xml是按一定格式来存储数据的文件,将xml看为数据库,xml中元素看为存储数据的表,dtd文件与xml schema文件看为对表结构的定义。
dtd,document type definition,以类似<!DOCTYPE 根元素 [<!ELEMENT ..> ..}>
的方式定义结构,不推荐使用。
xml schema,有着严谨的结构合丰富的功能,推荐使用的方式。
html标签是严格定义好的,xml标签是自定义的,不同的人定义的标签,在同一个xml文件内共享可能会存在冲突,就出现了xmlns,xhtml namespace
<beans
// beans标签schema文件的命名空间,没有指定空间别名,表示可直接使用beans标签的内容
xmlns="http://www.springframework.org/schema/beans"
// aop标签schema文件的命名空间,空间别名aop,表示使用aop标签的内容时,要加前缀aop,如aop:xx
xmlns:aop="http://www.springframework.org/schema/aop"
// xsi标签schema文件的命名空间,空间别名xsi,该标签规定了xml标签遵循的规范
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
// xmlns:xx仅指定schema文件命名空间的别名,类似包名
// xsi:schemaLocation指定schema文件的具体位置,类似包下的类
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
....
</beans>