xsl select distinct elements

After upgrading to xsl 2.0 and saxon 8, the saxon:distinct function no longer works.

The variable $languages looks like:


    <language>English</language>
    <language>Chinese</language>
    <language>English</language>
    <language>French</language>
    <language>French</language>

  

It contains 5 language elements, but we only want to process the 3 distinct languages.

In the past, I used the saxon:distinct function, specific to saxon. Other xsl processors have their own functions.


    
      <xsl:for-each select="saxon:distinct($languages/language)">
        language found: <xsl:value-of select="."/>
      </xsl:for-each>

For xsl 2.0, the above can be replaced with:


    <xsl:for-each select="distinct-values($languages/lang)">
      <xsl:value-of select="."/>
    </xsl:for-each>