Hi Christian,
thanks for your help. I tried using is operator instead of = and now I got expected result, but I got error with comparsion where true should be returned.
i.e when I call fn:root(/test) is /test which should return true, but it returns false. I'm using same simple XML.
<?xml version='1.0' encoding='UTF-8'?> <test> <nodes> <node></node> </nodes> <nodes2> </nodes2> </test>
Is there something above /test some "super root"? I have checked what returns each command and the result is the same. for both, but when I check tree map window in base-x gui I found out that fn:root(/test) select my.xml and /test select test node directly. Is this a right behaviour?
Thanks again for quick and helpful responses
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 at 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
Hi Jiří,
i.e when I call fn:root(/test) is /test which should return true, but it returns false. I'm using same simple XML.
The query result is correct, as each XML document has a document node on top…
[1] fn:root(/test) is /test → false [3] fn:root(/test) is / → true [2] fn:root(doc('test.xml')/test) is doc('test.xml') → true
Hope this helps; feel free to ask for more, Christian
<?xml version='1.0' encoding='UTF-8'?>
<test> <nodes> <node></node> </nodes> <nodes2> </nodes2>
</test>
Is there something above /test some "super root"? I have checked what returns each command and the result is the same. for both, but when I check tree map window in base-x gui I found out that fn:root(/test) select my.xml and /test select test node directly. Is this a right behaviour?
Thanks again for quick and helpful responses
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 at 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