RE: Question about combination of xsi:type and import

The following 4 files seem to work with XML Spy...

1) Schema: tree.xsd
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by Pierre G.
Boutquin (Veredex Logistics) -->
<xsd:schema targetNamespace="urn:tree" xmlns:tns="urn:tree"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xsd:element name="tree" type="tns:branchType"/>
	<xsd:complexType name="leafType">
		<xsd:sequence>
			<xsd:element name="name" type="xsd:string"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:complexType name="branchType">
		<xsd:choice maxOccurs="unbounded">
			<xsd:element name="leaf" type="tns:leafType"/>
			<xsd:element name="branch" type="tns:branchType"/>
		</xsd:choice>
	</xsd:complexType>
</xsd:schema>

2) Schema: extLeaf.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="urn:extLeaf" xmlns:tns="urn:tree"
xmlns:extLeaf="urn:extLeaf" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
elementFormDefault="qualified">
	<xsd:import namespace="urn:tree" schemaLocation="tree.xsd"/>
	<xsd:complexType name="extendedLeafType">
		<xsd:complexContent>
			<xsd:extension base="tns:leafType">
				<xsd:sequence>
					<xsd:element name="info" type="xsd:string"/>
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>
</xsd:schema>

3) Instance document: tree.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by Pierre G.
Boutquin (Veredex Logistics) -->
<tree:tree xmlns:tree="urn:tree"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="urn:tree tree.xsd">
	<tree:leaf>
		<tree:name>eins</tree:name>
	</tree:leaf>
</tree:tree>


4) Instance document: treeWithExtendedLeaf.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by Pierre G.
Boutquin (Veredex Logistics) -->
<tree:tree xmlns:tree="urn:tree" xmlns:extLeaf="urn:extLeaf"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="urn:extLeaf extLeaf.xsd">
	<tree:leaf xsi:type="extLeaf:extendedLeafType">
		<tree:name>eins</tree:name>
		<extLeaf:info>Test</extLeaf:info>
	</tree:leaf>
</tree:tree>

<Pierre/>

Pierre Boutquin
Director, Product Architecture
Veredex Logistics
2355 Skymark Avenue, Suite 300
Mississauga, Ontario  L4W 4Y6  Canada
Work: 905.282.1515 x311
Fax: 905.282.9219
pboutquin@veredex.com
www.veredex.com

Received on Monday, 11 June 2001 05:35:08 UTC