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

how to do i18n with parameter substitution

Subject: how to do i18n with parameter substitution
From: George James <GeorgeJ@xxxxxxxxxxxxxxx>
Date: Wed, 23 Mar 2005 02:55:40 -0000
xml parameter substitution
I have a template that does language substitution for text strings.  I want
to extend this to be able to pass in a variable number of parameter values
that get substituted into placeholder in each language string.

The current template looks something like this:

  <xsl:template name='i18n'>
    <xsl:param name='caption'/>
    <xsl:choose>
      <xsl:when
test='document("phrases.xml")/phrases/phrase/target[../@key=$caption and
lang($language)]'>
        <xsl:copy-of
select='document("phrases.xml")/phrases/phrase/target[../@key=$caption and
lang($language)]' />
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy-of select='$caption' />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

I have a phrases.xml document that looks like this:

<phrase key='Client not on file'>
 <target xml:lang='en'>Client number <p1/> not on file. Priority:
<p2/></target>
 <target xml:lang='de'>Prioritdt: <p2/>. Klient Nr. <p1/> nicht auf
Akte.</target>
</phrase>

How can I extend my template so that will take as input something like the
following:

<caption key='Client not on file'>
 <p1 value='123456'/>
 <p2 value='99'/>
</caption>

and produce one of the following strings, depending on the language:
Client number 123456 not on file. Priority: 99
Prioritdt: 99. Klient Nr. 123456 nicht auf Akte.

Can anyone help me with this?
George

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.