Click to See Complete Forum and Search --> : XML validation woes


gogginderek
04-29-2008, 11:55 AM
Hi,

I am hoping someone will be able to help me with an issue I am having in writing a schema for a piece of XML. Below is a sample of what the XML will look like

<elem1>

<elem2/>
<elem3/>
<elem4/>
<elem5/>

</elem1>


elem2,3 can be either present or not present but one of either elem4 or elem5 must be present. The real sticking point for me is I don't want to use a combination of <xs:sequence and <xs:choice as I want these elements to be un-ordered. Also if I use <xs:all I am restricted from using an <xs:choice sub element. Below is an example of another solution I tried which does not work.


<xs:complexType name="CHOICEBLOCK">
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="elem4" type="ELEM4" minOccurs="0" maxOccurs="1"/>
<xs:element name="elem5" type="ELEM5" minOccurs="0" maxOccurs="1"/>
</xs:choice>
</xs:complexType>



<xs:complexType name="CreateModel">
<xs:complexContent>
<xs:extension base="CHOICEBLOCK">


<xs:all>
<xs:element name="elem2" type="ELEM2" minOccurs="1" maxOccurs="1"/>
<xs:element name="elem3" type="ELEM3" minOccurs="0" maxOccurs="1"/>

</xs:all>
Can anyone provide an insight into this as I am relativly new to XML and am hitting a dead end with it :confused: :confused:

thanks,
Derek