1<?xml version="1.0" encoding="utf-8"?> 2<!-- 3 Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com> 4 5 Distributed under the Boost Software License, Version 1.0. 6 (See accompanying file LICENSE_1_0.txt or copy at 7 http://www.boost.org/LICENSE_1_0.txt) 8 --> 9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 10 version="1.0"> 11 12 <!-- Import the man pages stylesheet --> 13 <xsl:import 14 href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/> 15 16 <xsl:param name="generate.manifest" select="1"/> 17 <xsl:param name="manifest">man.manifest</xsl:param> 18 19 <xsl:template match="literallayout"> 20 <xsl:text> .nf </xsl:text> 21 <xsl:apply-templates/> 22 <xsl:text> .fi </xsl:text> 23 </xsl:template> 24 25 <xsl:template match="para|simpara|remark" mode="list"> 26 <xsl:variable name="foo"> 27 <xsl:apply-templates/> 28 </xsl:variable> 29 <xsl:choose> 30 <xsl:when test="literallayout"> 31 <xsl:copy-of select="$foo"/> 32 </xsl:when> 33 <xsl:otherwise> 34 <xsl:value-of select="normalize-space($foo)"/> 35 </xsl:otherwise> 36 </xsl:choose> 37 <xsl:text> </xsl:text> 38 <xsl:if test="following-sibling::para or following-sibling::simpara or 39 following-sibling::remark"> 40 <!-- Make sure multiple paragraphs within a list item don't --> 41 <!-- merge together. --> 42 <xsl:text> </xsl:text> 43 </xsl:if> 44 </xsl:template> 45 46 <xsl:template name="build.refentry.filename"> 47 <xsl:param name="node" select="."/> 48 <xsl:variable name="section" select="$node/refmeta/manvolnum"/> 49 <xsl:variable name="name" select="$node/refnamediv/refname[1]"/> 50 <xsl:value-of select="concat('man', $section, '/', 51 translate(normalize-space($name), 52 '<>', '__'), 53 '.', $section)"/> 54 55 </xsl:template> 56 57 <xsl:template match="refentry" mode="manifest"> 58 <xsl:call-template name="build.refentry.filename"/> 59 <xsl:text> </xsl:text> 60 </xsl:template> 61 62 <xsl:template match="/"> 63 <xsl:choose> 64 <xsl:when test="//refentry"> 65 <xsl:apply-templates select="//refentry"/> 66 <xsl:if test="$generate.manifest=1"> 67 <xsl:call-template name="write.text.chunk"> 68 <xsl:with-param name="filename" select="$manifest"/> 69 <xsl:with-param name="content"> 70 <xsl:value-of select="$manifest"/> 71 <xsl:text> </xsl:text> 72 <xsl:apply-templates select="//refentry" mode="manifest"/> 73 </xsl:with-param> 74 </xsl:call-template> 75 </xsl:if> 76 </xsl:when> 77 <xsl:otherwise> 78 <xsl:message>No refentry elements!</xsl:message> 79 </xsl:otherwise> 80 </xsl:choose> 81 </xsl:template> 82 83<xsl:template match="refentry"> 84 <xsl:variable name="section" select="refmeta/manvolnum"/> 85 <xsl:variable name="name" select="refnamediv/refname[1]"/> 86 87 <!-- standard man page width is 64 chars; 6 chars needed for the two 88 (x) volume numbers, and 2 spaces, leaves 56 --> 89 <xsl:variable name="twidth" select="(56 - string-length(refmeta/refentrytitle)) div 2"/> 90 91 <xsl:variable name="reftitle" 92 select="substring(refmeta/refentrytitle, 1, $twidth)"/> 93 94 <xsl:variable name="title"> 95 <xsl:choose> 96 <xsl:when test="refentryinfo/title"> 97 <xsl:value-of select="refentryinfo/title"/> 98 </xsl:when> 99 <xsl:when test="../referenceinfo/title"> 100 <xsl:value-of select="../referenceinfo/title"/> 101 </xsl:when> 102 </xsl:choose> 103 </xsl:variable> 104 105 <xsl:variable name="date"> 106 <xsl:choose> 107 <xsl:when test="refentryinfo/date"> 108 <xsl:value-of select="refentryinfo/date"/> 109 </xsl:when> 110 <xsl:when test="../referenceinfo/date"> 111 <xsl:value-of select="../referenceinfo/date"/> 112 </xsl:when> 113 </xsl:choose> 114 </xsl:variable> 115 116 <xsl:variable name="productname"> 117 <xsl:choose> 118 <xsl:when test="refentryinfo/productname"> 119 <xsl:value-of select="refentryinfo/productname"/> 120 </xsl:when> 121 <xsl:when test="../referenceinfo/productname"> 122 <xsl:value-of select="../referenceinfo/productname"/> 123 </xsl:when> 124 </xsl:choose> 125 </xsl:variable> 126 127 <xsl:call-template name="write.text.chunk"> 128 <xsl:with-param name="filename"> 129 <xsl:call-template name="build.refentry.filename"/> 130 </xsl:with-param> 131 <xsl:with-param name="content"> 132 <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source. 133.de Sh \" Subsection 134.br 135.if t .Sp 136.ne 5 137.PP 138\fB\\$1\fR 139.PP 140.. 141.de Sp \" Vertical space (when we can't use .PP) 142.if t .sp .5v 143.if n .sp 144.. 145.de Ip \" List item 146.br 147.ie \\n(.$>=3 .ne \\$3 148.el .ne 3 149.IP "\\$1" \\$2 150.. 151.TH "</xsl:text> 152 <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> 153 <xsl:text>" </xsl:text> 154 <xsl:value-of select="refmeta/manvolnum[1]"/> 155 <xsl:text> "</xsl:text> 156 <xsl:value-of select="normalize-space($date)"/> 157 <xsl:text>" "</xsl:text> 158 <xsl:value-of select="normalize-space($productname)"/> 159 <xsl:text>" "</xsl:text> 160 <xsl:value-of select="$title"/> 161 <xsl:text>" 162</xsl:text> 163 <xsl:apply-templates/> 164 <xsl:text> </xsl:text> 165 166 <!-- Author section --> 167 <xsl:choose> 168 <xsl:when test="refentryinfo//author"> 169 <xsl:apply-templates select="refentryinfo" mode="authorsect"/> 170 </xsl:when> 171 <xsl:when test="/book/bookinfo//author"> 172 <xsl:apply-templates select="/book/bookinfo" mode="authorsect"/> 173 </xsl:when> 174 <xsl:when test="/article/articleinfo//author"> 175 <xsl:apply-templates select="/article/articleinfo" mode="authorsect"/> 176 </xsl:when> 177 </xsl:choose> 178 179 </xsl:with-param> 180 </xsl:call-template> 181 <!-- Now generate stub include pages for every page documented in 182 this refentry (except the page itself) --> 183 <xsl:for-each select="refnamediv/refname"> 184 <xsl:if test=". != $name"> 185 <xsl:call-template name="write.text.chunk"> 186 <xsl:with-param name="filename" 187 select="concat(normalize-space(.), '.', $section)"/> 188 <xsl:with-param name="content" select="concat('.so man', 189 $section, '/', $name, '.', $section, ' ')"/> 190 </xsl:call-template> 191 </xsl:if> 192 </xsl:for-each> 193</xsl:template> 194 195</xsl:stylesheet> 196