Re: [xml] XPath question w/ libxml2

On Thu, Apr 15, 2004 at 12:08:06PM -0600, Mark_Vakoc peoplesoft com wrote:
This is really an XPath question: have read the XPath 1.0 spec and am
not clear on the proper behavior for a predicate when NaN is used in an
expression such as:




libxml2 appears to evaluate this predicate as all nodes, whereas I would
have thought it would match zero nodes.  Is this behavior defined?

  Dixit section 2.4 Predicates:
    "A PredicateExpr is evaluated by evaluating the Expr and converting
     the result to a boolean. If the result is a number, the result will
     be converted to true if the number is equal to the context position
     and will be converted to false otherwise"

So I agree it sounds like this should select no node.
The difference though is that at least on my platform this works as
    paphio:~/XML -> xmllint --shell tst.xml
    / > xpath doc[1]
    Object is a Node Set :
    Set contains 1 nodes:
    1  ELEMENT doc
    / > xpath doc[number('NaN')]
    Object is a Node Set :
    Set contains 0 nodes:
    / > 

I'm afraid you might be seeing some weird floating point troubles.
Can you try to see if the basic tests from test/XPath/expr/floats
work correctly first ? Then it might be number('NaN') failing or
the index tests.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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