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

Re: unique elements from different sourcefile

Subject: Re: unique elements from different sourcefile
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 3 Jan 2002 16:01:42 +0000
distinct unique diff
Thomas Winkler asked:
> all i want is getting all possible children of a specific element.
> since the content model of some elements can be very complicated
> (such as "head"), most xpath axis don't work.

Ken's already produced an XSLT 1.0 answer. For interest, possible XSLT
2.0 solutions would be:

Using the distinct-values() function:

  <xsl:value-of select="distinct-values(.//element-name/@name)"
                separator=", " />

If you wanted to do something further with the element-name elements,
the xsl:for-each-group element would be more use:

  <xsl:for-each-group select=".//element-name"
                      group-by="@name">
    <xsl:value-of select="@name" />
    <xsl:if test="position() != last()">, </xsl:if>
  </xsl:for-each-group>

Although you could just use xsl:for-each with distinct-values() if you
wanted:

  <xsl:for-each select="distinct-values(.//element-name/@name)">
    <xsl:value-of select="." />
    <xsl:if test="position() != last()">, </xsl:if>
  </xsl:for-each>
                
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.