© 2004 Microsoft Corporation. All rights reserved.

Figure 2 Namespaces in C++
namespace foo1
{
   class bar
   {
      •••
   };
   class baz
   {
      •••
   };
}
namespace foo2
{
   class bar
   {
      •••
   };
   class baz
   {
      •••
   };
}
Figure 4 Syntactic Namespace Definition
<schema xmlns='http://www.w3.org/2000/10/XMLSchema'
   targetNamespace='http://www.develop.com/student'
   elementFormDefault='qualified'
>
  <element name='student'/>
     <complexType>
         <sequence>
            <element name='id' type='long'/>
            <element name='name' type='string'/>
            <element name='language' type='string'/>
            <element name='rating' type='double'/>         
         </sequence>
     <complexType>
   </element>
</schema>
Figure 6 Differentiation using SAX
•••
void startElement(String namespaceURI, String localName, 
   String qName, Attributes atts)
{
    if ( namespaceURI.equals("urn:dm:student") &&
         localName.equals("student") )
       {
        // process Developmentor student element here
    }
    else if ( namespaceURI.equals("urn:www.ed.gov:student") 
         && localName.equals("student") )
       {
        // process elementary school student element here
    }
}
•••
Figure 7 Differentiation using DOM
void processStudent(Node n)
{
    if ( n.getNamespaceURI().equals("urn:dm:student") &&
         n.getLocalName().equals("student") )
       {
        // process Developmentor student element here
    }
    else if ( 
        n.getNamespaceURI().equals("urn:www.ed.gov:student") 
        && n.getLocalName().equals("student") )
       {
        // process elementary school student element here
    }
}
Show: