xml中的xmlns,xmlns:xsi,xsi:schemaLocation有什么作用
2018-02-06 00:14
281 查看
xml中的xmlns,xmlns:xsi,xsi:schemaLocation有什么作用,如果没有会怎么样呢
如 maven 的 pom.xml 开头是下面这样的谁能解释下,这东西有社么用,不写这东西又会怎么样的,官方拷贝来的说明文档就算了,我想要简明扼要的说明。
不胜感激
---------
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
回答:
我来给你解释一下吧,首先这个文件是一个xml文件,那么他里面的所有内容都符合xml语法规范,开头 的<project></project>这最外层同样也是一个xml文件的标签,后面那一长串也就是所谓的属性,其中 xmlns表示命名空间,xmlns="http://maven.apache.org/POM/4.0.0" 这表示默认命名空间,而下面 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 这个命名空间里面的元素或者属性就必须 要以xsi:这种方式来写,比如schemaLocation就是他的一个属性,所以写成xsi:schemaLocation,而默认命名空间不带类似
xsi这种,其实xml标签名称有个专业叫法叫做QName,而如果没有前面的xsi:这种一般叫做NCName。所以你看mvn里面 的<dependency>这种就是默认命名空间下面的元素,最后那一行就表示把定义这个命名空间的schema文件给引用进来,好让 eclipse这类型工具能够解析和验证你的xml文件是否符合语法规范。等同 于<import namespace="xxx" schemaLocation="xxx.xsd"/>。
相关文章推荐
- xml中的xmlns,xmlns:xsi,xsi:schemaLocation有什么作用,如果没有会怎么样呢
- xml中的xmlns,xmlns:xsi,xsi:schemaLocation有什么作用,如果没有会怎么样呢
- XML文档中的xmlns、xmlns:xsi和xsi:schemaLocation
- XML文档的xmlns、xmlns xsi和xsi schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- XML文档中的xmlns、xmlns:xsi和xsi:schemaLocation理解
- XML——xmlns、xmlns:xsi和xsi:schemaLocation
- XML文档中的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- XML文档中的xmlns、xmlns:xsi和xsi:schemaLocation
- web.xml开头<web-app>中的xmlns、xsi、schemaLocation、xsd等,命名空间
- XML文档的xmlns、xmlns:xsi和xsi:schemaLocation介绍
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- xml文件参照XSD时开始部分中的xmlns:和xsi:schemaLocation