This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: multilanguage support easily or including xml data dynamically
- To: xsl-list at mulberrytech dot com
- Subject: Re: multilanguage support easily or including xml data dynamically
- From: juggy at gmx dot net
- Date: Thu, 8 Jun 2000 22:28:30 +0200
- References: <393EE3F7.17036.E6912C@localhost> "from juggy@gmx.net at Jun 8, 2000 00:08:23 am"
- Reply-To: xsl-list at mulberrytech dot com
Hi,
How do you get this to work? I tried it exactly the way you wrote it,
but this appears:
saxon XMLNumberData.xml LangTest.xsl
Fatal error reported by XML parser: Illegal processing instruction
target (found
"xml")
URL: file:/E:/WORK/Programs/Develop/XML/saxon/LangTest.xsl
Line: 2
Column: 2
Error preparing style sheet
Illegal processing instruction target (found "xml")
Should I have changed something?
Juggy
On 8 Jun 2000, at 1:12, Mike Brown wrote:
> > I have a report to do with multilanguage support. It's designed this
> > way:
> >
> > XML-Number-Data + XSL --> HTML
> >
> > Now, I would like to pass a parameter to maybe an ASP, maybe to the
> > XML directly (I appreciate advices!), to select a language, let's
> > say English :). Now this should happen:
> >
> > 1.) open XML-Number-Data
> > 2.) include chunk of language-data properly (e.g. ENGLISH.XML)
> > 3.) label the data correctly via XSL and
> > 4.) create HTML.
> >
> > Do I need a scripting language like JScript for this? I would like
> > to use as much pure XML/XSL as possible.
>
> You can use pure XML/XSLT, although not by dynamically selecting from
> a master file of all local language info, not dynamically including
> just the language you need. A very brief example to demonstrate
> principles:
>
> <?xml version="1.0"?>
> <!-- this is XMLNumberData.xml -->
> <XMLNumberData>
> <numberData desc="albedo">0.39</numberData>
> <numberData desc="pi">3.1415926</numberData>
> </XMLNumberData>
>
> <?xml version="1.0"?>
> <!-- this is LanguageData.xml -->
> <!-- forgive my completely made-up Spanish! -->
> <phrases>
> <phrase key="albedo" xml:lang="en">The albedo of the earth is:
> </phrase> <phrase key="albedo" xml:lang="es">El albedo de la terra
> es: </phrase> <phrase key="pi" xml:lang="en">The value of pi is:
> </phrase> <phrase key="pi" xml:lang="es">El valor de pi es:
> </phrase>
> </phrases>
>
> <?xml version="1.0"?>
> <!-- This is LangTest.xsl -->
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" version="1.0" indent="yes"/>
> <xsl:param name="LanguageSelected" select="'en'"/>
> <xsl:variable name="phrases"
> select="document('LanguageData.xml')/phrases"/>
>
> <xsl:template match="/">
> <Result>
> <xsl:apply-templates select="XMLNumberData/numberData"/>
> </Result>
> </xsl:template>
>
> <xsl:template match="numberData">
> <xsl:value-of
> select="concat('
',$phrases/phrase[@key=current()/@desc and
> lang($LanguageSelected)],.)"/> <!-- note instead of lang($foo) I
> could've said @xml:lang=$foo -->
> </xsl:template>
> </xsl:stylesheet>
>
>
> Select the desired language by passing a parameter to the stylesheet,
> using the mechanism your XSL processor allows. Default will be 'en'.
>
> Example with Saxon:
> saxon XMLNumberData.xml LangTest.xsl LanguageSelected=es
>
> Output:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <Result>
> El albedo de la terra es: 0.39
> El valor de pi es: 3.1415926</Result>
>
>
> I would have tried to use <xsl:key/> and key() to make the phrase
> selection more efficient, but I couldn't get it to work with the
> separate LanguageData document.
>
> - Mike
> ____________________________________________________________________
> Mike J. Brown, software engineer at My XML/XSL resources:
> webb.net in Denver, Colorado, USA http://www.skew.org/xml/
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list