Using JAXP I can create a Schema object. e.g.
Path schemaPath = ...;
StreamSource source = new StreamSource(schemaPath.toFile());
SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(source);
I am using Xerces. Is there way to obtain the XSModel (org.apache.xerces.xs.XSModel) corresponding to the schema object?
I'm no expert and I don't understand all the details, but: first find out what the implementation class of the
Schema
object is; see whether this has a method to extract aGrammar
orGrammarPool
; see if you can cast the result to aSchemaGrammar
; and then theSchemaGrammar.toXSModel()
method gives you what you're after.