If you can use XSLT 3.0, you can use tokenize()
, string-join()
, and sort()
...
<xsl:template match="rate">
<xsl:copy>
<xsl:value-of select="string-join(sort(tokenize(normalize-space(),';')),',')"/>
</xsl:copy>
</xsl:template>
If you can use XSLT 2.0, you can use tokenize()
and string-join()
, but you'll have to use xsl:sort
(or xsl:perform-sort
) to do the sorting...
<xsl:template match="rate">
<xsl:variable name="rates" as="item()*">
<xsl:for-each select="tokenize(normalize-space(),';')">
<xsl:sort data-type="text"/>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:copy>
<xsl:value-of select="string-join($rates,',')"/>
</xsl:copy>
</xsl:template>