XML technologies / XML Schema / Data type reference / xs:QName
(Excerpt from “XML Schema” by Eric van der Vlist)
Namespaces in XML 1.0 qualified names
Derived from: xs:anySimpleType
Primitive type: xs:QName
Known subtypes: none
Facets: xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace
Definition
<xs:simpleType name="QName" id="QName">
<xs:restriction base="xs:anySimpleType">
<xs:whiteSpace value="collapse" fixed="true"/>
</xs:restriction>
</xs:simpleType>Description
The lexical space of xs:QName consists of qualified names as defined by “Namespaces in XML”: a local name, an xs:NCName, with an optional prefix, itself an xs:NCName, separated by a colon “:”. The prefix is declared as a namespace within the scope of the element carrying the value. The value space comprises pairs of namespace URI and local name, where the namespace URI is the URI associated with the prefix in its namespace declaration.
This separation of lexical and value spaces matters greatly when using facets such as xs:pattern, which operates only on lexical space and thus constrains the namespace prefix, and xs:enumeration, which operates on value space and thus constrains the namespace URI.
Restrictions
A pattern cannot be applied to the namespace URI.
Using QNames in elements and attributes is controversial because it makes document content dependent on markup. However, the W3C’s official position does not discourage this practice.
Example
W3C XML Schema has already given us examples of QNames. When we wrote <xs:attribute name="lang" type="xs:language"/>, attribute type was an xs:QName, and its value was tuple {"http://www.w3.org/2001/XMLSchema", "language"}, because URI "http://www.w3.org/2001/XMLSchema" had been assigned to prefix xs:. Without a namespace declaration for this prefix, attribute type would have been invalid.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de