W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2002

Re: Substitution Group

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 26 Jun 2002 10:00:28 +0100
Message-ID: <132248461598.20020626100028@jenitennison.com>
To: "Eoin Shanaghy" <eoinshanaghy@iol.ie>
CC: xmlschema-dev@w3.org

Hi Eoin,

> It seems that the extension for "sub" has to be the same type as
> "base", but how did I extend the anonymous complexType??

I see you're trying to confuse us by using 'xs' as the prefix for your
target namespace :)

You can't extend anonymous complex types, so you have to give them a
name, for example 'baseType':

<element name="base" type="xs:baseType" />
<complexType name="baseType" />

Then you can explicitly extend the baseType to provide the type for
the sub element:

<element name="sub" substitutionGroup="xs:base">
  <complexType>
    <complexContent>
      <extension base="xs:baseType">
        <sequence>
          <element name="subAttr" />
        </sequence>
      </extension>
    </complexContent>
  </complexType>
</element>

Note: I think that you might run into problems if you try to use an
'all' model group in your extension, because when you derive a type by
extension you effectively create a sequence of the base and extended
model groups, and 'all' model groups can't appear within sequences.
That's not a problem because you've only got one element in the above
anyway, but I guess it might be in your real situation. If so, I
suggest you look at making the base element be of type xs:anyType and
have the sub element's type be derived by restriction rather than
extension.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 26 June 2002 05:00:29 GMT

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