最近学xml 遇到了点小问题qaq 找了n多的博客大佬,反复看了半小时终于明白了,可能我太蠢了。。。

基础的知识就不赘述,直接放“栗子”,切重点:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:lzh="http://info.school.edu.cn" targetNamespace="http://info.school.edu.cn" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="schools">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="school" maxOccurs="10">
<xs:complexType>
<xs:sequence>
<xs:element name="sch_name" type="xs:string"/>
<xs:element name="sch_level">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="一本"/>
<xs:enumeration value="二本"/>
<xs:enumeration value="大专"/>
<xs:enumeration value="中专"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="sch_location" type="xs:string"/>
<xs:element name="area">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="6"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="principal_name" type="xs:string"/>
</xs:sequence>
<xs:attribute name="create_time">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{4}-[0-1][0-9]-[0-3][0-9]"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="country" default="中国"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<lzh:schools xmlns:lzh="http://info.school.edu.cn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://info.school.edu.cn file:///C:/Users/del/Desktop/lzh.xsd">
<lzh:school create_time="1985-01-02">
<lzh:sch_name>淮海工学院</lzh:sch_name>
<lzh:sch_level>二本</lzh:sch_level>
<lzh:sch_location>连云港市</lzh:sch_location>
<lzh:area>2162.78</lzh:area>
<lzh:principal_name>宁晓明</lzh:principal_name>
</lzh:school>
<lzh:school>
<lzh:sch_name>清华大学</lzh:sch_name>
<lzh:sch_level>一本</lzh:sch_level>
<lzh:sch_location>北京市</lzh:sch_location>
<lzh:area>392.4</lzh:area>
<lzh:principal_name>邱勇</lzh:principal_name>
</lzh:school>
</lzh:schools>

首先知道,targetNameSpace。targetNamespace定义了Schema定义的新元素与属性的名称空间。而"http://www.w3.org/2001/XMLSchema"名称空间则定义了element, attribute, complexType, group, simpleType等元素。若自身并不使用重用组件,仅供外部使用的话,则只定义targetNameSpace就可以,不用指定别名。

然后呢,xmlns:lzh="http://info.school.edu.cn" targetNamespace="http://info.school.edu.cn" 这里的URI是一样的,因为xmlns:后的lzh是一个别名一个命名空间的前缀,方便下面的element在遇到elementFormDefault="qualified"的情况下的使用。

over~好久没写博客,快要去上课了就先酱紫吧emmm~

XML 之 命名空间详解的更多相关文章

  1. 史上最全的maven pom.xml文件教程详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  2. crossdomain.xml的配置详解

    目录 1 简介 2 crossdomain.xml的配置详解 3 总结 1 简介 flash在跨域时唯一的限制策略就是crossdomain.xml文件,该文件限制了flash是否可以跨域读写数据以及 ...

  3. logback logback.xml常用配置详解(三)

    logback logback.xml常用配置详解 <filter> <filter>: 过滤器,执行一个过滤器会有返回个枚举值,即DENY,NEUTRAL,ACCEPT其中之 ...

  4. logback logback.xml常用配置详解(一)<configuration> and <logger>

    logback logback.xml常用配置详解(一)<configuration> and <logger> 博客分类: Log java loglogback  原创文章 ...

  5. ssh2的application.xml配置文件配置详解

    ssh2的application.xml配置文件配置详解   1.导入其他的配置文件.在ssh项目中可以导入其他的配置文件,导入的格式为: <import resource="clas ...

  6. linux命名空间详解_转

    转自: Linux的命名空间详解--Linux进程的管理与调度(二) Linux Namespaces机制提供一种资源隔离方案. PID,IPC,Network等系统资源不再是全局性的,而是属于特定的 ...

  7. [转] logback logback.xml常用配置详解(一)<configuration> and <logger>

    转载文章:原文出处:http://aub.iteye.com/blog/1101260 详细整理了logback常用配置, 不是官网手册的翻译版,而是使用总结,旨在更快更透彻的理解其配置 根节点< ...

  8. res文件夹及xml资源文件详解

    目录 一.values文件:存放字符串(strings).颜色(colors).尺寸(dimens).数组(arrays).样式(styles类似于CSS文件).类型等资源 二.drawable:存放 ...

  9. web.xml常用配置详解

    web.xml常用配置详解 context-param 指定 ServletContext(上下文) 配置文件路径,基本配置一般是Spring配置文件,或者是spring-security的配置文件. ...

随机推荐

  1. 什么是Capability

    desired capability的功能是配置Appium会话.他们告诉Appium服务器您想要自动化的平台和应用程序. Desired Capabilities是一组设置的键值对的集合,其中键对应 ...

  2. Pyhton高级-Socket

    1,UDP实现收发数据 import socket def send_msg(udp_socket): """获取键盘数据,并将其发送给对方""&qu ...

  3. 使用GitHub代码仓库Repositories上传自己的项目代码

    1.下载客户端github(必须下载,需要该软件所提供的Git shell输入命令来上传项目)下载地址: https://github-windows.s3.amazonaws.com/GitHubS ...

  4. 第一个GTK程序

    /*我已经把代码写在此处  希望借鉴和完善!一起加油奥(PS:我的QQ是1693672542欢迎加我一起进行探讨学习奥!!!)*/#include <stdio.h>#include< ...

  5. 论文WAN Optimized Replication of Backup Datasets Using Stream-Informed Delta Compression

         这是EMC的备份小组发表在FAST12上的论文,主要是结合重删和差量数据压缩的方法,达到更高的数据压缩率.并且作者使用了一种基于数据流的差量数据压缩,消除了对索引的需求.通过测试达到的压缩效 ...

  6. 洛谷 P1560 [USACO5.2]蜗牛的旅行Snail Trails(不明原因的scanf错误)

    P1560 [USACO5.2]蜗牛的旅行Snail Trails 题目描述 萨丽·斯内尔(Sally Snail,蜗牛)喜欢在N x N 的棋盘上闲逛(1 < n <= 120). 她总 ...

  7. Spring @async 方法上添加该注解实现异步调用的原理

    Spring @async 方法上添加该注解实现异步调用的原理 学习了:https://www.cnblogs.com/shangxiaofei/p/6211367.html 使用异步方法进行方法调用 ...

  8. Objective-C学习笔记(二十二)——初始化方法init的重写与自己定义

    初学OC.对init这种方法不是非常了解.我们如今来分别对init方法进行重写以及自己定义,来加深对他的了解. 本样例也是用Person类来进行測试. (一)重写init方法. (1)在Person. ...

  9. Linux 端口 为什么要有端口

    ip能锁定一台物理机器,对应着一张网卡,外界发来的数据包网卡都会接收.但是问题来了,网卡给程序提供了接口,你监听一下我,要是有消息来了,我就转发给你.这样应用程序就能收到数据了.但是问题来了,程序A和 ...

  10. badboy提示脚本错误解决方法

    1.输入URL,提示脚本错误 解决办法:打开IE浏览器,工具->internet选项->高级,如图所示去掉禁用脚本调试 2.badboy内置浏览器,提示脚本错误解决办法 解决办法:badb ...