[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XSD Choice between sequences
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|