The page w3schools gives the following as one form of schema declaration.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
...
...
</xs:schema>
Here,
targetNamespace defines the namespace for the XML document being defined-- which tags (elements) and which attributes can be used in the XML document being defined in "this" XSD.
xmlns=http://www.w3schools.com/schema/schema_schema.asp
, on the other hand, is defining the default namespace for the names in the XML document -- those names that aren't being defined on "this" XSD(?) so, the parser is first looking up the namespace declared in targetNamespace. if it can't find the name in there, going ahead and trying next the one in xmlns (?)
What exactly would i miss if i skip the targetNamespace attribute in the schema declaration above? while I have xmlns, targetNamespace redundant to me since they are referring to the same namespace.
What am i missing?
Note: i've seen What does "xmlns" in XML mean? among some other discussions.