fo.xsl 11 KB

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