W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2001

element substitutiongroups

From: Forge <forge@neonics.com>
Date: Wed, 28 Mar 2001 19:19:43 +0000 (UTC)
To: xmlschema-dev@w3.org
Message-ID: <Pine.LNX.4.21.0103281912080.531-100000@fire>

Hi there,

Normally the substitutiongroups look at the element name.

Is it also possible to make it look at some attribute name?

I have an element as such:

<status report-type="xxx">
  <options>...</options>
  <!-- some other elements, depending on the "xxx' above -->
</status>


I have made the following schema:


  <xsd:element name="status-report" type="statusReport" abstract="true"/>

  <!-- 'base class' -->
  <xsd:complexType name="statusReport">
    <xsd:sequence>
      <xsd:element name="options" type="options" minOccurs="0"/>
    </xsd:sequence>
    <xsd:attribute name="report-type" type="xsd:string" use="required"/>
  </xsd:complexType>

  <!-- instance for report-type="a" -->
  <xsd:element name="status" substitutionGroup="status-report">
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:restriction base="statusReport">

          <!-- add the 'payment-clusters' element -->
          <xsd:sequence>
            <xsd:element name="payment-clusters" type="paymentClusters"
                minOccurs="1"/>
          </xsd:sequence>

          <!-- fix the attribute to 'a' -->
          <xsd:attribute name="report-type">
            <xsd:simpleType>
              <xsd:restriction base="xsd:string">
                <xsd:enumeration value="a"/>
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:attribute>

        </xsd:restriction>
      </xsd:complexContent>
                                 
    </xsd:complexType>
  </xsd:element>

and something like that for "b". The only difference between the two is
the attribute's value and there is another element (not payment-clusters
but something else).


XMLSpy gives me the (correct) error that there are multiple declarations
of element 'status'.


Can this be done? Maybe with "xsd:choice", if so, how? I'd like
to keep the 'subclassing' in since I don't want to keep copying
everything :)


Thanks for your efforts!

Greetings,

	Kenney Westerhof
Received on Wednesday, 28 March 2001 12:11:47 GMT

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