2.5
<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"
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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
......
</beans>
3.0
<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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
......
</beans>
Spring3中的xsd文件的位置:
org.springframework.beans.factory.xml包下
同目录下还有Srping-beans.dtd Srping-beans-2.0.dtd
Srping-beans-2.0.xsd Srping-beans-2.5.xsd Srping-beans-3.0.xsd
Srping-tool-2.0.xsd Srping-tool-2.5.xsd Srping-tool-3.0.xsd
Srping-util-2.0.xsd Srping-util-2.5.xsd Srping-util-3.0.xsd
org.springframework.aop.config.包下
有Srping-aop-2.0.xsd Srping-aop-2.5.xsd Srping-aop-3.0.xsd
org.springframework.jdbc.config 包下Srping-jdbc-3.0.xsd
org.springframework.transaction.config.包下
有Srping-tx-2.0.xsd Srping-tx-2.5.xsd Srping-tx-3.0.xsd
org.springframework.context.config包下
有 Srping-context-2.5.xsd Srping-context-3.0.xsd
添加xsd到本地:window - preferences - Myeclipse enterprise - Files and Editors - xml - xml catalog - Add
然后key type选url,然后在location里导入导入
另xsd文件
参考From:http://wenku.baidu.com/view/3b9ff43a580216fc700afd1a.html
一、xmlns="http://www.springframework.org/schema/beans" 定义当前文档的默认的命名空间.
二、xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 定义命名空间,xsi这个命名空间是w3c定义的,使用它的原因 是下面"xsi:schemaLocation=" 中的schemaLocation属性是在http://www.w3.org/2001/XMLSchema-instance中定义的,所以要使用这个属性,就得引入它所在的命名空间.
三、xsi:schemaLocation=" schemaLocation属性的作用是用于指定名称空间所对应的XMLSchema模式文档在中里.这个属性在前面定义的xsi名称空间中,所以必须在前面加上表示其名称空间的前缀。设置值包括二部分:a)命名空间的URI;b)名称空间所标识的XML Schema文件的位置或者URL地址,这二个部分使用空格分隔。
EG:http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
XSD是指XML结构定义 ( XML Schemas Definition )
(From:http://zhidao.baidu.com/question/74740740.html ):
XML Schema 是DTD的替代品。XML Schema语言也就是XSD。
XML Schema描述了XML文档的结构。可以用一个指定的XML Schema来验证某个XML文档,以检查该XML文档是否符合其要求。文档设计者可以通过XML Schema指定一个XML文档所允许的结构和内容,并可据此检查一个XML文档是否是有效的。XML Schema本身是一个XML文档,它符合XML语法结构。可以用通用的XML解析器解析它。
一个XML Schema会定义:文档中出现的元素、文档中出现的属性、子元素、子元素的数量、子元素的顺序、元素是否为空、元素和属性的数据类型、元素或属性的默认和固定值。
XSD是DTD替代者的原因,一是据将来的条件可扩展,二是比DTD丰富和有用,三是用XML书写,四是支持数据类型,五是支持命名空间。
XSD文件的后缀名为.xsd。
XML Schema的优点:
1) XML Schema基于XML,没有专门的语法
2) XML可以象其他XML文件一样解析和处理
3) XML Schema支持一系列的数据类型(int、float、Boolean、date等)
4) XML Schema提供可扩充的数据模型。
5) XML Schema支持综合命名空间
6) XML Schema支持属性组。
Xsd可参考:http://bdk82924.iteye.com/blog/721443