Bug #3708

Serialization options ignored for XQuery update from command line

Added by Michael Kay over 2 years ago. Updated over 2 years ago.

XQuery Update
Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:


From direct email:

I have a XQuery which modifies the content of /text/a and reserves CDATA in /test/pattern of a XML file.

xquery version "3.0";
declare namespace saxon = "";
declare option saxon:output "cdata-section-elements=pattern";

let $doc := doc('testCDATA.xml')
return replace value of node $doc/test/a with 'fromxquery'

The XML file testCDATA.xml :


It works well in oXygen 19.1 with Saxon-EE

But if I run it with the Saxon (Saxon-EE command:

java -cp saxon9ee.jar net.sf.saxon.Query -t -backup:off -update:on -q:testCDATA.xquery

"CDATA" is get rid of the XML. It seems that options of serialization are not taken in Saxon for an update of the same file. If I missed something or it's a problem of Saxon?


#1 Updated by Michael Kay over 2 years ago

  • Status changed from New to In Progress

Confirmed that the problem exists.

Note that you can work around the problem by supplying serialization parameters on the command line, e.g.


#2 Updated by Michael Kay over 2 years ago

  • Status changed from In Progress to Resolved
  • Applies to branch 9.8, trunk added
  • Fix Committed on Branch 9.8, trunk added

Resolved in net.sf.saxon.Query by initializing the Serializer from the query properties:

if (updating && exp.isUpdateQuery()) {
                        runUpdate(exp, evaluator, serializer);

Note that this is specific to command-line invocation. At the API level, XQuery makes the updated documents available to the application, which can serialize them (and/or write them as files to filestore) if it wishes to do so.

#3 Updated by O'Neil Delpratt over 2 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release added

Bug fix applied in the Saxon maintenance release.

Please register to edit this issue

Also available in: Atom PDF