XdmNode.toString() on text nodes
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 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("\"", """) .replace("<", "<") .replace("&", "&");
which will have the effect of outputting
Please register to edit this issue