Re: XSL Abbreviations

Subject: Re: XSL Abbreviations
From: Matt Sergeant <matt@xxxxxxxxxxxx>
Date: Mon, 3 Jul 2000 15:29:34 +0100 (BST)
On Mon, 3 Jul 2000, Ben Pickering wrote:

> >Just reading the XPath docs wrong, that's all. // is equivalent to
> >/descendant-or-self::node()/ - note the leading and trailing slashes. You
> >could try ..//.[generate-id(.) = $node]
> 
> I tried you suggestion, but it doesn't seem to work, at least in XT.

Well it smells like a bug, but its hard to say without seeing your
code. The dot is simply equivalent to self::node() - i.e. no change
whatsoever in node position. It is specifically in the spec just for this
sort of hack. Of course you could try "..//self::node()[generate-id(.) =
$node]".

> Plus, can you explain the siginificance of the slashes, for curiosity's 
> sake:  I get that the leading '/' selects the document root (which is why 
> you need to say './/' rather than just '//' for the context node's parent; 
> the '//' includes a built-in '/' in front of descendant-or-self.)

You're trying to infer too much meaning, by the looks of things. Just
think of it as a kind-of macro expansion. The leading slash only selects
the root when its at the very beginning of a path (i.e. its an Absolute
Location Path). The slashes simply separate the Steps, like semi-colons in
a programming language separate lines of code. "//" is a full step, but it
also includes the slashes because otherwise you'd be writing "///" and
XPath would be even _more_ confusing :-)

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


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


Current Thread