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

Re: Getting a distinct list of node names

Subject: Re: Getting a distinct list of node names
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Wed, 17 Dec 2003 07:08:43 +0100
preceding sibling distinct
"David Tolpin" <dvd@xxxxxxxxxxxxxx> wrote in message
news:200312162015.hBGKFqkZ014006@xxxxxxxxxxxxxxxxxxxxxx
> > > > node:definition/*[not(name() = name(preceding-sibling::*))]
> > >
> > >Why should this take a long time?  Isn't this the same as
> > >
> > >*[not(name() = name(preceding-sibling::*[last()]))]
> >
> > preceding-sibling::*[last()]), which therefore won't de-duplicate
properly.
> >
> > So it won't take a long time, and it won't work either.
>
> But is there a way to express it as a single predicate? I mean, not equal
to the name
> of any preceding-sibling? Just out of curiousity.

Yes, either by using keys (e.g. the Muenchian method) or after sorting the
node-set then the comparison must be for inequality of the names of the
current node and its immediate preceding sibling:

   not(name() = name(preceding-sibling::*[1]))


In case the node-set is not sorted and keys are not used, this cannot be
expressed in a single XPath expression.

If we had to compare just the values and not the names, then the single
XPath expression is:

   not(. = preceding-sibling::*)


but finding all elements with non-duplicate content in this way takes O(N^2)



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

Resume:
http://fxsl.sourceforge.net/DNovatchev/Resume/Res.html




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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.