0
2つのXMLファイルがあり、XMLUNITを使用してそれらを比較すると、以下の例外が発生します。XMLUNIT XMLファイルを比較するときの名前空間の例外
Exception in thread "main" org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkDOMNSErr(CoreDocumentImpl.java:2530)
at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.setName(AttrNSImpl.java:117)
at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.<init>(AttrNSImpl.java:78)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttributeNS(CoreDocumentImpl.java:2142)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1596)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1560)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.cloneNode(CoreDocumentImpl.java:362)
at com.sun.org.apache.xerces.internal.dom.DocumentImpl.cloneNode(DocumentImpl.java:159)
at org.custommonkey.xmlunit.XMLUnit.stripWhiteSpaceWithoutXSLT(XMLUnit.java:522)
at org.custommonkey.xmlunit.XMLUnit.getWhitespaceStrippedDocument(XMLUnit.java:506)
at org.custommonkey.xmlunit.Diff.getWhitespaceManipulatedDocument(Diff.java:182)
at org.custommonkey.xmlunit.Diff.getManipulatedDocument(Diff.java:203)
at org.custommonkey.xmlunit.Diff.<init>(Diff.java:155)
at org.custommonkey.xmlunit.Diff.<init>(Diff.java:168)
at org.custommonkey.xmlunit.DetailedDiff.<init>(DetailedDiff.java:60)
私は以下のコードを使用していますが、期待通りに動作しません。
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
try {
factory.setFeature("http://xml.org/sax/features/namespaces", false);
factory.setFeature("http://xml.org/sax/features/validation", false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);;
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
XMLUnit.setTestDocumentBuilderFactory(factory);
XMLUnit.setControlDocumentBuilderFactory(factory);
XMLUnit.setIgnoreWhitespace(Boolean.TRUE);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUNITで名前空間の検証が無視されるようにするにはどうすればよいですか。