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

RE: Retrieving sequence of unique strings from another

Subject: RE: Retrieving sequence of unique strings from another sequence
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 5 Jan 2010 19:09:45 -0000
RE:  Retrieving sequence of unique strings from another
Try:

<xsl:for-each-group select="$list" group-by=".">
  <xsl:sequence select="current-group()[last()=1]"/>
</xsl:for-each-group> 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: Houghton,Andrew [mailto:houghtoa@xxxxxxxx] 
> Sent: 05 January 2010 18:41
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Retrieving sequence of unique strings from 
> another sequence
> 
> I have a sequence of strings, e.g., ('abc', 'def', 'def', 
> 'ghi'), and I want to create a new sequence that will have 
> only the unique strings in it.  The XSL 2.0 function 
> distinct-values is not what I want because:
> 
>   <xsl:variable name="list" as="xsd:string*" select="('abc', 
> 'def', 'def', 'ghi')" />
>   <xsl:variable name="uniq" as="xsd:string*" 
> select="distinct-values($list)" />
> 
> will result in a sequence of ('abc', 'def', 'ghi') which is 
> not what I'm looking for.  What I am looking for is the 
> sequence ('abc', 'ghi').  Unix people will recognize that 
> distinct-values() returns the result of the uniq command 
> without any options.  While what I'm looking for is the 
> result of the uniq command with the -u option.
> 
> Can anyone suggest how I might use one or more XSL 2.0 
> functions to return only the unique strings.
> 
> 
> Thanks, Andy.

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.