Namespace declaration attributes
Namespace declaration attributes are specified in the start tag of a direct element constructor. Namespace declaration attributes are used for two purposes: to bind a namespace prefix to a URI, and to set the default element/type namespace for the constructed element node and for its attributes and descendants.
Syntactically, a namespace declaration attribute has the same form as an attribute in a direct element constructor: the attribute is specified by a name and a value. The attribute name is constant QName. The attribute value is a string literal that represents a valid URI.
A namespace declaration attribute does not cause an attribute node to be created.
Binding a namespace prefix to a URI
If the QName begins with the prefix xmlns followed by a local name, then the declaration is used to bind the namespace prefix (specified as the local name) to a URI (specified as the attribute value). For example, the namespace declaration attribute xmlns:metric = "http://example.org/metric/units" binds the prefix metric to the namespace http://example.org/metric/units.When the namespace declaration attribute is processed, the prefix and URI are added to the statically known namespaces of the constructor expression, and the new binding overrides any existing binding of the given prefix. The prefix and URI are also added as a namespace binding to the in-scope namespaces of the constructed element.
<box xmlns:metric = "http://example.org/metric/units"
xmlns:english = "http://example.org/english/units">
<height> <metric:meters>3</metric:meters> </height>
<width> <english:feet>6</english:feet> </width>
<depth> <english:inches>18</english:inches> </depth>
</box>
Setting the default element/type namespace
If the QName is xmlns with no prefix, then the declaration is used to set the default element/type namespace. For example, the namespace declaration attribute xmlns = "http://example.org/animals" sets the default element/type namespace to http://example.org/animals.When the namespace declaration attribute is processed, the value of the attribute is interpreted as a namespace URI. This URI specifies the default element/type namespace of the constructor expression, and the new specification overrides any existing default. The URI is also added (with no prefix) to the in-scope namespaces of the constructed element, and the new specification overrides any existing namespace binding that has no prefix. If the namespace URI is a zero-length string, then the default element/type namespace of the constructor expression is set to "none".
<cat xmlns = "http://example.org/animals">
<breed>Persian</breed>
</cat>