在我的XML模式定义中,我试图将属性的值限制为0到100之间的整数.
参考下面的示例模式,我希望元素'root'上的属性'attr'具有此限制.为此,我定义了一个simpleType'Percentage'并将其设置为'attr'的'type'.
但是,我的XML模式编辑器(VS 2008)将属性标记为有问题:"类型'百分比'未声明或不是简单类型".
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" id="test" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://testtttt">
<xs:simpleType name="Percentage">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="root">
<xs:complexType>
<xs:attribute name="attr" type="Percentage" use="optional" />
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4012 次 |
| 最近记录: |