- From: Grégoire Pau <gpau@acland.fr>
- Date: Mon, 7 May 2001 19:51:20 +0200
- To: <www-xml-schema-comments@w3.org>
- Message-ID: <019001c0d71e$536e4460$1601a8c0@acland.fr>
Dear all,
I am currently having trouble with the combined use of
inheritance and imports. Let's have an example :
- In namespace ns1 :
<schema
xmlns="http://www.w3.org/2000/10/XMLSchema"
xmlns:ns1="http://www.ns1.com"
xmlns:ns2="http://www.ns2.com"
targetNamespace="http://www.ns1.com">
<element name="A" type="USAddress"/>
<complexType name="USAddress">
<complexContent>
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
</sequence>
</complexContent>
</complexType>
</schema>
- In namespace ns2 :
<schema
xmlns="http://www.w3.org/2000/10/XMLSchema"
xmlns:ns1="http://www.ns1.com"
xmlns:ns2="http://www.ns2.com"
targetNamespace="http://www.ns2.com">
<import namespace="http://www.ns1.com"
schemaLocation="http://www.ns1.com/ns1.xsd"/>
<complexType name="Analyst">
<complexContent>
<extension base="ns1:USAddress">
<sequence>
<element name="phone" type="string"/>
</sequence>
</extension>
</complexContent>
</complexType>
<!-- for later use -->
<element name="email" type="string"/>
</schema>
Which one of the following document is valid ?
- Document 1:
<ns1:A xsi:type="ns2:Analyst"
xmlns:xsi="http://www....."
xmlns:ns1="http://www.ns1.com"
xmlns:ns2="http://www.ns2.com">
<ns1:name>John doe</ns1:name>
<ns1:street>Lacepede</ns1:street>
<ns2:phone>...</ns2:phone>
</ns1:A>
- Document 2:
<ns1:A xsi:type="ns2:Analyst"
xmlns:xsi="http://www....."
xmlns:ns1="http://www.ns1.com"
xmlns:ns2="http://www.ns2.com">
<ns2:name>John doe</ns2:name>
<ns2:street>Lacepede</ns2:street>
<ns2:phone>...</ns2:phone>
</ns1:A>
Then, what about element ref ?
Let's define a new schema in a new namespace :
<schema
xmlns="http://www.w3.org/2000/10/XMLSchema"
xmlns:ns2="http://www.ns2.com"
xmlns:ns3="http://www.ns3.com"
targetNamespace="http://www.ns3.com">
<import namespace="http://www.ns2.com"
schemaLocation="http://www.ns2.com/ns2.xsd"/>
<complexType name="ModernAnalyst">
<complexContent>
<extension base="ns2:Analyst">
<sequence>
<element ref="ns2:email"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
Then which one of the following document is valid ?
<ns1:A xsi:type="ns3:ModernAnalyst">
xmlns:xsi="http://www....."
xmlns:ns1="http://www.ns1.com"
xmlns:ns2="http://www.ns2.com"
xmlns:ns3="http://www.ns3.com">
<??:name>John doe</??:name>
<??:street>Lacepede</??:street>
<??:phone>...</??:phone>
<ns3:email>...</ns3:email>
</ns1:A>
<ns1:A xsi:type="ns3:ModernAnalyst">
xmlns:xsi="http://www....."
xmlns:ns1="http://www.ns1.com"
xmlns:ns2="http://www.ns2.com"
xmlns:ns3="http://www.ns3.com">
<??:name>John doe</??:name>
<??:street>Lacepede</??:street>
<??:phone>...</??:phone>
<ns2:email>...</ns2:email>
</ns1:A>
Thank you very much,
Grégoire.
_____________________________________________________________________
Grégoire Pau
Expway
Received on Monday, 7 May 2001 13:56:05 UTC