如何使用 XSD 在 XML 文件中排除枚举值? [英] How to exclude an enumeration value in XML file using XSD?

查看:24
本文介绍了如何使用 XSD 在 XML 文件中排除枚举值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以指定标签或属性的值不应像 some_value ?

Is it possible to specify the value of a tag or attribute should not be like some_value ?

我有一个奇怪的要求,xsd 不知道发送给它的值.该特定标记的值可以是具有任何值的字符串除了一个值(比如data_migration).

I have a strange requirement, where the xsd isn't aware of the values being sent to it. The value of that particular tag can be a string with any value except one value ( say data_migration).

如果发送了该特定值,则应向发送方确认错误.

The sender should be acknowledged with the error, if that particular value is sent.

是否可以指定此限制?

推荐答案

我不是正则表达式专家,但是这个 simpleType 使得以 data_migration 开头的所有内容都无效.

I'm no regex expert, but this simpleType makes everything starting with data_migration invalid.

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

这篇关于如何使用 XSD 在 XML 文件中排除枚举值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆