[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Character conversion in stylesheet

Subject: Re: Character conversion in stylesheet
From: Michael Müller-Hillebrand <info@xxxxxxxxxxxxx>
Date: Fri, 2 Jul 2004 09:49:19 +0200
xml character conversion
On 01.07.2004 (14:34 Uhr -0500), Belkin, Alla wrote:

>Hello,
>I have to check if I have some of the extended ASCII (UTF8) characters in the input XML file.
>So, I am using stylesheet for transformation XML input file to the different format of the XML file.
>Can I do something efficient to check for special characters in some of the fields in the input XML file and to convert those specific characters, (for example, è to e) in the output file?

To check if you have non-ASCII characters you can remove all ASCII chars from a string and check whether the result is empty. First create a string variable which contains all valid characters:

<xsl:variable name="ascii-chars">&#32;!...01234568789..ABCD...abcd...</xsl:variable>

For the test you would use the translate() function:

<xsl:if test="translate(., $ascii-chars, '') = ''">
...
</xsl:if>

To change non-ASCII chars to ASCII chars you have to know which characters to change. This is easy if you know the input is ISO-8859-1 or some other limited range of characters. You would use the translate() function.

If any valid UTF-8 char could be in the input, there is no easy solution, because in many languages single characters can only be transliterated to more than one ASCII character.

- Michael
--
________________________________________________________________
Michael Müller-Hillebrand, Dipl.-Ing.    <http://cap-studio.de/>
    FrameMaker, FrameScript, XML/XSL,... Publishing-Lösungen

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.