xsd:choice on 'unconnected' elements
I have an xml that comes in two forms
<root>
<element1 req="mandatory"/>
<element2/>
<element3/>
<root>
and
<root>
<element2/>
<element3/>
<element4 req="开发者_StackOverflow中文版mandatory"/>
<root>
element1 or elem4 is req'd 2 and 3 are optional. I just cant figure out how to use a xsd:choice on it, help, thanks.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="root">
<xs:complexType>
<xs:choice>
<xs:sequence>
<xs:element name="element1"/>
<xs:element name="element2" minOccurs="0"/>
<xs:element name="element3" minOccurs="0"/>
</xs:sequence>
<xs:sequence>
<xs:element name="element2" minOccurs="0"/>
<xs:element name="element3" minOccurs="0"/>
<xs:element name="element4"/>
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:element>
精彩评论