3. Real World Example

Let us say you are integrating two companies systems. These systems will share information about their inventory. Both, very forward thinking companies, have processes which use XML to update their databases. Company A's XML data looks like the following:

Example 1.1. Input Document

<?xml version="1.0" ?>

<items> <item> <name>Lord of the Rings</name> <cost>32.00</cost> <count>4</count> </item> </items>

and company B needs the XML to look like this:

Example 1.2. Required Document

<?xml version="1.0" ?>

<inventory> <product> <name>Lord of the Rings</name> <type>DVD</type> <price>32.00</price> <quantity>4</quantity> </product> </inventory>

You could possibly code around the differences using whatever process is used to update the databases, but what if instead of two companies there are three, four, or twenty? That could turn into quite a few 'if' statements.

A nice way to handle this process could be XSLT. What we can do is have an XSLT process that sits between the two documents and changes the XML from company A's format to company B's format. Then if we need to add another company, it is a simple matter of adding another style sheet.