Conditional assignment of tree frag to variable doesn 't work. 2003-05-08 - By david_marston@(protected)
The construct <xsl:variable name="foo"> <xsl:choose> <xsl:when test="whatever"> <xsl:text>We have a whatever at this point.</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>We don't have a whatever at this point.</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> is part of our test suite, and it should work in all 2.x versions. Since it creates an RTF, the variable is always "set", so a test for set-ness, <xsl:when test="$foo != ''"> should always pass.
On the other hand, variables don't seem to pop out of xsl:choose as in <xsl:template match="/"> <xsl:choose> <xsl:when test="whatever"> <xsl:variable name="foo" select="'have-whatever'"> etc. due to the visibility rule (following siblings and descendants) in part 11.5 of the XSLT spec. Sorry about that.
I think Keith's problem might be about critical values being buried in the RTF he created. My suggestion is to have a variable that is set to a simple boolean (not RTF) that will be directly usable in later xsl:when elements. <xsl:when test="$have-whatever"> .................David Marston
|
|