在xml中如何引用自己定义的schema文件?
来源:互联网 发布:js 数组元素 函数 编辑:程序博客网 时间:2024/05/22 17:50
最关键的就是xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”这句话
意思是:自己这个文档的命名空间,可以方便其它xml或着schema文件引入。
方式一:通过命名空间引入
第一步:创建自己的01.xsd文件。如下:
<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/01" xmlns:tns="http://www.example.org/01" elementFormDefault="qualified"> <element name="user"> <complexType> <sequence> <element name="id" type="int"/> <element name="username" type="string"/> <element name="born" type="date"/> </sequence> </complexType> </element></schema>
第二步:编写01.xml,在01.xml中可以引入自己定义的01.xsd文件,如下:
<?xml version="1.0" encoding="UTF-8"?><user xmlns="http://www.example.org/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/01"> <id>1</id> <username>zhangsan</username> <born>1989-12-20 </born></user>
第二种方式:通过文件路径引入:
示例如下:
<?xml version="1.0" encoding="UTF-8"?><user xmlns="http://www.example.org/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="01.xsd"> <id>1</id> <username>zhangsan</username> <born>1999-12-23</born></user>
0 0
- 在xml中如何引用自己定义的schema文件?
- 如何在web.xml中引用其它的xml文件
- xml schema 中如何定义类似Map的结构
- xml schema中如何定义Map类型
- 在 XML 文档中引用 Schema
- Android 怎样在styles.xml中定义自己的样式并引用样式
- eclipse 的xml引用自己写的schema文件有自动代码提示
- 手动在eclipse中添加XML文件的schema约束
- Spring2.0 xml schema功能-允许在spring配置文件中添加自己的xml schema及解析器
- gradle中如何在自己的.c文件中引用三方so的方法
- xml中引用自定义schema
- Solr学习笔记之在schema.xml中定义字段
- Android 如何在XML文件中定义动画
- Android 如何在XML文件中定义动画
- 如何在mybatis中定义mapper.xml文件?
- xml去掉schema中没定义的标签
- c++中如何定义自己的头文件
- 如何在应用中发送自己定义的广播Broadcast
- Python算法实践——AC自动机
- 文章标题
- Docker与容器
- 内核调试
- Android进阶——自定义View之重写ViewGroup组合系统控件实现自定义ToolBar模板
- 在xml中如何引用自己定义的schema文件?
- 打酱油路过,2016年第四届湘潭大学新生趣味程序设计竞赛-Java
- C++ VS2010 一个解决方案下多个项目间的数据调用
- 2016就快结束了
- php基础07_文件上传
- [AHK]利用声音提示
- 十二月英语总结
- Time && Mathf
- Hadop案例之WordCount