是否有可能以指定的标签或属性的的值不应该是这样 SOME_VALUE

我有一种奇怪的要求,其中所述XSD是不知道的值的被发送给它。该特定标签的值可以是任意值的一个字符串除了一个值(比如说data_migration)。

在发送器应与该错误确认,如果该特定值被发送。

是否有可能以指定此限制?

有帮助吗?

解决方案

我不是正则表达式的专家,但此SimpleType让一切开始data_migration无效。

<xs:simpleType name="notDataMigration">
  <xs:restriction base="xs:string">
    <xs:pattern value="^(?!data_migration).*" />
  </xs:restriction>
</xs:simpleType>

其他提示

我不知道你是否能明确排除的值。我不知道这会有所帮助,但你可以创建两个单独的枚举,然后创建枚举的工会。

<xsd:simpleType name="IncludedEnumType">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="pending" />
    <xsd:enumeration value="in_process" />
    <xsd:enumeration value="failed" />
    <xsd:enumeration value="unknown" />
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="ExcludedEnumType">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="data_migration" />
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="CombinedEnumType">
  <xsd:union memberTypes="IncludedEnumType ExcludedEnumType" />
</xsd:simpleType>

您会使用任一IncludedEnumTypeCombinedEnumType是必要的。使用IncludedEnumType显然在ExcludedEnumType中排除的值。

此方法从由IBM 这本文使用溶液2。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top