Subject: Re: [xsl] preceding-sibling inside for-each appears to fail From: Ted Stresen-Reuter <tedmasterweb@xxxxxxx> Date: Sun, 9 Feb 2003 22:50:50 -0600 |
<p>checking: accents_db</p> <p>preceding sibling = </p> <p>following sibling = accept_language</p> <p>checking: accept_language</p> <p>preceding sibling = </p> <p>following sibling = add_anchors_to_excerpt</p> <p>checking: add_anchors_to_excerpt</p> <p>preceding sibling = accents_db</p> <p>following sibling = allow_double_slash</p> <p>checking: allow_double_slash</p> <p>preceding sibling = accept_language</p> <p>following sibling = allow_in_form</p>
<p>checking: accents_db</p> <p>preceding sibling = </p> <p>following sibling = accept_language</p> <p>checking: accept_language</p> <p>preceding sibling = </p> <p>following sibling = add_anchors_to_excerpt</p> <p>checking: add_anchors_to_excerpt</p> <p>preceding sibling = </p> <p>following sibling = allow_double_slash</p> <p>checking: allow_double_slash</p> <p>preceding sibling = </p> <p>following sibling = allow_in_form</p>
Hi Ted,
Ted Stresen-Reuter wrote: ...
<p>preceding sibling = <xsl:value-of select="preceding-sibling::attribute/@name" /></p>
...
As you can see, following-sibling successfully returns the following sibling, but preceding-sibling always returns the first node rather than the preceding-sibling node.
You need to remember two things here. First, XPath expressions normally return node-sets. Second, node-sets are processed in document order. So your select expression is returning the first member of the set "preceding-sibling::attribute/@name", which is always the first in document order. But if you put a positional predicate in as part of an XPath step then that is applied in the order of the current axis, so try
<p>preceding sibling = <xsl:value-of select="preceding-sibling::attribute[1]/@name" /></p>
Hope this helps -
Francis.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] preceding-sibling inside , Francis Norton | Thread | Re: [xsl] preceding-sibling inside , Francis Norton |
[xsl] Full path to a node, Ronny Haryanto | Date | Re: [xsl] Problems copying elements, Dimitre Novatchev |
Month |