SCHEMA学习一
2016-02-03 14:27
357 查看
<!--定义简易元素--> <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <lastname>Smith</lastname> <age>28</age> <!--简易元素的默认值和固定值--> <xs:element name="color" type="xs:string" default="red"/> <xs:element name="color" type="xs:string" fixed="red"/> <!--属性。简易元素无法拥有属性--> <xs:attribute name="width" type="xs:decimal"/> <width>10.2</width> <!--属性的默认值和固定值--> <xs:attribute name="width" type="xs:decimal" default="10.1"/> <xs:attribute name="width" type="xs:decimal" fixed="10.1"/> <!--必选的属性 使用use属性--> <xs:attribute name="lang" type="xs:string" use="required"/> <!--对值的限定。如下定义了带有一个限定且名为age的元素, age的值不能低于0或者高于120--> <xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="120"/> </xs:restriction> </xs:simpleType> </xs:element> <!--对一组值的限定 使用枚举约束 enumeration constraint--> <xs:element name="car"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Audi"/> <xs:enumeration value="Golf"/> <xs:enumeration value="BMW"/> </xs:restriction> </xs:simpleType> </xs:element> <!--对一系列值的限定 使用pattern constriction 只能输入a到z中的一个--> <xs:element name="letter"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[a-z]"/> </xs:restriction> </xs:simpleType> </xs:element> <!--对空白字符 使用whiteSpace限定 preserve表示XML不会移除任何空白字符 replace表示移除任何回车 换行制表符空格等空白字符 collpase表示换行回车空格及制表符被替换为空格 开头和结尾的空格会被移除 而多个连续的空格会被缩减为一个单一的空格--> <xs:element name="address"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:whiteSpace value="preserve"/> </xs:restriction> </xs:simpleType> </xs:element> <!--对长度的限定 限定password长度为8个字符--> <xs:element name="password"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:length value="8"/> <xs:minLength value="5"/> <xs:maxLength value="10"/> </xs:restriction> </xs:simpleType> </xs:element> <!-- 数据类型的限定 enumeration 定义可接受值的一个列表 fractionDigits 定义所允许的最大的小数位数 length 定义所允许的字符或者列表项目的精确数目 maxExclusive 定义数值的上限 所允许的值必须小于此值 maxInclusive 定义数值的上限 所允许的值必须小于等于此值 maxLength 定义所允许的字符或者列表项目的最大数目 minExclusive 定义数值的下限 minInclusive 定义数值的下限 minLength 定义所允许的字符或者列表项目的最小数目 pattern 定义可接受的字符的精确序列 totalDigits 定义所允许的阿拉伯数字的精确位数 whiteSpace 定义空白字符的处理方式 -->
相关文章推荐
- Spring REST
- BLE广播解释
- nginx的使用
- 二叉树逐行打印,同时打印每行时需要换行
- Android 网络框架学习之Retrofit
- mysql-5.7.10-winx64免安装版配置时碰到的问题
- centos7上编译openjdk
- Junit单元测试
- torch安装
- 华罗庚“统筹方法”的局限性——节约时间需要注意的问题
- (28)Cocos2d-x xml解析
- (27)Cocos2d-x 3.0 Json用法
- GeoTools-Swing显示原理
- Java观察者设计模式详解
- HDU——1027Ignatius and the Princess II(next_permutation函数)
- 【物联网】OpenWrt编译出现Unable to find remote helper for 'https'问题
- [算法学习]输入遍历重建二叉树
- C#设计模式——适配器模式
- php empty()和isset()的区别
- BZOJ 3875: [Ahoi2014]骑士游戏