A
Anna
Hi all.
I am using Jaxen to evaluate XPath expressions in Java.
I encountered problems when comparing results returned by jaxen with
results
returned by other XPath implementation - I was using Saxon.
Here is my example:
<p>
<span>text1</span>
</p>
<div>text2</div>
I want to get the first preceding element of the div element.
I apply the following XPath - //div/preceding::*[1]
Saxon results in span element matched.
Jaxen results in p element matched.
What I want is the span element.
From what I understood (I may be wrong), the difference in results is
because
Jaxen uses bredth first search, when saxon uses depth first search.
I can maybe construct something more specific to match the element I
want for Jaxen,but the problem is that my queries are already
complicated, and adding a lot more predicates slows the whole
evaluation drastically.
So I wondered if there is any elegant way to match nodes in Jaxen by
document order, in particular, match the closest preceding element to
a context element.
Sorry if this has been asked before, I've been searching for an answer
for a while, and didn't find anything.
Thank you very much for help.
Anna
I am using Jaxen to evaluate XPath expressions in Java.
I encountered problems when comparing results returned by jaxen with
results
returned by other XPath implementation - I was using Saxon.
Here is my example:
<p>
<span>text1</span>
</p>
<div>text2</div>
I want to get the first preceding element of the div element.
I apply the following XPath - //div/preceding::*[1]
Saxon results in span element matched.
Jaxen results in p element matched.
What I want is the span element.
From what I understood (I may be wrong), the difference in results is
because
Jaxen uses bredth first search, when saxon uses depth first search.
I can maybe construct something more specific to match the element I
want for Jaxen,but the problem is that my queries are already
complicated, and adding a lot more predicates slows the whole
evaluation drastically.
So I wondered if there is any elegant way to match nodes in Jaxen by
document order, in particular, match the closest preceding element to
a context element.
Sorry if this has been asked before, I've been searching for an answer
for a while, and didn't find anything.
Thank you very much for help.
Anna