EXSLT - set:distinct - Use Case 1

Category: example
XML Definition: set.distinct.xml
Function or Template: function

Use Case

Source (view)

<doc>
   <city name="Paris"
         country="France" />
   <city name="Madrid"
         country="Spain" />
   <city name="Vienna"
         country="Austria" />
   <city name="Barcelona"
         country="Spain" />
   <city name="Salzburg"
         country="Austria" />
   <city name="Bonn"
         country="Germany" />
   <city name="Lyon"
         country="France" />
   <city name="Hannover"
         country="Germany" />
   <city name="Calais"
         country="France" />
   <city name="Berlin"
         country="Germany" />
</doc>

Stylesheet (view)

<!--  Test exslt:distinct  -->
<xsl:template match="/">
   <out>
      <all-countries>
:
             <xsl:for-each select="//@country">
            <xsl:value-of select="." />
;
    
         </xsl:for-each>
      </all-countries>
:
        <distinct-countries>
:  
             <xsl:for-each select="set:distinct(//@country)">
            <xsl:value-of select="." />
;
    
         </xsl:for-each>
      </distinct-countries>
   </out>
</xsl:template>

Result (view)

<out xmlns:set="http://exslt.org/sets">
   <all-countries>:
    France;
    Spain;
    Austria;
    Spain;
    Austria;
    Germany;
    France;
    Germany;
    France;
    Germany;
    </all-countries>
:
     <distinct-countries>:  
    France;
    Spain;
    Austria;
    Germany;
    </distinct-countries>
</out>

Change History

Previous Version: ..NaN.html

VersionModifiedByDetails
12001-04-28Mike Kay

Tests functionality of set:distinct().

http://www.exslt.org/set/functions/distinct/set.distinct.use-case.1.html last modified 2001-04-28