[英]specifying values in enum in XSD
我在XSD文件中定义了如下的枚举
<xs:simpleType name="PaperSizes">
<xs:restriction base="xs:string">
<xs:enumeration value="NUMBERS"></xs:enumeration>
<xs:enumeration value="PICTURE"></xs:enumeration>
<xs:enumeration value="RTF"></xs:enumeration>
</xs:restriction>
我需要覆盖编译器分配的详细值。 即: - 对于NUMBERS,默认值为0.我需要值2。
我需要做些什么改变?
谢谢。
您不能为集合中的每个值设置不同的默认值。 您可以使用“default”关键字为任何xsd简单类型设置一个默认值。
因此,如果您想在上面的示例中设置默认值,您可以执行以下操作:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element default="PICTURE" name="PaperSizes">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="NUMBERS" />
<xs:enumeration value="PICTURE" />
<xs:enumeration value="RTF" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.