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

Fwd: i18n and l10n question

Subject: Fwd: i18n and l10n question
From: Nico Van Cleemput <Nicolas.VanCleemput@xxxxxxxx>
Date: Mon, 13 Nov 2006 09:26:17 +0100
Fwd:  i18n and l10n question
Hmm, maybe I should try to explain it better.

This is my XML-file:
<factory>
 <parameter>
    <name></name>
    <type></type>
    <i18n>
       <properties>
           <entry key="parameter.caption">caption</entry>
           <entry key="parameter.description">description</entry>
       </properties>
       <node name="nl">
         <properties>
             <entry key="parameter.caption">caption</entry>
             <entry key="parameter.description">description</entry>
         </properties>
       </node>
    </i18n>
 </parameter>
 <parameter>
    <name></name>
    <type></type>
    <i18n>
       <properties>
           <entry key="parameter.caption">caption</entry>
           <entry key="parameter.description">description</entry>
       </properties>
       <node name="nl">
         <properties>
             <entry key="parameter.caption">caption</entry>
             <entry key="parameter.description">description</entry>
         </properties>
       </node>
    </i18n>
 </parameter>
</factory>

This should be transformed in a table that looks like:

<table>
   <tr><td>caption</td><td>description</td></tr>
   ...
</table>

I use the following stylesheet:

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform">

<xsl:param name="locale"/>
<xsl:variable name="locale2" select="substring-before ($locale,'_')"/>
<xsl:key name="l" match="entry" use="concat(../../@name,' ',@key)"/>
<xsl:key name="help" match="help" use="concat(../../@name,' ')"/>


<xsl:template match="factory">
<table>
<xsl:for-each select="parameter">
<tr>
<td>
<xsl:choose>
<xsl:when test="key('l',concat($locale,' parameter.caption'))">
<xsl:apply-templates select="key('l',concat ($locale,' parameter.caption'))"/>
</xsl:when>
<xsl:when test="key('l',concat($locale2,' parameter.caption'))">
<xsl:apply-templates select="key('l',concat ($locale2,' parameter.caption'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="key('l',' parameter.caption')"/>
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test="key('l',concat($locale,' parameter.description'))">
<xsl:apply-templates select="key('l',concat ($locale,' parameter.description'))"/>
</xsl:when>
<xsl:when test="key('l',concat($locale2,' parameter.description'))">
<xsl:apply-templates select="key('l',concat ($locale2,' parameter.description'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="key('l',' parameter.description')"/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
<table>
</xsl:template>
</xsl:transform>


However, if there are two parameters, with caption n and r this returns:

<table>
   <tr><td>nr</td><td>description 1description 2</td></tr>
   <tr><td>nr</td><td>description 1description 2</td></tr>
</table>

and not

<table>
   <tr><td>n</td><td>description 1</td></tr>
   <tr><td>r</td><td>description 2</td></tr>
</table>

I would really appreciate any help on this.

Thanks in advance,
Nico Van Cleemput

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.