Re: Need help using all, group, choice, and sequence

Hi Rekha,

>       Is it possible to specify,
>
>       a) that GrpA, GrpB, and Element1 can occur in any
>          order within the RootElement.

Not with xs:all, and therefore not without either (a) creating content
models that spell out the possible combinations using xs:choice and
xs:sequence or (b) creating an open content model with a repeating
xs:choice and then using a something else (e.g. Schematron) to test
whether the required elements are present.

>       b) that the elements inside GrpA, i.e. GrpAElem1,
>          GrpAElem2, and GrpAElem3 can occur in any order.

Since all the elements in GrpA are optional and can be repeated any
number of times, you can achieve a mix between them by defining GrpA
as a choice (rather than a sequence) between the elements and using
minOccurs="0" maxOccurs="unbounded" on the reference to the group (you
don't have to specify minOccurs or maxOccurs on any of the element
declarations within the group if you do this).

>                /-----Child1  (optional) max=unbounded
>       Parent----------Child2  (optional)  max=unbounded
>               \ -----Child3  (optional)  max= unbounded
>
>       But Child1 or Child2 or both Child1 and Child2,
>       should be present.  Also, I would like to see if I
>       can specify without restricting the sequence of
>       occurance for Child1 and Child2(Child1 or Child2
>       can be specified first).

You can do this with:

  <xs:sequence>
    <xs:choice>
      <xs:sequence>
        <xs:element ref="Child1" />
        <xs:group ref="Child1Child2Choice" minOccurs="0"
                  maxOccurs="unbounded" />
      </xs:sequence>
      <xs:sequence>
        <xs:element ref="Child2" />
        <xs:group ref="Child1Child2Choice" minOccurs="0"
                  maxOccurs="unbounded" />
      </xs:sequence>
    </xs:choice>
    <xs:element ref="Child3" />
  </xs:sequence>

where Child1Child2Choice is defined as:

<xs:group name="Child1Child2Choice">
  <xs:choice>
    <xs:element ref="Child1" />
    <xs:element ref="Child2" />
  </xs:choice>
</xs:group>
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 1 November 2001 13:59:19 UTC