[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How does XSLT deal with international characters?

Subject: Re: How does XSLT deal with international characters?
From: Goetz Bock <bock@xxxxxxxxxxx>
Date: Wed, 2 May 2001 01:22:17 +0200
frank zhou
On Tue, May 01 '01 at 15:40, Frank Zhou wrote:
>       I thought someone in the list might be able to answer this question
> for me. I am wondering how XSLT deals with internationalization? My
> particular question is that suppose in one XML document all the tags and
> contents (is it allowed?) are in English, while the other one in Japanese,
> how do people handle this tranformation?  If you could refer me to any
> documents explaining these issues, that would be great!
What exactly is your problem?

If your (target) japenese tags are valid XML, you can use an XSL-T
(in either PULL or PUSH "mode") to convert english tags. Doing this with
the content of the tags is feaseale but no fun.

e.g. (english -> german, don't know japanese ;-))

given XML document:

<contact>
  <titel>Mr.</title>
  <surename>Goetz</surename>
  <name>Bock</name>
  <company>BlackNet IT-Consulting</company>
  <street>Nettelbeckstr. 7</street>
  <city>Munich</city>
  <zip>81929</zip>
  <country>Germany</country>
</contact>

intended target XML:

<kontakt>
  <anrede>Hr.</anrede>
  <vorname>Goetz</vorname>
  <name>Bock</bock>
  <firma>BlackNet EDV-Beratung</firma>
  <strasse>Nettelbeckstr. 7</strasse>
  <stadt>Muenchen</stadt>
  <postleitzahl>81929</postleitzahl>
  <land>Deutschland</land>
</kontakt>

As you can see, there is a pritty stright forward one2one mapping. But
there are also some content transformations: 
    Mr. -> Hr. 
    Germany -> Deutschland 
    ...
i will not do them here.

XSL-T fragment (pull):

<xsl:template match="contact">
  <kontakt>
    <anrede>
      <xsl:call-template name="transformTitle">
        <xsl:param name="title">
          <xsl:value-of select="title"/>
        </xsl:param>
      </xsl:call-template>
    </anrede>
    <vorname><xsl:value-of select="surename"/></vorname>
    <name><xsl:value-of select="name"/></name>
    <firma><xsl:value-of select="company"/></firma>
    <strasse><xsl:value-of select="street"/></strasse>
    <stadt><xsl:value-of select="city"/></stadt>
    <postleitzahl><xsl:value-of select="zip"/><postleitzahl>
    <land>
      <xsl:call-template name="transformCountry">
        <xsl:param name="country">
          <xsl:value-of select="country"/>
        </xsl:param>  
      </xsl:call-template>  
    </land>
  </kontakt>
</xsl:template>  

The called templates (transformTitle and transformCountry) allow you to
do the above mentioned transformations (but you have to write them
yourself).

BTW: It has proven to be very helpfull to not ask "How do you <some
vague idea/>" but to say "I have <XML/>, I want <XML/>. I've tried
<XSL/>. But it does not work <because/>". But please keep the <XML/> and
<XSL/> parts as short as possible and as verbose as necessary (and do
some indenting to make it nice to read on a 80 colomn text terminal).

Have fun,
    Goetz.

Attachment: pgp00000.pgp
Description: PGP signature

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.