Thank you this is what I looking for !



2009/3/26 Michael Kay <mike@saxonica.com>
The union operator (|) in XPath requires both operands to be node-sequences, but your second operand is a number.
 
You can use the comma operator (,) in XPath 2.0. The result will then be a sequence of nodes followed by a number. This is not a type that XPath 1.0 recognizes, so you can't handle it using the JAXP interface. But it would work fine using s9api.
 
In s9api it would work like this:
 
Processor proc = new Processor();
DocumentBuilder builder = proc.newDocumentBuilder();
XdmNode document = builder.build(....);
XPathCompiler xpc = proc.newXPathCompiler();
XPathSelector xps = xpc.compile("/BOOKLIST/BOOKS/ITEM, sum(//BOOKLIST/BOOKS/ITEM/PAGES)").load();
xps.setContextItem(document);
for (XdmItem xi : xps) {
  ... process the next item in the result ...
}
 
Michael Kay
http://www.saxonica.com/


From: Erik Rens [mailto:mail2rens@gmail.com]
Sent: 26 March 2009 15:03
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Fwd: Xpath 2.0 sequences and Saxon examples problems.

I want to sent more then one expression to xpath something like this.

expression = "/BOOKLIST/BOOKS/ITEM|sum(//BOOKLIST/BOOKS/ITEM/PAGES)";

thats the problem my evaluation function expects a NodeSet and for the sum a String. Ofcourse I can split those on the'  |  ' character en use two return types XPathConstants.NodeSet and XPathConstants.Number. But I prefer to handle this in one expression. So I thought XPath 2.0 can to this for me.

So this is the file I used from Saxon http://kickjava.com/src/ApplyXPathJAXP.java.htm examples.

Sorry but I dont understand how I can use s9api to solve this problem..

thanks.





------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/saxon-help