From 5e169dea9405388e0451bf04522f847f6c7cd1b4 Mon Sep 17 00:00:00 2001 From: OrangeAndGreen Date: Wed, 29 May 2024 13:12:58 -0400 Subject: [PATCH 1/3] Use System.lineSeparator in XmlUtil (for Windows compatibility) --- src/translate/java/org/javarosa/engine/xml/XmlUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/translate/java/org/javarosa/engine/xml/XmlUtil.java b/src/translate/java/org/javarosa/engine/xml/XmlUtil.java index 9820a82bbb..ce7a230e27 100644 --- a/src/translate/java/org/javarosa/engine/xml/XmlUtil.java +++ b/src/translate/java/org/javarosa/engine/xml/XmlUtil.java @@ -41,7 +41,7 @@ public static String getPrettyXml(byte[] xml) { DOMConfiguration domConfig = lsSerializer.getDomConfig(); domConfig.setParameter("format-pretty-print", true); domConfig.setParameter("cdata-sections", true); - lsSerializer.setNewLine("\n"); + lsSerializer.setNewLine(System.lineSeparator()); lsSerializer.write(document, lsOutput); return stringWriter.toString(); } catch (Exception e) { From 737f2f43f018c51d82cd1e70b97de3647ffd51c3 Mon Sep 17 00:00:00 2001 From: Dave Viggiano Date: Thu, 30 May 2024 12:48:22 -0400 Subject: [PATCH 2/3] Merging XmlUtil.java from formplayer branch. --- src/translate/java/org/javarosa/engine/xml/XmlUtil.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/translate/java/org/javarosa/engine/xml/XmlUtil.java b/src/translate/java/org/javarosa/engine/xml/XmlUtil.java index ce7a230e27..872acf052e 100644 --- a/src/translate/java/org/javarosa/engine/xml/XmlUtil.java +++ b/src/translate/java/org/javarosa/engine/xml/XmlUtil.java @@ -41,6 +41,12 @@ public static String getPrettyXml(byte[] xml) { DOMConfiguration domConfig = lsSerializer.getDomConfig(); domConfig.setParameter("format-pretty-print", true); domConfig.setParameter("cdata-sections", true); + + // LSSerializer does not have an explicit control for ending the XML Declaration with a + // newline, hence the need for the property isStandalone + // More in https://bugs.openjdk.org/browse/JDK-8259502 + domConfig.setParameter("http://www.oracle.com/xml/jaxp/properties/isStandalone", true); + lsSerializer.setNewLine(System.lineSeparator()); lsSerializer.write(document, lsOutput); return stringWriter.toString(); @@ -52,6 +58,7 @@ public static String getPrettyXml(byte[] xml) { private static Document parseXmlFile(String in) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(in)); return db.parse(is); From 03b0fffa792ce1afdd51b9e3ef951022b724fdd1 Mon Sep 17 00:00:00 2001 From: Dave Viggiano Date: Thu, 30 May 2024 13:58:03 -0400 Subject: [PATCH 3/3] Updated test resource XML file from formplayer branch --- src/test/resources/pretty_printed_xml.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/resources/pretty_printed_xml.xml b/src/test/resources/pretty_printed_xml.xml index 8f389037c9..eb9b202a41 100644 --- a/src/test/resources/pretty_printed_xml.xml +++ b/src/test/resources/pretty_printed_xml.xml @@ -1,9 +1,10 @@ - + + Basic Form - + - + @@ -53,7 +54,7 @@ - +