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 02:44:47 UTC