It’s one thing to capture information from your Web site. It is quite another to get that information to the parts of the company that require it. Here’s a look at how one company used XML in conjunction with PHP and MySQL to get information from the company’s Web site—in usable formats—to the departments that needed it.

Real application
Let’s take a look at a solution that is currently in place in one of the largest companies in the world. (To prevent me from breaking the noncompete clause of my contract, it shall go unnamed.) This company needed to take data that was entered into the user interfaces on its Web sites and distribute the information across multiple departments and many OSs. The solution involved the use of XML, PHP, MySQL, and some very imaginative programming, and the end result is nothing short of impressive! While I assume some level of familiarity with these technologies, I believe you will find the examples interesting even if you rank yourself among the novices.

Step by step
First, we use PHP to gather the data online. Then, working with MySQL, our PHP scripts store the data in a database. The data is somewhat limited to Internet-based applications, leaving most of the company’s departments dependent on the database engineers to formulate queries and arrange the data in an acceptable format. To avoid those extra steps, we use XML to manipulate the data so that it can be used in other, more complicated programs and applications. This allows various departments to extract the data with software-specific programs written in XML, which are also known as XML applications. The code shown in Listing A outlines the basic format these XML programs adhere to.

In a simplistic way, this code creates a type of record layout that will be universal to the department applications. So for example, once the data has been stored in an XML application, our accounting department can use this information over and over again. It’s also possible to use XML within another department-related program. For example, you could use a set of XML applications as the core instruction set for a JAVA application that needs to know which orders are to be shipped and which ones aren’t. The payment type could determine this, whether the order was cash or check.

The code in our next example allows an XML application to efficiently manage data on a larger scale by incorporating XSLT (an extension of the Extensible Stylesheet Language for formatting an XML document). XSLT then translates the XML document and converts it to a node tree, which is a hierarchal representation of the entire XML document. Figure A shows our accounting department hierarchy.

Figure A
Basic XSLT hierarchy for the accounting department and style sheet

Once the node set is established, we can call it later in our document. The XSL snippet shown in Listing B handles this call from our style sheet.

This is how one company used XML to transform and manage data that was accepted from the customer on the company’s Web site, translated into another application, and then output to various other media. I hope that this sparks some brainstorming on your part and that the ideas you come up with help you as much as they have helped us.