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:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns:exsl="http://exslt.org/common" xmlns:set="http://exslt.org/sets" xmlns:h="urn:x-hex" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" 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="doc exsl set h db ng exslt">
 
   6 <!-- ********************************************************************
 
   7      $Id: htmlhelp-common.xsl 8400 2009-04-08 07:44:54Z bobstayton $
 
   8      ******************************************************************** -->
 
  10 <!-- ==================================================================== -->
 
  11 <!-- Customizations of standard HTML stylesheet parameters -->
 
  13 <!-- no navigation on pages by default, HTML Help provides its own navigation controls -->
 
  14 <xsl:param name="suppress.navigation" select="1"/>
 
  16 <!-- no separate HTML page with index, index is built inside CHM index pane -->
 
  17 <xsl:param name="generate.index" select="0"/>
 
  19 <!-- ==================================================================== -->
 
  21 <xsl:param name="htmlhelp.generate.index" select="//indexterm[1]|//db:indexterm[1]|//ng:indexterm[1]"/>
 
  23 <!-- Set up HTML Help flag -->
 
  24 <xsl:variable name="htmlhelp.output" select="1"/>
 
  26 <!-- ==================================================================== -->
 
  28 <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="/">
 
  30   <!-- * Get a title for current doc so that we let the user -->
 
  31   <!-- * know what document we are processing at this point. -->
 
  32   <xsl:variable name="doc.title">
 
  33     <xsl:call-template name="get.doc.title"/>
 
  36     <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
 
  37          toss the namespace and continue.  Use the docbook5 namespaced
 
  38          stylesheets for DocBook5 if you don't want to use this feature.-->
 
  39     <xsl:when test="false()"/>
 
  41   <xsl:if test="$htmlhelp.only != 1">
 
  43       <xsl:when test="$rootid != ''">
 
  45           <xsl:when test="count($profiled-nodes//*[@id=$rootid]) = 0">
 
  46             <xsl:message terminate="yes">
 
  47               <xsl:text>ID '</xsl:text>
 
  48               <xsl:value-of select="$rootid"/>
 
  49               <xsl:text>' not found in document.</xsl:text>
 
  53             <xsl:message>Formatting from <xsl:value-of select="$rootid"/></xsl:message>
 
  54             <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="process.root"/>
 
  59         <xsl:if test="$collect.xref.targets = 'yes' or                       $collect.xref.targets = 'only'">
 
  60           <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
 
  62         <xsl:if test="$collect.xref.targets != 'only'">
 
  63           <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
 
  70   <xsl:if test="$collect.xref.targets != 'only'">
 
  71     <xsl:call-template name="hhp"/>
 
  72     <xsl:call-template name="hhc"/>
 
  73     <xsl:if test="($rootid = '' and //processing-instruction('dbhh')) or                   ($rootid != '' and $profiled-nodes//*[@id=$rootid]//processing-instruction('dbhh'))">
 
  74       <xsl:call-template name="hh-map"/>
 
  75       <xsl:call-template name="hh-alias"/>
 
  77     <xsl:if test="$htmlhelp.generate.index">
 
  78       <xsl:call-template name="hhk"/>
 
  85 <!-- ==================================================================== -->
 
  87 <xsl:template name="hhp">
 
  88   <xsl:call-template name="write.text.chunk">
 
  89     <xsl:with-param name="filename">
 
  90       <xsl:if test="$manifest.in.base.dir != 0">
 
  91         <xsl:value-of select="$base.dir"/>
 
  93       <xsl:value-of select="$htmlhelp.hhp"/>
 
  95     <xsl:with-param name="method" select="'text'"/>
 
  96     <xsl:with-param name="content">
 
  97       <xsl:call-template name="hhp-main"/>
 
  99     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
 
 100     <xsl:with-param name="quiet" select="$chunk.quietly"/>
 
 104 <!-- ==================================================================== -->
 
 105 <xsl:template name="hhp-main">
 
 107   <xsl:variable name="raw.help.title">
 
 109       <xsl:when test="$htmlhelp.title = ''">
 
 111           <xsl:when test="$rootid != ''">
 
 112             <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="title.markup"/>
 
 115             <xsl:apply-templates select="$profiled-nodes/*" mode="title.markup"/>
 
 120         <xsl:value-of select="$htmlhelp.title"/>
 
 125   <xsl:variable name="help.title" select="normalize-space($raw.help.title)"/>
 
 127 <xsl:variable name="default.topic">
 
 129     <xsl:when test="$htmlhelp.default.topic != ''">
 
 130       <xsl:value-of select="$htmlhelp.default.topic"/>
 
 133       <xsl:call-template name="make-relative-filename">
 
 134         <xsl:with-param name="base.dir">
 
 135           <xsl:if test="$manifest.in.base.dir = 0">
 
 136             <xsl:value-of select="$base.dir"/>
 
 139         <xsl:with-param name="base.name">
 
 141             <xsl:when test="$rootid != ''">
 
 142               <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="chunk-filename"/>
 
 145               <xsl:apply-templates select="$profiled-nodes" mode="chunk-filename"/>
 
 153 <xsl:variable name="xnavigation">
 
 154   <xsl:text>0x</xsl:text>
 
 155   <xsl:call-template name="toHex">
 
 156     <xsl:with-param name="n" select="9504 + $htmlhelp.show.menu * 65536                                           + $htmlhelp.show.advanced.search * 131072                                           + $htmlhelp.show.favorities * 4096                                           + (1 - $htmlhelp.show.toolbar.text) * 64                                           + $htmlhelp.remember.window.position * 262144"/>
 
 159 <xsl:variable name="xbuttons">
 
 160   <xsl:text>0x</xsl:text>
 
 161   <xsl:call-template name="toHex">
 
 162     <xsl:with-param name="n" select="0 + $htmlhelp.button.hideshow * 2                                        + $htmlhelp.button.back * 4                                        + $htmlhelp.button.forward * 8                                        + $htmlhelp.button.stop * 16                                        + $htmlhelp.button.refresh * 32                                        + $htmlhelp.button.home * 64                                        + $htmlhelp.button.options * 4096                                        + $htmlhelp.button.print * 8192                                        + $htmlhelp.button.locate * 2048                                        + $htmlhelp.button.jump1 * 262144                                        + $htmlhelp.button.jump2 * 524288                                        + $htmlhelp.button.next * 2097152                                        + $htmlhelp.button.prev * 4194304                                        + $htmlhelp.button.zoom * 1048576"/>
 
 167 <xsl:if test="$htmlhelp.generate.index">
 
 168 <xsl:text>Auto Index=Yes
 
 170 <xsl:if test="$htmlhelp.hhc.binary != 0">
 
 171 <xsl:text>Binary TOC=Yes
 
 173 <xsl:text>Compatibility=1.1 or later
 
 174 Compiled file=</xsl:text><xsl:value-of select="$htmlhelp.chm"/><xsl:text>
 
 175 Contents file=</xsl:text><xsl:value-of select="$htmlhelp.hhc"/><xsl:text>
 
 177 <xsl:if test="$htmlhelp.hhp.window != ''">
 
 178 <xsl:text>Default Window=</xsl:text><xsl:value-of select="$htmlhelp.hhp.window"/><xsl:text>
 
 180 <xsl:text>Default topic=</xsl:text><xsl:value-of select="$default.topic"/>
 
 182 Display compile progress=</xsl:text>
 
 184     <xsl:when test="$htmlhelp.display.progress != 1">
 
 185       <xsl:text>No</xsl:text>
 
 188       <xsl:text>Yes</xsl:text>
 
 194 <xsl:if test="$htmlhelp.generate.index">
 
 195 <xsl:text>Index file=</xsl:text><xsl:value-of select="$htmlhelp.hhk"/><xsl:text>
 
 197 <xsl:text>Language=</xsl:text>
 
 198 <xsl:for-each select="*">   <!-- Change context from / to root element -->
 
 199   <xsl:call-template name="gentext.template">
 
 200     <xsl:with-param name="context" select="'htmlhelp'"/>
 
 201     <xsl:with-param name="name" select="'langcode'"/>
 
 206   <xsl:value-of select="$help.title"/>
 
 208 Enhanced decompilation=</xsl:text>
 
 210     <xsl:when test="$htmlhelp.enhanced.decompilation != 0">
 
 211       <xsl:text>Yes</xsl:text>
 
 214       <xsl:text>No</xsl:text>
 
 218 <xsl:if test="$htmlhelp.hhp.window != ''">
 
 223 <xsl:value-of select="$htmlhelp.hhp.window"/>
 
 224 <xsl:text>="</xsl:text>
 
 225 <xsl:value-of select="$help.title"/>
 
 226 <xsl:text>","</xsl:text><xsl:value-of select="$htmlhelp.hhc"/>
 
 227 <xsl:text>",</xsl:text>
 
 228 <xsl:if test="$htmlhelp.generate.index">
 
 229   <xsl:text>"</xsl:text>
 
 230   <xsl:value-of select="$htmlhelp.hhk"/>
 
 231   <xsl:text>"</xsl:text>
 
 233 <xsl:text>,"</xsl:text>
 
 234 <xsl:value-of select="$default.topic"/>
 
 235 <xsl:text>",</xsl:text>
 
 236 <xsl:text>"</xsl:text>
 
 238   <xsl:when test="$htmlhelp.button.home != 0">
 
 239     <xsl:value-of select="$htmlhelp.button.home.url"/>
 
 242     <xsl:value-of select="$default.topic"/>
 
 245 <xsl:text>"</xsl:text>
 
 246 <xsl:text>,</xsl:text>
 
 247 <xsl:if test="$htmlhelp.button.jump1 != 0">
 
 248   <xsl:text>"</xsl:text>
 
 249   <xsl:value-of select="$htmlhelp.button.jump1.url"/>
 
 250   <xsl:text>"</xsl:text>
 
 252 <xsl:text>,</xsl:text>
 
 253 <xsl:if test="$htmlhelp.button.jump1 != 0">
 
 254   <xsl:text>"</xsl:text>
 
 255   <xsl:value-of select="$htmlhelp.button.jump1.title"/>
 
 256   <xsl:text>"</xsl:text>
 
 258 <xsl:text>,</xsl:text>
 
 259 <xsl:if test="$htmlhelp.button.jump2 != 0">
 
 260   <xsl:text>"</xsl:text>
 
 261   <xsl:value-of select="$htmlhelp.button.jump2.url"/>
 
 262   <xsl:text>"</xsl:text>
 
 264 <xsl:text>,</xsl:text>
 
 265 <xsl:if test="$htmlhelp.button.jump2 != 0">
 
 266   <xsl:text>"</xsl:text>
 
 267   <xsl:value-of select="$htmlhelp.button.jump2.title"/>
 
 268   <xsl:text>"</xsl:text>
 
 270 <xsl:text>,</xsl:text>
 
 271 <xsl:value-of select="$xnavigation"/>
 
 272 <xsl:text>,</xsl:text><xsl:value-of select="$htmlhelp.hhc.width"/><xsl:text>,</xsl:text>
 
 273 <xsl:value-of select="$xbuttons"/>
 
 274 <xsl:text>,</xsl:text><xsl:value-of select="$htmlhelp.window.geometry"/><xsl:text>,,,,,,,0
 
 279   Needs more investigation to generate propetly all fields 
 
 280 <xsl:text>search="</xsl:text>
 
 281 <xsl:value-of select="normalize-space(//title[1])"/>
 
 282 <xsl:text>","toc.hhc","index.hhk","</xsl:text>
 
 283 <xsl:value-of select="$root.filename"/>
 
 284 <xsl:text>.html","</xsl:text>
 
 285 <xsl:value-of select="$root.filename"/>
 
 286 <xsl:text>.html",,,,,</xsl:text>
 
 287 <xsl:value-of select="$xnavigation"/>
 
 288 <xsl:text>,</xsl:text>
 
 289 <xsl:value-of select="$htmlhelp.hhc.width"/>
 
 290 <xsl:text>,</xsl:text>
 
 291 <xsl:value-of select="$xbuttons"/>
 
 292 <xsl:text>,</xsl:text>
 
 293 <xsl:value-of select="$htmlhelp.window.geometry"/>
 
 298 <xsl:if test="$htmlhelp.hhp.windows">
 
 299   <xsl:value-of select="$htmlhelp.hhp.windows"/>
 
 307   <xsl:when test="$rootid != ''">
 
 308     <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="enumerate-files"/>
 
 311     <xsl:apply-templates select="$profiled-nodes" mode="enumerate-files"/>
 
 315 <xsl:if test="$htmlhelp.enumerate.images">
 
 316   <xsl:variable name="imagelist">
 
 318       <xsl:when test="$rootid != ''">
 
 319         <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="enumerate-images"/>
 
 322         <xsl:apply-templates select="$profiled-nodes" mode="enumerate-images"/>
 
 327     <xsl:when test="$exsl.node.set.available != 0                     and function-available('set:distinct')">
 
 328       <xsl:for-each select="set:distinct(exsl:node-set($imagelist)/filename)">
 
 329         <xsl:value-of select="."/>
 
 335       <xsl:value-of select="$imagelist"/>
 
 340 <xsl:if test="($htmlhelp.force.map.and.alias != 0) or                ($rootid = '' and //processing-instruction('dbhh')) or               ($rootid != '' and $profiled-nodes//*[@id=$rootid]//processing-instruction('dbhh'))">
 
 343 #include </xsl:text><xsl:value-of select="$htmlhelp.alias.file"/><xsl:text>
 
 346 #include </xsl:text><xsl:value-of select="$htmlhelp.map.file"/><xsl:text>
 
 350 <xsl:value-of select="$htmlhelp.hhp.tail"/>
 
 353 <!-- ==================================================================== -->
 
 355 <xsl:template match="graphic|inlinegraphic[@format!='linespecific']" mode="enumerate-images">
 
 356   <xsl:call-template name="write.filename.enumerate-images">
 
 357     <xsl:with-param name="filename">
 
 358       <xsl:call-template name="mediaobject.filename.enumerate-images">
 
 359         <xsl:with-param name="object" select="."/>
 
 365 <xsl:template match="mediaobject|inlinemediaobject" mode="enumerate-images">
 
 366   <xsl:call-template name="select.mediaobject.enumerate-images"/>
 
 369 <xsl:template name="select.mediaobject.enumerate-images">
 
 370   <xsl:param name="olist" select="imageobject|imageobjectco                      |videoobject|audioobject|textobject"/>
 
 371   <xsl:param name="count">1</xsl:param>
 
 373   <xsl:if test="$count <= count($olist)">
 
 374     <xsl:variable name="object" select="$olist[position()=$count]"/>
 
 376     <xsl:variable name="useobject">
 
 378         <!-- The phrase is never used -->
 
 379         <xsl:when test="name($object)='textobject' and $object/phrase">
 
 380           <xsl:text>0</xsl:text>
 
 382         <!-- The first textobject is a reasonable fallback (but not for image in HH) -->
 
 383         <xsl:when test="name($object)='textobject'">
 
 384           <xsl:text>0</xsl:text>
 
 386         <!-- If there's only one object, use it -->
 
 387         <xsl:when test="$count = 1 and count($olist) = 1">
 
 388           <xsl:text>1</xsl:text>
 
 390         <!-- Otherwise, see if this one is a useable graphic -->
 
 393             <!-- peek inside imageobjectco to simplify the test -->
 
 394             <xsl:when test="local-name($object) = 'imageobjectco'">
 
 395               <xsl:call-template name="is.acceptable.mediaobject">
 
 396                 <xsl:with-param name="object" select="$object/imageobject"/>
 
 400               <xsl:call-template name="is.acceptable.mediaobject">
 
 401                 <xsl:with-param name="object" select="$object"/>
 
 410       <xsl:when test="$useobject='1' and $object[not(*/@format='linespecific')]">
 
 411         <xsl:call-template name="write.filename.enumerate-images">
 
 412           <xsl:with-param name="filename">
 
 413             <xsl:call-template name="mediaobject.filename.enumerate-images">
 
 414               <xsl:with-param name="object" select="$object"/>
 
 420         <xsl:call-template name="select.mediaobject.enumerate-images">
 
 421           <xsl:with-param name="olist" select="$olist"/>
 
 422           <xsl:with-param name="count" select="$count + 1"/>
 
 429 <xsl:template name="mediaobject.filename.enumerate-images">
 
 430   <xsl:param name="object"/>
 
 432   <xsl:variable name="urifilename">
 
 433     <xsl:call-template name="mediaobject.filename">
 
 434       <xsl:with-param name="object" select="$object"/>
 
 438   <xsl:variable name="filename">
 
 440       <xsl:when test="starts-with($urifilename, 'file:/')">
 
 441         <xsl:value-of select="substring-after($urifilename, 'file:/')"/>
 
 444         <xsl:value-of select="$urifilename"/>
 
 449   <xsl:value-of select="translate($filename, '/', '\')"/>
 
 453 <xsl:template match="text()" mode="enumerate-images">
 
 456 <xsl:template name="write.filename.enumerate-images">
 
 457   <xsl:param name="filename"/>
 
 459     <xsl:when test="function-available('exsl:node-set') and function-available('set:distinct')">
 
 460       <filename><xsl:value-of select="$filename"/></filename>
 
 463       <xsl:value-of select="$filename"/>
 
 470 <!-- ==================================================================== -->
 
 472 <!-- HHC and HHK files are processed by compiler line by line
 
 473      and therefore are very sensitive to whitespaces (linefeeds for sure).  -->
 
 475 <xsl:template name="hhc">
 
 476   <xsl:call-template name="write.chunk">
 
 477     <xsl:with-param name="filename">
 
 478       <xsl:if test="$manifest.in.base.dir != 0">
 
 479         <xsl:value-of select="$base.dir"/>
 
 481       <xsl:value-of select="$htmlhelp.hhc"/>
 
 483     <xsl:with-param name="indent" select="'no'"/>
 
 484     <xsl:with-param name="content">
 
 485       <xsl:call-template name="hhc-main"/>
 
 487     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
 
 488     <xsl:with-param name="quiet" select="$chunk.quietly"/>
 
 492 <xsl:template name="hhc-main">
 
 499   <xsl:if test="$htmlhelp.hhc.folders.instead.books != 0">
 
 500    <OBJECT type="text/site properties"><xsl:text>
 
 502      <param name="ImageType" value="Folder"/><xsl:text>
 
 507   <xsl:variable name="content">
 
 509       <xsl:when test="$rootid != ''">
 
 510         <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hhc"/>
 
 513         <xsl:apply-templates select="$profiled-nodes" mode="hhc"/>
 
 519     <xsl:when test="$htmlhelp.hhc.show.root != 0">
 
 522         <xsl:copy-of select="$content"/>
 
 527     <xsl:copy-of select="$content"/>
 
 535 <xsl:template name="hhc.entry">
 
 536   <xsl:param name="title">
 
 537     <xsl:if test="$htmlhelp.autolabel=1">
 
 538       <xsl:variable name="label.markup">
 
 539         <xsl:apply-templates select="." mode="label.markup"/>
 
 541       <xsl:if test="normalize-space($label.markup)">
 
 542         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
 
 545     <xsl:apply-templates select="." mode="title.markup"/>
 
 548   <LI><OBJECT type="text/sitemap"><xsl:text>
 
 551       <xsl:attribute name="value">
 
 552           <xsl:value-of select="normalize-space($title)"/>
 
 557       <xsl:attribute name="value">
 
 558           <xsl:call-template name="href.target.with.base.dir"/>
 
 561   </OBJECT></LI><xsl:text>
 
 565 <xsl:template match="set" mode="hhc">
 
 566   <xsl:if test="$htmlhelp.hhc.show.root != 0">
 
 567     <xsl:call-template name="hhc.entry"/>
 
 570     <xsl:variable name="toc.params">
 
 571       <xsl:call-template name="find.path.params">
 
 572         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
 
 576       <xsl:if test="contains($toc.params, 'toc') and $htmlhelp.hhc.show.root = 0">
 
 577       <LI><OBJECT type="text/sitemap"><xsl:text>
 
 580             <xsl:attribute name="value">
 
 581             <xsl:call-template name="gentext">
 
 582               <xsl:with-param name="key" select="'TableofContents'"/>
 
 588             <xsl:attribute name="value">
 
 590                 <xsl:when test="$chunk.tocs.and.lots != 0">
 
 591                   <xsl:apply-templates select="." mode="recursive-chunk-filename">
 
 592                     <xsl:with-param name="recursive" select="true()"/>
 
 593                   </xsl:apply-templates>
 
 594                   <xsl:text>-toc</xsl:text>
 
 595                   <xsl:value-of select="$html.ext"/>
 
 598                   <xsl:call-template name="href.target.with.base.dir"/>
 
 603       </OBJECT></LI><xsl:text>
 
 606       <xsl:apply-templates select="book" mode="hhc"/>
 
 612 <xsl:template match="book" mode="hhc">
 
 613   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 614     <xsl:call-template name="hhc.entry"/>
 
 616   <xsl:if test="part|reference|preface|chapter|appendix|bibliography|article|colophon|glossary">
 
 617     <xsl:variable name="toc.params">
 
 618       <xsl:call-template name="find.path.params">
 
 619         <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
 
 623       <xsl:if test="contains($toc.params, 'toc') and $htmlhelp.hhc.show.root = 0 and not(parent::*)">
 
 624         <LI><OBJECT type="text/sitemap"><xsl:text>
 
 627               <xsl:attribute name="value">
 
 628                 <xsl:call-template name="gentext">
 
 629                   <xsl:with-param name="key" select="'TableofContents'"/>
 
 635               <xsl:attribute name="value">
 
 637                   <xsl:when test="$chunk.tocs.and.lots != 0">
 
 638                     <xsl:apply-templates select="." mode="recursive-chunk-filename">
 
 639                       <xsl:with-param name="recursive" select="true()"/>
 
 640                     </xsl:apply-templates>
 
 641                     <xsl:text>-toc</xsl:text>
 
 642                     <xsl:value-of select="$html.ext"/>
 
 645                     <xsl:call-template name="href.target.with.base.dir"/>
 
 650         </OBJECT></LI><xsl:text>
 
 653       <xsl:apply-templates select="part|reference|preface|chapter|bibliography|appendix|article|colophon|glossary" mode="hhc"/>
 
 659 <xsl:template match="part|reference|preface|chapter|bibliography|appendix|article|glossary" mode="hhc">
 
 660   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 661     <xsl:call-template name="hhc.entry"/>
 
 663   <xsl:if test="article|reference|preface|chapter|appendix|refentry|section|sect1|bibliodiv">
 
 666       <xsl:apply-templates select="article|reference|preface|chapter|appendix|refentry|section|sect1|bibliodiv" mode="hhc"/>
 
 671 <xsl:template match="section" mode="hhc">
 
 672   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 673     <xsl:call-template name="hhc.entry"/>
 
 675   <xsl:if test="section[count(ancestor::section) < $htmlhelp.hhc.section.depth]|refentry">
 
 678       <xsl:apply-templates select="section|refentry" mode="hhc"/>
 
 683 <xsl:template match="sect1" mode="hhc">
 
 684   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 685     <xsl:call-template name="hhc.entry"/>
 
 687   <xsl:if test="sect2[$htmlhelp.hhc.section.depth > 1]|refentry">
 
 690       <xsl:apply-templates select="sect2|refentry" mode="hhc"/>
 
 695 <xsl:template match="sect2" mode="hhc">
 
 696   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 697     <xsl:call-template name="hhc.entry"/>
 
 699   <xsl:if test="sect3[$htmlhelp.hhc.section.depth > 2]|refentry">
 
 702       <xsl:apply-templates select="sect3|refentry" mode="hhc"/>
 
 707 <xsl:template match="sect3" mode="hhc">
 
 708   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 709     <xsl:call-template name="hhc.entry"/>
 
 711   <xsl:if test="sect4[$htmlhelp.hhc.section.depth > 3]|refentry">
 
 714       <xsl:apply-templates select="sect4|refentry" mode="hhc"/>
 
 719 <xsl:template match="sect4" mode="hhc">
 
 720   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 721     <xsl:call-template name="hhc.entry"/>
 
 723   <xsl:if test="sect5[$htmlhelp.hhc.section.depth > 4]|refentry">
 
 726       <xsl:apply-templates select="sect5|refentry" mode="hhc"/>
 
 731 <xsl:template match="sect5|refentry|colophon|bibliodiv" mode="hhc">
 
 732   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
 
 733     <xsl:call-template name="hhc.entry"/>
 
 735   <xsl:if test="refentry">
 
 738       <xsl:apply-templates select="refentry" mode="hhc"/>
 
 743 <!-- ==================================================================== -->
 
 745 <xsl:template match="indexterm">
 
 747     <xsl:when test="$htmlhelp.use.hhk = 0">
 
 749       <xsl:variable name="primary" select="normalize-space(primary)"/>
 
 750       <xsl:variable name="secondary" select="normalize-space(secondary)"/>
 
 751       <xsl:variable name="tertiary" select="normalize-space(tertiary)"/>
 
 753       <xsl:variable name="text">
 
 754         <xsl:value-of select="$primary"/>
 
 755         <xsl:if test="secondary">
 
 756           <xsl:text>, </xsl:text>
 
 757           <xsl:value-of select="$secondary"/>
 
 759         <xsl:if test="tertiary">
 
 760           <xsl:text>, </xsl:text>
 
 761           <xsl:value-of select="$tertiary"/>
 
 765       <xsl:if test="secondary">
 
 766         <xsl:if test="not(//indexterm[normalize-space(primary)=$primary and not(secondary)])">
 
 767           <xsl:call-template name="write.indexterm">
 
 768             <xsl:with-param name="text" select="$primary"/>
 
 773       <xsl:if test="tertiary">
 
 774         <xsl:if test="not(//indexterm[normalize-space(primary)=$primary and                                        normalize-space(secondary)=$secondary and not(tertiary)])">
 
 775           <xsl:call-template name="write.indexterm">
 
 776             <xsl:with-param name="text" select="concat($primary, ', ', $secondary)"/>
 
 781       <xsl:call-template name="write.indexterm">
 
 782         <xsl:with-param name="text" select="$text"/>
 
 788         <xsl:attribute name="name">
 
 789           <xsl:call-template name="object.id"/>
 
 797 <xsl:template name="write.indexterm">
 
 798   <xsl:param name="text"/>
 
 799   <OBJECT type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
 
 800     <param name="Keyword" value="{$text}"/>
 
 804 <!-- ==================================================================== -->
 
 806 <xsl:template name="hhk">
 
 807   <xsl:call-template name="write.chunk">
 
 808     <xsl:with-param name="filename">
 
 809       <xsl:if test="$manifest.in.base.dir != 0">
 
 810         <xsl:value-of select="$base.dir"/>
 
 812       <xsl:value-of select="$htmlhelp.hhk"/>
 
 814     <xsl:with-param name="indent" select="'no'"/>
 
 815     <xsl:with-param name="content"><xsl:text disable-output-escaping="yes"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
 818 <meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
 
 819 <!-- Sitemap 1.0 -->
 
 820 </HEAD><BODY>
 
 821 <OBJECT type="text/site properties">
 
 825 <xsl:if test="($htmlhelp.use.hhk != 0) and $htmlhelp.generate.index">
 
 827     <xsl:when test="$rootid != ''">
 
 828       <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hhk"/>
 
 831       <xsl:apply-templates select="$profiled-nodes" mode="hhk"/>
 
 835 <xsl:text disable-output-escaping="yes"></UL>
 
 836 </BODY></HTML>
 
 837 </xsl:text></xsl:with-param>
 
 838     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
 
 839     <xsl:with-param name="quiet" select="$chunk.quietly"/>
 
 843 <xsl:template match="indexterm[@class='endofrange']" mode="hhk"/>
 
 845 <xsl:template match="indexterm" mode="hhk">
 
 846   <xsl:variable name="primary" select="normalize-space(primary)"/>
 
 847   <xsl:variable name="secondary" select="normalize-space(secondary)"/>
 
 848   <xsl:variable name="tertiary" select="normalize-space(tertiary)"/>
 
 850   <xsl:call-template name="write.indexterm.hhk">
 
 851     <xsl:with-param name="text" select="$primary"/>
 
 852     <xsl:with-param name="seealso" select="seealso"/>
 
 855   <xsl:if test="secondary">
 
 856     <xsl:if test="not(//indexterm[normalize-space(primary)=$primary and not(secondary)])">
 
 857       <xsl:call-template name="write.indexterm.hhk">
 
 858         <!-- We must create fake entry when there is secondary without primary --> 
 
 859         <xsl:with-param name="text" select="$primary"/>
 
 860         <xsl:with-param name="seealso" select="$primary"/>
 
 864     <xsl:call-template name="write.indexterm.hhk">
 
 865       <xsl:with-param name="text" select="$secondary"/>
 
 866       <xsl:with-param name="seealso" select="secondary/seealso"/>
 
 868     <xsl:if test="tertiary">
 
 871       <xsl:call-template name="write.indexterm.hhk">
 
 872         <xsl:with-param name="text" select="$tertiary"/>
 
 873         <xsl:with-param name="seealso" select="tertiary/seealso"/>
 
 882 <xsl:template name="write.indexterm.hhk">
 
 883   <xsl:param name="text"/>
 
 884   <xsl:param name="seealso"/>
 
 886   <LI> <OBJECT type="text/sitemap"><xsl:text>
 
 889       <xsl:attribute name="value">
 
 890         <xsl:value-of select="$text"/>
 
 895       <xsl:if test="not(seealso)">
 
 896         <xsl:variable name="href">
 
 897           <xsl:call-template name="href.target.with.base.dir"/>
 
 899         <xsl:variable name="title">
 
 900           <xsl:call-template name="nearest.title">
 
 901             <xsl:with-param name="object" select=".."/>
 
 906           <xsl:attribute name="value">
 
 907           <xsl:value-of select="$title"/>
 
 912           <xsl:attribute name="value">
 
 913           <xsl:value-of select="$href"/>
 
 919       <xsl:if test="seealso">
 
 920         <param name="See Also">
 
 921           <xsl:attribute name="value">
 
 922           <xsl:value-of select="$seealso"/>
 
 930 <xsl:template match="text()" mode="hhk"/>
 
 932 <xsl:template name="nearest.title">
 
 933   <xsl:param name="object"/>
 
 934   <xsl:apply-templates select="$object/ancestor-or-self::*[title][1]" mode="title.markup"/>
 
 937 <!-- ==================================================================== -->
 
 939 <xsl:template name="hh-map">
 
 940   <xsl:call-template name="write.text.chunk">
 
 941     <xsl:with-param name="filename">
 
 942       <xsl:if test="$manifest.in.base.dir != 0">
 
 943         <xsl:value-of select="$base.dir"/>
 
 945       <xsl:value-of select="$htmlhelp.map.file"/>
 
 947     <xsl:with-param name="method" select="'text'"/>
 
 948     <xsl:with-param name="content">
 
 950        <xsl:when test="$rootid != ''">
 
 951          <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hh-map"/>
 
 954          <xsl:apply-templates select="$profiled-nodes" mode="hh-map"/>
 
 958     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
 
 959     <xsl:with-param name="quiet" select="$chunk.quietly"/>
 
 963 <xsl:template match="processing-instruction('dbhh')" mode="hh-map">
 
 964   <xsl:variable name="topicname">
 
 965     <xsl:call-template name="pi-attribute">
 
 966       <xsl:with-param name="pis" select="."/>
 
 967       <xsl:with-param name="attribute" select="'topicname'"/>
 
 970   <xsl:variable name="topicid">
 
 971     <xsl:call-template name="pi-attribute">
 
 972       <xsl:with-param name="pis" select="."/>
 
 973       <xsl:with-param name="attribute" select="'topicid'"/>
 
 976   <xsl:text>#define </xsl:text>
 
 977   <xsl:value-of select="$topicname"/>
 
 978   <xsl:text>    </xsl:text>
 
 979   <xsl:value-of select="$topicid"/>
 
 984 <xsl:template match="text()" mode="hh-map"/>
 
 986 <!-- ==================================================================== -->
 
 988 <xsl:template name="hh-alias">
 
 989   <xsl:call-template name="write.text.chunk">
 
 990     <xsl:with-param name="filename">
 
 991       <xsl:if test="$manifest.in.base.dir != 0">
 
 992         <xsl:value-of select="$base.dir"/>
 
 994       <xsl:value-of select="$htmlhelp.alias.file"/>
 
 996     <xsl:with-param name="method" select="'text'"/>
 
 997     <xsl:with-param name="content">
 
 999        <xsl:when test="$rootid != ''">
 
1000          <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hh-alias"/>
 
1003          <xsl:apply-templates select="$profiled-nodes" mode="hh-alias"/>
 
1007     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
 
1008     <xsl:with-param name="quiet" select="$chunk.quietly"/>
 
1009   </xsl:call-template>
 
1012 <xsl:template match="processing-instruction('dbhh')" mode="hh-alias">
 
1013   <xsl:variable name="topicname">
 
1014     <xsl:call-template name="pi-attribute">
 
1015       <xsl:with-param name="pis" select="."/>
 
1016       <xsl:with-param name="attribute" select="'topicname'"/>
 
1017     </xsl:call-template>
 
1019   <xsl:variable name="href">
 
1020     <xsl:call-template name="href.target.with.base.dir">
 
1021       <xsl:with-param name="object" select=".."/>
 
1022     </xsl:call-template>
 
1024   <xsl:value-of select="$topicname"/>
 
1025   <xsl:text>=</xsl:text>
 
1026   <!-- Some versions of HH doesn't like fragment identifires, but some does. -->
 
1027   <!-- <xsl:value-of select="substring-before(concat($href, '#'), '#')"/> -->
 
1028   <xsl:value-of select="$href"/>
 
1033 <xsl:template match="text()" mode="hh-alias"/>
 
1035 <!-- ==================================================================== -->
 
1036 <!-- This code can be used to convert any number to hexadecimal format -->
 
1057   <xsl:template name="toHex">
 
1058     <xsl:param name="n" select="0"/>
 
1059     <xsl:param name="digit" select="$n mod 16"/>
 
1060     <xsl:param name="rest" select="floor($n div 16)"/>
 
1061     <xsl:if test="$rest > 0">
 
1062       <xsl:call-template name="toHex">
 
1063         <xsl:with-param name="n" select="$rest"/>
 
1064       </xsl:call-template>
 
1066     <xsl:value-of select="document('')//h:hex/d[$digit+1]"/>
 
1069 <!-- ==================================================================== -->
 
1070 <!-- Modification to standard HTML stylesheets -->
 
1072 <!-- There are links from ToC pane to bibliodivs, so there must be anchor -->
 
1073 <xsl:template match="bibliodiv/title">
 
1074   <h3 class="{name(.)}">
 
1075     <xsl:call-template name="anchor">
 
1076       <xsl:with-param name="node" select=".."/>
 
1077       <xsl:with-param name="conditional" select="0"/>
 
1078     </xsl:call-template>
 
1079     <xsl:apply-templates/>