# EXSLT - set:distinct

Implementer Page: set.distinct.html Function Package: set.distinct.zip #### Function Syntax
    node-set set:distinct(node-set)
#### Template Syntax
    <xsl:call-template name="set:distinct">
       <xsl:with-param name="nodes" select="node-set" />
    </xsl:call-template>
The `set:distinct` function returns a subset of the nodes contained in the node-set NS passed as the first argument. Specifically, it selects a node N if there is no node in NS that has the same string value as N, and that precedes N in document order. The `set:distinct` template applies templates to these nodes in `set:distinct` mode. By default, the nodes are copied by this template, so that a result tree fragment consisting of the nodes is returned. ## Implementations The following XSLT processors support `set:distinct`: 4XSLT, from 4Suite. (version 0.12.0a3) SAXON from Michael Kay (version 6.3) jd.xslt from Johannes Döbler (version 1.0.9) Xalan-J from Apache (version 2.4.D1) Implementations of `set:distinct` are available in the following languages: XSLT Template (by Jeni Tennison) EXSLT Function (by Jeni Tennison) ## Examples ### Function The following example shows how to use the `set:distinct` function: #### Source
    <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
    <!--  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
    <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>

http://www.exslt.org/set/functions/distinct/index.html last modified 2002-11-12