当前位置:网站首页>xml schem 记录
xml schem 记录
2022-06-23 05:38:00 【小代码2016】
优势
- 可读性更好
- 支持为元素内容或属性值指定数据类型,功能更完善、更强大
- 可针对未来的需求进行扩展
根元素
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:schema>
xmlns[:xxx]属性用于为指定XML文档引入语义约束。该属性的属性值就是该文本所使用的语义约束对应的命名空间。xxx是一个任意胡标识名,作为该约束所定义的所有元素的前缀
xmlns:xs="http://www.w3.org/2001/XMLSchema"是每个schema文档都有的
指定命名空间
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3school.com.cn"
xmlns="http://www.w3school.com.cn">
</xs:element>
targetNamespace="http://www.w3school.com.cn"指定该schema的目标命名空间。当需要引用该XML schema里定义的schema组件时,通常需要使用该命令空间对应的前缀作为限定xmlns="http://www.w3school.com.cn"指定使用http://www.w3school.com.cn命名空间下的组件时,不需要使用任何前缀作为限定
不论是XML文档还是XML schema文档,其根元素可以接受任意多个xmlns[:xxx]属性,其中[:xxx]部分是可选的,xxx可以是任意合法的标识名。
xmlns:[xxx]="schameNamespace"指定使用schameNamespace命名空间下的组件时,应该使用xxx前缀作为限定
此外,可以为schema元素指定如下两个属性:
elementFormDerfault:该属性值可以是qualified或unqualified,用于指定XML文档使用该schema中定义的局部元素时是否必须使用命名空间限定
attributeFormDerfault:该属性值可以是qualified或unqualified,用于指定XML文档使用该schema中定义的局部属性时是否必须使用命名空间限定
xml 引入 schema
引用无命名空间的 schema
在文档根元素中添加如下两个属性:
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:noNamespaceSchemaLocation:指定XML Schema文件的URI
引用有命名空间的 schema
- 每引入一个有命名空间的schema,就为XML根元素添加一个xmlns[:xxx]属性
如果XML根元素中已有xsi:schemaLocation属性(xsi前缀可变),则在该属性值后为该XML Schema追加一项,追加项要保持 schemaNamespace schemaURI 的格式。
如果XML根元素中还没有xsi:schemaLocation属性,则为其添加该属性,并设置属性值为 schemaNamespace schemaURI
一份XML文档中最多引入一份无命名空间的XML Schema
数据类型
schema不仅内置了丰富的数据类型,还允许开发者从内置数据类型派生新数据类型。
schema支持的数据类型分为两大类:
简单类型:可以作为XML元素的类型,也可以作为XML属性的类型
复杂类型:只能作为XML元素的类型
其中简单类型分类:
done
边栏推荐
- C language stepping on the pit: document coding error, resulting in Base64 Chinese coding error
- Laravel log channel grouping configuration
- Set tensorflow1 X to pytorch
- 2022-01-12: give a positive array arr, length N, subscript 0~n-1, a
- 开源生态|超实用开源License基础知识扫盲帖(下)
- Explain csma/cd, token bus and token ring clearly
- leetcode - 572. A subtree of another tree
- 嵌入式实时系统线程的副作用
- js创建数组(元素都是对象)
- MySQL ON DUPLICATE KEY 和 PgSQL ON CONFLICT(主键) 处理主键冲突
猜你喜欢

redux Actions may not have an undefined “type“ property. Have you misspelled a constant?

leetcode - 572. A subtree of another tree

Index - MySQL

Illustration Google V8 18: asynchronous programming (I): how does V8 implement micro tasks?
百度URL參數之LINK?URL參數加密解密研究(代碼實例)

The softing datafeed OPC suite stores Siemens PLC data in an Oracle Database

【接口自动化】软件测试涨薪核心技能、让薪资涨幅200%

Home address exchange

Sword finger offer 42 Maximum sum of successive subarrays

Network architecture from Wan to sd-wan edge devices
随机推荐
haas506 2.0开发教程-高级组件库-modem.sms(仅支持2.2以上版本)
Coordinate transformation
Get to know webassembly quickly
聚焦智慧城市,华为携手中科星图共同开拓数字化新蓝海
Functions and basic structure of CPU
云盒子联合深信服,为南京一中打造智慧双模教学资源分享平台
For non dpdk kvm1.0 machines, set init Maxrxbuffers changed from 256 to 1024 to improve packet receiving capacity
redux Actions may not have an undefined “type“ property. Have you misspelled a constant?
Focusing on the smart city, Huawei cooperates with China Science and technology Xingtu to jointly develop a new digital blue ocean
C Advanced Learning -- Reflection
如何实现与FDA保持邮件通信安全加密?
bootstrap如何清除浮动的样式
C# wpf 附加属性实现界面上定义装饰器
Miscellaneous things
Media industry under the epidemic situation, small program ecology driven digital transformation exploration
Programmers' real ideas | daily anecdotes
项目_过滤器Filter解决中文乱码
Xray linkage crawlergo automatic scanning pit climbing record
haas506 2.0开发教程-高级组件库-modem.sim(仅支持2.2以上版本)
Termux