A single XML document may contain elements and attributes that are defined for and used by multiple schema, posing the problems of recognition and collision. An XML file referencing those schema needs to be able to identify the particular schema from which an XML element comes from, allowing TIBCO Hawk data and data from other sources to be combined in a document without name collisions. This is possible through the use of universal names whose scope extends beyond their containing document. The
XML namespaces mechanism accomplishes this.
There are a number of commercially available books that describe XML and XML namespace. In addition, some of the following text was used with permission from
http://www.w3.org/TR/REC-xml-names/.
All data generated by TIBCO Hawk HTTP Adapter is in XML format and is namespace qualified. The URI in the namespace is
http://www.tibco.com/TIBCOHawk.
XML namespaces provide a simple method for qualifying element and attribute names used in XML documents by associating them with namespaces identified by URI references. An XML namespace identifies an XML element as coming from a particular XML schema. This allows multiple XML schemas to use elements with identical names, and an XML file referencing those schemas can easily determine the correct definition for each element.
An XML namespace is a collection of names, identified by a URI reference, which are used in XML documents as element types and attribute names. XML namespaces differ from the "namespaces" conventionally used in computing disciplines in that the XML version has internal structure and is not, mathematically speaking, a set.
For example, the Marketing.xml schema and the
Sales.xml schema may each have an element named
<PurchaseOrder>. The namespace adds the schema name to each element, so one element is renamed
<Marketing:PurchaseOrder> and the other is renamed
<Sales:PurchaseOrder>. An XML file that uses both schemas will not get confused about which
<PurchaseOrder> element definition to use.
A namespace is valid for the element it is defined in and for all of the subelements. Subelements can have additional or overriding namespace definitions. A namespace can also contain URIs that refer to XML schema documents not located on the Internet.
As an example, the following segment of an XML stream is generated when the Agents URL is invoked. All element names in this sample, such as
<Agent> and
<AgentName>, belong to the namespace
http://www.tibco.com/TIBCOHawk (text is bold for emphasis).
Names from XML namespaces may appear as qualified names (QNames). Any application using the TIBCO Hawk HTTP Adapter XML data stream must use QNames to access the XML elements.
The prefix provides the namespace prefix part of the QName, and must be associated with a namespace URI reference in a namespace declaration. The LocalPart provides the local part of the qualified name. The combination of the universally managed URI namespace and the document's own namespace produces identifiers that are universally unique.
In TIBCO Hawk HTTP Adapter, the namespace prefix for the URI http://www.tibco.com/TIBCOHawk is
th (abbreviation for TIBCO Hawk).