Entities

   

Namespaces

Because XML is extensible, anybody or any organization can draft its own tags. This raises the risk that two different organizations or people will use the same tag with different meanings.

The namespace mechanism is a small extension to XML to clearly label the owner of a tag. The mechanism builds on the familiar URIs (URLs and URNs).

For example, the following uses the element title as defined in the context of namespace http://www.psol.com/axs/library. The namespace is declared (with the xmlns attribute) and bound to a prefix ( psol ).

 <psol:title xmlns:psol="http://www.psol.com/axs/library">Applied XML Solutions</psol: graphics/ccc.gif title> 

Although simple, namespace is the source of much confusion so let's debunk two of the most common errors:

  • The URI is only an identifier; it doesn't need to point to a description of the element.

  • The prefix is used only as a shorthand for the URI because the URIs are typically large and include characters not valid for XML names .

It is probably easier if you forget the prefix and think of the document as

 <http://www.psol.com/axs/library:title>Applied XML Solutions </http://www.psol.com/ graphics/ccc.gif axs/library:title> 

In practice, however, this would be verbose and the element name would include illegal characters (such as / ). Hence the prefix mechanism.

   


Applied XML Solutions
Applied XML Solutions
ISBN: 0672320541
EAN: 2147483647
Year: 1999
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net