【发布时间】:2012-02-14 02:11:48
【问题描述】:
我有以下 XML 标记
<price currency="euros">20000.00</price>
如何将货币属性限制为以下之一:
- 欧元
- 磅
- 美元
价格要翻倍?
当我尝试在两者上输入一个类型时,我只是得到一个错误,这是我目前所得到的:
<xs:element name="price">
<xs:complexType>
<xs:attribute name="currency">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="pounds" />
<xs:enumeration value="euros" />
<xs:enumeration value="dollars" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
【问题讨论】:
-
如果您这样做,您还需要从
元素中删除 type="xs:string" 。当 simpleType 或 complexType 存在时,你不能给出类型。