This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
XSLT and Unicode character functions --XSLT v 1.1?--
- To: "'xsl-list-digest at lists dot mulberrytech dot com'" <xsl-list-digest at lists dot mulberrytech dot com>
- Subject: [xsl] XSLT and Unicode character functions --XSLT v 1.1?--
- From: Eric Vermetten <EVermetten at nl dot alpnet dot com>
- Date: Tue, 30 Jan 2001 15:35:41 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hello all,
XML/XSLT works with Unicode, and while you can equate any given
character with one other special one like this:
<xsl:variable name="test-char" select="€" >
<xsl:if test="substring(., 1 ) = $test-char" >
<!-- do something usefull here -->
</xsl:if>
It is not possible do a range of tests based on
unicode numbers. Also, it is not possible to do simple
comparisons of characters based on their Unicode number, like:
<xsl:if test="'a' < 'b'" >
The above test, of course, does not do character comparison
in XSLT because the string
arguments 'a' and 'b' are convered, by an implicit call of
the number() function, to NaN.
What does work is the use extension functions like the two below:
<msxsl:script implements-prefix="local" language="JScript">
<![CDATA[
function UNInumber(xmlchar)
{
var s = new String(xmlchar);
return s.charCodeAt(0);
}
function num2char(num)
{
var s = String.fromCharCode(num)
return s;
}
]]>
</msxsl:script>
Now you can say:
<xsl:if test="local:UNInumber('a') < local:UNInumber('b') >
These functions are very minimalistic and have functional equivalent
counterparts in many languages such as Visual Basic, C++ and Java.
_______________________________________________________________
My question is simple:
XML/XSLT is, internally (and externally through different
encodings), based on Unicode character handling.
Then wouldn't it be logical and desirable that the two functions
given here be part of the standard XSLT function reportoire?
(e.g. XSLT v1.1)?
Adding these two functions would enhance portability and,
so I would presume, implementation can be done in a jiffy.
I've been reading the XSL-digest list for quite some time now
and that is why I'm asking you, XSLT/XML users, developers alike,
for your thoughts on this.
Regards,
Eric Vermetten
P.S. For anyone outside the 12 designated countries, choose as
test-char £ ¥ $ or any other appropiate alternative!
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list