Peter Nabbefeld schrieb:
        <xsl:message>Button1[extended] = <xsl:value-of
select="$button1"/></xsl:message>

        <xsl:message>Buttons-extended  = <xsl:value-of
select="boolean($button1) and boolean($button2) and
boolean($button3)"/></xsl:message>

You haven't told us what's inside the variables, but your surprise
likely stems from a confusion of string value and boolean value.

The string value of the boolean false() is, confusingly, 'false', and
the string value of the string 'false' is, logically, 'false'. (Same
story in green for true() and 'true'.)

The boolean value of the boolean false() is, logically, false(), and the
boolean value of the string 'false' is, logically', true().

Consider the following stylesheet (run on any XML document).

Michael Ludwig

<xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="text"/>
  <xsl:template match="/">
    <xsl:variable name="t" select="true()"/><!-- a boolean -->
    <xsl:variable name="f" select="false()"/><!-- a boolean -->
    <xsl:variable name="fstr" select="'false'"/><!-- a string -->

    <xsl:value-of select="$t"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="boolean($t)"/>
    <xsl:text>&#10;</xsl:text>

    <xsl:value-of select="$f"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="boolean($f)"/>
    <xsl:text>&#10;</xsl:text>

    <xsl:value-of select="$fstr"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="boolean($fstr)"/>
    <xsl:text>&#10;</xsl:text>

  </xsl:template>
</xsl:transform>

Output:

true true
false false
false true

Reply via email to