Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 05, 2012 02:38 PM by echotrain
Mar 01, 2012 09:13 PM|LINK
I am feeling my way with XML/Schema and having trouble designing a schema that will allow for some data to be required and in sequence, followed by some that is not. This XML snippet is an example:
Each Patient is required to have LastName and FirstName in that order. This would be followed by episodes of PsychiatricTreatment and MedicalTreatment. Both categories can have 0-unbounded entries in any order.
It seems to me that this should be represented by a group, but I'm not getting it. Here is what I have:
<xs:element ref="LastName" />
<xs:element ref="FirstName" />
<xs:group ref="TreatmentGroup" />
<xs:element name="PsychiatricTreatment" />
<xs:element name="MedicalTreatment" />
I would very much appreciate anything that could be pointed out to me.
Mar 05, 2012 02:38 PM|LINK
The solution turned out to be xs:choice rather than xs:all. I misunderstood the element restriction of maxOccurs="1", which actually means that while only 1 element at a time can be chosen, the choice can be made as many times as needed. For a detailed
discussion, see the W3Schools Schema forum, where I was disabused of my preconceptions: