You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2002/01/21 01:07:07 UTC
cvs commit: jakarta-commons/latka/xsl/site docbook2document.xsl
dion 02/01/20 16:07:07
Added: latka/xsl/site docbook2document.xsl
Log:
First cut at docbook to site format (document)
Revision Changes Path
1.1 jakarta-commons/latka/xsl/site/docbook2document.xsl
Index: docbook2document.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="book">
<body>
<title><xsl:value-of select="title"/></title>
<center>
<table width="80%">
<tr>
<td bgcolor="#F3DD61">
<br/>
<center>
<b>
<font color="#000000" face="arial,helvetica,sanserif">
<xsl:value-of select="title"/>
<xsl:if test="subtitle"><xsl:text>: </xsl:text>
<xsl:value-of select="subtitle"/>
</xsl:if>
</font>
</b>
</center>
<br/>
</td>
</tr>
</table>
</center>
<br/>
<xsl:apply-templates select="dedication"/>
<xsl:apply-templates select="bookinfo"/>
</body>
</xsl:template>
<xsl:template match="chapter|article|appendix">
<document>
<properties>
<title>
<xsl:value-of select="title"/>
<xsl:if test="subtitle">
(<xsl:value-of select="subtitle"/>)
</xsl:if>
</title>
<xsl:for-each select="//authorgroup/author">
<author email="{address/email}">
<xsl:if test="honorific"><xsl:value-of select="honorific"/>. </xsl:if>
<xsl:if test="firstname"><xsl:value-of select="firstname"/> </xsl:if>
<xsl:value-of select="surname"/>
</author>
</xsl:for-each>
<author email="commons-dev@jakarta.apache.org">
Commons Documentation Team
</author>
</properties>
<!-- FIXME:
plan to remove all html formatting from the stylesheet unless it's
translating the docbook tags across -->
<body>
<xsl:apply-templates select="para"/>
<xsl:apply-templates select="section">
<xsl:with-param name="level" select="1"/>
</xsl:apply-templates>
<xsl:apply-templates select="//footnote" mode="base"/>
</body>
</document>
</xsl:template>
<xsl:template match="title|subtitle"/>
<!-- FIXME: Where would this match? -->
<xsl:template match="author">
<p>
<xsl:value-of select="honorific"/><xsl:text>. </xsl:text>
<xsl:value-of select="firstname"/><xsl:text> </xsl:text>
<xsl:value-of select="surname"/>
</p>
<xsl:text>Author: </xsl:text>
<xsl:value-of select="honorific"/><xsl:text>. </xsl:text>
<xsl:value-of select="firstname"/><xsl:text> </xsl:text>
<xsl:value-of select="surname"/>
<xsl:text>Affiliations</xsl:text>
<ul>
<xsl:apply-templates select="affiliation"/>
</ul>
<xsl:apply-templates select="authorblurb"/>
</xsl:template>
<xsl:template match="affiliation">
<li>
<xsl:text>[</xsl:text><xsl:value-of select="shortaffil"/><xsl:text>] </xsl:text>
<b><xsl:value-of select="jobtitle"/></b>
<i><xsl:value-of select="orgname"/><xsl:if test="orgdiv"><xsl:text>/</xsl:text><xsl:value-of select="orgdiv"/></xsl:if></i>
</li>
</xsl:template>
<xsl:template match="authorblurb">
<xsl:text>Bio</xsl:text>
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="honorific|firstname|surname|orgdiv|orgname|shortaffil|jobtitle"/>
<xsl:template match="revhistory">
<section name="Revision History">
<xsl:variable name="unique-revisions"
select="revision[not(revnumber=preceding-sibling::revision/revnumber)]/revnumber"/>
<xsl:variable name="base" select="."/>
<xsl:for-each select="$unique-revisions">
<p>Revision <xsl:value-of select="."/>
(<xsl:value-of select="$base/revision[revnumber=current()]/date"/>)
</p>
<ul>
<xsl:apply-templates select="$base/revision[revnumber=current()]"/>
</ul>
</xsl:for-each>
</section>
</xsl:template>
<xsl:template match="para">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="emphasis"><em><xsl:apply-templates/></em></xsl:template>
<xsl:template match="revision">
<li>
<xsl:choose>
<xsl:when test="@revisionflag='added'">
<img align="absmiddle" alt="added" border="0" src="images/add.jpg"/>
</xsl:when>
<xsl:when test="@revisionflag='changed'">
<img align="absmiddle" alt="changed" border="0" src="images/update.jpg"/>
</xsl:when>
<xsl:when test="@revisionflag='deleted'">
<img align="absmiddle" alt="deleted" border="0" src="images/remove.jpg"/>
</xsl:when>
<xsl:when test="@revisionflag='off'">
<img align="absmiddle" alt="off" border="0" src="images/fix.jpg"/>
</xsl:when>
<xsl:otherwise>
<img align="absmiddle" alt="changed" border="0" src="images/update.jpg"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="revremark"/>
<xsl:text> (</xsl:text><xsl:value-of select="authorinitials"/><xsl:text>)</xsl:text>
</li>
</xsl:template>
<xsl:template match="revnumber|revremark|authorinitials|date"/>
<xsl:template match="section">
<xsl:param name="level"/>
<xsl:choose>
<xsl:when test="number($level)=1">
<section name="{title}">
<xsl:apply-templates>
<xsl:with-param name="level" select="number($level)+1"/>
</xsl:apply-templates>
</section>
</xsl:when>
<xsl:when test="number($level)=2">
<subsection name="{title}">
<xsl:apply-templates>
<xsl:with-param name="level" select="number($level)+1"/>
</xsl:apply-templates>
</subsection>
</xsl:when>
<xsl:otherwise>
<p><em><xsl:value-of select="title"/></em>
<br />
<xsl:apply-templates>
<xsl:with-param name="level" select="number($level)+1"/>
</xsl:apply-templates>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="bookinfo">
<b><xsl:value-of select="edition"/></b><xsl:text> </xsl:text>
<i>pub. <xsl:value-of select="pubdate"/></i>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="dedication">
<b>Dedication</b>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="edition|pubdate|year|holder"/>
<xsl:template match="copyright">
<p>Copyright ©<xsl:value-of select="year"/> by
<xsl:value-of select="holder"/>.<br/>
<i>All rights reserved.</i>
</p>
</xsl:template>
<xsl:template match="legalnotice">
<p>Legal Notice</p>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="programlisting">
<pre>
<xsl:apply-templates/>
</pre>
</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="itemizedlist"><ul><xsl:apply-templates/></ul></xsl:template>
<xsl:template match="classname|function|parameter"><code><xsl:apply-templates/><xsl:if test="name(.)='function'"><xsl:text>()</xsl:text></xsl:if></code></xsl:template>
<xsl:template match="blockquote">
<xsl:if test="title">
<blockquote><xsl:value-of select="title"/></blockquote>
</xsl:if>
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="warning">
<xsl:if test="title">
<p><em><xsl:value-of select="title"/></em></p>
</xsl:if>
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="ulink"><a href="{@url}"><xsl:apply-templates/></a></xsl:template>
<xsl:template match="footnote">
<sup><a href="#{generate-id(.)}"><xsl:value-of select="generate-id(.)"/></a>
</sup>
</xsl:template>
<xsl:template match="footnote" mode="base">
<a name="{generate-id(.)}"/><xsl:value-of select="generate-id(.)"/><xsl:text>) </xsl:text><i><xsl:value-of select="."/></i>
</xsl:template>
<xsl:template match="figure">
<p>Figure: <xsl:value-of select="title"/></p>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="graphic">
<img border="0" alt="{@srccredit}" src="{@fileref}"/>
<xsl:if test="@srccredit">
<ul><li><xsl:value-of select="@srccredit"/></li></ul>
</xsl:if>
</xsl:template>
<xsl:template match="table">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="tgroup">
<xsl:apply-templates select="thead|tbody|tfoot"/>
</xsl:template>
<xsl:template match="thead">
<xsl:apply-templates select="row" mode="head"/>
</xsl:template>
<xsl:template match="row" mode="head">
<th><xsl:apply-templates/></th>
</xsl:template>
<xsl:template match="row">
<tr><xsl:apply-templates/></tr>
</xsl:template>
<xsl:template match="tbody|tfoot">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="entry">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="firstterm">
<i><xsl:apply-templates/></i>
</xsl:template>
<xsl:template match="remark">
<p><b>Note:</b> <xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="trademark"><xsl:apply-templates/><sup>TM</sup></xsl:template>
<xsl:template match="node()|@*" priority="-1">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>