1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
<?xml version="1.0"?>
<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"
version="1.0"
exclude-result-prefixes="exsl db ng">
<xsl:import href="../html/chunk.xsl"/>
<!-- ********************************************************************
This file is part of the XSL DocBook Stylesheet distribution.
See ../README or http://cdn.docbook.org/release/xsl/current/ for
copyright and other information.
******************************************************************** -->
<xsl:variable name="no.namespace">
<xsl:if test="$exsl.node.set.available != 0 and
namespace-uri(/*) = 'http://docbook.org/ns/docbook'">
<xsl:apply-templates select="/*" mode="stripNS"/>
</xsl:if>
</xsl:variable>
<xsl:template match="/">
<!-- * Get a title for current doc so that we let the user -->
<!-- * know what document we are processing at this point. -->
<xsl:variable name="doc.title">
<xsl:call-template name="get.doc.title"/>
</xsl:variable>
<xsl:choose>
<!-- fix namespace if necessary -->
<xsl:when test="$exsl.node.set.available != 0 and
namespace-uri(/*) = 'http://docbook.org/ns/docbook'">
<xsl:call-template name="log.message">
<xsl:with-param name="level">Note</xsl:with-param>
<xsl:with-param name="source" select="$doc.title"/>
<xsl:with-param name="context-desc">
<xsl:text>namesp. cut</xsl:text>
</xsl:with-param>
<xsl:with-param name="message">
<xsl:text>stripped namespace before processing</xsl:text>
</xsl:with-param>
</xsl:call-template>
<!-- DEBUG: uncomment to save namespace-fixed document.
<xsl:message>Saving namespace-fixed document.</xsl:message>
<xsl:call-template name="write.chunk">
<xsl:with-param name="filename" select="'namespace-fixed.debug.xml'"/>
<xsl:with-param name="method" select="'xml'"/>
<xsl:with-param name="content">
<xsl:copy-of select="exsl:node-set($no.namespace)"/>
</xsl:with-param>
</xsl:call-template>
-->
<xsl:apply-templates select="exsl:node-set($no.namespace)"/>
</xsl:when>
<!-- Can't process unless namespace fixed with exsl node-set()-->
<xsl:when test="namespace-uri(/*) = 'http://docbook.org/ns/docbook'">
<xsl:message terminate="yes">
<xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
<xsl:text> cannot proceed.</xsl:text>
</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$rootid != ''">
<xsl:choose>
<xsl:when test="count(key('id',$rootid)) = 0">
<xsl:message terminate="yes">
<xsl:text>ID '</xsl:text>
<xsl:value-of select="$rootid"/>
<xsl:text>' not found in document.</xsl:text>
</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$collect.xref.targets = 'yes' or
$collect.xref.targets = 'only'">
<xsl:apply-templates select="key('id', $rootid)"
mode="collect.targets"/>
</xsl:if>
<xsl:if test="$collect.xref.targets != 'only'">
<xsl:message>Formatting from <xsl:value-of
select="$rootid"/></xsl:message>
<xsl:apply-templates select="key('id',$rootid)"
mode="process.root"/>
<xsl:call-template name="etoc"/>
<xsl:call-template name="plugin.xml"/>
<xsl:call-template name="helpidx"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$collect.xref.targets = 'yes' or
$collect.xref.targets = 'only'">
<xsl:apply-templates select="/" mode="collect.targets"/>
</xsl:if>
<xsl:if test="$collect.xref.targets != 'only'">
<xsl:apply-templates select="/" mode="process.root"/>
<xsl:call-template name="etoc"/>
<xsl:call-template name="plugin.xml"/>
<xsl:call-template name="helpidx"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="etoc">
<xsl:call-template name="write.chunk">
<xsl:with-param name="filename">
<xsl:if test="$manifest.in.base.dir != 0">
<xsl:value-of select="$chunk.base.dir"/>
</xsl:if>
<xsl:value-of select="'toc.xml'"/>
</xsl:with-param>
<xsl:with-param name="method" select="'xml'"/>
<xsl:with-param name="encoding" select="'utf-8'"/>
<xsl:with-param name="indent" select="'yes'"/>
<xsl:with-param name="quiet" select="$chunk.quietly"/>
<xsl:with-param name="content">
<xsl:choose>
<xsl:when test="$rootid != ''">
<xsl:variable name="title">
<xsl:if test="$eclipse.autolabel=1">
<xsl:variable name="label.markup">
<xsl:apply-templates select="key('id',$rootid)" mode="label.markup"/>
</xsl:variable>
<xsl:if test="normalize-space($label.markup)">
<xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
</xsl:if>
</xsl:if>
<xsl:apply-templates select="key('id',$rootid)" mode="title.markup"/>
</xsl:variable>
<xsl:variable name="href">
<xsl:call-template name="href.target.with.base.dir">
<xsl:with-param name="object" select="key('id',$rootid)"/>
</xsl:call-template>
</xsl:variable>
<toc label="{normalize-space($title)}" topic="{$href}">
<xsl:apply-templates select="key('id',$rootid)/*" mode="etoc"/>
</toc>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="title">
<xsl:if test="$eclipse.autolabel=1">
<xsl:variable name="label.markup">
<xsl:apply-templates select="/*" mode="label.markup"/>
</xsl:variable>
<xsl:if test="normalize-space($label.markup)">
<xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
</xsl:if>
</xsl:if>
<xsl:apply-templates select="/*" mode="title.markup"/>
</xsl:variable>
<xsl:variable name="href">
<xsl:call-template name="href.target.with.base.dir">
<xsl:with-param name="object" select="/"/>
</xsl:call-template>
</xsl:variable>
<toc label="{normalize-space($title)}" topic="{$href}">
<xsl:apply-templates select="/*/*" mode="etoc"/>
</toc>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="book|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc">
<xsl:variable name="title">
<xsl:if test="$eclipse.autolabel=1">
<xsl:variable name="label.markup">
<xsl:apply-templates select="." mode="label.markup"/>
</xsl:variable>
<xsl:if test="normalize-space($label.markup)">
<xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
</xsl:if>
</xsl:if>
<xsl:apply-templates select="." mode="title.markup"/>
</xsl:variable>
<xsl:variable name="href">
<xsl:call-template name="href.target.with.base.dir">
<xsl:with-param name="context" select="/"/> <!-- Generate links relative to the location of root file/toc.xml file -->
</xsl:call-template>
</xsl:variable>
<topic label="{normalize-space($title)}" href="{$href}">
<xsl:apply-templates select="part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv|index" mode="etoc"/>
</topic>
</xsl:template>
<xsl:template match="text()" mode="etoc"/>
<xsl:template name="plugin.xml">
<xsl:call-template name="write.chunk">
<xsl:with-param name="filename">
<xsl:if test="$manifest.in.base.dir != 0">
<xsl:value-of select="$chunk.base.dir"/>
</xsl:if>
<xsl:value-of select="'plugin.xml'"/>
</xsl:with-param>
<xsl:with-param name="method" select="'xml'"/>
<xsl:with-param name="encoding" select="'utf-8'"/>
<xsl:with-param name="indent" select="'yes'"/>
<xsl:with-param name="quiet" select="$chunk.quietly"/>
<xsl:with-param name="content">
<plugin name="{$eclipse.plugin.name}"
id="{$eclipse.plugin.id}"
version="1.0"
provider-name="{$eclipse.plugin.provider}">
<extension point="org.eclipse.help.toc">
<toc file="toc.xml" primary="true"/>
</extension>
<extension point="org.eclipse.help.index">
<index file="index.xml"/>
</extension>
</plugin>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- ==================================================================== -->
<!-- The following templates come from the javahelp xsls with modifications needed to make them generate and ecilpse index.xml file -->
<xsl:template name="helpidx">
<xsl:call-template name="write.chunk.with.doctype">
<xsl:with-param name="filename" select="concat($chunk.base.dir, 'index.xml')"/>
<xsl:with-param name="method" select="'xml'"/>
<xsl:with-param name="indent" select="'yes'"/>
<xsl:with-param name="doctype-public" select="''"/>
<xsl:with-param name="doctype-system" select="''"/>
<xsl:with-param name="encoding" select="'utf-8'"/>
<xsl:with-param name="quiet" select="$chunk.quietly"/>
<xsl:with-param name="content">
<xsl:call-template name="helpidx.content"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="helpidx.content">
<index>
<xsl:choose>
<xsl:when test="$rootid != ''">
<xsl:apply-templates select="key('id',$rootid)//indexterm" mode="idx">
<xsl:sort select="normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = '']))"/>
<xsl:sort select="normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = '']))"/>
<xsl:sort select="normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = '']))"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="//indexterm" mode="idx">
<xsl:sort select="normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = '']))"/>
<xsl:sort select="normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = '']))"/>
<xsl:sort select="normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = '']))"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</index>
</xsl:template>
<xsl:template match="indexterm[@class='endofrange']" mode="idx"/>
<xsl:template match="indexterm|primary|secondary|tertiary" mode="idx">
<xsl:variable name="href">
<xsl:call-template name="href.target.with.base.dir">
<xsl:with-param name="context" select="/"/> <!-- Generate links relative to the location of root file/toc.xml file -->
</xsl:call-template>
</xsl:variable>
<xsl:variable name="text">
<xsl:value-of select="normalize-space(.)"/>
<xsl:if test="following-sibling::*[1][self::see]">
<xsl:text> (</xsl:text><xsl:call-template name="gentext">
<xsl:with-param name="key" select="'see'"/>
</xsl:call-template><xsl:text> </xsl:text>
<xsl:value-of select="following-sibling::*[1][self::see]"/>)</xsl:if>
</xsl:variable>
<xsl:choose>
<xsl:when test="self::indexterm">
<xsl:apply-templates select="primary" mode="idx"/>
</xsl:when>
<xsl:when test="self::primary">
<entry keyword="{$text}">
<topic href="{$href}"/>
<xsl:apply-templates select="following-sibling::secondary" mode="idx"/>
</entry>
</xsl:when>
<xsl:otherwise>
<entry keyword="{$text}">
<topic href="{$href}"/>
<xsl:apply-templates select="following-sibling::tertiary" mode="idx"/>
</entry>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ==================================================================== -->
</xsl:stylesheet>
|