Qname
来源:互联网 发布:淘宝api调用实例php 编辑:程序博客网 时间:2024/05/22 14:30
Qname这个东东,在使用dom4j的时候,经常见到,可能是自己解析的xml都太简单了,所以没有仔细研究过,就是觉得名字很怪异,在google百度搜索“什么是qname”,居然只有几条没有像样答案的纪录。还好,在国外网站上找到了相关的解释,这下基本明白了。
1.来历:qname是qualified name 的简写
2.构成:由名字空间(namespace)前缀(prefix)以及冒号(:),还有一个元素名称构成
3.举例:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
version="1.0">
<xsl:template match="foo">
<hr/>
</xsl:template>
</xsl:stylesheet>
xsl是名字空间前缀,template是元素名称,xsl:template 就是一个qname
4.总结:qname无非是有着特定格式的xml元素,其作用主要是增加了名字空间,比如有同样的元素名称,而名字空间不同的情况。先了解这么多,请大家补充。
参考地址:
http://infohost.nmt.edu/tcc/help/pubs/pyxml/def-qname.html
原文如下:
A document may contain elements and attributes from more than one namespace URI. Because namespace URIs can be quite lengthy, it is cumbersome to include the complete namespace URI in each element or attribute name.
XML allows a shorthand notation to simplify assigning names to namespaces. You may invent a shortnamespace prefix and associate it with a namespace URI.
For example, suppose your document contains names from both the XSLT and XHTML namespaces. In this situation, it is customary to associate the namespace prefix “xsl
” with XSLT. You might use prefix “html
” to refer to the XHTML namespace.
A qualified name has three parts:
A namespace prefix.
A colon character, “
:
”.A local name that gives the name of the element or attribute within that namespace.
For example, here is a fragment illustrating the use of qualified names:
<xsl:template match="separator"> <html:hr/></xsl:template>
Element template
is in the XSLT namespace, and elementhr
is in the HTML namespace.
You can also use an unqualified name, which is just a local name without the namespace prefix. The namespace of such a name is called thedefault namespace.
The association between a namespace prefix and a namespace URI is made with anxmlns
attribute located in some element. This attribute can have two forms:
An attribute named
xmlns='
defines the namespace URI of the default namespace. This namespace is associated with all elements and attributes that have unqualified names.nsURI
'An attribute named
xmlns:
associates the givenprefix
='nsURI
'prefix
with the namespace URInsURI
.
Here is an example of a complete document using elements from two namespaces:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" version="1.0"> <xsl:template match="foo"> <hr/> </xsl:template></xsl:stylesheet>
In this example, the template
element is in the XSLT namespace. Thehr
element is in the default namespace, which is associated with the XHTML namespace URI.
- qname
- QName
- QName
- qname
- Qname
- 什么是QName
- 什么是QName
- 什么是QName
- 了解QName
- 什么是QName
- 什么是QName
- 什么是QName
- QName是什么
- 什么是QName
- 什么是QName
- 什么是Qname
- QName【转】
- Dom4J qname
- (2.3.6)java变量的初始化之后的默认值
- 使用java进行文件编码转换
- JAVA操作properties文件
- IE6、 IE7、IE8、IE9、Firefox兼容性问题
- ECU软件开发介绍篇
- Qname
- HTML5可互动的可视化图表js插件库
- c#对XML文件的生成-修改-添加-删除-读取等操作
- FileZilla Server的安装和设置
- 第二章第七题
- python 快速建立 HTTP Server 共享文件
- 1.自定义checkbox 2.根据checkbox让密码显示与隐藏
- OpenCV成长之路(10):视频的处理
- 【c语言】从键盘输入一个小于1000的正数,输出它的平方根(若平方根不是整数,则输出它的整数部分)