TargetNameSpace: main purpose to identify uniqueness of the schema.
Here I had created 2 schemas 1) Default Name Space 2) Default Name Space and TargetName Space
1.xsd -- DefaultNameSpace
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="USAddress">
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
</sequence>
</complexType>
</schema>
2.xsd -- TargetNameSpace
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNameSpace="http://rameshvanka.com/"
elementFormDefault="qualified">
<complexType name="USAddress">
<sequence>
<element name="name" type="string"/>
<element name="street" type="string"/>
</sequence>
</complexType>
</schema>
Now I want to import the schema of 1.xsd and 2.xsd into my 3.xsd
But 1.xsd don't have targetName. it is not possible to import that schema, it don't uniqueness to identify the schema.
2.xsd have targetNameSpace, so that 3.xsd able to identify the target using the targetNameSpace of
http://rameshvanka.com/
3.xsd:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ram="http://rameshvanka.com/"
targetNameSpace="http://megastar.com/"
elementFormDefault="qualified">
<import schemalocation="2.xsd"
namespace="http://rameshvanka.com/"/>
</schema>
Hope it will clear the all doubts on targetNamespace.