--默认值
<xs:element name="color" type="xs:string" default="red" />
--固定值
<xs:element name="color" type="xs:string" fixed="red" />
--必须输入
<xs:attribute name="xx" type="uu" use="required"/>
--限定值范围
<xs:element name="age">
<xs:simpletype >
<xs:restriction base="xs:integet">
<xs:minInclusive value="0" />
<xs:maxInclusive value="120" />
</xs:restriction>
</xs:smipletype>
<xs:element>
--限定为一组值
<xs:element name="car" type="cartype">
<xs:simpletype name="cartype">
<xs:restriction base="xs:string">
<xs:enumeration value="aaaa" />
<xs:enumeration value="bbbb" />
<xs:enumeration value="cccc" />
</xs:restriction>
</xs:simpletype>
</xs:element>
--模式约束
<xs:element name="prodid">
<xs:simpletype>
<xs:restriction base="xs:integer">
<xs:pattern value="[0-9][A-Z]" />
</xs:restriction>
</xs:simpletype>
</xs:element>
--小写字母+大写字母
<xs:element name="letter">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([a-z][A-Z])+"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
--male和female 只取其一 value 可以是正则表达式
<xs:element name="gender">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:pattern value="male|female" />
</xs:restriction>
</xs:simpletype>
</xs:element>
---对空白字符的处理
<xs:element name="address">
<xs:simpletype>
<xs:restriction base="xs:string">
--这意味着 XML 处理器将移除所有空白字符
-- (换行、回车、空格以及制表符会被替换为空格,
-- 开头和结尾的空格会被移除,而多个连续的空格
-- 会被缩减为一个单一的空格):
<xs:whiteSpace value="collapse" />
--这意味着 XML 处理器将移除所有空白字符(换行、回车、空格以及制表符):
<xs:whiteSpace value="replace"/>
--XML 处理器不会移除任何空白字符
<xs:whiteSpace value="preserve"/>
</xs:restiction>
</xs:simpletype>
</xs:element>
--限定长度 8
<xs:element name="password">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
--长度
<xs:element name="password">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
<xs:maxLength value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
限定 | 描述 |
---|---|
enumeration | 定义可接受值的一个列表 |
fractionDigits | 定义所允许的最大的小数位数。必须大于等于0。 |
length | 定义所允许的字符或者列表项目的精确数目。必须大于或等于0。 |
maxExclusive | 定义数值的上限。所允许的值必须小于此值。 |
maxInclusive | 定义数值的上限。所允许的值必须小于或等于此值。 |
maxLength | 定义所允许的字符或者列表项目的最大数目。必须大于或等于0。 |
minExclusive | 定义数值的下限。所允许的值必需大于此值。 |
minInclusive | 定义数值的下限。所允许的值必需大于或等于此值。 |
minLength | 定义所允许的字符或者列表项目的最小数目。必须大于或等于0。 |
pattern | 定义可接受的字符的精确序列。 |
totalDigits | 定义所允许的阿拉伯数字的精确位数。必须大于0。 |
whiteSpace | 定义空白字符(换行、回车、空格以及制表符)的处理方式。 |