profile-docbook.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?xml version="1.0" encoding="US-ASCII"?>
  2. <!--This file was created automatically by xsl2profile-->
  3. <!--from the DocBook XSL stylesheets. Do not edit this file.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exslt="http://exslt.org/common" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="db ng exsl exslt" version="1.0">
  5. <!-- It is important to use indent="no" here, otherwise verbatim -->
  6. <!-- environments get broken by indented tags...at least when the -->
  7. <!-- callout extension is used...at least with some processors -->
  8. <xsl:output method="xml" indent="no"/>
  9. <!-- ********************************************************************
  10. $Id$
  11. ********************************************************************
  12. This file is part of the XSL DocBook Stylesheet distribution.
  13. See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  14. and other information.
  15. ******************************************************************** -->
  16. <!-- ==================================================================== -->
  17. <xsl:include href="../VERSION"/>
  18. <xsl:include href="param.xsl"/>
  19. <xsl:include href="../lib/lib.xsl"/>
  20. <xsl:include href="../common/l10n.xsl"/>
  21. <xsl:include href="../common/common.xsl"/>
  22. <xsl:include href="../common/labels.xsl"/>
  23. <xsl:include href="../common/titles.xsl"/>
  24. <xsl:include href="../common/subtitles.xsl"/>
  25. <xsl:include href="../common/gentext.xsl"/>
  26. <xsl:include href="../common/olink.xsl"/>
  27. <xsl:include href="../common/targets.xsl"/>
  28. <xsl:include href="../common/pi.xsl"/>
  29. <xsl:include href="autotoc.xsl"/>
  30. <xsl:include href="autoidx.xsl"/>
  31. <xsl:include href="lists.xsl"/>
  32. <xsl:include href="callout.xsl"/>
  33. <xsl:include href="verbatim.xsl"/>
  34. <xsl:include href="graphics.xsl"/>
  35. <xsl:include href="xref.xsl"/>
  36. <xsl:include href="formal.xsl"/>
  37. <xsl:include href="table.xsl"/>
  38. <xsl:include href="htmltbl.xsl"/>
  39. <xsl:include href="sections.xsl"/>
  40. <xsl:include href="inline.xsl"/>
  41. <xsl:include href="footnote.xsl"/>
  42. <xsl:include href="fo.xsl"/>
  43. <xsl:include href="fo-rtf.xsl"/>
  44. <xsl:include href="info.xsl"/>
  45. <xsl:include href="keywords.xsl"/>
  46. <xsl:include href="division.xsl"/>
  47. <xsl:include href="index.xsl"/>
  48. <xsl:include href="toc.xsl"/>
  49. <xsl:include href="refentry.xsl"/>
  50. <xsl:include href="math.xsl"/>
  51. <xsl:include href="admon.xsl"/>
  52. <xsl:include href="component.xsl"/>
  53. <xsl:include href="biblio.xsl"/>
  54. <xsl:include href="biblio-iso690.xsl"/>
  55. <xsl:include href="glossary.xsl"/>
  56. <xsl:include href="block.xsl"/>
  57. <xsl:include href="task.xsl"/>
  58. <xsl:include href="qandaset.xsl"/>
  59. <xsl:include href="synop.xsl"/>
  60. <xsl:include href="titlepage.xsl"/>
  61. <xsl:include href="titlepage.templates.xsl"/>
  62. <xsl:include href="pagesetup.xsl"/>
  63. <xsl:include href="pi.xsl"/>
  64. <xsl:include href="spaces.xsl"/>
  65. <xsl:include href="ebnf.xsl"/>
  66. <xsl:include href="../html/chunker.xsl"/>
  67. <xsl:include href="annotations.xsl"/>
  68. <xsl:include href="../common/stripns.xsl"/>
  69. <xsl:include href="fop.xsl"/>
  70. <xsl:include href="fop1.xsl"/>
  71. <xsl:include href="passivetex.xsl"/>
  72. <xsl:include href="xep.xsl"/>
  73. <xsl:include href="axf.xsl"/>
  74. <xsl:include href="ptc.xsl"/>
  75. <xsl:param name="stylesheet.result.type" select="'fo'"/>
  76. <!-- ==================================================================== -->
  77. <xsl:key name="id" match="*" use="@id|@xml:id"/>
  78. <!-- ==================================================================== -->
  79. <xsl:template match="*">
  80. <xsl:message>
  81. <xsl:value-of select="name(.)"/>
  82. <xsl:text> encountered</xsl:text>
  83. <xsl:if test="parent::*">
  84. <xsl:text> in </xsl:text>
  85. <xsl:value-of select="name(parent::*)"/>
  86. </xsl:if>
  87. <xsl:text>, but no template matches.</xsl:text>
  88. </xsl:message>
  89. <fo:block color="red">
  90. <xsl:text>&lt;</xsl:text>
  91. <xsl:value-of select="name(.)"/>
  92. <xsl:text>&gt;</xsl:text>
  93. <xsl:apply-templates/>
  94. <xsl:text>&lt;/</xsl:text>
  95. <xsl:value-of select="name(.)"/>
  96. <xsl:text>&gt;</xsl:text>
  97. </fo:block>
  98. </xsl:template>
  99. <!-- Update this list if new root elements supported -->
  100. <xsl:variable name="root.elements" select="' appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex '"/>
  101. <xslo:include xmlns:xslo="http://www.w3.org/1999/XSL/Transform" href="../profiling/profile-mode.xsl"/><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"><xslo:choose><xslo:when test="*/self::ng:* or */self::db:*"><xslo:message>Stripping NS from DocBook 5/NG document.</xslo:message><xslo:variable name="stripped-content"><xslo:apply-templates select="/" mode="stripNS"/></xslo:variable><xslo:message>Processing stripped document.</xslo:message><xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/></xslo:when><xslo:otherwise><xslo:apply-templates select="/" mode="profile"/></xslo:otherwise></xslo:choose></xslo:variable><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-nodes" select="exslt:node-set($profiled-content)"/><xsl:template match="/">
  102. <xsl:choose>
  103. <!-- include extra test for Xalan quirk -->
  104. <xsl:when test="false()"/>
  105. <!-- Can't process unless namespace removed -->
  106. <xsl:when test="false()"/>
  107. <xsl:otherwise>
  108. <xsl:choose>
  109. <xsl:when test="$rootid != ''">
  110. <xsl:variable name="root.element" select="key('id', $rootid)"/>
  111. <xsl:choose>
  112. <xsl:when test="count($root.element) = 0">
  113. <xsl:message terminate="yes">
  114. <xsl:text>ID '</xsl:text>
  115. <xsl:value-of select="$rootid"/>
  116. <xsl:text>' not found in document.</xsl:text>
  117. </xsl:message>
  118. </xsl:when>
  119. <xsl:when test="not(contains($root.elements, concat(' ', local-name($root.element), ' ')))">
  120. <xsl:message terminate="yes">
  121. <xsl:text>ERROR: Document root element ($rootid=</xsl:text>
  122. <xsl:value-of select="$rootid"/>
  123. <xsl:text>) for FO output </xsl:text>
  124. <xsl:text>must be one of the following elements:</xsl:text>
  125. <xsl:value-of select="$root.elements"/>
  126. </xsl:message>
  127. </xsl:when>
  128. <!-- Otherwise proceed -->
  129. <xsl:otherwise>
  130. <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
  131. <xsl:apply-templates select="$root.element" mode="collect.targets"/>
  132. </xsl:if>
  133. <xsl:if test="$collect.xref.targets != 'only'">
  134. <xsl:apply-templates select="$root.element" mode="process.root"/>
  135. </xsl:if>
  136. </xsl:otherwise>
  137. </xsl:choose>
  138. </xsl:when>
  139. <!-- Otherwise process the document root element -->
  140. <xsl:otherwise>
  141. <xsl:variable name="document.element" select="*[1]"/>
  142. <xsl:choose>
  143. <xsl:when test="not(contains($root.elements, concat(' ', local-name($document.element), ' ')))">
  144. <xsl:message terminate="yes">
  145. <xsl:text>ERROR: Document root element for FO output </xsl:text>
  146. <xsl:text>must be one of the following elements:</xsl:text>
  147. <xsl:value-of select="$root.elements"/>
  148. </xsl:message>
  149. </xsl:when>
  150. <!-- Otherwise proceed -->
  151. <xsl:otherwise>
  152. <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
  153. <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
  154. </xsl:if>
  155. <xsl:if test="$collect.xref.targets != 'only'">
  156. <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
  157. </xsl:if>
  158. </xsl:otherwise>
  159. </xsl:choose>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. </xsl:otherwise>
  163. </xsl:choose>
  164. </xsl:template>
  165. <xsl:template match="*" mode="process.root">
  166. <xsl:variable name="document.element" select="self::*"/>
  167. <xsl:call-template name="root.messages"/>
  168. <xsl:variable name="title">
  169. <xsl:choose>
  170. <xsl:when test="$document.element/title[1]">
  171. <xsl:value-of select="$document.element/title[1]"/>
  172. </xsl:when>
  173. <xsl:otherwise>[could not find document title]</xsl:otherwise>
  174. </xsl:choose>
  175. </xsl:variable>
  176. <!-- Include all id values in XEP output -->
  177. <xsl:if test="$xep.extensions != 0">
  178. <xsl:processing-instruction name="xep-pdf-drop-unused-destinations">false</xsl:processing-instruction>
  179. </xsl:if>
  180. <fo:root xsl:use-attribute-sets="root.properties">
  181. <xsl:attribute name="language">
  182. <xsl:call-template name="l10n.language">
  183. <xsl:with-param name="target" select="/*[1]"/>
  184. </xsl:call-template>
  185. </xsl:attribute>
  186. <xsl:if test="$xep.extensions != 0">
  187. <xsl:call-template name="xep-pis"/>
  188. <xsl:call-template name="xep-document-information"/>
  189. </xsl:if>
  190. <xsl:if test="$axf.extensions != 0">
  191. <xsl:call-template name="axf-document-information"/>
  192. </xsl:if>
  193. <xsl:call-template name="setup.pagemasters"/>
  194. <xsl:if test="$fop.extensions != 0">
  195. <xsl:apply-templates select="$document.element" mode="fop.outline"/>
  196. </xsl:if>
  197. <xsl:if test="$fop1.extensions != 0">
  198. <xsl:variable name="bookmarks">
  199. <xsl:apply-templates select="$document.element" mode="fop1.outline"/>
  200. </xsl:variable>
  201. <xsl:if test="string($bookmarks) != ''">
  202. <fo:bookmark-tree>
  203. <xsl:copy-of select="$bookmarks"/>
  204. </fo:bookmark-tree>
  205. </xsl:if>
  206. </xsl:if>
  207. <xsl:if test="$xep.extensions != 0">
  208. <xsl:variable name="bookmarks">
  209. <xsl:apply-templates select="$document.element" mode="xep.outline"/>
  210. </xsl:variable>
  211. <xsl:if test="string($bookmarks) != ''">
  212. <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
  213. <xsl:copy-of select="$bookmarks"/>
  214. </rx:outline>
  215. </xsl:if>
  216. </xsl:if>
  217. <xsl:if test="$arbortext.extensions != 0 and $ati.xsl11.bookmarks != 0">
  218. <xsl:variable name="bookmarks">
  219. <xsl:apply-templates select="$document.element" mode="ati.xsl11.bookmarks"/>
  220. </xsl:variable>
  221. <xsl:if test="string($bookmarks) != ''">
  222. <fo:bookmark-tree>
  223. <xsl:copy-of select="$bookmarks"/>
  224. </fo:bookmark-tree>
  225. </xsl:if>
  226. </xsl:if>
  227. <xsl:apply-templates select="$document.element"/>
  228. </fo:root>
  229. </xsl:template>
  230. <xsl:template name="root.messages">
  231. <!-- redefine this any way you'd like to output messages -->
  232. <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
  233. <xsl:message>
  234. <xsl:text>Making </xsl:text>
  235. <xsl:value-of select="$page.orientation"/>
  236. <xsl:text> pages on </xsl:text>
  237. <xsl:value-of select="$paper.type"/>
  238. <xsl:text> paper (</xsl:text>
  239. <xsl:value-of select="$page.width"/>
  240. <xsl:text>x</xsl:text>
  241. <xsl:value-of select="$page.height"/>
  242. <xsl:text>)</xsl:text>
  243. </xsl:message>
  244. </xsl:template>
  245. <!-- ==================================================================== -->
  246. </xsl:stylesheet>