Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 1 Introduction : TIBCO Hawk HTTP Adapter and XML Namespaces

TIBCO Hawk HTTP Adapter and XML Namespaces
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
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).
  <?xml version="1.0" encoding="UTF-8" ?>
- <Agents xmlns="http://www.tibco.com/TIBCOHawk">
  - <Agent>
      <AgentName>Solaris_29</AgentName>
      <DnsName>tibco.com</DnsName>
      <HawkDomain>default</HawkDomain>
      <OsArch>sparc</OsArch>
      <OsName>SunOS</OsName>
      <OsVersion>5.9</OsVersion>
.
.
.
    </Agent>
  </Agents>
Qualified Names (QNames)
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.
A QName is an element name that has been qualified with a namespace prefix that functions as a placeholder for a namespace URI reference, as shown:
   prefix:LocalPart
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).
The following sample segment of an XSL stylesheet contains a namespace declaration that specifies two prefixes to represent two URIs:
xsl represents the URI http://www.w3.org/1999/XSL/Transform.
th represents the TIBCO Hawk URI, http://www.tibco.com/TIBCOHawk.
In this example, text is bold for emphasis.
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:th='http://www.tibco.com/TIBCOHawk'>
<xsl:template match="/">
<html>
<head>
  <title>
  Total Number of Agents: <xsl:value-of   select="count(//th:Agents/th:Agent)"/>
  </title>
</head>
<BODY BGCOLOR="#FFFFCC" TEXT="#060203">
<H1 Align="CENTER">
TIBCO Hawk Agent Status
</H1>

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved