xsl-list
[Top] [All Lists]

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

2013-05-10 12:25:49
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 ü (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 Æ can turn to Ae or AE, ẞ to ss, and so
on.

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 é 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

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--