Hi all,
 
I'm using xmlbeans-2.2.0 and saxonb8-6-1 and I'm trying to use the
XmlObject.selectPath function.
 
Here my xml document:
 
<bs:bookstore xmlns:bs="http://www.bsource.ch/bs";>
 <book>
   <id>1</id>
   <author>author1</author>
   <title>title1</title>
 </book>
 <book>
   <id>2</id>
   <author>author2</author>
   <title>title2</title>
  </book>
</bs:bookstore>
 
generated using XmlCursor object in the following way:
 
1) in Bookstore constructor
 
document = XmlObject.Factory.newInstance();
cursor = document.newCursor();
cursor.toNextToken();
cursor.beginElement("bookstore", namespace);
 
2) when I add a book to my bookstore object
 
public void add(Book book) throws BookstoreException
{
   if (book == null)        throw new ...
   if (document == null) throw new ...
 
   id++;
   book.setId("" + id);
 
   cursor.beginElement("book");
   cursor.insertElementWithText("id", book.getId());
   cursor.insertElementWithText("author", book.getAuthor());
   cursor.insertElementWithText("title", book.getTitle());
   cursor.toNextToken();
}
 
Now I'm trying to run the following piece of code:
 
XmlObject[] elems = null;
...
elems =
document.selectPath("$this/bs:bookstore/book[author='author2']/author");
if (elems.length == 0)
   throw new BookstoreException("no result found for the given path
expression");
 
but selectPath returns zero elems !
I've checked the xpath expression
(/bs:bookstore/book[author='author2']/author) with XMLSpy against the
same xml document and the xpath expression seems to be correct ... so I
don't understand because selectPath fails to return the results.
 
Could you give me please some hints on that ?
 
Regards
Patrizio
 


IMPORTANT:
This e-mail transmission is intended for the named
addressee(s)only.
Its contents are private, confidential and protected
from disclosure and should not be read, copied or
disclosed by any other person.
If you are not the intended recipient, we kindly ask
you to notify the sender immediately by telephone
(+41 (0)58 806 50 00), to redirect the message to the
account "[EMAIL PROTECTED]" and to delete this e-mail.
E-mail transmissions may be intercepted, altered or
read by unauthorized persons and may contain viruses.
Therefore, it is recommended that you use regular mail
or courier services for any information intended to be
confidential. However, by sending us messages through
e-mail, you authorize and instruct us to correspond by
e-mail in the relevant matter.
Thank you.

Reply via email to