Bug #4173
closedXdmNode.toString() on text nodes
100%
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
Updated by Michael Kay about 5 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("\"", """)
.replace("<", "<")
.replace("&", "&");
which will have the effect of outputting <
as &lt;
Updated by Michael Kay about 5 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.
Updated by O'Neil Delpratt almost 5 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