map2html5-coverImpl.xsl 9.0 KB

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