Hi,
Ferdinand Soethe <xsl-list(_at_)soethe(_dot_)net> wrote:
For an international application I'd like to store all texts in a
construct like
<xsl:variable name="AllTexts">
<!-- german language texts -->
<de>
<searchButton>Suchen</searchButton>
</de>
First, in XSLT 1.0 you cannot access result-tree fragments through
XPath, but if you're using XSLT 2.0 you're alright. However, I'd
strongly advice to put all this stuff in an external XML file, such as
;
text.xml:
<text>
<searchButton de="Suchen" en="Search" />
<findButton de="Finden" en="Find" />
<clickButton de="Drucken" en="Click" />
</text>
And then you can use this in your stylesheet as ;
<xsl:param name="language">de</xsl:param>
<xsl:variable name="AllTexts" select="document('text.xml')/*" />
<xsl:value-of select="$AllTexts/searchButton/@*[name()=$language]" />
To further this, to make the XSLT look nicer it would be good to acces
the language texts as ;
<xsl:value-of select="$AllTexts/searchButton" />
and you could do that by having your languages in separate XML files
as text_en.xml and text_de.xml, and ;
<xsl:variable name="AllTexts"
select="document(concat('text_',$language,'.xml'))/*" />
and have the format of your text_de.xml (for example) file as ;
<text>
<searchButton>Suchen</searchButton>
...
</text>
Many options here, really. Depends on how complex your needs are and so forth.
Alex
--
"Ultimately, all things are known because you want to believe you know."
- Frank Herbert
__ http://shelter.nu/ __________________________________________________
--~------------------------------------------------------------------
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>
--~--