- From: Fuchs, Matthew <matthew.fuchs@commerceone.com>
- Date: Thu, 6 Sep 2001 08:38:44 -0700
- To: "'www-xml-schema-comments@w3.org'" <www-xml-schema-comments@w3.org>
If this is as Henry says below, then we have a serious issue here - perhaps an erratum, perhaps just weirdness. See below. Matthew > -----Original Message----- > From: ht@cogsci.ed.ac.uk [mailto:ht@cogsci.ed.ac.uk] > Sent: Thursday, September 06, 2001 1:35 AM > To: Schwarzhoff, Kelly > Cc: 'www-xml-schema-comments@w3.org' > Subject: Re: Restrictions and element namespaces > > > "Schwarzhoff, Kelly" <kelly.schwarzhoff@commerceone.com> writes: > > > 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> > > ========================= > > The tns:RMainType definition is broken, for two reasons: > > 1) The sns:MainType definition allows sequences > (sns:shipTo*,sns:billTo?). > The tns:RMainType definition allows sequences > (tns:shipTo*,tns:billTo?). > But renaming of elements is not an allowed part of restriction. > > 2) Even if you changed to form="unqualified", which would > solve _that_ > problem, tns:newShipType is not a restriction of > sns:ShipType, it's an > extension, which is not allowed. > > > 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"}? > > The REC is perfectly clear: http://localhost/two. > > The element declaration is what it is, regardless of what its > enclosing type definition may be based on. This essentially means that if you use elementForm="qualified" for a local type, then you cannot restrict that local type in any schema with a different targetNamespace. This is certainly consistent in its own way, so not an a priori erratum. However, it's certainly a major restriction on restriction. If anyone needed a good reason not to muck with the defaults, this is it. > Consider the alternative > -- you wouldn't know whether City was in sns or tns until you knew > whether it was being used to extend or restrict. > I don't understand the problem with this. If you look at the example, you know if you're restricting or extending before you even get to the definition of City, so it's pretty obvious.
Received on Thursday, 6 September 2001 11:37:03 UTC