Project

Profile

Help

Bug #4173

closed

XdmNode.toString() on text nodes

Added by Michael Kay about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
s9api API
Sprint/Milestone:
-
Start date:
2019-03-20
Due date:
% Done:

100%

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

Description

Bug #4081 -- see comment 5 -- changed the effect of XdmNode.toString() to trim leading and trailing whitespace from the result. This is fine for document and element nodes, but it is wrong for text nodes.

Note that XdmNode.toString() on a text node will escape special characters such as "&" and "<"; this should perhaps be noted in the documentation.

Users should probably be calling XdmNode.getStringValue() instead, but this doesn't alter the fact that trimming the value here is incorrect.

Reported by Norm Walsh on Saxon help mailing list

Actions #1

Updated by Michael Kay about 3 years ago

Looking at the code I noticed that the escaping for attribute and namespace nodes is done incorrectly. The code is written

String val = node.getStringValue()
                    .replace("\"", "&quot;")
                    .replace("<", "&lt;")
                    .replace("&", "&amp;");

which will have the effect of outputting < as &amp;lt;

Actions #2

Updated by Michael Kay about 3 years ago

  • Status changed from New to Resolved
  • Fix Committed on Branch 9.9, trunk added

Patch committed on 9.9 and trunk. Unit test TestXdmNode.testToString() added.

Actions #3

Updated by O'Neil Delpratt about 3 years ago

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

Bug fix applied to the Saxon 9.9.1.3 maintenance release

Please register to edit this issue

Also available in: Atom PDF