RE: [xsl] Can I use variables in location paths?

Subject: RE: [xsl] Can I use variables in location paths?
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 27 May 2003 16:23:59 +0300
Hi,

> What I'd like to do is this (note use of variable)
> 
> 		<xsl:variable name="Scenario">BASECASE</xsl:variable>
> 		<xsl:variable name="Date">20030408</xsl:variable>
> 
> 		<xsl:for-each 
> select="PositionFactorLevels/Scenario[ @Name='${Scenario}' 
> ]/Factor/Data[ @Date= '${Date}' ]">
> 				<xsl:value-of select="../@Name" 
> /> = <xsl:value-of select="." /> <br></br>
> 		</xsl:for-each>		

  @Name='${Scenario}'

Means you're testing if the Name attribute is equal to the string "${Scenario}"; see <http://www.w3.org/TR/xpath#NT-VariableReference>. Instead use

  <xsl:for-each select="PositionFactorLevels/Scenario[@Name = $Scenario]/Factor/Data[@Date = $Date]">

Cheers,

Jarno - Neurotic Fish: Prostitute

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread