don't escape umlaut in elem utf8
This commit is contained in:
parent
b01c64dc2c
commit
ebc2a7a6ba
|
@ -1,8 +1,11 @@
|
|||
package org.hl7.fhir.r5.test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
|
@ -239,4 +242,26 @@ public class CDARoundTripTests {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
/**
|
||||
* verify that umlaut like äö etc are not encoded in UTF-8 in attributes
|
||||
*/
|
||||
public void testSerializeUmlaut() throws IOException {
|
||||
Element xml = Manager.parse(context,
|
||||
TestingUtilities.loadTestResourceStream("validator", "cda", "example.xml"), FhirFormat.XML);
|
||||
|
||||
List<Element> title = xml.getChildrenByName("title");
|
||||
assertTrue(title != null && title.size() == 1);
|
||||
|
||||
|
||||
Element value = title.get(0).getChildren().get(0);
|
||||
Assertions.assertEquals("Episode Note", value.getValue());
|
||||
value.setValue("öé");
|
||||
|
||||
ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
|
||||
Manager.compose(TestingUtilities.context(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
String cdaSerialised = baosXml.toString("UTF-8");
|
||||
assertTrue(cdaSerialised.indexOf("öé") > 0);
|
||||
}
|
||||
|
||||
}
|
|
@ -726,7 +726,7 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter {
|
|||
if (dontEscape)
|
||||
write(content);
|
||||
else
|
||||
write(XMLUtil.escapeXML(content, "US-ASCII", false));
|
||||
write(XMLUtil.escapeXML(content, charset, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue