ITeye博客

xml schema写法

major361 · 2008-03-18 18:01 · Markdown

1.把xml文件和schema文件关联起来

1)和本地的shema关联

<rootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:noNamespaceSchemaLocation="xxx.xsd">
或者xsi:noNamespaceSchemaLocation="file:///文件的路径">

2)第二种关联的方法 在xsd文件中定义如下:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://localhost">

在xml文件中定义如下

<rootElement
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://localhost"
	xsi:schemaLocation="http://localhost planes.xsd">
<!--schemaLocation以命名空间开始然后接一个空格 再跟xsd文件名,可以多个-->

2.当elementFormDefault="unqualified" 表示全局元素和类型归于目标命名空间,而局部元素归于无名的命名空间 当elementFormDefault="qualified" 表示全局元素和类型,以及局部元素都归于目标命名空间

3.attributeFormDefault="qualified" 表示属性值归于目标命名空间 当attributeFormDefault="unqualified"时表示属性值归于拥有属性的元素??对吗??

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。