Created Debian package
[xmldoc.git] / html.xsl
index 8e4a16e..ac20845 100644 (file)
--- a/html.xsl
+++ b/html.xsl
 <?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
 
 <xsl:strip-space elements="doc chapter section"/>
-<xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
+<xsl:output method="xml" indent="yes" encoding="iso-8859-1"
+            doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"
+            doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"/>
 
 <xsl:template match="doc">
-<html>
+<xsl:element name="html" namespace="http://www.w3.org/1999/xhtml">
 <head>
+   <meta charset="utf-8"/>
    <link>
    <xsl:attribute name="rel">stylesheet</xsl:attribute>
    <xsl:attribute name="type">text/css</xsl:attribute>
    <xsl:attribute name="href"><xsl:value-of select="@style"/></xsl:attribute>
    </link>
    <title>
+      <xsl:if test='not(*/titlepage/title)'>
+      -
+      </xsl:if>
       <xsl:value-of select="*/titlepage/title"/>
    </title>
+   <style type="text/css">
+      .center
+      {
+         text-align : center ;
+      }
+      table.docinfo
+      {
+         margin-left  : 10% ;
+         margin-right : 10% ;
+         border-style : solid ;
+      }
+      th
+      {
+         border-style : solid ;
+         border-width : thin ;
+      }
+      h3.toc
+      {
+         margin-left : 2em ;
+      }
+      pre.example
+      {
+         border : solid ;
+         padding-bottom : 1em ;
+      }
+      span.red
+      {
+         color : red ;
+      }
+      span.green
+      {
+         color : green ;
+      }
+      span.blue
+      {
+         color : blue ;
+      }
+      span.cyan
+      {
+         color : cyan ;
+      }
+      span.magenta
+      {
+         color : magenta ;
+      }
+      span.yellow
+      {
+         color : yellow ;
+      }
+      span.orange
+      {
+         color : orange ;
+      }
+      span.violet
+      {
+         color : violet ;
+      }
+      span.purple
+      {
+         color : purple ;
+      }
+      span.brown
+      {
+         color : brown ;
+      }
+      span.pink
+      {
+         color : pink ;
+      }
+      span.olive
+      {
+         color : olive ;
+      }
+      span.black
+      {
+         color : black ;
+      }
+      span.darkgray
+      {
+         color : darkgray ;
+      }
+      span.gray
+      {
+         color : gray ;
+      }
+      span.lightgray
+      {
+         color : lightgray ;
+      }
+      span.white
+      {
+         color : white ;
+      }
+   </style>
 </head>
+
 <body>
    <xsl:apply-templates/>
    <hr/>
    <xsl:apply-templates select="//footnote" mode="footnotes"/>
 </body>
-</html>
+</xsl:element>
 </xsl:template>
 
 <xsl:template match="titlepage">
 </xsl:template>
 
 <xsl:template match="docinfo">
-   <center><table border="2" width="90%">
+   <table class="docinfo">
    <tr><th colspan="2">Document Information</th></tr>
    <xsl:apply-templates/>
-   </table></center>
+   </table>
 </xsl:template>
 
 <xsl:template match="infoitem">
 
 <xsl:template match="abstract">
    <blockquote>
-   <b>Abstract:</b><br/>
+   <p><b>Abstract:</b></p>
+   <p>
    <xsl:apply-templates/>
+   </p>
    </blockquote>
 </xsl:template>
 
    <xsl:value-of select="heading"/>
    </a>
    </h2>
-   <ul>
    <xsl:for-each select="section">
-      <h3>
+      <h3 class="toc">
       <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
       <a>
       <xsl:attribute name="href">#SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
       </a>
       </h3>
    </xsl:for-each>
-   </ul>
 </xsl:for-each>
 <hr></hr>
 </xsl:template>
      <xsl:number count="chapter"/>
      <xsl:text>  </xsl:text>
       <a>
-      <xsl:attribute name="name">CH<xsl:number count="chapter"/></xsl:attribute>
+      <xsl:attribute name="id">CH<xsl:number count="chapter"/></xsl:attribute>
       </a>
      <xsl:apply-templates/>
    </h1>
    <h2>
      <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
      <a>
-     <xsl:attribute name="name">SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
+     <xsl:attribute name="id">SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
      </a>
      <xsl:apply-templates/>
    </h2>
 </xsl:template>
 
 <xsl:template match="quote">
-   <blockquote>
+   <blockquote><p>
      <xsl:apply-templates/>
-   </blockquote>
+   </p></blockquote>
 </xsl:template>
 
 <xsl:template match="verbatim">
 </pre>
 </xsl:template>
 
+<xsl:template match="example">
+<pre class='example'>
+ <xsl:apply-templates/>
+</pre>
+</xsl:template>
+
 <xsl:template match="itemize">
 <ul>
    <xsl:apply-templates/>
 </ol>
 </xsl:template>
 
-<xsl:template match="item">
+<xsl:template match="description">
+<dl>
+   <xsl:apply-templates/>
+</dl>
+</xsl:template>
+
+<xsl:template match="itemize/item">
 <li>
    <xsl:apply-templates/>
 </li>
 </xsl:template>
 
+<xsl:template match="enumerate/item">
+<li>
+   <xsl:apply-templates/>
+</li>
+</xsl:template>
+
+<xsl:template match="description/item">
+<dt><xsl:value-of select='@tag'/></dt>
+<dd>
+   <xsl:apply-templates/>
+</dd>
+</xsl:template>
+
 <xsl:template match="footnote">
 <sup><a>
   <xsl:attribute name='href'>#footnote<xsl:number level='any'/></xsl:attribute>
 </xsl:template>
 
 <xsl:template match="footnote" mode="footnotes">
-<sup><a><xsl:attribute name='name'>footnote<xsl:number level='any'/></xsl:attribute>
-        <xsl:number level='any'/></a></sup> <xsl:apply-templates/><br/>
-
+<p>
+<sup><a><xsl:attribute name='id'>footnote<xsl:number level='any'/></xsl:attribute>
+        <xsl:number level='any'/></a></sup> <xsl:apply-templates/>
+</p>
 </xsl:template>
 
 <xsl:template match="emph">
 <sup><xsl:apply-templates/></sup>
 </xsl:template>
 
+<xsl:template match="color">
+<span><xsl:attribute name="class"><xsl:value-of select="@colorname"/></xsl:attribute><xsl:apply-templates/></span>
+</xsl:template>
+
+<xsl:template match="big">
+<big><xsl:apply-templates/></big>
+</xsl:template>
+
+<xsl:template match="small">
+<small><xsl:apply-templates/></small>
+</xsl:template>
+
 <xsl:template match="table">
 <table>
 <xsl:apply-templates/>
 </table>
 </xsl:template>
 
+<xsl:template match="newline"><br/></xsl:template>
 
 <xsl:template match="row">
 <tr><xsl:apply-templates/></tr>
 </xsl:template>
 
 <xsl:template match="label">
-   <a><xsl:attribute name='name'>
+   <a><xsl:attribute name='id'>
       <xsl:value-of select="@name"/>
    </xsl:attribute></a>
 </xsl:template>
 
+<xsl:template match="index"></xsl:template>
+
 <xsl:template match="ref">
    <a><xsl:attribute name='href'>#<xsl:value-of select="@to"/></xsl:attribute>
      <xsl:apply-templates/>
-     <xsl:apply-templates select="id(@to)" mode="section-number"/>
+     <!--<xsl:apply-templates select="id(@to)" mode="section-number"/>-->
    </a>
 </xsl:template>
 
 </a>
 </xsl:template>
 
-</xsl:stylesheet>
+<xsl:template match="math">
+<xsl:element name="math" namespace="http://www.w3.org/1998/Math/MathML">
+   <xsl:copy-of select='./*'/>
+</xsl:element>
+</xsl:template>
+
+<xsl:template match="svg">
+<xsl:if test='@src'>
+   <xsl:copy-of select="document(@src)"/>
+</xsl:if>
+<xsl:if test='not(@src)'>
+   <xsl:element name="svg" namespace="http://www.w3.org/2000/svg">
+      <xsl:copy-of select='./*'/>
+   </xsl:element>
+</xsl:if>
+</xsl:template>
+
 
+
+</xsl:stylesheet>