[2] | 1 | <?xml version='1.0'?>
|
---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 3 | xmlns:exsl="http://exslt.org/common"
|
---|
| 4 | xmlns:dyn="http://exslt.org/dynamic"
|
---|
| 5 | xmlns:saxon="http://icl.com/saxon"
|
---|
| 6 | exclude-result-prefixes="exsl dyn saxon"
|
---|
| 7 | version='1.0'>
|
---|
| 8 |
|
---|
| 9 | <!-- ********************************************************************
|
---|
| 10 | $Id: utility.xsl,v 1.5 2005/08/09 09:11:02 xmldoc Exp $
|
---|
| 11 | ********************************************************************
|
---|
| 12 |
|
---|
| 13 | This file is part of the XSL DocBook Stylesheet distribution.
|
---|
| 14 | See ../README or http://docbook.sf.net/release/xsl/current/ for
|
---|
| 15 | copyright and other information.
|
---|
| 16 |
|
---|
| 17 | ******************************************************************** -->
|
---|
| 18 |
|
---|
| 19 | <!-- ==================================================================== -->
|
---|
| 20 |
|
---|
| 21 | <!-- * This file contains "utility" templates that are called multiple -->
|
---|
| 22 | <!-- * times per each Refentry. -->
|
---|
| 23 |
|
---|
| 24 | <!-- ==================================================================== -->
|
---|
| 25 |
|
---|
| 26 | <!-- * NOTE TO DEVELOPERS: For ease of maintenance, the current -->
|
---|
| 27 | <!-- * manpages stylesheets use the mode="bold" and mode="italic" -->
|
---|
| 28 | <!-- * templates for *anything and everything* that needs to get -->
|
---|
| 29 | <!-- * boldfaced or italicized. -->
|
---|
| 30 | <!-- * -->
|
---|
| 31 | <!-- * So if you add anything that needs bold or italic character -->
|
---|
| 32 | <!-- * formatting, try to apply these templates to it rather than -->
|
---|
| 33 | <!-- * writing separate code to format it. This can be a little odd if -->
|
---|
| 34 | <!-- * the content you want to format is not element content; in those -->
|
---|
| 35 | <!-- * cases, you need to turn it into element content before applying -->
|
---|
| 36 | <!-- * the template; see examples of this in the existing code. -->
|
---|
| 37 |
|
---|
| 38 | <xsl:template mode="bold" match="*">
|
---|
| 39 | <xsl:for-each select="node()">
|
---|
| 40 | <xsl:text>\fB</xsl:text>
|
---|
| 41 | <xsl:apply-templates select="."/>
|
---|
| 42 | <xsl:text>\fR</xsl:text>
|
---|
| 43 | </xsl:for-each>
|
---|
| 44 | </xsl:template>
|
---|
| 45 |
|
---|
| 46 | <xsl:template mode="italic" match="*">
|
---|
| 47 | <xsl:for-each select="node()">
|
---|
| 48 | <xsl:text>\fI</xsl:text>
|
---|
| 49 | <xsl:apply-templates select="."/>
|
---|
| 50 | <xsl:text>\fR</xsl:text>
|
---|
| 51 | </xsl:for-each>
|
---|
| 52 | </xsl:template>
|
---|
| 53 |
|
---|
| 54 | <!-- ================================================================== -->
|
---|
| 55 |
|
---|
| 56 | <!-- * NOTE TO DEVELOPERS: For ease of maintenance, the current -->
|
---|
| 57 | <!-- * manpages stylesheets use the mode="prevent.line.breaking" -->
|
---|
| 58 | <!-- * templates for *anything and everything* that needs to have -->
|
---|
| 59 | <!-- * embedded spaces turned into no-break spaces in output - in -->
|
---|
| 60 | <!-- * order to prevent that output from getting broken across lines -->
|
---|
| 61 | <!-- * -->
|
---|
| 62 | <!-- * So if you add anything that whose output, try to apply this -->
|
---|
| 63 | <!-- * template to it rather than writing separate code to format -->
|
---|
| 64 | <!-- * it. This can be a little odd if the content you want to -->
|
---|
| 65 | <!-- * format is not element content; in those cases, you need to -->
|
---|
| 66 | <!-- * turn it into element content before applying the template; -->
|
---|
| 67 | <!-- * see examples of this in the existing code. -->
|
---|
| 68 | <!-- * -->
|
---|
| 69 | <!-- * This template is currently called by the funcdef and paramdef -->
|
---|
| 70 | <!-- * and group/arg templates. -->
|
---|
| 71 | <xsl:template mode="prevent.line.breaking" match="*">
|
---|
| 72 | <xsl:variable name="rcontent">
|
---|
| 73 | <xsl:apply-templates/>
|
---|
| 74 | </xsl:variable>
|
---|
| 75 | <xsl:variable name="content">
|
---|
| 76 | <xsl:value-of select="normalize-space($rcontent)"/>
|
---|
| 77 | </xsl:variable>
|
---|
| 78 | <xsl:call-template name="string.subst">
|
---|
| 79 | <xsl:with-param name="string" select="$content"/>
|
---|
| 80 | <xsl:with-param name="target" select="' '"/>
|
---|
| 81 | <!-- * We output a real nobreak space here (rather than, "\ ", -->
|
---|
| 82 | <!-- * the roff nobreak space) because, when we do character-map -->
|
---|
| 83 | <!-- * processing before final output, the character-map will -->
|
---|
| 84 | <!-- * handle conversion of the   to "\ " for us -->
|
---|
| 85 | <xsl:with-param name="replacement" select="' '"/>
|
---|
| 86 | </xsl:call-template>
|
---|
| 87 | </xsl:template>
|
---|
| 88 |
|
---|
| 89 | <!-- ================================================================== -->
|
---|
| 90 |
|
---|
| 91 | <xsl:template name="suppress.hyphenation">
|
---|
| 92 | <!-- * we need to suppress hyphenation inline only if hyphenation is -->
|
---|
| 93 | <!-- * actually on, and even then only outside of Cmdsynopsis and -->
|
---|
| 94 | <!-- * Funcsynopsis, where it is already always turned off -->
|
---|
| 95 | <xsl:if test="$man.hyphenate != 0 and
|
---|
| 96 | not(ancestor::cmdsynopsis) and
|
---|
| 97 | not(ancestor::funcsynopsis)">
|
---|
| 98 | <xsl:text>\%</xsl:text>
|
---|
| 99 | </xsl:if>
|
---|
| 100 | </xsl:template>
|
---|
| 101 |
|
---|
| 102 | <!-- ================================================================== -->
|
---|
| 103 |
|
---|
| 104 | <!-- * The nested-section-title template is called for refsect3, and any -->
|
---|
| 105 | <!-- * refsection nested more than 2 levels deep, and for formalpara. -->
|
---|
| 106 | <xsl:template name="nested-section-title">
|
---|
| 107 | <!-- * The next few lines are some arcane roff code to control line -->
|
---|
| 108 | <!-- * spacing after headings. -->
|
---|
| 109 | <xsl:text>.sp </xsl:text>
|
---|
| 110 | <xsl:text>.it 1 an-trap </xsl:text>
|
---|
| 111 | <xsl:text>.nr an-no-space-flag 1 </xsl:text>
|
---|
| 112 | <xsl:text>.nr an-break-flag 1 </xsl:text>
|
---|
| 113 | <xsl:text>.br </xsl:text>
|
---|
| 114 | <!-- * make title wrapper so that we can use mode="bold" template to -->
|
---|
| 115 | <!-- * apply character formatting to it -->
|
---|
| 116 | <xsl:variable name="title.wrapper">
|
---|
| 117 | <bold><xsl:choose>
|
---|
| 118 | <xsl:when test="title">
|
---|
| 119 | <xsl:value-of select="normalize-space(title[1])"/>
|
---|
| 120 | </xsl:when>
|
---|
| 121 | <xsl:otherwise>
|
---|
| 122 | <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
|
---|
| 123 | </xsl:otherwise>
|
---|
| 124 | </xsl:choose></bold>
|
---|
| 125 | </xsl:variable>
|
---|
| 126 | <xsl:call-template name="mark.subheading"/>
|
---|
| 127 | <xsl:apply-templates mode="bold" select="exsl:node-set($title.wrapper)"/>
|
---|
| 128 | <xsl:text> </xsl:text>
|
---|
| 129 | <xsl:call-template name="mark.subheading"/>
|
---|
| 130 | </xsl:template>
|
---|
| 131 |
|
---|
| 132 | <!-- ================================================================== -->
|
---|
| 133 |
|
---|
| 134 | <!-- * The mixed-block template jumps through a few hoops to deal with -->
|
---|
| 135 | <!-- * mixed-content blocks, so that we don't end up munging verbatim -->
|
---|
| 136 | <!-- * environments or lists and so that we don't gobble up whitespace -->
|
---|
| 137 | <!-- * when we shouldn't -->
|
---|
| 138 | <xsl:template name="mixed-block">
|
---|
| 139 | <xsl:for-each select="node()">
|
---|
| 140 | <xsl:choose>
|
---|
| 141 | <!-- * Check to see if this node is a verbatim environment. -->
|
---|
| 142 | <!-- * If so, put a line of space before it. -->
|
---|
| 143 | <!-- * -->
|
---|
| 144 | <!-- * Yes, address and synopsis are vertabim environments. -->
|
---|
| 145 | <!-- * -->
|
---|
| 146 | <!-- * The code here previously also treated informaltable as a -->
|
---|
| 147 | <!-- * verbatim, presumably to support some kludge; I removed it -->
|
---|
| 148 | <xsl:when test="self::address|self::literallayout|self::programlisting|
|
---|
| 149 | self::screen|self::synopsis">
|
---|
| 150 | <xsl:text> </xsl:text>
|
---|
| 151 | <xsl:text>.sp </xsl:text>
|
---|
| 152 | <xsl:apply-templates select="."/>
|
---|
| 153 | </xsl:when>
|
---|
| 154 | <!-- * Check to see if this node is a list; if it is, we don't -->
|
---|
| 155 | <!-- * want to normalize-space(), so we just apply-templates -->
|
---|
| 156 | <xsl:when test="(self::itemizedlist|self::orderedlist|
|
---|
| 157 | self::variablelist|self::glosslist|
|
---|
| 158 | self::simplelist[@type !='inline'])">
|
---|
| 159 | <xsl:apply-templates select="."/>
|
---|
| 160 | </xsl:when>
|
---|
| 161 | <xsl:when test="self::text()">
|
---|
| 162 | <!-- * Check to see if this is a text node. -->
|
---|
| 163 | <!-- * -->
|
---|
| 164 | <!-- * If so, replace all whitespace at the beginning or end of it -->
|
---|
| 165 | <!-- * with a single linebreak. -->
|
---|
| 166 | <!-- * -->
|
---|
| 167 | <xsl:variable name="content">
|
---|
| 168 | <xsl:apply-templates select="."/>
|
---|
| 169 | </xsl:variable>
|
---|
| 170 | <xsl:if
|
---|
| 171 | test="starts-with(translate(.,'	 ',' '), ' ')
|
---|
| 172 | and preceding-sibling::node()[1][name(.)!='']
|
---|
| 173 | and normalize-space($content) != ''
|
---|
| 174 | and not(
|
---|
| 175 | preceding-sibling::*[1][
|
---|
| 176 | self::variablelist or
|
---|
| 177 | self::glosslistlist or
|
---|
| 178 | self::itemizedlist or
|
---|
| 179 | self::orderededlist or
|
---|
| 180 | self::procedure or
|
---|
| 181 | self::address or
|
---|
| 182 | self::literallayout or
|
---|
| 183 | self::programlisting or
|
---|
| 184 | self::screen
|
---|
| 185 | ]
|
---|
| 186 | )
|
---|
| 187 | ">
|
---|
| 188 | <xsl:text> </xsl:text>
|
---|
| 189 | </xsl:if>
|
---|
| 190 | <xsl:value-of select="normalize-space($content)"/>
|
---|
| 191 | <xsl:if
|
---|
| 192 | test="translate(substring(., string-length(.), 1),'	 ',' ') = ' '
|
---|
| 193 | and following-sibling::node()[1][name(.)!='']
|
---|
| 194 | ">
|
---|
| 195 | <xsl:if test="normalize-space($content) != ''">
|
---|
| 196 | <xsl:text> </xsl:text>
|
---|
| 197 | </xsl:if>
|
---|
| 198 | </xsl:if>
|
---|
| 199 | </xsl:when>
|
---|
| 200 | <xsl:otherwise>
|
---|
| 201 | <!-- * At this point, we know that this node is not a verbatim -->
|
---|
| 202 | <!-- * environment, list, or text node; so we can safely -->
|
---|
| 203 | <!-- * normalize-space() it. -->
|
---|
| 204 | <xsl:variable name="content">
|
---|
| 205 | <xsl:apply-templates select="."/>
|
---|
| 206 | </xsl:variable>
|
---|
| 207 | <xsl:value-of select="normalize-space($content)"/>
|
---|
| 208 | </xsl:otherwise>
|
---|
| 209 | </xsl:choose>
|
---|
| 210 | </xsl:for-each>
|
---|
| 211 | </xsl:template>
|
---|
| 212 |
|
---|
| 213 | <!-- ================================================================== -->
|
---|
| 214 |
|
---|
| 215 | <!-- * Put a horizontal rule or other divider around section titles -->
|
---|
| 216 | <!-- * in roff source (just to make things easier to read). -->
|
---|
| 217 | <xsl:template name="mark.subheading">
|
---|
| 218 | <xsl:if test="$man.subheading.divider.enabled != 0">
|
---|
| 219 | <xsl:text>.\" </xsl:text>
|
---|
| 220 | <xsl:value-of select="$man.subheading.divider"/>
|
---|
| 221 | <xsl:text> </xsl:text>
|
---|
| 222 | </xsl:if>
|
---|
| 223 | </xsl:template>
|
---|
| 224 |
|
---|
| 225 | </xsl:stylesheet>
|
---|