In an xml schema document, if I have both the targetNamespace and the xmlns without a prefix.
namespace means like scope
targetNamespace
is an attribute of schema
element defines namespace i.e. package in XSD file. By convention we use URI/URLs, but we could use any string.
xmlns
is an attribute is used to refer elements and datatypes that come from xmlns attribute value for the current element scope.
For Example:
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
is with prefix as xsd
means namespace should be prefixed with xsd:
xmlns="http://www.w3.org/2001/XMLSchema"
without prefix is default p
means namespace should be prefixed with p:
Where xmlns:xsd
and xmlns:p
are QNames and xmlns
is local name.
The following image helps to understand XSD using Java analogy as per my knowledge: