XML是文本文件,在该类型的文件中,使用类似HTML标记的自定义标记来组织数据。
由于XML文件的标记是自定义标记,一个标记,可以带属性/子标记,也可以不带属性/子标记,标记的的属性、子标记内的数据,可以是各种类型,这就给XML的解析带来麻烦,因此通常XML文档都需要有约束文档,用来对内部的数据类型与其结构进行明确规定,以方便程序解析处理。
XML的约束文档通常有两种:xsd文件和dtd文件(你写的tdt有点象TNT:)
这两种文件的区别在于语法不同和可约束的项目范围不同。xsd较dtd,约束范围更广,语法也自然复杂一些。
一个xml文件可以引用多个约束文件。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
xmlns=http://www.springframework.org/schema/beans :不以任何字符开头的都采用该路径的规范
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance : 以xsl开头的采用该路径的规范
http://www.springframework.org/schema/context/spring-context-2.5.xsd 是一个Key,通过这个Key在xml-catalog中匹配相应的Key找到相应的xsd文件。