Custom Search
Logiclabz

Comma Separation in XSLT

  

<xsl:template name="Splitter">
<!-- Parameter TotalStr Contains Whole String as 1,2,3,4,5.... -->
    <xsl:param name="TotalStr"/>
<!-- variable SplieStr stores first splitted string from TotalStr -->
    <xsl:variable name="SplitStr" select="substring-before($TotalStr,',')"/>
    <xsl:choose>
<!-- if SplitStr is not null -->
        <xsl:when test="string-length($SplitStr) > 0">
<!-- The Process with Splitted String --> 
            <td><xsl:value-of select="$SplitStr"/></td>
<!-- Recurrsive call to get all sub-strings -->
            <xsl:call-template name="Splitter">
                <xsl:with-param name="TotalStr">
                <xsl:value-of select="substring-after($TotalStr,',')"/>
               </xsl:with-param>
            </xsl:call-template>
       </xsl:when>
 <!-- if SplitStr is null -->
        <xsl:otherwise>
             <td><xsl:value-of select="$TotalStr"/></td>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>



  


Leave a reply




Do you like this post?