In case this helps anyone out in the future, one way to handle inlined schemas is to use a XMLGrammarPoolImpl.
 
        loader = new XMLSchemaLoader();
        XMLGrammarPoolImpl grammarPool = new XMLGrammarPoolImpl();
        String NL_GRAMMAR_POOL =
            Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
        loader.setProperty(NL_GRAMMAR_POOL, grammarPool);
----- Original Message -----
Sent: Wednesday, March 03, 2004 11:53 AM
Subject: XMLSchemaLoader handling inlined schemas

I am trying to obtain XSModels for inlined schemas in WSDLs.
 
I am able to do this successfully, except when the inlined schemas reference each other.  For instance, assume I have 2 inlined schemas in the WSDL.
 
<definitions>
<types>
 
<xsd:schema targetNamespace="foo" xmlns:xsd="...">
...
</schema>
 
<xsd:schema targetNamespace="bar" xmlns:xsd="...">
<xsd:import namespace="foo"/>
...
</schema>
 
</types>
</definition>
 
Some type declarations in "bar" schema reference elements in the "foo" schema.  As a result, when I try to load the schema for "bar" schema, I get an error saying that it cannot resolve the name "nsBar:Something" when nsBar is the prefix for "bar" namespace.
 
I am doing this:
loader is instance of XMLSchemaLoader
SchemaGrammer grammar = loader.loadGrammar(source) where source is the XMLInputSource representing the inlined schema.
XSModel model = grammar.toXSModel()
 
I've tried setting an XMLEntityResolver to the XMLSchemaLoader that returns XMLInputSource representing "foo" schema when resolveEntity() is called.
 
However, I am still getting error messages to stout/sterr.
 
Any ideas?  What is the best way to handle inlined schemas?
 
Thanks,
 
Jeehong Min

Reply via email to