XML Schema Multiple Element Occurances

jezus

New Member
I am trying to develop an XML schema. It is for a survey, and example XML could look as follows.\[code\]<survey> <instructions>Please complete the survey.</instructions> <section> <sectionHeader>Multiple Choice: Select the most appropriate answer.</sectionHeader> <item> <question>What is your favorite color?</question> <answer> <option>red</option> <option>yellow</option> <option>blue</option> </answer> </item> <item> <question>What is your favorite shape?</question> <answer> <option>circle</option> <option>square</option> <option>triangle</option> </answer> </item> </section> <section> <sectionHeader>Free Response: Type a Response</sectionHeader> <item> <question>Who is your idol and why?</question> <answer> <textbox>Type your answer here.</textbox> </answer> </item> <section></survey>\[/code\]Basically, an answer can either contain one or more options, or a single text box. Also the survey must contain one or more sections, each of which can contain one or more items. I currently have the following xml schema.\[code\]<xs:element name="survey"> <xs:complexType> <xs:element name="instructions" type="xs:string"/> <xs:element name="section"> <xs:complexType> <xs:element name="sectionHeader" type="xs:string"/> <xs:element name="item"/> <xs:complexType> <xs:element name="question" type="xs:string"/> <xs:element name="answer"> ?? Choice between multiple options or one text box ?? </xs:element> </xs:complexType> </xs:element> </xs:complexType> </xs:element> </xs:complexType></xs:element>\[/code\]This however, only allows for one section and one item. I want to have it allow one or more of these tags in sequence. Also I want the answer tag to contain one or more options or a single textbox. How can I do this?
 
Back
Top