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

Fwd: FW: Namespace of locally declared elements when extending imported types

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 6 Dec 2001 12:25:12 +0000
Message-ID: <164166145774.20011206122512@jenitennison.com>
To: xmlschema-dev@w3.org
-----Original Message-----
From: Jeffrey Stephenson [mailto:Jeffrey.Stephenson@oracle.com]
Sent: Wednesday, December 05, 2001 4:01 PM
To: xmlschema-dev@w3.org
Subject: Namespace of locally declared elements when extending imported

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"

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

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


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 

<schema targetNamespace="http://www.example.com/bug"

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

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

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


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" >

or this?

<contactInfo xmlns="http://www.example.com/bug"
             xmlns:ipo="http://www.example.com/IPO" >

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 07:26:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:56 UTC