[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSD Choice between sequences

  • From: "John Avery" <j.avery@b...>
  • To: <xml-dev@l...>
  • Date: Fri, 22 Dec 2006 12:08:11 +1100

xsd choice
I have a schema representing a message which has two parts in sequence,
I am trying to describe a specialisation of that message which imposes
certain constraints on the two parts of the message. Effectively if the
message has a type A part one it needs a type A part two, if it has a
type B part one it needs a type B part two, etc.

It seems to me that the logical way to express this would be:

<xsd:complexType name="specialisationMessage.CONTENT">
  <xsd:complexContent>
    <xsd:restriction base="message.CONTENT">
      <xsd:choice>
        <xsd:sequence>
          <xsd:element ref="partOne.TypeA"/>
          <xsd:element ref="partTwo.TypeA"/>
        </xsd:sequence>
        <xsd:sequence>
          <xsd:element ref="partOne.TypeB"/>
          <xsd:element ref="partTwo.TypeB"/>
        </xsd:sequence>
      </xsd:choice>
    </xsd:restriction>		
  </xsd:complexContent>
</xsd:complexType>

<xsd:element name="specialisationMessage"
type="specialisationMessage.CONTENT" substitutionGroup="message"/>

Where message has the type:

<xsd:complexType name="message.CONTENT">
  <xsd:complexContent>
        <xsd:sequence>
          <xsd:element ref="partOne"/>
          <xsd:element ref="partTwo"/>
        </xsd:sequence>
      </xsd:choice>
    </xsd:restriction>		
  </xsd:complexContent>
</xsd:complexType>

And where partOne.TypeA and partOne.TypeB are valid restriction of
partOne, and partTwo.TypeA and partTwo.TypeB are valid restrictions of
partTwo.

Yet when I validate this document I got message informing me that I I
cannot restrict a sequence with a choice, a fact verified by the XML
Schema documentation. So (finally) my question. How can i express this
restriction?

I can't say:


<xsd:complexType name="specialisationMessage.CONTENT">
  <xsd:complexContent>
    <xsd:restriction base="message.CONTENT">
      <xsd:sequence>
        <xsd:choice>
          <xsd:element ref="partOne.TypeA"/>
          <xsd:element ref="partOne.TypeB"/>
        </xsd:choice>
        <xsd:choice>
          <xsd:element ref="partTwo.TypeA"/>
          <xsd:element ref="partTwo.TypeB"/>
        </xsd:choice>
      </xsd:sequence>
    </xsd:restriction>		
  </xsd:complexContent>
</xsd:complexType>

as it allows type A and B messages to be mixed. 

ANy help would be much appreciated.

Regards,

John Avery


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.