-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Labels
Description
The expression number(//non-existent-node)
should evaluate to NaN
but it currently evaluates to 0
: I verified this by adding the following two tests which should pass, but they fail:
test_xpath_eval(t, empty_example, `number(//non-existent-node) = 0`, false)
assertTrue(t, math.IsNaN(MustCompile(`number(//non-existent-node)`).Evaluate(createNavigator(empty_example)).(float64)))
This creates issues for instance with a document as follows
<data>
<item v="1"/>
<item v="2"/>
</data>
The query //item[@v = preceding-sibling::item/@v + 1]
should return only the second item, but returns both instead. See http://xpather.com/atHhzd0d for an interactive example confirming that only the second item should match.
Looking at the spec, it says that
number(node-set)
should first convert the node set to a string,string(node-set)
should return the empty string if the node set is empty,number("")
should returnNaN
.