Re: Substitution Group

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 UTC