Namespace of locally declared elements when extending imported types

XML Schema gurus,

I have a question about the semantics of extending a complexType 
imported from a schema for a different targetNamespace.  Here is
a simplified example of this situation, adapted from the familiar
purchase order schema in the XML Schema Primer:

Examine the existing schema which defines an "addressType",
note that elementFormDefault="qualified" is specified :

<schema targetNamespace="http://www.example.com/IPO"
        xmlns="http://www.w3.org/2000/10/XMLSchema"
        xmlns:ipo="http://www.example.com/IPO"
        elementFormDefault="qualified">

<element name="address" type="ipo:addressType" />

<complexType name="addressType">
  <sequence>
    <element name="name"   type="string"/>
    <element name="street" type="string"/>
    <element name="city"   type="string"/>
  </sequence>
</complexType>

</schema>

Now examine the following schema in a new namespace
which imports the address.xsd schema and defines a
new "contactInfoType" that is an extension of 
"ipo:addressType":

<schema targetNamespace="http://www.example.com/bug"
        xmlns="http://www.w3.org/2000/10/XMLSchema"
        xmlns:ipo="http://www.example.com/IPO"
        xmlns:bug="http://www.example.com/bug"
        elementFormDefault="qualified">

<import namespace="http://www.example.com/IPO" schemaLocation="address.xsd" />

<element name="contactInfo" type="bug:contactInfoType" />

<complexType name="contactInfoType">
  <complexContent>
    <extension base="ipo:addressType">
      <sequence>
        <element name="workPhone" type="string"/>
        <element name="homePhone" type="string"/>
      </sequence>
    </extension>
  </complexContent>
</complexType>

</schema>

Now the question is, if I use the contactInfo element in an instance
document, what namespace will I have to specify for the locally 
declared elements?  Would a valid instance document look like this:

<contactInfo xmlns="http://www.example.com/bug" >
  <name></name>
  <street></street> 
  <city></city>
  <workPhone></workPhone>
  <homePhone></homePhone>
</contactInfo>

or this?

<contactInfo xmlns="http://www.example.com/bug"
             xmlns:ipo="http://www.example.com/IPO" >
  <ipo:name></ipo:name>
  <ipo:street></ipo:street> 
  <ipo:city></ipo:city>
  <workPhone></workPhone>
  <homePhone></homePhone>
</contactInfo>

Some documentation, like the Hide vs. Expose Namespaces document on the
XML Schemas: Best Practices page (http://www.xfront.com/BestPracticesHomepage.html)
seem to indicate that the second instance document is correct (the namespaces
of the local elements are split based upon where they were declared).

However, the XML Schema Primer Section 5.4 on importing types seems to indicate
the opposite.  If you examine the "Analyst" extension of the USAddress type, and
the sample instance document below you will see that the sample instance document
uses the default namespace of the extension schema, and the name, street, and
city elements are shown as being in that namespace.

Which is correct?  

Thanks and Regards,

Jeffrey Stephenson
Oracle Corporation  

Received on Thursday, 6 December 2001 19:31:00 UTC