我看到了一个XML模式(EPP)whitch使用xsd:choice
与元素,即使我们可以用xsd:enumeration
代替:为什么有些模式使用<xsd:choice>而不是<xsd:enumeration>?
<element name="access" type="epp:dcpAccessType"/>
<complexType name="dcpAccessType">
<choice>
<element name="all"/>
<element name="none"/>
<element name="null"/>
<element name="other"/>
<element name="personal"/>
<element name="personalAndOther"/>
</choice>
</complexType>
使问题清楚了,我会用这个例子来代替:
<element name="sport" type="sportType"/>
<!-- using choice-->
<complexType name="sportType">
<choice>
<element name="football"/>
<element name="tennis"/>
</choice>
</complexType>
<!-- Or using enumeration-->
<simpleType name="sportType">
<restriction base="string">
<enumeration value="football"/>
<enumeration value="tennis"/>
</restriction>
</simpleType>
使用模式的XML示例:
<!--using choice-->
<sport>
<football/>
</sport>
<!--using enumeration-->
<sport>football</sport>
他们为什么喜欢xsd:choice
而不是xsd:enumeration
在这种情况下?
由于