fop1.xsl 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
  4. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  5. version='1.0'>
  6. <!-- ********************************************************************
  7. $Id: fop1.xsl 9293 2012-04-19 18:42:11Z bobstayton $
  8. ********************************************************************
  9. This file is part of the XSL DocBook Stylesheet distribution.
  10. See ../README or http://docbook.sf.net/release/xsl/current/ for
  11. copyright and other information.
  12. ******************************************************************** -->
  13. <!-- ==================================================================== -->
  14. <xsl:variable name="bookmarks.state">
  15. <xsl:choose>
  16. <xsl:when test="$bookmarks.collapse != 0">hide</xsl:when>
  17. <xsl:otherwise>show</xsl:otherwise>
  18. </xsl:choose>
  19. </xsl:variable>
  20. <xsl:template match="*" mode="fop1.outline">
  21. <xsl:apply-templates select="*" mode="fop1.outline"/>
  22. </xsl:template>
  23. <xsl:template match="set|book|part|reference|
  24. preface|chapter|appendix|article|topic
  25. |glossary|bibliography|index|setindex
  26. |refentry
  27. |sect1|sect2|sect3|sect4|sect5|section"
  28. mode="fop1.outline">
  29. <xsl:variable name="id">
  30. <xsl:call-template name="object.id"/>
  31. </xsl:variable>
  32. <xsl:variable name="bookmark-label">
  33. <xsl:apply-templates select="." mode="object.title.markup"/>
  34. </xsl:variable>
  35. <!-- Put the root element bookmark at the same level as its children -->
  36. <!-- If the object is a set or book, generate a bookmark for the toc -->
  37. <xsl:choose>
  38. <xsl:when test="self::index and $generate.index = 0"/>
  39. <xsl:when test="parent::*">
  40. <fo:bookmark internal-destination="{$id}">
  41. <xsl:attribute name="starting-state">
  42. <xsl:value-of select="$bookmarks.state"/>
  43. </xsl:attribute>
  44. <fo:bookmark-title>
  45. <xsl:value-of select="normalize-space($bookmark-label)"/>
  46. </fo:bookmark-title>
  47. <xsl:apply-templates select="*" mode="fop1.outline"/>
  48. </fo:bookmark>
  49. </xsl:when>
  50. <xsl:otherwise>
  51. <fo:bookmark internal-destination="{$id}">
  52. <xsl:attribute name="starting-state">
  53. <xsl:value-of select="$bookmarks.state"/>
  54. </xsl:attribute>
  55. <fo:bookmark-title>
  56. <xsl:value-of select="normalize-space($bookmark-label)"/>
  57. </fo:bookmark-title>
  58. </fo:bookmark>
  59. <xsl:variable name="toc.params">
  60. <xsl:call-template name="find.path.params">
  61. <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
  62. </xsl:call-template>
  63. </xsl:variable>
  64. <xsl:if test="contains($toc.params, 'toc')
  65. and (book|part|reference|preface|chapter|appendix|article|topic
  66. |glossary|bibliography|index|setindex
  67. |refentry
  68. |sect1|sect2|sect3|sect4|sect5|section)">
  69. <fo:bookmark internal-destination="toc...{$id}">
  70. <fo:bookmark-title>
  71. <xsl:call-template name="gentext">
  72. <xsl:with-param name="key" select="'TableofContents'"/>
  73. </xsl:call-template>
  74. </fo:bookmark-title>
  75. </fo:bookmark>
  76. </xsl:if>
  77. <xsl:apply-templates select="*" mode="fop1.outline"/>
  78. </xsl:otherwise>
  79. </xsl:choose>
  80. <!--
  81. <fo:bookmark internal-destination="{$id}"/>
  82. -->
  83. </xsl:template>
  84. <xsl:template match="*" mode="fop1.foxdest">
  85. <xsl:apply-templates select="*" mode="fop1.foxdest"/>
  86. </xsl:template>
  87. <xsl:template match="set|book|part|reference|
  88. preface|chapter|appendix|article|topic
  89. |glossary|bibliography|index|setindex
  90. |refentry
  91. |sect1|sect2|sect3|sect4|sect5|section"
  92. mode="fop1.foxdest">
  93. <xsl:variable name="id">
  94. <xsl:call-template name="object.id"/>
  95. </xsl:variable>
  96. <xsl:variable name="bookmark-label">
  97. <xsl:apply-templates select="." mode="object.title.markup"/>
  98. </xsl:variable>
  99. <!--xsl:if test="$id != ''">
  100. <fox:destination internal-destination="{$id}"/>
  101. </xsl:if-->
  102. <!-- Put the root element bookmark at the same level as its children -->
  103. <!-- If the object is a set or book, generate a bookmark for the toc -->
  104. <xsl:choose>
  105. <xsl:when test="self::index and $generate.index = 0"/>
  106. <xsl:when test="parent::*">
  107. <fox:destination internal-destination="{$id}"/>
  108. <xsl:apply-templates select="*" mode="fop1.foxdest"/>
  109. </xsl:when>
  110. <xsl:otherwise>
  111. <fox:destination internal-destination="{$id}"/>
  112. <xsl:apply-templates select="*" mode="fop1.foxdest"/>
  113. </xsl:otherwise>
  114. </xsl:choose>
  115. </xsl:template>
  116. <!-- Metadata support ("Document Properties" in Adobe Reader) -->
  117. <xsl:template name="fop1-document-information">
  118. <xsl:variable name="authors" select="(//author|//editor|//corpauthor|//authorgroup)[1]"/>
  119. <xsl:variable name="title">
  120. <xsl:apply-templates select="/*[1]" mode="label.markup"/>
  121. <xsl:apply-templates select="/*[1]" mode="title.markup"/>
  122. <xsl:variable name="subtitle">
  123. <xsl:apply-templates select="/*[1]" mode="subtitle.markup">
  124. <xsl:with-param name="verbose" select="0"/>
  125. </xsl:apply-templates>
  126. </xsl:variable>
  127. <xsl:if test="$subtitle !=''">
  128. <xsl:text> - </xsl:text>
  129. <xsl:value-of select="$subtitle"/>
  130. </xsl:if>
  131. </xsl:variable>
  132. <fo:declarations>
  133. <x:xmpmeta xmlns:x="adobe:ns:meta/">
  134. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  135. <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
  136. <!-- Dublin Core properties go here -->
  137. <!-- Title -->
  138. <dc:title><xsl:value-of select="normalize-space($title)"/></dc:title>
  139. <!-- Author -->
  140. <xsl:if test="$authors">
  141. <xsl:variable name="author">
  142. <xsl:choose>
  143. <xsl:when test="$authors[self::authorgroup]">
  144. <xsl:call-template name="person.name.list">
  145. <xsl:with-param name="person.list"
  146. select="$authors/*[self::author|self::corpauthor|
  147. self::othercredit|self::editor]"/>
  148. </xsl:call-template>
  149. </xsl:when>
  150. <xsl:when test="$authors[self::corpauthor]">
  151. <xsl:value-of select="$authors"/>
  152. </xsl:when>
  153. <xsl:when test="$authors[orgname]">
  154. <xsl:value-of select="$authors/orgname"/>
  155. </xsl:when>
  156. <xsl:otherwise>
  157. <xsl:call-template name="person.name">
  158. <xsl:with-param name="node" select="$authors"/>
  159. </xsl:call-template>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. </xsl:variable>
  163. <dc:creator><xsl:value-of select="normalize-space($author)"/></dc:creator>
  164. </xsl:if>
  165. <!-- Subject -->
  166. <xsl:if test="//subjectterm">
  167. <dc:description>
  168. <xsl:for-each select="//subjectterm">
  169. <xsl:value-of select="normalize-space(.)"/>
  170. <xsl:if test="position() != last()">
  171. <xsl:text>, </xsl:text>
  172. </xsl:if>
  173. </xsl:for-each>
  174. </dc:description>
  175. </xsl:if>
  176. </rdf:Description>
  177. <rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
  178. <!-- PDF properties go here -->
  179. <!-- Keywords -->
  180. <xsl:if test="//keyword">
  181. <pdf:Keywords>
  182. <xsl:for-each select="//keyword">
  183. <xsl:value-of select="normalize-space(.)"/>
  184. <xsl:if test="position() != last()">
  185. <xsl:text>, </xsl:text>
  186. </xsl:if>
  187. </xsl:for-each>
  188. </pdf:Keywords>
  189. </xsl:if>
  190. </rdf:Description>
  191. <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
  192. <!-- XMP properties go here -->
  193. <!-- Creator Tool -->
  194. <xmp:CreatorTool>DocBook XSL Stylesheets with Apache FOP</xmp:CreatorTool>
  195. </rdf:Description>
  196. </rdf:RDF>
  197. </x:xmpmeta>
  198. </fo:declarations>
  199. </xsl:template>
  200. </xsl:stylesheet>