Project

Profile

Help

Bug #5788

closed

XdmNode.toString() is no longer indented

Added by O'Neil Delpratt almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Serialization
Sprint/Milestone:
-
Start date:
2023-01-03
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

Issue reported by user here: https://saxonica.plan.io/boards/4/topics/9166

The default toString() of an XdmNode with SaxonJ and SaxonCS seems to use indentation while that doesn't happen for SaxonC.

See repo below:

from saxonc import *

with PySaxonProcessor(license=False) as proc:

    doc_builder = proc.new_document_builder()

    xml2 = '''<root><item>a</item><item>b</item><item>c</item></root>'''

    xdm_node2 = doc_builder.parse_xml(xml_text = xml2)

    print(xdm_node2)
Actions #1

Updated by O'Neil Delpratt almost 2 years ago

  • Assignee changed from O'Neil Delpratt to Michael Kay

It looks like the underlying problem is with SaxonJ 12.0.

Actions #2

Updated by Michael Kay almost 2 years ago

  • Project changed from SaxonC to Saxon
  • Category deleted (Saxon-C Internals)
  • Status changed from New to In Progress
  • Priority changed from Low to Normal
  • Found in version deleted (11.99)
  • Platforms .NET, Java added
  • Applies to branch 12, trunk added

In the past XdmNode had its own toString() method. It now inherits from XdmValue.toString(). This uses the Adaptive serialization method. It sets the serialization options indent=yes, but at AdaptiveEmitter.serializeNode() line 230 this is overridden with indent=no.

Actions #3

Updated by Michael Kay almost 2 years ago

I changed that and it made no difference.

In the serialization properties as passed to QueryResult.serialize(), the "indent" property has the value "true", but the SerializerFactory is expecting "yes". On public APIs this would be caught by validation, but it's not being checked when we set the values internally.

Having fixed this, I'm seeing test failures because the serialized output of a node contains a trailing newline, which unit tests aren't expecting.

Actions #4

Updated by Michael Kay almost 2 years ago

  • Category set to Serialization
  • Status changed from In Progress to Resolved
  • Fix Committed on Branch 12, trunk added

I have expanded the Javadoc for XdmValue.toString() to set expectations more clearly, and have added tests. Trailing newlines are now removed from the result.

Actions #5

Updated by Michael Kay almost 2 years ago

  • Subject changed from default toString() of an XdmNode not indent SaxonC to XdmNode.toString() is no longer indented
Actions #6

Updated by O'Neil Delpratt over 1 year ago

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

Bug fix applied in the Saxon 12.1 maintenance release.

Please register to edit this issue

Also available in: Atom PDF