XPath and indexes

?

--

Image I've got a schema similar to this:
<Root>
<Xs>
<X>X Item 1</X>
<X>X Item 2</X>
<X>X Item 3</X>
<X>X Item 4</X>
</Xs>
<Ys>
<Y>Y Item 1</Y>
<Y>Y Item 2</Y>
<Y>Y Item 3</Y>
<Y>Y Item 4</Y>
</Ys>
</Root>

I would like an (Infopath 03 compatible) XPath expression, such that
when it's executed in the context of a Y node, returns the
corresponding X node. So if executed in <Y>Y Item 3</Y>, it returns
<X>X Item 3</X>.
Anyone have any idea how to accomplish this? Is it even possible.

I'm thinking the solution is something like:
/Root/Xs/X[position() = ???]
I just have no idea what to put in the ???, how to I get the position
of the initial context node?
 
G

Greg Collins

If this is in the context of a Y node, and the content of X and Y will be
identical, then you would use something like:

/Root/Xs/X[. = current()]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top