美文网首页
Schema(补充)

Schema(补充)

作者: 邹小月 | 来源:发表于2017-06-19 17:30 被阅读11次

一.Schema简介

Schema是新的XML文档约束;

Schema本事就是一个XML文档,但它的扩展名是xsd,而不是XML。

二.名称空间

名称空间类似于JAVA中的包,它可以唯一标识一个元素或属性

(1).指定目标名称空间

指定当前xsd文件中定义的元素、属性、类型,都在这个 名称空间中。

targetNameLocation="http://www.itcast.cn/xml"

(2).在xml中,关联xsd文件

schemaLocation="目标名称空间  xsd文件路径"

<students schemaLocation="http://www.itcast.cn/xml" students.xsd

                                              http://www.edu.cn/xml" edu.xsd>

</students>

ps:可以关联多个名称空间

(3).在xml中,指定名称空间前缀(定义名称空间)

xml定义名称空间   xmlns:"前缀"=“目标名称空间”

xml定义默认名称空间  xmlns:="目标名称空间"

xmlns是特殊的属性但是schemaLocation不是特殊属性,它没有指定前缀,它是W3C提供的。

<students xmlns:it="http://www.itcast.cn/xml"

               xmlns="http://www.edu.cn/xml"

               xmlns:xsi="http://www.w3.org/2001/XML Schema-instance" 

        xsi: schemaLocation="http://www.itcast.cn/xml student.xsd

                                      http://www,edu.cn/xml edu.xsd">

   <it:student>

       <name>zhangsan</as:name>

</it:student>

</students>

相关文章

网友评论

      本文标题:Schema(补充)

      本文链接:https://www.haomeiwen.com/subject/vtpgqxtx.html