Re: Changing sequence of mixed elements

Hi Erwin,

> I'd looked at the Primer doc, hacked my schema but did not found the
> proper implementation of the following problem (yet). I hope
> somebody can help me:
>
> The following schema-part.....
>
>     <xsd:complexType name="testType" mixed="true">
>                 <xsd:sequence>        
>                     <xsd:element name="pA" type="xsd:string"
> maxOccurs="unbounded"/>
>                     <xsd:element name="pB" type="xsd:string"
> maxOccurs="unbounded"/>
>                 </xsd:sequence>        
>     </xsd:complexType>

This states that elements of the type testType have a content model of
a sequence of (that's what xs:sequence means) one or more pA elements
*followed by* one or more pB elements. The content model is mixed, so
you can have any text you like intermingled with those elements.

I don't know what model you want, but it sounds as if you might want
to allow the pB elements to come before the pA elements as well as the
other way round, in which case you need something like:

<xs:complexType name="testType" mixed="true">
  <xs:choice>
    <xs:sequence>
      <xs:element name="pA" type="xs:string" maxOccurs="unbounded" />
      <xs:element name="pB" type="xs:string" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:sequence>
      <xs:element name="pB" type="xs:string" maxOccurs="unbounded" />
      <xs:element name="pA" type="xs:string" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:choice>
</xs:complexType>

Or you might want to allow any mixture of pA and pB elements, in which
case you want:

<xs:complexType name="testType" mixed="true">
  <xs:choice maxOccurs="unbounded">
    <xs:element name="pA" type="xs:string" />
    <xs:element name="pB" type="xs:string" />
  </xs:choice>
</xs:complexType>

If neither of the above does the trick, please post again describing
what kind of content you want the test element to have.

I hope that helps,

Jeni

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

Received on Friday, 9 November 2001 04:34:42 UTC