|
Subject: Re: [xsl] How does XSLT deal with international characters? From: Goetz Bock <bock@xxxxxxxxxxx> Date: Wed, 2 May 2001 01:22:17 +0200 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] How does XSLT deal with inter, Frank Zhou | Thread | RE: [xsl] How does XSLT deal with i, Michael Kay |
| [xsl] How does XSLT deal with inter, Frank Zhou | Date | Re: [xsl] Printing an XSL->HTML doc, Lyndall Scantlebury |
| Month |