René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

XML Namespaces

An XML namespace is a collection of element and attribute names. This collection is referenced through a URI reference. This URI reference does not need to be a physical file; it is simply a way to distinguish between namespaces.
An XML namespace is declared with the xmlns Attribute.
Namespaces are not supported by DTDs.

Objective

Differentiation of duplicate Element or Attribute names

What namespaces are not

THE XML NAMESPACES RECOMMENDATION DOES NOT DEFINE ANYTHING EXCEPT A TWO-PART NAMING SYSTEM FOR ELEMENT TYPES AND ATTRIBUTES.

Declaring a namespace

<foo xmlns:bar_ns='http://something.qq/hallo'>
</foo>
The prefix bar_ns is associated with http://something.qq/hallo. The prefix acts only as a placeholder for the URL!
Note: the URL doesn't even have to exist. Usually, it is the URL of the organization maintaining the namespace.

Declaring a default namespace

<something xmlns="http://here.there.everywhere/xyz.html">...

The xml prefix and namespace

The xml prefix is bound to the namespace http://www.w3.org/XML/1998/namespace.

xml:lang

xml:space

xml:base

Other well known prefixes

  • xhmtl
  • xsl
  • xsd
  • svg
  • m or mml
   <?xml version="1.0" ?>
   <!DOCTYPE root-elem [
   
     <!ELEMENT root-elem (#PCDATA|xml:space)*>
     <!ELEMENT xml:space (#PCDATA)   >
   
   ]>
   <root-elem>
       
     just          some text
      <xml:space>
        just          some text
      </xml:space>
   </root-elem>

     <h3>xml:link</h3>

     <h3>xml:attribute</h3>

Known namespaces

  • XLink: http://www.w3.org/1999/xlink
  • XSL: http://www.w3.org/1999/XSL/Transform
  • Oracle XML DB: http://xmlns.oracle.com/xdb