> You don't really have a current node-set at the time that you are
> evaluating position(), hence you get weird results.  Note that there is
> a different between a node-set and the node's list of siblings.  You are
> better off to do something like:
>       XPath xp2 = new XPath( "count(preceding-sibling::b)+'1'", null,
> null, XPath.SELECT );

I know. However, I was aiming for expression "position()" to operate within
the context of xp1. The expressions "/a/b" and "position()" are given - how
can you use org.apache.xpath to calculate expected results in Java is the
question.

I'm assuming this is a built-in functionality of the org.apache.xpath
because I see Xalan performing exactly the same thing in its implementation
of XSLT's for-each.


Reply via email to