@Test public void testNormalizer() { String xml1 = readFileAsString("src/test/resources/response-expected-result-single-line.xml"); String xml2 = readFileAsString("src/test/resources/response-expected-result-formatted.xml"); xml1 = XPathUtil.normalizeXmlString(xml1); xml2 = XPathUtil.normalizeXmlString(xml2); assertEquals(xml1, xml2); }
public static String normalizeXmlString(String xml) { log.debug("XML from start:\n{}", xml); Document doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, false, 0); log.debug("XML after removing whitespace:\n{}", xml); doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, true, 2); log.debug("XML fully normalized:\n{}", xml); return xml; }
XPathUtil { public static String normalizeXmlString(String xml) { log.debug("XML from start:\n{}", xml); Document doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, false, 0); log.debug("XML after removing whitespace:\n{}", xml); doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, true, 2); log.debug("XML fully normalized:\n{}", xml); return xml; } }
XPathUtil { public static String normalizeXmlString(String xml) { log.debug("XML from start:\n{}", xml); Document doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, false, 0); log.debug("XML after removing whitespace:\n{}", xml); doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, true, 2); log.debug("XML fully normalized:\n{}", xml); return xml; } private  XPathUtil(); }
XPathUtil { public static String normalizeXmlString(String xml) { log.debug("XML from start:\n{}", xml); Document doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, false, 0); log.debug("XML after removing whitespace:\n{}", xml); doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, true, 2); log.debug("XML fully normalized:\n{}", xml); return xml; } private  XPathUtil(); static Document createDocument(InputStream content); static Document createDocument(String content); static Document createDocument(String content, String charset); static DocumentBuilder getBuilder(); static String getDocumentComment(Document doc); static NodeList getXPathResult(Node node, String namespacePrefix, String namespaceURI, String expression); static NodeList getXPathResult(Node node, Map<String, String> namespaceMap, String expression); static String getFirstValue(NodeList nodes); static List<String> getValues(NodeList nodes); static void appendXmlFragment(Node parent, String fragment); static String getXml(Node node); static String getXml(Node node, boolean indentXml, int indentSize); static XMLGregorianCalendar convertDateToXmlDate(Date date); static String lookupParameterValue(String key, String string); static String normalizeXmlString(String xml); }
XPathUtil { public static String normalizeXmlString(String xml) { log.debug("XML from start:\n{}", xml); Document doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, false, 0); log.debug("XML after removing whitespace:\n{}", xml); doc = createDocument(xml); doc.setXmlStandalone(true); xml = getXml(doc, true, 2); log.debug("XML fully normalized:\n{}", xml); return xml; } private  XPathUtil(); static Document createDocument(InputStream content); static Document createDocument(String content); static Document createDocument(String content, String charset); static DocumentBuilder getBuilder(); static String getDocumentComment(Document doc); static NodeList getXPathResult(Node node, String namespacePrefix, String namespaceURI, String expression); static NodeList getXPathResult(Node node, Map<String, String> namespaceMap, String expression); static String getFirstValue(NodeList nodes); static List<String> getValues(NodeList nodes); static void appendXmlFragment(Node parent, String fragment); static String getXml(Node node); static String getXml(Node node, boolean indentXml, int indentSize); static XMLGregorianCalendar convertDateToXmlDate(Date date); static String lookupParameterValue(String key, String string); static String normalizeXmlString(String xml);  }