XML Namespaces

Name Conflicts: XML Namespaces provide a method to avoid element name conflicts.

In XML, element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications.

This XML carries HTML Book information (Index details):

<book>
  <index>
    <chapter>second</chapter>
    <page>thirty</page>
  </index>
</book>

This XML carries information about a Book (price details):

<book>
  <author>African Coffee Table</author>
  <price>90</price>
  <publisher>INX</publisher>
</book>

If these XML fragments were added together, there would be a name conflict. Both contain a <book> element, but the elements have different content and meaning.

An XML parser will not know how to handle these differences.

This Name Conflict can Solve by Using a Prefix

Name conflicts in XML can easily be avoided using a name prefix. This XML carries information about an HTML book, and a price details:

<x:book>
  <x:index>
    <x:chapter>second</x:chapter>
    <x:page>thirty</x:page>
  </x:index>
</x:book>

<y:book>
  <y:author>African Coffee Table</y:author>
  <y:price>90</y:price>
  <y:publisher>INX</y:publisher>
</y:book>

In the example above, there will be no conflict because the two <book> elements have different names.

XML Namespaces - The 'xmlns' Attribute

When using prefixes in XML, also-called namespace for the prefix must be defined.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".
 
<root>
<x:book xmlns:x="http://www.tibco.com/abc/dfg/">
  <x:index>
    <x:chapter>second</x:chapter>
    <x:page>thirty</x:page>
  </x:index>
</x:book>
 <y:book xmlns:y="http://www.tibcoworldin.com/test">
  <y:author>African Coffee Table</y:author>
  <y:price>90</y:price>
  <y:publisher>INX</y:publisher>
</y:book>
</root>

In the example above, the xmlns attribute in the <book> tag give the x: and y: prefixes a qualified namespace.

Default Namespaces

Defining a default namespace for an element saves us from using prefixes in all the child elements.
It has the following syntax:
 
xmlns="namespaceURI"

This XML carries HTML book information:

<book xmlns="http://www.tibco.com/abc/dfg/">
  <index>
    <chapter>second</chapter>
    <page>thirty</page>
  </index>
</book>

This XML carries information about a Book (price details):

<book xmlns ="http://www.tibcoworldin.com/test>
  <author>African Coffee Table</author>
  <price>90</price>
  <publisher>INX</publisher>
</book>

Why Web Services ?

Web Services = XML + Protocol

Web Services take web-applications to the next level. By using Web services, your application can publish its function or message to the rest of the world. By doing this other platforms can also access the web application.

So once this web application available to the rest of world, other platform can also access and also by doing this can interact with the other platforms which are already using that web.

Many of the major platforms can access the web using web browsers.

Web-applications are simply applications that run on the web. These are built around the Web browser standards and can be used by any browser on any platform.

Use of the web services are

1.Interoperability.
2.Reusable application components.
3.Open Standards XML + open Protocol based.

Components of the web services are

SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)

What is SOAP ?

SOAP is an XML-based protocol to let applications exchange information over HTTP.
SOAP stands for Simple Object Access Protocol.
  • SOAP is a communication protocol
  • SOAP is a format for sending messages
  • SOAP is designed to communicate via Internet
  • SOAP is platform independent
  • SOAP is language independent
  • SOAP is based on XML
  • SOAP is simple and extensible
  • SOAP allows you to get around firewalls
  • SOAP is a W3C standard

What is WSDL?

WSDL is an XML-based language for locating and describing Web services.
  • WSDL stands for Web Services Description Language
  • WSDL is based on XML
  • WSDL is used to describe Web services
  • WSDL is used to locate Web services
  • WSDL is a W3C standard

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP