如何创建接受一系列预定义值的XSD类型



我试图定义在我的XML文档中使用的类型,它仅接受该特定数据类型,这是以下值之一:

  • product1
  • product2
  • product3

这可能吗?

好吧,我刚刚使用属性"枚举"找到了答案。这是说明,以下代码是其中使用的示例:

<xs:element name="car">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="Audi"/>
      <xs:enumeration value="Golf"/>
      <xs:enumeration value="BMW"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

最新更新