fo.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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="processing-instruction('linebreak')">
  100. <fo:block/>
  101. </xsl:template>
  102. <xsl:template match="programlisting[@role='tab']">
  103. <fo:block xsl:use-attribute-sets="monospace.verbatim.properties">
  104. <xsl:attribute name="font-family">serif</xsl:attribute>
  105. <xsl:attribute name="font-size">10pt</xsl:attribute>
  106. <xsl:apply-templates/>
  107. </fo:block>
  108. </xsl:template>
  109. <!--sans-serif-para-role-->
  110. <xsl:template match="para[@role='sans']">
  111. <fo:block>
  112. <xsl:attribute name="font-family">sans-serif</xsl:attribute>
  113. <xsl:apply-templates/>
  114. </fo:block>
  115. </xsl:template>
  116. <xsl:template match="para[@role='wsig']">
  117. <fo:block xsl:use-attribute-sets="monospace.verbatim.properties">
  118. <xsl:attribute name="font-size">10pt</xsl:attribute>
  119. <xsl:apply-templates/>
  120. </fo:block>
  121. </xsl:template>
  122. <xsl:template match="programlisting[@role='wsig']">
  123. <fo:block xsl:use-attribute-sets="monospace.verbatim.properties">
  124. <xsl:attribute name="font-size">10pt</xsl:attribute>
  125. <xsl:apply-templates/>
  126. </fo:block>
  127. </xsl:template>
  128. <xsl:attribute-set name="monospace.verbatim.properties">
  129. <xsl:attribute name="font-size">
  130. 0.83em
  131. </xsl:attribute>
  132. </xsl:attribute-set>
  133. <xsl:attribute-set name="section.title.level1.properties">
  134. <xsl:attribute name="font-size">
  135. <xsl:value-of select="$body.font.master * 2.525"></xsl:value-of>
  136. <xsl:text>pt</xsl:text>
  137. </xsl:attribute>
  138. <xsl:attribute name="color">#A91919</xsl:attribute>
  139. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  140. </xsl:attribute-set>
  141. <xsl:attribute-set name="section.title.level2.properties">
  142. <xsl:attribute name="color">#A91919</xsl:attribute>
  143. </xsl:attribute-set>
  144. <xsl:attribute-set name="section.level1.properties">
  145. <xsl:attribute name="break-before">
  146. <xsl:choose>
  147. <xsl:when test="@role = 'nobrk'">auto</xsl:when>
  148. <xsl:otherwise>page</xsl:otherwise>
  149. </xsl:choose>
  150. </xsl:attribute>
  151. </xsl:attribute-set>
  152. <xsl:attribute-set name="section.level2.properties">
  153. <xsl:attribute name="break-before">
  154. <xsl:choose>
  155. <xsl:when test="@role = 'brk'">page</xsl:when>
  156. <xsl:otherwise>auto</xsl:otherwise>
  157. </xsl:choose>
  158. </xsl:attribute>
  159. </xsl:attribute-set>
  160. <xsl:attribute-set name="section.level3.properties">
  161. <xsl:attribute name="break-before">
  162. <xsl:choose>
  163. <xsl:when test="@role = 'brk'">page</xsl:when>
  164. <xsl:otherwise>auto</xsl:otherwise>
  165. </xsl:choose>
  166. </xsl:attribute>
  167. </xsl:attribute-set>
  168. <xsl:attribute-set name="header.content.properties">
  169. <xsl:attribute name="font-family">
  170. <xsl:value-of select="$title.font.family"></xsl:value-of>
  171. </xsl:attribute>
  172. </xsl:attribute-set>
  173. <xsl:attribute-set name="footer.content.properties">
  174. <xsl:attribute name="font-family">
  175. <xsl:value-of select="$title.font.family"></xsl:value-of>
  176. </xsl:attribute>
  177. </xsl:attribute-set>
  178. <!--chapter-title-attrib-set-->
  179. <xsl:attribute-set name="component.title.properties">
  180. <xsl:attribute name="text-align">right</xsl:attribute>
  181. </xsl:attribute-set>
  182. <xsl:template name="footer.content">
  183. <xsl:param name="pageclass" select="''"/>
  184. <xsl:param name="sequence" select="''"/>
  185. <xsl:param name="position" select="''"/>
  186. <xsl:param name="gentext-key" select="''"/>
  187. <xsl:choose>
  188. <xsl:when test="$double.sided = 0 and $position='center'">
  189. <fo:block>
  190. <xsl:value-of select="ancestor-or-self::book/bookinfo/releaseinfo"/>
  191. </fo:block>
  192. <fo:block>
  193. <fo:page-number/>
  194. </fo:block>
  195. </xsl:when>
  196. </xsl:choose>
  197. </xsl:template>
  198. <xsl:template name="header.content">
  199. <xsl:param name="pageclass" select="body"/>
  200. <xsl:param name="sequence" select="''"/>
  201. <xsl:param name="position" select="''"/>
  202. <xsl:param name="gentext-key" select="''"/>
  203. <xsl:choose>
  204. <xsl:when test="$pageclass = 'titlepage' and $position='center'">
  205. <!--IFC-HEADER-LOGIC-->
  206. <fo:block>
  207. <xsl:value-of select="ancestor-or-self::book/bookinfo/title"/>
  208. </fo:block>
  209. </xsl:when>
  210. <xsl:when test="$pageclass = 'lot' and $position='center'">
  211. <!--TOC-HEADER-LOGIC-->
  212. <fo:block>
  213. <xsl:value-of select="ancestor-or-self::book/bookinfo/title"/>
  214. </fo:block>
  215. </xsl:when>
  216. <xsl:when test="$double.sided = 0 and $position='center'">
  217. <fo:block>
  218. <xsl:value-of select="ancestor-or-self::book/bookinfo/title"/>
  219. </fo:block>
  220. <fo:block>
  221. <xsl:apply-templates select="." mode="object.title.markup"/>
  222. </fo:block>
  223. </xsl:when>
  224. </xsl:choose>
  225. </xsl:template>
  226. <!--VarListVariation-->
  227. <xsl:template match="varlistentry/term">
  228. <fo:inline font-family="sans-serif" font-weight="bold">
  229. <xsl:apply-templates/>
  230. </fo:inline>
  231. </xsl:template>
  232. <!--COLORING-TEMPLATES-->
  233. <xsl:template match="emphasis[@role='bluebold']">
  234. <fo:inline color="blue" font-weight="bold">
  235. <xsl:apply-templates/>
  236. </fo:inline>
  237. </xsl:template>
  238. <xsl:template match="emphasis[@role='blueital']">
  239. <fo:inline color="blue" font-style="italic">
  240. <xsl:apply-templates/>
  241. </fo:inline>
  242. </xsl:template>
  243. <xsl:template match="emphasis[@role='blue']">
  244. <fo:inline color="blue">
  245. <xsl:apply-templates/>
  246. </fo:inline>
  247. </xsl:template>
  248. <xsl:template match="emphasis[@role='redbold']">
  249. <fo:inline color="red" font-weight="bold">
  250. <xsl:apply-templates/>
  251. </fo:inline>
  252. </xsl:template>
  253. <xsl:template match="emphasis[@role='redital']">
  254. <fo:inline color="red" font-style="italic">
  255. <xsl:apply-templates/>
  256. </fo:inline>
  257. </xsl:template>
  258. <xsl:template match="emphasis[@role='red']">
  259. <fo:inline color="red">
  260. <xsl:apply-templates/>
  261. </fo:inline>
  262. </xsl:template>
  263. <xsl:template match="emphasis[@role='greenbold']">
  264. <fo:inline color="green" font-weight="bold">
  265. <xsl:apply-templates/>
  266. </fo:inline>
  267. </xsl:template>
  268. <xsl:template match="emphasis[@role='greenital']">
  269. <fo:inline color="green" font-style="italic">
  270. <xsl:apply-templates/>
  271. </fo:inline>
  272. </xsl:template>
  273. <xsl:template match="emphasis[@role='green']">
  274. <fo:inline color="green">
  275. <xsl:apply-templates/>
  276. </fo:inline>
  277. </xsl:template>
  278. <xsl:template match="emphasis[@role='whitebold']">
  279. <fo:inline color="white" font-weight="bold">
  280. <xsl:apply-templates/>
  281. </fo:inline>
  282. </xsl:template>
  283. <xsl:template match="emphasis[@role='whiteital']">
  284. <fo:inline color="white" font-style="italic">
  285. <xsl:apply-templates/>
  286. </fo:inline>
  287. </xsl:template>
  288. <xsl:template match="emphasis[@role='white']">
  289. <fo:inline color="white">
  290. <xsl:apply-templates/>
  291. </fo:inline>
  292. </xsl:template>
  293. <xsl:template match="emphasis[@role='underline']">
  294. <fo:inline text-decoration="underline">
  295. <xsl:apply-templates/>
  296. </fo:inline>
  297. </xsl:template>
  298. <!--NEW-inline_monospace-8-12-->
  299. <xsl:template match="emphasis[@role='code']">
  300. <fo:inline font-family="monospace">
  301. <xsl:apply-templates/>
  302. </fo:inline>
  303. </xsl:template>
  304. <xsl:template match="emphasis[@role='codebold']">
  305. <fo:inline font-family="monospace" font-weight="bold">
  306. <xsl:apply-templates/>
  307. </fo:inline>
  308. </xsl:template>
  309. <xsl:template match="ulink">
  310. <fo:inline color="blue" text-decoration="underline">
  311. <xsl:apply-templates/>
  312. </fo:inline>
  313. </xsl:template>
  314. <!--Special-TABLE-Striping-TEMPLATE-->
  315. <xsl:template name="table.row.properties">
  316. <xsl:variable name="tabstyle">
  317. <xsl:call-template name="tabstyle"/>
  318. </xsl:variable>
  319. <xsl:variable name="rownum">
  320. <xsl:number from="tgroup" count="row"/>
  321. </xsl:variable>
  322. <xsl:choose>
  323. <xsl:when test="$tabstyle = 'striped'">
  324. <xsl:if test="$rownum mod 2 = 0">
  325. <xsl:attribute name="background-color">#939598</xsl:attribute>
  326. </xsl:if>
  327. <xsl:if test="$rownum mod 2 != 0">
  328. <xsl:attribute name="background-color">#bcbec0</xsl:attribute>
  329. </xsl:if>
  330. </xsl:when>
  331. </xsl:choose>
  332. </xsl:template>
  333. </xsl:stylesheet>