map2html5-coverImpl_template.xsl 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. Copyright 2014 Jarno Elovirta
  5. See the accompanying LICENSE file for applicable license.
  6. -->
  7. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  9. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  10. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  11. version="2.0"
  12. exclude-result-prefixes="xs dita-ot ditamsg">
  13. <xsl:import href="plugin:org.dita.html5:xsl/dita2html5Impl.xsl"/>
  14. <dita:extension id="dita.xsl.html5.cover"
  15. behavior="org.dita.dost.platform.ImportXSLAction"
  16. xmlns:dita="http://dita-ot.sourceforge.net"/>
  17. <xsl:template match="*[contains(@class, ' map/map ')]" mode="toc">
  18. <xsl:param name="pathFromMaplist"/>
  19. <xsl:if test="descendant::*[contains(@class, ' map/topicref ')]
  20. [not(@toc = 'no')]
  21. [not(@processing-role = 'resource-only')]">
  22. <nav>
  23. <ul>
  24. <xsl:call-template name="commonattributes"/>
  25. <xsl:apply-templates select="*[contains(@class, ' map/topicref ')]" mode="toc">
  26. <xsl:with-param name="pathFromMaplist" select="$pathFromMaplist"/>
  27. </xsl:apply-templates>
  28. </ul>
  29. </nav>
  30. </xsl:if>
  31. </xsl:template>
  32. <xsl:template match="*[contains(@class, ' map/topicref ')]
  33. [not(@toc = 'no')]
  34. [not(@processing-role = 'resource-only')]"
  35. mode="toc">
  36. <xsl:param name="pathFromMaplist"/>
  37. <xsl:variable name="title">
  38. <xsl:apply-templates select="." mode="get-navtitle"/>
  39. </xsl:variable>
  40. <xsl:choose>
  41. <xsl:when test="normalize-space($title)">
  42. <li>
  43. <xsl:call-template name="commonattributes"/>
  44. <xsl:choose>
  45. <!-- If there is a reference to a DITA or HTML file, and it is not external: -->
  46. <xsl:when test="normalize-space(@href)">
  47. <a>
  48. <xsl:attribute name="href">
  49. <xsl:choose>
  50. <xsl:when test="@copy-to and not(contains(@chunk, 'to-content')) and
  51. (not(@format) or @format = 'dita' or @format = 'ditamap') ">
  52. <xsl:if test="not(@scope = 'external')">
  53. <xsl:value-of select="$pathFromMaplist"/>
  54. </xsl:if>
  55. <xsl:call-template name="replace-extension">
  56. <xsl:with-param name="filename" select="@copy-to"/>
  57. <xsl:with-param name="extension" select="$OUTEXT"/>
  58. </xsl:call-template>
  59. <xsl:if test="not(contains(@copy-to, '#')) and contains(@href, '#')">
  60. <xsl:value-of select="concat('#', substring-after(@href, '#'))"/>
  61. </xsl:if>
  62. </xsl:when>
  63. <xsl:when test="not(@scope = 'external') and (not(@format) or @format = 'dita' or @format = 'ditamap')">
  64. <xsl:if test="not(@scope = 'external')">
  65. <xsl:value-of select="$pathFromMaplist"/>
  66. </xsl:if>
  67. <xsl:call-template name="replace-extension">
  68. <xsl:with-param name="filename" select="@href"/>
  69. <xsl:with-param name="extension" select="$OUTEXT"/>
  70. </xsl:call-template>
  71. </xsl:when>
  72. <xsl:otherwise><!-- If non-DITA, keep the href as-is -->
  73. <xsl:if test="not(@scope = 'external')">
  74. <xsl:value-of select="$pathFromMaplist"/>
  75. </xsl:if>
  76. <xsl:value-of select="@href"/>
  77. </xsl:otherwise>
  78. </xsl:choose>
  79. </xsl:attribute>
  80. <xsl:if test="@scope = 'external' or not(not(@format) or @format = 'dita' or @format = 'ditamap')">
  81. <xsl:attribute name="target">_blank</xsl:attribute>
  82. </xsl:if>
  83. <xsl:value-of select="$title"/>
  84. </a>
  85. </xsl:when>
  86. <xsl:otherwise>
  87. <xsl:value-of select="$title"/>
  88. </xsl:otherwise>
  89. </xsl:choose>
  90. <!-- If there are any children that should be in the TOC, process them -->
  91. <xsl:if test="descendant::*[contains(@class, ' map/topicref ')]
  92. [not(@toc = 'no')]
  93. [not(@processing-role = 'resource-only')]">
  94. <ul>
  95. <xsl:apply-templates select="*[contains(@class, ' map/topicref ')]" mode="toc">
  96. <xsl:with-param name="pathFromMaplist" select="$pathFromMaplist"/>
  97. </xsl:apply-templates>
  98. </ul>
  99. </xsl:if>
  100. </li>
  101. </xsl:when>
  102. <xsl:otherwise><!-- if it is an empty topicref -->
  103. <xsl:apply-templates select="*[contains(@class, ' map/topicref ')]" mode="toc">
  104. <xsl:with-param name="pathFromMaplist" select="$pathFromMaplist"/>
  105. </xsl:apply-templates>
  106. </xsl:otherwise>
  107. </xsl:choose>
  108. </xsl:template>
  109. <!-- If toc=no, but a child has toc=yes, that child should bubble up to the top -->
  110. <xsl:template match="*[contains(@class, ' map/topicref ')]
  111. [@toc = 'no']
  112. [not(@processing-role = 'resource-only')]"
  113. mode="toc">
  114. <xsl:param name="pathFromMaplist"/>
  115. <xsl:apply-templates select="*[contains(@class, ' map/topicref ')]" mode="toc">
  116. <xsl:with-param name="pathFromMaplist" select="$pathFromMaplist"/>
  117. </xsl:apply-templates>
  118. </xsl:template>
  119. <xsl:template match="*" mode="toc" priority="-1"/>
  120. <xsl:template match="*[contains(@class, ' map/map ')]">
  121. <xsl:apply-templates select="." mode="root_element"/>
  122. </xsl:template>
  123. <xsl:template match="*[contains(@class, ' map/map ')]" mode="chapterBody">
  124. <body>
  125. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
  126. <xsl:if test="@outputclass">
  127. <xsl:attribute name="class" select="@outputclass"/>
  128. </xsl:if>
  129. <xsl:apply-templates select="." mode="addAttributesToBody"/>
  130. <xsl:call-template name="setidaname"/>
  131. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  132. <xsl:call-template name="generateBreadcrumbs"/>
  133. <xsl:call-template name="gen-user-header"/>
  134. <xsl:call-template name="processHDR"/>
  135. <xsl:if test="$INDEXSHOW = 'yes'">
  136. <xsl:apply-templates select="/*/*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' topic/keywords ')]/*[contains(@class, ' topic/indexterm ')]"/>
  137. </xsl:if>
  138. <xsl:call-template name="gen-user-sidetoc"/>
  139. <xsl:choose>
  140. <xsl:when test="*[contains(@class, ' topic/title ')]">
  141. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
  142. </xsl:when>
  143. <xsl:otherwise>
  144. <xsl:apply-templates select="@title"/>
  145. </xsl:otherwise>
  146. </xsl:choose>
  147. <xsl:variable name="map" as="element()*">
  148. <xsl:apply-templates select="." mode="normalize-map"/>
  149. </xsl:variable>
  150. <xsl:apply-templates select="$map" mode="toc"/>
  151. <xsl:call-template name="gen-endnotes"/>
  152. <xsl:call-template name="gen-user-footer"/>
  153. <xsl:call-template name="processFTR"/>
  154. <xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  155. </body>
  156. </xsl:template>
  157. <xsl:template match="*[contains(@class, ' map/map ')]/*[contains(@class, ' topic/title ')]">
  158. <h1 class="title topictitle1">
  159. <xsl:call-template name="gen-user-panel-title-pfx"/>
  160. <xsl:apply-templates/>
  161. </h1>
  162. </xsl:template>
  163. <xsl:template match="*[contains(@class, ' map/map ')]/@title">
  164. <h1 class="title topictitle1">
  165. <xsl:call-template name="gen-user-panel-title-pfx"/>
  166. <xsl:value-of select="."/>
  167. </h1>
  168. </xsl:template>
  169. <xsl:template match="*[contains(@class,' bookmap/bookmap ')]/*[contains(@class,' bookmap/booktitle ')]" priority="10">
  170. <h1 class="title topictitle1">
  171. <xsl:call-template name="gen-user-panel-title-pfx"/>
  172. <xsl:apply-templates select="*[contains(@class, ' bookmap/mainbooktitle ')]/node()"/>
  173. </h1>
  174. </xsl:template>
  175. <xsl:template name="generateChapterTitle">
  176. <title>
  177. <xsl:choose>
  178. <xsl:when test="/*[contains(@class,' bookmap/bookmap ')]/*[contains(@class,' bookmap/booktitle ')]/*[contains(@class, ' bookmap/mainbooktitle ')]">
  179. <xsl:call-template name="gen-user-panel-title-pfx"/>
  180. <xsl:value-of select="/*[contains(@class,' bookmap/bookmap ')]/*[contains(@class,' bookmap/booktitle ')]/*[contains(@class, ' bookmap/mainbooktitle ')]"/>
  181. </xsl:when>
  182. <xsl:when test="/*[contains(@class,' map/map ')]/*[contains(@class,' topic/title ')]">
  183. <xsl:call-template name="gen-user-panel-title-pfx"/>
  184. <xsl:value-of select="/*[contains(@class,' map/map ')]/*[contains(@class,' topic/title ')]"/>
  185. </xsl:when>
  186. <xsl:when test="/*[contains(@class,' map/map ')]/@title">
  187. <xsl:call-template name="gen-user-panel-title-pfx"/>
  188. <xsl:value-of select="/*[contains(@class,' map/map ')]/@title"/>
  189. </xsl:when>
  190. </xsl:choose>
  191. </title>
  192. </xsl:template>
  193. </xsl:stylesheet>