javax.xml.namespace.QName
2013-03-25 11:44
459 查看
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元素,其作用主要是增加了名字空间,比如有同样的元素名称,而名字空间不同的情况。
自己测试:
仔细看下下面的东西: 我也是耐心了看了几遍才懂的。。。
be given as
qualified names, defined as follows:
Qualified Name
The Prefix provides thenamespace prefix part of the qualified name, andMUST
be associated with a namespace URI reference in a
namespace declaration. [Definition: TheLocalPart provides thelocal part of the qualified name.]
Note that the prefix functions only as a placeholder for a namespace name. ApplicationsSHOULD use the namespace name, not the prefix, in constructing names
whose scope extends beyond the containing document.
Element Names
An example of a qualified name serving as an element name:
Attributes are either namespace declarations or their names are given asqualified
names:
Attribute
An example of a qualified name serving as an attribute name:
JDK api文档里的跳转页面也有这些上面的资料 可以做去查下。。。。
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元素,其作用主要是增加了名字空间,比如有同样的元素名称,而名字空间不同的情况。
自己测试:
// 指定名称空间 URI 和本地部分的 QName 构造方法。 // QName qn=new javax.xml.namespace.QName("http://tempuri.org/", "resultXML"); //指定名称空间 URI、本地部分和前缀的 QName 构造方法。 // QName qn=new javax.xml.namespace.QName("http://tempuri.org/", "resultXML","/"); //指定本地部分的 QName 构造方法。 QName qn=new javax.xml.namespace.QName("resultXML"); System.out.println("LocalPart:"+qn.getLocalPart()); System.out.println("Prefix:"+qn.getPrefix()); System.out.println("NameSapceUri:"+qn.getNamespaceURI());
仔细看下下面的东西: 我也是耐心了看了几遍才懂的。。。
4 Qualified Names
In XML documents conforming to this specification, some names (constructs corresponding to the nonterminalName)MUSTbe 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 |
be associated with a namespace URI reference in a
namespace declaration. [Definition: TheLocalPart provides thelocal part of the qualified name.]
Note that the prefix functions only as a placeholder for a namespace name. ApplicationsSHOULD use the namespace name, not the prefix, in constructing names
whose scope extends beyond the containing document.
5 Using Qualified Names
In XML documents conforming to this specification, element names are given asqualified names, as follows:Element Names
[12] | STag | ::= | '<' QName (SAttribute)*S? '>' | [NSC: Prefix Declared] |
[13] | ETag | ::= | '</' QName S? '>' | [NSC: Prefix Declared] |
[14] | EmptyElemTag | ::= | '<' QName (SAttribute)*S? '/>' | [NSC: Prefix Declared] |
<!-- the 'price' element's namespace is http://ecommerce.example.org/schema --> <edi:price xmlns:edi='http://ecommerce.example.org/schema' units='Euro'>32.18</edi:price>
Attributes are either namespace declarations or their names are given asqualified
names:
Attribute
[15] | Attribute | ::= | NSAttNameEqAttValue | |
| QName Eq AttValue | [NSC: Prefix Declared] | |||
[NSC: No Prefix Undeclaring] | ||||
[NSC: Attributes Unique] |
<x xmlns:edi='http://ecommerce.example.org/schema'> <!-- the 'taxClass' attribute's namespace is http://ecommerce.example.org/schema --> <lineItem edi:taxClass="exempt">Baby food</lineItem> </x>
JDK api文档里的跳转页面也有这些上面的资料 可以做去查下。。。。
相关文章推荐
- Axis: rt.jar和jaxrpc中javax.xml.namespace.QName冲突问题分析
- [转载]javax.xml.namespace.QName是什么
- javax.xml.namespace.QName
- Java 异常 —— java.io.InvalidClassException: javax.xml.namespace.QName; local class incompatible
- Weblogic 9.2 启动时报错 javax.xml.namespace.QName
- symbol:constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature
- weblogic启动异常:Parsing Failure in config.xml: javax.xml.namespace.QName; local class incompatible
- weblogic javax/xml/namespace/QName报错
- javax.xml.namespace.QName
- javax.xml.namespace.QName 解释以及作用JDK
- android studio错误解决finished with non-zero exit value 1 【javax/xml/namespace/QName.class】
- javax.xml.ws.Service 报错The constructor Service(URL, QName, WebServiceFeature[]) is undefined的解决方案
- javax.xml.ws.Service 报错The constructor Service(URL, QName, WebServiceFeature[]) is undefined的解决方案
- javax.xml.ws.Service 报错The constructor Service(URL, QName, WebServiceFeature[]) is undefined的解决方案
- javax.xml.namespace.QName类的用法
- JDOM处理带Namespace的XML文件
- javax.xml.ws.soap.SOAPFaultException: 没有Header,拦截器实施拦截
- Linq To Xml 备忘录3(使用Namespace的查询)
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- PHP - XML - Filtering XML Nodes by Namespace