profile-eclipse.xsl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exsl="http://exslt.org/common" xmlns:exslt="http://exslt.org/common" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" version="1.0" exclude-result-prefixes="exsl db ng exslt">
  5. <xsl:import href="../html/chunk.xsl"/>
  6. <!-- ********************************************************************
  7. $Id: eclipse.xsl 9149 2011-11-12 00:12:07Z bobstayton $
  8. ********************************************************************
  9. This file is part of the XSL DocBook Stylesheet distribution.
  10. See ../README or http://docbook.sf.net/release/xsl/current/ for
  11. copyright and other information.
  12. ******************************************************************** -->
  13. <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="/">
  14. <!-- * Get a title for current doc so that we let the user -->
  15. <!-- * know what document we are processing at this point. -->
  16. <xsl:variable name="doc.title">
  17. <xsl:call-template name="get.doc.title"/>
  18. </xsl:variable>
  19. <xsl:choose>
  20. <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
  21. toss the namespace and continue. Use the docbook5 namespaced
  22. stylesheets for DocBook5 if you don't want to use this feature.-->
  23. <!-- include extra test for Xalan quirk -->
  24. <xsl:when test="false()"/>
  25. <xsl:otherwise>
  26. <xsl:choose>
  27. <xsl:when test="$rootid != ''">
  28. <xsl:choose>
  29. <xsl:when test="count($profiled-nodes//*[@id=$rootid or @xml:id=$rootid]) = 0">
  30. <xsl:message terminate="yes">
  31. <xsl:text>ID '</xsl:text>
  32. <xsl:value-of select="$rootid"/>
  33. <xsl:text>' not found in document.</xsl:text>
  34. </xsl:message>
  35. </xsl:when>
  36. <xsl:otherwise>
  37. <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
  38. <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
  39. </xsl:if>
  40. <xsl:if test="$collect.xref.targets != 'only'">
  41. <xsl:message>Formatting from <xsl:value-of select="$rootid"/></xsl:message>
  42. <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]" mode="process.root"/>
  43. <xsl:call-template name="etoc"/>
  44. <xsl:call-template name="plugin.xml"/>
  45. <xsl:call-template name="helpidx"/>
  46. </xsl:if>
  47. </xsl:otherwise>
  48. </xsl:choose>
  49. </xsl:when>
  50. <xsl:otherwise>
  51. <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
  52. <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
  53. </xsl:if>
  54. <xsl:if test="$collect.xref.targets != 'only'">
  55. <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
  56. <xsl:call-template name="etoc"/>
  57. <xsl:call-template name="plugin.xml"/>
  58. <xsl:call-template name="helpidx"/>
  59. </xsl:if>
  60. </xsl:otherwise>
  61. </xsl:choose>
  62. </xsl:otherwise>
  63. </xsl:choose>
  64. </xsl:template>
  65. <xsl:template name="etoc">
  66. <xsl:call-template name="write.chunk">
  67. <xsl:with-param name="filename">
  68. <xsl:if test="$manifest.in.base.dir != 0">
  69. <xsl:value-of select="$chunk.base.dir"/>
  70. </xsl:if>
  71. <xsl:value-of select="'toc.xml'"/>
  72. </xsl:with-param>
  73. <xsl:with-param name="method" select="'xml'"/>
  74. <xsl:with-param name="encoding" select="'utf-8'"/>
  75. <xsl:with-param name="indent" select="'yes'"/>
  76. <xsl:with-param name="quiet" select="$chunk.quietly"/>
  77. <xsl:with-param name="content">
  78. <xsl:choose>
  79. <xsl:when test="$rootid != ''">
  80. <xsl:variable name="title">
  81. <xsl:if test="$eclipse.autolabel=1">
  82. <xsl:variable name="label.markup">
  83. <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]" mode="label.markup"/>
  84. </xsl:variable>
  85. <xsl:if test="normalize-space($label.markup)">
  86. <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
  87. </xsl:if>
  88. </xsl:if>
  89. <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]" mode="title.markup"/>
  90. </xsl:variable>
  91. <xsl:variable name="href">
  92. <xsl:call-template name="href.target.with.base.dir">
  93. <xsl:with-param name="object" select="key('id',$rootid)"/>
  94. </xsl:call-template>
  95. </xsl:variable>
  96. <toc label="{normalize-space($title)}" topic="{$href}">
  97. <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]/*" mode="etoc"/>
  98. </toc>
  99. </xsl:when>
  100. <xsl:otherwise>
  101. <xsl:variable name="title">
  102. <xsl:if test="$eclipse.autolabel=1">
  103. <xsl:variable name="label.markup">
  104. <xsl:apply-templates select="$profiled-nodes/*" mode="label.markup"/>
  105. </xsl:variable>
  106. <xsl:if test="normalize-space($label.markup)">
  107. <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
  108. </xsl:if>
  109. </xsl:if>
  110. <xsl:apply-templates select="$profiled-nodes/*" mode="title.markup"/>
  111. </xsl:variable>
  112. <xsl:variable name="href">
  113. <xsl:call-template name="href.target.with.base.dir">
  114. <xsl:with-param name="object" select="$profiled-nodes"/>
  115. </xsl:call-template>
  116. </xsl:variable>
  117. <toc label="{normalize-space($title)}" topic="{$href}">
  118. <xsl:apply-templates select="$profiled-nodes/*/*" mode="etoc"/>
  119. </toc>
  120. </xsl:otherwise>
  121. </xsl:choose>
  122. </xsl:with-param>
  123. </xsl:call-template>
  124. </xsl:template>
  125. <xsl:template match="book|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc">
  126. <xsl:variable name="title">
  127. <xsl:if test="$eclipse.autolabel=1">
  128. <xsl:variable name="label.markup">
  129. <xsl:apply-templates select="." mode="label.markup"/>
  130. </xsl:variable>
  131. <xsl:if test="normalize-space($label.markup)">
  132. <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
  133. </xsl:if>
  134. </xsl:if>
  135. <xsl:apply-templates select="." mode="title.markup"/>
  136. </xsl:variable>
  137. <xsl:variable name="href">
  138. <xsl:call-template name="href.target.with.base.dir">
  139. <xsl:with-param name="context" select="/"/> <!-- Generate links relative to the location of root file/toc.xml file -->
  140. </xsl:call-template>
  141. </xsl:variable>
  142. <topic label="{normalize-space($title)}" href="{$href}">
  143. <xsl:apply-templates select="part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc"/>
  144. </topic>
  145. </xsl:template>
  146. <xsl:template match="text()" mode="etoc"/>
  147. <xsl:template name="plugin.xml">
  148. <xsl:call-template name="write.chunk">
  149. <xsl:with-param name="filename">
  150. <xsl:if test="$manifest.in.base.dir != 0">
  151. <xsl:value-of select="$chunk.base.dir"/>
  152. </xsl:if>
  153. <xsl:value-of select="'plugin.xml'"/>
  154. </xsl:with-param>
  155. <xsl:with-param name="method" select="'xml'"/>
  156. <xsl:with-param name="encoding" select="'utf-8'"/>
  157. <xsl:with-param name="indent" select="'yes'"/>
  158. <xsl:with-param name="quiet" select="$chunk.quietly"/>
  159. <xsl:with-param name="content">
  160. <plugin name="{$eclipse.plugin.name}" id="{$eclipse.plugin.id}" version="1.0" provider-name="{$eclipse.plugin.provider}">
  161. <extension point="org.eclipse.help.toc">
  162. <toc file="toc.xml" primary="true"/>
  163. </extension>
  164. <extension point="org.eclipse.help.index">
  165. <index file="index.xml"/>
  166. </extension>
  167. </plugin>
  168. </xsl:with-param>
  169. </xsl:call-template>
  170. </xsl:template>
  171. <!-- ==================================================================== -->
  172. <!-- The following templates come from the javahelp xsls with modifications needed to make them generate and ecilpse index.xml file -->
  173. <xsl:template name="helpidx">
  174. <xsl:call-template name="write.chunk.with.doctype">
  175. <xsl:with-param name="filename" select="concat($chunk.base.dir, 'index.xml')"/>
  176. <xsl:with-param name="method" select="'xml'"/>
  177. <xsl:with-param name="indent" select="'yes'"/>
  178. <xsl:with-param name="doctype-public" select="''"/>
  179. <xsl:with-param name="doctype-system" select="''"/>
  180. <xsl:with-param name="encoding" select="'utf-8'"/>
  181. <xsl:with-param name="quiet" select="$chunk.quietly"/>
  182. <xsl:with-param name="content">
  183. <xsl:call-template name="helpidx.content"/>
  184. </xsl:with-param>
  185. </xsl:call-template>
  186. </xsl:template>
  187. <xsl:template name="helpidx.content">
  188. <index>
  189. <xsl:choose>
  190. <xsl:when test="$rootid != ''">
  191. <xsl:apply-templates select="key('id',$rootid)//indexterm" mode="idx">
  192. <xsl:sort select="normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = '']))"/>
  193. <xsl:sort select="normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = '']))"/>
  194. <xsl:sort select="normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = '']))"/>
  195. </xsl:apply-templates>
  196. </xsl:when>
  197. <xsl:otherwise>
  198. <xsl:apply-templates select="//indexterm" mode="idx">
  199. <xsl:sort select="normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = '']))"/>
  200. <xsl:sort select="normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = '']))"/>
  201. <xsl:sort select="normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = '']))"/>
  202. </xsl:apply-templates>
  203. </xsl:otherwise>
  204. </xsl:choose>
  205. </index>
  206. </xsl:template>
  207. <xsl:template match="indexterm[@class='endofrange']" mode="idx"/>
  208. <xsl:template match="indexterm|primary|secondary|tertiary" mode="idx">
  209. <xsl:variable name="href">
  210. <xsl:call-template name="href.target.with.base.dir">
  211. <xsl:with-param name="context" select="/"/> <!-- Generate links relative to the location of root file/toc.xml file -->
  212. </xsl:call-template>
  213. </xsl:variable>
  214. <xsl:variable name="text">
  215. <xsl:value-of select="normalize-space(.)"/>
  216. <xsl:if test="following-sibling::*[1][self::see]">
  217. <xsl:text> (</xsl:text><xsl:call-template name="gentext">
  218. <xsl:with-param name="key" select="'see'"/>
  219. </xsl:call-template><xsl:text> </xsl:text>
  220. <xsl:value-of select="following-sibling::*[1][self::see]"/>)</xsl:if>
  221. </xsl:variable>
  222. <xsl:choose>
  223. <xsl:when test="self::indexterm">
  224. <xsl:apply-templates select="primary" mode="idx"/>
  225. </xsl:when>
  226. <xsl:when test="self::primary">
  227. <entry keyword="{$text}">
  228. <topic href="{$href}"/>
  229. <xsl:apply-templates select="following-sibling::secondary" mode="idx"/>
  230. </entry>
  231. </xsl:when>
  232. <xsl:otherwise>
  233. <entry keyword="{$text}">
  234. <topic href="{$href}"/>
  235. <xsl:apply-templates select="following-sibling::tertiary" mode="idx"/>
  236. </entry>
  237. </xsl:otherwise>
  238. </xsl:choose>
  239. </xsl:template>
  240. <!-- ==================================================================== -->
  241. </xsl:stylesheet>