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: XPath expression to derive list of distinct element names


> From: David Carlisle <davidc@nag.co.uk>
> doesn't
>   select="$x//*[not(following::*[name()=name(current())])]"
> select all the element nodes in $x that are the last occurrence of an
>   element of that name?

As far as i can see not, unless you redefine the current() function.
Why not using the Muenchian method?

 <xsl:key name="sibling-names" match="*" use="concat(generate-id(..),'#',name())"/>
 ...
    select="*[generate-id()=generate-id(key(generate-id(..),'#',name())[1])]"

Untested. There are some obvious optimizations.

I'm not sure whether this is what the original poster wanted
but HTH anyway.

I also hope Jeni is absorbed with other stuff enough that i
can beat her this time...  :-)

J.Pietschmann

 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]