[xsd-users] Problem with target and default namespaces

Boris Kolpackov boris at codesynthesis.com
Wed May 14 14:00:27 EDT 2008


Hi Joe,

Mcduffey, Joe <jdmcduf at nsa.gov> writes:

> I am having a problem with namespaces when I try to compile:
> when I have a parent schema that specifies a default and target
> namespace and then I include another schema that makes use of
> types contained in the parent schema errors occur. For example
>
> ---------------- Parent.xsd --------------------------------
> <xs:schema targetNamespace="xyz" xmlns="xyz"...>
> 	<include schemaLocation=test.xsd/>
> 	<xs:complexType name ="test" >
> 		...
> 	</xs:complexType>
>
> -------------- Child.xsd ----------------------------
>
> <xs:element name="testName" type="testType">
> ...
> </xs:element>
>
> I then get an error
> 	unable to resolve namespace=""

I was able to create a test case that reproduces the problem.

When you include a schema without a target namespace into a schema
with a target namespace (the so-called chameleon inclusion) then the
included schema assumes the target namespace of the including schema.
Chameleon inclusion is quite tricky and I will have to check the XML
Schema spec to see what happens if one references things from the
including schema. Xerces-C++ handles this test case without any
errors so there is a good chance we have a bug in the compiler.
I will let you know.

I am also not sure whether the chameleon inclusion is intentional
or not in your case since the included schema knows about a type in
the including schema so its ability to be reused in other namespaces
is somewhat limited (that is, all including schemas will have to
define testType). If chameleon inclusion is not required then the
easy work around for this problem is to add the same target namespace
to Child.xsd as in Parent.xsd.

Boris




More information about the xsd-users mailing list