Appendix E. Stylesheets

Table of Contents

E.1. html-prex.xsl
[Note]

Note to self: Need to add section on stylesheets, and all the XML and CSS stylesheets here.

E.1. html-prex.xsl

<?xml version='1.0'?>
<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">

  <!-- Copies the whole tree, with attributes. -->
  <xsl:template match="node()|@*">
    <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>
  </xsl:template>

  <!-- Changes markup for programlisting. If the pathname is relative, it
       strips off the first '../', because that is used only for the SGML
       that operates from a subdirectory.-->
  <xsl:template match="programlisting">

    <xsl:variable name="fref" select="inlinemediaobject/imageobject/imagedata/@fileref"/>
    <xsl:variable name="filenm">
      <xsl:choose>
      <!-- Note to self: change this to simply $fref after switching from SGML to XML,
           take out the choose/otherwise option, and rewrite all paths without the
           first '../' -->
        <xsl:when test="(substring($fref, 1, 3)) = string('../')">
          <xsl:value-of select="substring($fref, 4)"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$fref"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    
    <programlisting>
      <xsl:text disable-output-escaping="yes">&lt;xi:include  href=&quot;</xsl:text>
      <xsl:value-of select="$filenm"/>
      <xsl:text disable-output-escaping="yes">&quot; parse=&quot;text&quot;
      xmlns:xi=&quot;http://www.w3.org/2001/XInclude&quot;/></xsl:text>
    </programlisting>
  </xsl:template>


</xsl:stylesheet>