]> err.no Git - varnish/commitdiff
Lightweight XSL stylesheet for transforming DocBook XML to XHTML, with
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 24 Feb 2006 15:01:14 +0000 (15:01 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 24 Feb 2006 15:01:14 +0000 (15:01 +0000)
accompanying CSS stylesheet.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@26 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-doc/share/docbook-html.css [new file with mode: 0644]
varnish-doc/share/docbook-html.xsl [new file with mode: 0644]

diff --git a/varnish-doc/share/docbook-html.css b/varnish-doc/share/docbook-html.css
new file mode 100644 (file)
index 0000000..b9011bd
--- /dev/null
@@ -0,0 +1,45 @@
+/* $Id$ */
+
+body {
+       margin: 1in;
+       background-color: white;
+       color: black;
+}
+
+h1.book-title {
+       font-size: 200%;
+       font-weight: bold;
+}
+
+h1.article-title {
+       font-size: 200%;
+       font-weight: bold;
+}
+
+span.title1 {
+       color: maroon;
+       font-weight: bold;
+       font-size: xx-large;
+}
+
+span.title2 {
+       color: maroon;
+       font-weight: bold;
+       font-size: x-large;
+}
+
+span.title3 {
+       color: maroon;
+       font-weight: bold;
+       font-size: large;
+}
+
+span.title4 {
+       color: maroon;
+       font-weight: bold;
+}
+
+span.title5 {
+       color: maroon;
+       font-weight: bold;
+}
diff --git a/varnish-doc/share/docbook-html.xsl b/varnish-doc/share/docbook-html.xsl
new file mode 100644 (file)
index 0000000..8ffd1e6
--- /dev/null
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  This XSL stylesheet will transform a DocBook XML document into
+  XHTML 1.0 Transitional.  It does not cover the entire DocBook
+  schema, and is primarily meant for previewing DocBook documents
+  in a browser.
+  -->
+<xsl:stylesheet
+    version="1.0"
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <xsl:output
+      method="html" encoding="utf-8" indent="yes"
+      doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+      doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
+
+  <xsl:template match="/book">
+    <html>
+      <head>
+       <title>
+         <xsl:call-template name="book-title"/>
+       </title>
+       <link rel="stylesheet" type="text/css" href="docbook-html.css"/>
+      </head>
+      <body>
+       <h1 class="book-title">
+         <xsl:call-template name="book-title"/>
+       </h1>
+       <xsl:apply-templates select="chapter|appendix|bibliography"/>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="/article">
+    <html>
+      <head>
+       <title>
+         <xsl:call-template name="article-title"/>
+       </title>
+       <link rel="stylesheet" type="text/css" href="docbook-html.css"/>
+      </head>
+      <body>
+       <h1 class="article-title">
+         <xsl:call-template name="article-title"/>
+       </h1>
+       <xsl:apply-templates select="section|appendix|bibliography"/>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="chapter">
+    <xsl:param name="level" select="1"/>
+    <div class="chapter">
+      <xsl:apply-templates>
+       <xsl:with-param name="level" select="$level + 1"/>
+      </xsl:apply-templates>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="section">
+    <xsl:param name="level" select="1"/>
+    <div class="section">
+      <xsl:apply-templates>
+       <xsl:with-param name="level" select="$level + 1"/>
+      </xsl:apply-templates>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="appendix">
+    <xsl:param name="level" select="1"/>
+    <div class="appendix">
+      <xsl:apply-templates>
+       <xsl:with-param name="level" select="$level + 1"/>
+      </xsl:apply-templates>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="bibliography">
+    <xsl:param name="level"/>
+    <div class="bibliography">
+      <xsl:apply-templates>
+       <xsl:with-param name="level" select="$level + 1"/>
+      </xsl:apply-templates>
+    </div>
+  </xsl:template>
+
+  <xsl:template name="article-title">
+    <xsl:choose>
+      <xsl:when test="articleinfo/title">
+       <xsl:value-of select="articleinfo/title"/>
+      </xsl:when>
+      <xsl:when test="title">
+       <xsl:value-of select="title"/>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:text>Unnamed DocBook Article</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="book-title">
+    <xsl:choose>
+      <xsl:when test="bookinfo/title">
+       <xsl:value-of select="bookinfo/title"/>
+      </xsl:when>
+      <xsl:when test="title">
+       <xsl:value-of select="title"/>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:text>Unnamed DocBook Book</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="title">
+    <xsl:param name="level" select="1"/>
+    <xsl:element name="span">
+      <xsl:attribute name="class">
+       <xsl:value-of select="concat('title', $level)"/>
+      </xsl:attribute>
+      <xsl:apply-templates/>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="itemizedlist">
+    <ul>
+      <xsl:apply-templates/>
+    </ul>
+  </xsl:template>
+
+  <xsl:template match="orderedlist">
+    <ol>
+      <xsl:apply-templates/>
+    </ol>
+  </xsl:template>
+
+  <xsl:template match="listitem">
+    <li>
+      <xsl:apply-templates/>
+    </li>
+  </xsl:template>
+
+  <xsl:template match="para">
+    <p>
+      <xsl:apply-templates/>
+    </p>
+  </xsl:template>
+
+  <xsl:template match="*" priority="-1">
+    <!--xsl:message>Warning: no template for element <xsl:value-of select="name()"/></xsl:message-->
+    <xsl:value-of select="concat('&lt;', name(), '&gt;')"/>
+    <xsl:apply-templates/>
+    <xsl:value-of select="concat('&lt;/', name(), '&gt;')"/>
+  </xsl:template>
+</xsl:stylesheet>