xsl-list
[Top] [All Lists]

Fwd: [xsl] i18n and l10n question

2006-11-13 01:27:18
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>