XML Integration

WorldClass Creating an Extension with XML.  XML is a Language.

This utilizes an Open Source “Language Driver” technology that is published as a part of XMLFoundation.

The “ObjectsFromXML” example application is part of the XMLFoundation source download.  In the example application, XML data is transformed into business objects ready to be used by an application developer.  The purpose of the sample is to show how an application developer can use XML.  The source of the XML is irrelevant, it can come from anywhere so two sample sources are shown to create the same application data – one source from a disk file, and another from a dynamic document rendering system – UBT’s TransactXML Server

The complete source and makefiles are located in the Examples/c++/ObjectsFromXML directory.

The purpose of this document is to show how to setup UBT’s TransactXML Server version 5.2 to generate the dynamic XML that  works with the sample application.. Refer to the notes in the sample source code to see how to switch from one XML data source to another.

The first step to creating a document is understanding where to get the information that must be included in the document. That information is located within your business or organization.  It may be hand entered, but generally it comes from the DBMS (DataBase Management System) directly, or from an existing Application that has applied business rules to the information in the DBMS .   Information may also come directly from a hardware device interface.

For this reason, TransactXML server crosses a binary layer (often called a driver) to go get the actual information.  The specifications for which are public so if you have a proprietary information source can build you own.  While we have drivers for many different sources this example will focus on the simplest and most common source of information, this is the DBMS.  Any DBMS will do, but for the example we need to choose one, so I picked one that ships as a sample database on both SQL Server and Microsoft Access, the Northwind database so you can use either DBMS .  If you use Oracle you can use the sample SCOTT database or DB2 use the sample ADMINISTRATOR, but you’ll need to simplify the results to a list of Employees.

The query will join 3 tables to retrieve the information.

Visually it looks like this:

.ObjFromXML1

In Native SQL syntax it looks like this:

SELECT           Customers.CustomerID, Customers.ContactName, Customers.City, Customers.Country,

Orders.OrderID,Orders.OrderDate, Orders.ShippedDate, [Order Details].ProductID, [Order Details].UnitPrice

FROM             (Customers INNER JOIN Orders  ON Customers.CustomerID = Orders.CustomerID)

INNER JOIN [Order Details] ON Orders.OrderID =

[Order Details].OrderID

ORDER BY     Customers.CustomerID,Orders.OrderID

and as data it looks like this:

ObjFromXML2

Once the SQL to generate the data has been created, we need to define the markup in DesignerXML.

In DesignerXML:, File/new

ObjFromXML3press “Next” to this:ObjFromXML4press “Next” to this:

ObjFromXML5press “Next” to this:

ObjFromXML6By Default, a list of stored procedures is displayed.

Change the default from “SQL stored procedure” to “SQL Select statement”

Then press finish to this:

ObjFromXML7Paste the SQL into the query window, then set the primary tab to “Document” and you will see a blank document like this:

ObjFromXML8Double click “CustomerID” in the SQL result columns so that it is added to the document like this:

ObjFromXML9

Then double click “CustomerID” in the XML document so that it’s properties may be set like this:

ObjFromXML10

Press OK, then add “ContactName”, “City”, and “Country” and “OrderID” to the XML document like this:

ObjFromXML11Double click OrderID and change it’s name to Order and set it to be repeatable on each occurrence like we did for the CustomerID like this:

ObjFromXML13Press OK, then add “OrderDate”, “ShippedDate”, and “ProductID” to the XML document like this:

ObjFromXML14Double click ProductID and change it’s name to LineItem and set it to be repeatable on each occurance of ProductID, then add “ProductID” and “Unit Price” to “LineItem” so that the document looks like this:

ObjFromXML12Save the script. You just programmed TransactXML server to render a moderately complex  XML Document.  This document uses no external modifiers, but every element has the option “Custom Extension” that allows you to manipulate the document values, apply business logic, or graft in new branches of XML from  C/C++ Library , Java class, Perl,  Python, COM, CORBA, or even Custom Implementation extensions that you develop.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s