[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using a variable to get the value of an element
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|