Purpose of XML Namespaces

An XML Namespace is collection of element types and attribute names. It consists of two parts :

1) The first part is the URI used to identify the namespace
2) The second part is the element type or attribute name itself.

Together they form a unique name.

The various purpose of XML Namespace are
1. Combine fragments from different documents without any naming conflicts.
2. Write reusable code modules that can be invoked for specific elements and attributes. Universally unique names guarantee that
such modules are invoked only for the correct elements and attributes.
3. Define elements and attributes that can be reused in other schemas or instance documents without fear of name collisions.

For
example, you might use XHTML elements in a parts catalog of shopping cart to provide part descriptions. Or you might use the nil attribute
defined in XML Schemas to indicate a missing value.


< Department >
< Name >XYZ< /Name >
< addr:Address xmlns:addr="[URL link here]" >
< addr:Street >Gold Street. 7< /addr:Street >
< addr:City >Ahmedabad< /addr:City >
< addr:State >gujarat< /addr:State >
< addr:Country >India< /addr:Country >
< addr:PostalCode >D-64285< /addr:PostalCode >
< /addr:Address >
< serv:Server xmlns:serv="[URL link here]" >
< serv:Name >OurWebServer< /serv:Name >
< serv:Address >123.45.67.8< /serv:Address >
< /serv:Server >
< /Department >


Comments

Author: PHANI HARSHITHA MADALA22 Apr 2009 Member Level: Gold   Points : 0

Hi,

Nice of piece of info on xml namespaces...

regards,

greeny

Author: Sra122 Apr 2009 Member Level: Silver   Points : 2

Hi Deepika,

Thanks for sharing this article, one question from my side do the XML which gets generated from oracle will have the same approach.
I mean the first part is URI and the second part is attribute name.

Best Regards,
Sra1

Today is Earth Day join to celebrate

Author: Pradeep Iyer22 Apr 2009 Member Level: Gold   Points : 1

Hi,

Good one..

Keep posting more articles..

Very informative indeed..

Regards,
Pradeep



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: