- xml 命名空间
- 使用命名空间来避免冲突
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="http://www.w3school.com.cn/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
- 使用默认的命名空间简化书写
对应上面的h 命名空间
<table xmlns="http://www.w3.org/TR/html4/">
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>
对应上面的f 命名空间
<table xmlns="http://www.w3school.com.cn/furniture">
<name>African Coffee Table</name>
<width>80</width>
<length>120</length>
</table>
- xsd(Xml Schema Definition)与 dtd(Document Type Definition)
-
xsd 和 dtd 的作用都是定义xml的合法构建模块,描述xml文档的结构
-
对dtd文件的引用:
<!DOCTYPE note SYSTEM "http://www.w3school.com.cn/dtd/note.dtd">
-
对xsd 文件的引用:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd">
说明:
xmlns=“http://www.springframework.org/schema/beans” 表示默认的命令空间,即没有前缀的标签都是这个命名空间中的标签
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” 与
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" 配合使用指定xsd文件的位置,其中命名空间与xsd文件位置紧跟,且一 一对应