开发者

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>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜