Subject: RE: [xsl] problem using dyn:evaluate with MSXML From: Kevin Rodgers <kevin.rodgers@xxxxxxx> Date: Thu, 16 Dec 2004 09:37:24 -0700 |
Michael Kay writes: > Matthieu Ricaud writes: > > I define a variable $y containing an Xpath expression laike this : > > > > <xsl:variable name="y" select"'@my_attribute'"> > > > > Calling > > <xsl:value-of select="dyn:evaluate(., $y)"/> > > works fine and give me the attribute value. > > > > The problem I have is that when I define $y like this : > > > > <xsl:variable name="y">@num</xsl:variable> > > > > (Which is to me exactly the same definition as before) > > then I get a error ! > > The HTML page cannot be loaded. > > The two expressions are not at all the same. In one, the variable is a > string, in the other it is a result tree fragment. XPath automatically > converts a result tree fragment to a string when required (probably at > considerable cost), but Javascript does not. What is the recommended way to define a string-valued variable computed by a conditional instruction? Here's an example from a stylesheet I'm working on: <xsl:variable name="source"> <xsl:choose> <xsl:when test="$kind >= 0 and $kind < 5000"> <xsl:value-of select="format-number('01','00')"/> </xsl:when> <xsl:when test="$kind >= 5000 and $kind < 6000"> <xsl:value-of select="format-number('20','00')"/> </xsl:when> <xsl:when test="$kind >= 6000"> <xsl:value-of select="format-number('30','00')"/> </xsl:when> <xsl:when test="$kind = 'NATO'"> <xsl:value-of select="format-number('40','00')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="format-number('05','00')"/> </xsl:otherwise> </xsl:choose> </xsl:variable> Also, what is the recommended way to define an empty string-valued variable? <xsl:variable name="foo"/> <xsl:variable name="foo" select="''"/> <!-- or something else? --> -- Kevin Rodgers
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] problem using dyn:evaluat, Matthieu Ricaud | Thread | Re: [xsl] problem using dyn:evaluat, David Carlisle |
RE: [xsl] problem using dyn:evaluat, Matthieu Ricaud | Date | [xsl] Sub total generation - filte, Srinivasan, Sundar |
Month |