Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting value from another node based on current ID

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB

Right there here is my next question.

We work with multilingual websites and use a variable within our CMS that contains all of the languages for the site. This is setup as en=English,fr=French,de=German and so on.

The current language is being stored within the variable $Lang.

I am putting this variable into an xml document like this:

list one
<SiteLanguages>
<Language>en</Language>
<Language>fr</Language>
<Language>de</Language>
</SiteLanguages>

Then within the generic document I have an element for all of the possible languages:

list two
<languages>
<language id="en">
<en>English</en>
<fr>French</fr>
<de>German</de>
</language>
<language id="de">
<en>English De</en>
<fr>French De</fr>
<de>German De</de>
</language>
<language id="fr">
<en>English Fr</en>
<fr>French Fr</fr>
<de>German Fr</de>
</language>
<language id="es">
<en>English es</en>
<fr>French es</fr>
<de>German es</de>
</language>
</languages>

What I want to be able to do, is to loop over the all of the elements in list one, and then output the long language from list two. So if the site is currently in french(fr), I need to output all of the nodes from list 2 where the id = fr. At the moment I have it so that it outputs all of the same node (English, English, English, English) using this:

<xsl:for-each select="//SiteLanguages/Language">
<input type="radio" name="Language" value="{.}" /><xsl:value-of select="//newsletter/languages/language[@id=$Lang]/fr" />
</xsl:for-each>

when i replace this hardcoded "fr" with . from the loop I get the whole list!

Any ideas

TIA

Tony
 
The description is a bit cryptic. Not sure whether this is what you've in mind.
[tt]
<xsl:for-each select="//SiteLanguages/Language">
<xsl:variable name="x" select="." />
<input type="radio" name="Language" value="{.}" /><xsl:value-of select="//newsletter/languages/language[@id=$Lang]/*[name()=$x]" />
</xsl:for-each>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top