The precise scenarios you mention are explained and distinguished in
Roger Costello's XPath 1.0 tutorial which you can get at
www.xfront.com.
On Sun, May 27, 2012 at 11:21 PM, Jorge
<chocolate(_dot_)camera(_at_)gmail(_dot_)com> wrote:
Hi,
When I learned that the Xpath path "A//B" returns all B nodes in A context, I
assumed that appending an N index number would return the Nth node in that
list.
I.e. using the following snippet as the source XML to be transformed
<article>
<p>1st paragraph</p>
<p>2nd paragraph</p>
</article>
<article>
<p>3rd paragraph</p>
<p>4rth paragraph</p>
</article>
I assumed //p[2] would return only "<p>2nd paragraph</p>", whatever the
hierarchy looks like.
I now see I was wrong, and instead returns all nodes on the Nth position in
their respective tree level. (i.e. returns "<p>2nd paragraph</p>, <p>4rth
paragraph</p>").
In order to mimic the behavior I originally expected, I can only think of
creating a variable, assigning all p element nodes to it, and from then on
use that variable to get the single Nth node inside the variable's context.
I.e., if I wanted to get the "4rth paragraph" irrespectively of the tree, I
could use this XSLT
<xsl:variable name="PARAGRAPHS" select="//p"/>
<copy-of>
<xsl:value-of select="$PARAGRAPHS/p[4]"/>
</copy-of>
Is there any other way more straight?
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--