removing_duplicated_data

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="text()" name="distinctSubstrings"> <xsl:param name="pText" select="."/> <xsl:param name="poutDelim"/> <xsl:param name="pFoundDistinctSubs" select="','"/> <xsl:param name="pCountDistinct" select="0"/> <xsl:if test="$pText"> <xsl:variable name="vnextSub" select="substring-before(concat($pText, ','), ',')"/> <xsl:variable name="vIsNewDistinct" select= "not(contains(concat($pFoundDistinctSubs, ','), concat(',', $vnextSub, ',')))"/> <xsl:variable name="vnextDistinct" select= "substring(concat($poutDelim,$vnextSub), 1 div $vIsNewDistinct)"/> <xsl:value-of select="$vnextDistinct"/> <xsl:variable name="vNewFoundDistinctSubs" select="concat($pFoundDistinctSubs, $vnextDistinct)"/> <xsl:variable name="vnextOutDelim" select="substring(',', 2 - ($pCountDistinct > 0))"/> <xsl:call-template name="distinctSubstrings"> <xsl:with-param name="pText" select="substring-after($pText, ',')"/> <xsl:with-param name="pFoundDistinctSubs" select="$vNewFoundDistinctSubs"/> <xsl:with-param name="pCountDistinct" select="$pCountDistinct + $vIsNewDistinct"/> <xsl:with-param name="poutDelim" select="$vnextOutDelim"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet>
XSLT 1.0 to omit duplicate value on a comma-separated string.

INPUT :- <t>asdf,asdf,weqt,fd,asdf,asdf</t>
OUTPUT :- asdf,weqt,fd

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.