lot-lof.xsl 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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:dita2xslfo="http://dita-ot.sourceforge.net/ns/200910/dita2xslfo"
  5. xmlns:opentopic="http://www.idiominc.com/opentopic"
  6. xmlns:opentopic-index="http://www.idiominc.com/opentopic/index"
  7. xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder"
  8. exclude-result-prefixes="opentopic opentopic-index dita2xslfo ot-placeholder"
  9. version="2.0">
  10. <xsl:variable name="tableset">
  11. <xsl:for-each select="//*[contains (@class, ' topic/table ')][*[contains(@class, ' topic/title ' )]]">
  12. <xsl:copy>
  13. <xsl:copy-of select="@*"/>
  14. <xsl:if test="not(@id)">
  15. <xsl:attribute name="id">
  16. <xsl:call-template name="get-id"/>
  17. </xsl:attribute>
  18. </xsl:if>
  19. </xsl:copy>
  20. </xsl:for-each>
  21. </xsl:variable>
  22. <xsl:variable name="figureset">
  23. <xsl:for-each select="//*[contains (@class, ' topic/fig ')][*[contains(@class, ' topic/title ' )]]">
  24. <xsl:copy>
  25. <xsl:copy-of select="@*"/>
  26. <xsl:if test="not(@id)">
  27. <xsl:attribute name="id">
  28. <xsl:call-template name="get-id"/>
  29. </xsl:attribute>
  30. </xsl:if>
  31. </xsl:copy>
  32. </xsl:for-each>
  33. </xsl:variable>
  34. <!-- LOT -->
  35. <xsl:template match="ot-placeholder:tablelist" name="createTableList">
  36. <xsl:if test="//*[contains(@class, ' topic/table ')]/*[contains(@class, ' topic/title ' )]">
  37. <!--exists tables with titles-->
  38. <fo:page-sequence master-reference="toc-sequence" xsl:use-attribute-sets="page-sequence.lot">
  39. <xsl:call-template name="insertTocStaticContents"/>
  40. <fo:flow flow-name="xsl-region-body">
  41. <fo:block start-indent="0in">
  42. <xsl:call-template name="createLOTHeader"/>
  43. <xsl:apply-templates select="//*[contains (@class, ' topic/table ')][child::*[contains(@class, ' topic/title ' )]]" mode="list.of.tables"/>
  44. </fo:block>
  45. </fo:flow>
  46. </fo:page-sequence>
  47. </xsl:if>
  48. </xsl:template>
  49. <xsl:template name="createLOTHeader">
  50. <fo:block xsl:use-attribute-sets="__lotf__heading" id="{$id.lot}">
  51. <fo:marker marker-class-name="current-header">
  52. <xsl:call-template name="getVariable">
  53. <xsl:with-param name="id" select="'List of Tables'"/>
  54. </xsl:call-template>
  55. </fo:marker>
  56. <xsl:call-template name="getVariable">
  57. <xsl:with-param name="id" select="'List of Tables'"/>
  58. </xsl:call-template>
  59. </fo:block>
  60. </xsl:template>
  61. <xsl:template match="*[contains (@class, ' topic/table ')][child::*[contains(@class, ' topic/title ' )]]" mode="list.of.tables">
  62. <fo:block xsl:use-attribute-sets="__lotf__indent">
  63. <fo:block xsl:use-attribute-sets="__lotf__content">
  64. <fo:basic-link xsl:use-attribute-sets="__toc__link">
  65. <xsl:attribute name="internal-destination">
  66. <xsl:call-template name="get-id"/>
  67. </xsl:attribute>
  68. <fo:inline xsl:use-attribute-sets="__lotf__title">
  69. <xsl:call-template name="getVariable">
  70. <xsl:with-param name="id" select="'Table.title'"/>
  71. <xsl:with-param name="params">
  72. <number>
  73. <xsl:variable name="id">
  74. <xsl:call-template name="get-id"/>
  75. </xsl:variable>
  76. <xsl:variable name="tableNumber">
  77. <xsl:number format="1" value="count($tableset/*[@id = $id]/preceding-sibling::*) + 1" />
  78. </xsl:variable>
  79. <xsl:value-of select="$tableNumber"/>
  80. </number>
  81. <title>
  82. <xsl:apply-templates select="./*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  83. </title>
  84. </xsl:with-param>
  85. </xsl:call-template>
  86. </fo:inline>
  87. <fo:inline xsl:use-attribute-sets="__lotf__page-number">
  88. <fo:leader xsl:use-attribute-sets="__lotf__leader"/>
  89. <fo:page-number-citation>
  90. <xsl:attribute name="ref-id">
  91. <xsl:call-template name="get-id"/>
  92. </xsl:attribute>
  93. </fo:page-number-citation>
  94. </fo:inline>
  95. </fo:basic-link>
  96. </fo:block>
  97. </fo:block>
  98. </xsl:template>
  99. <!-- LOF -->
  100. <xsl:template match="ot-placeholder:figurelist" name="createFigureList">
  101. <xsl:if test="//*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/title ' )]">
  102. <!--exists figures with titles-->
  103. <fo:page-sequence master-reference="toc-sequence" xsl:use-attribute-sets="page-sequence.lof">
  104. <xsl:call-template name="insertTocStaticContents"/>
  105. <fo:flow flow-name="xsl-region-body">
  106. <fo:block start-indent="0in">
  107. <xsl:call-template name="createLOFHeader"/>
  108. <xsl:apply-templates select="//*[contains (@class, ' topic/fig ')][child::*[contains(@class, ' topic/title ' )]]" mode="list.of.figures"/>
  109. </fo:block>
  110. </fo:flow>
  111. </fo:page-sequence>
  112. </xsl:if>
  113. </xsl:template>
  114. <xsl:template name="createLOFHeader">
  115. <fo:block xsl:use-attribute-sets="__lotf__heading" id="{$id.lof}">
  116. <fo:marker marker-class-name="current-header">
  117. <xsl:call-template name="getVariable">
  118. <xsl:with-param name="id" select="'List of Figures'"/>
  119. </xsl:call-template>
  120. </fo:marker>
  121. <xsl:call-template name="getVariable">
  122. <xsl:with-param name="id" select="'List of Figures'"/>
  123. </xsl:call-template>
  124. </fo:block>
  125. </xsl:template>
  126. <xsl:template match="*[contains (@class, ' topic/fig ')][child::*[contains(@class, ' topic/title ' )]]" mode="list.of.figures">
  127. <fo:block xsl:use-attribute-sets="__lotf__indent">
  128. <fo:block xsl:use-attribute-sets="__lotf__content">
  129. <fo:basic-link xsl:use-attribute-sets="__toc__link">
  130. <xsl:attribute name="internal-destination">
  131. <xsl:call-template name="get-id"/>
  132. </xsl:attribute>
  133. <fo:inline xsl:use-attribute-sets="__lotf__title">
  134. <xsl:call-template name="getVariable">
  135. <xsl:with-param name="id" select="'Figure.title'"/>
  136. <xsl:with-param name="params">
  137. <number>
  138. <xsl:variable name="id">
  139. <xsl:call-template name="get-id"/>
  140. </xsl:variable>
  141. <xsl:variable name="figureNumber">
  142. <xsl:number format="1" value="count($figureset/*[@id = $id]/preceding-sibling::*) + 1" />
  143. </xsl:variable>
  144. <xsl:value-of select="$figureNumber"/>
  145. </number>
  146. <title>
  147. <xsl:apply-templates select="./*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  148. </title>
  149. </xsl:with-param>
  150. </xsl:call-template>
  151. </fo:inline>
  152. <fo:inline xsl:use-attribute-sets="__lotf__page-number">
  153. <fo:leader xsl:use-attribute-sets="__lotf__leader"/>
  154. <fo:page-number-citation>
  155. <xsl:attribute name="ref-id">
  156. <xsl:call-template name="get-id"/>
  157. </xsl:attribute>
  158. </fo:page-number-citation>
  159. </fo:inline>
  160. </fo:basic-link>
  161. </fo:block>
  162. </fo:block>
  163. </xsl:template>
  164. </xsl:stylesheet>