lfs-pdf.xsl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. xmlns="http://www.w3.org/1999/xhtml"
  5. version="1.0">
  6. <!-- We use FO and FOP as the processor -->
  7. <xsl:import href="http://docbook.sourceforge.net/release/xsl/1.65.1/fo/docbook.xsl"/>
  8. <xsl:param name="fop.extensions" select="1"/>
  9. <xsl:param name="draft.mode" select="'no'"/>
  10. <!-- Probably want to make the paper size configurable -->
  11. <xsl:param name="paper.type" select="'A4'"/>
  12. <!-- Include our customised templates -->
  13. <xsl:include href="pdf/lfs-index.xsl"/>
  14. <!-- Font size -->
  15. <xsl:param name="body.font.master">8</xsl:param>
  16. <xsl:param name="body.font.size">10pt</xsl:param>
  17. <!-- Margins -->
  18. <xsl:param name="page.margin.inner">1in</xsl:param>
  19. <xsl:param name="page.margin.outer">0.5in</xsl:param>
  20. <xsl:param name="title.margin.left">-1pc</xsl:param>
  21. <!-- TOC stuff -->
  22. <xsl:param name="generate.toc">
  23. book toc
  24. part nop
  25. </xsl:param>
  26. <xsl:param name="toc.section.depth">1</xsl:param>
  27. <xsl:param name="generate.section.toc.level" select="-1"></xsl:param>
  28. <xsl:param name="toc.indent.width" select="18"></xsl:param>
  29. <!-- Force section1's onto a new page -->
  30. <xsl:attribute-set name="section.level1.properties">
  31. <xsl:attribute name="break-after">page</xsl:attribute>
  32. </xsl:attribute-set>
  33. <!-- Columns in appendix -->
  34. <xsl:param name="column.count.back" select="2"/>
  35. <!-- Don't hyphenate -->
  36. <xsl:param name="hyphenate">false</xsl:param>
  37. <xsl:param name="alignment">left</xsl:param>
  38. <!-- Page number in Xref-->
  39. <xsl:param name="insert.xref.page.number">yes</xsl:param>
  40. <xsl:template match="xref" name="xref">
  41. <xsl:variable name="targets" select="key('id',@linkend)"/>
  42. <xsl:variable name="target" select="$targets[1]"/>
  43. <xsl:variable name="refelem" select="local-name($target)"/>
  44. <xsl:call-template name="check.id.unique">
  45. <xsl:with-param name="linkend" select="@linkend"/>
  46. </xsl:call-template>
  47. <xsl:choose>
  48. <xsl:when test="$refelem=''">
  49. <xsl:message>
  50. <xsl:text>XRef to nonexistent id: </xsl:text>
  51. <xsl:value-of select="@linkend"/>
  52. </xsl:message>
  53. <xsl:text>???</xsl:text>
  54. </xsl:when>
  55. <xsl:when test="@endterm">
  56. <fo:basic-link internal-destination="{@linkend}"
  57. xsl:use-attribute-sets="xref.properties">
  58. <xsl:variable name="etargets" select="key('id',@endterm)"/>
  59. <xsl:variable name="etarget" select="$etargets[1]"/>
  60. <xsl:choose>
  61. <xsl:when test="count($etarget) = 0">
  62. <xsl:message>
  63. <xsl:value-of select="count($etargets)"/>
  64. <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  65. <xsl:value-of select="@endterm"/>
  66. </xsl:message>
  67. <xsl:text>???</xsl:text>
  68. </xsl:when>
  69. <xsl:otherwise>
  70. <xsl:apply-templates select="$etarget" mode="endterm"/>
  71. </xsl:otherwise>
  72. </xsl:choose>
  73. </fo:basic-link>
  74. </xsl:when>
  75. <xsl:when test="$target/@xreflabel">
  76. <fo:basic-link internal-destination="{@linkend}"
  77. xsl:use-attribute-sets="xref.properties">
  78. <xsl:call-template name="xref.xreflabel">
  79. <xsl:with-param name="target" select="$target"/>
  80. </xsl:call-template>
  81. </fo:basic-link>
  82. </xsl:when>
  83. <xsl:otherwise>
  84. <fo:basic-link internal-destination="{@linkend}"
  85. xsl:use-attribute-sets="xref.properties">
  86. <xsl:apply-templates select="$target" mode="xref-to">
  87. <xsl:with-param name="referrer" select="."/>
  88. <xsl:with-param name="xrefstyle">
  89. <xsl:choose>
  90. <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
  91. <xsl:value-of select="@role"/>
  92. </xsl:when>
  93. <xsl:otherwise>
  94. <xsl:value-of select="@xrefstyle"/>
  95. </xsl:otherwise>
  96. </xsl:choose>
  97. </xsl:with-param>
  98. </xsl:apply-templates>
  99. </fo:basic-link>
  100. </xsl:otherwise>
  101. </xsl:choose>
  102. <xsl:if test="not(starts-with(normalize-space(@xrefstyle), 'select:') != ''
  103. and (contains(@xrefstyle, 'page')
  104. or contains(@xrefstyle, 'Page')))
  105. and ( $insert.xref.page.number = 'yes'
  106. or $insert.xref.page.number = '1')
  107. or local-name($target) = 'para'">
  108. <fo:basic-link internal-destination="{@linkend}"
  109. xsl:use-attribute-sets="xref.properties">
  110. <xsl:text>, p. </xsl:text>
  111. <xsl:apply-templates select="$target" mode="page.citation">
  112. <xsl:with-param name="id" select="@linkend"/>
  113. </xsl:apply-templates>
  114. </fo:basic-link>
  115. </xsl:if>
  116. </xsl:template>
  117. <!-- Prevent duplicate e-mails in the Acknowledgments pages-->
  118. <xsl:param name="ulink.show" select="0"/>
  119. </xsl:stylesheet>