Subject: Finding the closest node (was Re: [xsl] inconsistent Preceding-Sibling behaviour when nested in For-Each From: Peter Flynn <peter@xxxxxxxxxxx> Date: Tue, 05 Nov 2002 00:07:48 +0000 |
Jeni Tennison wrote: [...]
When you collect together all the preceding-siblings of a node, and handle them in document order the first of those nodes is the first of the siblings -- the first child of the parent -- not the closest of those siblings.
If you want to get the *closest* of the siblings then you can use [last()] as follows:
<xsl:value-of select="(preceding-sibling::person/name)[last()]" />
What if I want to get the closest of some possible (specific) subset of ancestors? eg (this is Docbook, let us say the current node is an <xref> in a <para> at some depth within one of the following):
<xsl:variable name="anchor" select="ancestor::sidebar | ancestor::warning | ancestor::note | ancestor::orderedlist | ancestor::itemizedlist | ancestor::variablelist | ancestor::varlistentry | ancestor::listitem | ancestor::procedure | ancestor::step | ancestor::footnote"/>
Unfortunately, XPath returns the remotest node (the earliest in document order). For example, if the current node is in a step in a procedure, I need a variable set to that step, not to the whole procedure. Ignore for the moment the possibility of nested lists.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] inconsistent Preceding-Si, Alan Stein | Thread | Re: Finding the closest node (was R, G. Ken Holman |
[xsl] Parameter based transformatio, Damian Clark | Date | RE: [xsl] xsl:include of a variable, Richard Lander |
Month |