|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XSLT and Unicode character functions --XSLT v 1.1?--
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








