[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Unicode accented letters to simple ASCII equivalents

Subject: Re: [xsl] Unicode accented letters to simple ASCII equivalents
From: Liam R E Quin <liam@xxxxxx>
Date: Fri, 10 May 2013 13:25:45 -0400

On Fri, 2013-05-10 at 13:07 -0400, Jonina Dames wrote:
> Hi everyone,
> I'm trying to re-map any accented letters from Unicode (in the XML) to 
> simple, un-accented ASCII equivalents (in an output text file). Is there 
> a way to do this in XSLT 1.0?

It depends on several things:
(1) the normalization form of the input;
(2) what you mean by un-accented ASCII equivalents.
(3) whether you can call extension functions

I'm not trying to split hairs - for example C< (u with two strokes over
it, or two dots) should usually turn to ue without the accent, and if
you need all-seven-bit output C can turn to Ae or AE, a: to ss, and so

One way to handle this might be an XML file with specific characters in
an attribute and replacements in content (say), and use key() in XSLT to
look each character up in turn.

Watch that C) can be represented in two ways in Unicode - the precombined
character or an e followed by an acute accent. You can handle the
multiple-character case in XSLT 2 with replace(), and some XSLT 1
implementations might have a regular expression library available.

Normalizing the input first into a fully-decomposed form and then using
a regular expression, or using translate() to identify characters
outside the ASCII range and skipping them, might be simplest.

I won't speculate further because it really depends on the exact
software and environment and on your purpose and exact problem.


Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

Current Thread