title: How TargetNamespace is different from Namespace
body: <p>I'm new to xsd and learning about namespaces. Seen maximum all questions, blog etc but no one could help me understand in simple way.</p>
  
  <p>What I have understood so far is that, Namespaces are used to differentiate elements having same names. (Not cleared about targetnamespace)</p>
  
  <p>My understanding to make namespace is below</p>
  
  <pre><code>xlmns:foo()="URI" --&gt;Namespace (Its a unique token I would say which is responsible to differentiate elements with this syntax. And this synatx given a name and the criteria of making that name is Prefix:ElementName--&gt;Prefix.
  </code></pre>
  
  <p>I have got one example</p>
  
  <pre><code>&lt;foo:tag xmlns:foo="http://me.com/namespaces/foofoo"  
           xmlns:bar="http://me.com/namespaces/foobar"  
           &gt;  
  
    &lt;foo:head&gt;  
      &lt;foo:title&gt;An example document&lt;/foo:title&gt;  
    &lt;/foo:head&gt;  
  
    &lt;bar:body&gt;  
      &lt;bar:e1&gt;a simple document&lt;/bar:e1&gt;  
      &lt;bar:e2&gt;  
        Another element  
      &lt;/bar:e2&gt;  
    &lt;/bar:body&gt;  
  &lt;/foo:tag&gt;
  </code></pre>
  
  <p>If we want to use multiple namespaces in a xsd then we can declare them once like in above example. Where same prefix is being used for multiple namespaces </p>
  
  <pre><code>foo:tag ---&gt;xmlns:foo="http://me.com/namespaces/foofoo" 
  foo:tag ---&gt;xmlns:bar="http://me.com/namespaces/foobar
  </code></pre>
  
  <p>Is it same like in java where in a package we can have multiple classes and each class has its own attributes, in case of xml its elements. Am I correct ? Can anyone help me to understand TargetNamespace ?</p>