Hi Mukul, What you're attempting to do is already possible:
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); XMLSchemaFactory xsf = (XMLSchemaFactory) sf; XSModel xsmodel = ...; XSNamespaceItemList nsItemList = model.getNamespaceItems(); Grammar[] grammars = (Grammar[]) nsItemList.toArray(new Grammar[nsItemList.getLength()]); XMLGrammarPool pool = new XMLGrammarPoolImpl(); pool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA, grammars); Schema s = xsf.newSchema(pool); though I thought that Psychopath took XSModel as input. Or is this necessary for something else? Saxon perhaps? Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [email protected] E-mail: [email protected] Mukul Gandhi <[email protected]> wrote on 05/17/2009 01:59:27 AM: > Hi Michael, > Actually, it would help me if I can construct the JAXP object, > "Schema" from XSModel. I need this for XML Schema 1.1 assertions > implementation. > > I looked into Xerces code, and it doesn't seem to be possible > currently with given exposed public APIs. > > I further thought about this, and think, making following changes > would make this possible: > > Expose, the object fGrammarList in XSModelImpl.java > > So, we could have following new method [1] in XSModelImpl.java (seems > to me feasible to do): > > public SchemaGrammar[] getSchemaGrammars() { > return fGrammarList; > } > > I think, introducing this new method in XSModelImpl.java would make it > possible to construct JAXP, "Schema" object. > > Assuming the method [1] is now available, I think we need to write > following code to achieve this: > > XSModel xsmodel = ...; // we have a valid XSModel with us > SchemaGrammar[] schemaGrammars = xsmodel.getSchemaGrammars(); // the > new method I propose > XMLGrammarPoolImpl grammarPool = new XMLGrammarPoolImpl(); > grammarPool.putGrammar(schemaGrammars[0]); > > Schema schema = new XMLSchema(grammarPool, > XMLConstants.W3C_XML_SCHEMA_NS_URI); // this is what I need :) > > Is this feasible and correct? The whole of idea above, relies on > adding a new method, getSchemaGrammars() in XSModelImpl.java. > > On Fri, May 15, 2009 at 6:52 PM, Mukul Gandhi <[email protected]> wrote: > > Hi Michael, > > Thanks for reply. This works fine, and is really nice. > > > > I have another question. > > > > Can we convert XSModel into the JAXP object, javax.xml.validation.Schema? > > > -- > Regards, > Mukul Gandhi > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected]
