Reputation: 179
I have several XML files (content.xml). One with actual content and the other XML's contain text information for translation (translation_*.xml e.g. translation_EN.xml).
The content.xml contains a node with information about the language e.g.
<language>EN</language>
In the beginning of the content.xml I declare a variable, to use it in conjunction with the document() function
<xsl:variable name="trans">translation_EN.xml</xsl:variable>
I was trying to write choose and if constructs to change the EN in the variable according to the node value in content.xml. However it seems to not be valid to use those constructs outside of xsl:template.
Hope I explained my misery understandably. Is there another way to do it?
Upvotes: 0
Views: 31
Reputation: 117073
There 's a lot of details missing here, but say you have an input XML in the form of:
<content>
<language>EN</language>
<item/>
<item/>
</content>
you can define a global variable as:
<xsl:variable name="trans-doc" select="document(concat('translation_', /content/language, '.xml'))" />
and use this to retrieve data from an external XML document named "translation_EN.xml", for example as:
<xsl:value-of select="$trans-doc/root/item" />
Upvotes: 1