My code is unable to sort the names, when 'use-character-maps' module is used. Without CharMap, I am able to get the required result.
Sorting should be based on CharMap character also, i.e., 'Anupam' should be the third author in result (my code is listing him at the end). Please suggest. (XSLT2 vesrion)
XML:
<article>
<aug>
<author><surname>Akhil</surname><fnm>GH</fnm></author>
<author><surname>Kishan</surname><fnm>TR</fnm></author>
<author><surname>Ánupam</surname><fnm>TP</fnm></author>
<author><surname>Abhi</surname><fnm>TD</fnm></author>
</aug>
</article>
XSLT:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" use-character-maps="chars"/>
<xsl:character-map name="chars">
<xsl:output-character character="Á" string="A"/>
</xsl:character-map>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="aug">
<aug>
<xsl:for-each select="author">
<xsl:sort select="surname"/>
<au><xsl:apply-templates select="surname"/><xsl:text> </xsl:text><xsl:apply-templates select="fnm"/></au>
</xsl:for-each>
</aug>
</xsl:template>
</xsl:stylesheet>
Required Result:
<article>
<aug>
<author><surname>Abhi</surname><fnm>TD</fnm></author>
<author><surname>Akhil</surname><fnm>GH</fnm></author>
<author><surname>Anupam</surname><fnm>TP</fnm></author>
<author><surname>Kishan</surname><fnm>TR</fnm></author>
</aug>
</article>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…