XML学习之------>Schema约束XML文件的实例
2023-09-27 14:29:34 时间
?xmlversion="1.0"encoding="UTF-8"? xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.itstar.cn/shiporder_1" elementFormDefault="qualified" xs:elementname="shiporder" xs:complexType xs:sequence xs:elementname="orderperson"type="xs:string" / xs:elementname="shipto" xs:complexType xs:sequence xs:elementname="name"type="xs:string"/ xs:elementname="address"type="xs:string" / xs:elementname="city"type="xs:string"/ xs:elementname="country"type="xs:string" / /xs:sequence /xs:complexType /xs:element xs:elementname="item"maxOccurs="unbounded" xs:complexType xs:sequence xs:elementname="title"type="xs:string"/ xs:elementname="note"type="xs:string"minOccurs="0"/ xs:elementname="quantity"type="xs:positiveInteger" /xs:element xs:elementname="price"type="xs:decimal"/ /xs:sequence /xs:complexType /xs:element /xs:sequence xs:attributename="orderid"type="xs:string" use="required"/ /xs:complexType /xs:element /xs:schema
shiporder_2.xsd文件:(不知道为什么此种方式不能加入targetNamespace属性)
?xmlversion="1.0"encoding="UTF-8"? xh:schemaxmlns:xh="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" !-- 简易元素的定义 -- xh:elementname="orderperson"type="xh:string" / xh:elementname="name"type="xh:string"/ xh:elementname="address"type="xh:string" / xh:elementname="city"type="xh:string"/ xh:elementname="country"type="xh:string" / xh:elementname="title"type="xh:string"/ xh:elementname="note"type="xh:string"/ xh:elementname="quantity"type="xh:positiveInteger"/ xh:elementname="price"type="xh:decimal"/ !-- 属性的定义 -- xh:attributename="orderid"type="xh:string" / !-- 复合元素的定义 -- xh:elementname="shipto" xh:complexType xh:sequence xh:elementref="name"/ xh:elementref="address"/ xh:elementref="city"/ xh:elementref="country"/ /xh:sequence /xh:complexType /xh:element xh:elementname="item" xh:complexType xh:sequence xh:elementref="title"/ xh:elementref="note"minOccurs="0"/ xh:elementref="quantity"/ xh:elementref="price"/ /xh:sequence /xh:complexType /xh:element xh:elementname="shiporder" xh:complexType xh:sequence xh:elementref="orderperson"/ xh:elementref="shipto"/ xh:elementref="item"maxOccurs="unbounded"/ /xh:sequence xh:attributeref="orderid"use="required" / /xh:complexType /xh:element /xh:schema
?xmlversion="1.0"encoding="UTF-8"? shiporderxmlns="http://www.itstar.cn/shiporder_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.itstar.cn/shiporder_1 shiporder_1.xsd" orderid="111" orderperson orderperson /orderperson shipto name name /name address address /address city city /city country country /country /shipto item title title /title note note /note quantity 100 /quantity price 100.0 /price /item item title title /title quantity 200 /quantity price 80.0 /price /item /shiporder
字节卷动 You will never know how excellent you are unless you impel yourself once.
相关文章
- 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort
- 【pytorch 入门系列】01深度学习-入门实例线性回归--pytorch版本&自定义版本
- PyTorch的自动混合精度(AMP)
- 机器学习---对线性回归模型假设条件的检验以及违反假设条件情况下的解决办法(Machine Learning Detection & Solutions Linear Regression Model Assumptions Violation)
- [na][dhcp]dhcp细枝末节&dhcp防攻
- Python 测试框架之 Unittest & Pytest
- [Laravel] 11 - WEB API : cache & timer
- [Linux/Bash/Shell]curl & wget
- ★古今中外著名14大悖论
- Android之从Browser中打开本地的应用程序&微信检测是否有对应app
- R & ggplot2 & Excel绘图(直方图/经验分布图/QQ图/茎叶图/箱线图)实例
- 正向代理和反向代理的区别&Nginx配置虚拟主机流程(后续更新)
- 【原创 Hadoop&Spark 动手实践 6】Spark 编程实例与案例演示
- Golang包管理工具govendor的使用&go mod
- 我的Android进阶之旅------>Android使用9Patch图片作为不失真背景
- 我的Android进阶之旅------>android异步加载图片显示,并且对图片进行缓存实例
- Hibernate学习之------>Hibernate中Session.load与Session.get的区别