1
0

profile-docbook.xsl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <?xml version="1.0" encoding="US-ASCII"?>
  2. <!--This file was created automatically by xsl2profile-->
  3. <!--from the DocBook XSL stylesheets.-->
  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: docbook.xsl 9647 2012-10-26 17:42:03Z bobstayton $
  11. ********************************************************************
  12. This file is part of the XSL DocBook Stylesheet distribution.
  13. See ../README or http://docbook.sf.net/release/xsl/current/ for
  14. copyright and other information.
  15. ******************************************************************** -->
  16. <!-- ==================================================================== -->
  17. <xsl:include href="../VERSION.xsl"/>
  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/utility.xsl"/>
  23. <xsl:include href="../common/labels.xsl"/>
  24. <xsl:include href="../common/titles.xsl"/>
  25. <xsl:include href="../common/subtitles.xsl"/>
  26. <xsl:include href="../common/gentext.xsl"/>
  27. <xsl:include href="../common/olink.xsl"/>
  28. <xsl:include href="../common/targets.xsl"/>
  29. <xsl:include href="../common/pi.xsl"/>
  30. <xsl:include href="autotoc.xsl"/>
  31. <xsl:include href="autoidx.xsl"/>
  32. <xsl:include href="lists.xsl"/>
  33. <xsl:include href="callout.xsl"/>
  34. <xsl:include href="verbatim.xsl"/>
  35. <xsl:include href="graphics.xsl"/>
  36. <xsl:include href="xref.xsl"/>
  37. <xsl:include href="formal.xsl"/>
  38. <xsl:include href="table.xsl"/>
  39. <xsl:include href="htmltbl.xsl"/>
  40. <xsl:include href="sections.xsl"/>
  41. <xsl:include href="inline.xsl"/>
  42. <xsl:include href="footnote.xsl"/>
  43. <xsl:include href="fo.xsl"/>
  44. <xsl:include href="fo-rtf.xsl"/>
  45. <xsl:include href="info.xsl"/>
  46. <xsl:include href="keywords.xsl"/>
  47. <xsl:include href="division.xsl"/>
  48. <xsl:include href="index.xsl"/>
  49. <xsl:include href="toc.xsl"/>
  50. <xsl:include href="refentry.xsl"/>
  51. <xsl:include href="math.xsl"/>
  52. <xsl:include href="admon.xsl"/>
  53. <xsl:include href="component.xsl"/>
  54. <xsl:include href="biblio.xsl"/>
  55. <xsl:include href="biblio-iso690.xsl"/>
  56. <xsl:include href="glossary.xsl"/>
  57. <xsl:include href="block.xsl"/>
  58. <xsl:include href="task.xsl"/>
  59. <xsl:include href="qandaset.xsl"/>
  60. <xsl:include href="synop.xsl"/>
  61. <xsl:include href="titlepage.xsl"/>
  62. <xsl:include href="titlepage.templates.xsl"/>
  63. <xsl:include href="pagesetup.xsl"/>
  64. <xsl:include href="pi.xsl"/>
  65. <xsl:include href="spaces.xsl"/>
  66. <xsl:include href="ebnf.xsl"/>
  67. <xsl:include href="../html/chunker.xsl"/>
  68. <xsl:include href="annotations.xsl"/>
  69. <xsl:include href="../common/stripns.xsl"/>
  70. <xsl:include href="fop.xsl"/>
  71. <xsl:include href="fop1.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:text>Element </xsl:text>
  82. <xsl:value-of select="local-name(.)"/>
  83. <xsl:text> in namespace '</xsl:text>
  84. <xsl:value-of select="namespace-uri(.)"/>
  85. <xsl:text>' encountered</xsl:text>
  86. <xsl:if test="parent::*">
  87. <xsl:text> in </xsl:text>
  88. <xsl:value-of select="name(parent::*)"/>
  89. </xsl:if>
  90. <xsl:text>, but no template matches.</xsl:text>
  91. </xsl:message>
  92. <fo:block color="red">
  93. <xsl:text>&lt;</xsl:text>
  94. <xsl:value-of select="name(.)"/>
  95. <xsl:text>&gt;</xsl:text>
  96. <xsl:apply-templates/>
  97. <xsl:text>&lt;/</xsl:text>
  98. <xsl:value-of select="name(.)"/>
  99. <xsl:text>&gt;</xsl:text>
  100. </fo:block>
  101. </xsl:template>
  102. <!-- Update this list if new root elements supported -->
  103. <xsl:variable name="root.elements" select="' appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex '"/>
  104. <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>Note: namesp. cut : stripped namespace before processing</xslo:message><xslo:variable name="stripped-content"><xslo:apply-templates select="/" mode="stripNS"/></xslo:variable><xslo:message>Note: namesp. cut : 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="/">
  105. <!-- * Get a title for current doc so that we let the user -->
  106. <!-- * know what document we are processing at this point. -->
  107. <xsl:variable name="doc.title">
  108. <xsl:call-template name="get.doc.title"/>
  109. </xsl:variable>
  110. <xsl:choose>
  111. <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
  112. toss the namespace and continue. Use the docbook5 namespaced
  113. stylesheets for DocBook5 if you don't want to use this feature.-->
  114. <xsl:when test="false()"/>
  115. <!-- Can't process unless namespace removed -->
  116. <xsl:when test="false()"/>
  117. <xsl:otherwise>
  118. <xsl:choose>
  119. <xsl:when test="$rootid != ''">
  120. <xsl:variable name="root.element" select="key('id', $rootid)"/>
  121. <xsl:choose>
  122. <xsl:when test="count($root.element) = 0">
  123. <xsl:message terminate="yes">
  124. <xsl:text>ID '</xsl:text>
  125. <xsl:value-of select="$rootid"/>
  126. <xsl:text>' not found in document.</xsl:text>
  127. </xsl:message>
  128. </xsl:when>
  129. <xsl:when test="not(contains($root.elements, concat(' ', local-name($root.element), ' ')))">
  130. <xsl:message terminate="yes">
  131. <xsl:text>ERROR: Document root element ($rootid=</xsl:text>
  132. <xsl:value-of select="$rootid"/>
  133. <xsl:text>) for FO output </xsl:text>
  134. <xsl:text>must be one of the following elements:</xsl:text>
  135. <xsl:value-of select="$root.elements"/>
  136. </xsl:message>
  137. </xsl:when>
  138. <!-- Otherwise proceed -->
  139. <xsl:otherwise>
  140. <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
  141. <xsl:apply-templates select="$root.element" mode="collect.targets"/>
  142. </xsl:if>
  143. <xsl:if test="$collect.xref.targets != 'only'">
  144. <xsl:apply-templates select="$root.element" mode="process.root"/>
  145. </xsl:if>
  146. </xsl:otherwise>
  147. </xsl:choose>
  148. </xsl:when>
  149. <!-- Otherwise process the document root element -->
  150. <xsl:otherwise>
  151. <xsl:variable name="document.element" select="*[1]"/>
  152. <xsl:choose>
  153. <xsl:when test="not(contains($root.elements, concat(' ', local-name($document.element), ' ')))">
  154. <xsl:message terminate="yes">
  155. <xsl:text>ERROR: Document root element for FO output </xsl:text>
  156. <xsl:text>must be one of the following elements:</xsl:text>
  157. <xsl:value-of select="$root.elements"/>
  158. </xsl:message>
  159. </xsl:when>
  160. <!-- Otherwise proceed -->
  161. <xsl:otherwise>
  162. <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
  163. <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
  164. </xsl:if>
  165. <xsl:if test="$collect.xref.targets != 'only'">
  166. <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
  167. </xsl:if>
  168. </xsl:otherwise>
  169. </xsl:choose>
  170. </xsl:otherwise>
  171. </xsl:choose>
  172. </xsl:otherwise>
  173. </xsl:choose>
  174. </xsl:template>
  175. <xsl:template match="*" mode="process.root">
  176. <xsl:variable name="document.element" select="self::*"/>
  177. <xsl:call-template name="root.messages"/>
  178. <xsl:variable name="title">
  179. <xsl:choose>
  180. <xsl:when test="$document.element/title[1]">
  181. <xsl:value-of select="$document.element/title[1]"/>
  182. </xsl:when>
  183. <xsl:otherwise>[could not find document title]</xsl:otherwise>
  184. </xsl:choose>
  185. </xsl:variable>
  186. <!-- Include all id values in XEP output -->
  187. <xsl:if test="$xep.extensions != 0">
  188. <xsl:processing-instruction name="xep-pdf-drop-unused-destinations">false</xsl:processing-instruction>
  189. </xsl:if>
  190. <fo:root xsl:use-attribute-sets="root.properties">
  191. <xsl:attribute name="language">
  192. <xsl:call-template name="l10n.language">
  193. <xsl:with-param name="target" select="/*[1]"/>
  194. </xsl:call-template>
  195. </xsl:attribute>
  196. <xsl:if test="$xep.extensions != 0">
  197. <xsl:call-template name="xep-pis"/>
  198. <xsl:call-template name="xep-document-information"/>
  199. </xsl:if>
  200. <xsl:if test="$axf.extensions != 0">
  201. <xsl:call-template name="axf-document-information"/>
  202. </xsl:if>
  203. <xsl:call-template name="setup.pagemasters"/>
  204. <xsl:if test="$fop.extensions != 0">
  205. <xsl:apply-templates select="$document.element" mode="fop.outline"/>
  206. </xsl:if>
  207. <xsl:if test="$fop1.extensions != 0">
  208. <xsl:call-template name="fop1-document-information"/>
  209. <xsl:variable name="bookmarks">
  210. <xsl:apply-templates select="$document.element" mode="fop1.outline"/>
  211. </xsl:variable>
  212. <xsl:if test="string($bookmarks) != ''">
  213. <fo:bookmark-tree>
  214. <xsl:copy-of select="$bookmarks"/>
  215. </fo:bookmark-tree>
  216. </xsl:if>
  217. <xsl:apply-templates select="$document.element" mode="fop1.foxdest"/>
  218. </xsl:if>
  219. <xsl:if test="$xep.extensions != 0">
  220. <xsl:variable name="bookmarks">
  221. <xsl:apply-templates select="$document.element" mode="xep.outline"/>
  222. </xsl:variable>
  223. <xsl:if test="string($bookmarks) != ''">
  224. <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
  225. <xsl:copy-of select="$bookmarks"/>
  226. </rx:outline>
  227. </xsl:if>
  228. </xsl:if>
  229. <xsl:if test="$arbortext.extensions != 0 and $ati.xsl11.bookmarks != 0">
  230. <xsl:variable name="bookmarks">
  231. <xsl:apply-templates select="$document.element" mode="ati.xsl11.bookmarks"/>
  232. </xsl:variable>
  233. <xsl:if test="string($bookmarks) != ''">
  234. <fo:bookmark-tree>
  235. <xsl:copy-of select="$bookmarks"/>
  236. </fo:bookmark-tree>
  237. </xsl:if>
  238. </xsl:if>
  239. <xsl:apply-templates select="$document.element"/>
  240. </fo:root>
  241. </xsl:template>
  242. <xsl:template name="root.messages">
  243. <!-- redefine this any way you'd like to output messages -->
  244. <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
  245. <xsl:message>
  246. <xsl:text>Making </xsl:text>
  247. <xsl:value-of select="$page.orientation"/>
  248. <xsl:text> pages on </xsl:text>
  249. <xsl:value-of select="$paper.type"/>
  250. <xsl:text> paper (</xsl:text>
  251. <xsl:value-of select="$page.width"/>
  252. <xsl:text>x</xsl:text>
  253. <xsl:value-of select="$page.height"/>
  254. <xsl:text>)</xsl:text>
  255. </xsl:message>
  256. </xsl:template>
  257. <!-- ==================================================================== -->
  258. </xsl:stylesheet>