After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 363002 - boolean() of empty string sometimes returns true instead of false
boolean() of empty string sometimes returns true instead of false
Status: RESOLVED NOTABUG
Product: libxslt
Classification: Platform
Component: general
1.1.14
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-10-17 23:01 UTC by Archie Cobbs
Modified: 2006-11-18 13:09 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Archie Cobbs 2006-10-17 23:01:52 UTC
Please describe the problem:
When $foo is a string variable, and $foo is equal to the empty string, then boolean($foo) is supposed to return false. Sometimes, it is returning true instead.


Steps to reproduce:
Run the following stylesheet on itself with xsltproc:

$ cat > bug.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output encoding="ISO-8859-1" method="text"/>
    <xsl:template match="/*">
        <xsl:variable name="foo">
            <xsl:value-of select="''"/>
        </xsl:variable>
        <xsl:choose>
            <xsl:when test="boolean($foo)">boolean($foo) is true&#10;</xsl:when>
            <xsl:otherwise>boolean($foo) is false&#10;</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
^D
$ xsltproc bug.xsl bug.xsl
boolean($foo) is true
$ 

Actual results:
boolean($foo) is true

Expected results:
boolean($foo) is false

Does this happen every time?
yes

Other information:
System is SuSE 10. RPM is libxslt-1.1.14-3.
Comment 1 William M. Brack 2006-11-18 13:09:03 UTC
The xpath boolean() function in libxslt (actually part of libxml2) is behaving correctly.  The two xsl declarations
    <xsl:variable name = "foo" select = "''"/>
and
    <xsl:variable name = "foo">
        <xsl:value-of select = "''"/>
    </xsl:variable>
are **NOT** equivalent.  The first of these gives a string, and boolean($foo) will return false, since it's string length is zero.  The second of these gives a "result tree fragment", which is treated as a node-set (see http://www.w3.org/TR/xslt#variable-values).  Since the node-set is not empty (it contains a text node with an empty string), the result of boolean($foo) is true.