// Get the Schema object from the factory
this.grammar = spf.getSchema();
if (grammar != null) {
XMLParserConfiguration config = xmlReader.getXMLParserConfiguration();
XMLComponent validatorComponent = null;
/** For Xerces grammars, use built-in schema validator. **/
if (grammar instanceof XSGrammarPoolContainer) {
validatorComponent = new XMLSchemaValidator();
fSchemaValidationManager = new ValidationManager();
XMLDTDFilter entityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
config.setDTDHandler(entityHandler);
entityHandler.setDTDHandler(xmlReader);
xmlReader.setDTDSource(entityHandler);
fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
(XSGrammarPoolContainer) grammar, fSchemaValidationManager);
}
/** For third party grammars, use the JAXP validator component. **/
else {
validatorComponent = new JAXPValidatorComponent(grammar.newValidatorHandler());
fSchemaValidatorComponentManager = config;
}
config.addRecognizedFeatures(validatorComponent.getRecognizedFeatures());
config.addRecognizedProperties(validatorComponent.getRecognizedProperties());
config.setDocumentHandler((XMLDocumentHandler) validatorComponent);
((XMLDocumentSource)validatorComponent).setDocumentHandler(xmlReader);
xmlReader.setDocumentSource((XMLDocumentSource) validatorComponent);
fSchemaValidator = validatorComponent;
}