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