[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Split and Found unique values


Subject: Re: [xsl] Split and Found unique values
From: "cruscio\@libero\.it" <cruscio@xxxxxxxxx>
Date: Thu, 7 Dec 2006 23:08:46 +0100

In XSLT1 it works good. It is joining all values but I have problems now with
split and find unique values.
This is my function. $seen variable should contain all processed values to
find unique:

<xsl:template name="Split">
  <xsl:param name="strInput"/>
  <xsl:param name="strDelimiter" select="'-'"/>
  <xsl:param name="processed"/>
  <xsl:variable name="strNextItem"
select="substring-before($strInput,$strDelimiter)"/>
  <xsl:variable name="strOutput"
select="substring-after($strInput,$strDelimiter)"/>

  <xsl:variable name="seen" select="concat($strNextItem,'-',$processed)"/>

  <xsl:choose>
    <xsl:when test='contains($strInput,$strDelimiter) and
(not(contains($strNextItem,$seen)))'>
      <xsl:element name='OPTION'>
       <xsl:value-of select="$strNextItem"/>
      </xsl:element>

      <xsl:call-template name="Split">
       <xsl:with-param name="strInput" select="$strOutput"/>
       <xsl:with-param name="strDelimiter" select="$strDelimiter"/>
       <xsl:with-param name="processed" select="$seen"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:if test="not(contains($strInput,$seen))">
        <xsl:element name='OPTION'>
         <xsl:value-of select="$strInput"/>
        </xsl:element>
       </xsl:if>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>





---------- Initial Header -----------

Current Thread