0

Hopefully the schema here describes what I'm trying to do.

<xs:complexType name="Survey">
    <xs:sequence>
        <xs:element name="SurveyID" type="SurveyID"/>
        <xs:choice>
            <!-- Allow topics, questions, answers on their own -->
            <xs:element name="Topics" type="SurveyTopics"/>
            <xs:element name="Questions" type="SurveyQuestions"/>
            <xs:element name="Answers" type="SurveyAnswers"/>
            <xs:sequence>
                <!-- Allow topics and questions to be created simultaneously by a survey admin -->
                <xs:element name="Topics" type="SurveyTopics"/>
                <xs:element name="Questions" type="SurveyQuestions"/>
            </xs:sequence>
            <xs:sequence>
                <!-- Allow user to create new questions when they're answering -->
                <xs:element name="Questions" type="SurveyQuestions"/>
                <xs:element name="Answers" type="SurveyAnswers"/>
            </xs:sequence>
        </xs:choice>
    </xs:sequence>
</xs:complexType>

I want to accept topics, questions, and answers. Topics and questions can be combined, a survey administrator might do this when creating new topics. Questions and answers can be combined, a surveyee is allowed to add their own questions when filling out the survey.

The error I'm getting is Multiple definition of element '..Topics' causes the content model to become ambiguous. I think this is because it's not sure if Topics is on it's own, or supposed to be the start of the sequence.

Is there good way to accomplish what I'm going for?

Jamie
  • 168
  • 10

1 Answers1

0

After posting I found a related question that pointed me in the right direction.

This is what I came up with.

<xs:complexType name="Survey">
    <xs:sequence>
        <xs:element name="SurveyID" type="SurveyID"/>
        <xs:choice>
            <xs:sequence>
                <!-- Allow topics, or topics and questions -->
                <xs:element name="Topics" type="SurveyTopics"/>
                <xs:element name="Questions" type="SurveyQuestions" minOccurs="0"/>
            </xs:sequence>
            <xs:sequence>
                <!-- Allow questions, or questions and answers -->
                <xs:element name="Questions" type="SurveyQuestions"/>
                <xs:element name="Answers" type="SurveyAnswers" minOccurs="0"/>
            </xs:sequence>
            <!-- Allow answers on their own -->
            <xs:element name="Answers" type="SurveyAnswers"/
        </xs:choice>
    </xs:sequence>
</xs:complexType>
Jamie
  • 168
  • 10