[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Using a variable to get the value of an element
Subject: Re: [xsl] Using a variable to get the value of an element From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Sat, 26 Jan 2002 00:27:06 +0000 |
Hi Ben, > I need the value of an element, but the name of that element is > stored in a variable - see below: You either need an evaluate() extension function or, for this simple case, you can use the pattern: *[name() = $variable] Which locates all the elements whose name is the value of the $variable. One thing you need to watch out for in your particular example is whitespace. The $hello variable will contain a string that looks like: "
 officename1_en" To avoid that whitespace, you either have to normalize the variable before you compare it to the name of the element: *[name() = normalize-space($hello)] or you need to create the $hello variable without the extraneous whitespace, with: <xsl:variable name="hello">officename1_<xsl:value-of select="$PageLang /></xsl:variable> or: <xsl:variable name="hello"> <xsl:text>officename1_</xsl:text> <xsl:value-of select="$PageLang" /> </xsl:variable> or: <xsl:variable name="hello"> <xsl:value-of select="concat('officename1_', $PageLang)" /> </xsl:variable> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using a variable to get t, Joerg Heinicke | Thread | Re: [xsl] Using a variable to get t, Jeni Tennison |
Re: [xsl] Using a variable to get t, Joerg Heinicke | Date | Re: [xsl] Meunchian Method - Groupi, Jeni Tennison |
Month |