3.3. Declaring Namespaces

Namespaces are declared by using a family of reserved attributes. In XML 1.0, attributes starting with the three letters ‘xml’ (including variants with capital letters) are reserved for W3C use. To declare a default namespace, you add an attribute named ‘xmlns’ that has a value of the URI you choose to associate the namespace with. For example:

<Customer xmlns="http://www.example.com/foo"> 
     *     *     *     *     * 
</Customer> 

In the preceding example, a default namespace is declared. All unprefixed elements will be in the namespace associated with the URI ‘http://www.example.com/foo’.

Note

As specified in the Namespace Recommendation, all unprefixed attributes are unqualified—not part of any namespace.

There needs to be a way to ...

Get XML Schema Complete Reference, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.