[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?--

Subject: XSLT and Unicode character functions --XSLT v 1.1?--
From: Eric Vermetten <EVermetten@xxxxxxxxxxxxx>
Date: Tue, 30 Jan 2001 15:35:41 -0000
xslt unicode character
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="&#8364;" >

	<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' &lt; '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') &lt; 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 &#xA3; &#xA5; &#x24; or any other appropiate alternative!

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.