This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Replacing all Occurences of a String
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Replacing all Occurences of a String
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Thu, 30 Aug 2001 14:33:20 -0400
- References: <001e01c13162$496079e0$3554a8c0@everyware.ch>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Roger,
If you construct your lookup table along the lines David suggested, you can
use keys to rationalize (and optimize) access to it.
So, try something like this in your dictionary.xml:
<months>
<month en="January" de="Januar" fr="Janvier"/>
<month en="February" de="Februar" fr="Fevrier"/>
[etc.]
</months>
Then, in your stylesheet
<xsl:variable name="dictionary" select="document('dictionary.xml')"/>
<!-- This does nothing but make the dictionary document accessible
to the transformation -->
<xsl:key name="month-en" match="month" use="@en"/>
<xsl:key name="month-de" match="month" use="@de"/>
<xsl:key name="month-fr" match="month" use="@fr"/>
<!-- These set up access to your dictionary -->
When your source string is the name of a month in English, get its German
equivalent by asking for
key('month-en', $englishstring)/@de
and, to go the other way,
key('month-de', $germanstring)/@en
This is a clean and easily-extensible way to manage the strings you need to
replace in and out.
Compress it even more if you know your languages will never step on each other:
<xsl:key name="month" match="month" use="@en"/>
<xsl:key name="month" match="month" use="@de"/>
<xsl:key name="month" match="month" use="@fr"/>
key('month', $string)/@de gives you German from English or French (or German)
key('month', $string)/@fr gives you French from English or German (or French)
Enjoy,
Wendell
At 12:03 PM 8/30/01, Chris wrote:
>Roger,
>Have a look at
>http://www.biglist.com/lists/xsl-list/archives/200008/msg01300.html for
>some ideas on internationalization....
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list