// 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();
fUnparsedEntityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
config.setDTDHandler(fUnparsedEntityHandler);
fUnparsedEntityHandler.setDTDHandler(xmlReader);
xmlReader.setDTDSource(fUnparsedEntityHandler);
fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
(XSGrammarPoolContainer) grammar, fSchemaValidationManager);
}
/** For third party grammars, use the JAXP validator component. **/
else {
validatorComponent = new JAXPValidatorComponent(grammar.newValidatorHandler());
fSchemaValidationManager = null;
fUnparsedEntityHandler = null;
fSchemaValidatorComponentManager = config;
}
config.addRecognizedFeatures(validatorComponent.getRecognizedFeatures());
config.addRecognizedProperties(validatorComponent.getRecognizedProperties());
config.setDocumentHandler((XMLDocumentHandler) validatorComponent);
((XMLDocumentSource)validatorComponent).setDocumentHandler(xmlReader);
xmlReader.setDocumentSource((XMLDocumentSource) validatorComponent);
fSchemaValidator = validatorComponent;
}