2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:ng="http://docbook.org/docbook-ng"
4 xmlns:db="http://docbook.org/ns/docbook"
5 xmlns:exsl="http://exslt.org/common"
7 exclude-result-prefixes="exsl db ng">
9 <xsl:import href="../html/chunk.xsl"/>
11 <!-- ********************************************************************
12 $Id: eclipse.xsl 8400 2009-04-08 07:44:54Z bobstayton $
13 ********************************************************************
15 This file is part of the XSL DocBook Stylesheet distribution.
16 See ../README or http://docbook.sf.net/release/xsl/current/ for
17 copyright and other information.
19 ******************************************************************** -->
21 <xsl:template match="/">
22 <!-- * Get a title for current doc so that we let the user -->
23 <!-- * know what document we are processing at this point. -->
24 <xsl:variable name="doc.title">
25 <xsl:call-template name="get.doc.title"/>
28 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
29 toss the namespace and continue. Use the docbook5 namespaced
30 stylesheets for DocBook5 if you don't want to use this feature.-->
31 <!-- include extra test for Xalan quirk -->
32 <xsl:when test="$exsl.node.set.available != 0
33 and (*/self::ng:* or */self::db:*)">
34 <xsl:call-template name="log.message">
35 <xsl:with-param name="level">Note</xsl:with-param>
36 <xsl:with-param name="source" select="$doc.title"/>
37 <xsl:with-param name="context-desc">
38 <xsl:text>namesp. cut</xsl:text>
40 <xsl:with-param name="message">
41 <xsl:text>stripped namespace before processing</xsl:text>
44 <xsl:variable name="nons">
45 <xsl:apply-templates mode="stripNS"/>
47 <xsl:call-template name="log.message">
48 <xsl:with-param name="level">Note</xsl:with-param>
49 <xsl:with-param name="source" select="$doc.title"/>
50 <xsl:with-param name="context-desc">
51 <xsl:text>namesp. cut</xsl:text>
53 <xsl:with-param name="message">
54 <xsl:text>processing stripped document</xsl:text>
57 <xsl:apply-templates select="exsl:node-set($nons)"/>
61 <xsl:when test="$rootid != ''">
63 <xsl:when test="count(key('id',$rootid)) = 0">
64 <xsl:message terminate="yes">
65 <xsl:text>ID '</xsl:text>
66 <xsl:value-of select="$rootid"/>
67 <xsl:text>' not found in document.</xsl:text>
71 <xsl:if test="$collect.xref.targets = 'yes' or
72 $collect.xref.targets = 'only'">
73 <xsl:apply-templates select="key('id', $rootid)"
74 mode="collect.targets"/>
76 <xsl:if test="$collect.xref.targets != 'only'">
77 <xsl:message>Formatting from <xsl:value-of
78 select="$rootid"/></xsl:message>
79 <xsl:apply-templates select="key('id',$rootid)"
81 <xsl:call-template name="etoc"/>
82 <xsl:call-template name="plugin.xml"/>
83 <xsl:call-template name="helpidx"/>
89 <xsl:if test="$collect.xref.targets = 'yes' or
90 $collect.xref.targets = 'only'">
91 <xsl:apply-templates select="/" mode="collect.targets"/>
93 <xsl:if test="$collect.xref.targets != 'only'">
94 <xsl:apply-templates select="/" mode="process.root"/>
95 <xsl:call-template name="etoc"/>
96 <xsl:call-template name="plugin.xml"/>
97 <xsl:call-template name="helpidx"/>
105 <xsl:template name="etoc">
106 <xsl:call-template name="write.chunk">
107 <xsl:with-param name="filename">
108 <xsl:if test="$manifest.in.base.dir != 0">
109 <xsl:value-of select="$base.dir"/>
111 <xsl:value-of select="'toc.xml'"/>
113 <xsl:with-param name="method" select="'xml'"/>
114 <xsl:with-param name="encoding" select="'utf-8'"/>
115 <xsl:with-param name="indent" select="'yes'"/>
116 <xsl:with-param name="quiet" select="$chunk.quietly"/>
117 <xsl:with-param name="content">
120 <xsl:when test="$rootid != ''">
121 <xsl:variable name="title">
122 <xsl:if test="$eclipse.autolabel=1">
123 <xsl:variable name="label.markup">
124 <xsl:apply-templates select="key('id',$rootid)" mode="label.markup"/>
126 <xsl:if test="normalize-space($label.markup)">
127 <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
130 <xsl:apply-templates select="key('id',$rootid)" mode="title.markup"/>
132 <xsl:variable name="href">
133 <xsl:call-template name="href.target.with.base.dir">
134 <xsl:with-param name="object" select="key('id',$rootid)"/>
138 <toc label="{normalize-space($title)}" topic="{$href}">
139 <xsl:apply-templates select="key('id',$rootid)/*" mode="etoc"/>
144 <xsl:variable name="title">
145 <xsl:if test="$eclipse.autolabel=1">
146 <xsl:variable name="label.markup">
147 <xsl:apply-templates select="/*" mode="label.markup"/>
149 <xsl:if test="normalize-space($label.markup)">
150 <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
153 <xsl:apply-templates select="/*" mode="title.markup"/>
155 <xsl:variable name="href">
156 <xsl:call-template name="href.target.with.base.dir">
157 <xsl:with-param name="object" select="/"/>
161 <toc label="{normalize-space($title)}" topic="{$href}">
162 <xsl:apply-templates select="/*/*" mode="etoc"/>
171 <xsl:template match="book|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc">
172 <xsl:variable name="title">
173 <xsl:if test="$eclipse.autolabel=1">
174 <xsl:variable name="label.markup">
175 <xsl:apply-templates select="." mode="label.markup"/>
177 <xsl:if test="normalize-space($label.markup)">
178 <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
181 <xsl:apply-templates select="." mode="title.markup"/>
184 <xsl:variable name="href">
185 <xsl:call-template name="href.target.with.base.dir">
186 <xsl:with-param name="context" select="/"/> <!-- Generate links relative to the location of root file/toc.xml file -->
190 <topic label="{normalize-space($title)}" href="{$href}">
191 <xsl:apply-templates select="part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc"/>
196 <xsl:template match="text()" mode="etoc"/>
198 <xsl:template name="plugin.xml">
199 <xsl:call-template name="write.chunk">
200 <xsl:with-param name="filename">
201 <xsl:if test="$manifest.in.base.dir != 0">
202 <xsl:value-of select="$base.dir"/>
204 <xsl:value-of select="'plugin.xml'"/>
206 <xsl:with-param name="method" select="'xml'"/>
207 <xsl:with-param name="encoding" select="'utf-8'"/>
208 <xsl:with-param name="indent" select="'yes'"/>
209 <xsl:with-param name="quiet" select="$chunk.quietly"/>
210 <xsl:with-param name="content">
211 <plugin name="{$eclipse.plugin.name}"
212 id="{$eclipse.plugin.id}"
214 provider-name="{$eclipse.plugin.provider}">
216 <extension point="org.eclipse.help.toc">
217 <toc file="toc.xml" primary="true"/>
219 <extension point="org.eclipse.help.index">
220 <index file="index.xml"/>
227 <!-- ==================================================================== -->
228 <!-- The following templates come from the javahelp xsls with modifications needed to make them generate and ecilpse index.xml file -->
230 <xsl:template name="helpidx">
231 <xsl:call-template name="write.chunk.with.doctype">
232 <xsl:with-param name="filename" select="concat($base.dir, 'index.xml')"/>
233 <xsl:with-param name="method" select="'xml'"/>
234 <xsl:with-param name="indent" select="'yes'"/>
235 <xsl:with-param name="doctype-public" select="''"/>
236 <xsl:with-param name="doctype-system" select="''"/>
237 <xsl:with-param name="encoding" select="'utf-8'"/>
238 <xsl:with-param name="quiet" select="$chunk.quietly"/>
239 <xsl:with-param name="content">
240 <xsl:call-template name="helpidx.content"/>
245 <xsl:template name="helpidx.content">
248 <xsl:when test="$rootid != ''">
249 <xsl:apply-templates select="key('id',$rootid)//indexterm" mode="idx">
250 <xsl:sort select="normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = '']))"/>
251 <xsl:sort select="normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = '']))"/>
252 <xsl:sort select="normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = '']))"/>
253 </xsl:apply-templates>
256 <xsl:apply-templates select="//indexterm" mode="idx">
257 <xsl:sort select="normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = '']))"/>
258 <xsl:sort select="normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = '']))"/>
259 <xsl:sort select="normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = '']))"/>
260 </xsl:apply-templates>
266 <xsl:template match="indexterm[@class='endofrange']" mode="idx"/>
268 <xsl:template match="indexterm|primary|secondary|tertiary" mode="idx">
270 <xsl:variable name="href">
271 <xsl:call-template name="href.target.with.base.dir">
272 <xsl:with-param name="context" select="/"/> <!-- Generate links relative to the location of root file/toc.xml file -->
276 <xsl:variable name="text">
277 <xsl:value-of select="normalize-space(.)"/>
278 <xsl:if test="following-sibling::*[1][self::see]">
279 <xsl:text> (</xsl:text><xsl:call-template name="gentext">
280 <xsl:with-param name="key" select="'see'"/>
281 </xsl:call-template><xsl:text> </xsl:text>
282 <xsl:value-of select="following-sibling::*[1][self::see]"/>)</xsl:if>
286 <xsl:when test="self::indexterm">
287 <xsl:apply-templates select="primary" mode="idx"/>
289 <xsl:when test="self::primary">
290 <entry keyword="{$text}">
291 <topic href="{$href}"/>
292 <xsl:apply-templates select="following-sibling::secondary" mode="idx"/>
296 <entry keyword="{$text}">
297 <topic href="{$href}"/>
298 <xsl:apply-templates select="following-sibling::tertiary" mode="idx"/>
304 <!-- ==================================================================== -->