xsl-list
[Top] [All Lists]

Re: current context preceding-sibling then following-sibling

2005-03-07 12:47:38
Karl Stubsjoen wrote:
the context of the following-sibling following a preceding-sibling
should result you in the context of the current sibling?

It depends. Note:

The short of it is, I am comparing the preceding-sibling with the
current.  The preceding-sibling must contain the code "XYZ" when the
current contains the code "WXY".

If you talk about "content", be aware that looking up elements
both in the preceding-sibling and the following-sibling axis
are likely to produce node sets, and the stringification of a
node set will result in the string value of the first element in
document order. An example XML
 <foo>
   <bar>1</bar>
   <bar>2</bar>
   <bar id="3">3</bar>
 </foo>
The statement
 <xsl:value-of select="
   /foo/bar[(_at_)id='3']/preceding-sibling::bar
   /following-sibling::bar"/>

Will get you a 2, not a 3 as you might expect.
If in doubt, use a position predicate
 <xsl:value-of select="
   /foo/bar[(_at_)id='3']/preceding-sibling::bar[1]
   /following-sibling::bar[1]"/>

J.Pietschmann


--~------------------------------------------------------------------
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>
--~--