From: Ralf J. <ral...@gm...> - 2011-01-09 10:30:27
|
Hi list, while debugging an issue, I noticed it is actually caused by eXist behaving incorrectly (or at least weird) when evaluating XPath statements like item/count(.//@cod). I broke the issue down to the attached example code: xquery version "1.0"; let $doc := doc('/db/test.xml') let $data := <root><item><l cod="bla"/></item> <item><l cod="blubb"/><f cod="foo"/><g cod="bar"/></item></root> let $result := $data/item/count(.//@cod) return <res>{for $i in $result return <i>{$i}</i>}</res> produces the expected output <res><i>1</i><i>3</i></res> However, if I change the code to say let $result := $doc/item/count(.//@cod) with the content of doc being just the same as $data <root><item><l cod="bla"/></item> <item><l cod="blubb"/><f cod="foo"/><g cod="bar"/></item></root> the output is <res><i>0</i></res> Even more weird, if I then change the query to let $result := $doc/root/item/count(.//@cod) It says <res><i>4</i></res> I am not sure what the expected behaviour of doc() is (i.e. whether $doc should be the same as $data, or $doc/root should be the same as $data), but either way, the result looks incorrect to me. Am I doing a mistake, or is this actually a bug and I should file a report? Kind regards, Ralf |