Loading ...
Sorry, an error occurred while loading the content.

Re: in XML schema

Expand Messages
  • mike_sample_ca
    ... Apache ... Then it ... Unfortunately, the EntityResolver approach will not work. ImportState.java contains a Todo comment that says that schemaLocation
    Message 1 of 3 , Dec 5, 2002
      > > Sometimes schema extracted from a WSDL document generated by
      > > Axis will has an <import
      > > namespace="http://schemas.xmlsoap.org/soap/encoding/"/> element
      > > without a "schemaLocation" attribute. Is it possible to tell msv
      > > where to find the schema of that namespace?
      > I think you can set your own EntityResolver to a GrammarLoader.
      Then it
      > will be called with the publicId parameter set to the namespace URI.

      Unfortunately, the EntityResolver approach will not
      work. ImportState.java contains a "Todo" comment that
      says that schemaLocation is optional just before it
      calls the XMLSchemaReader.switchSource method. The
      switchSource method expects a schemaLocation attribute
      in the source state's (ImportState) StartTagInfo, and
      reports an error and returns without importing if it
      doesn't find one.

      Also, I believe using an EntityResolver (the
      GrammarReaderController you set up) with a null
      systemId and a non-null publicId is violating the
      contract for that method
      (http://www.saxproject.org/). This doesn't really
      matter so long as your EntityResolver implementation
      does the right thing but it may not play nice with
      catalog based lookup. Perhaps in future MSV versions
      the JAXP URIResolver interface can be supported which
      doesn't have this problem and also makes the baseUri
      explicit instead of expecting the app the put it in
      there. This is nice if you are using a Catalog.

      A quick fix is to modify ImportState to call
      "switchSourceOnImport()" and define the method in the
      XMLSchemaReader as follows:

      protected void switchSourceOnImport( State sourceState,
      State newRootState ) throws AbortException {
      String schemaLocation =

      if( schemaLocation == null ) {
      // schemaLocation is optional for import,
      // if missing try namespace uri itself
      schemaLocation =
      // parse specified file
      switchSource( sourceState, schemaLocation, newRootState );

      Be aware that this fix results in the import tag's
      namespace attribute's uri value being used as the
      systemId parameter to the the EntityResolver's
      resolveEntity method. You'll need to know this if
      working with a catalog to configure it correctly and to
      implment your own resolver.

      Also be aware that if your resolver can't map the
      URI/systemId MSV will try to resolve it directly
      (rightly so). This may work sometimes, but you'll get
      errors for "urn:xzy" style namespace URIs.

      /Mike Sample
    Your message has been successfully submitted and would be delivered to recipients shortly.