Multiple imports for the same name space?

This should cover W3C XML Schema, Relax NG and DTD related problems.
GrayMan
Posts: 5
Joined: Thu May 26, 2005 9:16 pm

Multiple imports for the same name space?

Post by GrayMan » Thu May 26, 2005 9:44 pm

I have an XML and modular schema that validate under XMLSpy. When I attempt to validate them under Oxygen6 it appears that the second, third, ... imports within an XSD for the same namespace are ignored as I get pairs of the form

Code: Select all

cannot resolve the name 'prefix:SchemaType' to a(n) 'type definition' component
cannot resolve the name 'prefix:SchemaType' to a(n) 'simpleType definition' component
i.e., Others.xsd (in a different namespace) contains a sequence like

Code: Select all

<xs:schema targetNamespace="http://domain.tld/OTHERS"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://domain.tld/OTHERS"
xmlns:prefix="http://domain.tld/PREFIX">
<xs:import namespace="http://domain.tld/PREFIX" schemaLocation="http://domain.tld/PREFIX/Schema1.xsd"/>
<xs:import namespace="http://domain.tld/PREFIX" schemaLocation="http://domain.tld/PREFIX/Schema2.xsd"/>
<xs:import namespace="http://domain.tld/PREFIX" schemaLocation="http://domain.tld/PREFIX/Schema3.xsd"/>
...

Radu
Posts: 6592
Joined: Fri Jul 09, 2004 5:18 pm

Post by Radu » Fri May 27, 2005 9:47 am

Hi,

Oxygen uses Xerces for validation.
Xerces only uses the first <xsd:import> for each namespace. It
ignores subsequent ones, leading to problems if you, as in this example,
have multiple schemas with the same namespace imported in the same schema.

Having reported this as a bug in Xerces, it was pointed out that
the spec makes supporting multiple imports into the same namespace up to the processor. Further the comment made was that they believed that they were encouraging better Schema authoring practice by disallowing this.

See the link below:
http://issues.apache.org/bugzilla/show_bug.cgi?id=13193

As a workaround you can define a new schema with the target namespace "http://domain.tld/PREFIX" which can include all the other schemas with the same namespace. This schema can be then imported in your main schema.

Hope this helps.
Regards, Radu.

Post Reply