XML - Schema之数据类型扩展
来源:互联网 发布:监测数据造假 编辑:程序博客网 时间:2024/05/13 22:58
一、定义
<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.xilen.com/customer" xmlns:customer="http://www.xilen.com/customer"> <!-- 定义当前命名空间的根元素customer --><element name="customer" type="customer:customerType"/><complexType name="customerType"> <!-- 定义customer的数据类型 --><sequence><element name="name" type="customer:nameType"/> <!-- 定义customer的name子元素,数据类型引用nameType的定义 --><element name="address" type="customer:addressType"/><!-- 定义customer的address子元素,数据类型引用nameType的定义 --><element name="extName" type="customer:extNameType"/> <!-- 扩展后的元素 --><element name="extAddress" type="customer:extAddressType"/> <!-- 扩展后的元素 --></sequence></complexType><simpleType name="nameType"> <!-- 定义Name --><restriction base="string"><pattern value="[a-zA-Z][_a-zA-Z0-9]*" /> <!-- 定义正则来规范名称 --><minLength value="3" /> <!-- 定义最小长度 --><maxLength value="18" /> <!-- 定义最大长度 --></restriction></simpleType><complexType name="addressType"> <!-- 定义address的数据类型 --><sequence><element name="code" type="customer:codeType" /> <!-- 定义address的code子元素,数据类型引用codeType的定义 --><element name="info" type="customer:infoType"/> <!-- 定义address的info子元素,数据类型引用infoType的定义 --></sequence></complexType><simpleType name="codeType"> <!-- 定义Code --><restriction base="string"> <!-- 定义限定条件,基于string的类型 --><pattern value="[0-9]*"/><length value="6"/> <!-- 定义最小长度 --></restriction></simpleType><simpleType name="infoType" > <!-- 定义Info的类型 --><restriction base="string"> <!-- 定义限定条件,基于string的类型 --><minLength value="0"/> <!-- 定义最小长度 --><maxLength value="255"/> <!-- 定义最大长度 --></restriction></simpleType><!-- - - - - - - - - - - - - - - - - - - 分隔线 - - - - - - - - - - - - - - - - - --><!-- 对复杂类型addressType进行扩展,添加note子元素 --><complexType name="extAddressType"><complexContent><extension base="customer:addressType"><sequence><element name="note" type="string"/></sequence></extension></complexContent></complexType><!-- 对简单类型nameType进行扩展,添加id属性 --><complexType name="extNameType"><simpleContent><extension base="customer:nameType"><attribute name="id" type="string"/></extension></simpleContent></complexType></schema>三、使用
<?xml version="1.0" encoding="UTF-8"?><customer xmlns="http://www.xilen.com/customer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.xilen.com/customer ext_customer.xsd"><name>Tom</name><address><code>100000</code><info>BeiJing</info></address><extName id="extId-0001">ExtTom</extName> <!-- 添加了Id属性 --><extAddress><code>100000</code><info>BeiJing</info><note>Home</note> <!-- 添加了note子元素 --></extAddress></customer>
0 0
- XML - Schema之数据类型扩展
- XML - Schema之数据类型重用
- xml的Schema扩展
- XML Schema内置数据类型
- XML Schema(W3C)数据类型
- XML学习之Xml Schema:七、派生复杂类型--扩展
- XML简介Schema之XSD 杂项数据类型 VS XML总结
- XML简介Schema之XSD XSD 实例 VS 字符串数据类型
- xml schema数据类型,元素类型
- XML简介Schema之 XSD 日期及时间数据类型 VS XSD 数值数据类型
- XML学习之 schema
- Xml Schema 之 指示器
- xml之schema
- XML之Schema验证
- XML之Schema约束
- XML学习之Schema
- XML之Schema验证
- xml之DTD && schema
- Java 同步块(synchronized)详细说明
- 训练赛的二三事
- JAVA RMI(远程方法调用)简单实例
- 新辰:浅谈那些被挑毛病的90后创业者 到底谁错了?
- css 权重
- XML - Schema之数据类型扩展
- 序列化与持久化相同点跟不同点
- C++获取本机IP地址信息
- UML语言简介-协作图
- 打开文件对话框OpenFileDialog
- hibernate could not resolve property
- 调用存储过程
- MMORPG游戏服务器端设计
- 企业应用网站性能优化实例分析_SEO的关键