Move expansion of Samba-specific XML elements out of xslt/latex.xsl into a
authorJelmer Vernooij <jelmer@samba.org>
Fri, 1 May 2009 18:51:43 +0000 (20:51 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 1 May 2009 20:49:12 +0000 (22:49 +0200)
separate file, for better readability. xslt/latex.xsl now only contains
tweaks to the dblatex configuration.

docs-xml/xslt/latex.xsl
docs-xml/xslt/latex/samba.xsl [new file with mode: 0644]

index 9f6abdb1acb95485eb0fd2c64b4685c510ebef21..5bc6deb8c1e4d9c72720c91ae1bc43c09b9f8e70 100644 (file)
@@ -1,11 +1,15 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'
        xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+
        <!-- Remove bits from the manual pages that are not relevant for the HOWTO Collection, 
        such as author info, etc -->
-<xsl:import href="strip-references.xsl"/>
+       <xsl:import href="strip-references.xsl"/>
+
+       <!-- Handle Samba-specific elements -->
+       <xsl:import href="latex/samba.xsl"/>
 
-<xsl:param name="latex.mapping.xml" select="document('latex.overrides.xml')"/>
+       <xsl:param name="latex.mapping.xml" select="document('latex.overrides.xml')"/>
 
 <xsl:param name="generate.toc">
        /appendix toc,title
        set       toc,title
 </xsl:param>
 
-<!-- Show real name of the link rather then user specified description 
-<xsl:template match="link">
-       <xsl:variable name="target" select="key('id',@linkend)[1]"/>
-       <xsl:variable name="refelem" select="local-name($target)"/>
-       <xsl:if test="$refelem=''">
-               <xsl:message><xsl:text>XRef to nonexistent id: </xsl:text><xsl:value-of select="@linkend"/></xsl:message>
-               <xsl:text>XrefId[?</xsl:text>
-               <xsl:apply-templates/>
-               <xsl:text>?]</xsl:text>
-       </xsl:if>
-
-       <xsl:call-template name="generate.hyperlink">
-               <xsl:with-param name="target" select="$target"/>
-               <xsl:with-param name="text">
-                       <xsl:call-template name="generate.xref.text">
-                               <xsl:with-param name="target" select="$target"/>
-                       </xsl:call-template>
-               </xsl:with-param>
-       </xsl:call-template>
-</xsl:template>
--->
-
 <xsl:output method="text" encoding="UTF-8" indent="yes"/>
 <xsl:variable name="l10n.gentext.default.language" select="'en'"/>
 <xsl:variable name="latex.example.caption.style"></xsl:variable>
 <xsl:variable name="ulink.footnotes" select="1"/>
 <xsl:variable name="ulink.show" select="0"/>
 
-<xsl:template name="user.params.set2">
-       <xsl:text>\usepackage{samba}&#10;</xsl:text>
-</xsl:template>
-
-<xsl:template match="smbconfblock/smbconfoption">
-       <xsl:text>      </xsl:text><xsl:value-of select="@name"/>
-       <xsl:if test="text() != ''">
-               <xsl:text> = </xsl:text>
-               <xsl:value-of select="text()"/>
-       </xsl:if>
-       <xsl:text>&#10;</xsl:text>
-</xsl:template>
-
-<xsl:template match="smbconfblock/smbconfcomment">
-       <xsl:text># </xsl:text>
-       <xsl:apply-templates/>
-       <xsl:text>&#10;</xsl:text>
-</xsl:template>
-
-<xsl:template match="smbconfblock/smbconfsection">
-       <xsl:value-of select="@name"/>
-       <xsl:text>&#10;</xsl:text>
-</xsl:template>
-
-<xsl:template match="smbconfoption">
-       <xsl:text>\smbconfoption{</xsl:text>
-       <xsl:call-template name="scape">
-               <xsl:with-param name="string" select="@name"/>
-       </xsl:call-template>
-       <xsl:text>}</xsl:text>
-
-       <xsl:choose>
-               <xsl:when test="text() != ''">
-                       <xsl:text> = </xsl:text>
-                       <xsl:call-template name="scape">
-                               <xsl:with-param name="string" select="text()"/>
-                       </xsl:call-template>
-               </xsl:when>
-       </xsl:choose>
-</xsl:template>
-
-<xsl:template match="smbconfblock">
-       <xsl:text>&#10;\begin{lstlisting}[language=smbconf,style=smbconfblock]&#10;</xsl:text>
-       <xsl:apply-templates/>
-       <xsl:text>\end{lstlisting}&#10;</xsl:text>
-</xsl:template>
-
-<xsl:template match="smbconfsection">
-       <xsl:text>\smbconfsection{</xsl:text>
-       <xsl:call-template name="scape">
-               <xsl:with-param name="string" select="@name"/>
-       </xsl:call-template>
-       <xsl:text>}</xsl:text>
-</xsl:template>
-
+<!-- The 'imagefile' element, so we can use images without three layers of XML elements -->
 <xsl:template match="imagefile">
        <xsl:text>\includegraphics[scale=</xsl:text>
        <xsl:choose>
        <xsl:value-of select="text()"/>
        <xsl:text>}&#10;</xsl:text>
 </xsl:template>
-
-<!-- smb.conf documentation -->
-
-<xsl:template match="description"><xsl:apply-templates/></xsl:template>
-
-<xsl:template match="value"><xsl:apply-templates/></xsl:template>
-
-<xsl:template match="synonym"><xsl:apply-templates/></xsl:template>
-
-<xsl:template match="related"><xsl:apply-templates/></xsl:template>
-
-<xsl:template match="//samba:parameterlist">
-       <xsl:text>\begin{description}&#10;</xsl:text>
-       <xsl:apply-templates>
-               <xsl:sort select="samba:parameter/@name"/>
-       </xsl:apply-templates>
-       <xsl:text>\end{description}&#10;</xsl:text>
-</xsl:template>
-
-<xsl:template match="value/comment">
-       <xsl:text>&#10;# </xsl:text>
-       <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="/">
-       <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="refentry">
-       <xsl:text>\section{</xsl:text><xsl:value-of select="refmeta/refentrytitle"/><xsl:text>}&#10;</xsl:text>
-       <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="//samba:parameter">
-       <xsl:for-each select="synonym">
-               <xsl:text>\item[{</xsl:text><xsl:value-of select="."/><xsl:text>}]\null{}&#10;</xsl:text>
-       <xsl:text>\index{</xsl:text><xsl:value-of select="."/><xsl:text>}&#10;</xsl:text>
-       <xsl:text>This parameter is a synonym for \smbconfoption{</xsl:text><xsl:value-of select="../@name"/><xsl:text>}.</xsl:text>
-       </xsl:for-each>
-
-       <xsl:text>\item[{</xsl:text><xsl:value-of select="@name"/>
-       <xsl:text> (</xsl:text>
-       <xsl:value-of select="@context"/>
-       <xsl:text>)</xsl:text>
-       <xsl:text>}]\null{}&#10;&#10;</xsl:text>
-       <xsl:text>\index{</xsl:text><xsl:value-of select="@name"/><xsl:text>}&#10;</xsl:text>
-
-       <!-- Print default value-->
-       <xsl:text>&#10;</xsl:text>
-       <xsl:text>Default: </xsl:text>
-       <xsl:text>\emph{</xsl:text>
-       <xsl:choose>
-               <xsl:when test="value[@type='default'] != ''">
-                       <xsl:value-of select="@name"/>
-                       <xsl:text> = </xsl:text>
-                       <xsl:apply-templates select="value"/>
-               </xsl:when>
-               <xsl:otherwise>
-                       <xsl:text>No default</xsl:text>
-               </xsl:otherwise>
-       </xsl:choose>
-       <xsl:text>}</xsl:text>
-       <xsl:text>&#10;</xsl:text>
-
-       <!-- Generate list of examples -->
-       <xsl:text>&#10;</xsl:text>
-       <xsl:for-each select="value[@type='example']">
-               <xsl:text>&#10;</xsl:text>
-               <xsl:text>Example: </xsl:text>
-               <xsl:text>\emph{</xsl:text><xsl:value-of select="../@name"/>
-               <xsl:text> = </xsl:text>
-               <xsl:apply-templates select="."/>
-               <xsl:text>}</xsl:text>
-               <xsl:text>&#10;</xsl:text>
-       </xsl:for-each>
-
-       <!-- Description -->
-       <xsl:apply-templates select="description"/>
-</xsl:template>
-
 </xsl:stylesheet>
diff --git a/docs-xml/xslt/latex/samba.xsl b/docs-xml/xslt/latex/samba.xsl
new file mode 100644 (file)
index 0000000..9fc27e6
--- /dev/null
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+       Expand Samba-specific XML elements to LaTeX, for use with dblatex
+
+       Copyright (C) 2003,2004,2009 Jelmer Vernooij <jelmer@samba.org>
+       Published under the GNU GPLv3 or later
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'
+       xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+
+<!-- FIXME: dblatex should have some way to load additional packages, user.params.set2 
+       isn't really meant for this sort of thing -->
+<xsl:template name="user.params.set2">
+       <xsl:text>\usepackage{samba}&#10;</xsl:text>
+</xsl:template>
+
+<xsl:template match="smbconfblock/smbconfoption">
+       <xsl:text>      </xsl:text><xsl:value-of select="@name"/>
+       <xsl:if test="text() != ''">
+               <xsl:text> = </xsl:text>
+               <xsl:value-of select="text()"/>
+       </xsl:if>
+       <xsl:text>&#10;</xsl:text>
+</xsl:template>
+
+<xsl:template match="smbconfblock/smbconfcomment">
+       <xsl:text># </xsl:text>
+       <xsl:apply-templates/>
+       <xsl:text>&#10;</xsl:text>
+</xsl:template>
+
+<xsl:template match="smbconfblock/smbconfsection">
+       <xsl:value-of select="@name"/>
+       <xsl:text>&#10;</xsl:text>
+</xsl:template>
+
+<xsl:template match="smbconfoption">
+       <xsl:text>\smbconfoption{</xsl:text>
+       <xsl:call-template name="scape">
+               <xsl:with-param name="string" select="@name"/>
+       </xsl:call-template>
+       <xsl:text>}</xsl:text>
+
+       <xsl:choose>
+               <xsl:when test="text() != ''">
+                       <xsl:text> = </xsl:text>
+                       <xsl:call-template name="scape">
+                               <xsl:with-param name="string" select="text()"/>
+                       </xsl:call-template>
+               </xsl:when>
+       </xsl:choose>
+</xsl:template>
+
+<xsl:template match="smbconfblock">
+       <xsl:text>&#10;\begin{lstlisting}[language=smbconf,style=smbconfblock]&#10;</xsl:text>
+       <xsl:apply-templates/>
+       <xsl:text>\end{lstlisting}&#10;</xsl:text>
+</xsl:template>
+
+<xsl:template match="smbconfsection">
+       <xsl:text>\smbconfsection{</xsl:text>
+       <xsl:call-template name="scape">
+               <xsl:with-param name="string" select="@name"/>
+       </xsl:call-template>
+       <xsl:text>}</xsl:text>
+</xsl:template>
+
+
+<xsl:template match="description"><xsl:apply-templates/></xsl:template>
+
+<xsl:template match="value"><xsl:apply-templates/></xsl:template>
+
+<xsl:template match="synonym"><xsl:apply-templates/></xsl:template>
+
+<xsl:template match="related"><xsl:apply-templates/></xsl:template>
+
+<xsl:template match="//samba:parameterlist">
+       <xsl:text>\begin{description}&#10;</xsl:text>
+       <xsl:apply-templates>
+               <xsl:sort select="samba:parameter/@name"/>
+       </xsl:apply-templates>
+       <xsl:text>\end{description}&#10;</xsl:text>
+</xsl:template>
+
+<xsl:template match="value/comment">
+       <xsl:text>&#10;# </xsl:text>
+       <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="/">
+       <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="refentry">
+       <xsl:text>\section{</xsl:text><xsl:value-of select="refmeta/refentrytitle"/><xsl:text>}&#10;</xsl:text>
+       <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="//samba:parameter">
+       <xsl:for-each select="synonym">
+               <xsl:text>\item[{</xsl:text><xsl:value-of select="."/><xsl:text>}]\null{}&#10;</xsl:text>
+       <xsl:text>\index{</xsl:text><xsl:value-of select="."/><xsl:text>}&#10;</xsl:text>
+       <xsl:text>This parameter is a synonym for \smbconfoption{</xsl:text><xsl:value-of select="../@name"/><xsl:text>}.</xsl:text>
+       </xsl:for-each>
+
+       <xsl:text>\item[{</xsl:text><xsl:value-of select="@name"/>
+       <xsl:text> (</xsl:text>
+       <xsl:value-of select="@context"/>
+       <xsl:text>)</xsl:text>
+       <xsl:text>}]\null{}&#10;&#10;</xsl:text>
+       <xsl:text>\index{</xsl:text><xsl:value-of select="@name"/><xsl:text>}&#10;</xsl:text>
+
+       <!-- Print default value-->
+       <xsl:text>&#10;</xsl:text>
+       <xsl:text>Default: </xsl:text>
+       <xsl:text>\emph{</xsl:text>
+       <xsl:choose>
+               <xsl:when test="value[@type='default'] != ''">
+                       <xsl:value-of select="@name"/>
+                       <xsl:text> = </xsl:text>
+                       <xsl:apply-templates select="value"/>
+               </xsl:when>
+               <xsl:otherwise>
+                       <xsl:text>No default</xsl:text>
+               </xsl:otherwise>
+       </xsl:choose>
+       <xsl:text>}</xsl:text>
+       <xsl:text>&#10;</xsl:text>
+
+       <!-- Generate list of examples -->
+       <xsl:text>&#10;</xsl:text>
+       <xsl:for-each select="value[@type='example']">
+               <xsl:text>&#10;</xsl:text>
+               <xsl:text>Example: </xsl:text>
+               <xsl:text>\emph{</xsl:text><xsl:value-of select="../@name"/>
+               <xsl:text> = </xsl:text>
+               <xsl:apply-templates select="."/>
+               <xsl:text>}</xsl:text>
+               <xsl:text>&#10;</xsl:text>
+       </xsl:for-each>
+
+       <!-- Description -->
+       <xsl:apply-templates select="description"/>
+</xsl:template>
+
+</xsl:stylesheet>