QName
   HOME

TheInfoList



OR:

A QName, or qualified name, is the fully qualified name of an element, attribute, or identifier in an
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
document. A QName concisely associates the URI of an
XML namespace XML namespaces are used for providing uniquely named elements and attributes in an XML document. They are defined in a W3C recommendation. An XML instance may contain element or attribute names from more than one XML vocabulary. If each vocabulary ...
with the ''local name'' of an element, attribute, or identifier in that namespace. To make this association, the QName assigns the local name a ''prefix'' that corresponds to its namespace. In all, the QName comprises the URI of the XML namespace, the ''prefix'', and the ''local name''. The
World Wide Web Consortium The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working together in ...
introduced the QName convention in the 1999
specification A specification often refers to a set of documented requirements to be satisfied by a material, design, product, or service. A specification is often a type of technical standard. There are different types of technical or engineering specificati ...
"Namespaces in XML".


Purpose

Since URI references can be long and may contain prohibited characters for element/attribute naming, QNames are used to create a mapping between the URI and a namespace prefix. The mapping enables the abbreviation of URIs, therefore it achieves a more convenient way to write XML documents (see example below).


Formal definition

QNames are formally defined by the W3C as: QName ::= PrefixedName , UnprefixedName PrefixedName ::= Prefix ':' LocalPart UnprefixedName ::= LocalPart Prefix ::= NCName LocalPart ::= NCName NCName is defined as follows: NCName ::= Name - (Char* ':' Char*) (* An XML Name, minus the ":" *) Name ::= NameStartChar (NameChar)* NameStartChar ::= ":" , -Z, "_" , -z, xC0-#xD6, xD8-#xF6 , xF8-#x2FF, x370-#x37D, x37F-#x1FFF , x200C-#x200D, x2070-#x218F, x2C00-#x2FEF , x3001-#xD7FF, xF900-#xFDCF, xFDF0-#xFFFD , x10000-#xEFFFFNameChar ::= NameStartChar , "-" , "." , -9 , #xB7 , x0300-#x036F, x203F-#x2040Char ::= (* any Unicode char, excluding surrogate blocks FFFE and FFFF. *) #x9 , #xA , #xD , x20-#xD7FF , xE000-#xFFFD, x10000-#x10FFFF Whereby the Prefix is used as placeholder for the namespace and the LocalPart as the local part of the qualified name. A local part can be an attribute name or an element name.


Example

In line two the prefix "x" is declared to be associated with the URI "http://example.com/ns/foo". This prefix can further on be used as abbreviation for this namespace. Subsequently, the tag "x:p" is a valid QName because it uses the "x" as namespace reference and "p" as local part. The tag "doc" is also a valid QName, but it consists only of a local part.Namespaces in XML 1.0 (Second Edition)
/ref>


See also

*
CURIE Curie may refer to: *Curie family, a family of distinguished scientists: :* Jacques Curie (1856–1941), French physicist, Pierre's brother :* Pierre Curie (1859–1906), French physicist and Nobel Prize winner, Marie's husband :* Marie Curi ...
: Compact URI * Fully qualified name


References

{{reflist XML