I have the following input:
<?xml version="1.0" encoding="utf-8"?>
<NewTerms>
<newTerm>XPath</newTerm>
<newTerm>AutoValue</newTerm>
<newTerm>XPath</newTerm>
<newTerm>context</newTerm>
<newTerm>AutoValue</newTerm>
<newTerm>language files</newTerm>
<newTerm>AutoValue</newTerm>
<newTerm>.NET</newTerm>
<newTerm>XPath</newTerm>
</NewTerms>
I want to sort it, and it functions perfectly with the following:
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()">
<xsl:sort select="."/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The problem is I am getting (Obviously) a sorted output list with the elements with same values in repetition (e.g XPath, AutoValue). I want to have the sorted list without the repeated values. That is, I want to have each value only once in the sorted XML output.
Please any suggestions?
This stylesheet:
Output:
Note: Do not sort attributes and children together because you can’t output an attribute after you output a children.