You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ch...@apache.org on 2011/03/18 18:23:23 UTC

svn commit: r1082984 [2/3] - in /db/derby/docs/trunk: build.xml lib/dita2htmlImpl.xsl lib/index.html

Added: db/derby/docs/trunk/lib/dita2htmlImpl.xsl
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/lib/dita2htmlImpl.xsl?rev=1082984&view=auto
==============================================================================
--- db/derby/docs/trunk/lib/dita2htmlImpl.xsl (added)
+++ db/derby/docs/trunk/lib/dita2htmlImpl.xsl Fri Mar 18 17:23:23 2011
@@ -0,0 +1,3826 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
+
+<!DOCTYPE xsl:stylesheet [
+
+  <!ENTITY gt            "&gt;">
+  <!ENTITY lt            "&lt;">
+  <!ENTITY rbl           " ">
+  <!ENTITY nbsp          "&#xA0;">    <!-- &#160; -->
+  <!ENTITY quot          "&#34;">
+  <!ENTITY copyr         "&#169;">
+]>
+
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+
+
+<!-- =========== OTHER STYLESHEET INCLUDES/IMPORTS =========== -->
+
+<xsl:import href="../common/dita-utilities.xsl"/>
+<xsl:include href="get-meta.xsl"/>
+<xsl:include href="rel-links.xsl"/>
+<xsl:include href="../common/output-message.xsl"/>
+
+
+<!-- =========== OUTPUT METHOD =========== -->
+
+<!-- XHTML output with XML syntax -->
+<xsl:output method="xml"
+            encoding="utf-8"
+            indent="no"
+            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
+            doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+/>
+
+
+<!-- =========== DEFAULT VALUES FOR EXTERNALLY MODIFIABLE PARAMETERS =========== -->
+
+<!-- /CSS = default CSS filename parameter ('')-->
+<xsl:param name="CSS"/>
+<xsl:param name="dita-css" select="'commonltr.css'"/> <!-- left to right languages -->
+<xsl:param name="bidi-dita-css" select="'commonrtl.css'"/> <!-- bidirectional languages -->
+
+<!-- default CSS path parameter (null)-->
+<xsl:param name="CSSPATH"/>
+
+<!-- the file name containing XHTML to be placed in the HEAD area
+     (file name and extension only - no path). -->
+<xsl:param name="HDF"/>
+
+<!-- the file name containing XHTML to be placed in the BODY running-heading area
+     (file name and extension only - no path). -->
+<xsl:param name="HDR"/>
+
+<!-- the file name containing XHTML to be placed in the BODY running-footing area
+     (file name and extension only - no path). -->
+<xsl:param name="FTR"/>
+
+<!-- default "output artwork filenames" processing parameter ('no')-->
+<xsl:param name="ARTLBL" select="'no'"/><!-- "no" and "yes" are valid values; non-'yes' is ignored -->
+
+<!-- default "hide draft & cleanup content" processing parameter ('no' = hide them)-->
+<xsl:param name="DRAFT" select="'no'"/><!-- "no" and "yes" are valid values; non-'yes' is ignored -->
+
+<!-- default "hide index entries" processing parameter ('no' = hide them)-->
+<xsl:param name="INDEXSHOW" select="'no'"/><!-- "no" and "yes" are valid values; non-'yes' is ignored -->
+
+<!-- for now, disable breadcrumbs pending link group descision -->
+<xsl:param name="BREADCRUMBS" select="'no'"/> <!-- "no" and "yes" are valid values; non-'yes' is ignored -->
+
+<!-- the year for the copyright -->
+<xsl:param name="YEAR" select="'2005'"/>
+
+<!-- default "output extension" processing parameter ('.html')-->
+<xsl:param name="OUTEXT" select="'.html'"/><!-- "htm" and "html" are valid values -->
+
+<!-- the working directory that contains the document being transformed.
+     Needed as a directory prefix for the @conref "document()" function calls.
+     default is '../doc/')-->
+<xsl:param name="WORKDIR" select="'./'"/>
+
+<!-- the path back to the project. Used for c.gif, delta.gif, css to allow user's to have
+     these files in 1 location. -->
+<xsl:param name="PATH2PROJ"/>
+
+<!-- the file name (file name and extension only - no path) of the document being transformed.
+     Needed to help with debugging.
+     default is 'myfile.xml')-->
+<xsl:param name="FILENAME"/>
+
+<!-- the file name containing filter/flagging/revision information
+     (file name and extension only - no path).  - testfile: revflag.dita -->
+<xsl:param name="FILTERFILE"/>
+
+<!-- Debug mode - enables XSL debugging xsl-messages.
+     Needed to help with debugging.
+     default is 'no')-->
+<xsl:param name="DBG" select="'no'"/> <!-- "no" and "yes" are valid values; non-'yes' is ignored -->
+
+<!-- DITAEXT file extension name of dita topic file -->
+<xsl:param name="DITAEXT" select="'.dita'"/>
+
+<!-- =========== "GLOBAL" DECLARATIONS (see 35) =========== -->
+
+<!-- The document tree of filterfile returned by document($FILTERFILE,/)-->
+<xsl:variable name="FILTERDOC" select="document($FILTERFILE,/)"/>
+
+<!-- Define a newline character -->
+<xsl:variable name="newline"><xsl:text>
+</xsl:text></xsl:variable>
+
+<!-- Define the error message prefix identifier -->
+<xsl:variable name="msgprefix">IDXS</xsl:variable>
+
+<!-- Filler for A-name anchors  - was &nbsp;-->
+<xsl:variable name="afill"></xsl:variable>
+
+<!-- these elements are never processed in a conventional presentation. can be overridden. -->
+<xsl:template match="*[contains(@class,' topic/no-topic-nesting ')]"/>
+
+
+<!-- =========== ROOT RULE (just fall through; no side effects for new delivery contexts =========== -->
+
+<xsl:template match="/">
+  <xsl:apply-templates/>
+</xsl:template>
+
+
+<!-- =========== NESTED TOPIC RULES =========== -->
+
+<!-- This first template rule generates the outer-level shell for a delivery context.
+     In an override stylesheet, the same call to "chapter-setup" must be issued to
+     maintain the consistency of overall look'n'feel of the output HTML.
+     Match on the first DITA element -or- the first root 'topic' element. -->
+<xsl:template match="/dita | /*[contains(@class,' topic/topic ')]" priority="1" name="root_element">
+  <xsl:call-template name="chapter-setup"/>
+</xsl:template>
+
+<!-- child topics get a div wrapper and fall through -->
+<xsl:template match="*[contains(@class,' topic/topic ')]" name="child.topic">
+  <xsl:param name="nestlevel">
+      <xsl:choose>
+          <!-- Limit depth for historical reasons, could allow any depth. Previously limit was 5. -->
+          <xsl:when test="count(ancestor::*[contains(@class,' topic/topic ')]) > 9">9</xsl:when>
+          <xsl:otherwise><xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ')])"/></xsl:otherwise>
+      </xsl:choose>
+  </xsl:param>
+<div class="nested{$nestlevel}">
+ <xsl:call-template name="gen-topic"/>
+</div><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template name="gen-topic">
+ <xsl:choose>
+   <xsl:when test="parent::dita and not(preceding-sibling::*)">
+     <!-- Do not reset xml:lang if it is already set on <html> -->
+     <xsl:apply-templates select="@outputclass"/>
+   </xsl:when>
+   <xsl:otherwise><xsl:call-template name="commonattributes"/></xsl:otherwise>
+ </xsl:choose>
+ <xsl:call-template name="setidaname"/>
+ <xsl:call-template name="gen-toc-id"/>
+ <xsl:call-template name="flagit"/>
+ <xsl:call-template name="start-revflag"/>
+ <xsl:apply-templates/>
+ <xsl:call-template name="end-revflag"/>
+</xsl:template>
+
+
+<!-- NESTED TOPIC TITLES (sensitive to nesting depth, but are still processed for contained markup) -->
+<!-- 1st level - topic/title -->
+<!-- Condensed topic title into single template without priorities; use $headinglevel to set heading.
+     If desired, somebody could pass in the value to manually set the heading level -->
+<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]">
+  <xsl:param name="headinglevel">
+      <xsl:choose>
+          <xsl:when test="count(ancestor::*[contains(@class,' topic/topic ')]) > 6">6</xsl:when>
+          <xsl:otherwise><xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ')])"/></xsl:otherwise>
+      </xsl:choose>
+  </xsl:param>
+  <xsl:element name="h{$headinglevel}">
+      <xsl:attribute name="class">topictitle<xsl:value-of select="$headinglevel"/></xsl:attribute>
+      <xsl:call-template name="commonattributes"/>
+      <xsl:apply-templates/>
+  </xsl:element>
+  <xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- Hide titlealts - they need to get pulled into the proper places -->
+<xsl:template match="*[contains(@class,' topic/titlealts ')]"/>
+
+
+<!-- =========== BODY/SECTION (not sensitive to nesting depth) =========== -->
+
+<xsl:template match="*[contains(@class,' topic/body ')]" name="topic.body">
+<div>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagit"/>
+  <xsl:call-template name="start-revflag"/>
+  <!-- here, you can generate a toc based on what's a child of body -->
+  <!--xsl:call-template name="gen-sect-ptoc"/--><!-- Works; not always wanted, though; could add a param to enable it.-->
+
+  <!-- Insert prev/next links. since they need to be scoped by who they're 'pooled' with, apply-templates in 'hierarchylink' mode to linkpools (or related-links itself) when they have children that have any of the following characteristics:
+       - role=ancestor (used for breadcrumb)
+       - role=next or role=previous (used for left-arrow and right-arrow before the breadcrumb)
+       - importance=required AND no role, or role=sibling or role=friend or role=previous or role=cousin (to generate prerequisite links)
+       - we can't just assume that links with importance=required are prerequisites, since a topic with eg role='next' might be required, while at the same time by definition not a prerequisite -->
+
+  <!-- get the short descr para -->
+  <xsl:apply-templates select="preceding-sibling::*[contains(@class,' topic/shortdesc ')]" mode="outofline"/>
+
+<!-- Insert pre-req links - after shortdesc - unless there is a prereq section about -->
+  <xsl:apply-templates select="following-sibling::*[contains(@class,' topic/related-links ')]" mode="prereqs"/>
+
+  <xsl:apply-templates/>
+  <xsl:call-template name="end-revflag"/>
+</div><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- no fallthru for shortdesc - needs to be pulled for 1st para and for abstract metadata -->
+<xsl:template match="*[contains(@class,' topic/shortdesc ')]"/>
+<!-- called shortdesc processing - para at start of topic -->
+<xsl:template match="*[contains(@class,' topic/shortdesc ')]" mode="outofline">
+<p>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:apply-templates/>
+</p><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- section processor - div with no generated title -->
+<xsl:template match="*[contains(@class,' topic/section ')]" name="topic.section">
+<div class="section">
+ <xsl:call-template name="commonattributes"/>
+ <xsl:call-template name="gen-toc-id"/>
+ <xsl:call-template name="setidaname"/>
+ <xsl:call-template name="flagit"/>
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+    <div class="{@rev}"><xsl:apply-templates select="."  mode="section-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+    <xsl:apply-templates select="."  mode="section-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</div><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/section ')]" mode="section-fmt">
+  <xsl:call-template name="start-revflag"/>
+  <xsl:call-template name="sect-heading"/>
+  <xsl:apply-templates select="*[not(contains(@class,' topic/title '))] | text() | comment() | processing-instruction()"/>
+  <xsl:call-template name="end-revflag"/>
+</xsl:template>
+
+<!-- example processor - div with no generated title -->
+<xsl:template match="*[contains(@class,' topic/example ')]" name="topic.example">
+<div class="example">
+ <xsl:call-template name="commonattributes"/>
+ <xsl:call-template name="setidaname"/>
+ <xsl:call-template name="gen-toc-id"/>
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+    <div class="{@rev}"><xsl:apply-templates select="."  mode="example-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+    <xsl:apply-templates select="."  mode="example-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</div><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/example ')]" mode="example-fmt">
+  <xsl:call-template name="start-revflag"/>
+  <xsl:call-template name="flagit"/>
+  <xsl:call-template name="sect-heading"/>
+  <xsl:apply-templates select="*[not(contains(@class,' topic/title '))] | text() | comment() | processing-instruction()"/>
+  <xsl:call-template name="end-revflag"/>
+</xsl:template>
+
+
+<!-- ===================================================================== -->
+
+<!-- =========== BASIC BODY ELEMENTS =========== -->
+
+<!-- paragraphs -->
+<xsl:template match="*[contains(@class,' topic/p ')]" name="topic.p">
+
+ <!-- To ensure XHTML validity, need to determine whether the DITA kids are block elements.
+      If so, use div_class="p" instead of p -->
+ <xsl:choose>
+  <xsl:when test="descendant::*[contains(@class,' topic/pre ')] or
+       descendant::*[contains(@class,' topic/screen ')] or
+       descendant::*[contains(@class,' topic/ul ')] or
+       descendant::*[contains(@class,' topic/sl ')] or
+       descendant::*[contains(@class,' topic/ol ')] or
+       descendant::*[contains(@class,' topic/lq ')] or
+       descendant::*[contains(@class,' topic/dl ')] or
+       descendant::*[contains(@class,' topic/note ')] or
+       descendant::*[contains(@class,' topic/lines ')] or
+       descendant::*[contains(@class,' topic/fig ')] or
+       descendant::*[contains(@class,' topic/table ')] or
+       descendant::*[contains(@class,' topic/simpletable ')]">
+     <div class="p"><xsl:call-template name="commonattributes"/><xsl:call-template name="setidaname"/><xsl:call-template name="flagit"/><xsl:call-template name="revblock"/></div></xsl:when>
+  <xsl:otherwise><p><xsl:call-template name="commonattributes"/><xsl:call-template name="setidaname"/><xsl:call-template name="flagit"/><xsl:call-template name="revblock"/></p></xsl:otherwise>
+ </xsl:choose><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/note ')]" name="topic.note">
+ <xsl:call-template name="spec-title"/>
+  <xsl:choose>
+    <xsl:when test="@type='note'">
+     <xsl:call-template name="note"/>
+    </xsl:when>
+    <xsl:when test="@type='tip'">
+     <div class="tip">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <span class="tiptitle">
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'Tip'"/>
+       </xsl:call-template>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+       </xsl:call-template><xsl:text> </xsl:text>
+      </span>
+      <xsl:call-template name="flagit"/>
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='fastpath'">
+     <div class="fastpath">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <span class="fastpathtitle">
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'Fastpath'"/>
+       </xsl:call-template>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+       </xsl:call-template><xsl:text> </xsl:text>
+      </span>
+      <xsl:call-template name="flagit"/>
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='important'">
+     <div class="important">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <span class="importanttitle">
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'Important'"/>
+       </xsl:call-template>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+       </xsl:call-template><xsl:text> </xsl:text>
+      </span>
+      <xsl:call-template name="flagit"/>
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='remember'">
+     <div class="remember">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <span class="remembertitle">
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'Remember'"/>
+       </xsl:call-template>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+       </xsl:call-template><xsl:text> </xsl:text>
+      </span>
+      <xsl:call-template name="flagit"/>
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='restriction'">
+     <div class="restriction">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <span class="restrictiontitle">
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'Restriction'"/>
+       </xsl:call-template>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+       </xsl:call-template><xsl:text> </xsl:text>
+      </span>
+      <xsl:call-template name="flagit"/>
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='attention'">
+     <div class="attention">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <span class="attentiontitle">
+       <xsl:call-template name="flagit"/>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'Attention'"/>
+       </xsl:call-template>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+       </xsl:call-template><xsl:text> </xsl:text>
+      </span>
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='caution'">
+     <div class="cautiontitle">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <xsl:call-template name="flagit"/>
+      <xsl:call-template name="getString">
+       <xsl:with-param name="stringName" select="'Caution'"/>
+      </xsl:call-template>
+       <xsl:call-template name="getString">
+        <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+       </xsl:call-template><xsl:text> </xsl:text>
+     </div>
+     <div class="caution">
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='danger'">
+     <div class="dangertitle">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="setidaname"/>
+      <xsl:call-template name="flagit"/>
+      <xsl:call-template name="getString">
+       <xsl:with-param name="stringName" select="'Danger'"/>
+      </xsl:call-template>
+     </div>
+     <div class="danger">
+      <xsl:call-template name="commonattributes"/>
+      <xsl:call-template name="revblock"/>
+     </div>
+    </xsl:when>
+    <xsl:when test="@type='other'">
+     <xsl:choose>
+      <xsl:when test="@othertype"> 
+       <div class="note">
+       <xsl:call-template name="commonattributes"/>
+       <xsl:call-template name="setidaname"/>
+        <span class="notetitle">
+         <xsl:value-of select="@othertype"/>
+         <xsl:call-template name="getString">
+          <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+         </xsl:call-template><xsl:text> </xsl:text>
+        </span>
+        <xsl:call-template name="flagit"/>
+        <xsl:call-template name="revblock"/>
+       </div>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:call-template name="note"/> <!-- otherwise, give them the standard note -->
+      </xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:call-template name="note"/>
+    </xsl:otherwise>
+  </xsl:choose>
+ <xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template name="note">
+ <div class="note">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <span class="notetitle">
+   <xsl:call-template name="getString">
+    <xsl:with-param name="stringName" select="'Note'"/>
+   </xsl:call-template>
+   <xsl:call-template name="getString">
+    <xsl:with-param name="stringName" select="'ColonSymbol'"/>
+   </xsl:call-template><xsl:text> </xsl:text>
+  </span>
+  <xsl:call-template name="flagit"/>
+  <xsl:call-template name="revblock"/>
+ </div>
+</xsl:template>
+
+<!-- long quote (bibliographic association).
+     @reftitle contains the citation for the excerpt.
+     With a link if @href is used.  -->
+<xsl:template match="*[contains(@class,' topic/lq ')]" name="topic.lq">
+<blockquote>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagit"/>
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+    <div class="{@rev}"><xsl:apply-templates select="."  mode="lq-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+    <xsl:apply-templates select="."  mode="lq-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</blockquote><xsl:value-of select="$newline"/>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/lq ')]" mode="lq-fmt">
+  <xsl:call-template name="start-revflag"/>
+  <xsl:apply-templates/>
+  <xsl:choose>
+   <xsl:when test="@href"> <!-- Insert citation as link, use @href as-is -->
+    <br/><div style="text-align:right"><a>
+     <xsl:attribute name="href">
+      <xsl:choose>
+       <xsl:when test="contains(@href,$DITAEXT)">
+        <xsl:value-of select="substring-before(@href,$DITAEXT)"/><xsl:value-of select="$OUTEXT"/><xsl:value-of select="substring-after(@href,$DITAEXT)"/>
+       </xsl:when>
+       <xsl:otherwise>
+        <xsl:value-of select="@href"/>
+       </xsl:otherwise>
+      </xsl:choose>
+     </xsl:attribute>
+     <xsl:choose>
+      <xsl:when test="@type='external'">
+       <xsl:attribute name="target">_blank</xsl:attribute>
+      </xsl:when>
+      <xsl:otherwise><!--nop - no target needed for internal or biblio types (OR-should internal force DITA xref-like processing? What is intent? @type is only internal/external/bibliographic) --></xsl:otherwise>
+     </xsl:choose>
+     <cite><xsl:choose>
+      <xsl:when test="@reftitle"><xsl:value-of select="@reftitle"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="@href"/></xsl:otherwise>
+      </xsl:choose></cite></a></div>
+   </xsl:when>
+   <xsl:when test="@reftitle"> <!-- Insert citation text -->
+     <br/><div style="text-align:right"><cite><xsl:value-of select="@reftitle"/></cite></div>
+   </xsl:when>
+   <xsl:otherwise><!--nop - do nothing--></xsl:otherwise>
+  </xsl:choose>
+  <xsl:call-template name="end-revflag"/>
+</xsl:template>
+
+
+<!-- =========== SINGLE PART LISTS =========== -->
+
+<!-- Unordered List -->
+<!-- handle all levels thru browser processing -->
+<xsl:template match="*[contains(@class,' topic/ul ')]" name="topic.ul">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="ul-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+     <xsl:apply-templates select="."  mode="ul-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/ul ')]" mode="ul-fmt">
+ <xsl:call-template name="flagit"/>
+ <xsl:call-template name="start-revflag"/>
+ <xsl:call-template name="setaname"/>
+ <ul>
+   <xsl:call-template name="commonattributes"/>
+   <xsl:apply-templates select="@compact"/>
+   <xsl:call-template name="setid"/>
+   <xsl:apply-templates/>
+ </ul>
+ <xsl:call-template name="end-revflag"/>
+ <xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- Simple List -->
+<!-- handle all levels thru browser processing -->
+<xsl:template match="*[contains(@class,' topic/sl ')]" name="topic.sl">
+<xsl:call-template name="flagit"/>
+  <xsl:choose> <!-- draft rev mode, add div w/ rev attr value -->
+   <xsl:when test="@rev and not($FILTERFILE='') and ($DRAFT='yes')">
+    <xsl:variable name="revtest"> <!-- Flag the revision? 1=yes; 0=no -->
+     <xsl:call-template name="find-active-rev-flag">
+      <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="$revtest=1">
+      <div class="{@rev}"><xsl:apply-templates select="."  mode="sl-fmt" /></div>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:apply-templates select="."  mode="sl-fmt" />
+     </xsl:otherwise>
+    </xsl:choose>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:apply-templates select="."  mode="sl-fmt" />
+   </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/sl ')]" mode="sl-fmt">
+<xsl:call-template name="start-revflag"/>
+<xsl:call-template name="setaname"/>
+<ul class="simple">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:apply-templates select="@compact"/>
+  <xsl:call-template name="setid"/>
+  <xsl:apply-templates/>
+</ul>
+<xsl:call-template name="end-revflag"/>
+<xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- Ordered List - 1st level - Handle levels 1 to 9 thru OL-TYPE attribution -->
+<!-- Updated to use a single template, use count and mod to set the list type -->
+<xsl:template match="*[contains(@class,' topic/ol ')]" name="topic.ol">
+<xsl:variable name="olcount" select="count(ancestor-or-self::*[contains(@class,' topic/ol ')])"/>
+<xsl:call-template name="flagit"/>
+<xsl:call-template name="start-revflag"/>
+<xsl:call-template name="setaname"/>
+<ol>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:apply-templates select="@compact"/>
+  <xsl:choose>
+    <xsl:when test="$olcount mod 3 = 1"/>
+    <xsl:when test="$olcount mod 3 = 2"><xsl:attribute name="type">a</xsl:attribute></xsl:when>
+    <xsl:otherwise><xsl:attribute name="type">i</xsl:attribute></xsl:otherwise>
+  </xsl:choose>
+  <xsl:call-template name="setid"/>
+  <xsl:apply-templates/>
+</ol>
+<xsl:call-template name="end-revflag"/>
+<xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- list item -->
+<xsl:template match="*[contains(@class,' topic/li ')]" name="topic.li">
+<li>
+ <!-- handle non-compact list items -->
+ <xsl:if test="parent::*/@compact='no'">
+  <xsl:attribute name="class">liexpand</xsl:attribute>
+ </xsl:if>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagit"/>
+  <xsl:call-template name="revblock"/>
+</li><xsl:value-of select="$newline"/>
+</xsl:template>
+<!-- simple list item -->
+<xsl:template match="*[contains(@class,' topic/sli ')]" name="topic.sli">
+<li>
+ <!-- handle non-compact list items -->
+ <xsl:if test="parent::*/@compact='no'">
+  <xsl:attribute name="class">sliexpand</xsl:attribute>
+ </xsl:if>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagit"/>
+  <xsl:call-template name="revblock"/>
+</li><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- special case of getting the number of a list item referenced by xref -->
+<xsl:template match="*[contains(@class,' topic/li ')]" mode="xref">
+  <xsl:number/>
+</xsl:template>
+
+
+<!-- list item section is like li/lq but without presentation (indent) -->
+<xsl:template match="*[contains(@class,' topic/itemgroup ')]" name="topic.itemgroup">
+<!-- insert a space before all but the first itemgroups in a LI -->
+<xsl:variable name="itemgroupcount"><xsl:number count="*[contains(@class,' topic/itemgroup ')]"/></xsl:variable>
+  <xsl:if test="$itemgroupcount&gt;'1'">
+    <xsl:text> </xsl:text>
+  </xsl:if>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagcheck"/>
+  <xsl:call-template name="revtext"/>
+</xsl:template>
+
+<!-- =========== DEFINITION LIST =========== -->
+
+<!-- DL -->
+<xsl:template match="*[contains(@class,' topic/dl ')]" name="topic.dl">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="dl-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+     <xsl:apply-templates select="."  mode="dl-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/dl ')]"  mode="dl-fmt">
+<xsl:call-template name="flagit"/>
+<xsl:call-template name="start-revflag"/>
+<xsl:call-template name="setaname"/>
+<dl>
+ <!-- handle DL compacting - default=yes -->
+  <xsl:if test="@compact='no'">
+   <xsl:attribute name="class">dlexpand</xsl:attribute>
+  </xsl:if>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:apply-templates select="@compact"/>
+  <xsl:call-template name="setid"/>
+  <xsl:apply-templates/>
+</dl>
+<xsl:call-template name="end-revflag"/>
+<xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- DL entry -->
+<xsl:template match="*[contains(@class,' topic/dlentry ')]" name="topic.dlentry">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<!-- DL term -->
+<xsl:template match="*[contains(@class,' topic/dt ')]" name="topic.dt">
+<!-- insert a blank line before only the first DT in a DLENTRY; count which DT this is -->
+<xsl:variable name="dtcount"><xsl:number count="*[contains(@class,' topic/dt ')]"/></xsl:variable>
+<xsl:choose>
+ <xsl:when test="$dtcount=1">
+  <dt class="dlterm">
+   <!-- handle non-compact list items -->
+   <xsl:if test="../../@compact='no'">
+    <xsl:attribute name="class">dltermexpand</xsl:attribute>
+   </xsl:if>
+   <xsl:apply-templates select="../@xml:lang"/> <!-- Get from DLENTRY, then override with local -->
+   <xsl:call-template name="commonattributes"/>
+   <xsl:call-template name="setidaname"/>
+   <!-- handle ID on a DLENTRY -->
+    <xsl:if test="parent::*/@id">
+     <xsl:call-template name="parent-id"/>
+    </xsl:if>
+   <!-- handle non-compact DLs dl/dlentry/dt-->
+    <xsl:call-template name="flagit-parent"/>
+    <xsl:call-template name="flagit"/>
+    <xsl:call-template name="start-revflag-parent"/>
+    <xsl:call-template name="revtext"/>
+    <xsl:call-template name="end-revflag-parent"/>
+  </dt>
+ </xsl:when>
+ <xsl:otherwise><!-- DTs 2 thru N -->
+  <dt class="dlterm">
+    <xsl:apply-templates select="../@xml:lang"/> <!-- Get from DLENTRY, then override with local -->
+    <xsl:call-template name="commonattributes"/>
+    <xsl:call-template name="setidaname"/>
+    <xsl:call-template name="flagit"/>
+    <xsl:call-template name="start-revflag-parent"/>
+    <xsl:call-template name="revtext"/>
+    <xsl:call-template name="end-revflag-parent"/>
+  </dt>
+ </xsl:otherwise>
+</xsl:choose>
+<xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- DL description -->
+<xsl:template match="*[contains(@class,' topic/dd ')]" name="topic.dd">
+<!-- insert a blank line before all but the first DD in a DLENTRY; count which DD this is -->
+<xsl:variable name="ddcount"><xsl:number count="*[contains(@class,' topic/dd ')]"/></xsl:variable>
+<xsl:choose>
+ <xsl:when test="$ddcount=1">
+  <dd>
+   <xsl:apply-templates select="../@xml:lang"/> <!-- Get from DLENTRY, then override with local -->
+   <xsl:call-template name="commonattributes"/>
+   <xsl:call-template name="setidaname"/>
+   <xsl:call-template name="flagit"/>
+   <xsl:call-template name="start-revflag-parent"/>
+   <xsl:call-template name="revblock"/>
+   <xsl:call-template name="end-revflag-parent"/>
+  </dd>
+ </xsl:when>
+ <xsl:otherwise><!-- para space before 2 thru N -->
+  <dd class="ddexpand">
+   <xsl:apply-templates select="../@xml:lang"/> <!-- Get from DLENTRY, then override with local -->
+   <xsl:call-template name="commonattributes"/>
+   <xsl:call-template name="setidaname"/>
+   <xsl:call-template name="flagit"/>
+   <xsl:call-template name="start-revflag-parent"/>
+   <xsl:call-template name="revblock"/>
+   <xsl:call-template name="end-revflag-parent"/>
+  </dd>
+ </xsl:otherwise>
+</xsl:choose>
+<xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- DL heading -->
+<xsl:template match="*[contains(@class, ' topic/dlhead ')]" name="topic.dlhead">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- DL heading, term -->
+<xsl:template match="*[contains(@class,' topic/dthd ')]" name="topic.dthd">
+<dt>
+ <xsl:apply-templates select="../@xml:lang"/> <!-- Get from DLHEAD, then override with local -->
+ <xsl:call-template name="commonattributes"/>
+ <xsl:call-template name="setidaname"/>
+ <xsl:call-template name="flagit"/>
+ <xsl:call-template name="start-revflag-parent"/>
+ <strong><xsl:call-template name="revtext"/></strong>
+ <xsl:call-template name="end-revflag-parent"/>
+</dt><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- DL heading, description -->
+<xsl:template match="*[contains(@class,' topic/ddhd ')]" name="topic.ddhd">
+<dd>
+ <xsl:apply-templates select="../@xml:lang"/> <!-- Get from DLHEAD, then override with local -->
+ <xsl:call-template name="commonattributes"/>
+ <xsl:call-template name="setidaname"/>
+ <xsl:call-template name="flagit"/>
+ <xsl:call-template name="start-revflag-parent"/>
+ <strong><xsl:call-template name="revblock"/></strong>
+ <xsl:call-template name="end-revflag-parent"/>
+</dd><xsl:value-of select="$newline"/>
+</xsl:template>
+
+
+<!-- =========== PHRASES =========== -->
+
+<!-- phrase presentational style - have to use a low priority otherwise topic/ph always wins -->
+<!-- should not need priority, default is low enough -->
+
+<xsl:template match="*[contains(@class,' topic/ph ')]" name="topic.ph">
+ <span>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagcheck"/>
+  <xsl:call-template name="revtext"/></span>
+</xsl:template>
+
+<!-- keyword presentational style - have to use priority else topic/keyword always wins -->
+<!-- should not need priority, default is low enough -->
+
+<xsl:template match="*[contains(@class,' topic/keyword ')]" name="topic.keyword">
+ <span class="keyword">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagcheck"/>
+  <xsl:call-template name="revtext"/></span>
+</xsl:template>
+
+<!-- trademarks  -->
+<!-- prepare a key for each trademark tag -->
+<xsl:key name="tm"  match="*[contains(@class,' topic/tm ')]" use="."/>
+
+<!-- process the TM tag -->
+<!-- removed priority 1 : should not be needed -->
+<xsl:template match="*[contains(@class,' topic/tm ')]" name="topic.tm">
+
+  <xsl:apply-templates/> <!-- output the TM content -->
+
+  <xsl:variable name="Ltmclass">
+    <xsl:call-template name="convert-to-lower"> <!-- ensure lowercase for comparisons -->
+      <xsl:with-param name="inputval" select="@tmclass"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <!-- If this is a good class, continue... -->
+  <xsl:if test="$Ltmclass='ibm' or $Ltmclass='ibmsub' or $Ltmclass='special'">
+    <!-- Test for TM area's language -->
+    <xsl:variable name="tmtest">
+      <xsl:call-template name="tm-area"/>
+    </xsl:variable>
+
+    <!-- If this language should get trademark markers, continue... -->
+    <xsl:if test="$tmtest='tm'">
+      <xsl:variable name="tmvalue"><xsl:value-of select="@trademark"/></xsl:variable>
+
+      <!-- Determine if this is in a title, and should be marked -->
+      <xsl:variable name="usetitle">
+        <xsl:if test="ancestor::*[contains(@class,' topic/title ')]/parent::*[contains(@class,' topic/topic ')]">
+          <xsl:choose>
+            <!-- Not the first one in a title -->
+            <xsl:when test="generate-id(.)!=generate-id(key('tm',.)[1])">skip</xsl:when>
+            <!-- First one in the topic, BUT it appears in a shortdesc or body -->
+            <xsl:when test="//*[contains(@class,' topic/shortdesc ') or contains(@class,' topic/body ')]//*[contains(@class,' topic/tm ')][@trademark=$tmvalue]">skip</xsl:when>
+            <xsl:otherwise>use</xsl:otherwise>
+          </xsl:choose>
+        </xsl:if>
+      </xsl:variable>
+
+      <!-- Determine if this is in a body, and should be marked -->
+      <xsl:variable name="usebody">
+        <xsl:choose>
+          <!-- If in a title or prolog, skip -->
+          <xsl:when test="ancestor::*[contains(@class,' topic/title ') or contains(@class,' topic/prolog ')]/parent::*[contains(@class,' topic/topic ')]">skip</xsl:when>
+          <!-- If first in the document, use it -->
+          <xsl:when test="generate-id(.)=generate-id(key('tm',.)[1])">use</xsl:when>
+          <!-- If there is another before this that is in the body or shortdesc, skip -->
+          <xsl:when test="preceding::*[contains(@class,' topic/tm ')][@trademark=$tmvalue][ancestor::*[contains(@class,' topic/body ') or contains(@class,' topic/shortdesc ')]]">skip</xsl:when>
+          <!-- Otherwise, any before this must be in a title or ignored section -->
+          <xsl:otherwise>use</xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+
+      <!-- If it should be used in a title or used in the body, output your favorite TM marker based on the attributes -->
+      <xsl:if test="$usetitle='use' or $usebody='use'">
+        <xsl:choose>  <!-- ignore @tmtype=service or anything else -->
+          <xsl:when test="@tmtype='tm'">&#x2122;</xsl:when>
+          <xsl:when test="@tmtype='reg'"><sup>&#xAE;</sup></xsl:when>
+          <xsl:otherwise/>
+        </xsl:choose>
+      </xsl:if>
+    </xsl:if>
+ </xsl:if>
+</xsl:template>
+
+<!-- Test for in TM area: returns "tm" when parent's @xml:lang needs a trademark language;
+     Otherwise, leave blank.
+     Use the TM for US English and the AP languages (Japanese, Korean, and both Chinese).
+     Ignore the TM for all other languages. -->
+<xsl:template name="tm-area">
+ <xsl:variable name="parentlang">
+  <xsl:call-template name="getLowerCaseLang"/>
+ </xsl:variable>
+ <xsl:choose>
+  <xsl:when test="$parentlang='en-us' or $parentlang='en'">tm</xsl:when>
+  <xsl:when test="$parentlang='ja-jp' or $parentlang='ja'">tm</xsl:when>
+  <xsl:when test="$parentlang='ko-kr' or $parentlang='ko'">tm</xsl:when>
+  <xsl:when test="$parentlang='zh-cn' or $parentlang='zh'">tm</xsl:when>
+  <xsl:when test="$parentlang='zh-tw' or $parentlang='zh'">tm</xsl:when>
+  <xsl:otherwise/>
+ </xsl:choose>
+</xsl:template>
+
+
+<!-- phrase "semantic" classes -->
+<!-- citations -->
+<xsl:template match="*[contains(@class,' topic/cite ')]" name="topic.cite">
+<cite>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagcheck"/>
+  <xsl:call-template name="revtext"/>
+</cite>
+</xsl:template>
+
+<!-- quotes - only do 1 level, no flip-flopping -->
+<xsl:template match="*[contains(@class,' topic/q ')]" name="topic.q">
+<span class="q">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="getString">
+   <xsl:with-param name="stringName" select="'OpenQuote'"/>
+  </xsl:call-template>
+  <xsl:call-template name="flagcheck"/>
+  <xsl:call-template name="revtext"/>
+  <xsl:call-template name="getString">
+   <xsl:with-param name="stringName" select="'CloseQuote'"/>
+  </xsl:call-template>
+</span>
+</xsl:template>
+
+<!-- terms -->
+<xsl:template match="*[contains(@class,' topic/term ')]" name="topic.term">
+<dfn class="term">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="flagcheck"/>
+  <xsl:call-template name="revtext"/>
+</dfn>
+</xsl:template>
+
+
+<!-- =========== BOOLEAN-STATE DATA TYPES =========== -->
+<!-- Use color to indicate these types for now -->
+<!-- output the tag & it's state -->
+<xsl:template match="*[contains(@class,' topic/boolean ')]" name="topic.boolean">
+ <span style="color:green">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:value-of select="name()"/><xsl:text>: </xsl:text><xsl:value-of select="@state"/>
+ </span>
+</xsl:template>
+
+<!-- output the tag, it's name & value -->
+<xsl:template match="*[contains(@class,' topic/state ')]" name="topic.state">
+<span style="color:red">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:value-of select="name()"/><xsl:text>: </xsl:text><xsl:value-of select="@name"/><xsl:text>=</xsl:text><xsl:value-of select="@value"/>
+</span>
+</xsl:template>
+
+
+<!-- =========== RECORD END RESPECTING DATA =========== -->
+<!-- PRE -->
+<xsl:template match="*[contains(@class,' topic/pre ')]" name="topic.pre">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')">
+     <xsl:call-template name="find-active-rev-flag"> 
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="pre-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+     <xsl:apply-templates select="."  mode="pre-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/pre ')]" mode="pre-fmt">
+<xsl:if test="contains(@frame,'top')"><hr /></xsl:if>
+<xsl:call-template name="flagit"/>
+<xsl:call-template name="start-revflag"/>
+<xsl:call-template name="spec-title-nospace"/>
+<pre>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setscale"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:apply-templates/>
+</pre>
+<xsl:call-template name="end-revflag"/>
+<xsl:if test="contains(@frame,'bot')"><hr /></xsl:if><xsl:value-of select="$newline"/>
+</xsl:template>
+
+
+<!-- lines - body font -->
+<xsl:template match="*[contains(@class,' topic/lines ')]" name="topic.lines">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag"> 
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="lines-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+     <xsl:apply-templates select="."  mode="lines-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/lines ')]" mode="lines-fmt">
+<xsl:if test="contains(@frame,'top')"><hr /></xsl:if>
+<xsl:call-template name="flagit"/>
+<xsl:call-template name="start-revflag"/>
+<xsl:call-template name="spec-title-nospace"/>
+ <p>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setscale"/>
+  <xsl:call-template name="setidaname"/>
+  <xsl:apply-templates/>
+ </p>
+<xsl:call-template name="end-revflag"/>
+<xsl:if test="contains(@frame,'bot')"><hr /></xsl:if><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/lines ')]//text()">
+ <xsl:variable name="linetext"><xsl:value-of select="."/></xsl:variable>
+ <xsl:variable name="linetext2">
+  <xsl:call-template name="sp-replace"><xsl:with-param name="sptext" select="$linetext"/></xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="br-replace">
+  <xsl:with-param name="brtext" select="$linetext2"/>
+ </xsl:call-template>
+</xsl:template>
+
+
+<!-- =========== FIGURE =========== -->
+<xsl:template match="*[contains(@class,' topic/fig ')]" name="topic.fig">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="fig-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+     <xsl:apply-templates select="."  mode="fig-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/fig ')]" mode="fig-fmt">
+<xsl:call-template name="flagit"/>
+<xsl:call-template name="start-revflag"/>
+ <div>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setscale"/>
+  <xsl:choose>
+    <xsl:when test="@frame='all'">
+      <xsl:attribute name="class">figborder</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="@frame='sides'">
+      <xsl:attribute name="class">figsides</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="@frame='top'">
+      <xsl:attribute name="class">figtop</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="@frame='bottom'">
+      <xsl:attribute name="class">figbottom</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="@frame='topbot'">
+      <xsl:attribute name="class">figtopbot</xsl:attribute>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:attribute name="class">fignone</xsl:attribute>
+    </xsl:otherwise>
+  </xsl:choose>
+  <xsl:call-template name="setidaname"/>
+  <xsl:call-template name="place-fig-lbl"/>
+  <xsl:apply-templates select="*[not(contains(@class,' topic/title '))][not(contains(@class,' topic/desc '))] |text()|comment()|processing-instruction()"/>
+ </div>
+<xsl:call-template name="end-revflag"/>
+<xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- should not need priority, default is low enough; was set to 1 -->
+<xsl:template match="*[contains(@class,' topic/figgroup ')]" name="topic.figgroup">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')">
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="figgroup-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+     <xsl:apply-templates select="."  mode="figgroup-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/figgroup ')]" mode="figgroup-fmt">
+<xsl:call-template name="flagit"/>
+<xsl:call-template name="start-revflag"/>
+ <span>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setidaname"/>
+  <!-- Allow title to fallthrough -->
+  <xsl:apply-templates/>
+ </span>
+<xsl:call-template name="end-revflag"/>
+</xsl:template>
+
+
+<!-- =========== IMAGE/OBJECT =========== -->
+
+<xsl:template match="*[contains(@class,' topic/image ')]" name="topic.image">
+  <!-- build any pre break indicated by style -->
+  <xsl:choose>
+    <xsl:when test="parent::fig[contains(@frame,'top ')]">
+      <!-- NOP if there is already a break implied by a parent property -->
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:choose>
+      <xsl:when test="(@placement='break')"><br/>
+       <xsl:call-template name="flagit"/>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:call-template name="flagcheck"/>
+      </xsl:otherwise>
+     </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+  <xsl:call-template name="start-revflag"/>
+  <xsl:call-template name="setaname"/>
+  <xsl:choose>
+   <xsl:when test="@placement='break'"><!--Align only works for break-->
+    <xsl:choose>
+     <xsl:when test="@align='left'">
+      <div class="imageleft">
+       <xsl:call-template name="topic-image"/>
+      </div>
+     </xsl:when>
+     <xsl:when test="@align='right'">
+      <div class="imageright">
+       <xsl:call-template name="topic-image"/>
+      </div>
+     </xsl:when>
+     <xsl:when test="@align='center'">
+      <div class="imagecenter">
+       <xsl:call-template name="topic-image"/>
+      </div>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:call-template name="topic-image"/>
+     </xsl:otherwise>
+    </xsl:choose>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:call-template name="topic-image"/>
+   </xsl:otherwise>
+  </xsl:choose>
+  <xsl:call-template name="end-revflag"/>
+  <!-- build any post break indicated by style -->
+  <xsl:if test="not(@placement='inline')"><br/></xsl:if>
+  <!-- image name for review -->
+  <xsl:if test="$ARTLBL='yes'">
+    [<xsl:value-of select="@href"/>]
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="topic-image">
+  <!-- now invoke the actual content and its alt text -->
+  <xsl:element name="img">
+    <xsl:call-template name="commonattributes"/>
+    <xsl:call-template name="setid"/>
+    <xsl:apply-templates select="@href|@height|@width|@longdescref"/>
+    <xsl:choose>
+      <xsl:when test="*[contains(@class,' topic/alt')]">
+        <xsl:attribute name="alt"><xsl:value-of select="*[contains(@class,' topic/alt ')]"/></xsl:attribute>
+      </xsl:when>
+      <xsl:when test="@alt">
+        <xsl:attribute name="alt"><xsl:value-of select="@alt"/></xsl:attribute>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:element>
+</xsl:template>
+<!-- Process image attributes. Using priority, in case default @href is added at some point. -->
+<xsl:template match="*[contains(@class,' topic/image ')]/@href" priority="1">
+  <xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/image ')]/@height">
+  <xsl:attribute name="height"><xsl:value-of select="."/></xsl:attribute>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/image ')]/@width">
+  <xsl:attribute name="width"><xsl:value-of select="."/></xsl:attribute>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/image ')]/@longdescref">
+  <xsl:attribute name="longdesc">
+    <xsl:choose>
+      <xsl:when test="contains(.,$DITAEXT)">  <!-- switch extension from .dita -->
+        <xsl:value-of select="substring-before(.,$DITAEXT)"/><xsl:value-of select="$OUTEXT"/><xsl:value-of select="substring-after(.,$DITAEXT)"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="."/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:attribute>
+</xsl:template>
+
+
+<!-- object, desc, & param -->
+<xsl:template match="*[contains(@class,' topic/object ')]" name="topic.object">
+ <xsl:element name="object">
+  <xsl:if test="@id"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute></xsl:if>
+  <xsl:if test="@declare"><xsl:attribute name="declare"><xsl:value-of select="@declare"/></xsl:attribute></xsl:if>
+  <xsl:if test="@codebase"><xsl:attribute name="codebase"><xsl:value-of select="@codebase"/></xsl:attribute></xsl:if>
+  <xsl:if test="@type"><xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute></xsl:if>
+  <xsl:if test="@archive"><xsl:attribute name="archive"><xsl:value-of select="@archive"/></xsl:attribute></xsl:if>
+  <xsl:if test="@height"><xsl:attribute name="height"><xsl:value-of select="@height"/></xsl:attribute></xsl:if>
+  <xsl:if test="@usemap"><xsl:attribute name="usemap"><xsl:value-of select="@usemap"/></xsl:attribute></xsl:if>
+  <xsl:if test="@tabindex"><xsl:attribute name="tabindex"><xsl:value-of select="@tabindex"/></xsl:attribute></xsl:if>
+  <xsl:if test="@classid"><xsl:attribute name="classid"><xsl:value-of select="@classid"/></xsl:attribute></xsl:if>
+  <xsl:if test="@data"><xsl:attribute name="data"><xsl:value-of select="@data"/></xsl:attribute></xsl:if>
+  <xsl:if test="@codetype"><xsl:attribute name="codetype"><xsl:value-of select="@codetype"/></xsl:attribute></xsl:if>
+  <xsl:if test="@standby"><xsl:attribute name="standby"><xsl:value-of select="@standby"/></xsl:attribute></xsl:if>
+  <xsl:if test="@width"><xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute></xsl:if>
+  <xsl:if test="@name"><xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute></xsl:if>
+  <xsl:if test="@longdescref">
+   <xsl:call-template name="output-message">
+    <xsl:with-param name="msg">The LONGDESCREF attribute on tag "<xsl:value-of select="name(.)"/>" will be ignored. Accessibility needs to be handled another way.</xsl:with-param>
+    <xsl:with-param name="msgnum">010</xsl:with-param>
+    <xsl:with-param name="msgsev">I</xsl:with-param>
+   </xsl:call-template>
+  </xsl:if>
+  <xsl:apply-templates/>
+ <!-- Test for Flash movie; include EMBED statement for non-IE browsers -->
+ <xsl:if test="contains(@codebase,'swflash.cab')">
+  <xsl:element name="embed">
+   <xsl:if test="@id"><xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute></xsl:if>
+   <xsl:if test="@height"><xsl:attribute name="height"><xsl:value-of select="@height"/></xsl:attribute></xsl:if>
+   <xsl:if test="@width"><xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute></xsl:if>
+   <xsl:attribute name="type"><xsl:text>application/x-shockwave-flash</xsl:text></xsl:attribute>
+   <xsl:attribute name="pluginspage"><xsl:text>http://www.macromedia.com/go/getflashplayer</xsl:text></xsl:attribute>
+   <xsl:if test="./*[contains(@class,' topic/param ')]/@name='movie'">
+    <xsl:attribute name="src"><xsl:value-of select="./*[contains(@class,' topic/param ')][@name='movie']/@value"/></xsl:attribute>
+   </xsl:if>
+   <xsl:if test="./*[contains(@class,' topic/param ')]/@name='quality'">
+    <xsl:attribute name="quality"><xsl:value-of select="./*[contains(@class,' topic/param ')][@name='quality']/@value"/></xsl:attribute>
+   </xsl:if>
+   <xsl:if test="./*[contains(@class,' topic/param ')]/@name='bgcolor'">
+    <xsl:attribute name="bgcolor"><xsl:value-of select="./*[contains(@class,' topic/param ')][@name='bgcolor']/@value"/></xsl:attribute>
+   </xsl:if>
+  </xsl:element>
+ </xsl:if>
+ </xsl:element>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/param ')]" name="topic.param">
+ <xsl:element name="param">
+  <xsl:if test="@name"><xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute></xsl:if>
+  <xsl:if test="@id"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute></xsl:if>
+  <xsl:if test="@value"><xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute></xsl:if>
+ </xsl:element>
+</xsl:template>
+
+<!-- need to add test for object/desc to avoid conflicts -->
+<xsl:template match="*[contains(@class,' topic/object ')]/*[contains(@class,' topic/desc ')]" name="topic.object_desc">
+ <xsl:element name="span">
+  <xsl:if test="@name"><xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute></xsl:if>
+  <xsl:if test="@id"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute></xsl:if>
+  <xsl:if test="@value"><xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute></xsl:if>
+  <xsl:apply-templates/>
+ </xsl:element>
+</xsl:template>
+
+<!-- ===================================================================== -->
+
+<!-- =========== CALS (OASIS) TABLE =========== -->
+
+<xsl:template match="*[contains(@class,' topic/table ')]" name="topic.table">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag"> 
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="table-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+     <xsl:apply-templates select="."  mode="table-fmt" />
+   </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+<xsl:template match="*[contains(@class,' topic/table ')]" mode="table-fmt">
+ <xsl:value-of select="$newline"/>
+ <!-- special case for IE & NS for frame & no rules - needs to be a double table -->
+ <xsl:variable name="colsep">
+   <xsl:choose>
+     <xsl:when test="*[contains(@class,' topic/tgroup ')]/@colsep"><xsl:value-of select="*[contains(@class,' topic/tgroup ')]/@colsep"/></xsl:when>
+     <xsl:when test="@colsep"><xsl:value-of select="@colsep"/></xsl:when>
+   </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="rowsep">
+   <xsl:choose>
+     <xsl:when test="*[contains(@class,' topic/tgroup ')]/@rowsep"><xsl:value-of select="*[contains(@class,' topic/tgroup ')]/@rowsep"/></xsl:when>
+     <xsl:when test="@rowsep"><xsl:value-of select="@rowsep"/></xsl:when>
+   </xsl:choose>
+ </xsl:variable>
+ <xsl:choose>
+  <xsl:when test="@frame='all' and $colsep='0' and $rowsep='0'">
+    <table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td><xsl:value-of select="$newline"/>
+     <xsl:call-template name="dotable"/>
+    </td></tr></table>
+  </xsl:when>
+  <xsl:when test="not(@frame) and $colsep='0' and $rowsep='0'">
+    <table cellpadding="4" cellspacing="0" border="1" class="tableborder"><tr><td><xsl:value-of select="$newline"/>
+     <xsl:call-template name="dotable"/>
+    </td></tr></table>
+  </xsl:when>
+  <xsl:otherwise>
+   <div class="tablenoborder">
+   <xsl:call-template name="dotable"/>
+   </div>
+  </xsl:otherwise>
+ </xsl:choose><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template name="dotable">
+ <xsl:call-template name="flagit"/>
+ <xsl:call-template name="start-revflag"/>
+ <xsl:call-template name="setaname"/>
+ <table cellpadding="4" cellspacing="0" summary="">
+  <xsl:variable name="colsep">
+    <xsl:choose>
+      <xsl:when test="*[contains(@class,' topic/tgroup ')]/@colsep"><xsl:value-of select="*[contains(@class,' topic/tgroup ')]/@colsep"/></xsl:when>
+      <xsl:when test="@colsep"><xsl:value-of select="@colsep"/></xsl:when>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="rowsep">
+    <xsl:choose>
+      <xsl:when test="*[contains(@class,' topic/tgroup ')]/@rowsep"><xsl:value-of select="*[contains(@class,' topic/tgroup ')]/@rowsep"/></xsl:when>
+      <xsl:when test="@rowsep"><xsl:value-of select="@rowsep"/></xsl:when>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:call-template name="setid"/>
+  <xsl:call-template name="commonattributes"/>
+  <xsl:call-template name="setscale"/>
+  <!-- When a table's width is set to page or column, force it's width to 100%. If it's in a list, use 90%.
+       Otherwise, the table flows to the content -->
+  <xsl:choose>
+   <xsl:when test="(@expanse='page' or @pgwide='1')and (ancestor::*[contains(@class,' topic/li ')] or ancestor::*[contains(@class,' topic/dd ')] )">
+    <xsl:attribute name="width">90%</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="(@expanse='column' or @pgwide='0') and (ancestor::*[contains(@class,' topic/li ')] or ancestor::*[contains(@class,' topic/dd ')] )">
+    <xsl:attribute name="width">90%</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="(@expanse='page' or @pgwide='1')">
+    <xsl:attribute name="width">100%</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="(@expanse='column' or @pgwide='0')">
+    <xsl:attribute name="width">100%</xsl:attribute>
+   </xsl:when>
+  </xsl:choose>
+  <xsl:choose>
+   <xsl:when test="@frame='all' and $colsep='0' and $rowsep='0'">
+    <xsl:attribute name="border">0</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="not(@frame) and $colsep='0' and $rowsep='0'">
+    <xsl:attribute name="border">0</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="@frame='sides'">
+    <xsl:attribute name="frame">vsides</xsl:attribute>
+    <xsl:attribute name="border">1</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="@frame='top'">
+    <xsl:attribute name="frame">above</xsl:attribute>
+    <xsl:attribute name="border">1</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="@frame='bottom'">
+    <xsl:attribute name="frame">below</xsl:attribute>
+    <xsl:attribute name="border">1</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="@frame='topbot'">
+    <xsl:attribute name="frame">hsides</xsl:attribute>
+    <xsl:attribute name="border">1</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="@frame='none'">
+    <xsl:attribute name="frame">void</xsl:attribute>
+    <xsl:attribute name="border">1</xsl:attribute>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:attribute name="frame">border</xsl:attribute>
+    <xsl:attribute name="border">1</xsl:attribute>
+   </xsl:otherwise>
+  </xsl:choose>
+  <xsl:choose>
+   <xsl:when test="@frame='all' and $colsep='0' and $rowsep='0'">
+    <xsl:attribute name="border">0</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="not(@frame) and $colsep='0' and $rowsep='0'">
+    <xsl:attribute name="border">0</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="$colsep='0' and $rowsep='0'">
+    <xsl:attribute name="rules">none</xsl:attribute>
+    <xsl:attribute name="border">0</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="$colsep='0'">
+    <xsl:attribute name="rules">rows</xsl:attribute>
+   </xsl:when>
+   <xsl:when test="$rowsep='0'">
+    <xsl:attribute name="rules">cols</xsl:attribute>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:attribute name="rules">all</xsl:attribute>
+   </xsl:otherwise>
+  </xsl:choose>
+  <xsl:call-template name="place-tbl-lbl"/>
+  <!-- title and desc are processed elsewhere -->
+  <xsl:apply-templates select="*[contains(@class,' topic/tgroup ')]"/>
+ </table><xsl:value-of select="$newline"/>
+ <xsl:call-template name="end-revflag"/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/tgroup ')]" name="topic.tgroup">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/colspec ')]"></xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/spanspec ')]"></xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/thead ')]" name="topic.thead">
+  <thead>
+  <xsl:call-template name="commonattributes"/>
+    <xsl:choose>
+     <xsl:when test="@align">
+      <xsl:attribute name="align">
+        <xsl:value-of select="@align"/>
+      </xsl:attribute>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:call-template name="th-align"/>
+     </xsl:otherwise>
+    </xsl:choose>
+    <xsl:if test="@char">
+      <xsl:attribute name="char">
+        <xsl:value-of select="@char"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@charoff">
+      <xsl:attribute name="charoff">
+        <xsl:value-of select="@charoff"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@valign">
+      <xsl:attribute name="valign">
+        <xsl:value-of select="@valign"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates/>
+  </thead><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- Table footer processing. Ignore fall-thru tfoot; process them from the table body -->
+<xsl:template match="*[contains(@class,' topic/tfoot ')]"/>
+
+<xsl:template match="*[contains(@class,' topic/tbody ')]" name="topic.tbody">
+  <tbody>
+    <xsl:call-template name="commonattributes"/>
+    <xsl:if test="@align">
+      <xsl:attribute name="align">
+        <xsl:value-of select="@align"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@char">
+      <xsl:attribute name="char">
+        <xsl:value-of select="@char"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@charoff">
+      <xsl:attribute name="charoff">
+        <xsl:value-of select="@charoff"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@valign">
+      <xsl:attribute name="valign">
+        <xsl:value-of select="@valign"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates/>
+    <!-- process table footer -->
+    <xsl:apply-templates select="../*[contains(@class,' topic/tfoot ')]" mode="gen-tfoot" />
+  </tbody><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- special mode for table footers -->
+<xsl:template match="*[contains(@class,' topic/tfoot ')]" mode="gen-tfoot">
+  <xsl:apply-templates/><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/row ')]" name="topic.row">
+  <tr>
+    <xsl:call-template name="setid"/>
+    <xsl:call-template name="commonattributes"/>
+    <xsl:if test="@align">
+      <xsl:attribute name="align">
+        <xsl:value-of select="@align"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@char">
+      <xsl:attribute name="char">
+        <xsl:value-of select="@char"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@charoff">
+      <xsl:attribute name="charoff">
+        <xsl:value-of select="@charoff"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="@valign">
+      <xsl:attribute name="valign">
+        <xsl:value-of select="@valign"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates/>
+  </tr><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/entry ')]" name="topic.entry">
+  <xsl:choose>
+      <xsl:when test="parent::*/parent::*[contains(@class,' topic/thead ')]">
+          <xsl:call-template name="topic.thead_entry"/>
+      </xsl:when>
+      <xsl:otherwise>
+          <xsl:call-template name="topic.tbody_entry"/>
+      </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- do header entries -->
+<xsl:template name="topic.thead_entry">
+ <th>
+  <xsl:call-template name="doentry"/>
+ </th><xsl:value-of select="$newline"/>
+</xsl:template>
+
+<!-- do body entries -->
+<xsl:template name="topic.tbody_entry">
+  <xsl:variable name="startpos">
+    <xsl:if test="../../../../@rowheader='firstcol'"><xsl:call-template name="find-entry-start-position"/></xsl:if>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$startpos=1"><th><xsl:call-template name="doentry"/></th></xsl:when>
+    <xsl:otherwise><td><xsl:call-template name="doentry"/></td></xsl:otherwise>
+  </xsl:choose>
+  <xsl:value-of select="$newline"/>
+</xsl:template>
+
+<xsl:template name="doentry">
+  <xsl:call-template name="commonattributes"/>
+  <xsl:if test="@morerows">
+    <xsl:attribute name="rowspan"> <!-- set the number of rows to span -->
+      <xsl:value-of select="@morerows+1"/>
+    </xsl:attribute>
+  </xsl:if>
+  <xsl:if test="@spanname">
+    <xsl:attribute name="colspan"> <!-- get the number of columns to span from the corresponding spanspec -->
+      <xsl:call-template name="find-spanspec-colspan"/>
+    </xsl:attribute>
+  </xsl:if>
+  <xsl:if test="@namest and @nameend"> <!-- get the number of columns to span from the specified named column values -->
+    <xsl:attribute name="colspan">
+      <xsl:call-template name="find-colspan"/>
+    </xsl:attribute>
+  </xsl:if>
+  <!-- If align is on the tgroup, use it (parent=row, then tbody|thead|tfoot, then tgroup) -->
+  <xsl:if test="../../../@align">
+    <xsl:attribute name="align">
+      <xsl:value-of select="../../../@align"/>
+    </xsl:attribute>
+  </xsl:if>
+  <!-- If align is specified on a colspec or spanspec, that takes priority over tgroup -->
+  <xsl:if test="@colname">
+    <xsl:variable name="this-colname"><xsl:value-of select="@colname"/></xsl:variable>
+    <xsl:if test="../../../*[contains(@class,' topic/colspec ')][@colname=$this-colname][@align]">
+      <xsl:attribute name="align">
+        <xsl:value-of select="../../../*[contains(@class,' topic/colspec ')][@colname=$this-colname]/@align"/>
+      </xsl:attribute>
+    </xsl:if>
+  </xsl:if>
+  <xsl:if test="@spanname">
+    <xsl:variable name="this-spanname"><xsl:value-of select="@spanname"/></xsl:variable>
+    <xsl:if test="../../../*[contains(@class,' topic/spanspec ')][@spanname=$this-spanname][@align]">
+      <xsl:attribute name="align">
+        <xsl:value-of select="../../../*[contains(@class,' topic/spanspec ')][@spanname=$this-spanname]/@align"/>
+      </xsl:attribute>
+    </xsl:if>
+  </xsl:if>
+  <!-- If align is locally specified, that takes priority over all -->
+  <xsl:if test="@align">
+    <xsl:attribute name="align">
+      <xsl:value-of select="@align"/>
+    </xsl:attribute>
+  </xsl:if>
+  <xsl:if test="@char">
+    <xsl:attribute name="char">
+      <xsl:value-of select="@char"/>
+    </xsl:attribute>
+  </xsl:if>
+  <xsl:if test="@charoff">
+    <xsl:attribute name="charoff">
+      <xsl:value-of select="@charoff"/>
+    </xsl:attribute>
+  </xsl:if>
+  <xsl:choose>
+   <xsl:when test="@valign">
+    <xsl:attribute name="valign">
+      <xsl:value-of select="@valign"/>
+    </xsl:attribute>
+   </xsl:when>
+   <xsl:when test="ancestor::*[contains(@class,' topic/row ')]/@valign">
+    <xsl:attribute name="valign">
+      <xsl:value-of select="ancestor::*[contains(@class,' topic/row ')]/@valign"/>
+    </xsl:attribute>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:attribute name="valign">top</xsl:attribute>
+   </xsl:otherwise>
+  </xsl:choose>
+  <xsl:if test="../../../*[contains(@class,' topic/colspec ')]/@colwidth and
+                not(@namest) and not(@nameend) and not(@spanspec)">
+    <xsl:variable name="entrypos">    <!-- Current column -->
+      <xsl:call-template name="find-entry-start-position"/>
+    </xsl:variable>
+    <xsl:variable name="totalwidth">  <!-- Total width of the column, in units -->
+      <xsl:apply-templates select="../../../*[contains(@class,' topic/colspec ')][1]" mode="count-colwidth"/>
+    </xsl:variable>
+    <xsl:variable name="thiswidth">   <!-- Width of this column, in units -->
+      <xsl:choose>
+        <xsl:when test="../../../*[contains(@class,' topic/colspec ')][number($entrypos)]/@colwidth">
+          <xsl:value-of select="substring-before(../../../*[contains(@class,' topic/colspec ')][number($entrypos)]/@colwidth,'*')"/>
+        </xsl:when>
+        <xsl:otherwise>1</xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <!-- Width = width of this column / width of table, times 100 to make a percent -->
+    <xsl:attribute name="width">
+      <xsl:value-of select="($thiswidth div $totalwidth) * 100"/><xsl:text>%</xsl:text>
+    </xsl:attribute>
+  </xsl:if>
+
+  <!-- If @rowheader='firstcol' on table, and this entry is in the first column,
+       output an ID and the firstcol class -->
+  <xsl:if test="../../../../@rowheader='firstcol'">
+    <xsl:variable name="startpos">
+      <xsl:call-template name="find-entry-start-position"/>
+    </xsl:variable>
+    <xsl:if test="number($startpos)=1">
+      <xsl:attribute name="class">firstcol</xsl:attribute>
+      <xsl:attribute name="id">
+        <xsl:value-of select="generate-id(.)"/>
+      </xsl:attribute>
+     </xsl:if>
+  </xsl:if>
+
+  <xsl:choose>
+    <!-- When entry is in a thead, output the ID -->
+    <xsl:when test="parent::*/parent::*[contains(@class,' topic/thead ')]">
+      <xsl:attribute name="id">
+        <xsl:value-of select="generate-id(.)"/>
+      </xsl:attribute>
+    </xsl:when>
+    <!-- otherwise, add @headers if needed -->
+    <xsl:otherwise>
+      <xsl:call-template name="add-headers-attribute"/>
+    </xsl:otherwise>
+  </xsl:choose>
+
+  <xsl:choose>
+    <!-- When entry is empty, output a blank -->
+    <xsl:when test="not(*|text()|processing-instruction())">
+      <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>  <!-- nbsp -->
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:variable name="revtest">
+        <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+          <xsl:call-template name="find-active-rev-flag">               
+            <xsl:with-param name="allrevs" select="@rev"/>
+          </xsl:call-template>
+        </xsl:if>
+      </xsl:variable>
+      <xsl:variable name="revtest-row">
+        <xsl:if test="../@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+          <xsl:call-template name="find-active-rev-flag">   
+            <xsl:with-param name="allrevs" select="../@rev"/>
+          </xsl:call-template>
+        </xsl:if>
+      </xsl:variable>
+      <xsl:choose>
+        <xsl:when test="$revtest=1">   <!-- Entry Rev is active - add the span -->
+          <span class="{@rev}">
+          <xsl:call-template name="start-revflag-parent"/>
+          <xsl:call-template name="start-revflag"/>            
+          <xsl:apply-templates/>
+          <xsl:call-template name="end-revflag"/>
+          <xsl:call-template name="end-revflag-parent"/>
+          </span>
+        </xsl:when>
+        <xsl:when test="$revtest-row=1">   <!-- Row Rev is active - add the span -->
+          <span class="{../@rev}">
+          <xsl:call-template name="start-revflag-parent"/>
+          <xsl:call-template name="start-revflag"/>
+          <xsl:apply-templates/>
+          <xsl:call-template name="end-revflag"/>
+          <xsl:call-template name="end-revflag-parent"/>
+          </span>
+        </xsl:when>
+        <xsl:otherwise>  <!-- Rev wasn't active - process normally -->
+          <xsl:call-template name="start-revflag-parent"/>
+          <xsl:call-template name="start-revflag"/>
+          <xsl:apply-templates/>
+          <xsl:call-template name="end-revflag"/>
+          <xsl:call-template name="end-revflag-parent"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*[contains(@class,' topic/colspec ')]" mode="count-colwidth">
+  <xsl:param name="totalwidth">0</xsl:param> <!-- Total counted width so far -->
+  <xsl:variable name="thiswidth">            <!-- Width of this column -->
+    <xsl:choose>
+      <xsl:when test="@colwidth"><xsl:value-of select="substring-before(@colwidth,'*')"/></xsl:when>
+      <xsl:otherwise>1</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <!-- If there are more colspecs, continue, otherwise return the current count -->
+  <xsl:choose>
+    <xsl:when test="following-sibling::*[contains(@class,' topic/colspec ')]">
+      <xsl:apply-templates select="following-sibling::*[contains(@class,' topic/colspec ')][1]" mode="count-colwidth">
+        <xsl:with-param name="totalwidth" select="$totalwidth + $thiswidth"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise><xsl:value-of select="$totalwidth + $thiswidth"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- Find the starting column of an entry in a row. -->
+<xsl:template name="find-entry-start-position">
+  <xsl:choose>
+
+    <!-- if the column number is specified, use it -->
+    <xsl:when test="@colnum">
+      <xsl:value-of select="@colnum"/>
+    </xsl:when>
+
+    <!-- If there is a defined column name, check the colspans to determine position -->
+    <xsl:when test="@colname">
+      <!-- count the number of colspans before the one this entry references, plus one -->
+      <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=current()/@colname]/preceding-sibling::*)+1)"/>
+    </xsl:when>
+
+    <!-- If the starting column is defined, check colspans to determine position -->
+    <xsl:when test="@namest">
+      <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=current()/@namest]/preceding-sibling::*)+1)"/>
+    </xsl:when>
+
+    <!-- Need a test for spanspec -->
+    <xsl:when test="@spanname">
+      <xsl:variable name="startspan">  <!-- starting column for this span -->
+        <xsl:value-of select="../../../*[contains(@class,' topic/spanspec ')][@spanname=current()/@spanname]/@namest"/>
+      </xsl:variable>
+      <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$startspan]/preceding-sibling::*)+1)"/>
+    </xsl:when>
+
+    <!-- Otherwise, just use the count of cells in this row -->
+    <xsl:otherwise>
+      <xsl:variable name="prev-sib">
+        <xsl:value-of select="count(preceding-sibling::*)"/>
+      </xsl:variable>
+      <xsl:value-of select="$prev-sib+1"/>
+    </xsl:otherwise>
+
+  </xsl:choose>
+</xsl:template>
+
+<!-- Find the end column of a cell. If the cell does not span any columns,
+     the end position is the same as the start position. -->
+<xsl:template name="find-entry-end-position">
+  <xsl:param name="startposition" select="0"/>
+  <xsl:choose>
+    <xsl:when test="@nameend">
+      <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=current()/@nameend]/preceding-sibling::*)+1)"/>
+    </xsl:when>
+    <xsl:when test="@spanname">
+      <xsl:variable name="endspan">  <!-- starting column for this span -->
+        <xsl:value-of select="../../../*[contains(@class,' topic/spanspec ')][@spanname=current()/@spanname]/@nameend"/>
+      </xsl:variable>
+      <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$endspan]/preceding-sibling::*)+1)"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$startposition"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- Check <thead> entries, and return IDs for those which match the desired column -->
+<xsl:template match="*[contains(@class,' topic/thead ')]/*[contains(@class,' topic/row ')]/*[contains(@class,' topic/entry ')]" mode="findmatch">
+  <xsl:param name="startmatch">1</xsl:param>  <!-- start column of the tbody cell -->
+  <xsl:param name="endmatch">1</xsl:param>    <!-- end column of the tbody cell -->
+  <xsl:variable name="entrystartpos">         <!-- start column of this thead cell -->
+    <xsl:call-template name="find-entry-start-position"/>
+  </xsl:variable>
+  <xsl:variable name="entryendpos">           <!-- end column of this thead cell -->
+    <xsl:call-template name="find-entry-end-position">
+      <xsl:with-param name="startposition" select="$entrystartpos"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:choose>
+    <!-- Ignore this header cell if it  starts after the tbody cell we are testing -->
+    <xsl:when test="number($endmatch) &lt; number($entrystartpos)"/>
+    <!-- Ignore this header cell if it ends before the tbody cell we are testing -->
+    <xsl:when test="number($startmatch) > number($entryendpos)"/>
+    <!-- Otherwise, this header lines up with the tbody cell, so use the ID -->
+    <xsl:otherwise>
+      <xsl:value-of select="generate-id(.)"/><xsl:text> </xsl:text>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- Check the first column for entries that line up with the test row.
+     Any entries that line up need to have the header saved. This template is first
+     called with the first entry of the first row in <tbody>. It is called from here
+     on the next cell in column one.            -->
+<xsl:template match="*[contains(@class,' topic/entry ')]" mode="check-first-column">
+  <xsl:param name="startMatchRow" select="1"/>   <!-- First row of the tbody cell we are matching -->
+  <xsl:param name="endMatchRow" select="1"/>     <!-- Last row of the tbody cell we are matching -->
+  <xsl:param name="startCurrentRow" select="1"/> <!-- First row of the column-1 cell we are testing -->
+  <xsl:variable name="endCurrentRow">            <!-- Last row of the column-1 cell we are testing -->
+    <xsl:choose>
+      <!-- If @morerows, the cell ends at startCurrentRow + @morerows. Otherise, start=end. -->
+      <xsl:when test="@morerows"><xsl:value-of select="number($startCurrentRow)+number(@morerows)"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$startCurrentRow"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:choose>
+    <!-- When the current column-1 cell ends before the tbody cell we are matching -->
+    <xsl:when test="number($endCurrentRow) &lt; number($startMatchRow)">
+      <!-- Call this template again with the next entry in column one -->
+      <xsl:if test="parent::*/parent::*/*[number($endCurrentRow)+1]">
+        <xsl:apply-templates select="parent::*/parent::*/*[number($endCurrentRow)+1]/*[1]" mode="check-first-column">
+          <xsl:with-param name="startMatchRow" select="$startMatchRow"/>
+          <xsl:with-param name="endMatchRow" select="$endMatchRow"/>
+          <xsl:with-param name="startCurrentRow" select="number($endCurrentRow)+1"/>
+        </xsl:apply-templates>
+      </xsl:if>
+    </xsl:when>
+    <!-- If this column-1 cell starts after the tbody cell we are matching, jump out of recursive loop -->
+    <xsl:when test="number($startCurrentRow) &gt; number($endMatchRow)"/>
+    <!-- Otherwise, the column-1 cell is aligned with the tbody cell, so save the ID and continue -->
+    <xsl:otherwise>
+      <xsl:value-of select="generate-id(.)"/><xsl:text> </xsl:text>
+      <!-- If we are not at the end of the tbody cell, and more rows exist, continue testing column 1 -->
+      <xsl:if test="number($endCurrentRow) &lt; number($endMatchRow) and
+                    parent::*/parent::*/*[number($endCurrentRow)+1]">
+        <xsl:apply-templates select="parent::*/parent::*/*[number($endCurrentRow)+1]/*[1]" mode="check-first-column">
+          <xsl:with-param name="startMatchRow" select="$startMatchRow"/>
+          <xsl:with-param name="endMatchRow" select="$endMatchRow"/>
+          <xsl:with-param name="startCurrentRow" select="number($endCurrentRow)+1"/>
+        </xsl:apply-templates>
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- Add @headers to cells in the body of a table. -->
+<xsl:template name="add-headers-attribute">
+  <!-- Determine the start column for the current cell -->
+  <xsl:variable name="entrystartpos">
+    <xsl:call-template name="find-entry-start-position"/>
+  </xsl:variable>
+  <!-- Determine the end column for the current cell -->
+  <xsl:variable name="entryendpos">
+    <xsl:call-template name="find-entry-end-position">
+      <xsl:with-param name="startposition" select="$entrystartpos"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <!-- Find the IDs of headers that are aligned above this cell. This is done by applying
+       templates on all headers, using mode=findmatch; matching IDs are returned. -->
+  <xsl:variable name="hdrattr">
+    <xsl:apply-templates select="../../../*[contains(@class,' topic/thead ')]/*[contains(@class,' topic/row ')]/*" mode="findmatch">
+      <xsl:with-param name="startmatch" select="$entrystartpos"/>
+      <xsl:with-param name="endmatch" select="$entryendpos"/>
+    </xsl:apply-templates>
+  </xsl:variable>
+  <!-- Find the IDs of headers in the first column, which are aligned with this cell -->
+  <xsl:variable name="rowheader">
+    <!-- If this entry is not in the first column or in thead, and @rowheader=firstcol on table -->
+    <xsl:if test="not(number($entrystartpos)=1) and
+                  not(parent::*/parent::*[contains(@class,' topic/thead ')]) and
+                  ../../../../@rowheader='firstcol'">
+      <!-- Find the start row for this entry -->
+      <xsl:variable name="startrow" select="number(count(parent::*/preceding-sibling::*)+1)"/>
+      <!-- Find the end row for this entry -->
+      <xsl:variable name="endrow">
+        <xsl:if test="@morerows"><xsl:value-of select="number($startrow) + number(@morerows)"/></xsl:if>
+        <xsl:if test="not(@morerows)"><xsl:value-of select="$startrow"/></xsl:if>
+      </xsl:variable>
+      <!-- Scan first-column entries for ones that align with this cell, starting with
+           the first entry in the first row -->
+      <xsl:apply-templates select="../../*[contains(@class,' topic/row ')][1]/*[contains(@class,' topic/entry ')][1]" mode="check-first-column">
+        <xsl:with-param name="startMatchRow" select="$startrow"/>
+        <xsl:with-param name="endMatchRow" select="$endrow"/>
+      </xsl:apply-templates>
+    </xsl:if>
+  </xsl:variable>
+   <xsl:if test="string-length($rowheader)>0 or string-length($hdrattr)>0">
+    <xsl:attribute name="headers"><xsl:value-of select="$rowheader"/><xsl:value-of select="$hdrattr"/></xsl:attribute>
+  </xsl:if>
+</xsl:template>
+
+<!-- Find the number of column spans between name-start and name-end attrs -->
+<xsl:template name="find-colspan">
+  <xsl:variable name="startpos">
+    <xsl:call-template name="find-entry-start-position"/>
+  </xsl:variable>
+  <xsl:variable name="endpos">
+    <xsl:call-template name="find-entry-end-position"/>
+  </xsl:variable>
+  <xsl:value-of select="$endpos - $startpos + 1"/>
+</xsl:template>
+
+<xsl:template name="find-spanspec-colspan">
+  <xsl:variable name="spanname"><xsl:value-of select="@spanname"/></xsl:variable>
+  <xsl:variable name="startcolname">
+    <xsl:value-of select="../../../*[contains(@class,' topic/spanspec ')][@spanname=$spanname][1]/@namest"/>
+  </xsl:variable>
+  <xsl:variable name="endcolname">
+    <xsl:value-of select="../../../*[contains(@class,' topic/spanspec ')][@spanname=$spanname][1]/@nameend"/>
+  </xsl:variable>
+  <xsl:variable name="startpos">
+   <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$startcolname]/preceding-sibling::*)+1)"/>
+  </xsl:variable>
+  <xsl:variable name="endpos">
+   <xsl:value-of select="number(count(../../../*[contains(@class,' topic/colspec ')][@colname=$endcolname]/preceding-sibling::*)+1)"/>
+  </xsl:variable>
+  <xsl:value-of select="$endpos - $startpos + 1"/>
+</xsl:template>
+
+<!-- end of table section -->
+
+
+<!-- ===================================================================== -->
+
+<!-- =========== SimpleTable - SEMANTIC TABLE =========== -->
+
+<xsl:template match="*[contains(@class,' topic/simpletable ')]" name="topic.simpletable">
+ <xsl:variable name="revtest">
+   <xsl:if test="@rev and not($FILTERFILE='') and ($DRAFT='yes')"> 
+     <xsl:call-template name="find-active-rev-flag">
+       <xsl:with-param name="allrevs" select="@rev"/>
+     </xsl:call-template>
+   </xsl:if>
+ </xsl:variable>
+ <xsl:choose>
+   <xsl:when test="$revtest=1">   <!-- Rev is active - add the DIV -->
+     <div class="{@rev}"><xsl:apply-templates select="."  mode="simpletable-fmt" /></div>
+   </xsl:when>
+   <xsl:otherwise>  <!-- Rev wasn't active - process normally -->

[... 1789 lines stripped ...]