|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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:
separator="/"
and:
separator="{'/'}"
give exactly the same thing.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








