[Home] [By Thread] [By Date] [Recent Entries]
Hi,
I'm still having some problems putting this to use in our case, but I thank you already because I've learned some new ways of doing things from this, (As you might have guessed: these are my first steps in XSL). I tried to adjust your tip to what we already had, but it didn't seem to work. It gave no errors (after I closed some brackets and typed some extra commas ;)), but it just printed the default text several times. I will give a more concrete example on how I changed your file. First of all, this is my example source file, named TuranGraphFactory.xml: <factory>
<i18n>
<properties>
<entry key="factory.name">Turan Graph</entry>
</properties>
<node name="nl">
<properties>
<entry key="factory.name">Turan Graaf</entry>
</properties>
</node>
</i18n>
</factory>I made this xslt-file that should transform the TuranGraphFactory.xml file to a html-file: <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:template match="factory">
<html>
<body>
<h1>
<xsl:variable name="key" select="'factory.name'"/>
<xsl:for-each select="//entry">
<xsl:choose>
<xsl:when test="key('l',concat($locale,' ',$key))">
<xsl:apply-templates
select="key('l',concat($locale,' ',$key))"/>
</xsl:when>
<xsl:when test="key('l',concat($locale2,' ',$key))">
<xsl:apply-templates
select="key('l',concat($locale2,' ',$key))"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="key('l',concat('
',$key))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</h1>
</body>
</html>
</xsl:template>
</xsl:transform>The desired result would be a simple html-file that contained one title with the name of the graph in the current locale. However I get a file that contains one title that is the name of the graph four times: first the english, then the dutch, then the english and again the dutch. Any help would really be appreciated. Nico van Cleemput Quoting David Carlisle <davidc@xxxxxxxxx>:
|

Cart



