Breaking News

Namespaces In XML

A method for identifying XML elements and attributes that have the same name, but different meanings. For example, ADDRESS is a tag that can be used to identify totally different data elements such as “street address” and “IP address.”
 
 
An XML Namespace is a Prefix
 
An XML namespace uses a URL as a prefix in front of the “local name.” The combination of URL and local name makes the element or attribute name unique. The URL is used only as a way to create a unique prefix and does not have to resolve to a real page on the Internet. However, a document may be stored where the URL points that provides information about the namespace
 
Since element names in XML are not predefined, a name conflict will occur when two different documents use the same element names.
 
Name Conflicts
 
Since element names in XML are not predefined, a name conflict will occur when two different documents use the same element names.
 
This XML document carries details about an associate:
 
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<ebiz>
<details>
    <name>Dharmedra Das</name>
    <address>D 210, sector 13</address>
    <city>Noida</city>
    <state>UP</state>
    <pin>201301</pin>
</details>
</ebiz>
 
Click here to view the file.
 
This XML document carries details about a book:
 
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<ebiz>
<details>
    <title>XML Tutorial</title>
     <author>Ravish Tiwari</author>
     <date>29/04/2007</date>
     <ISBN>1-23343-235-2</ISBN>
     <publisher>eBIZ.com Publication</publisher>
</details>
</ebiz>
 
Click here to view the file.
 
If these two XML documents were added together, there would be an element name conflict because both documents contain a <details> element with different content and definition.
 
 
This XML document carries details about an associate:
 
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<associate:ebiz xmlns:associate=”http://www.ebizel.com/”>
<associate:details>
    <associate:name>Dharmedra Das</associate:name>
    <associate:address>D 210, sector 13</associate:address>
    <associate:city>Noida</associate:city>
    <associate:state>UP</associate:state>
    <associate:pin>201301</associate:pin>
</associate:details>
</associate:ebiz>
 
This XML document carries details about a book:
 
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<tutorial:ebiz xmlns:tutorial=”http://education.ebizel.com/”>
<tutorial:details>
    <tutorial:title>XML Tutorial</tutorial:title>
    <tutorial:author>Ravish Tiwari</tutorial:author>
    <tutorial:date>29/04/2007</tutorial:date>
    <tutorial:ISBN>1-23343-235-2</tutorial:ISBN>
    <tutorial:publisher>eBIZ.com Publication</tutorial:publisher>
</tutorial:details>
</tutorial:ebiz>

Check Also

XML and Server

Generating XML with JSP   XML can be generated on a server without any installed …