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

Re: Re: RE: Postional predicates de-mystified

Subject: Re: Re: RE: Postional predicates de-mystified
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 4 Jan 2002 14:42:29 +0000
Re:  Re: RE: Postional predicates de-mystified
Dimitre wrote:
> This is indeed quite powerful, however in order to obtain the "path"
> to the current node there still must be:
> 1. The starting "/" for the root node. This could be obtained by
> changing the expression to:
>    <xsl:value-of select="for $e in ancestor::node() return name($e)"
>                  separator="/" />

I think that rubs up against the problem that the name() function
actually returns an empty sequence for the document node (new
terminology 'root node' is 'document node' in XPath 2.0), rather than
an empty string (this is documented as an XPath 1.0 -> XPath 2.0
incompatibility). Therefore including the root node actually makes no
difference to the sequence generated, and you get exactly the same
thing as you would by just selecting elements.

You could do:

  <xsl:value-of select="('', for $e in ancestor::* return name($e))"
                separator="/" />

I think, or:

  <xsl:value-of select="('', for $e in ancestor-or-self::*
                                 return name($e))"
                separator="/" />

if you want to include the current element.

[snip absolutely correct points on the drawbacks of generating a path
like this as more than just an exercise]

>  4. Maybe I'm wrong, but shouldn't this be: separator="'/'" ?

The separator attribute is an attribute value template - if you want
to compute the separator dynamically you use {}s, as with
xsl:sort/@order, for example. So:




give exactly the same thing.



Jeni Tennison

 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.