Elisenda
Elisenda

Reputation: 1

xslt variables value

I have this piece of code:

        <xsl:variable name="varPriceDate">
          <xsl:call-template name="lookup_MarketGNLPricesFile_Valor">
            <xsl:with-param name="PARAM_Key" select="'A'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:element name="priceDate">
          <xsl:value-of select="Col[$varPriceDate]"/>
        </xsl:element>
        <xsl:variable name="varPrice">
          <xsl:call-template name="lookup_MarketGNLPricesFile_Valor">
            <xsl:with-param name="PARAM_Key" select="'B'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:element name="price">
          <xsl:value-of select="Col[$varPrice]"/>
        </xsl:element>

Where <xsl:value-of select="Col[$varPriceDate]"/> is showing the same result as <xsl:value-of select="Col[$varPrice]"/>. Can you help me? I need to solution it

Upvotes: 0

Views: 108

Answers (1)

Michael Kay
Michael Kay

Reputation: 163595

The values of both variables are result tree fragments (in XSLT 2.0, document nodes), and the effective boolean value of a result tree fragment is always true. Therefore the expressions Col[$varPriceDate] and Col[$varPrice] are both equivalent to simply writing Col.

To correct this we need to know what the code was intended to achieve, which isn't clear.

Upvotes: 1

Related Questions