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

Substitution groups - replacing required elements in the s.group head

From: Shane Lauf <srl01@uow.edu.au>
Date: Mon, 2 Aug 2004 19:27:03 +1000
To: <xmlschema-dev@w3.org>
Message-Id: <20040802092820.9BD42A06B3@frink.w3.org>

I am running in to a problem with substitution groups when the substitution
group head includes a required element. For an element which I would like to
include in the substitution group, I would like the required element to be
replaced by a different element which is not substitutable for the required

For example, I have a myObject element (think "postal letter") of type
myObjectType, defined to include either a "pobox" or some number of
"streetaddress"es. (i.e. it has to have at least one or the other.)

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="myContainer">
        <xsd:element ref="myObject"/>
  <xsd:element name="myObject" type="myObjectType"/>
  <xsd:complexType name="myObjectType" mixed="true">
        <xsd:element name="pobox" type="string"/>
        <xsd:element name="streetaddress" type="string"

Example usage: 
<myObject><streetaddress>12345 Smith Ave.</streetAddress></myObject>

I would like to define a myOtherObject which can have a "forwardingaddress"
instead of the "pobox" or "streetaddress"es:

<myOtherObject><forwardingaddress>12345 Jones

The crunch is that I also need myOtherObject to *substitute* for myObject
under myContainer. However if I declare myOtherObject to have
substitutionGroup="myObject", it seems to have to be to be a derivation from
myObjectType - thereby inheriting the requirement to have either a "pobox"
or a "streetaddress". Is there some way I can:

* substitute for, without deriving from (extending), myObjectType;
* extend myObjectType with a minOccurs="0" on the elements in the choice; or
* extend myObjectType with another possible element (forwardingaddress) in
the choice

.... allowing me to get around the one-or-the-other(pobox|streetaddress)
restriction - and leave the original schema intact?

Received on Monday, 2 August 2004 05:33:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:23 UTC