This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]