njn | 3e986b2 | 2004-11-30 10:43:45 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> <!-- -*- sgml -*- --> |
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 | xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> |
| 4 | |
| 5 | <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/> |
| 6 | <xsl:import href="vg-common.xsl"/> |
| 7 | |
| 8 | <!-- set indent = yes while debugging, then change to NO --> |
| 9 | <xsl:output method="xml" indent="no"/> |
| 10 | |
| 11 | <!-- ensure only passivetex extensions are on --> |
| 12 | <xsl:param name="stylesheet.result.type" select="'fo'"/> |
| 13 | <!-- fo extensions: PDF bookmarks and index terms --> |
| 14 | <xsl:param name="use.extensions" select="'1'"/> |
| 15 | <xsl:param name="xep.extensions" select="0"/> |
| 16 | <xsl:param name="fop.extensions" select="0"/> |
| 17 | <xsl:param name="saxon.extensions" select="0"/> |
| 18 | <xsl:param name="passivetex.extensions" select="1"/> |
| 19 | <xsl:param name="tablecolumns.extension" select="'1'"/> |
| 20 | |
| 21 | <!-- ensure we are using single sided --> |
| 22 | <xsl:param name="double.sided" select="'0'"/> |
| 23 | |
| 24 | <!-- insert cross references to page numbers --> |
| 25 | <xsl:param name="insert.xref.page.number" select="1"/> |
| 26 | |
| 27 | <!-- <?custom-pagebreak?> inserts a page break at this point --> |
| 28 | <xsl:template match="processing-instruction('custom-pagebreak')"> |
| 29 | <fo:block break-before='page'/> |
| 30 | </xsl:template> |
| 31 | |
| 32 | <!-- show links in color --> |
| 33 | <xsl:attribute-set name="xref.properties"> |
| 34 | <xsl:attribute name="color">blue</xsl:attribute> |
| 35 | </xsl:attribute-set> |
| 36 | |
| 37 | <!-- make pre listings indented a bit + a bg colour --> |
| 38 | <xsl:template match="programlisting | screen"> |
| 39 | <fo:block start-indent="0.25in" wrap-option="no-wrap" |
| 40 | white-space-collapse="false" text-align="start" |
| 41 | font-family="monospace" background-color="#f2f2f9" |
| 42 | linefeed-treatment="preserve" |
| 43 | xsl:use-attribute-sets="normal.para.spacing"> |
| 44 | <xsl:apply-templates/> |
| 45 | </fo:block> |
| 46 | </xsl:template> |
| 47 | |
| 48 | <!-- workaround bug in passivetex fo output for itemizedlist --> |
| 49 | <xsl:template match="itemizedlist/listitem"> |
| 50 | <xsl:variable name="id"> |
| 51 | <xsl:call-template name="object.id"/></xsl:variable> |
| 52 | <xsl:variable name="itemsymbol"> |
| 53 | <xsl:call-template name="list.itemsymbol"> |
| 54 | <xsl:with-param name="node" select="parent::itemizedlist"/> |
| 55 | </xsl:call-template> |
| 56 | </xsl:variable> |
| 57 | <xsl:variable name="item.contents"> |
| 58 | <fo:list-item-label end-indent="label-end()"> |
| 59 | <fo:block> |
| 60 | <xsl:choose> |
| 61 | <xsl:when test="$itemsymbol='disc'">•</xsl:when> |
| 62 | <xsl:when test="$itemsymbol='bullet'">•</xsl:when> |
| 63 | <xsl:otherwise>•</xsl:otherwise> |
| 64 | </xsl:choose> |
| 65 | </fo:block> |
| 66 | </fo:list-item-label> |
| 67 | <fo:list-item-body start-indent="body-start()"> |
| 68 | <xsl:apply-templates/> <!-- removed extra block wrapper --> |
| 69 | </fo:list-item-body> |
| 70 | </xsl:variable> |
| 71 | <xsl:choose> |
| 72 | <xsl:when test="parent::*/@spacing = 'compact'"> |
| 73 | <fo:list-item id="{$id}" |
| 74 | xsl:use-attribute-sets="compact.list.item.spacing"> |
| 75 | <xsl:copy-of select="$item.contents"/> |
| 76 | </fo:list-item> |
| 77 | </xsl:when> |
| 78 | <xsl:otherwise> |
| 79 | <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing"> |
| 80 | <xsl:copy-of select="$item.contents"/> |
| 81 | </fo:list-item> |
| 82 | </xsl:otherwise> |
| 83 | </xsl:choose> |
| 84 | </xsl:template> |
| 85 | |
| 86 | <!-- workaround bug in passivetex fo output for orderedlist --> |
| 87 | <xsl:template match="orderedlist/listitem"> |
| 88 | <xsl:variable name="id"> |
| 89 | <xsl:call-template name="object.id"/></xsl:variable> |
| 90 | <xsl:variable name="item.contents"> |
| 91 | <fo:list-item-label end-indent="label-end()"> |
| 92 | <fo:block> |
| 93 | <xsl:apply-templates select="." mode="item-number"/> |
| 94 | </fo:block> |
| 95 | </fo:list-item-label> |
| 96 | <fo:list-item-body start-indent="body-start()"> |
| 97 | <xsl:apply-templates/> <!-- removed extra block wrapper --> |
| 98 | </fo:list-item-body> |
| 99 | </xsl:variable> |
| 100 | <xsl:choose> |
| 101 | <xsl:when test="parent::*/@spacing = 'compact'"> |
| 102 | <fo:list-item id="{$id}" |
| 103 | xsl:use-attribute-sets="compact.list.item.spacing"> |
| 104 | <xsl:copy-of select="$item.contents"/> |
| 105 | </fo:list-item> |
| 106 | </xsl:when> |
| 107 | <xsl:otherwise> |
| 108 | <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing"> |
| 109 | <xsl:copy-of select="$item.contents"/> |
| 110 | </fo:list-item> |
| 111 | </xsl:otherwise> |
| 112 | </xsl:choose> |
| 113 | </xsl:template> |
| 114 | |
| 115 | <!-- workaround bug in passivetex fo output for variablelist --> |
| 116 | <xsl:param name="variablelist.as.blocks" select="1"/> |
| 117 | <xsl:template match="varlistentry" mode="vl.as.blocks"> |
| 118 | <xsl:variable name="id"> |
| 119 | <xsl:call-template name="object.id"/></xsl:variable> |
| 120 | <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing" |
| 121 | keep-together.within-column="always" |
| 122 | keep-with-next.within-column="always"> |
| 123 | <xsl:apply-templates select="term"/> |
| 124 | </fo:block> |
| 125 | <fo:block start-indent="0.5in" end-indent="0in" |
| 126 | space-after.minimum="0.2em" |
| 127 | space-after.optimum="0.4em" |
| 128 | space-after.maximum="0.6em"> |
| 129 | <fo:block> |
| 130 | <xsl:apply-templates select="listitem"/> |
| 131 | </fo:block> |
| 132 | </fo:block> |
| 133 | </xsl:template> |
| 134 | |
| 135 | <!-- workaround bug in passivetext fo output for revhistory --> |
| 136 | <xsl:template match="revhistory" mode="titlepage.mode"> |
| 137 | <fo:block space-before="1.0em"> |
| 138 | <fo:table table-layout="fixed" width="100%"> |
| 139 | <fo:table-column column-number="1" column-width="33%"/> |
| 140 | <fo:table-column column-number="2" column-width="33%"/> |
| 141 | <fo:table-column column-number="3" column-width="34%"/> |
| 142 | <fo:table-body> |
| 143 | <fo:table-row> |
| 144 | <fo:table-cell number-columns-spanned="3" text-align="left"> |
| 145 | <fo:block> |
| 146 | <xsl:call-template name="gentext"> |
| 147 | <xsl:with-param name="key" select="'RevHistory'"/> |
| 148 | </xsl:call-template> |
| 149 | </fo:block> |
| 150 | </fo:table-cell> |
| 151 | </fo:table-row> |
| 152 | <xsl:apply-templates mode="titlepage.mode"/> |
| 153 | </fo:table-body> |
| 154 | </fo:table> |
| 155 | </fo:block> |
| 156 | </xsl:template> |
| 157 | |
| 158 | <xsl:template match="revhistory/revision" mode="titlepage.mode"> |
| 159 | <xsl:variable name="revnumber" select=".//revnumber"/> |
| 160 | <xsl:variable name="revdate" select=".//date"/> |
| 161 | <xsl:variable name="revauthor" select=".//authorinitials"/> |
| 162 | <xsl:variable name="revremark" select=".//revremark"/> |
| 163 | <fo:table-row> |
| 164 | <fo:table-cell text-align="left"> |
| 165 | <fo:block> |
| 166 | <xsl:if test="$revnumber"> |
| 167 | <xsl:call-template name="gentext"> |
| 168 | <xsl:with-param name="key" select="'Revision'"/> |
| 169 | </xsl:call-template> |
| 170 | <xsl:call-template name="gentext.space"/> |
| 171 | <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/> |
| 172 | </xsl:if> |
| 173 | </fo:block> |
| 174 | </fo:table-cell> |
| 175 | <fo:table-cell text-align="left"> |
| 176 | <fo:block> |
| 177 | <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/> |
| 178 | </fo:block> |
| 179 | </fo:table-cell> |
| 180 | <fo:table-cell text-align="left"> |
| 181 | <fo:block> |
| 182 | <xsl:apply-templates select="$revauthor[1]" mode="titlepage.mode"/> |
| 183 | </fo:block> |
| 184 | </fo:table-cell> |
| 185 | </fo:table-row> |
| 186 | <xsl:if test="$revremark"> |
| 187 | <fo:table-row> |
| 188 | <fo:table-cell number-columns-spanned="3" text-align="left"> |
| 189 | <fo:block> |
| 190 | <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/> |
| 191 | </fo:block> |
| 192 | </fo:table-cell> |
| 193 | </fo:table-row> |
| 194 | </xsl:if> |
| 195 | </xsl:template> |
| 196 | |
| 197 | |
| 198 | <!-- workaround bug in footers: force right-align w/two 80|30 cols --> |
| 199 | <xsl:template name="footer.table"> |
| 200 | <xsl:param name="pageclass" select="''"/> |
| 201 | <xsl:param name="sequence" select="''"/> |
| 202 | <xsl:param name="gentext-key" select="''"/> |
| 203 | <xsl:choose> |
| 204 | <xsl:when test="$pageclass = 'index'"> |
| 205 | <xsl:attribute name="margin-left">0pt</xsl:attribute> |
| 206 | </xsl:when> |
| 207 | </xsl:choose> |
| 208 | <xsl:variable name="candidate"> |
| 209 | <fo:table table-layout="fixed" width="100%"> |
| 210 | <fo:table-column column-number="1" column-width="80%"/> |
| 211 | <fo:table-column column-number="2" column-width="20%"/> |
| 212 | <fo:table-body> |
| 213 | <fo:table-row height="14pt"> |
| 214 | <fo:table-cell text-align="left" display-align="after"> |
| 215 | <xsl:attribute name="relative-align">baseline</xsl:attribute> |
| 216 | <fo:block> |
| 217 | <fo:block> </fo:block><!-- empty cell --> |
| 218 | </fo:block> |
| 219 | </fo:table-cell> |
| 220 | <fo:table-cell text-align="center" display-align="after"> |
| 221 | <xsl:attribute name="relative-align">baseline</xsl:attribute> |
| 222 | <fo:block> |
| 223 | <xsl:call-template name="footer.content"> |
| 224 | <xsl:with-param name="pageclass" select="$pageclass"/> |
| 225 | <xsl:with-param name="sequence" select="$sequence"/> |
| 226 | <xsl:with-param name="position" select="'center'"/> |
| 227 | <xsl:with-param name="gentext-key" select="$gentext-key"/> |
| 228 | </xsl:call-template> |
| 229 | </fo:block> |
| 230 | </fo:table-cell> |
| 231 | </fo:table-row> |
| 232 | </fo:table-body> |
| 233 | </fo:table> |
| 234 | </xsl:variable> |
| 235 | <!-- Really output a footer? --> |
| 236 | <xsl:choose> |
| 237 | <xsl:when test="$pageclass='titlepage' and $gentext-key='book' |
| 238 | and $sequence='first'"> |
| 239 | <!-- no, book titlepages have no footers at all --> |
| 240 | </xsl:when> |
| 241 | <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0"> |
| 242 | <!-- no output --> |
| 243 | </xsl:when> |
| 244 | <xsl:otherwise> |
| 245 | <xsl:copy-of select="$candidate"/> |
| 246 | </xsl:otherwise> |
| 247 | </xsl:choose> |
| 248 | </xsl:template> |
| 249 | |
| 250 | |
| 251 | <!-- fix bug in headers: force right-align w/two 40|60 cols --> |
| 252 | <xsl:template name="header.table"> |
| 253 | <xsl:param name="pageclass" select="''"/> |
| 254 | <xsl:param name="sequence" select="''"/> |
| 255 | <xsl:param name="gentext-key" select="''"/> |
| 256 | <xsl:choose> |
| 257 | <xsl:when test="$pageclass = 'index'"> |
| 258 | <xsl:attribute name="margin-left">0pt</xsl:attribute> |
| 259 | </xsl:when> |
| 260 | </xsl:choose> |
| 261 | <xsl:variable name="candidate"> |
| 262 | <fo:table table-layout="fixed" width="100%"> |
| 263 | <xsl:call-template name="head.sep.rule"> |
| 264 | <xsl:with-param name="pageclass" select="$pageclass"/> |
| 265 | <xsl:with-param name="sequence" select="$sequence"/> |
| 266 | <xsl:with-param name="gentext-key" select="$gentext-key"/> |
| 267 | </xsl:call-template> |
| 268 | <fo:table-column column-number="1" column-width="40%"/> |
| 269 | <fo:table-column column-number="2" column-width="60%"/> |
| 270 | <fo:table-body> |
| 271 | <fo:table-row height="14pt"> |
| 272 | <fo:table-cell text-align="left" display-align="before"> |
| 273 | <xsl:attribute name="relative-align">baseline</xsl:attribute> |
| 274 | <fo:block> |
| 275 | <fo:block> </fo:block><!-- empty cell --> |
| 276 | </fo:block> |
| 277 | </fo:table-cell> |
| 278 | <fo:table-cell text-align="center" display-align="before"> |
| 279 | <xsl:attribute name="relative-align">baseline</xsl:attribute> |
| 280 | <fo:block> |
| 281 | <xsl:call-template name="header.content"> |
| 282 | <xsl:with-param name="pageclass" select="$pageclass"/> |
| 283 | <xsl:with-param name="sequence" select="$sequence"/> |
| 284 | <xsl:with-param name="position" select="'center'"/> |
| 285 | <xsl:with-param name="gentext-key" select="$gentext-key"/> |
| 286 | </xsl:call-template> |
| 287 | </fo:block> |
| 288 | </fo:table-cell> |
| 289 | </fo:table-row> |
| 290 | </fo:table-body> |
| 291 | </fo:table> |
| 292 | </xsl:variable> |
| 293 | <!-- Really output a header? --> |
| 294 | <xsl:choose> |
| 295 | <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book' |
| 296 | and $sequence='first'"> |
| 297 | <!-- no, book titlepages have no headers at all --> |
| 298 | </xsl:when> |
| 299 | <xsl:when test="$sequence = 'blank' and $headers.on.blank.pages = 0"> |
| 300 | <!-- no output --> |
| 301 | </xsl:when> |
| 302 | <xsl:otherwise> |
| 303 | <xsl:copy-of select="$candidate"/> |
| 304 | </xsl:otherwise> |
| 305 | </xsl:choose> |
| 306 | </xsl:template> |
| 307 | |
| 308 | |
| 309 | </xsl:stylesheet> |
| 310 | |
| 311 | <!-- |
| 312 | pagebreaks in fo output: |
| 313 | - http://www.dpawson.co.uk/docbook/styling/fo.html#d1408e636 |
| 314 | http://www.dpawson.co.uk/docbook/styling/fo.html |
| 315 | http://docbook.sourceforge.net/release/xsl/current/doc/fo/variablelist.as.blocks.html |
| 316 | alt. book to oreilly: |
| 317 | - http://www.ravelgrane.com/ER/doc/lx/book.html |
| 318 | tex memory: |
| 319 | - http://www.dpawson.co.uk/docbook/tools.html#d4e191 |
| 320 | --> |