Project

Profile

Help

Bug #3708

Serialization options ignored for XQuery update from command line

Added by Michael Kay over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XQuery Update
Sprint/Milestone:
-
Start date:
2018-03-01
Due date:
% Done:

100%

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

Description

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 = "http://saxon.sf.net/";
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 :

<test>
   <a>test</a>
  <pattern><![CDATA[(?<=(^|[^0-9]+))([0-9]+([-]+[0-9]+)*)(?=([^0-9]+|$))]]></pattern>
</test>

It works well in oXygen 19.1 with Saxon-EE 9.7.0.19

But if I run it with the Saxon (Saxon-EE 9.8.0.6J) 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?

History

#1 Updated by Michael Kay over 1 year 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.

!cdata-section-elements=pattern

#2 Updated by Michael Kay over 1 year 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()) {
                        serializer.setDefaultOutputProperties(
                                exp.getUnderlyingCompiledQuery().getExecutable().getDefaultOutputProperties());
                        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 about 1 year ago

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

Bug fix applied in the Saxon 9.8.0.10 maintenance release.

Please register to edit this issue

Also available in: Atom PDF