Search in sources :

Example 1 with XSGrammarPoolContainer

use of org.apache.xerces.jaxp.validation.XSGrammarPoolContainer in project webtools.sourceediting by eclipse.

the class CompleteNewApiTest method getGrammar.

// private Schema getSchema(InputStream schemaIs) throws SAXException {
// SchemaFactory sf = SchemaFactory
// .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
// Schema schema = sf.newSchema(new StreamSource(schemaIs));
// return schema;
// }
protected XSModel getGrammar(URL schemaURL) throws IOException, SAXException {
    InputStream schemaIs = schemaURL.openStream();
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = sf.newSchema(new StreamSource(schemaIs));
    XSGrammarPoolContainer poolContainer = (XSGrammarPoolContainer) schema;
    XMLGrammarPool pool = poolContainer.getGrammarPool();
    Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
    XSGrammar[] xsGrammars = new XSGrammar[grammars.length];
    System.arraycopy(grammars, 0, xsGrammars, 0, grammars.length);
    return xsGrammars[0].toXSModel(xsGrammars);
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) XMLGrammarPool(org.apache.xerces.xni.grammars.XMLGrammarPool) InputStream(java.io.InputStream) XSGrammarPoolContainer(org.apache.xerces.jaxp.validation.XSGrammarPoolContainer) Schema(javax.xml.validation.Schema) StreamSource(javax.xml.transform.stream.StreamSource) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar) Grammar(org.apache.xerces.xni.grammars.Grammar) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar)

Example 2 with XSGrammarPoolContainer

use of org.apache.xerces.jaxp.validation.XSGrammarPoolContainer in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathTest method getGrammar.

protected XSModel getGrammar(URL schemaURL) throws IOException, SAXException {
    InputStream schemaIs = testResolve(schemaURL);
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = sf.newSchema(new StreamSource(schemaIs));
    XSGrammarPoolContainer poolContainer = (XSGrammarPoolContainer) schema;
    XMLGrammarPool pool = poolContainer.getGrammarPool();
    Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
    XSGrammar[] xsGrammars = new XSGrammar[grammars.length];
    System.arraycopy(grammars, 0, xsGrammars, 0, grammars.length);
    return xsGrammars[0].toXSModel(xsGrammars);
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) XMLGrammarPool(org.apache.xerces.xni.grammars.XMLGrammarPool) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XSGrammarPoolContainer(org.apache.xerces.jaxp.validation.XSGrammarPoolContainer) Schema(javax.xml.validation.Schema) StreamSource(javax.xml.transform.stream.StreamSource) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar) Grammar(org.apache.xerces.xni.grammars.Grammar)

Example 3 with XSGrammarPoolContainer

use of org.apache.xerces.jaxp.validation.XSGrammarPoolContainer in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathWTPTest method getGrammar.

protected XSModel getGrammar(URL schemaURL) throws IOException, SAXException {
    InputStream schemaIs = testResolve(schemaURL);
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = sf.newSchema(new StreamSource(schemaIs));
    XSGrammarPoolContainer poolContainer = (XSGrammarPoolContainer) schema;
    XMLGrammarPool pool = poolContainer.getGrammarPool();
    Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
    XSGrammar[] xsGrammars = new XSGrammar[grammars.length];
    System.arraycopy(grammars, 0, xsGrammars, 0, grammars.length);
    return xsGrammars[0].toXSModel(xsGrammars);
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) XMLGrammarPool(org.apache.xerces.xni.grammars.XMLGrammarPool) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XSGrammarPoolContainer(org.apache.xerces.jaxp.validation.XSGrammarPoolContainer) Schema(javax.xml.validation.Schema) StreamSource(javax.xml.transform.stream.StreamSource) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar) XSGrammar(org.apache.xerces.xni.grammars.XSGrammar) Grammar(org.apache.xerces.xni.grammars.Grammar)

Aggregations

InputStream (java.io.InputStream)3 StreamSource (javax.xml.transform.stream.StreamSource)3 Schema (javax.xml.validation.Schema)3 SchemaFactory (javax.xml.validation.SchemaFactory)3 XSGrammarPoolContainer (org.apache.xerces.jaxp.validation.XSGrammarPoolContainer)3 Grammar (org.apache.xerces.xni.grammars.Grammar)3 XMLGrammarPool (org.apache.xerces.xni.grammars.XMLGrammarPool)3 XSGrammar (org.apache.xerces.xni.grammars.XSGrammar)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2