xml中的xmlns,xmlns:xsi,xsi:schemaLocation有什么作用,如果没有会怎么样呢

雨雪飘零 2014-04-04 09:15:11
如 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">
...全文
43848 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianyue911x 2016-12-16
  • 打赏
  • 举报
回复
天天见却到现在才注意到 ,看来还要多学习多发现呀
橙色阳光 2016-07-07
  • 打赏
  • 举报
回复
yonghua 2015-08-06
  • 打赏
  • 举报
回复
引用 11 楼 limenghua9112 的回复:
原来如此,天天看这些个文件,自己竟然不知道这些个属性是干嘛用的,忏愧啊
忏愧啊,汗。。。。
快乐柠檬 2015-06-24
  • 打赏
  • 举报
回复
原来如此,天天看这些个文件,自己竟然不知道这些个属性是干嘛用的,忏愧啊
iceman1952 2015-05-10
  • 打赏
  • 举报
回复
引用 8 楼 Lee_jaedong 的回复:
我来给你解释一下吧,首先这个文件是一个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"/>。
解释的很清楚
meiyounini 2015-04-19
  • 打赏
  • 举报
回复
顶楼上,专业。
DreamRoute 2015-01-28
  • 打赏
  • 举报
回复
我来给你解释一下吧,首先这个文件是一个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"/>。
a8511007 2015-01-12
  • 打赏
  • 举报
回复
xsi全名:xml schema instance web-app是web.xml的根节点标签名称 version是版本的意思 xmlns是web.xml文件用到的命名空间 xmlns:xsi是指web.xml遵守xml规范 xsi:schemaLocation是指具体用到的schema资源
xie_zhr 2014-09-20
  • 打赏
  • 举报
回复
在XML中,用xmlns或者xmlns:prefix指定命名空间,命名空间不是什么高深的知识,起作用只是表示一个元素的范围,在一份XML文档中可能有多个元素相同,这时XMLns就显得非常重要了。
FlyBird2004 2014-07-09
  • 打赏
  • 举报
回复
类似于代码中的包民.类名 xml中的命名空间也是如此。引用时,命名空间.元素 使用一些特殊的属性设置可以省略命名空间(此时,命名空间是默认的)。
huagaisheng 2014-07-04
  • 打赏
  • 举报
回复
<project xmlns="http://maven.apache.org/POM/4.0.0" --命名空间,类似包名,因为xml的标签可自定义,需要命名空间来区分 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" --xml遵循的标签规范 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> --用来定义xmlschema的地址,也就是xml书写时需要遵循的语法,两部分组成,前面部分就是命名空间的名字,后面是xsd(xmlschema)的地址
雨雪飘零 2014-04-06
  • 打赏
  • 举报
回复
还有人回复吗
teemai 2014-04-04
  • 打赏
  • 举报
回复
类似DTD,你可以打开url看看里面是什么 如xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://maven.apache.org/POM/4.0.0" elementFormDefault="qualified" targetNamespace="http://maven.apache.org/POM/4.0.0">
<xs:element name="project" type="Model">
<xs:annotation>
<xs:documentation source="version">3.0.0+</xs:documentation>
<xs:documentation source="description">
The <code><project></code> element is the root of the descriptor. The following table lists all of the possible child elements.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="Model">
<xs:annotation>
<xs:documentation source="version">3.0.0+</xs:documentation>
<xs:documentation source="description">
The <code><project></code> element is the root of the descriptor. The following table lists all of the possible child elements.
</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="parent" minOccurs="0" type="Parent">
<xs:annotation>
<xs:documentation source="version">4.0.0</xs:documentation>
<xs:documentation source="description">
The location of the parent project, if one exists. Values from the parent project will be the default for this project if they are left unspecified. The location is given as a group ID, artifact ID and version.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="modelVersion" minOccurs="0" type="xs:string">
<xs:annotation>
<xs:documentation source="version">4.0.0</xs:documentation>
<xs:documentation source="description">
Declares to which version of project descriptor this POM conforms.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="groupId" minOccurs="0" type="xs:string">
<xs:annotation>
<xs:documentation source="version">3.0.0+</xs:documentation>
<xs:documentation source="description">
A universally unique identifier for a project. It is normal to use a fully-qualified package name to distinguish it from other projects with a similar name (eg. <code>org.apache.maven</code>).
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="artifactId" minOccurs="0" type="xs:string">
<xs:annotation>
<xs:documentation source="version">3.0.0+</xs:documentation>
<xs:documentation source="description">
The identifier for this artifact that is unique within the group given by the group ID. An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="packaging" minOccurs="0" type="xs:string" default="jar">
<xs:annotation>
<xs:documentation source="version">4.0.0</xs:documentation>
<xs:documentation source="description">
The type of artifact this project produces, for example <code>jar</code> <code>war</code> <code>ear</code> <code>pom</code>. Plugins can create their own packaging, and therefore their own packaging types, so this list does not contain all possible types.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="name" minOccurs="0" type="xs:string">
<xs:annotation>
<xs:documentation s...

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧