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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a node using a param 1

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi,

I am trying to write an XSL file that will be used on a multilingual website. I am passing a param into the XSL that identifies the language, this is called lang and can contain en,cy,es,fr,de etc.

I then have an XML document that I want to pull the language specific element from. the document looks like this:

<parent>
<element>
<en>test</en>
<es>test es</es>
<fr>test fr</fr>
</element>
</parent>

So I have been trying to use the following:

<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="Lang" />
<xsl:eek:utput method="xhtml"/>
<xsl:template match="/">
<xsl:value-of select="//newsletter/name/$Lang" />
</xsl:template>
</xsl:stylesheet>

I have tried:

//newsletter/name/[$Lang]
//newsletter/name/{$Lang}
//newsletter/name/($Lang)

any ideas of how I can get this working?

TIA

Tony
 
For a given Lang being set as global, it would appears like this.
[tt]
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:param name="Lang" [blue]select="'es'"[/blue] />
<xsl:eek:utput method="html"/> [blue]<!-- change it back to xhtml after beefed up -->[/blue]
<xsl:template match="/">
<xsl:for-each select="//newsletter/name/*[local-name()=$Lang]">
<xsl:value-of select="." /><br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
[/tt]
 
That would have taken me soooo long to figure out, thanks for your help. have a star for the quick and accurate response

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top