[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi,
I want to convert the decimal integers returned by the XPath 2 function fn:string-to-codepoints into a sequence of strings that use the conventional "U+..." hexadecimal notation of the Unicode standard.
Neither the XPath 2 spec nor the XSLT FAQ offered a complete solution to this problem, so I developed my own. It is working, but I wonder how to integrate these two functions, which convert a decimal integer into its hexadecimal equivalent, into a single function which still returns just one string:
<xsl:function name="my:decimal-to-hex" as="xs:string">
<xsl:param name="decimalNumber"/>
<xsl:sequence select="string-join(my:decimal-to-hex-internal($decimalNumber),'')"/>
</xsl:function>
Yves
[xsl] Decimal to hexadecimal in one function (XSLT/XPath 2)
Subject: [xsl] Decimal to hexadecimal in one function (XSLT/XPath 2) From: Yves Forkl <Y.Forkl@xxxxxx> Date: Tue, 17 Feb 2009 12:22:43 +0100 |
Hi,
I want to convert the decimal integers returned by the XPath 2 function fn:string-to-codepoints into a sequence of strings that use the conventional "U+..." hexadecimal notation of the Unicode standard.
Neither the XPath 2 spec nor the XSLT FAQ offered a complete solution to this problem, so I developed my own. It is working, but I wonder how to integrate these two functions, which convert a decimal integer into its hexadecimal equivalent, into a single function which still returns just one string:
<xsl:function name="my:decimal-to-hex" as="xs:string">
<xsl:param name="decimalNumber"/>
<xsl:sequence select="string-join(my:decimal-to-hex-internal($decimalNumber),'')"/>
</xsl:function>
<xsl:function name="my:decimal-to-hex-internal" as="xs:string+"> <xsl:param name="decimalNumber"/> <xsl:variable name="hexDigits" select="'0123456789ABCDEF'"/> <xsl:if test="$decimalNumber >= 16"> <xsl:sequence select="my:decimal-to-hex-internal(floor($decimalNumber div 16))"/> </xsl:if> <xsl:sequence select="substring($hexDigits, ($decimalNumber mod 16) + 1, 1)"/> </xsl:function>
Yves
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Finding Untagged content , Michael Kay | Thread | Re: [xsl] Decimal to hexadecimal in, Michael Müller-Hille |
[xsl] Finding Untagged content in X, Ganesh Babu N | Date | Re: [xsl] Decimal to hexadecimal in, Michael Müller-Hille |
Month |