Given an XML file which contains a newline character reference ( ) in the value of an attribute, the following groovy code incorrectly outputs the actual newline character instead of the original character reference. This is a significant problem because the XML standard dictates that newlines found in the value of an attribute must be treated as a space. Thus, if any XML parser reads the output of this groovy snippet, it is as if the newline is gone.
<option name="LINE_SEPARATOR" value=" "/>
def fileWriter = new FileWriter('./newline-roundtrip.xml')
def input = new XmlParser().parse('./newline.xml')
PrintWriter printWriter = new PrintWriter(fileWriter)
I've attached a junit test which demonstrates the problem.