first_.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="www.first.com">
<xs:simpleType name="bid">
<xs:restriction base="xs:string">
<xs:pattern value="[A]\d{6}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
second_.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="www.second.com">
<xs:simpleType name="aid">
<xs:restriction base="xs:string">
<xs:pattern value="[c]\d{6}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
_third.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="www.myweb.com"
targetNamespace="www.myweb.com"
xmlns:first="www.first.com"
xmlns:second="www.second.com"> <xs:import namespace="www.first.com" schemaLocation="first_.xsd"/>
<xs:import namespace="www.second.com" schemaLocation="second_.xsd"/> <xs:element name="books" type="infotype"/> <xs:complexType name="infotype">
<xs:sequence>
<xs:element name="book" type="booktype"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="booktype">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="atype"/>
</xs:sequence>
<xs:attribute name="bookid" type="first:bid"/>
</xs:complexType>
<xs:complexType name="atype">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
<xs:attribute name="authorid" type="second:aid"/>
</xs:complexType>
</xs:schema>

说明:

first_.xsd:定义简单类型, 并指定目标命名空间为"www.first.com";

second_.xsd:定义简单类型, 并指定目标命名空间为"www.second.com";

third_.xsd:定义复杂类型,并引用first_.xsd, second_.xsd,引用这两个schema文件,但是目标命名空间不一致。因为third_.xsd引用了first_.xsd, second_.xsd所以必须指定这两个文件的命名空间为"www.first.com"和"www.second.com",否则无法引用firtst.xsd, second.xsd中定义的简单类型数据;

目标命名空间:指定被此Schema文档约束的元素及数据类型都来自于的命名空间;

默认命名空间:指定当前XML文档中使用的元素及数据类型都来自于的命名空间;

最新文章

  1. 狼人杀BETA阶段计划简介
  2. pdf 显示
  3. PHP指定字段的多维数组排序方法
  4. MVC显示详细记录Without Entity Framework
  5. POJ1410 Intersection 计算几何
  6. 如何在eclipse中添加ADT
  7. Inception体验之安装
  8. 全局API
  9. hadoop之数据压缩与数据格式
  10. python smtp邮件
  11. html 手机web超出屏幕宽度的内容不换行,并产生横向滚动条
  12. Python语言的有限状态机实现样例
  13. linux-top命令查看内存CPU
  14. 一个基于NodeJS开发的APP管理CMS系统
  15. Codeforces Round #279 (Div. 2) C. Hacking Cypher 机智的前缀和处理
  16. How To Open An URL In Android’s Web Browser
  17. Xshell和SecureCRT等SSH下使用Tmux及Byobu(解决Byobu被statusline信息面板刷屏问题)
  18. 无生物学重复RNA-seq分析 CORNAS: coverage-dependent RNA-Seq analysis of gene expression data without biological replicates
  19. ES6 rest参数和扩展运算符
  20. python学习(二十六) 字典

热门文章

  1. UVA 11624 Fire!(广度优先搜索)
  2. mormot orm rest注意事项
  3. mormot json操作
  4. 清空form表单下所有的input值-------------jquery
  5. Silverlight 上传文件源代码
  6. 表A的数据减去表B ,最终得到表C
  7. Yii中事件触发机制
  8. 字符串和json之间的互相转化
  9. Windows 8.1 应用再出发 (WinJS) - 几种新增控件(1)
  10. linux知识点总结与随笔(关注linux爱好者公众号的一些笔记)