Hello,
I have a problem, I have an error and don't know where is the problem:
//I've just copied it from some web-page...
public void testValidation() throws Exception { XMLUnit.getTestDocumentBuilderFactory().setValidating(true); Document myTestDocument = XMLUnit.buildTestDocument("myXml.xml"); String mySystemId = "pubID"; String myDTDUrl = new File("dtdfile.dtd").toURL().toExternalForm(); Validator myValidator = new Validator(myTestDocument, mySystemId, myDTDUrl); assertTrue("test document validates against unreferenced DTD", myValidator.isValid()); }
and the error is
org.xml.sax.SAXParseException: Content is not allowed in prolog. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
I have a simple xml, dtd file. I have validate them, no errors...
I just wanna to test if the export of the XML is correct.
The problem seems to be in a line
Document myTestDocument = XMLUnit.buildTestDocument("myXml.xml");
Please help. Thanks in advance.