Hi guys,
I'm having a trouble with using fn:root function. I want to check if given XPath selects root node. So i decided to do it with following
for eg. /test/nodes - is example XPath chosing non root element and i want to check if this is root element byt running one of these statements
fn:root(/test/nodes) = /test/nodes or fn:root() = /test/nodes
both of these return true on following document:
<?xml version='1.0' encoding='UTF-8'?> <test> <nodes> <node></node> </nodes> <nodes2> </nodes2> </test>
when I run just first part of statement fn:root(/test/nodes) I get: <test> <nodes> <node/> </nodes> <nodes2/> </test>
which is ok when I run separately /test/nodes i got this: <nodes> <node/> </nodes>
it's also ok but when I try to compare it together I get false which is definitelly not OK. i.e fn:root(/test/nodes) = /test/nodes .... returns true
Am I doing something wrong or it's a bug in base-X. I have tried also last BASE-X 6.03 and I'm having same problem.
Thank you for help
Jiri
Hi Jiří,
"=" is a »general comparison« operator, which compares the atomized values of your left and right operands. So-called »node comparison« operators will give you the expected result:
fn:root(/test/nodes) is /test/nodes
More details in the specs: http://www.w3.org/TR/xquery/#id-node-comparisons
Christian
On Fri, Mar 19, 2010 at 5:12 PM, Jiří Kadlec jir.kadlec@post.cz wrote:
Hi guys,
I'm having a trouble with using fn:root function. I want to check if given XPath selects root node. So i decided to do it with following
for eg. /test/nodes - is example XPath chosing non root element and i want to check if this is root element byt running one of these statements
fn:root(/test/nodes) = /test/nodes or fn:root() = /test/nodes
both of these return true on following document:
<?xml version='1.0' encoding='UTF-8'?>
<test> <nodes> <node></node> </nodes> <nodes2> </nodes2> </test>
when I run just first part of statement fn:root(/test/nodes) I get:
<test> <nodes> <node/> </nodes> <nodes2/> </test>
which is ok when I run separately /test/nodes i got this:
<nodes> <node/> </nodes>
it's also ok but when I try to compare it together I get false which is definitelly not OK. i.e fn:root(/test/nodes) = /test/nodes .... returns true
Am I doing something wrong or it's a bug in base-X. I have tried also last BASE-X 6.03 and I'm having same problem.
Thank you for help
Jiri
___________________________
Christian Gruen Universitaet Konstanz Department of Computer & Information Science D-78457 Konstanz, Germany Tel: +49 (0)7531/88-4449, Fax: +49 (0)7531/88-3577 http://www.inf.uni-konstanz.de/~gruen
basex-talk@mailman.uni-konstanz.de