]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/javahelp/javahelp.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / javahelp / javahelp.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3   xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4   xmlns:ng="http://docbook.org/docbook-ng"
5   xmlns:db="http://docbook.org/ns/docbook"
6   xmlns:exsl="http://exslt.org/common"
7   version="1.0"
8   exclude-result-prefixes="doc ng db exsl">
9
10 <xsl:import href="../html/chunk.xsl"/>
11
12 <xsl:output method="html"/>
13
14 <!-- ********************************************************************
15      $Id: javahelp.xsl 8400 2009-04-08 07:44:54Z bobstayton $
16      ********************************************************************
17
18      This file is part of the XSL DocBook Stylesheet distribution.
19      See ../README or http://docbook.sf.net/release/xsl/current/ for
20      copyright and other information.
21
22      ******************************************************************** -->
23
24 <!-- ==================================================================== -->
25
26 <xsl:template match="/">
27   <!-- * Get a title for current doc so that we let the user -->
28   <!-- * know what document we are processing at this point. -->
29   <xsl:variable name="doc.title">
30     <xsl:call-template name="get.doc.title"/>
31   </xsl:variable>
32   <xsl:choose>
33     <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
34          toss the namespace and continue.  Use the docbook5 namespaced
35          stylesheets for DocBook5 if you don't want to use this feature.-->
36     <xsl:when test="$exsl.node.set.available != 0
37                     and (*/self::ng:* or */self::db:*)">
38       <xsl:call-template name="log.message">
39         <xsl:with-param name="level">Note</xsl:with-param>
40         <xsl:with-param name="source" select="$doc.title"/>
41         <xsl:with-param name="context-desc">
42           <xsl:text>namesp. cut</xsl:text>
43         </xsl:with-param>
44         <xsl:with-param name="message">
45           <xsl:text>stripped namespace before processing</xsl:text>
46         </xsl:with-param>
47       </xsl:call-template>
48       <xsl:variable name="nons">
49         <xsl:apply-templates mode="stripNS"/>
50       </xsl:variable>
51       <xsl:call-template name="log.message">
52         <xsl:with-param name="level">Note</xsl:with-param>
53         <xsl:with-param name="source" select="$doc.title"/>
54         <xsl:with-param name="context-desc">
55           <xsl:text>namesp. cut</xsl:text>
56         </xsl:with-param>
57         <xsl:with-param name="message">
58           <xsl:text>processing stripped document</xsl:text>
59         </xsl:with-param>
60       </xsl:call-template>
61       <xsl:apply-templates select="exsl:node-set($nons)"/>
62     </xsl:when>
63     <xsl:otherwise>
64   <xsl:choose>
65     <xsl:when test="$rootid != ''">
66       <xsl:choose>
67         <xsl:when test="count(key('id',$rootid)) = 0">
68           <xsl:message terminate="yes">
69             <xsl:text>ID '</xsl:text>
70             <xsl:value-of select="$rootid"/>
71             <xsl:text>' not found in document.</xsl:text>
72           </xsl:message>
73         </xsl:when>
74         <xsl:otherwise>
75           <xsl:message>Formatting from <xsl:value-of select="$rootid"/></xsl:message>
76           <xsl:apply-templates select="key('id',$rootid)" mode="process.root"/>
77         </xsl:otherwise>
78       </xsl:choose>
79     </xsl:when>
80     <xsl:otherwise>
81       <xsl:apply-templates select="/" mode="process.root"/>
82     </xsl:otherwise>
83   </xsl:choose>
84   <xsl:for-each select="/">    <!-- This is just a hook for building profiling stylesheets -->
85     <xsl:call-template name="helpset"/>
86     <xsl:call-template name="helptoc"/>
87     <xsl:call-template name="helpmap"/>
88     <xsl:call-template name="helpidx"/>
89   </xsl:for-each>
90 </xsl:otherwise>
91 </xsl:choose>
92 </xsl:template>
93
94 <xsl:template name="header.navigation">
95 </xsl:template>
96
97 <xsl:template name="footer.navigation">
98 </xsl:template>
99
100 <!-- ==================================================================== -->
101
102 <xsl:template name="helpset">
103   <xsl:call-template name="write.chunk.with.doctype">
104     <xsl:with-param name="filename" select="concat($base.dir,'jhelpset.hs')"/>
105     <xsl:with-param name="method" select="'xml'"/>
106     <xsl:with-param name="indent" select="'yes'"/>
107     <xsl:with-param name="doctype-public" select="'-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN'"/>
108     <xsl:with-param name="doctype-system" select="'http://java.sun.com/products/javahelp/helpset_1_0.dtd'"/>
109     <xsl:with-param name="content">
110       <xsl:call-template name="helpset.content"/>
111     </xsl:with-param>
112     <xsl:with-param name="quiet" select="$chunk.quietly"/>
113   </xsl:call-template>
114 </xsl:template>
115
116 <xsl:template name="helpset.content">
117   <xsl:variable name="title">
118     <xsl:apply-templates select="." mode="title.markup"/>
119   </xsl:variable>
120
121   <helpset version="1.0">
122     <title>
123       <xsl:value-of select="normalize-space($title)"/>
124     </title>
125
126     <!-- maps -->
127     <maps>
128       <homeID>top</homeID>
129       <mapref location="jhelpmap.jhm"/>
130     </maps>
131
132     <!-- views -->
133     <view>
134       <name>TOC</name>
135       <label>Table Of Contents</label>
136       <type>javax.help.TOCView</type>
137       <data>jhelptoc.xml</data>
138     </view>
139
140     <view>
141       <name>Index</name>
142       <label>Index</label>
143       <type>javax.help.IndexView</type>
144       <data>jhelpidx.xml</data>
145     </view>
146
147     <view>
148       <name>Search</name>
149       <label>Search</label>
150       <type>javax.help.SearchView</type>
151       <data engine="com.sun.java.help.search.DefaultSearchEngine">JavaHelpSearch</data>
152     </view>
153   </helpset>
154 </xsl:template>
155
156 <!-- ==================================================================== -->
157
158 <xsl:template name="helptoc">
159   <xsl:call-template name="write.chunk.with.doctype">
160     <xsl:with-param name="filename" select="concat($base.dir,'jhelptoc.xml')"/>
161     <xsl:with-param name="method" select="'xml'"/>
162     <xsl:with-param name="indent" select="'yes'"/>
163     <xsl:with-param name="doctype-public" select="'-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN'"/>
164     <xsl:with-param name="doctype-system" select="'http://java.sun.com/products/javahelp/toc_1_0.dtd'"/>
165     <xsl:with-param name="encoding" select="$javahelp.encoding"/>
166     <xsl:with-param name="content">
167       <xsl:call-template name="helptoc.content"/>
168     </xsl:with-param>
169     <xsl:with-param name="quiet" select="$chunk.quietly"/>
170   </xsl:call-template>
171 </xsl:template>
172
173 <xsl:template name="helptoc.content">
174   <toc version="1.0">
175     <xsl:choose>
176       <xsl:when test="$rootid != ''">
177         <xsl:apply-templates select="key('id',$rootid)" mode="jhtoc"/>
178       </xsl:when>
179       <xsl:otherwise>
180         <xsl:apply-templates select="." mode="jhtoc"/>
181       </xsl:otherwise>
182     </xsl:choose>
183   </toc>
184 </xsl:template>
185
186 <xsl:template match="set" mode="jhtoc">
187   <xsl:variable name="id">
188     <xsl:call-template name="object.id">
189       <xsl:with-param name="object" select="."/>
190     </xsl:call-template>
191   </xsl:variable>
192   <xsl:variable name="title">
193     <xsl:apply-templates select="." mode="title.markup"/>
194   </xsl:variable>
195
196   <tocitem target="{$id}">
197     <xsl:attribute name="text">
198       <xsl:value-of select="normalize-space($title)"/>
199     </xsl:attribute>
200     <xsl:apply-templates select="book" mode="jhtoc"/>
201   </tocitem>
202 </xsl:template>
203
204 <xsl:template match="book" mode="jhtoc">
205   <xsl:variable name="id">
206     <xsl:call-template name="object.id"/>
207   </xsl:variable>
208   <xsl:variable name="title">
209     <xsl:apply-templates select="." mode="title.markup"/>
210   </xsl:variable>
211
212   <tocitem target="{$id}">
213     <xsl:attribute name="text">
214       <xsl:value-of select="normalize-space($title)"/>
215     </xsl:attribute>
216     <xsl:apply-templates select="part|reference|preface|chapter|appendix|article|colophon|glossary|bibliography"
217                          mode="jhtoc"/>
218   </tocitem>
219 </xsl:template>
220
221 <xsl:template match="part|reference|preface|chapter|appendix|article"
222               mode="jhtoc">
223   <xsl:variable name="id">
224     <xsl:call-template name="object.id"/>
225   </xsl:variable>
226   <xsl:variable name="title">
227     <xsl:apply-templates select="." mode="title.markup"/>
228   </xsl:variable>
229
230   <tocitem target="{$id}">
231     <xsl:attribute name="text">
232       <xsl:value-of select="normalize-space($title)"/>
233     </xsl:attribute>
234     <xsl:apply-templates
235       select="article|preface|chapter|appendix|refentry|section|sect1|glossary|bibliography"
236       mode="jhtoc"/>
237   </tocitem>
238 </xsl:template>
239
240 <xsl:template match="section" mode="jhtoc">
241   <xsl:variable name="id">
242     <xsl:call-template name="object.id"/>
243   </xsl:variable>
244   <xsl:variable name="title">
245     <xsl:apply-templates select="." mode="title.markup"/>
246   </xsl:variable>
247
248   <tocitem target="{$id}">
249     <xsl:attribute name="text">
250       <xsl:value-of select="normalize-space($title)"/>
251     </xsl:attribute>
252     <xsl:apply-templates select="section" mode="jhtoc"/>
253   </tocitem>
254 </xsl:template>
255
256 <xsl:template match="sect1" mode="jhtoc">
257   <xsl:variable name="id">
258     <xsl:call-template name="object.id"/>
259   </xsl:variable>
260   <xsl:variable name="title">
261     <xsl:apply-templates select="." mode="title.markup"/>
262   </xsl:variable>
263
264   <tocitem target="{$id}">
265     <xsl:attribute name="text">
266       <xsl:value-of select="normalize-space($title)"/>
267     </xsl:attribute>
268     <xsl:apply-templates select="sect2" mode="jhtoc"/>
269   </tocitem>
270 </xsl:template>
271
272 <xsl:template match="sect2" mode="jhtoc">
273   <xsl:variable name="id">
274     <xsl:call-template name="object.id"/>
275   </xsl:variable>
276   <xsl:variable name="title">
277     <xsl:apply-templates select="." mode="title.markup"/>
278   </xsl:variable>
279
280   <tocitem target="{$id}">
281     <xsl:attribute name="text">
282       <xsl:value-of select="normalize-space($title)"/>
283     </xsl:attribute>
284     <xsl:apply-templates select="sect3" mode="jhtoc"/>
285   </tocitem>
286 </xsl:template>
287
288 <xsl:template match="sect3" mode="jhtoc">
289   <xsl:variable name="id">
290     <xsl:call-template name="object.id"/>
291   </xsl:variable>
292   <xsl:variable name="title">
293     <xsl:apply-templates select="." mode="title.markup"/>
294   </xsl:variable>
295
296   <tocitem target="{$id}">
297     <xsl:attribute name="text">
298       <xsl:value-of select="normalize-space($title)"/>
299     </xsl:attribute>
300     <xsl:apply-templates select="sect4" mode="jhtoc"/>
301   </tocitem>
302 </xsl:template>
303
304 <xsl:template match="sect4" mode="jhtoc">
305   <xsl:variable name="id">
306     <xsl:call-template name="object.id"/>
307   </xsl:variable>
308   <xsl:variable name="title">
309     <xsl:apply-templates select="." mode="title.markup"/>
310   </xsl:variable>
311
312   <tocitem target="{$id}">
313     <xsl:attribute name="text">
314       <xsl:value-of select="normalize-space($title)"/>
315     </xsl:attribute>
316     <xsl:apply-templates select="sect5" mode="jhtoc"/>
317   </tocitem>
318 </xsl:template>
319
320 <xsl:template match="sect5|colophon|refentry" mode="jhtoc">
321   <xsl:variable name="id">
322     <xsl:call-template name="object.id"/>
323   </xsl:variable>
324   <xsl:variable name="title">
325     <xsl:apply-templates select="." mode="title.markup"/>
326   </xsl:variable>
327
328   <tocitem target="{$id}">
329     <xsl:attribute name="text">
330       <xsl:value-of select="normalize-space($title)"/>
331     </xsl:attribute>
332   </tocitem>
333 </xsl:template>
334
335
336 <xsl:template match="glossary" mode="jhtoc">
337   <xsl:variable name="id">
338     <xsl:call-template name="object.id"/>
339   </xsl:variable>
340
341   <xsl:variable name="title">
342     <xsl:call-template name="gentext">
343       <xsl:with-param name="key" select="'Glossary'"/>
344     </xsl:call-template>
345   </xsl:variable>
346
347   <tocitem target="{$id}">
348     <xsl:attribute name="text">
349       <xsl:value-of select="$title"/>
350     </xsl:attribute>
351   </tocitem>
352
353 </xsl:template>
354
355 <xsl:template match="bibliography" mode="jhtoc">
356   <xsl:variable name="id">
357     <xsl:call-template name="object.id"/>
358   </xsl:variable>
359
360   <xsl:variable name="title">
361     <xsl:call-template name="gentext">
362       <xsl:with-param name="key" select="'Bibliography'"/>
363     </xsl:call-template>
364   </xsl:variable>
365
366   <tocitem target="{$id}">
367     <xsl:attribute name="text">
368       <xsl:value-of select="$title"/>
369     </xsl:attribute>
370     
371   </tocitem>
372 </xsl:template>
373
374 <!-- ==================================================================== -->
375
376 <xsl:template name="helpmap">
377   <xsl:call-template name="write.chunk.with.doctype">
378     <xsl:with-param name="filename" select="concat($base.dir, 'jhelpmap.jhm')"/>
379     <xsl:with-param name="method" select="'xml'"/>
380     <xsl:with-param name="indent" select="'yes'"/>
381     <xsl:with-param name="doctype-public" select="'-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN'"/>
382     <xsl:with-param name="doctype-system" select="'http://java.sun.com/products/javahelp/map_1_0.dtd'"/>
383     <xsl:with-param name="encoding" select="$javahelp.encoding"/>
384     <xsl:with-param name="content">
385       <xsl:call-template name="helpmap.content"/>
386     </xsl:with-param>
387     <xsl:with-param name="quiet" select="$chunk.quietly"/>
388   </xsl:call-template>
389 </xsl:template>
390
391 <xsl:template name="helpmap.content">
392   <map version="1.0">
393     <xsl:choose>
394       <xsl:when test="$rootid != ''">
395         <xsl:apply-templates select="key('id',$rootid)//set
396                                      | key('id',$rootid)//book
397                                      | key('id',$rootid)//part
398                                      | key('id',$rootid)//reference
399                                      | key('id',$rootid)//preface
400                                      | key('id',$rootid)//chapter
401                                      | key('id',$rootid)//appendix
402                                      | key('id',$rootid)//article
403                                      | key('id',$rootid)//colophon
404                                      | key('id',$rootid)//refentry
405                                      | key('id',$rootid)//section
406                                      | key('id',$rootid)//sect1
407                                      | key('id',$rootid)//sect2
408                                      | key('id',$rootid)//sect3
409                                      | key('id',$rootid)//sect4
410                                      | key('id',$rootid)//sect5
411                                      | key('id',$rootid)//indexterm 
412                                      | key('id',$rootid)//glossary
413                                      | key('id',$rootid)//bibliography
414                                      | key('id',$rootid)//*[@id]"
415                              mode="map"/>
416       </xsl:when>
417       <xsl:otherwise>
418         <xsl:apply-templates select="//set
419                                      | //book
420                                      | //part
421                                      | //reference
422                                      | //preface
423                                      | //chapter
424                                      | //appendix
425                                      | //article
426                                      | //colophon
427                                      | //refentry
428                                      | //section
429                                      | //sect1
430                                      | //sect2
431                                      | //sect3
432                                      | //sect4
433                                      | //sect5
434                                      | //indexterm
435                                      | //glossary
436                                      | //bibliography
437                                      | //*[@id]"
438                              mode="map"/>
439       </xsl:otherwise>
440     </xsl:choose>
441   </map>
442 </xsl:template>
443
444 <xsl:template match="set" mode="map">
445   <xsl:variable name="id">
446     <xsl:call-template name="object.id">
447       <xsl:with-param name="object" select="."/>
448     </xsl:call-template>
449   </xsl:variable>
450
451   <mapID target="{$id}">
452     <xsl:attribute name="url">
453       <xsl:call-template name="href.target.uri"/>
454     </xsl:attribute>
455   </mapID>
456 </xsl:template>
457
458 <xsl:template match="book" mode="map">
459   <xsl:variable name="id">
460     <xsl:call-template name="object.id"/>
461   </xsl:variable>
462
463   <mapID target="{$id}">
464     <xsl:attribute name="url">
465       <xsl:call-template name="href.target.uri"/>
466     </xsl:attribute>
467   </mapID>
468 </xsl:template>
469
470 <xsl:template match="part|reference|preface|chapter|appendix|refentry|article|glossary|bibliography"
471               mode="map">
472   <xsl:variable name="id">
473     <xsl:call-template name="object.id"/>
474   </xsl:variable>
475
476   <mapID target="{$id}">
477     <xsl:attribute name="url">
478       <xsl:call-template name="href.target.uri"/>
479     </xsl:attribute>
480   </mapID>
481 </xsl:template>
482
483 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5|colophon" mode="map">
484   <xsl:variable name="id">
485     <xsl:call-template name="object.id"/>
486   </xsl:variable>
487
488   <mapID target="{$id}">
489     <xsl:attribute name="url">
490       <xsl:call-template name="href.target.uri"/>
491     </xsl:attribute>
492   </mapID>
493 </xsl:template>
494
495 <xsl:template match="indexterm[@class='endofrange']" mode="map"/>
496
497 <xsl:template match="indexterm" mode="map">
498   <xsl:variable name="id">
499     <xsl:call-template name="object.id"/>
500   </xsl:variable>
501
502   <mapID target="{$id}">
503     <xsl:attribute name="url">
504       <xsl:call-template name="href.target.uri"/>
505     </xsl:attribute>
506   </mapID>
507 </xsl:template>
508
509 <xsl:template match="*[@id]" mode="map">
510   <xsl:variable name="id">
511     <xsl:call-template name="object.id"/>
512   </xsl:variable>
513
514   <mapID target="{$id}">
515     <xsl:attribute name="url">
516       <xsl:call-template name="href.target.uri"/>
517     </xsl:attribute>
518   </mapID>
519 </xsl:template>
520
521 <!-- ==================================================================== -->
522
523 <xsl:template name="helpidx">
524   <xsl:call-template name="write.chunk.with.doctype">
525     <xsl:with-param name="filename" select="concat($base.dir, 'jhelpidx.xml')"/>
526     <xsl:with-param name="method" select="'xml'"/>
527     <xsl:with-param name="indent" select="'yes'"/>
528     <xsl:with-param name="doctype-public" select="'-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN'"/>
529     <xsl:with-param name="doctype-system" select="'http://java.sun.com/products/javahelp/index_1_0.dtd'"/>
530     <xsl:with-param name="encoding" select="$javahelp.encoding"/>
531     <xsl:with-param name="content">
532       <xsl:call-template name="helpidx.content"/>
533     </xsl:with-param>
534     <xsl:with-param name="quiet" select="$chunk.quietly"/>
535   </xsl:call-template>
536 </xsl:template>
537
538 <xsl:template name="helpidx.content">
539   <index version="1.0">
540     <xsl:choose>
541       <xsl:when test="$rootid != ''">
542         <xsl:apply-templates select="key('id',$rootid)//indexterm" mode="idx">
543           <xsl:sort select="primary"/>
544           <xsl:sort select="secondary"/>
545           <xsl:sort select="tertiary"/>
546         </xsl:apply-templates>
547       </xsl:when>
548       <xsl:otherwise>
549         <xsl:apply-templates select="//indexterm" mode="idx">
550           <xsl:sort select="primary"/>
551           <xsl:sort select="secondary"/>
552           <xsl:sort select="tertiary"/>
553         </xsl:apply-templates>
554       </xsl:otherwise>
555     </xsl:choose>
556   </index>
557 </xsl:template>
558
559 <xsl:template match="indexterm[@class='endofrange']" mode="idx"/>
560
561 <xsl:template match="indexterm" mode="idx">
562   <xsl:variable name="id">
563     <xsl:call-template name="object.id"/>
564   </xsl:variable>
565
566   <xsl:variable name="text">
567     <xsl:value-of select="normalize-space(primary)"/>
568     <xsl:if test="secondary">
569       <xsl:text>, </xsl:text>
570       <xsl:value-of select="normalize-space(secondary)"/>
571     </xsl:if>
572     <xsl:if test="tertiary">
573       <xsl:text>, </xsl:text>
574       <xsl:value-of select="normalize-space(tertiary)"/>
575     </xsl:if>
576   </xsl:variable>
577
578   <xsl:choose>
579     <xsl:when test="see">
580       <xsl:variable name="see"><xsl:value-of select="normalize-space(see)"/></xsl:variable>
581       <indexitem text="{$text} see '{$see}'"/>
582     </xsl:when>
583     <xsl:otherwise>
584       <indexitem text="{$text}" target="{$id}"/>
585     </xsl:otherwise>
586   </xsl:choose>
587 </xsl:template>
588
589 <!-- ==================================================================== -->
590 <!-- Kludge for Xalan outputting &trade; which fails in javahelp -->
591 <xsl:template name="dingbat.characters">
592   <!-- now that I'm using the real serializer, all that dingbat malarky -->
593   <!-- isn't necessary anymore... -->
594   <xsl:param name="dingbat">bullet</xsl:param>
595
596   <xsl:choose>
597     <xsl:when test="$dingbat='bullet'">&#x2022;</xsl:when>
598     <xsl:when test="$dingbat='copyright'">&#x00A9;</xsl:when>
599     <xsl:when test="$dingbat='trademark' or $dingbat='trade'">
600       <xsl:choose>
601         <xsl:when test="contains(system-property('xsl:vendor'),
602                                  'Apache Software Foundation')">
603           <sup>TM</sup>
604         </xsl:when>
605         <xsl:otherwise>&#x2122;</xsl:otherwise>
606       </xsl:choose>
607     </xsl:when>
608     <xsl:when test="$dingbat='registered'">&#x00AE;</xsl:when>
609     <xsl:when test="$dingbat='service'">(SM)</xsl:when>
610     <xsl:when test="$dingbat='nbsp'">&#x00A0;</xsl:when>
611     <xsl:when test="$dingbat='ldquo'">&#x201C;</xsl:when>
612     <xsl:when test="$dingbat='rdquo'">&#x201D;</xsl:when>
613     <xsl:when test="$dingbat='lsquo'">&#x2018;</xsl:when>
614     <xsl:when test="$dingbat='rsquo'">&#x2019;</xsl:when>
615     <xsl:when test="$dingbat='em-dash'">&#x2014;</xsl:when>
616     <xsl:when test="$dingbat='mdash'">&#x2014;</xsl:when>
617     <xsl:when test="$dingbat='en-dash'">&#x2013;</xsl:when>
618     <xsl:when test="$dingbat='ndash'">&#x2013;</xsl:when>
619     <xsl:otherwise>
620       <xsl:text>&#x2022;</xsl:text>
621     </xsl:otherwise>
622   </xsl:choose>
623 </xsl:template>
624
625 </xsl:stylesheet>