>But sometimes I want to use the sum function of XPath with the same
evaluation function, but thats not possible beacuse it returns a NODESET and not
a String what XPath use the sum function.
In the JAXP XPath interface, you declare the result
type you expect the XPath expression to return. If the expression is returning a
number (which is what sum() returns), then declare the return type as
XPathConstants.NUMBER instead of XPathConstants.NODESET.
Alternatively: the JAXP interface was designed for
XPath 1.0, and it really doesn't work that well with XPath 2.0. You might find
that Saxon's s9api API is a lot more flexible.
>I couldn't get
which example is the solution for me, all the examples except one look like a
Yes, there aren't that many examples around. Very
often, XPath expressions invoked directly from Java are very simple, which
probably accounts for this.
>the error message "Supplied node must be built using the same or a
This means that the XPathFactory you are using has a
different underlying Saxon Configuration from the one that was used to build the
source document being queried. This is a symptom of the fact that the APIs are
very disconnected. Using s9api makes it much easier to avoid this kind of
If you want help diagnosing the problem, however, it
helps to show us your code.
I have a question about XPath2.0. I used xpath 1.0 in Java to
get some information of a xml file. Nothing news. Some times I use an
retrieve a nodelist : doc/entry/Number. So when I use
the evaluate function with XPathConstants.NODESET it will return NodeList.
Then i use a for loop
to iterate. But sometimes I want to use the sum
function of XPath with the same evaluation function, but thats not possible
beacuse it returns a NODESET and not a String what XPath use the sum function.
So I read on the Internet and I thought meaby XPath 2.0 could help me because
it can return sequences. I download the free libary of Saxon 220.127.116.11 and use
some examples to get it up and running. I couldn't get which example is the
solution for me, all the examples except one look like a xpath1.0
implementation. So meaby ApplyXPathJAXP.java is what I need, but when I want
to run this example the error message "Supplied node must be built using the
same or a compatible Configuration" appear when the function
"xpath.compile(xpathExpressionStr);" is executed.
I tried to solve the
problem but it didn't make sense to me. So can someone tell me if XPath 2.0 is
the solution for me?!. And how I can solve my problem if the is the right way
? I have to use it in Java 1.5 and not in XSLT.
Also I want to use more
expressions in XPath.