看代码时经常碰到QName,当时对这个东东具体什么意思也是不太明白;今天在看SOAP消息的时候,想到这个东东,就去仔细看了下。QName其实就是Qualified Name的简称,在“NameSpaces in XML1.0(Third Edition)”(http://www.w3.org/TR/REC-xml-names/#ns-qualnames)中有如下这段话:

URI references can contain characters not allowed in names, and are often inconveniently long, so expanded names are not used directly to name elements and attributes in XML documents. Instead qualified names are used. [Definition: A qualified name is a name subject to namespace interpretation. ] In documents conforming to this specification, element and attribute names appear as qualified names. Syntactically, they are either prefixed names or unprefixed names.

同时文中对QName的定义如下:

In XML documents conforming to this specification, some names (constructs corresponding to the nonterminal Name) MUST be given as qualified names,defined as follows:

Qualified Name

[7]    QName    ::=    PrefixedName
      UnprefixedName
[8]    PrefixedName    ::=    Prefix ':' LocalPart
[9]    UnprefixedName    ::=    LocalPart
[10]    Prefix    ::=    NCName
[11]    LocalPart    ::=    NCName

The Prefix provides the namespace prefix part of the qualified name, and MUST be associated with a namespace URI reference in a namespace declaration. [Definition: The LocalPart provides the local part of the qualified name.]

Note that the prefix functions only as a placeholder for a namespace name. Applications SHOULD use the namespace name, not the prefix, in constructing names whose scope extends beyond the containing document.

In XML documents conforming to this specification, element names are given as qualified names;

Attributes are either namespace declarations or their names are given as qualified names.

也就是说QName分为两种,一种是带前缀的名字,另一种是不带前缀的。若是带前缀,则前缀必须和命名空间的URI引用相关联,如

<namespace-prefix:envelope xmlns:namespace-prefix="namespaceURI"> ... </namespace-prefix:envelope>,其中<namespace-prefix:envelope>就是QName;不带前缀,也就是说xml文件使用的默认命名空间,如<rootElement xmlns="namespaceURI"> ... </rootElement>,这里<rootElement>就是QName;在xml文件中,元素和属性都是用QName表示的;

如果应用程序在构造QName的时候,同时这个QName的范围超过了其被包含的xml文档,比如应用程序是Java或C#程序,那么在构造QName的时候就需要使用命名空间,而不是前缀,QName可以看做是一个包含了命名空间和local part的二元组,如(namespace, local name).

什么是QName的更多相关文章

  1. Java 异常 —— java.io.InvalidClassException: javax.xml.namespace.QName; local class incompatible

    项目中有个 WebService 接口,调试时使用 Main 方法运行,别人的机器上都能运行,就笔者的机器出问题.他们说是RP的问题…… 异常信息: java.io.InvalidClassExcep ...

  2. Qname

    Qname的全称是qualified name. Qname由三部分组成: 1.Namespace prefix 2.A colon character(":") 3.A loca ...

  3. gsoap入门:C/C++代码生成及编译--包含soapcpp2 -qname添加命名空间后报错的解决方法--可用

    gsoap是什么 先来一段百度百科,说说gsoap是什么: gSOAP一种跨平台的开源的C/C++软件开发工具包.生成C/C++的RPC代码,XML数据绑定,对SOAP Web服务和其他应用形成高效的 ...

  4. 解决 weblogic poi3.9 报错 a different type with name "javax/xml/namespace/QName"

    解决 java.lang.LinkageError: loader constraint violation: loader (instance of weblogic/utils/classload ...

  5. Weblogic 9.2 启动时报错 javax.xml.namespace.QName

    启动Weblogic 时会报错.javax.xml.namespace.QName; local class incompatible: stream classdesc serialVersionU ...

  6. Access restriction: The type QName is not accessible due to restriction on required library

    There's another solution that also works. I found it on this forum: Go to the Build Path settings in ...

  7. 前端学HTTP之重定向和负载均衡

    前面的话 HTTP并不是独自运行在网上的.很多协议都会在HTTP报文的传输过程中对其数据进行管理.HTTP只关心旅程的端点(发送者和接收者),但在包含有镜像服务器.Web代理和缓存的网络世界中,HTT ...

  8. Android之SAX解析XML

    一.SAX解析方法介绍 SAX(Simple API for XML)是一个解析速度快并且占用内存少的XML解析器,非常适合用于Android等移动设备. SAX解析器是一种基于事件的解析器,事件驱动 ...

  9. java调用CXF WebService接口的两种方式

    通过http://localhost:7002/card/services/HelloWorld?wsdl访问到xml如下,说明接口写对了. 2.静态调用 // 创建WebService客户端代理工厂 ...

随机推荐

  1. linux开机自动启动

    1 .vi /etc/rc.local 2.编写开机后运行的命令 如:service httpd start

  2. jqMobile中的dialog和popup的区别

    主要区别是:dialog默认含回退按钮.并且dialog在1.4版中已经过时,1.5中将会移除. 下面是 原文1: Using a Dialog Window as a Popup A jQuery ...

  3. springMvc请求的跳转和传值

    forword跳转页面的三种方式: 1.使用serlvet /** * 使用forward跳转,传递基本类型参数到页面 * 注意: * 1.使用servlet原生API Request作用域 * */ ...

  4. 写启动界面Splash的正确姿势,解决启动白屏(转)

    原文链接:http://www.jianshu.com/p/cd6ef8d3d74d 从我学习写第一个android项目以来,我都是这样写着启动界面: 在里面做一些事,比如:第一次启动时拷贝数据. 然 ...

  5. 在Ubuntu 14.04中安装最新版Eclipse

    1.下载eclipse从官网http://www.eclipse.org/downloads/下载Eclipse IDE for Java EE Developers的Linux版本eclipse-S ...

  6. android textview改变部分文字的颜色和string.xml中文字的替换(转)

    转   :http://blog.csdn.net/ljz2009y/article/details/23878669 一:TextView组件改变部分文字的颜色: TextView textView ...

  7. 【BZOJ 3052】【WC 2013】糖果公园

    对树的dfs序分块,打开了新世界的大门233 第一关键字是l所在的块,第二关键字是r所在的块,第三关键字是时间,分完块后暴力莫队即可 #include<cmath> #include< ...

  8. 如何在CentOS 5/6上安装EPEL源

    EPEL 是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/CentO ...

  9. IOS并发编程GCD

    iOS有三种多线程编程的技术 (一)NSThread  (二)Cocoa NSOperation (三)GCD(全称:Grand Central Dispatch) 这三种编程方式从上到下,抽象度层次 ...

  10. 三、基础功能模块,用户类别管理——锁、EF并发处理、领域服务、应用服务的划分

    在上一章节中,我们处理了MVC多级目录问题,参见<二.处理MVC多级目录问题——以ABP为基础架构的一个中等规模的OA开发日志>.从这章开始,我们将进入正式的开发过程.首先,我们要完成系统 ...