Restrictions and element namespaces

Hi all,

I am writing a few schemas using restrictions features, and there seems to
be an ambiguity w.r.t. what the namespace is of local elements. Consider a
schema:

===============================
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://localhost/kelly"
xmlns:sns="http://localhost/kelly"
elementFormDefault="qualified"
>


  <element name="RootTag" type="sns:MainType"/>

  <complexType name="MainType">
    <sequence>
      <xsd:element name="shipTo" type="sns:ShipType" minOccurs="0" 
maxOccurs="unbounded"/>
      <xsd:element name="billTo" type="xsd:string" minOccurs="0"/>
    </sequence>
    <attribute name="currency" type="xsd:string"/>
  </complexType>

  <complexType name="ShipType">
    <sequence>
      <element name="Shipper" type="xsd:string"/>
    </sequence>
  </complexType>

</schema>
=========================

Then, in a seperate namespace, we restrict the root type

=========================
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://localhost/two"
xmlns:sns="http://localhost/kelly"
xmlns:tns="http://localhost/two"
elementFormDefault="qualified"
>


  <complexType name="NewShipType">
    <complexContent>
      <extension base="sns:ShipType">
        <sequence>
          <element name="City" type="xsd:string"/>
        </sequence>
      </extension>
    </complexContent>
  </complexType>

  <complexType name="RMainType">
    <complexContent>
      <restriction base="sns:MainType">
        <sequence>
          <xsd:element name="shipTo" type="tns:NewShipType" minOccurs="0" 
maxOccurs="unbounded"/>
          <xsd:element name="billTo" type="xsd:string" minOccurs="0"/>
        </sequence>
      </restriction>
    </complexContent>
  </complexType>
</schema>
=========================

What is the namespace of the locally declared elements (ex, "billTo"), which
are used in elements of the runtime type {namespace="http://localhost/two",
localname="RMainType"}? Originally, these elements were (locally) declared
in the base target namespace schema, "http://localhost/kelly". However, when
restricted the target namespace is in the new schema namespace,
"http://localhost/two". What, then, is the instance's correct namespace?

Kelly

Received on Wednesday, 5 September 2001 14:45:42 UTC