I was referring to XQuery update writeback, chop option is set to false:
$ basex.bat -u -w -c"set exporter omit-xml-declaration=no,indent=no" -itest.xml update.xquery
update.xquery:
for $c in doc(document-uri())//kennung return (replace value of node $c with "REPLACED")
test.xml:
<?xml version="1.0" encoding="UTF-8"?> <root><vs> <kennung>test</kennung> <absatz> <fett>eins</fett> </absatz> </vs> </root>
Result
<?xml version="1.0" encoding="UTF-8"?> <root><vs><kennung>REPLACED</kennung><absatz><fett>eins</fett></absatz><absatz>Test<fett>fett</fett><kursiv>kursiv</kursiv>Text z.B. am 01.02.2018 Text.</absatz></vs></root>
Saxon does not change indentation (with declare option saxon:output "indent=no")
-----Ursprüngliche Nachricht----- Von: Christian Grün [mailto:christian.gruen@gmail.com] Gesendet: Donnerstag, 13. Dezember 2018 12:41 An: Zimmel, Daniel Cc: BaseX Betreff: Re: [basex-talk] Command line options not working with update operation on input file
The only thing is I prefer the Saxon default about not changing anything on
already existing indentation (BaseX is deleting any indentation with indent=no), but I am aware this is implementation-defined.
Existing identation is actually preserved by both BaseX and Saxon:
declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization'; declare option output:indent 'no'; parse-xml('<a> <b/> </a>')
Were you referring to documents with chopped whitespaces?
Cheers Christian
-----Ursprüngliche Nachricht----- Von: Christian Grün [mailto:christian.gruen@gmail.com] Gesendet: Mittwoch, 12. Dezember 2018 18:47 An: Zimmel, Daniel Cc: BaseX Betreff: Re: [basex-talk] Command line options not working with update
operation
on input file
…I think I got what you were trying to achieve! There is a separate option for exporting databases and writing updates. This may be more obvious now after another updates of our documentation [1].
Here is a little self-contained BaseX call that (as I hope) demonstrates the behavior:
basex -u -c"set exporter omit-xml-declaration=no" "file:write('doc.xml', <a/>)" "insert node <b/> into doc('doc.xml')/*" "fetch:xml('doc.xml')"
<?xml version="1.0" encoding="UTF-8"?>
<a> <b/> </a>
You can also run the following command script ("basex script.bxs"):
set exporter omit-xml-declaration=no set writeback on xquery file:write('doc.xml', <a/>) xquery insert node <a/> into doc('doc.xml')/* xquery fetch:xml('doc.xml')
Maybe we’ll merge these two options in a future release of BaseX. Until then, just add an EXPORTER option to your .basex file with the identical serialization parameters.
Best Christian
[1] http://docs.basex.org/wiki/Options#WRITEBACK
On Wed, Dec 12, 2018 at 6:35 PM Christian Grün christian.gruen@gmail.com wrote:
Any serialization parameter gets ignored from the command line with
XQuery
Update.
Has this been solved? Is this a bug?
XML declarations are never stored in the database. Instead, they will be added during serialization. So I’m not exactly on what you just tried to do. Could you please give some step-by-step instructions?