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

localization using <xsl:key> help

Subject: localization using <xsl:key> help
From: Mike Engelhart <mengelhart@xxxxxxxxxxxxx>
Date: Thu, 09 Mar 2000 14:09:47 -0600
xsl localization
Hi

I'm trying to use <xsl:key> to do string lookups for localization.  I have
it working using the following setup (i'm using Cocoon w/xalan & xerces to
do the processing)   The following three files test.xml, test.xsl,
localization.xml are what I'm using

<!--  localization.xml -->
<?xml version="1.0"?>
<localization>
    <word name="_FIRST_NAME">
        <translation lang="en">First Name</translation>
        <translation lang="es">Nombre</translation>
        <translation lang="it">Nome</translation>
    </word>
</localization>

<!-- test.xml -->
<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="./test.xsl" type="text/xsl"?>
<page xml:lang="en">
    <field>_FIRST_NAME</field>
</page>

<!-- test.xsl -->
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
    <xsl:key name="translate" match="word" use="@name"/>
    <xsl:template match="page">
      <xsl:for-each select="document('./localization.xml')">
        <html><body><h1>
        <xsl:value-of select="key('translate','_FIRST_NAME')/translation"/>
        </h1></body></html>
      </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Now when run through Cocoon, I get an html page with the output being "First
Name" as an <H1> element as expected.  What I want to do is have the key
lookup determine which <translation> element to grab based on the language
attribute.  i can't figure out what to put here:

<xsl:value-of select="key('translate','_FIRST_NAME')/translation"/>

to get this done.  

Any help would be greatly appreciated.

Thanks,
MIke


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.