/** Default constructor. */ public CachingParserPool() { this(new SymbolTable(), new XMLGrammarPoolImpl()); } // <init>()
XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl(); pool.putGrammar(grammar); XMLSchema11Factory factory = new XMLSchema11Factory(); Schema schema = factory.newSchema(pool); Validator validator = schema.newValidator(); DOMSource source = new DOMSource(document); validator.validate(source);
/** * Create and configure the two grammar pools for this WSDL validation context. * * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#setupValidation(org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext) */ protected void setupValidation(NestedValidatorContext context) { super.setupValidation(context); XMLGrammarPool xsdGrammarPool = new InlineSchemaModelGrammarPoolImpl(); XMLGrammarPool xmlGrammarPool = new XMLGrammarPoolImpl(); xsdGrammarPools.put(context, xsdGrammarPool); xmlGrammarPools.put(context, xmlGrammarPool); }
/** * Get an instance of XSLoader that is capable of * parsing schema files * * @return */ public XSLoader getXSLoader() { XMLSchemaLoader xsloader = new XMLSchemaLoader(); JBossXSErrorHandler eh = new JBossXSErrorHandler(); xsloader.setErrorHandler(eh); xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl()); return xsloader; }
/** * Get an instance of XSLoader that is capable of * parsing schema files * @param xeh XML Error handler * @param xer XML Entity Resolver * @return */ public XSLoader getXSLoader(XMLErrorHandler xeh, XMLEntityResolver xer) { XMLSchemaLoader xsloader = new XMLSchemaLoader(); xsloader.setEntityResolver(xer); xsloader.setErrorHandler(xeh); xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl()); return xsloader; }
/** * Associate an <code>ASModel</code> with a document instance. This * <code>ASModel</code> will be used by the " * <code>validate-if-schema</code>" and " * <code>datatype-normalization</code>" options during the load of a new * <code>Document</code>. */ public void setAbstractSchema(ASModel abstractSchema) { // since the ASModel associated with this object is an attribute // according to the DOM IDL, we must obliterate anything // that was set before, rather than adding to it. // REVISIT: so shouldn't we attempt to clear the // grammarPool before adding stuff to it? - NG fAbstractSchema = (ASModelImpl)abstractSchema; // make sure the GrammarPool is properly initialized. XMLGrammarPool grammarPool = (XMLGrammarPool)fConfiguration.getProperty(StandardParserConfiguration.XMLGRAMMAR_POOL); // if there is no grammar pool, create one // REVISIT: ASBuilder should always create one. if (grammarPool == null) { // something's not right in this situation... grammarPool = new XMLGrammarPoolImpl(); fConfiguration.setProperty(StandardParserConfiguration.XMLGRAMMAR_POOL, grammarPool); } if (fAbstractSchema != null) { initGrammarPool(fAbstractSchema, grammarPool); } }
XMLGrammarPool grammarPool = new XMLGrammarPoolImpl(); grammarPreparser.setGrammarPool(grammarPool);
XMLGrammarPool grammarPool = new XMLGrammarPoolImpl(); grammarPreparser.setGrammarPool(grammarPool);
grammarPreparser.setGrammarPool(grammarPool != null ? grammarPool : new XMLGrammarPoolImpl()); grammarPreparser.setErrorHandler(errorHandler); if (entityResolver != null)
SymbolTable symbolTable = new SymbolTable(); XMLGrammarPreparser preparser = new XMLGrammarPreparser(symbolTable); XMLGrammarPool grammarPool = new XMLGrammarPoolImpl(); preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); preparser.setGrammarPool(grammarPool);
SymbolTable symbolTable = new SymbolTable(); XMLGrammarPreparser preparser = new XMLGrammarPreparser(symbolTable); XMLGrammarPool grammarPool = new XMLGrammarPoolImpl(); preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); preparser.setGrammarPool(grammarPool);