Page 1 of 1

How to generate codepoints with xslt 1.0

Posted: Fri Jan 13, 2006 1:30 pm
by Toralion
Hello,
I 'm searching for a solution to create unicode codepoints with xslt 1.0 (converting xml2rtf).

XSLT 2.0 (or rather Xpath2) provides a function "string-to-codepoint" but unfortunately I have to use 1.0.

Does anyone know any other solution to convert a unicode character to the adequate number?
Maybe any function provided by xalan, msxsl and/or exsl?

Regards Tora

P.S.
This is how it works in 2.0.:
<xsl:template name="StringToCodePoint">
<xsl:param name="stringToParse" />
<xsl:param name="stringToken" select="string-to-codepoints($stringToParse)" />
<xsl:for-each select="$stringToken">
<xsl:choose>
<xsl:when test=". < 256">
<xsl:value-of select="codepoints-to-string(.)" />
</xsl:when>
<xsl:when test=". > 32767">
<xsl:text>\u</xsl:text>
<xsl:value-of select=".-65536" />
<xsl:text>\'3f</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\u</xsl:text>
<xsl:value-of select="." />
<xsl:text>\'3f</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:value-of select="$stringToParse" />
</xsl:template>