Wednesday 21 October 2015

Differences between targetNamespace and default namespace

Reference :
http://www.liquid-technologies.com/Tutorials/XmlSchemas/XsdTutorial_04.aspx
http://www.ibm.com/developerworks/library/xml-schema/


targetNamespace is the namespace that is going to be assigned to the schema you are creating. It is the namespace an instance is going to use to access the types it declares. In the following code, the schema will be assigned to the namespace http://www.Monson-Haefel.com/jswbook/po

...
</schema>



In an XML document instance, you declare the namespaces you are going to be using by means of the xmlns attribute. For example:
?
1
2
3
4
5
6
  <accountName>Shanita</accountName>
  <accountNumber>123456</accountNumber>
  <addr:street>20 King St</addr:street>

</purchaseOrder>


The default namespace here is
 http://www.Monson-Haefel.com/jswbook/po, which makes reference to the schema previously created. This namespace applies to the element that declares it, and its child elements, unles they are prefixed. In the example, all the elements belong to the default namespace, except addr:street. Since it is prefixed, it belongs to the addr namespace (xmlns:addr="http://www.Monson-Haefel.com/jwsbook/addr")


No comments:

Post a Comment