I can't quite get my head around this.
So I have this external XML data file:
<?xml version="1.0" encoding="UTF-8"?>
<Translations xmlns="http://www.publictalksoftware.co.uk/msa">
<en>
<Chairman>Chairman</Chairman>
<Conductor>Conductor</Conductor>
<Hospitality>Hospitality</Hospitality>
<Prayer>Prayer</Prayer>
<PublicTalk>Public Talk</PublicTalk>
<Reader>Reader</Reader>
<ServiceTalk>Service Talk</ServiceTalk>
<Speaker>Speaker</Speaker>
<Theme>Theme</Theme>
<WTStudy>Watchtower Study</WTStudy>
</en>
</Translations>
It is referenced in my master XSL script like this:
<xsl:variable name="Translations" select="document('Workbook-S-140-Compact_2020_v2_Translations.XML')"/>
I am able to extract values from this XML file like this:
<xsl:value-of select="$Translations/msa:Translations/msa:en/msa:ServiceTalk"/>
The above will pull out the English translation. Here is the thing, in my main XML data file I have the following at the top:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Workbook-S-140-Compact_2020_v2.xsl"?>
<MeetingWorkBook>
<Settings>
<LanguageCode>en</LanguageCode>
<Direction>ltr</Direction>
<EditorMode>1</EditorMode>
<ForeignGroupMode>0</ForeignGroupMode>
<Now Day="20" Month="2" Year="2020"/>
</Settings>
Notice the LanguageCode entry? I wanted to make use of this so that my transformation was based on the language code. So I initially added a second variable to my XSL file:
<xsl:variable name="LangCode">
msa:<xsl:value-of select="//Settings//LanguageCode"/>
</xsl:variable>
And adjusting my path like this:
<xsl:value-of select="$Translations/msa:Translations/{$LangCode}/msa:ServiceTalk"/>
But it doesn't like it. I can't work out how to insert the language code into the path query. I have lots of these translation lines so I am looking for a simple solution if possible.
I have also tried saving the variable as:
<xsl:variable name="LangCode">
<xsl:value-of select="//Settings//LanguageCode"/>
</xsl:variable>
And then using:
<xsl:value-of select="$Translations/msa:Translations/msa:{$LangCode}/msa:ServiceTalk"/>
It still fails.
Is it possible to adjust this line:
<xsl:variable name="Translations" select="document('Workbook-S-140-Compact_2020_v2_Translations.XML')"/>
So that $Translations is pointing to the Translations/langcode node? Make sense?