|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Character conversion in stylesheet
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"> !...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
|
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








