Stylus Studio XML Editor

Table of contents

Appendices

3 Declaring Namespaces

Declaring Namespaces

A 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
[1]   NSAttName   ::=    [PrefixedAttName]
| [DefaultAttName]
[2]   PrefixedAttName   ::=   'xmlns:' [NCName]
[3]   DefaultAttName   ::=   'xmlns'
[4]   NCName   ::=    [NCNameStartChar] [NCNameChar] */*An XML Name, minus the ":"*/
[5]   NCNameChar   ::=   NameChar - ':'
[6]   NCNameStartChar   ::=   NameStartChar - ':'

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 http://ecommerce.example.org/schema:

<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 http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared, and MUST NOT be undeclared or bound to any other namespace name. Other prefixes MUST NOT be bound to this namespace name.

The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. It MUST NOT be declared or undeclared. Other prefixes MUST NOT be bound to this namespace name.

All other prefixes beginning with the three-letter sequence x, m, l, in any case combination, are reserved. This means that:

  • users SHOULD NOT use them except as defined by later specifications

  • processors MUST NOT treat them as fatal errors.

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.