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

Re: mixing orderer and unordered elements

From: Rick Jelliffe <ricko@topologi.com>
Date: Thu, 13 Jun 2002 04:44:01 +1000
Message-ID: <042001c21241$1ef0d8b0$4bc8a8c0@AlletteSystems.com>
To: <xmlschema-dev@w3.org>

Torsten Curdt <tcurdt@dff.st> wrote:
--------------------------------------------------------------------------
 I am trying to have a mixture of ordered and unordered elements:

<root>
  <seq1/>
  <seq2/>
  <unordered2/>
  <unordered1/>
</root>
-------------------------------------------------------------------------

For these kind of complex requirements, it may be easier to layer
rather than attempt baroque content models:

  <xs:element name="root">
    <xs:complexType>
        <xs:all>
          <!-- All in the family -->
          <xs:element name="seq1"/>
          <xs:element name="seq2"/>
          <xs:element name="unordered1"/>
          <xs:element name="unordered2"/>
        </xs:all>
    </xs:complexType>
    <xs:annotation>
        <xs:appinfo>
            <pattern xmlns="http://www.ascc.net/xml/schematron">
                   <rule context="root">
                       <!-- Who's on first -->
                        <assert test="*[1][self::seq1]" />
                        <assert test="*[2][self::seq2]" />
                    </rule>
            </pattern>
        </xs:appinfo>
    </xs:annotation>
  </xs:element>
</xs:schema>

with the proviso that ifever  "root" is used as a local element name
with a different content model you will need to factor that in
(such as   <rule context="root[not(parent::fred)]">  
which breaks encapsulation.


Cheers
Rick Jelliffe
Received on Wednesday, 12 June 2002 14:31:16 GMT

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