Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Version 2.2
-
None
-
None
Description
I'm formatting a XML Document using the following XMLOptions:
XmlOptions options = new XmlOptions();
options.setSavePrettyPrint();
XmlOptionCharEscapeMap escapes = new XmlOptionCharEscapeMap();
escapes.addMapping('<', XmlOptionCharEscapeMap.PREDEF_ENTITY);
escapes.addMapping('>', XmlOptionCharEscapeMap.PREDEF_ENTITY);
escapes.addMapping('&', XmlOptionCharEscapeMap.PREDEF_ENTITY);
escapes.addMapping('\'', XmlOptionCharEscapeMap.PREDEF_ENTITY);
escapes.addMapping('"', XmlOptionCharEscapeMap.PREDEF_ENTITY);
options.setSaveSubstituteCharacters(escapes);
This works when using content containing the escaped chars, but attribut values are not escaped:
<inventory>
<customer name1=">"/>
</inventory>
This should be:
<inventory>
<customer name1=">"/>
</inventory>
The reason for this is, that Saver.entitizeAttrValue() does not contain:
[....]
else if (isEscapedChar( ch ))
i = replace( i, _replaceChar.getEscapedString( ch ) );
[....]
This is only done in Saver.entitizeContent().