- From: Bassam Tabbara <bassamt@windows.microsoft.com>
- Date: Tue, 31 Oct 2006 18:27:51 +0000
- To: <www-xml-schema-comments@w3.org>
- Message-Id: <588E0D10-1D58-40A5-96CE-D33011D8684E@windows.microsoft.com>
Hello, We are glad to see the simplification of the rules for complex type restrictions in recent working drafts of XML Schema 1.1. This will address a number of problems we have encountered with XML Schema 1.0. Another problem that is equally important but not addressed by XML Schema 1.1 is related to complex type restrictions across namespaces. The following simplified scenario: <xs:schema targetNamespace="urn:vehicle" elementFormDefault="qualified" xmlns:tns="urn:vehicle"xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="Engine"/> <xs:complexType name="Wheel"/> <!-- a vehicle can have one or more engines, and 1 or more wheels --> <xs:complexType name="Vehicle"> <xs:sequence> <xs:element name="Engine" type="tns:Engine" minOccurs="1" maxOccurs="unbounded"/> <xs:element name="Wheels" type="tns:Wheel" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <!-- a car is a vehicle with one engine and four wheels --> <xs:complexType name="Car"> <xs:complexContent> <xs:restriction base="tns:Vehicle"> <xs:sequence> <xs:element name="Engine" type="tns:Engine" minOccurs="1" maxOccurs="1"/> <xs:element name="Wheels" type="tns:Wheel" minOccurs="1" maxOccurs="4"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:schema> This definition works well using XML Schema 1.0. However there are many cases where the owners of base and restricted types are different. As such the type definitions would live in different schemas (w/ different target namespaces). For example, <xs:schema targetNamespace="urn:vehicle" elementFormDefault="qualified" xmlns:tns="urn:vehicle"xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="Engine"/> <xs:complexType name="Wheel"/> <!-- a vehicle can have one or more engines, and 1 or more wheels --> <xs:complexType name="Vehicle"> <xs:sequence> <xs:element name="Engine" type="tns:Engine" minOccurs="1" maxOccurs="unbounded"/> <xs:element name="Wheels" type="tns:Wheel" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:schema> <xs:schema targetNamespace="urn:car" elementFormDefault="qualified" xmlns:tns="urn:car" xmlns:base="urn:vehicle"xmlns:xs="http:// www.w3.org/2001/XMLSchema"> <xs:import namespace="urn:vehicle"/> <!-- a car is a vehicle with one engine and four wheels --> <xs:complexType name="Car"> <xs:complexContent> <xs:restriction base="base:Vehicle"> <xs:sequence> <xs:element name="Engine" type="base:Engine" minOccurs="1" maxOccurs="1"/> <xs:element name="Wheels" type="base:Wheel" minOccurs="1" maxOccurs="4"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:schema> This is currently not supported by XML Schema 1.0. Car is not considered a valid restrictions of Vehicle since it’s local element declaration “Engine” and “Wheel” are in the “urn:car” namespace. One way to workaround this limitation is to use only global elements, refs, and substitution groups (i.e Garden of Eden and Salami Slice schema styles). In our scenarios, this workaround suffers from the following problems: Schema author must uniformly avoid using local elements or their types can not be restricted in other schemas. We can not use existing (published) schemas that make heavy use of local elements for complex type restrictions. Many schema authors prefer the use of complex types and local elements (i.e. Venetian blinds). See section 4 ofhttp:// homepages.cwi.nl/~ralf/xml05/paper.pdf. We would like to see support for overriding the target namespace of a local element or attribute declaration. One way to accomplish this is as follows: <xs:complexType name="Car"> <xs:complexContent> <xs:restriction base="base:Vehicle"> <xs:sequence> <xs:element name="base:Engine" type="base:Engine" minOccurs="1" maxOccurs="1"/> <xs:element name="base:Wheels" type="base:Wheel" minOccurs="1" maxOccurs="4"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> We believe this to be an important addition to XML Schema 1.1, and would improve the work we are doing with SML (see www.serviceml.org ) and the common model library. Thanks! Bassam
Received on Thursday, 8 February 2007 00:49:41 UTC