Represent OR in XSD
I need开发者_运维技巧 to require
(firstName and lastName) OR (nameForDisplay)
in an XSD. I can get XOR if I use <xs:choice>
but I can't seem to get OR.
<choice>
<sequence>
<element name="firstName" />
<element name="lastName" />
<element name="nameForDisplay" minOccurs="0" />
</sequence>
<element name="nameForDisplay" />
</choice>
Ugly to have repetition, I know. You could factor out some repetition with groups.
Here's an alternative:
<choice>
<element name="Name" type="xs:complexType">
<sequence>
<element name="firstName" type="xs:String"/>
<element name="lastName" type="xs:String"/>
</sequence>
</element>
<element name="nameForDisplay" type="xs:String"/>
</choice>
精彩评论