使用.xsd文件中的枚举验证属性 [英] validating an attribute using enumeration in .xsd file
本文介绍了使用.xsd文件中的枚举验证属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<applicationstatus code="2" />
我想用枚举来验证它来限制一组值(1或2或3)
代码价值可能是1或2或3
其中代码是元素ApplicationStatus的属性
请帮忙紧急...
I want to validate it using enumeration to Restrict a Set of Values(1 or 2 or 3)
code value may be 1 or 2 or 3
where code is attribute of element ApplicationStatus
Please help its urgent...
推荐答案
您可以创建自己的类型,如下所示:
You can create your own type, like so:
<xs:simpleType name="rangedInt">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1" />
<xs:maxInclusive value="3" />
</xs:restriction>
</xs:simpleType>
然后像这样使用
And then use it like this
<xs:attribute name="code" type="rangedInt" />
另请参见 W3Schools [ ^ ]
这将创建一个整数类型,允许值1,2和3.
属性的类型应该是rangedInt,而不是现在(可能)的常规整数。
See also W3Schools[^]
This will create an integer type that allows the values 1, 2 and 3.
The type of your attribute should then be rangedInt, instead of a regular integer like it is now (probably).
这篇关于使用.xsd文件中的枚举验证属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文