Table of contentsAppendices |
3 Declaring NamespacesDeclaring NamespacesA namespace (or more precisely, a namespace binding) is declared using a family of reserved attributes. Such an attribute's name must either be xmlns or begin xmlns:. These attributes, like any other XML attributes, may be provided directly or by default. Attribute Names for Namespace Declaration
The attribute's normalized value MUST be either an IRI reference — the [namespace name] identifying the namespace — or an empty string. The namespace name, to serve its intended purpose, SHOULD have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists). Uniform Resource Names [URNs] is an example of a syntax that is designed with these goals in mind. However, it should be noted that ordinary URLs can be managed in such a way as to achieve these same goals. If the attribute name matches [PrefixedAttName] , then the [NCName] gives the namespace prefix, used to associate element and attribute names with the [namespace name] in the attribute value in the scope of the element to which the declaration is attached. If the attribute name matches [DefaultAttName] , then the [namespace name] in the attribute value is that of the default namespace in the scope of the element to which the declaration is attached. Default namespaces and overriding of declarations are discussed in [scoping-defaulting] . An example namespace declaration, which associates the
namespace prefix edi with the namespace name
<x xmlns:edi='http://ecommerce.example.org/schema'>
<!-- the "edi" prefix is bound to http://ecommerce.example.org/schema
for the "x" element and contents -->
</x>
Reserved Prefixes and Namespace Names
The prefix xml is by definition bound to the namespace name
The prefix xmlns is used only to declare namespace bindings and is by
definition bound to the namespace name
All other prefixes beginning with the three-letter sequence x, m, l, in any case combination, are reserved. This means that:
add Though they are not themselves reserved, it is inadvisable to use prefixed names whose LocalPart begins with the letters x, m, l, in any case combination, as these names would be reserved if used without a prefix. |