fo.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4. version='1.0'>
  5. <xsl:import href="../docbook-xsl/fo/profile-docbook.xsl"/>
  6. <xsl:import href="mytitlepage.xsl"/>
  7. <xsl:param name="img.src.path">../</xsl:param>
  8. <xsl:param name="admon.graphics" select="1"/>
  9. <xsl:param name="admon.graphics.path" select="icons"/>
  10. <xsl:param name="chapter.autolabel" select="0"/>
  11. <xsl:param name="shade.verbatim" select="1"/>
  12. <!--xsl:param name="body.font.family" select="serif"/-->
  13. <xsl:param name="body.start.indent" select="0"/>
  14. <xsl:param name="callout.graphics" select="0"/>
  15. <xsl:param name="footer.column.widths" select="'0 3 0'"/>
  16. <!--xsl:param name="use.extensions" select="1"/-->
  17. <xsl:param name="fop1.extensions" select="1"/>
  18. <xsl:param name="generate.index" select="3"/>
  19. <xsl:param name="generate.section.toc.level" select="1"/>
  20. <xsl:param name="generate.toc">book toc</xsl:param>
  21. <xsl:param name="header.column.widths" select="'0 3 0'"/>
  22. <xsl:param name="paper.type" select="letter"/>
  23. <xsl:param name="profile.condition" select="int"/>
  24. <xsl:param name="qanda.inherit.numeration" select="0"/>
  25. <xsl:param name="section.autolabel" select="0"/>
  26. <!--xsl:param name="title.font.family" select="sans-serif"/-->
  27. <xsl:param name="toc.section.depth" select="1"/>
  28. <!--===========================SPECIAL_TOC_SAUCE======================-->
  29. <xsl:template name="page.number.format">
  30. <xsl:param name="element" select="local-name(.)"/>
  31. <xsl:choose>
  32. <xsl:when test="$element = 'toc'">1</xsl:when>
  33. <xsl:otherwise>1</xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:template>
  36. <xsl:template name="initial.page.number">
  37. <xsl:param name="element" select="local-name(.)"/>
  38. <xsl:param name="master-reference" select="''"/>
  39. <!-- Select the first content that the stylesheet places
  40. after the TOC -->
  41. <xsl:variable name="first.book.content"
  42. select="ancestor::book/*[
  43. not(self::title or
  44. self::subtitle or
  45. self::titleabbrev or
  46. self::bookinfo or
  47. self::info or
  48. self::dedication or
  49. self::preface or
  50. self::toc or
  51. self::lot)][1]"/>
  52. <xsl:choose>
  53. <!-- double-sided output -->
  54. <xsl:when test="$double.sided != 0">
  55. <xsl:choose>
  56. <xsl:when test="$element = 'toc'">auto-odd</xsl:when>
  57. <xsl:when test="$element = 'book'">auto</xsl:when>
  58. <!-- preface typically continues TOC roman numerals -->
  59. <!-- Change page.number.format if not -->
  60. <xsl:when test="$element = 'preface'">auto-odd</xsl:when>
  61. <xsl:when test="($element = 'dedication' or $element = 'article')
  62. and not(preceding::chapter
  63. or preceding::preface
  64. or preceding::appendix
  65. or preceding::article
  66. or preceding::dedication
  67. or parent::part
  68. or parent::reference)">auto</xsl:when>
  69. <xsl:when test="generate-id($first.book.content) =
  70. generate-id(.)">auto</xsl:when>
  71. <xsl:otherwise>auto-odd</xsl:otherwise>
  72. </xsl:choose>
  73. </xsl:when>
  74. <!-- single-sided output -->
  75. <xsl:otherwise>
  76. <xsl:choose>
  77. <xsl:when test="$element = 'toc'">auto</xsl:when>
  78. <xsl:when test="$element = 'book'">1</xsl:when>
  79. <xsl:when test="$element = 'preface'">auto</xsl:when>
  80. <xsl:when test="($element = 'dedication' or $element = 'article') and
  81. not(preceding::chapter
  82. or preceding::preface
  83. or preceding::appendix
  84. or preceding::article
  85. or preceding::dedication
  86. or parent::part
  87. or parent::reference)">auto</xsl:when>
  88. <xsl:when test="generate-id($first.book.content) =
  89. generate-id(.)">auto</xsl:when>
  90. <xsl:otherwise>auto</xsl:otherwise>
  91. </xsl:choose>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:template>
  95. <!--================ENDOFSPECIAL_tocSauce==============================-->
  96. <xsl:template match="processing-instruction('hard-pagebreak')">
  97. <fo:block break-after='page'/>
  98. </xsl:template>
  99. <xsl:template match="programlisting[@role='tab']">
  100. <fo:block xsl:use-attribute-sets="monospace.verbatim.properties">
  101. <xsl:attribute name="font-family">serif</xsl:attribute>
  102. <xsl:attribute name="font-size">10pt</xsl:attribute>
  103. <xsl:apply-templates/>
  104. </fo:block>
  105. </xsl:template>
  106. <!--sans-serif-para-role-->
  107. <xsl:template match="para[@role='sans']">
  108. <fo:block>
  109. <xsl:attribute name="font-family">sans-serif</xsl:attribute>
  110. <xsl:apply-templates/>
  111. </fo:block>
  112. </xsl:template>
  113. <xsl:template match="para[@role='wsig']">
  114. <fo:block xsl:use-attribute-sets="monospace.verbatim.properties">
  115. <xsl:attribute name="font-size">10pt</xsl:attribute>
  116. <xsl:apply-templates/>
  117. </fo:block>
  118. </xsl:template>
  119. <xsl:template match="programlisting[@role='wsig']">
  120. <fo:block xsl:use-attribute-sets="monospace.verbatim.properties">
  121. <xsl:attribute name="font-size">10pt</xsl:attribute>
  122. <xsl:apply-templates/>
  123. </fo:block>
  124. </xsl:template>
  125. <xsl:attribute-set name="monospace.verbatim.properties">
  126. <xsl:attribute name="font-size">
  127. 0.83em
  128. </xsl:attribute>
  129. </xsl:attribute-set>
  130. <xsl:attribute-set name="section.title.level1.properties">
  131. <xsl:attribute name="font-size">
  132. <xsl:value-of select="$body.font.master * 2.525"></xsl:value-of>
  133. <xsl:text>pt</xsl:text>
  134. </xsl:attribute>
  135. <xsl:attribute name="color">#A91919</xsl:attribute>
  136. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  137. </xsl:attribute-set>
  138. <xsl:attribute-set name="section.title.level2.properties">
  139. <xsl:attribute name="color">#A91919</xsl:attribute>
  140. </xsl:attribute-set>
  141. <xsl:attribute-set name="section.level1.properties">
  142. <xsl:attribute name="break-before">
  143. <xsl:choose>
  144. <xsl:when test="@role = 'nobrk'">auto</xsl:when>
  145. <xsl:otherwise>page</xsl:otherwise>
  146. </xsl:choose>
  147. </xsl:attribute>
  148. </xsl:attribute-set>
  149. <xsl:attribute-set name="section.level2.properties">
  150. <xsl:attribute name="break-before">
  151. <xsl:choose>
  152. <xsl:when test="@role = 'brk'">page</xsl:when>
  153. <xsl:otherwise>auto</xsl:otherwise>
  154. </xsl:choose>
  155. </xsl:attribute>
  156. </xsl:attribute-set>
  157. <xsl:attribute-set name="section.level3.properties">
  158. <xsl:attribute name="break-before">
  159. <xsl:choose>
  160. <xsl:when test="@role = 'brk'">page</xsl:when>
  161. <xsl:otherwise>auto</xsl:otherwise>
  162. </xsl:choose>
  163. </xsl:attribute>
  164. </xsl:attribute-set>
  165. <xsl:attribute-set name="header.content.properties">
  166. <xsl:attribute name="font-family">
  167. <xsl:value-of select="$title.font.family"></xsl:value-of>
  168. </xsl:attribute>
  169. </xsl:attribute-set>
  170. <xsl:attribute-set name="footer.content.properties">
  171. <xsl:attribute name="font-family">
  172. <xsl:value-of select="$title.font.family"></xsl:value-of>
  173. </xsl:attribute>
  174. </xsl:attribute-set>
  175. <!--chapter-title-attrib-set-->
  176. <xsl:attribute-set name="component.title.properties">
  177. <xsl:attribute name="text-align">right</xsl:attribute>
  178. </xsl:attribute-set>
  179. <xsl:template name="footer.content">
  180. <xsl:param name="pageclass" select="''"/>
  181. <xsl:param name="sequence" select="''"/>
  182. <xsl:param name="position" select="''"/>
  183. <xsl:param name="gentext-key" select="''"/>
  184. <xsl:choose>
  185. <xsl:when test="$double.sided = 0 and $position='center'">
  186. <fo:block>
  187. <xsl:value-of select="ancestor-or-self::book/bookinfo/releaseinfo"/>
  188. </fo:block>
  189. <fo:block>
  190. <fo:page-number/>
  191. </fo:block>
  192. </xsl:when>
  193. </xsl:choose>
  194. </xsl:template>
  195. <xsl:template name="header.content">
  196. <xsl:param name="pageclass" select="body"/>
  197. <xsl:param name="sequence" select="''"/>
  198. <xsl:param name="position" select="''"/>
  199. <xsl:param name="gentext-key" select="''"/>
  200. <xsl:choose>
  201. <xsl:when test="$pageclass = 'titlepage' and $position='center'">
  202. <!--IFC-HEADER-LOGIC-->
  203. <fo:block>
  204. <xsl:value-of select="ancestor-or-self::book/bookinfo/title"/>
  205. </fo:block>
  206. </xsl:when>
  207. <xsl:when test="$pageclass = 'lot' and $position='center'">
  208. <!--TOC-HEADER-LOGIC-->
  209. <fo:block>
  210. <xsl:value-of select="ancestor-or-self::book/bookinfo/title"/>
  211. </fo:block>
  212. </xsl:when>
  213. <xsl:when test="$double.sided = 0 and $position='center'">
  214. <fo:block>
  215. <xsl:value-of select="ancestor-or-self::book/bookinfo/title"/>
  216. </fo:block>
  217. <fo:block>
  218. <xsl:apply-templates select="." mode="object.title.markup"/>
  219. </fo:block>
  220. </xsl:when>
  221. </xsl:choose>
  222. </xsl:template>
  223. <!--VarListVariation-->
  224. <xsl:template match="varlistentry/term">
  225. <fo:inline font-family="sans-serif" font-weight="bold">
  226. <xsl:apply-templates/>
  227. </fo:inline>
  228. </xsl:template>
  229. <!--COLORING-TEMPLATES-->
  230. <xsl:template match="emphasis[@role='bluebold']">
  231. <fo:inline color="blue" font-weight="bold">
  232. <xsl:apply-templates/>
  233. </fo:inline>
  234. </xsl:template>
  235. <xsl:template match="emphasis[@role='blueital']">
  236. <fo:inline color="blue" font-style="italic">
  237. <xsl:apply-templates/>
  238. </fo:inline>
  239. </xsl:template>
  240. <xsl:template match="emphasis[@role='blue']">
  241. <fo:inline color="blue">
  242. <xsl:apply-templates/>
  243. </fo:inline>
  244. </xsl:template>
  245. <xsl:template match="emphasis[@role='redbold']">
  246. <fo:inline color="red" font-weight="bold">
  247. <xsl:apply-templates/>
  248. </fo:inline>
  249. </xsl:template>
  250. <xsl:template match="emphasis[@role='redital']">
  251. <fo:inline color="red" font-style="italic">
  252. <xsl:apply-templates/>
  253. </fo:inline>
  254. </xsl:template>
  255. <xsl:template match="emphasis[@role='red']">
  256. <fo:inline color="red">
  257. <xsl:apply-templates/>
  258. </fo:inline>
  259. </xsl:template>
  260. <xsl:template match="emphasis[@role='greenbold']">
  261. <fo:inline color="green" font-weight="bold">
  262. <xsl:apply-templates/>
  263. </fo:inline>
  264. </xsl:template>
  265. <xsl:template match="emphasis[@role='greenital']">
  266. <fo:inline color="green" font-style="italic">
  267. <xsl:apply-templates/>
  268. </fo:inline>
  269. </xsl:template>
  270. <xsl:template match="emphasis[@role='green']">
  271. <fo:inline color="green">
  272. <xsl:apply-templates/>
  273. </fo:inline>
  274. </xsl:template>
  275. <xsl:template match="emphasis[@role='whitebold']">
  276. <fo:inline color="white" font-weight="bold">
  277. <xsl:apply-templates/>
  278. </fo:inline>
  279. </xsl:template>
  280. <xsl:template match="emphasis[@role='whiteital']">
  281. <fo:inline color="white" font-style="italic">
  282. <xsl:apply-templates/>
  283. </fo:inline>
  284. </xsl:template>
  285. <xsl:template match="emphasis[@role='white']">
  286. <fo:inline color="white">
  287. <xsl:apply-templates/>
  288. </fo:inline>
  289. </xsl:template>
  290. <xsl:template match="emphasis[@role='underline']">
  291. <fo:inline text-decoration="underline">
  292. <xsl:apply-templates/>
  293. </fo:inline>
  294. </xsl:template>
  295. <!--NEW-inline_monospace-8-12-->
  296. <xsl:template match="emphasis[@role='code']">
  297. <fo:inline font-family="monospace">
  298. <xsl:apply-templates/>
  299. </fo:inline>
  300. </xsl:template>
  301. <xsl:template match="emphasis[@role='codebold']">
  302. <fo:inline font-family="monospace" font-weight="bold">
  303. <xsl:apply-templates/>
  304. </fo:inline>
  305. </xsl:template>
  306. <xsl:template match="ulink">
  307. <fo:inline color="blue" text-decoration="underline">
  308. <xsl:apply-templates/>
  309. </fo:inline>
  310. </xsl:template>
  311. <!--Special-TABLE-Striping-TEMPLATE-->
  312. <xsl:template name="table.row.properties">
  313. <xsl:variable name="tabstyle">
  314. <xsl:call-template name="tabstyle"/>
  315. </xsl:variable>
  316. <xsl:variable name="rownum">
  317. <xsl:number from="tgroup" count="row"/>
  318. </xsl:variable>
  319. <xsl:choose>
  320. <xsl:when test="$tabstyle = 'striped'">
  321. <xsl:if test="$rownum mod 2 = 0">
  322. <xsl:attribute name="background-color">#939598</xsl:attribute>
  323. </xsl:if>
  324. <xsl:if test="$rownum mod 2 != 0">
  325. <xsl:attribute name="background-color">#bcbec0</xsl:attribute>
  326. </xsl:if>
  327. </xsl:when>
  328. </xsl:choose>
  329. </xsl:template>
  330. </xsl:stylesheet>