|
From: Bonnet E. <eb...@ge...> - 2003-02-07 11:12:02
|
I think I found it :
The features necessary for the SAX parser are not added in the case of XSD validation.
Here is the code I changed in the Validator Class to make it work.
I still have a problem later with the assertXMLEquals.
But now XmlUnit validates my files with XSD.
____________________________________________________________
/**
* Baseline constructor: called by all others
* @param inputSource
* @param usingDoctypeReader
* @throws ParserConfigurationException
* @throws SAXException
*/
protected Validator(InputSource inputSource, boolean usingDoctypeReader)
throws ParserConfigurationException, SAXException {
isValid = null;
messages = new StringBuffer();
SAXParserFactory factory = XMLUnit.getSAXParserFactory();
factory.setValidating(true);
parser = factory.newSAXParser();
this.validationInputSource = inputSource;
this.usingDoctypeReader = usingDoctypeReader;
//---- EB modification
parser.getXMLReader().setFeature("http://xml.org/sax/features/validation", true);
parser.getXMLReader().setFeature("http://apache.org/xml/features/validation/schema", ! usingDoctypeReader);
parser.getXMLReader().setFeature("http://apache.org/xml/features/validation/dynamic", true);
}
_________________________________________________________________________
Hope this helps,
Emmanuel
|