XML常用标签的介绍
觉醒任务 2026-08-02 05:25:48
xsi:noNamespaceSchemaLocation="country.xsd">
(3)xmlns(XML Namespaces):即XML的命名空间,因为XML文件的标签名称都是自定义的,自己写的和其他人定义的标签很有可能会重命的现象,所以用namespace来区分这个xml文件和其他的xml文件,类似于java中的package。
(4)xsi(xml schema instance):是指xml文件遵守xml规范,是指具体用到的schema资源文件里定义的元素所准守的规范。例如:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
上面的例子定义了一个Schema的实例命名空间。只有作了这个定义才能使用schemaLocation属性。xsi:schemaLocation是指具体用到的schema资源
xsi:schemaLocation= "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
schemaLocation属性由成对的值组成,可以有多对。因为一个XML文档可以有多个命名空间,所以schemaLocation值可以有多对。第一个"http://www.springframework.org/schema/beans"是要使用schema进行有效验证的命名空间的元素。而"http://www.springframework.org/schema/beans/spring-beans.xsd"是要使用的schema文档的路径。
3、XML实例
XML实例如下所示:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> .....
在上面的实例中,可知beans是该XML文件的根节点标签名称。xmlns:util是指命名空间util,util命名空间的Xsi(XML schema instance)的地址为"http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"。