final String publicId,
final Logger logger )
throws Exception
{
setupResolver();
final SAXConfigurationHandler handler = new SAXConfigurationHandler();
if( null == publicId )
{
final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setNamespaceAware( false );
final SAXParser saxParser = saxParserFactory.newSAXParser();
final XMLReader reader = saxParser.getXMLReader();
reader.setEntityResolver( c_resolver );
reader.setContentHandler( handler );
reader.setErrorHandler( handler );
reader.parse( input );
}
else
{
final InputSource inputSource = c_resolver.resolveEntity( publicId,
null );
if( null == inputSource )
{
final String message = "Unable to locate schema with publicID=" +
publicId;
throw new IllegalStateException( message );
}
final ConfigValidator validator =
ConfigValidatorFactory.create( inputSource, c_resolver );
final ValidationResult result = validator.validate( input,
(ContentHandler)handler );
processValidationResults( result, logger );
}
return handler.getConfiguration();
}