W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2001

Question about combination of xsi:type and import

From: <O.Geisser@ceyoniq.com>
Date: Wed, 16 May 2001 13:36:09 +0200
Message-Id: <01May16.133630cest.119105@firewallsrv1.bi.ceyoniq.com>
To: xmlschema-dev@w3.org

A remark at the beginning: I have tried all this with XML Spy, so the
namespace URLs are
not that of the current XSDL spec. But the question remains the same.

Starting point is a schema that defines a tree structure.
Let's call it: tree.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="urn:tree"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" xmlns:tns="urn:tree"
elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xsd:element name="tree" type="tns:branchType"/>
	<xsd:complexType name="leafType">
			<xsd:element name="name" type="xsd:string"/>
	<xsd:complexType name="branchType">
		<xsd:choice maxOccurs="unbounded">
			<xsd:element name="leaf" type="tns:leafType"/>
			<xsd:element name="branch" type="tns:branchType"/>
	<xsd:complexType name="extendedLeafType">
			<xsd:extension base="tns:leafType">
					<xsd:element name="info"

This defines a derived type "extendedLeafType" by extension.

I can use this derived type inside an instance document like the following:

<?xml version="1.0" encoding="UTF-8"?>
<tree:tree xmlns:tree="urn:tree"
	<tree:leaf xsi:type="tree:extendedLeafType">

Up until here there is no problem.

Now I want to do the following, but I don't know if it is possible. And if
it is possible I don't know how
to do it:

The definition of the derived "extendedLeafType" should be in another
namespace and therefor in another schema.
Let's call the schema custom.xsd. The custom.xsd needs to import the
tree.xsd schema.
The tree.xsd should not know anything about the custom.xsd, because the
custom.xsd is defined later (by some third party).

But I want to write instance documents that use the derived type. So I tried
the following:

<?xml version="1.0" encoding="UTF-8"?>
<tree:tree xmlns:tree="urn:tree" xmlns:custom="urn:custom"
	<tree:leaf xsi:type="custom:extendedLeafType">

This does not work!
I've tried to validate this with XML Spy and get the error: "Unknown type
custom:extendedLeafType" (or something similiar).

Maybe a comparison with OOP programming makes things clearer:

The tree.xsd is like a library that defines some classes. The custom.xsd is
like another library that extends some of the classes
defined in tree.xsd. In my application I want to use most of the classes out
of tree.xsd but polymorphic substitute occurences
of "leafType" objects by "extendedLeafType" objects.

With Java or C++ this is no problem. But can I do the same with XSDL ?

Oliver Geisser
System Architect
Received on Wednesday, 16 May 2001 07:37:05 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:51 UTC