【问题标题】:xsd - not allowing values defined in the enumeration listxsd - 不允许在枚举列表中定义值
【发布时间】:2018-05-02 12:37:49
【问题描述】:

我想对属性强制执行一个规则,该规则不允许在与另一个属性关联的枚举值中定义的值。

这是我的示例架构。

<xs:complexType name="component">
    <xs:attribute name="type" type="componentMainType"/>
    <xs:attribute name="category" type="forbiddenCategoryTypes" use="optional"/>
</xs:complexType>

<xs:simpleType name="forbiddenCategoryTypes">
  <xs:restriction base="xs:string">
    **<xs:pattern value="not in forbiddenCategoryTypes"/>**
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="componentMainType">
  <xs:restriction base="xs:string">
    <xs:enumeration value="Component1"/>
    <xs:enumeration value="Component2"/>
    <xs:enumeration value="Component3"/>
    <xs:enumeration value="Component4"/>
    <xs:enumeration value="Component5"/>
  </xs:restriction>
</xs:simpleType>

【问题讨论】:

    标签: xsd schema


    【解决方案1】:

    在我看来不可能,模式只需要一个正则表达式。我找不到任何其他相关限制。

    我建议用值改变正则表达式的方法(我知道这不是最佳解决方案)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多