Problem with omit-xml-declaration during update operation

Tuesday, 10 May 2011 · 6 messages · last reply 13 May 2011
DR
David Reichle10 May 2011 09:11 #
I'm trying to do an update operation on a file using standalone cmdline basex. The xml-declaration get printed to stdout instead of to the updated file.
$cat test.xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <test/>
</root>

$cat test.xq
declare option output:omit-xml-declaration "no";

let $root := doc("test.xml")/root
return insert node <test/> into $root

$basex -u test.xq

$cat test.xml
<root>
  <test/>
  <test/>
</root>
The declaration gets removed :<
AW
Andreas Weiler10 May 2011 13:27 #
Hi David, the following query does what you trying to do (i guess):
declare option output:omit-xml-declaration "no";
put(
  copy $doc := doc("test.xml")
  modify insert node <testnew/> into $doc/root
  return $doc, "test2.xml")
Kind regards, Andreas
Quoted text · David Reichle · 31 lines
On 10.05.2011, at 07:11, David Reichle wrote: > I'm trying to do an update operation on a file using standalone cmdline basex. > > The xml-declaration get printed to stdout instead of to the updated file. > > $cat test.xml > <?xml version="1.0" encoding="UTF-8"?> > <root> > <test/> > </root> > > $cat test.xq > declare option output:omit-xml-declaration "no"; > > let $root := doc("test.xml")/root > return insert node <test/> into $root > > $basex -u test.xq > > $cat test.xml > <root> > <test/> > <test/> > </root> > > The declaration gets removed :< > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
DR
David Reichle12 May 2011 08:24 #
I'm sorry; I wasn't really _trying_ to do anything, except to point out what I consider a bug. Thank-you for your reply.
Quoted text · Andreas Weiler · 50 lines
On Tue, May 10, 2011 at 5:27 AM, Andreas Weiler < andreas.weiler at uni-konstanz.de> wrote: > Hi David, > > the following query does what you trying to do (i guess): > > declare option output:omit-xml-declaration "no"; > put( > copy $doc := doc("test.xml") > modify insert node <testnew/> into $doc/root > return $doc, "test2.xml") > > Kind regards, > Andreas > > On 10.05.2011, at 07:11, David Reichle wrote: > > > I'm trying to do an update operation on a file using standalone cmdline > basex. > > > > The xml-declaration get printed to stdout instead of to the updated file. > > > > $cat test.xml > > <?xml version="1.0" encoding="UTF-8"?> > > <root> > > <test/> > > </root> > > > > $cat test.xq > > declare option output:omit-xml-declaration "no"; > > > > let $root := doc("test.xml")/root > > return insert node <test/> into $root > > > > $basex -u test.xq > > > > $cat test.xml > > <root> > > <test/> > > <test/> > > </root> > > > > The declaration gets removed :< > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
CG
Christian Grün12 May 2011 09:57 #
Dear David, thanks, all observations on potential bugs are welcome. In this case, the behavior is indeed expected (although somewhat counterintuitive): When the document is serialized to disk, we have already lost the information if an XML declaration was specified. Other information, such as DTD declarations and entities, are lost as well as long as they are not explicitly specified as serialization parameters. Best, Christian
Quoted text · David Reichle · 64 lines
On Thu, May 12, 2011 at 6:24 AM, David Reichle <dreichle at cableone.net> wrote: > I'm sorry; I wasn't really _trying_ to do anything, except to point out what > I consider a bug. > Thank-you for your reply. > > On Tue, May 10, 2011 at 5:27 AM, Andreas Weiler > <andreas.weiler at uni-konstanz.de> wrote: >> >> Hi David, >> >> the following query does what you trying to do (i guess): >> >> declare option output:omit-xml-declaration "no"; >> put( >> copy $doc := doc("test.xml") >> modify insert node <testnew/> into $doc/root >> return $doc, "test2.xml") >> >> Kind regards, >> Andreas >> >> On 10.05.2011, at 07:11, David Reichle wrote: >> >> > I'm trying to do an update operation on a file using standalone cmdline >> > basex. >> > >> > The xml-declaration get printed to stdout instead of to the updated >> > file. >> > >> > $cat test.xml >> > <?xml version="1.0" encoding="UTF-8"?> >> > <root> >> > <test/> >> > </root> >> > >> > $cat test.xq >> > declare option output:omit-xml-declaration "no"; >> > >> > let $root := doc("test.xml")/root >> > return insert node <test/> into $root >> > >> > $basex -u test.xq >> > >> > $cat test.xml >> > <root> >> > <test/> >> > <test/> >> > </root> >> > >> > The declaration gets removed :< >> > >> > _______________________________________________ >> > BaseX-Talk mailing list >> > BaseX-Talk at mailman.uni-konstanz.de >> > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
CG
Christian Grünin reply to David Reichle, 13 May 2011, 08:1513 May 2011 07:37 #
This behavior is implementation-defined. mxquery will always add an xml declaration to the result, no matter if it has been specified before. Christian
Quoted text · David Reichle · 129 lines
Am 13.05.2011 06:15 schrieb "David Reichle" <dreichle at cableone.net>: > The serialization parameter 'omit-xml-declaration' is being specified. I > ran the following test > with basex and mxquery to compare the behavior. > > > $ > $ cat test.xq > let $root := doc("test.xml")/root > return insert node <test/> into $root > $ > $ echo "<root/>" > test.xml > $ java -jar mxquery.jar -um -x -s omit-xml-declaration=no -f test.xq > May 12, 2011 9:40:33 PM ch.ethz.mxquery.cmdline.MXQuery executeQuery > WARNING: Logger started > May 12, 2011 9:40:33 PM ch.ethz.mxquery.util.Logger log > INFO: Parsing completed, took 24 ms > <?xml version='1.0' encoding='UTF-8' ?>$ > $ > $ cat test.xml > <?xml version='1.0' encoding='UTF-8' ?><root><test/></root>$ > $ > $ echo "<root/>" > test.xml > $ > $ basex -s omit-xml-declaration=no -u test.xq > <?xml version="1.0" encoding="UTF-8"?>$ > $ > $ cat test.xml > <root> > <test/> > </root>$ > $ > $ > > > You can see that mxquery also prints the declaration to stdout like basex > but also inserts it into the updated serialized test.xml. I haven't tried > any other processors but the behavior of mxquery is what I would expect. > I looked but didn't see anything in the XQuery Update Facility specification > about serialization behavior. > > David > > > On Thu, May 12, 2011 at 1:57 AM, Christian Grün > <christian.gruen at gmail.com>wrote: > >> Dear David, >> >> thanks, all observations on potential bugs are welcome. In this case, >> the behavior is indeed expected (although somewhat counterintuitive): >> When the document is serialized to disk, we have already lost the >> information if an XML declaration was specified. Other information, >> such as DTD declarations and entities, are lost as well as long as >> they are not explicitly specified as serialization parameters. >> >> Best, >> Christian >> ___________________________ >> >> On Thu, May 12, 2011 at 6:24 AM, David Reichle <dreichle at cableone.net> >> wrote: >> > I'm sorry; I wasn't really _trying_ to do anything, except to point out >> what >> > I consider a bug. >> > Thank-you for your reply. >> > >> > On Tue, May 10, 2011 at 5:27 AM, Andreas Weiler >> > <andreas.weiler at uni-konstanz.de> wrote: >> >> >> >> Hi David, >> >> >> >> the following query does what you trying to do (i guess): >> >> >> >> declare option output:omit-xml-declaration "no"; >> >> put( >> >> copy $doc := doc("test.xml") >> >> modify insert node <testnew/> into $doc/root >> >> return $doc, "test2.xml") >> >> >> >> Kind regards, >> >> Andreas >> >> >> >> On 10.05.2011, at 07:11, David Reichle wrote: >> >> >> >> > I'm trying to do an update operation on a file using standalone >> cmdline >> >> > basex. >> >> > >> >> > The xml-declaration get printed to stdout instead of to the updated >> >> > file. >> >> > >> >> > $cat test.xml >> >> > <?xml version="1.0" encoding="UTF-8"?> >> >> > <root> >> >> > <test/> >> >> > </root> >> >> > >> >> > $cat test.xq >> >> > declare option output:omit-xml-declaration "no"; >> >> > >> >> > let $root := doc("test.xml")/root >> >> > return insert node <test/> into $root >> >> > >> >> > $basex -u test.xq >> >> > >> >> > $cat test.xml >> >> > <root> >> >> > <test/> >> >> > <test/> >> >> > </root> >> >> > >> >> > The declaration gets removed :< >> >> > >> >> > _______________________________________________ >> >> > BaseX-Talk mailing list >> >> > BaseX-Talk at mailman.uni-konstanz.de >> >> > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> >> > >> > >> > _______________________________________________ >> > BaseX-Talk mailing list >> > BaseX-Talk at mailman.uni-konstanz.de >> > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > >> > >>
DR
David Reichlein reply to Christian Grün, 12 May 2011, 09:5713 May 2011 08:15 #
The serialization parameter 'omit-xml-declaration' is being specified. I ran the following test with basex and mxquery to compare the behavior. $ $ cat test.xq let $root := doc("test.xml")/root return insert node <test/> into $root $ $ echo "<root/>" > test.xml $ java -jar mxquery.jar -um -x -s omit-xml-declaration=no -f test.xq May 12, 2011 9:40:33 PM ch.ethz.mxquery.cmdline.MXQuery executeQuery WARNING: Logger started May 12, 2011 9:40:33 PM ch.ethz.mxquery.util.Logger log INFO: Parsing completed, took 24 ms <?xml version='1.0' encoding='UTF-8' ?>$ $ $ cat test.xml <?xml version='1.0' encoding='UTF-8' ?><root><test/></root>$ $ $ echo "<root/>" > test.xml $ $ basex -s omit-xml-declaration=no -u test.xq <?xml version="1.0" encoding="UTF-8"?>$ $ $ cat test.xml <root> <test/> </root>$ $ $ You can see that mxquery also prints the declaration to stdout like basex but also inserts it into the updated serialized test.xml. I haven't tried any other processors but the behavior of mxquery is what I would expect. I looked but didn't see anything in the XQuery Update Facility specification about serialization behavior. David On Thu, May 12, 2011 at 1:57 AM, Christian Grün <christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 81 lines
> Dear David, > > thanks, all observations on potential bugs are welcome. In this case, > the behavior is indeed expected (although somewhat counterintuitive): > When the document is serialized to disk, we have already lost the > information if an XML declaration was specified. Other information, > such as DTD declarations and entities, are lost as well as long as > they are not explicitly specified as serialization parameters. > > Best, > Christian > ___________________________ > > On Thu, May 12, 2011 at 6:24 AM, David Reichle <dreichle at cableone.net> > wrote: > > I'm sorry; I wasn't really _trying_ to do anything, except to point out > what > > I consider a bug. > > Thank-you for your reply. > > > > On Tue, May 10, 2011 at 5:27 AM, Andreas Weiler > > <andreas.weiler at uni-konstanz.de> wrote: > >> > >> Hi David, > >> > >> the following query does what you trying to do (i guess): > >> > >> declare option output:omit-xml-declaration "no"; > >> put( > >> copy $doc := doc("test.xml") > >> modify insert node <testnew/> into $doc/root > >> return $doc, "test2.xml") > >> > >> Kind regards, > >> Andreas > >> > >> On 10.05.2011, at 07:11, David Reichle wrote: > >> > >> > I'm trying to do an update operation on a file using standalone > cmdline > >> > basex. > >> > > >> > The xml-declaration get printed to stdout instead of to the updated > >> > file. > >> > > >> > $cat test.xml > >> > <?xml version="1.0" encoding="UTF-8"?> > >> > <root> > >> > <test/> > >> > </root> > >> > > >> > $cat test.xq > >> > declare option output:omit-xml-declaration "no"; > >> > > >> > let $root := doc("test.xml")/root > >> > return insert node <test/> into $root > >> > > >> > $basex -u test.xq > >> > > >> > $cat test.xml > >> > <root> > >> > <test/> > >> > <test/> > >> > </root> > >> > > >> > The declaration gets removed :< > >> > > >> > _______________________________________________ > >> > BaseX-Talk mailing list > >> > BaseX-Talk at mailman.uni-konstanz.de > >> > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >> > > > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > >

⚡Generated with XQuery