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.
///Peter
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list