You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jeehong Min <je...@parasoft.com> on 2004/03/03 20:53:17 UTC

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

Re: XMLSchemaLoader handling inlined schemas

Posted by Jeehong Min <je...@parasoft.com>.
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 ----- 
  From: Jeehong Min 
  To: xerces-j-user@xml.apache.org 
  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