Re: [xml] xpath mixed type equality expressions



On Mon, Jun 10, 2002 at 10:39:24PM +0200, Matthias Clasen wrote:

I have a little problem with the xsl docbook stylesheets, which don't
behave as expected with xsltproc. The problem can be condensed to the
following:

  <xsl:template name="test" match="*">
    <xsl:variable name="value">1.0</xsl:variable>
    <xsl:choose>
      <xsl:when test="$value != 1.0">
        <xsl:message>UNEQUAL</xsl:message>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>EQUAL</xsl:message>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

This will print UNEQUAL when run trough xsltproc, although I believe
that the XPath spec (section 3.4) specifies that it should print EQUAL, 
since the test attribute is an EqualityExpression with a node-set and a
number as operands. Such an expression shall evaluate to true if any
node x in the node-set yields the given number when fed through
number(string-value(x)). 

libxml does't really implement this, but rather converts the number to a
string (which converts 1.0 into "1") and then compares the
string-value(x) with the resulting string (in xmlXPathEqualNodeSetFloat)

I think this is a bug in libxml.

  Seems you're right and the way xmlXPathEqualNodeSetFloat() is implemented
doesn't respect the XPath semantic :-(
  bug_to_fix++

  thanks for the report !

Daniel


-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]