lot-lof.xsl 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?xml version='1.0'?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. Copyright 2011 Reuven Weiser
  5. See the accompanying LICENSE file for applicable license.
  6. -->
  7. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  9. xmlns:dita2xslfo="http://dita-ot.sourceforge.net/ns/200910/dita2xslfo"
  10. xmlns:opentopic="http://www.idiominc.com/opentopic"
  11. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  12. xmlns:opentopic-index="http://www.idiominc.com/opentopic/index"
  13. xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder"
  14. exclude-result-prefixes="dita-ot opentopic opentopic-index dita2xslfo ot-placeholder"
  15. version="2.0">
  16. <xsl:variable name="tableset">
  17. <xsl:for-each select="//*[contains (@class, ' topic/table ')][*[contains(@class, ' topic/title ' )]]">
  18. <xsl:if test="dita-ot:notExcludedByDraftElement(.)">
  19. <xsl:copy>
  20. <xsl:copy-of select="@*"/>
  21. <xsl:if test="not(@id)">
  22. <xsl:attribute name="id">
  23. <xsl:call-template name="get-id"/>
  24. </xsl:attribute>
  25. </xsl:if>
  26. </xsl:copy>
  27. </xsl:if>
  28. </xsl:for-each>
  29. </xsl:variable>
  30. <xsl:variable name="figureset">
  31. <xsl:for-each select="//*[contains (@class, ' topic/fig ')][*[contains(@class, ' topic/title ' )]]">
  32. <xsl:if test="dita-ot:notExcludedByDraftElement(.)">
  33. <xsl:copy>
  34. <xsl:copy-of select="@*"/>
  35. <xsl:if test="not(@id)">
  36. <xsl:attribute name="id">
  37. <xsl:call-template name="get-id"/>
  38. </xsl:attribute>
  39. </xsl:if>
  40. </xsl:copy>
  41. </xsl:if>
  42. </xsl:for-each>
  43. </xsl:variable>
  44. <!-- LOT -->
  45. <xsl:template match="ot-placeholder:tablelist" name="createTableList">
  46. <xsl:if test="//*[contains(@class, ' topic/table ')]/*[contains(@class, ' topic/title ' )]">
  47. <!--exists tables with titles-->
  48. <fo:page-sequence master-reference="toc-sequence" xsl:use-attribute-sets="page-sequence.lot">
  49. <xsl:call-template name="insertTocStaticContents"/>
  50. <fo:flow flow-name="xsl-region-body">
  51. <fo:block start-indent="0in">
  52. <xsl:call-template name="createLOTHeader"/>
  53. <xsl:apply-templates select="//*[contains (@class, ' topic/table ')]
  54. [child::*[contains(@class, ' topic/title ' )]]
  55. [dita-ot:notExcludedByDraftElement(.)]"
  56. mode="list.of.tables"/>
  57. </fo:block>
  58. </fo:flow>
  59. </fo:page-sequence>
  60. </xsl:if>
  61. </xsl:template>
  62. <xsl:template name="createLOTHeader">
  63. <fo:block xsl:use-attribute-sets="__lotf__heading" id="{$id.lot}">
  64. <fo:marker marker-class-name="current-header">
  65. <xsl:call-template name="getVariable">
  66. <xsl:with-param name="id" select="'List of Tables'"/>
  67. </xsl:call-template>
  68. </fo:marker>
  69. <xsl:apply-templates select="." mode="customTopicMarker"/>
  70. <xsl:apply-templates select="." mode="customTopicAnchor"/>
  71. <xsl:call-template name="getVariable">
  72. <xsl:with-param name="id" select="'List of Tables'"/>
  73. </xsl:call-template>
  74. </fo:block>
  75. </xsl:template>
  76. <xsl:template match="*[contains (@class, ' topic/table ')][child::*[contains(@class, ' topic/title ' )]]" mode="list.of.tables">
  77. <fo:block xsl:use-attribute-sets="__lotf__indent">
  78. <fo:block xsl:use-attribute-sets="__lotf__content">
  79. <fo:basic-link xsl:use-attribute-sets="__toc__link">
  80. <xsl:attribute name="internal-destination">
  81. <xsl:call-template name="get-id"/>
  82. </xsl:attribute>
  83. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]/revprop[@changebar]" mode="changebar">
  84. <xsl:with-param name="changebar-id" select="concat(dita-ot:generate-changebar-id(.),'-toc')"/>
  85. </xsl:apply-templates>
  86. <fo:inline xsl:use-attribute-sets="__lotf__title">
  87. <xsl:call-template name="getVariable">
  88. <xsl:with-param name="id" select="'Table.title'"/>
  89. <xsl:with-param name="params">
  90. <number>
  91. <xsl:variable name="id">
  92. <xsl:call-template name="get-id"/>
  93. </xsl:variable>
  94. <xsl:variable name="tableNumber">
  95. <xsl:number format="1" value="count($tableset/*[@id = $id]/preceding-sibling::*) + 1" />
  96. </xsl:variable>
  97. <xsl:value-of select="$tableNumber"/>
  98. </number>
  99. <title>
  100. <xsl:apply-templates select="./*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  101. </title>
  102. </xsl:with-param>
  103. </xsl:call-template>
  104. </fo:inline>
  105. <fo:inline xsl:use-attribute-sets="__lotf__page-number">
  106. <fo:leader xsl:use-attribute-sets="__lotf__leader"/>
  107. <fo:page-number-citation>
  108. <xsl:attribute name="ref-id">
  109. <xsl:call-template name="get-id"/>
  110. </xsl:attribute>
  111. </fo:page-number-citation>
  112. </fo:inline>
  113. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]/revprop[@changebar]" mode="changebar">
  114. <xsl:with-param name="changebar-id" select="concat(dita-ot:generate-changebar-id(.),'-toc')"/>
  115. </xsl:apply-templates>
  116. </fo:basic-link>
  117. </fo:block>
  118. </fo:block>
  119. </xsl:template>
  120. <!-- LOF -->
  121. <xsl:template match="ot-placeholder:figurelist" name="createFigureList">
  122. <xsl:if test="//*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/title ' )]">
  123. <!--exists figures with titles-->
  124. <fo:page-sequence master-reference="toc-sequence" xsl:use-attribute-sets="page-sequence.lof">
  125. <xsl:call-template name="insertTocStaticContents"/>
  126. <fo:flow flow-name="xsl-region-body">
  127. <fo:block start-indent="0in">
  128. <xsl:call-template name="createLOFHeader"/>
  129. <xsl:apply-templates select="//*[contains (@class, ' topic/fig ')]
  130. [child::*[contains(@class, ' topic/title ' )]]
  131. [dita-ot:notExcludedByDraftElement(.)]"
  132. mode="list.of.figures"/>
  133. </fo:block>
  134. </fo:flow>
  135. </fo:page-sequence>
  136. </xsl:if>
  137. </xsl:template>
  138. <xsl:template name="createLOFHeader">
  139. <fo:block xsl:use-attribute-sets="__lotf__heading" id="{$id.lof}">
  140. <fo:marker marker-class-name="current-header">
  141. <xsl:call-template name="getVariable">
  142. <xsl:with-param name="id" select="'List of Figures'"/>
  143. </xsl:call-template>
  144. </fo:marker>
  145. <xsl:apply-templates select="." mode="customTopicMarker"/>
  146. <xsl:apply-templates select="." mode="customTopicAnchor"/>
  147. <xsl:call-template name="getVariable">
  148. <xsl:with-param name="id" select="'List of Figures'"/>
  149. </xsl:call-template>
  150. </fo:block>
  151. </xsl:template>
  152. <xsl:template match="*[contains (@class, ' topic/fig ')][child::*[contains(@class, ' topic/title ' )]]" mode="list.of.figures">
  153. <fo:block xsl:use-attribute-sets="__lotf__indent">
  154. <fo:block xsl:use-attribute-sets="__lotf__content">
  155. <fo:basic-link xsl:use-attribute-sets="__toc__link">
  156. <xsl:attribute name="internal-destination">
  157. <xsl:call-template name="get-id"/>
  158. </xsl:attribute>
  159. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]/revprop[@changebar]" mode="changebar">
  160. <xsl:with-param name="changebar-id" select="concat(dita-ot:generate-changebar-id(.),'-toc')"/>
  161. </xsl:apply-templates>
  162. <fo:inline xsl:use-attribute-sets="__lotf__title">
  163. <xsl:call-template name="getVariable">
  164. <xsl:with-param name="id" select="'Figure.title'"/>
  165. <xsl:with-param name="params">
  166. <number>
  167. <xsl:variable name="id">
  168. <xsl:call-template name="get-id"/>
  169. </xsl:variable>
  170. <xsl:variable name="figureNumber">
  171. <xsl:number format="1" value="count($figureset/*[@id = $id]/preceding-sibling::*) + 1" />
  172. </xsl:variable>
  173. <xsl:value-of select="$figureNumber"/>
  174. </number>
  175. <title>
  176. <xsl:apply-templates select="./*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  177. </title>
  178. </xsl:with-param>
  179. </xsl:call-template>
  180. </fo:inline>
  181. <fo:inline xsl:use-attribute-sets="__lotf__page-number">
  182. <fo:leader xsl:use-attribute-sets="__lotf__leader"/>
  183. <fo:page-number-citation>
  184. <xsl:attribute name="ref-id">
  185. <xsl:call-template name="get-id"/>
  186. </xsl:attribute>
  187. </fo:page-number-citation>
  188. </fo:inline>
  189. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]/revprop[@changebar]" mode="changebar">
  190. <xsl:with-param name="changebar-id" select="concat(dita-ot:generate-changebar-id(.),'-toc')"/>
  191. </xsl:apply-templates>
  192. </fo:basic-link>
  193. </fo:block>
  194. </fo:block>
  195. </xsl:template>
  196. </xsl:stylesheet>