XML Namespaces, XML Tutorial, Global Guideline

Bookmark Bookmark: XML Namespaces, XML Tutorial
Forum | Blog


      Home                    

Basic XML Guide.       
 XML Introduction.       
 XML Tags Guide.       
 XML Attributes.           
 XML Syntax Guide.    
 XML Compilation.      
 XML Execution.          
 XML with CSS.           
 XML with XSL.            
 XML Data Island.        
 XML Professional.       
 XML with JavaScript. 
 XML Namespaces.
 XML CDATA.              
 XML Editors.               
 XML Summary.           

XML Tutorial >> XML NAMESPACES.


     Back             Next     
In XML we have an open opportunity to define our own tags.  As it is a great thing for use at the same time it would be tough task for us to explain some common tags on the application or display end that how to treat the similar or equal tags.  Equality mean, as we have an idea, that we mostly use of XML is web based then, web based applications follows the HTML conventions mean they recognize HTML tags and know how to operate or treat them and suppose some where else we use the same tag in XML that is defined in HTML then our application will fail to operate it as XML tag. 

The major example of this hurdle is that suppose we try to store some information of a patient in a medical clinic about his body and suppose we use <body> as for his information and the <body> tag is not allowed we can say, in XML so to avoid this kind of confliction we will use a technique that is called XML Namespaces to avoid confliction.
When we create new elements, there is the chance that the element's name already exists.
XML was designed to be a very weak markup language that could be used in many different applications. However, with XML being able to communicate between so many different platforms, there is one problem that tends to arise. Look at the below example of XML tag names confliction.

XML document without Namespaces

<?xml version="1.0" encoding="ISO-8859-1"?>
<html>
  <head>
    <title>XML Tutorial, GGL Clinic</title>
  </head>
<body>
  <b>Welcome to GGL Health Resource</b>
</body>

<body>
  <color>white</color>
  <temperature>90</temperature>
  <bp>120</bp>
  <height>5.95</height>
  <weight>180 ponds</weight>
</body>

</html>

Explanation of Without Namespaces issues

On the above example as we saw that there are two very different elements that want to use the same naming convention <body>. So the conflictions will occur when any application will compile or operate the above code. Now the solution to this problem is to create XML Namespaces, which will differentiate between these two similarly named elements. 

Example of XML Namespaces

<?xml version="1.0" encoding="ISO-8859-1"?>
<html:html xmlns:html='https://www.w3.org/TR/html/>
  <html:head>
    <html:title>GGL Clinic</html:title>
  </html:head>
<html:body>
  <html:b>Welcome to GGL Health Resource</html:b>
</html:body>

<clinic:body xmlns:clininc='https://www.globalguideline.com/xml>
  <clinic:color>white</clinic:color>
  <clinic:temperature>90</clinic:temperature>
  <clinic:bp>120</clinic:bp>
  <clinic:height>5.95</clinic:height>
  <clinic:weight>180 ponds</clinic:weight>
</clinic:body>

</html:html>

On the above XML Namespaces of clinic and html we have separated the both bodies, medical clinic and html. By placing a namespace prefix before our own and html elements we have re-solved the confliction now.


     Back             Next     
 

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2018 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 212 visitors are online now