]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/styleguide/docbook-xsl-1.75.2/htmlhelp/profile-htmlhelp-common.xsl
stylesheet changes.
[working/Evergreen.git] / stylesheets / styleguide / docbook-xsl-1.75.2 / htmlhelp / profile-htmlhelp-common.xsl
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">
5
6 <!-- ********************************************************************
7      $Id: htmlhelp-common.xsl 8400 2009-04-08 07:44:54Z bobstayton $
8      ******************************************************************** -->
9
10 <!-- ==================================================================== -->
11 <!-- Customizations of standard HTML stylesheet parameters -->
12
13 <!-- no navigation on pages by default, HTML Help provides its own navigation controls -->
14 <xsl:param name="suppress.navigation" select="1"/>
15
16 <!-- no separate HTML page with index, index is built inside CHM index pane -->
17 <xsl:param name="generate.index" select="0"/>
18
19 <!-- ==================================================================== -->
20
21 <xsl:param name="htmlhelp.generate.index" select="//indexterm[1]|//db:indexterm[1]|//ng:indexterm[1]"/>
22   
23 <!-- Set up HTML Help flag -->
24 <xsl:variable name="htmlhelp.output" select="1"/>
25
26 <!-- ==================================================================== -->
27
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="/">
29
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"/>
34   </xsl:variable>
35   <xsl:choose>
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()"/>
40     <xsl:otherwise>
41   <xsl:if test="$htmlhelp.only != 1">
42     <xsl:choose>
43       <xsl:when test="$rootid != ''">
44         <xsl:choose>
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>
50             </xsl:message>
51           </xsl:when>
52           <xsl:otherwise>
53             <xsl:message>Formatting from <xsl:value-of select="$rootid"/></xsl:message>
54             <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="process.root"/>
55           </xsl:otherwise>
56         </xsl:choose>
57       </xsl:when>
58       <xsl:otherwise>
59         <xsl:if test="$collect.xref.targets = 'yes' or                       $collect.xref.targets = 'only'">
60           <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
61         </xsl:if>
62         <xsl:if test="$collect.xref.targets != 'only'">
63           <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
64         </xsl:if>
65       </xsl:otherwise>
66     </xsl:choose>
67   </xsl:if>
68
69
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"/>
76     </xsl:if>
77     <xsl:if test="$htmlhelp.generate.index">
78       <xsl:call-template name="hhk"/>
79     </xsl:if>
80   </xsl:if>
81 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:template>
84
85 <!-- ==================================================================== -->
86
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"/>
92       </xsl:if>
93       <xsl:value-of select="$htmlhelp.hhp"/>
94     </xsl:with-param>
95     <xsl:with-param name="method" select="'text'"/>
96     <xsl:with-param name="content">
97       <xsl:call-template name="hhp-main"/>
98     </xsl:with-param>
99     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
100     <xsl:with-param name="quiet" select="$chunk.quietly"/>
101   </xsl:call-template>
102 </xsl:template>
103
104 <!-- ==================================================================== -->
105 <xsl:template name="hhp-main">
106
107   <xsl:variable name="raw.help.title">
108     <xsl:choose>
109       <xsl:when test="$htmlhelp.title = ''">
110         <xsl:choose>
111           <xsl:when test="$rootid != ''">
112             <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="title.markup"/>
113           </xsl:when>
114           <xsl:otherwise>
115             <xsl:apply-templates select="$profiled-nodes/*" mode="title.markup"/>
116           </xsl:otherwise>
117         </xsl:choose>
118       </xsl:when>
119       <xsl:otherwise>
120         <xsl:value-of select="$htmlhelp.title"/>
121       </xsl:otherwise>
122     </xsl:choose>
123   </xsl:variable>
124
125   <xsl:variable name="help.title" select="normalize-space($raw.help.title)"/>
126   
127 <xsl:variable name="default.topic">
128   <xsl:choose>
129     <xsl:when test="$htmlhelp.default.topic != ''">
130       <xsl:value-of select="$htmlhelp.default.topic"/>
131     </xsl:when>
132     <xsl:otherwise>
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"/>
137           </xsl:if>
138         </xsl:with-param>
139         <xsl:with-param name="base.name">
140           <xsl:choose>
141             <xsl:when test="$rootid != ''">
142               <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="chunk-filename"/>
143             </xsl:when>
144             <xsl:otherwise>
145               <xsl:apply-templates select="$profiled-nodes" mode="chunk-filename"/>
146             </xsl:otherwise>
147           </xsl:choose>
148         </xsl:with-param>
149       </xsl:call-template>
150     </xsl:otherwise>
151   </xsl:choose>
152 </xsl:variable>
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"/>
157   </xsl:call-template>
158 </xsl:variable>
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"/>
163   </xsl:call-template>
164 </xsl:variable>
165 <xsl:text>[OPTIONS]
166 </xsl:text>
167 <xsl:if test="$htmlhelp.generate.index">
168 <xsl:text>Auto Index=Yes
169 </xsl:text></xsl:if>
170 <xsl:if test="$htmlhelp.hhc.binary != 0">
171 <xsl:text>Binary TOC=Yes
172 </xsl:text></xsl:if>
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>
176 </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>
179 </xsl:text></xsl:if>
180 <xsl:text>Default topic=</xsl:text><xsl:value-of select="$default.topic"/>
181 <xsl:text>
182 Display compile progress=</xsl:text>
183   <xsl:choose>
184     <xsl:when test="$htmlhelp.display.progress != 1">
185       <xsl:text>No</xsl:text>
186     </xsl:when>
187     <xsl:otherwise>
188       <xsl:text>Yes</xsl:text>
189     </xsl:otherwise>
190   </xsl:choose>
191 <xsl:text>
192 Full-text search=Yes
193 </xsl:text>
194 <xsl:if test="$htmlhelp.generate.index">
195 <xsl:text>Index file=</xsl:text><xsl:value-of select="$htmlhelp.hhk"/><xsl:text>
196 </xsl:text></xsl:if>
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'"/>
202   </xsl:call-template>
203 </xsl:for-each>
204 <xsl:text>
205 Title=</xsl:text>
206   <xsl:value-of select="$help.title"/>
207 <xsl:text>
208 Enhanced decompilation=</xsl:text>
209   <xsl:choose>
210     <xsl:when test="$htmlhelp.enhanced.decompilation != 0">
211       <xsl:text>Yes</xsl:text>
212     </xsl:when>
213     <xsl:otherwise>
214       <xsl:text>No</xsl:text>
215     </xsl:otherwise>
216   </xsl:choose>
217
218 <xsl:if test="$htmlhelp.hhp.window != ''">
219   <xsl:text>
220
221 [WINDOWS]
222 </xsl:text>
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>
232 </xsl:if>
233 <xsl:text>,"</xsl:text>
234 <xsl:value-of select="$default.topic"/>
235 <xsl:text>",</xsl:text>
236 <xsl:text>"</xsl:text>
237 <xsl:choose>
238   <xsl:when test="$htmlhelp.button.home != 0">
239     <xsl:value-of select="$htmlhelp.button.home.url"/>
240   </xsl:when>
241   <xsl:otherwise>
242     <xsl:value-of select="$default.topic"/>
243   </xsl:otherwise>
244 </xsl:choose>
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>
251 </xsl:if>
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>
257 </xsl:if>
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>
263 </xsl:if>
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>
269 </xsl:if>
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
275 </xsl:text>
276 </xsl:if>
277
278 <!-- 
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"/>
294 <xsl:text>,,,,,2,,0
295 </xsl:text>
296 -->
297
298 <xsl:if test="$htmlhelp.hhp.windows">
299   <xsl:value-of select="$htmlhelp.hhp.windows"/>
300 </xsl:if>
301 <xsl:text>
302
303 [FILES]
304 </xsl:text>
305
306 <xsl:choose>
307   <xsl:when test="$rootid != ''">
308     <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="enumerate-files"/>
309   </xsl:when>
310   <xsl:otherwise>
311     <xsl:apply-templates select="$profiled-nodes" mode="enumerate-files"/>
312   </xsl:otherwise>
313 </xsl:choose>
314
315 <xsl:if test="$htmlhelp.enumerate.images">
316   <xsl:variable name="imagelist">
317     <xsl:choose>
318       <xsl:when test="$rootid != ''">
319         <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="enumerate-images"/>
320       </xsl:when>
321       <xsl:otherwise>
322         <xsl:apply-templates select="$profiled-nodes" mode="enumerate-images"/>
323       </xsl:otherwise>
324     </xsl:choose>
325   </xsl:variable>
326   <xsl:choose>
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="."/>
330         <xsl:text>
331 </xsl:text>
332       </xsl:for-each>
333     </xsl:when>
334     <xsl:otherwise>
335       <xsl:value-of select="$imagelist"/>
336     </xsl:otherwise>
337   </xsl:choose>
338 </xsl:if>
339
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'))">
341   <xsl:text>
342 [ALIAS]
343 #include </xsl:text><xsl:value-of select="$htmlhelp.alias.file"/><xsl:text>
344
345 [MAP]
346 #include </xsl:text><xsl:value-of select="$htmlhelp.map.file"/><xsl:text>
347 </xsl:text>
348 </xsl:if>
349
350 <xsl:value-of select="$htmlhelp.hhp.tail"/>
351 </xsl:template>
352
353 <!-- ==================================================================== -->
354
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="."/>
360       </xsl:call-template>  
361     </xsl:with-param>
362   </xsl:call-template>
363 </xsl:template>
364
365 <xsl:template match="mediaobject|inlinemediaobject" mode="enumerate-images">
366   <xsl:call-template name="select.mediaobject.enumerate-images"/>
367 </xsl:template>
368
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>
372
373   <xsl:if test="$count &lt;= count($olist)">
374     <xsl:variable name="object" select="$olist[position()=$count]"/>
375
376     <xsl:variable name="useobject">
377       <xsl:choose>
378         <!-- The phrase is never used -->
379         <xsl:when test="name($object)='textobject' and $object/phrase">
380           <xsl:text>0</xsl:text>
381         </xsl:when>
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>
385         </xsl:when>
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>
389         </xsl:when>
390         <!-- Otherwise, see if this one is a useable graphic -->
391         <xsl:otherwise>
392           <xsl:choose>
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"/>
397               </xsl:call-template>
398             </xsl:when>
399             <xsl:otherwise>
400               <xsl:call-template name="is.acceptable.mediaobject">
401                 <xsl:with-param name="object" select="$object"/>
402               </xsl:call-template>
403             </xsl:otherwise>
404           </xsl:choose>
405         </xsl:otherwise>
406       </xsl:choose>
407     </xsl:variable>
408
409     <xsl:choose>
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"/>
415             </xsl:call-template>
416           </xsl:with-param>
417         </xsl:call-template>
418       </xsl:when>
419       <xsl:otherwise>
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"/>
423         </xsl:call-template>
424       </xsl:otherwise>
425     </xsl:choose>
426   </xsl:if>
427 </xsl:template>
428
429 <xsl:template name="mediaobject.filename.enumerate-images">
430   <xsl:param name="object"/>
431
432   <xsl:variable name="urifilename">
433     <xsl:call-template name="mediaobject.filename">
434       <xsl:with-param name="object" select="$object"/>
435     </xsl:call-template>
436   </xsl:variable>
437
438   <xsl:variable name="filename">
439     <xsl:choose>
440       <xsl:when test="starts-with($urifilename, 'file:/')">
441         <xsl:value-of select="substring-after($urifilename, 'file:/')"/>
442       </xsl:when>
443       <xsl:otherwise>
444         <xsl:value-of select="$urifilename"/>
445       </xsl:otherwise>
446     </xsl:choose>
447   </xsl:variable>
448
449   <xsl:value-of select="translate($filename, '/', '\')"/>
450
451 </xsl:template>
452
453 <xsl:template match="text()" mode="enumerate-images">
454 </xsl:template>
455
456 <xsl:template name="write.filename.enumerate-images">
457   <xsl:param name="filename"/>
458   <xsl:choose>
459     <xsl:when test="function-available('exsl:node-set') and function-available('set:distinct')">
460       <filename><xsl:value-of select="$filename"/></filename>
461     </xsl:when>
462     <xsl:otherwise>
463       <xsl:value-of select="$filename"/>
464       <xsl:text>
465 </xsl:text>
466     </xsl:otherwise>
467   </xsl:choose>
468 </xsl:template>
469
470 <!-- ==================================================================== -->
471
472 <!-- HHC and HHK files are processed by compiler line by line
473      and therefore are very sensitive to whitespaces (linefeeds for sure).  -->
474
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"/>
480       </xsl:if>
481       <xsl:value-of select="$htmlhelp.hhc"/>
482     </xsl:with-param>
483     <xsl:with-param name="indent" select="'no'"/>
484     <xsl:with-param name="content">
485       <xsl:call-template name="hhc-main"/>
486     </xsl:with-param>
487     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
488     <xsl:with-param name="quiet" select="$chunk.quietly"/>
489   </xsl:call-template>
490 </xsl:template>
491
492 <xsl:template name="hhc-main">
493 <HTML><xsl:text>
494 </xsl:text>
495  <HEAD/><xsl:text>
496 </xsl:text>
497  <BODY><xsl:text>
498 </xsl:text>
499   <xsl:if test="$htmlhelp.hhc.folders.instead.books != 0">
500    <OBJECT type="text/site properties"><xsl:text>
501 </xsl:text>
502      <param name="ImageType" value="Folder"/><xsl:text>
503 </xsl:text>
504    </OBJECT><xsl:text>
505 </xsl:text>
506   </xsl:if>
507   <xsl:variable name="content">
508     <xsl:choose>
509       <xsl:when test="$rootid != ''">
510         <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hhc"/>
511       </xsl:when>
512       <xsl:otherwise>
513         <xsl:apply-templates select="$profiled-nodes" mode="hhc"/>
514       </xsl:otherwise>
515     </xsl:choose>
516   </xsl:variable>
517
518   <xsl:choose>
519     <xsl:when test="$htmlhelp.hhc.show.root != 0">
520       <UL><xsl:text>
521 </xsl:text>
522         <xsl:copy-of select="$content"/>
523       </UL><xsl:text>
524 </xsl:text>
525     </xsl:when>
526     <xsl:otherwise>
527     <xsl:copy-of select="$content"/>
528     </xsl:otherwise>
529   </xsl:choose>
530
531  </BODY>
532 </HTML>
533 </xsl:template>
534
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"/>
540       </xsl:variable>
541       <xsl:if test="normalize-space($label.markup)">
542         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
543       </xsl:if>
544     </xsl:if>
545     <xsl:apply-templates select="." mode="title.markup"/>
546   </xsl:param>
547
548   <LI><OBJECT type="text/sitemap"><xsl:text>
549 </xsl:text>
550     <param name="Name">
551       <xsl:attribute name="value">
552           <xsl:value-of select="normalize-space($title)"/>
553       </xsl:attribute>
554     </param><xsl:text>
555 </xsl:text>
556     <param name="Local">
557       <xsl:attribute name="value">
558           <xsl:call-template name="href.target.with.base.dir"/>
559       </xsl:attribute>
560     </param>
561   </OBJECT></LI><xsl:text>
562 </xsl:text>
563 </xsl:template>
564
565 <xsl:template match="set" mode="hhc">
566   <xsl:if test="$htmlhelp.hhc.show.root != 0">
567     <xsl:call-template name="hhc.entry"/>
568   </xsl:if>
569   <xsl:if test="book">
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)"/>
573       </xsl:call-template>
574     </xsl:variable>
575     <UL>
576       <xsl:if test="contains($toc.params, 'toc') and $htmlhelp.hhc.show.root = 0">
577       <LI><OBJECT type="text/sitemap"><xsl:text>
578 </xsl:text>
579           <param name="Name">
580             <xsl:attribute name="value">
581             <xsl:call-template name="gentext">
582               <xsl:with-param name="key" select="'TableofContents'"/>
583             </xsl:call-template>
584             </xsl:attribute>
585           </param><xsl:text>
586 </xsl:text>
587           <param name="Local">
588             <xsl:attribute name="value">
589               <xsl:choose>
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"/>
596                 </xsl:when>
597                 <xsl:otherwise>
598                   <xsl:call-template name="href.target.with.base.dir"/>
599                 </xsl:otherwise>
600               </xsl:choose>
601             </xsl:attribute>
602           </param>
603       </OBJECT></LI><xsl:text>
604 </xsl:text>
605       </xsl:if>
606       <xsl:apply-templates select="book" mode="hhc"/>
607     </UL><xsl:text>
608 </xsl:text>
609   </xsl:if>
610 </xsl:template>
611
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"/>
615   </xsl:if>
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)"/>
620       </xsl:call-template>
621     </xsl:variable>
622     <UL>
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>
625 </xsl:text>
626             <param name="Name">
627               <xsl:attribute name="value">
628                 <xsl:call-template name="gentext">
629                   <xsl:with-param name="key" select="'TableofContents'"/>
630                 </xsl:call-template>
631               </xsl:attribute>
632             </param><xsl:text>
633 </xsl:text>
634             <param name="Local">
635               <xsl:attribute name="value">
636                 <xsl:choose>
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"/>
643                   </xsl:when>
644                   <xsl:otherwise>
645                     <xsl:call-template name="href.target.with.base.dir"/>
646                   </xsl:otherwise>
647                 </xsl:choose>
648               </xsl:attribute>
649             </param>
650         </OBJECT></LI><xsl:text>
651 </xsl:text>
652       </xsl:if>
653       <xsl:apply-templates select="part|reference|preface|chapter|bibliography|appendix|article|colophon|glossary" mode="hhc"/>
654     </UL><xsl:text>
655 </xsl:text>
656   </xsl:if>
657 </xsl:template>
658
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"/>
662   </xsl:if>
663   <xsl:if test="article|reference|preface|chapter|appendix|refentry|section|sect1|bibliodiv">
664     <UL><xsl:text>
665 </xsl:text>
666       <xsl:apply-templates select="article|reference|preface|chapter|appendix|refentry|section|sect1|bibliodiv" mode="hhc"/>
667     </UL>
668   </xsl:if>
669 </xsl:template>
670
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"/>
674   </xsl:if>
675   <xsl:if test="section[count(ancestor::section) &lt; $htmlhelp.hhc.section.depth]|refentry">
676     <UL><xsl:text>
677 </xsl:text>
678       <xsl:apply-templates select="section|refentry" mode="hhc"/>
679     </UL>
680   </xsl:if>
681 </xsl:template>
682
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"/>
686   </xsl:if>
687   <xsl:if test="sect2[$htmlhelp.hhc.section.depth &gt; 1]|refentry">
688     <UL><xsl:text>
689 </xsl:text>
690       <xsl:apply-templates select="sect2|refentry" mode="hhc"/>
691     </UL>
692   </xsl:if>
693 </xsl:template>
694
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"/>
698   </xsl:if>
699   <xsl:if test="sect3[$htmlhelp.hhc.section.depth &gt; 2]|refentry">
700     <UL><xsl:text>
701 </xsl:text>
702       <xsl:apply-templates select="sect3|refentry" mode="hhc"/>
703     </UL>
704   </xsl:if>
705 </xsl:template>
706
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"/>
710   </xsl:if>
711   <xsl:if test="sect4[$htmlhelp.hhc.section.depth &gt; 3]|refentry">
712     <UL><xsl:text>
713 </xsl:text>
714       <xsl:apply-templates select="sect4|refentry" mode="hhc"/>
715     </UL>
716   </xsl:if>
717 </xsl:template>
718
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"/>
722   </xsl:if>
723   <xsl:if test="sect5[$htmlhelp.hhc.section.depth &gt; 4]|refentry">
724     <UL><xsl:text>
725 </xsl:text>
726       <xsl:apply-templates select="sect5|refentry" mode="hhc"/>
727     </UL>
728   </xsl:if>
729 </xsl:template>
730
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"/>
734   </xsl:if>
735   <xsl:if test="refentry">
736     <UL><xsl:text>
737 </xsl:text>
738       <xsl:apply-templates select="refentry" mode="hhc"/>
739     </UL>
740   </xsl:if>
741 </xsl:template>
742
743 <!-- ==================================================================== -->
744
745 <xsl:template match="indexterm">
746   <xsl:choose>
747     <xsl:when test="$htmlhelp.use.hhk = 0">
748   
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)"/>
752       
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"/>
758         </xsl:if>
759         <xsl:if test="tertiary">
760           <xsl:text>, </xsl:text>
761           <xsl:value-of select="$tertiary"/>
762         </xsl:if>
763       </xsl:variable>
764       
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"/>
769           </xsl:call-template>
770         </xsl:if>
771       </xsl:if>
772
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)"/>
777           </xsl:call-template>
778         </xsl:if>
779       </xsl:if>
780       
781       <xsl:call-template name="write.indexterm">
782         <xsl:with-param name="text" select="$text"/>
783       </xsl:call-template>
784       
785     </xsl:when>
786     <xsl:otherwise>
787       <a>
788         <xsl:attribute name="name">
789           <xsl:call-template name="object.id"/>
790         </xsl:attribute>
791       </a>
792     </xsl:otherwise>
793     
794   </xsl:choose>
795 </xsl:template>
796
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}"/>
801   </OBJECT>
802 </xsl:template>
803
804 <!-- ==================================================================== -->
805
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"/>
811       </xsl:if>
812       <xsl:value-of select="$htmlhelp.hhk"/>
813     </xsl:with-param>
814     <xsl:with-param name="indent" select="'no'"/>
815     <xsl:with-param name="content"><xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
816 &lt;HTML&gt;
817 &lt;HEAD&gt;
818 &lt;meta name="GENERATOR" content="Microsoft&amp;reg; HTML Help Workshop 4.1"&gt;
819 &lt;!-- Sitemap 1.0 --&gt;
820 &lt;/HEAD&gt;&lt;BODY&gt;
821 &lt;OBJECT type="text/site properties"&gt;
822 &lt;/OBJECT&gt;
823 &lt;UL&gt;
824 </xsl:text>
825 <xsl:if test="($htmlhelp.use.hhk != 0) and $htmlhelp.generate.index">
826   <xsl:choose>
827     <xsl:when test="$rootid != ''">
828       <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hhk"/>
829     </xsl:when>
830     <xsl:otherwise>
831       <xsl:apply-templates select="$profiled-nodes" mode="hhk"/>
832     </xsl:otherwise>
833   </xsl:choose>
834 </xsl:if>
835 <xsl:text disable-output-escaping="yes">&lt;/UL&gt;
836 &lt;/BODY&gt;&lt;/HTML&gt;
837 </xsl:text></xsl:with-param>
838     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
839     <xsl:with-param name="quiet" select="$chunk.quietly"/>
840   </xsl:call-template>
841 </xsl:template>
842
843 <xsl:template match="indexterm[@class='endofrange']" mode="hhk"/>
844
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)"/>
849
850   <xsl:call-template name="write.indexterm.hhk">
851     <xsl:with-param name="text" select="$primary"/>
852     <xsl:with-param name="seealso" select="seealso"/>
853   </xsl:call-template>
854
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"/>
861       </xsl:call-template>
862     </xsl:if>
863     <UL>
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"/>
867     </xsl:call-template>
868     <xsl:if test="tertiary">
869       <UL><xsl:text>
870 </xsl:text>
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"/>
874       </xsl:call-template>
875       </UL>
876     </xsl:if>
877     </UL>
878   </xsl:if>
879
880 </xsl:template>
881
882 <xsl:template name="write.indexterm.hhk">
883   <xsl:param name="text"/>
884   <xsl:param name="seealso"/>
885
886   <LI> <OBJECT type="text/sitemap"><xsl:text>
887 </xsl:text>
888     <param name="Name">
889       <xsl:attribute name="value">
890         <xsl:value-of select="$text"/>
891       </xsl:attribute>
892     </param><xsl:text>
893 </xsl:text>
894
895       <xsl:if test="not(seealso)">
896         <xsl:variable name="href">
897           <xsl:call-template name="href.target.with.base.dir"/>
898         </xsl:variable>
899         <xsl:variable name="title">
900           <xsl:call-template name="nearest.title">
901             <xsl:with-param name="object" select=".."/>
902           </xsl:call-template>
903         </xsl:variable>
904
905         <param name="Name">
906           <xsl:attribute name="value">
907           <xsl:value-of select="$title"/>
908           </xsl:attribute>
909         </param><xsl:text>
910 </xsl:text>
911         <param name="Local">
912           <xsl:attribute name="value">
913           <xsl:value-of select="$href"/>
914           </xsl:attribute>
915         </param><xsl:text>
916 </xsl:text>
917       </xsl:if>
918
919       <xsl:if test="seealso">
920         <param name="See Also">
921           <xsl:attribute name="value">
922           <xsl:value-of select="$seealso"/>
923           </xsl:attribute>
924         </param><xsl:text>
925 </xsl:text>
926       </xsl:if>
927       </OBJECT></LI>
928 </xsl:template>
929
930 <xsl:template match="text()" mode="hhk"/>
931
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"/>
935 </xsl:template>
936
937 <!-- ==================================================================== -->
938
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"/>
944       </xsl:if>
945       <xsl:value-of select="$htmlhelp.map.file"/>
946     </xsl:with-param>
947     <xsl:with-param name="method" select="'text'"/>
948     <xsl:with-param name="content">
949      <xsl:choose>
950        <xsl:when test="$rootid != ''">
951          <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hh-map"/>
952        </xsl:when>
953        <xsl:otherwise>
954          <xsl:apply-templates select="$profiled-nodes" mode="hh-map"/>
955        </xsl:otherwise>
956      </xsl:choose>
957     </xsl:with-param>
958     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
959     <xsl:with-param name="quiet" select="$chunk.quietly"/>
960   </xsl:call-template>
961 </xsl:template>
962
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'"/>
968     </xsl:call-template>
969   </xsl:variable>
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'"/>
974     </xsl:call-template>
975   </xsl:variable>
976   <xsl:text>#define </xsl:text>
977   <xsl:value-of select="$topicname"/>
978   <xsl:text>    </xsl:text>
979   <xsl:value-of select="$topicid"/>
980   <xsl:text>
981 </xsl:text>
982 </xsl:template>
983
984 <xsl:template match="text()" mode="hh-map"/>
985
986 <!-- ==================================================================== -->
987
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"/>
993       </xsl:if>
994       <xsl:value-of select="$htmlhelp.alias.file"/>
995     </xsl:with-param>
996     <xsl:with-param name="method" select="'text'"/>
997     <xsl:with-param name="content">
998      <xsl:choose>
999        <xsl:when test="$rootid != ''">
1000          <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="hh-alias"/>
1001        </xsl:when>
1002        <xsl:otherwise>
1003          <xsl:apply-templates select="$profiled-nodes" mode="hh-alias"/>
1004        </xsl:otherwise>
1005      </xsl:choose>
1006     </xsl:with-param>
1007     <xsl:with-param name="encoding" select="$htmlhelp.encoding"/>
1008     <xsl:with-param name="quiet" select="$chunk.quietly"/>
1009   </xsl:call-template>
1010 </xsl:template>
1011
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>
1018   </xsl:variable>
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>
1023   </xsl:variable>
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"/>
1029   <xsl:text>
1030 </xsl:text>
1031 </xsl:template>
1032
1033 <xsl:template match="text()" mode="hh-alias"/>
1034
1035 <!-- ==================================================================== -->
1036 <!-- This code can be used to convert any number to hexadecimal format -->
1037
1038   <h:hex>
1039     <d>0</d>
1040     <d>1</d>
1041     <d>2</d>
1042     <d>3</d>
1043     <d>4</d>
1044     <d>5</d>
1045     <d>6</d>
1046     <d>7</d>
1047     <d>8</d>
1048     <d>9</d>
1049     <d>A</d>
1050     <d>B</d>
1051     <d>C</d>
1052     <d>D</d>
1053     <d>E</d>
1054     <d>F</d>
1055   </h:hex>
1056
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 &gt; 0">
1062       <xsl:call-template name="toHex">
1063         <xsl:with-param name="n" select="$rest"/>
1064       </xsl:call-template>
1065     </xsl:if>
1066     <xsl:value-of select="document('')//h:hex/d[$digit+1]"/>
1067   </xsl:template>
1068
1069 <!-- ==================================================================== -->
1070 <!-- Modification to standard HTML stylesheets -->
1071
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/>
1080   </h3>
1081 </xsl:template>
1082
1083 </xsl:stylesheet>