السبت، 10 يناير 2009

XML Namespace

Namespace help to avoid conflict between two xml objects (xml data) of the same name.

In the following example we have 2 roots called table so how we can differentiate between them? And if you make search in your Xml document with the 2 same name how to determine the element you want!! So we can solve this problem by using namespace prefixes, follow this structure

First: 2 root with no namespace

Problem with prefix

After we differentiate between 2 Xml objects using prefix we also have a problem with prefix, imagine one of department of your company choose the same name for namespace like other department in the same company that choose the same name.

 

Solution

Use Uniform Resource Identifier by using URLThe purpose is to give the namespace a unique name. However, often companies use the namespace as a pointer to a web page containing namespace information

The namespace is defined by the xmlns attribute in the start tag of an element

The namespace declaration has the following syntax. xmlns:prefix="URI"


0 التعليقات: