I have encountered a relative path error on a schema import with just the
XSD filename as the schemaLocation value (i.e. relative to the parent
schema URL):

<xs:import schemaLocation="name.xsd"
    namespace="http://example.org/name"; />

The test case wsdl is
'http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Import-1B/XSDImport.wsdl'
which does a schema import of 'name.xsd' relative to this URL (this is a
'bad' wsdl 2.0 test case, but the xs:import is good).

The stack trace is:

org.apache.ws.commons.schema.XmlSchemaException: no protocol: name.xsd
      at
org.apache.ws.commons.schema.SchemaBuilder.getXmlSchemaFromLocation(SchemaBuilder.java:1839)
      at
org.apache.ws.commons.schema.SchemaBuilder.handleImport(SchemaBuilder.java:1657)
      at
org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:113)
      at
org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:132)

The relevant code is:

SchemaBuilder.handleImport(..)
    ...getXmlSchemaFromLocation(schemaImport.schemaLocation);

I think the problem is that getXmlSchemaFromLocation assumes absolute URLs
but doesn't yet handle relative paths.  The URL constructor is called with
'name.xsd' as the argument and it throws a MalformedURLException.

Perhaps XmlSchemaObject.sourceURI could be set to the base URI of the
parent schema, then getXmlSchemaFromLocation could combine this with
schemaImport.schemaLocation to specify the correct import URL.

I encountered a similar problem with
'http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/SchemaId-1G/schemaIds.wsdl'
 but here the wsdl contained two inline schemas with the second schema
importing the namespace of the first by specifying a schemaLocation
referring to the 'id' attribute of the first schema (i.e.
schemaLocation="#items").  Again, a MalformedURLException with 'no
protocol: #items'.  An extra complication here is that the reference
reference spans <xs:schema> elements (i.e. spans invocations of XmlSchema).

regards,
John Kaputin

Reply via email to