QNAME is often seen when using dom4j. It may be that the XML parsed by myself is too simple, so I haven't studied it carefully, but I think the name is weird, in Google Baidu's search for "What Is QNAME", there are only a few records with no decent answers. Fortunately, I have found some explanations on foreign websites, and I understand it.
1. Origin: QNAME isQualified nameShort
2. Structure: it consists of a namespace prefix, a colon (:), and an element name.
3. Example:
<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 is the namespace prefix, template is the element name, and XSL: Template is a QNAME
4. Conclusion: QNAME is nothing more than an XML element with a specific format. Its function is to increase the namespace. For example, if the same element name exists, the namespace is different. I have learned so much about it. Please add it.
Reference address:
Http://infohost.nmt.edu/tcc/help/pubs/pyxml/def-qname.html
The original article is as follows:
A document may contain in 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 prefixAnd 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.
AQualified nameHas three parts:
A namespace prefix.
A colon character,":
".
ALocal nameThat gives the name of the element or attribute within that namespace.
For example, here is a fragment authentication strating the use of qualified names:
<xsl:template match="separator">
</xsl:template>
Elementtemplate
Is in the XSLT namespace, and Elementhr
Is in the HTML namespace.
You can also useUnqualified name, Which is just a local name without the namespace prefix. The namespace of such a name is calledDefault namespace.
The association between a namespace prefix and a namespace URI is made withxmlns
Attribute located in some element. This attribute can have two forms:
An Attribute namedxmlns='nsURI
'
Defines the namespace URI of the default namespace. This namespace is associated with all elements and attributes that have unqualified names.
An Attribute namedxmlns:prefix
='nsURI
'
Associates the givenprefix
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">
</xsl:template>
</xsl:stylesheet>
In this example,template
Element is in the XSLT namespace.hr
Element is in the default namespace, which is associated with the XHTML namespace URI.
QNAME is often seen when using dom4j. It may be that the XML parsed by myself is too simple, so I haven't studied it carefully, but I think the name is weird, in Google Baidu's search for "What Is QNAME", there are only a few records with no decent answers. Fortunately, I have found some explanations on foreign websites, and I understand it.
1. Origin: QNAME isQualified nameShort
2. Structure: it consists of a namespace prefix, a colon (:), and an element name.
3. Example:
<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 is the namespace prefix, template is the element name, and XSL: Template is a QNAME
4. Conclusion: QNAME is nothing more than an XML element with a specific format. Its function is to increase the namespace. For example, if the same element name exists, the namespace is different. I have learned so much about it. Please add it.
Reference address:
Http://infohost.nmt.edu/tcc/help/pubs/pyxml/def-qname.html
The original article is as follows:
A document may contain in 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 prefixAnd 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.
AQualified nameHas three parts:
A namespace prefix.
A colon character,":
".
ALocal nameThat gives the name of the element or attribute within that namespace.
For example, here is a fragment authentication strating the use of qualified names:
<xsl:template match="separator">
</xsl:template>
Elementtemplate
Is in the XSLT namespace, and Elementhr
Is in the HTML namespace.
You can also useUnqualified name, Which is just a local name without the namespace prefix. The namespace of such a name is calledDefault namespace.
The association between a namespace prefix and a namespace URI is made withxmlns
Attribute located in some element. This attribute can have two forms:
An Attribute namedxmlns='nsURI
'
Defines the namespace URI of the default namespace. This namespace is associated with all elements and attributes that have unqualified names.
An Attribute namedxmlns:prefix
='nsURI
'
Associates the givenprefix
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">
</xsl:template>
</xsl:stylesheet>
In this example,template
Element is in the XSLT namespace.hr
Element is in the default namespace, which is associated with the XHTML namespace URI.