3.5. Namespace Scoping

Namespaces have scoping rules that let you have a namespace in effect for only part of your document. A namespace declaration applies to the element where it is specified and to all elements contained within it. You can also override the binding of a prefix to a namespace URI by binding it to a different namespace URI, and you can turn off default namespace processing by setting the value of the xmlns attribute to an empty string. For example:

<root xmlns="http://www.example.com/root"> 
  <inrootnamespace/> 
  <child xmlns="http://www.example.com/child"> 
    <inchildnamespace/> 
    <nonamespace xmlns=""> 
    *    *    *    *    * 
    </nonamespace> 
  </child> 
</root> 

In the preceding example, the root and inrootnamespace elements are in the http://www.example.com/root namespace. The child and inchildnamespace elements are in the www.example.com/child namespace. In addition, the nonamespace element and its subelements do not belong in any namespace. Prefixes work the same way. It is possible to redefine a prefix to be associated with a different namespace. However, this is not a good thing to do. Because a prefix is just an arbitrary character string, you should not reuse a prefix in a document. The document will be error-prone and hard to read.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.26.176