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

RE: Extending by removing minOccurs restriction

From: <Simon.Cox@csiro.au>
Date: Thu, 23 Dec 2004 16:09:24 +0800
Message-ID: <2A2B2F12CF99EA4A898E2D4729441B41010391F9@exwa2-per.wa.csiro.au>
To: <rowan.bradley@herbertgroup.com>, <xmlschema-dev@w3.org>
1. order is significant in XML, and in XML Schema extension is only
possible by appending a <sequence> to the end of a content model
2. derivation by restriction must still result in types that are valid
according to the definition of the parent type. 
Thus it is not possible to suppress any component that is mandatory in
the parent - i.e. you can't turn a required component (minOccurs="1"
(either explicit or implied) for elements, use="required" for
attributes) into optional (minOccurs="0" or use="optional") and
certainly not suppressed entirely (maxOccurs="0" or use="prohibited"),
even in a two-step derivation process. 
If the type you are looking at has mandatory components that you don't
want, then it ain't for you - you gotta start somewhere else. 
 
Simon Cox


  _____  

	From: xmlschema-dev-request@w3.org
[mailto:xmlschema-dev-request@w3.org] On Behalf Of Rowan Bradley
	Sent: Wednesday, 22 December 2004 10:18 PM
	To: 'xmlschema-dev@w3.org'
	Subject: Extending by removing minOccurs restriction
	
	
	This may be a beginner's question. I need to develop a schema
based on a schema published by a third party (NRF-ARTS). I need to add
some elements to the published schema - I can do this via the
xsd:extension element of the xsd document. Is it the case that I can
only add elements after any existing elements? I.e. if the existing
schema contains a sequence of 10 elements, there is no way to add one
after the 5th of these?
	 
	I also need to be able to make one of the required elements in
the published schema optional. There doesn't seem to be a way using
restriction and extension to change a minOccurs="1" to a minOccurs="0",
presumably because this is not actually a restriction, i.e. an instance
of the new derived schema would not necessarily be a valid instance of
the base schema.
	 
	I wondered if one could do this in two steps: first derive a
schema by restriction which removes the element which I want to make
optional, then derive a further schema from this by extension which adds
the element back with a minOccurs="0". But this won't work because I
can't put the replacement element in the same position in the sequence
that the old one was in due to the first problem mentioned - it will
have to go at the end. Obviously instances that don't have the newly
optional element will not be valid instances of the original schema, but
this problem means that even instances that do have the optional element
will not be valid instances, since the element will be in the wrong
place.
	 
	Can anyone suggest a better way of doing this?
	 
	Thanks - Rowan
Received on Thursday, 23 December 2004 08:11:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:48 GMT