开发者

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>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜