Dear All,
I have found some odd behavior when using the db:add XQuery function with the document constructor. When the root element contains a qualified attribute, all namespaces are being dropped.
For example:
db:add('testing', document{ <a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"><b:Child>Text</b:Child></a:Root> },'doc_1')
will result in the following being added to the database (note the namespaces are removed):
<a:Root a:id="test">
<b:Child>Text</b:Child>
</a:Root>
Neither of the following queries retrieves the added node:
declare namespace a="ns1";
/a:Root
/*:Root
The only query that seems to acknowledge this node is:
/*
However, using a string for the document does work:
db:add('testing', '<a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"><b:Child>Text</b:Child></a:Root>', 'doc_2')
but this is not desired as the content to be added may have quotes within its elements.
The namespaces are also retained using the document constructor if the root node does not contain a qualified attribute:
db:add('testing', document{ <a:Root xmlns:a="ns1" xmlns:b="ns2" id="test"><b:Child>Text</b:Child></a:Root> },'doc_1')
Is this a bug or am I missing some special handling rules of the document constructor? Any feedback is much appreciated.
Thanks,
Jack Gager
Metadata Technology
Dear Jack,
thanks for your feedback. The latest version of BaseX [1] gives me the following result...
basex -c "create db testing;xquery db:add('testing', document{ <a:Root xmlns:a='ns1' xmlns:b='ns2' a:id='test'><b:Child>Text</b:Child></a:Root> },'doc_1');xquery /"
<a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"> <b:Child>Text</b:Child> </a:Root>
..which is why I believe the problem has been already fixed. Which version have you been using for testing?
Your feedback is welcome, Christian
[1] http://files.basex.org/releases/latest/ ___________________________
On Thu, Jan 26, 2012 at 5:40 AM, J Gager j.gager@metadatatechnology.com wrote:
Dear All,
I have found some odd behavior when using the db:add XQuery function with the document constructor. When the root element contains a qualified attribute, all namespaces are being dropped.
For example:
db:add('testing', document{ <a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"><b:Child>Text</b:Child></a:Root> },'doc_1')
will result in the following being added to the database (note the namespaces are removed):
<a:Root a:id="test">
<b:Child>Text</b:Child>
</a:Root>
Neither of the following queries retrieves the added node:
declare namespace a="ns1";
/a:Root
/*:Root
The only query that seems to acknowledge this node is:
/*
However, using a string for the document does work:
db:add('testing', '<a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"><b:Child>Text</b:Child></a:Root>', 'doc_2')
but this is not desired as the content to be added may have quotes within its elements.
The namespaces are also retained using the document constructor if the root node does not contain a qualified attribute:
db:add('testing', document{ <a:Root xmlns:a="ns1" xmlns:b="ns2" id="test"><b:Child>Text</b:Child></a:Root> },'doc_1')
Is this a bug or am I missing some special handling rules of the document constructor? Any feedback is much appreciated.
Thanks,
Jack Gager
Metadata Technology
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Christian,
I am using version 7.0.2 (downloaded from the link on the main page).
I will test with the latest version and get back to you if I still find the issue.
Thanks for the quick reply.
Jack
On Jan 26, 2012, at 7:26 AM, "Christian Grün" christian.gruen@gmail.com wrote:
Dear Jack,
thanks for your feedback. The latest version of BaseX [1] gives me the following result...
basex -c "create db testing;xquery db:add('testing', document{ <a:Root xmlns:a='ns1' xmlns:b='ns2' a:id='test'><b:Child>Text</b:Child></a:Root> },'doc_1');xquery /"
<a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"> <b:Child>Text</b:Child> </a:Root>
..which is why I believe the problem has been already fixed. Which version have you been using for testing?
Your feedback is welcome, Christian
[1] http://files.basex.org/releases/latest/ ___________________________
On Thu, Jan 26, 2012 at 5:40 AM, J Gager j.gager@metadatatechnology.com wrote:
Dear All,
I have found some odd behavior when using the db:add XQuery function with the document constructor. When the root element contains a qualified attribute, all namespaces are being dropped.
For example:
db:add('testing', document{ <a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"><b:Child>Text</b:Child></a:Root> },'doc_1')
will result in the following being added to the database (note the namespaces are removed):
<a:Root a:id="test">
<b:Child>Text</b:Child>
</a:Root>
Neither of the following queries retrieves the added node:
declare namespace a="ns1";
/a:Root
/*:Root
The only query that seems to acknowledge this node is:
/*
However, using a string for the document does work:
db:add('testing', '<a:Root xmlns:a="ns1" xmlns:b="ns2" a:id="test"><b:Child>Text</b:Child></a:Root>', 'doc_2')
but this is not desired as the content to be added may have quotes within its elements.
The namespaces are also retained using the document constructor if the root node does not contain a qualified attribute:
db:add('testing', document{ <a:Root xmlns:a="ns1" xmlns:b="ns2" id="test"><b:Child>Text</b:Child></a:Root> },'doc_1')
Is this a bug or am I missing some special handling rules of the document constructor? Any feedback is much appreciated.
Thanks,
Jack Gager
Metadata Technology
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de