xml與xml schema命名空間學習
阿新 • • 發佈:2017-05-19
col mes mon efault element body form names ext
首先,xml與xml schema(xsd)文件都是xml格式的文件,都遵循相同的命名空間規則
在schema元素中通過xmlns指定約束文件位置
如下面的xsd文件中的代碼
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/athena"
elementFormDefault="qualified">
<element name="body">
<complexType>
<sequence>
<element name="id" type="int"/>
<element name="name" type="string"/>
<element name="birthday" type="dateTime"/>
</sequence>
</complexType>
</element>
</schema>
通過xmlns指定xsd文件的約束文件位置
當一個文件中需要指定多個約束文件時,
通過xmlns:name區分不同約束文件中的元素,
只能有一個xmlns(不指定name),在調用元素的時候無需在元素前面加上名稱空間
xml與xml schema命名空間學習