Hello
We are using BaseX6 to manage a local repository of XML artifacts in a Java based application. We initially start with an empty collection, and add documents as they are needed.
We have tried a number of approaches to this (more to come on this in a separate email). One such approach is to insert the documents as nodes into the container using XQuery. Example:
insert nodes document {<t:test xmlns:t='xyz' xmlns:s='def'>good <s:test>bye</s:test></t:test>} into collection('MyCollection')
It seems to me that only the first namespace declaration is retrained.
If I follow this insertion with the following query:
declare namespace x ="xyz"; declare namespace y ="def"; collection('MyCollection')/x:test
I get the following result:
<t:test xmlns:t="xyz">good <s:test xmlns:s="">bye</s:test></t:test>
Notice that the namespace for the prefix s is now empty.
Further, if I reverse the order of the namespace declarations in the insert query:
<t:test xmlns:s='def' xmlns:t='xyz'>good <s:test>bye</s:test></t:test>
The query used above will not return a result (presumably because the xyz namespace has been dropped).
Has anyone else encountered such issues? Currently we are working around this by saving the XML content to a file and using the Add process - which seems to work as expected. If possible, we would prefer to avoid this extra step of saving the XML to a temporary file before adding it to our BaseX database.
Thanks,
J Gager
Dear J Gager,
thank for your e-mail..
We have tried a number of approaches to this (more to come on this in a separate email). One such approach is to insert the documents as nodes into the container using XQuery. Example:
insert nodes document {<t:test xmlns:t='xyz' xmlns:s='def'>good <s:test>bye</s:test></t:test>} into collection('MyCollection')
Unfortunately, the XQuery Update specification does not allow for the insertion of new document nodes in collections. This is why your query will insert the child node of the document node (i.e. the root element <t... >) into an existing collection or document. It looks like a bug, however, that one namespace is lost by the update. I added a bug entry for this one..
https://sourceforge.net/tracker/?func=detail&aid=2941714&group_id=19...
Has anyone else encountered such issues? Currently we are working around this by saving the XML content to a file and using the Add process - which seems to work as expected. If possible, we would prefer to avoid this extra step of saving the XML to a temporary file before adding it to our BaseX database.
Right, that's one way to go.. My answer on your second question is coming soon.
Best, Christian
basex-talk@mailman.uni-konstanz.de