Qualified Attributes In Root Elements

Thursday, 26 January 2012 · 3 messages
JG
J Gager26 Jan 2012 06:40 #
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
CG
Christian Grün26 Jan 2012 13:25 #
Dear Jack, thanks for your feedback. The latest version of BaseX [1] gives me the following result...
Quoted text · J Gager · 1 line
> 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/
Quoted text · J Gager · 100 lines
On Thu, Jan 26, 2012 at 5:40 AM, J Gager <j.gager at 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 at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
JG
J Gager26 Jan 2012 15:23 #
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
Quoted text · Christian Grün · 120 lines
On Jan 26, 2012, at 7:26 AM, "Christian Grün" <christian.gruen at 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 at 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 at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>

⚡Generated with XQuery