November 2003 Technical Tip Example - XSLT Transformation Program

The following is the full text of the XSLT transformation program used to generate the COBOL Curriculum table in the November 2003 Technical Tip example:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="" 
   <xsl:output method="html" encoding="UTF-8" media-type="text/html" />
   <xsl:template match="/">
            <title>Table Tricks With XML</title>
            <table cellPadding="2" border="1">
               <caption>COBOL Curriculum</caption>
                     <col align="middle" width="100" />
                     <col align="left" width="250" />
                     <col align="middle" width="75" />
                  <xsl:for-each select="/courses/course">
                        <xsl:when test="position() mod 2 != 0">
                           <tr bgcolor="#CCCCCC">
                              <xsl:apply-templates />
                           <tr bgcolor="#FFFFFF">
                              <xsl:apply-templates />
   <xsl:template match="courseno">
         <xsl:value-of select="." />
   <xsl:template match="coursename">
         <xsl:value-of select="." />
   <xsl:template match="duration">
         <xsl:value-of select="." />

Go to the articles index. Copyright 2003 by Caliber Data Training 800.938.1222