Re: Namespace of locally declared elements when extending imported types

"Jeffrey Stephenson" <Jeffrey.Stephenson@oracle.com> writes:

Sorry for long delay in answering this.  Answers at the end.

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

Nope.

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

Yep.

> 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).

Yes.

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

I think you're right, the instance example of <analyst> in
section 5.4 of the primer [1] is broken.  Thanks.

ht

[1] http://www.w3.org/TR/xmlschema-0/#import
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Thursday, 14 February 2002 05:58:08 UTC