Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Character conversion in stylesheet

From: Michael M&#xFC;ller-Hillebrand <info@------------->
To:
Date: 7/2/2004 11:49:00 AM
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, &#xE8; 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&#xFC;ller-Hillebrand, Dipl.-Ing.    <http://cap-studio.de/>
    FrameMaker, FrameScript, XML/XSL,... Publishing-L&#xF6;sungen


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent