Originally posted by Divya Gehlot:
1.Is it necessary to have targetnamesapce and namepsace to be same
Not if you are not referencing anything that you are defining. As soon as your are trying to reference anything in that namespace it has to be the default namespace or a namespace with an assigned prefix.
xmlns="http://www.w3.org/2001/XMLSchema"
this means that {http://www.w3.org/2001/XMLSchema} is the default namespace - therefore any of the XML Schema elements don't need a prefix.
xmlns:mh="http://www.Monson-Haefel.com/jwsbook"
assigns the "mh" prefix to the {http://www.Monson-Haefel.com/jwsbook} namespace. So whenever we refer an element or type that exists in that namespace we have to prefix it with "mh"
targetNamespace="http://www.Monson-Haefel.com/jwsbook"
this simply states that any elements and types that are defined by the Schema (or WSDL) are in created the {http://www.Monson-Haefel.com/jwsbook} namespace. It
doesn't create a means for you to refer to anything in the {http://www.Monson-Haefel.com/jwsbook} namespace. This is why you have to use the "mh" prefix assigned by the namespace declaration when you are using mh:USAddress, mh:Book, mh:PurchaseOrder.
3.In the example we have used prefix only for namespace not for Target namespace. why so??
"xmlns" is a namespace declaration which can assign a prefix.
"targetNamespace" isn't a namespace declaration - it simply specifies the
target namespace into which the new elements and types are defined into.
As far as understood TargetNamespace is like default namespace. I am in the right way?
No, that is incorrect.
However the default namespace can be the targetNamespace:
Now the default namespace is the target namespace. However now all of the XML Schema elements have to be prefixed with "xsd" - "xsd:schema", "xsd:complexType", "xsd:sequence" ...
[ February 29, 2008: Message edited by: Peer Reynders ]