[xsd-users] Refactoring of 3rd Party Schemas

Boris Kolpackov boris at codesynthesis.com
Tue Mar 17 05:00:21 EDT 2009


Hi Michael,

Forstner Michael <Michael.Forstner at cpg.de> writes:

> If this new common schema has it's own namespace and is imported by 
> the 4 others, xsd.exe generates seperate sources for each schema but
> the XML documents can't be parsed because they are missing the namespace
> prefixes for the common types.

You probably mean prefixes for the elements contained in the common types.
XML documents normally do not refer to type names defined in XML Schema,
except for the xsi:type case.


> If this new common schema has no namespace and is included by the 4 others,
> the XML documents can be parsed successfully but xsd.exe generates the 
> common types for each schema inline (multiple again).
> 
> Is there a possiblity to advise xsd.exe to handle includes like imports?

No there is no way to do this and even if there were, it wouldn't work.
The XML Schema spec prescribes that when a schema without a namespace
is included into a schema with a namespace, then the definitions in the
included schema assume the target namespace of the including schema (this
case is called chameleon inclusion). To support this, XSD has to generate
different code depending on the target namespace and that's the reason
why this code is generated inline.

I assume your schemas have elementFormDefault="qualified" which makes
all local elements qualified. In this case there is not much you can
do, except, perhaps factor out common simple types that don't have
any elements.

Boris




More information about the xsd-users mailing list