【发布时间】:2014-02-10 21:50:56
【问题描述】:
我有一个只能有两个值的属性。
用什么更好?
模式?
<xsd:attribute name="sex">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="male|female" />
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
还是枚举?
<xsd:attribute name="sex">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="male"></xsd:enumeration>
<xsd:enumeration value="female"></xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
如果没有差异,我将使用模式(少一行)
【问题讨论】: