Two XSL Files to Produce All the HTML Pages

While the managexmlxsl.inc ASP file controls all the site navigation and file management, two XSL files produce all the HTML pages. Because this Web site is relatively simple and the pages follow a uniform format, it's easy to produce all the HTML with just two files. (Theoretically, all the HTML could be produced from one XML file and one XSL file, but that's not recommended because the file sizes would get unwieldy and the complexity of the code would create unnecessary maintenance and processing burdens.)

There is no magic ruler to determine how many XSL files are needed for a certain number of HTML pages. However, pages that share a common format or focus generally can be produced from the same XSL file. The Center for Technology in Government's Web site uses less than 50 XSL files to produce over 10,000 Web pages, including HTML and PDF.

The Level 1 pages (which are the home page and the opening page of each of the top banner navigation items) are produced by the level1.xsl file shown below.


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- 
**************************************************************************************************************
COPYRIGHT NOTICE:
Copyright 2006 Center for Technology in Government.
The Center grants permission to use and modify this software code free of charge provided  
this copyright notice is included. By using this code you agree to indemnify the Center from 
any liability that might arise from its use. Selling the code is expressly forbidden.
**************************************************************************************************************
 -->
 <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
 <xsl:param name="name"/>
 <xsl:param name="sub"/>
 <xsl:param name="extension"/>
 <xsl:template match="book">
  <html lang="us-en">
   <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="description" content="XML Toolkit"/>
    <meta name="keywords" content="CTG, center for technology in government,  
      government, technology, XML"/>
    <title>
     <xsl:value-of select="title"/>
    </title>
    <style media="screen" type="text/css">
     @import "css/master.css"; /* main css template */
    </style>
    <link rel="stylesheet" href="css/master.css" type="text/css" media="print" />
    </head>
   <body>
    <div id="wrapper">
     <div id="banner">
      <a href="#main" id="skiplink" accesskey="" tabindex="0">Skip to Content</a>
      <a href="http://www.ctg.albany.edu" accesskey="" tabindex="0">
       <img src="img/common/ctg_logo.gif" alt="" style="margin-bottom:0;"/>
      </a>
      <img src="img/common/xml_graphic.jpg" alt="" id="graphic"/>
      <img src="img/common/xml_graphic2.jpg" alt="" id="graphic2"/>
      <img src="img/common/xml_graphic3.jpg" alt="" id="graphic3"/>
      <h1>
       <xsl:choose>
        <xsl:when test="$name='Index' or $name='index'">The XML Toolkit</xsl:when>
        <xsl:otherwise>
         <a href="/">The XML Toolkit</a>
        </xsl:otherwise>
       </xsl:choose>
      </h1>
     </div>
     <ul id="nav">
     <xsl:choose>
      <xsl:when test="$name='gettingstarted'">
       <li id="current">
        <a href="./gettingstarted{$extension}" accesskey="" tabindex="0">Getting Started</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./gettingstarted{$extension}" accesskey="" tabindex="0">Getting Started</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='environment'">
       <li id="current">
        <a href="./environment{$extension}" accesskey="" tabindex="0">Environment</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./environment{$extension}" accesskey="" tabindex="0">Environment</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='codesamples'">
       <li id="current">
        <a href="./codesamples{$extension}" accesskey="" tabindex="0">Code Samples</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./codesamples{$extension}" accesskey="" tabindex="0">Code Samples</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='tools'">
       <li id="current">
        <a href="./tools{$extension}" accesskey="" tabindex="0">Tools</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./tools{$extension}" accesskey="" tabindex="0">Tools</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='tips'">
       <li id="current">
        <a href="./tips{$extension}" accesskey="" tabindex="0">Tips</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./tips{$extension}" accesskey="" tabindex="0">Tips</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='guides'">
       <li id="current">
        <a href="./guides{$extension}" accesskey="" tabindex="0">Guides and Reports</a>
        </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./guides{$extension}" accesskey="" tabindex="0">Guides and Reports</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='inside'">
       <li id="current">
        <a href="./inside{$extension}" accesskey="" tabindex="0">Inside this Site</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./inside{$extension}" accesskey="" tabindex="0">Inside this Site</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='feedback'">
       <li id="current">
        <a href="./feedback{$extension}" accesskey="" tabindex="0">Feedback</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./feedback{$extension}" accesskey="" tabindex="0">Feedback</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
      </ul>
      <xsl:choose>
       <xsl:when test="$name='Index' or $name='index'">
        <h1 class="clearboth">
        <a name="main" tabindex="0" accesskey="">
         <xsl:value-of select="chapter[1]/title"/>
        </a>
        </h1>
        <xsl:apply-templates select="chapter[1]/para"/>
        <div id="content">
        <div id="home-sections">
        <xsl:for-each select="chapter[2]/sect1">
        <div class="homepage-block">
         <h1>
         <xsl:apply-templates select="title"/>
         </h1>
         <p>
         <xsl:value-of select="para"/>
         </p>
        </div>
        </xsl:for-each>
        <div class="copyright">Copyright 2006 Center for Technology in Government</div>	
        </div>
        </div>
       </xsl:when>
       <xsl:otherwise>
        <h1 class="clearboth">
        <a name="main" tabindex="0" accesskey="">
         <xsl:value-of select="chapter[1]/title"/>
        </a>
        </h1>
        <xsl:apply-templates select="chapter[1]/para"/>
        <div id="content">
        <div id="home-sections">
         <xsl:for-each select="chapter[1]/sect1">
         <div class="level1-block">
         <h1>
         <xsl:apply-templates select="title"/>
         </h1>
         <xsl:apply-templates select="para"/>
         </div>
         </xsl:for-each>
         <div class="copyright">Copyright 2006 Center for Technology in Government</div>	
         </div>
         </div>
        </xsl:otherwise>
       </xsl:choose>
      </div>
     </body>
    </html>
  </xsl:template>
 <xsl:include href="common.xsl"/>
 <xsl:template match="sect1/title">
  <xsl:apply-templates/>
 </xsl:template>
</xsl:stylesheet>

		
			

The Level 2 pages (which are the pages beyond the the opening page of the top banner navigation items, such as this page) are produced by the level2.xsl file shown below.


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- 
**************************************************************************************************************
COPYRIGHT NOTICE:
Copyright 2006 Center for Technology in Government.
The Center grants permission to use and modify this software code free of charge provided  
this copyright notice is included. By using this code you agree to indemnify the Center from 
any liability that might arise from its use. Selling the code is expressly forbidden.
**************************************************************************************************************
 -->
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
<xsl:param name="name"/>
<xsl:param name="sub"/>
<xsl:param name="extension"/>
<xsl:template match="book">
<html lang="us-en">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <meta name="description" content="XML Toolkit"/>
 <meta name="keywords" content="CTG, center for technology in government,  government, technology, XML"/>
 <title>
  <xsl:value-of select="title"/> - <xsl:value-of select="chapter[@label=$sub]/title"/>
 </title>
 <style media="screen" type="text/css">
  @import "css/master.css"; /* main css template */
 </style>
  <link rel="stylesheet" href="css/master.css" type="text/css" media="print" />
</head>
<body>
 <div id="wrapper">
 <div id="banner">
  <a href="#main" id="skiplink" accesskey="" tabindex="0">Skip to Content</a>
  <a href="http://www.ctg.albany.edu" accesskey="" tabindex="0">
   <img src="img/common/ctg_logo.gif" alt="" style="margin-bottom:0;"/>
  </a>
  <img src="img/common/xml_graphic.jpg" alt="" id="graphic"/>
  <img src="img/common/xml_graphic2.jpg" alt="" id="graphic2"/>
 <img src="img/common/xml_graphic3.jpg" alt="" id="graphic3"/>
 <h1>
  <a href="/" accesskey="" tabindex="0">The XML Toolkit</a>
  </h1>
 </div>
 <ul id="nav">
 <xsl:choose>
      <xsl:when test="$name='gettingstarted'">
       <li id="current">
        <a href="./gettingstarted{$extension}" accesskey="" tabindex="0">Getting Started</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./gettingstarted{$extension}" accesskey="" tabindex="0">Getting Started</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='environment'">
       <li id="current">
        <a href="./environment{$extension}" accesskey="" tabindex="0">Environment</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./environment{$extension}" accesskey="" tabindex="0">Environment</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='codesamples'">
       <li id="current">
        <a href="./codesamples{$extension}" accesskey="" tabindex="0">Code Samples</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./codesamples{$extension}" accesskey="" tabindex="0">Code Samples</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='tools'">
       <li id="current">
        <a href="./tools{$extension}" accesskey="" tabindex="0">Tools</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./tools{$extension}" accesskey="" tabindex="0">Tools</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='tips'">
       <li id="current">
        <a href="./tips{$extension}" accesskey="" tabindex="0">Tips</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./tips{$extension}" accesskey="" tabindex="0">Tips</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='guides'">
       <li id="current">
        <a href="./guides{$extension}" accesskey="" tabindex="0">Guides and Reports</a>
        </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./guides{$extension}" accesskey="" tabindex="0">Guides and Reports</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:choose>
      <xsl:when test="$name='inside'">
       <li id="current">
        <a href="./inside{$extension}" accesskey="" tabindex="0">Inside this Site</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./inside{$extension}" accesskey="" tabindex="0">Inside this Site</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
	 <xsl:choose>
      <xsl:when test="$name='feedback'">
       <li id="current">
        <a href="./feedback{$extension}" accesskey="" tabindex="0">Feedback</a>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <li>
        <a href="./feedback{$extension}" accesskey="" tabindex="0">Feedback</a>
       </li>
      </xsl:otherwise>
     </xsl:choose>
     </ul>
     <h1 class="clearboth">
     <a name="main" tabindex="0" accesskey="">
      <xsl:value-of select="chapter[@label=$sub]/title"/>
     </a>
     </h1>
     <xsl:apply-templates select="chapter[@label=$sub]/para"/>
      <xsl:for-each select="chapter[@label=$sub]/sect1">
      <xsl:apply-templates select="title"/>
      <xsl:apply-templates select="para"/>
      </xsl:for-each>
      <div class="copyright">Copyright 2006 Center for Technology in Government</div>
     </div>
    </body>
   </html>
 </xsl:template>
 <xsl:include href="common.xsl"/>
</xsl:stylesheet>