List of usage examples for org.w3c.dom Document isEqualNode
public boolean isEqualNode(Node arg);
From source file:Main.java
public static boolean compareXmls(InputStream xml1, InputStream xml2) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true);//w w w .j a v a 2 s .c o m dbf.setCoalescing(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setIgnoringComments(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc1 = db.parse(xml1); doc1.normalizeDocument(); Document doc2 = db.parse(xml2); doc2.normalizeDocument(); return doc2.isEqualNode(doc1); }
From source file:cz.muni.fi.mir.mathmlunificator.AbstractXMLTransformationTest.java
protected boolean isDOMEqual(Document templateDoc, Document testedDoc) { return templateDoc.isEqualNode(testedDoc); }
From source file:org.apache.rahas.impl.util.SAMLUtilsTest.java
private static boolean equals(String element1, String element2) throws ParserConfigurationException, IOException, SAXException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true);//from w w w . j av a 2 s . co m dbf.setCoalescing(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setIgnoringComments(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc1 = db.parse(new ByteArrayInputStream(element1.getBytes("UTF-8"))); doc1.normalizeDocument(); Document doc2 = db.parse(new ByteArrayInputStream(element1.getBytes("UTF-8"))); doc2.normalizeDocument(); return doc1.isEqualNode(doc2); }
From source file:org.docx4j.openpackaging.parts.XmlPart.java
public boolean isContentEqual(Part other) throws Docx4JException { if (!(other instanceof XmlPart)) return false; Document doc1 = getDocument(); Document doc2 = ((XmlPart) other).getDocument(); return doc1.isEqualNode(doc2); }
From source file:org.mule.modules.sugarcrm.automation.unit.TransformerXmlToCxfTest.java
@Test public void validTransformationXmlFromSugar() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true);//from w w w. jav a 2 s. co m dbf.setCoalescing(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setIgnoringComments(true); DocumentBuilder db = dbf.newDocumentBuilder(); String xml = IOUtils.getResourceAsString("response-searchByModule.xml", getClass()); String xmlTransform = new XmlToCxfTransformer().transform(xml); Document doc1 = db.parse(org.apache.commons.io.IOUtils.toInputStream(xmlTransform)); doc1.normalizeDocument(); Document doc2 = db.parse(IOUtils.getResourceAsStream("response-searchByModule-ok.xml", getClass())); doc2.normalizeDocument(); Assert.assertTrue(doc1.isEqualNode(doc2)); }