removing_duplicated_data_xslt2.0

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:myfn="MY:FN" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:function name="myfn:sortCSV" as="xs:string*"> <xsl:param name="csvString" as="xs:string"/> <!-- Split up string and remove duplicates --> <xsl:variable name="values" select="distinct-values(tokenize($csvString, '\s*,\s*'))" as="xs:string*"/> <!-- Return all elements, sorted --> <xsl:for-each select="$values"> <xsl:sort/> <!-- We don't return empty strings --> <xsl:sequence select=".[.!='']"/> </xsl:for-each> </xsl:function> <xsl:variable name="input"> <xsl:value-of select="input" /> </xsl:variable> <xsl:template match="/"> <!-- Let's test our function --> <xsl:value-of select="myfn:sortCSV($input)" separator=","/> </xsl:template> </xsl:stylesheet>
XSLT 2.0 to omit duplicate value on a comma-separated string

INPUT :- <input>asdf,asdf,weqt,fd,asdf,asdf</input>

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.