xsl for each sort uniq,thomas saverio, xml%%%xsl for each sort uniq - Re: sort

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

Re: sort | uniq via keys

Subject: Re: sort | uniq via keys
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Thu, 14 Feb 2002 12:32:02 -0500
xsl for each sort uniq
My post from February 11,2002, with the title "Re:  Many sets of eyes "
shows how to get a unique list of elements sorted by names (unique meaning
that each element name occurs once).  That should be close enough to get you
started.

Cheers,

Tom P

[Saverio Perugini]>
> I am interested in a sorted and uniqed list of all element names in
> an XML file (except for the root), similar to `sort | uniq' in UNIX.
>
> e.g., in the following data,
>
> <db>
>    <a>...</a>
>    <z>...</z>
>    <g>...</g>
>    <j>
>       <f>...</f>
>       <z>...</z>
>       <a><o>...</o></a>
>    </j>
>    <b>...</b>
>    <b>...</b>
> </db>
>
> I'd like the following list
>
> a
> b
> f
> g
> j
> o
> z
>
> I am trying to achieve this with keys (unless someone can direct me to
> a simpler method).  The following is an initial attempt.
>
> <xsl:key name="features" match="*" use="name()"/>
>
> <xsl:template match="/db">
>
> <xsl:for-each select="following::*[count (. | key('features', name())[1])
= 1]">
>    <xsl:sort select="name()" />
>    <xsl:value-of select="name()" /><xsl:text>
> </xsl:text>
> </xsl:for-each>
>
> </xsl:template>
>
> <xsl:template match="text()"/>
>
> This is not working out however.  It returns an empty file.  Does this
> appear to be correct?
>



 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.