[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Finding the closest node (was Re: inconsistent Precedi

Subject: Finding the closest node (was Re: inconsistent Preceding-Siblingbehaviour when nested in For-Each
From: Peter Flynn <peter@xxxxxxxxxxx>
Date: Tue, 05 Nov 2002 00:07:48 +0000
closest node
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 |

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.


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.