Last Modified: 1/29/08
  Computer Training
Purchase Order Program Exammple

Credit: Jon A. Morse (ST Sci/NASA)

Example Program

We demonstrate XSL processing through an example program that accepts purchase information from users and creates an XML data file that describes the purchase. The program itself is written entirely in ordinary HTML and Perl-CGI -- it contains no XML or XSL at all. However, it creates an output file that is valid XML. Each time a user fills out the purchase form, their purchase information is converted to XML format and pre-pended to the existing XML file, and so the XML file accumulates the history of all purchases.

All the processing of the XML file, however, is done entirely through XSL, which creates a variety of reports as well as modifications and updates to the XML file itself.

The components of this example are:

  • The HTML program po.html which displays an HTML form that the user fills in to describe their purchase.
  • The Perl-CGI program that creates the XML data file that describes a user's purchase po.cgi
  • The XML file created by repeated executions of the HTML program by different users. This XML file contains the purchase orders for five different people.
  • The resulting XML file after it has been processed by XSL several times to create new elements, such as "invoices" and "packing slips"
XSL Programs to Process the XML File
Note: the server used for these pages has a fully functional XSL processor, and so clicking on the XML file that references the XSL file displays the actual results (for example, an XML file that references an XSL might have the following header:
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="../Xsl/d0.xsl"?>
assuming that "d0.xsl" is an XSL file located in the "Xsl" directory.

However, this XSL processor is not yet available on the Homer/Dante web servers, so you would need to process the XSL files using the DOS command "XT".

The results of applying various XSL stylesheets to an XML file are available through the following links:

Previous Home Next

Course Topics

The relationships among HTML, JavaScript, XML, XSL, and XPATH

The process of converting XML to HTML or other forms of XML

Converting XML to HTML using HTML and JavaScript

Xpath

Converting XML to HTML using XSL

Major Structures in XSL

Purchase Order Program Example

 
Previous Home Next

©1999 UW Technology