-
Notifications
You must be signed in to change notification settings - Fork 2
/
ahelp_index.xsl
1037 lines (868 loc) · 36.3 KB
/
ahelp_index.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet>
<!--* AHELP XML to HTML convertor using XSL Transformations
*
*
* Create the "index" pages for the ahelp pages - at least the
* alphabetical and contextual listings.
*
* The stylesheet produces a text output - to STDOUT - listing the files it
* has created (it uses xsl:document to create the HTML files).
*
* User (ie by the stylesheet processor) defineable parameters:
* . type - string, required
* one of "live", "test", or "trial"
* determines where the HTML files are created
* trial is a "developer only" value
*
* . site - string, required
* what site are we to generate the index for, should be
* one of ciao or sherpa
*
* . url - TEMPORARY HACK - see v1.21 of ahelp_common
*
* . urlbase - string
* base URL of pages (MAY NOT BE NEEDED AS NO LONGER
* GENERATE PDF VERSION)
*
* . updateby - string
* name of person publishing the page (output of whoami is sufficient)
*
* . cssfile - string
* url of CSS file for pages
*
* . navbarname="name" of navbar to use for indexes
* if navbar is called navbar_XXX.incl then set navbarname to XXX
* default=ahelp
*
* . searchssi - string, default=/incl/search.html, required
* url of SSI file for the search bar
*
* . sitebanner=location of xinclude file for banner (optional)
* The location is relative to the top-level directory for the site
* and should be an xinclude-type page, if set.
*
* . logoimage, string, optional
*
* if the navbar is to have a logo image at the top, this gives the
* location of the image, relative to *THE LOCATION OF THE NAV BAR*
* e.g. ../imgs/ciao_logo_navbar.gif
* This is different than in navbar.xsl where we produce multiple
* navigation "bars" in one go and they are not guaranteed to be
* all at the same 'depth'
*
* . logotext, string, optional
*
* if logoimage is set then this gives the the ALT text for the
* logo image, eg "CIAO Logo". If logoimage is unset then this is the
* text that is used
*
* . logourl, string, optional
*
* If a logo is used (either text or an image) then make it a link to
* this location (e.g. '/ciao4.8/').
*
* . indir - string, required
* full path to directory where to find the XML files
* must end in a /
*
* . outdir - string, required
* full path to directory where to install file
* must end in a /
*
* . version, string, required
* used to create title element in html block.
* If "CIAO 2.2.1", then version = "2.2.1"
* NOTE: don't 'trust' the contents of the version block
*
* Notes:
* . we make use of EXSLT functions for date/time
* (see http://www.exslt.org/).
* Actually, could have used an input parameter to do this
*
* . can some of these templates be amalgamated/abstracted?
*
*-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:func="http://exslt.org/functions"
xmlns:exsl="http://exslt.org/common"
xmlns:extfuncs="http://hea-www.harvard.edu/~dburke/xsl/extfuncs"
extension-element-prefixes="date str func exsl extfuncs">
<!--* Change this if the filename changes *-->
<xsl:variable name="hack-import-ahelp_index" select="extfuncs:register-import-dependency('ahelp_index.xsl')"/>
<!--* load in templates *-->
<xsl:include href="ahelp_common.xsl"/>
<xsl:output method="text"/>
<xsl:param name="site" select="''"/>
<xsl:param name="cssfile"/>
<xsl:param name="navbarname" select='"ahelp"'/>
<xsl:param name="searchssi" select='"/incl/search.html"'/>
<xsl:param name="sitebanner" select='""'/>
<xsl:param name="logoimage" select='""'/>
<xsl:param name="logotext" select='""'/>
<xsl:param name="logourl" select='""'/>
<xsl:param name="headtitlepostfix" select='""'/>
<xsl:param name="texttitlepostfix" select='""'/>
<xsl:param name="type"/>
<xsl:param name="urlbase"/>
<xsl:param name="ahelpindexfile"/>
<xsl:param name="outdir"/>
<xsl:param name="version"/>
<xsl:param name="updateby"/>
<!-- for the disclaimer -->
<xsl:param name="pagename" select='"fake-index-page"'/>
<xsl:param name="sourcedir" select='"/dev/null/"'/>
<xsl:variable name="indir"/>
<!--* temporary hack for v1.21/2 of ahelp_common.xsl *-->
<xsl:param name="url" select='""'/>
<!--* needed by breadcrumbs and to stop some complaints *-->
<xsl:param name="depth" select="'1'"/>
<!--*
* Start processing here: "/"
*
* start with the root node since want a 'pull' style approach
*
*-->
<xsl:template match="/">
<!--*
* safety check: are all the required parameters defined/sensible
*-->
<xsl:call-template name="check-param">
<xsl:with-param name="pname" select="'type'"/>
<xsl:with-param name="pvalue" select="$type"/>
<xsl:with-param name="allowed" select="$allowed-types"/>
</xsl:call-template>
<xsl:call-template name="check-param">
<xsl:with-param name="pname" select="'site'"/>
<xsl:with-param name="pvalue" select="$site"/>
<xsl:with-param name="allowed" select="$allowed-sites"/>
</xsl:call-template>
<xsl:call-template name="check-param">
<xsl:with-param name="pname" select="'urlbase'"/>
<xsl:with-param name="pvalue" select="$urlbase"/>
</xsl:call-template>
<xsl:if test="substring($urlbase,string-length($urlbase))!='/'">
<xsl:message terminate="yes">
Error:
urlbase parameter must end in a / character.
urlbase=<xsl:value-of select="$urlbase"/>
</xsl:message>
</xsl:if>
<xsl:call-template name="check-param">
<xsl:with-param name="pname" select="'outdir'"/>
<xsl:with-param name="pvalue" select="$outdir"/>
</xsl:call-template>
<xsl:if test="substring($outdir,string-length($outdir))!='/'">
<xsl:message terminate="yes">
Error:
outdir parameter must end in a / character.
outdir=<xsl:value-of select="$outdir"/>
</xsl:message>
</xsl:if>
<xsl:call-template name="check-param">
<xsl:with-param name="pname" select="'version'"/>
<xsl:with-param name="pvalue" select="$version"/>
</xsl:call-template>
<!--*
* check the logo parameters
*-->
<xsl:if test="$logoimage != '' and $logotext = ''">
<xsl:message terminate="yes">
Error: logotext is unset but logoimage is set to '<xsl:value-of select="$logoimage"/>'
</xsl:message>
</xsl:if>
<!--*
* Check that we have some data:
* ahelpindex/ahelplist/ahelp/site=$site
* ahelpindex/alphabet[@site=$site]
* ahelpindex/context[@site=$site]
* We only need to check one, so try the alphabetical list
*-->
<xsl:if test="count(//ahelpindex/alphabet[@site=$site])=0">
<xsl:message terminate="yes">
Error: no ahelp files found for site='<xsl:value-of select="$site"/>'
</xsl:message>
</xsl:if>
<!--* end of checks *-->
<!--*
* what pages do we create?
*-->
<xsl:call-template name="make-navbar"/>
<xsl:call-template name="make-alphabet"/>
<xsl:call-template name="make-context"/>
<!--* and that's it *-->
</xsl:template> <!--* match=/ *-->
<!--*
* create: navbar_ahelp_index.incl
*
* Since the output is "simple" we create a text file and
* manually create all the tags (which is why there are so
* many xsl:text calls around!!!)
* As of CIAO 3.0 we use CSS to improve control of the look
* of the navbar, and now include the CIAO logo
*
* We also add a title attribute to each ahelp link listing
* the summary for that ahelp page
*
* After the CIAO 3.1 release added comments at the start/end
* of the navbar to hide the contents from the ht://Dig search
* engine used by the CXC (since this navbar contains all the
* ahelp names then it messes up the search)
*
* This is different to the main navbar page, since it retains
* the pre-CIAO 4.8 approach of using a dl to organise the
* contents (CIAO 4.8 main navbars now use a list)
*-->
<xsl:template name="make-navbar">
<!--* output filename to stdout *-->
<xsl:variable name="filename" select="concat($outdir,'navbar_ahelp_index.incl')"/>
<xsl:value-of select="$filename"/><xsl:call-template name="newline"/>
<!--* create document *-->
<xsl:document href="{$filename}" method="text">
<xsl:text disable-output-escaping="yes"><!--htdig_noindex-->
<div>
</xsl:text>
<!--* add the logo/link if required *-->
<xsl:if test="$logotext != ''">
<xsl:text disable-output-escaping="yes"><p class="navimage"></xsl:text>
<!--* link ? -->
<xsl:if test="$logourl != ''">
<xsl:text disable-output-escaping="yes"><a href="</xsl:text>
<xsl:value-of select="$logourl"/>
<xsl:text disaple-output-escaping="yes">"></xsl:text>
</xsl:if>
<!--* logo or text? *-->
<xsl:choose>
<xsl:when test="$logoimage != ''">
<xsl:text disable-output-escaping="yes"><img alt="[</xsl:text><xsl:value-of select="$logotext"/><xsl:text>]" src="</xsl:text><xsl:value-of select="$logoimage"/>"<xsl:text disable-output-escaping="yes">></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$logotext"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$logourl != ''">
<xsl:text disaple-output-escaping="yes"></a></xsl:text>
</xsl:if>
<xsl:text disable-output-escaping="yes"></p></xsl:text>
</xsl:if> <!--* $logotext != '' *-->
<!--* navbar class is now inherited from parent td, not from this div *-->
<!--* create the header links *-->
<xsl:call-template name="add-navbar-qlinks"/>
<xsl:call-template name="add-navbar-alphabet"/>
<!--* loop through each 'letter' (within another dl list) *-->
<xsl:text disable-output-escaping="yes"><dl></xsl:text>
<xsl:for-each select="ahelpindex/alphabet[@site=$site]/term">
<xsl:text disable-output-escaping="yes"><dt id="navbar-</xsl:text>
<xsl:value-of select="name"/>
<xsl:text disable-output-escaping="yes">"><a class="heading"></xsl:text>
<xsl:value-of select="name"/>
<xsl:text disable-output-escaping="yes"></a></dt></xsl:text>
<xsl:text disable-output-escaping="yes"><dd></xsl:text>
<!--*
* loop through each help file
* - try and be clever if have multiple items with the
* same key but different contexts
* have @samekey=1 => single match so can just use key
* 2 => two matches, so either have to say
* "key (context)"
* OR we want to combine because context=sl.*/py.*
* NOTE: the latter option is not supported yet
* _ => error
*-->
<xsl:for-each select="itemlist/item">
<xsl:variable name="thisid" select="@id"/>
<xsl:variable name="ahelpobj" select="/ahelpindex/ahelplist/ahelp[@id = $thisid]"/>
<xsl:if test="boolean($ahelpobj) = false()">
<xsl:message terminate="yes">
Error: Unable to find ahelp info in ahelp index for
key=<xsl:value-of select="$thiskey"/> context=<xsl:value-of select="$thiscon"/>
</xsl:message>
</xsl:if>
<xsl:choose>
<xsl:when test="$ahelpobj/@samekey = 1">
<xsl:call-template name="add-navbar-entry-key">
<xsl:with-param name="ahelpobj" select="$ahelpobj"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$ahelpobj/@samekey = 2">
<xsl:variable name="contail" select="substring($ahelpobj/context,4)"/>
<xsl:choose>
<xsl:when test="starts-with($ahelpobj/context,'sl.')">
<xsl:if test="count($ahelpobj/preceding-sibling::ahelp[key=$ahelpobj/key and context=concat('py.',$contail)]) = 0">
<xsl:call-template name="add-navbar-entry-key-slpy-context">
<xsl:with-param name="slobj" select="$ahelpobj"/>
<xsl:with-param name="context" select="$contail"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="starts-with($ahelpobj/context,'py.')">
<xsl:if test="count($ahelpobj/preceding-sibling::ahelp[key=$ahelpobj/key and context=concat('sl.',$contail)]) = 0">
<xsl:call-template name="add-navbar-entry-key-pysl-context">
<xsl:with-param name="pyobj" select="$ahelpobj"/>
<xsl:with-param name="context" select="$contail"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="add-navbar-entry-key-context">
<xsl:with-param name="ahelpobj" select="$ahelpobj"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ERROR: ahelp key=<xsl:value-of select="$ahelpobj/key"/> context=<xsl:value-of select="$ahelpobj/context"/> @samekey=<xsl:value-of select="$ahelpobj/@samekey"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> <!--* itemlist/item *-->
<xsl:text disable-output-escaping="yes">&nbsp;<br></dd></xsl:text>
</xsl:for-each> <!--* alphabet[@site=$site]/term *-->
<xsl:text disable-output-escaping="yes"></dl></xsl:text>
<!--* create the header links *-->
<xsl:call-template name="add-navbar-alphabet"/>
<xsl:call-template name="add-navbar-qlinks"/>
<xsl:text disable-output-escaping="yes"></div>
</xsl:text> <!--* class=navbar *-->
<xsl:text disable-output-escaping="yes"><!--/htdig_noindex-->
</xsl:text>
</xsl:document>
</xsl:template> <!--* name=make-navbar *-->
<!--*
* Add a link to the navbar to an ahelp entry; only the key is needed
* here
*-->
<xsl:template name="add-navbar-entry-key">
<xsl:param name="ahelpobj" select="''"/>
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="title" select="concat('Ahelp (',$ahelpobj/context,'): ',$ahelpobj/summary)"/>
<xsl:with-param name="url" select="concat($ahelpobj/page,'.html')"/>
<xsl:with-param name="txt"><xsl:value-of select="$ahelpobj/key"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="add-br"/>
</xsl:template> <!--* name=add-navbar-entry-key *-->
<!--*
* Add a link to the navbar to an ahelp entry; both the key
* and context are needed here
*-->
<xsl:template name="add-navbar-entry-key-context">
<xsl:param name="ahelpobj" select="''"/>
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="title" select="concat('Ahelp (',$ahelpobj/context,'): ',$ahelpobj/summary)"/>
<xsl:with-param name="url" select="concat($ahelpobj/page,'.html')"/>
<xsl:with-param name="txt"><xsl:value-of select="concat($ahelpobj/key,' (',$ahelpobj/context,')')"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="add-br"/>
</xsl:template> <!--* name=add-navbar-entry-key-context *-->
<!--*
* Add the actual text + link for a ahelp page with
* a multi-language context.
* Place Python first.
*-->
<xsl:template name="add-navbar-entry-lang">
<xsl:param name="pyobj" select="''"/>
<xsl:param name="slobj" select="''"/>
<xsl:variable name="key" select="$slobj/key"/>
<xsl:value-of select="concat($key,' - ')"/>
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="title" select="concat('Ahelp (',$pyobj/context,'): ',$pyobj/summary)"/>
<xsl:with-param name="url" select="concat($pyobj/page,'.html')"/>
<xsl:with-param name="txt">py</xsl:with-param>
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="title" select="concat('Ahelp (',$slobj/context,'): ',$slobj/summary)"/>
<xsl:with-param name="url" select="concat($slobj/page,'.html')"/>
<xsl:with-param name="txt">sl</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="add-br"/>
</xsl:template> <!--* name=add-navbar-entry-lang *-->
<!--*
* Add a link to the navbar to an ahelp entry which has
* multi-language support. Place Python first.
* The ahelpobj sent in represents the sl.* version
*-->
<xsl:template name="add-navbar-entry-key-slpy-context">
<xsl:param name="slobj" select="''"/>
<xsl:param name="context" select="''"/>
<xsl:variable name="key" select="$slobj/key"/>
<xsl:variable name="pyobj" select="$slobj/following-sibling::ahelp[key=$key and context=concat('py.',$context)]"/>
<xsl:call-template name="add-navbar-entry-lang">
<xsl:with-param name="pyobj" select="$pyobj"/>
<xsl:with-param name="slobj" select="$slobj"/>
</xsl:call-template>
</xsl:template> <!--* name=add-navbar-entry-key-slpy-context *-->
<!--*
* Add a link to the navbar to an ahelp entry which has
* multi-language support. Place Python first.
* The ahelpobj sent in represents the py.* version
*-->
<xsl:template name="add-navbar-entry-key-pysl-context">
<xsl:param name="pyobj" select="''"/>
<xsl:param name="context" select="''"/>
<xsl:variable name="key" select="$pyobj/key"/>
<xsl:variable name="slobj" select="$pyobj/following-sibling::ahelp[key=$key and context=concat('sl.',$context)]"/>
<xsl:call-template name="add-navbar-entry-lang">
<xsl:with-param name="pyobj" select="$pyobj"/>
<xsl:with-param name="slobj" select="$slobj"/>
</xsl:call-template>
</xsl:template> <!--* name=add-navbar-entry-key-pysl-context *-->
<!--*
* create the "quick links" section of the navbar
* - include a link to the main site "home page"
*-->
<xsl:template name="add-navbar-qlinks">
<xsl:variable name="pretty-site"><xsl:choose>
<xsl:when test="$site = 'ciao'">CIAO</xsl:when>
<xsl:when test="$site = 'sherpa'">Sherpa</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ERROR: expected site to be ciao or sherpa, not '<xsl:value-of select="$site"/>'
</xsl:message>
</xsl:otherwise>
</xsl:choose></xsl:variable>
<!--* link to the home page for the site IF there is no logo link *-->
<xsl:if test="$logourl = ''">
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="url" select="'../index.html'"/> <!--* I do not think we have a valid depth parameter? *-->
<xsl:with-param name="txt" select="concat('Home page (',$pretty-site,')')"/>
<xsl:with-param name="class" select="'heading'"/>
<xsl:with-param name="title" select="concat('The ',$pretty-site,' Home page')"/>
</xsl:call-template>
</xsl:if>
<!--* links to the index pages *-->
<xsl:text disable-output-escaping="yes"><div class="navqlink"></xsl:text>
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="url" select="'index.html'"/>
<xsl:with-param name="txt" select="'Help pages (AHELP)'"/>
<xsl:with-param name="class" select="'heading'"/>
<xsl:with-param name="title" select="'Main Ahelp page'"/>
</xsl:call-template>
<xsl:text disable-output-escaping="yes"></div></xsl:text>
<xsl:text disable-output-escaping="yes"><div class="navqlink"></xsl:text>
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="url" select="'index_alphabet.html'"/>
<xsl:with-param name="txt" select="'List by alphabet'"/>
<xsl:with-param name="class" select="'heading'"/>
<xsl:with-param name="title" select="'Ahelp pages listed in alphabetical order'"/>
</xsl:call-template>
<xsl:text disable-output-escaping="yes"></div></xsl:text>
<xsl:text disable-output-escaping="yes"><div class="navqlink"></xsl:text>
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="url" select="'index_context.html'"/>
<xsl:with-param name="txt" select="'List by context'"/>
<xsl:with-param name="class" select="'heading'"/>
<xsl:with-param name="title" select="'Ahelp pages listed by context'"/>
</xsl:call-template>
<xsl:text disable-output-escaping="yes"></div></xsl:text>
</xsl:template> <!--* name=add-navbar-qlinks *-->
<!--*
* create the "alphabetical links" section of the navbar
*-->
<xsl:template name="add-navbar-alphabet">
<xsl:text disable-output-escaping="yes"><dl></xsl:text>
<xsl:text disable-output-escaping="yes"><dt><span class="heading">Jump to:</span></dt></xsl:text>
<!--* links to the alphabetical sections below *-->
<xsl:text disable-output-escaping="yes"><dd></xsl:text>
<xsl:for-each select="ahelpindex/alphabet[@site=$site]/term">
<xsl:call-template name="add-link-to-text">
<xsl:with-param name="url" select="concat('#navbar-',name)"/>
<xsl:with-param name="txt" select="name"/>
<xsl:with-param name="title" select="concat('Jump to the letter ',name)"/>
</xsl:call-template><xsl:text> </xsl:text>
</xsl:for-each>
<xsl:text disable-output-escaping="yes"></dd></xsl:text>
<xsl:text disable-output-escaping="yes"></dl></xsl:text>
</xsl:template> <!--* name=add-navbar-alphabet *-->
<!--*
* create: index_alphabet.html
*-->
<xsl:template name="make-alphabet">
<xsl:variable name="pagename">index_alphabet</xsl:variable>
<xsl:variable name="filename"><xsl:value-of select="$outdir"/><xsl:value-of select="$pagename"/>.html</xsl:variable>
<!--* output filename to stdout *-->
<xsl:value-of select="$filename"/><xsl:call-template name="newline"/>
<!--* create document *-->
<xsl:document href="{$filename}" method="html" media-type="text/html"
doctype-system="about:legacy-compat"
version="5.0">
<html lang="en-US">
<xsl:call-template name="add-htmlhead">
<xsl:with-param name="title">Ahelp (alphabetical) - <xsl:value-of select="$headtitlepostfix"/></xsl:with-param>
<xsl:with-param name="pagename" select="$pagename"/>
</xsl:call-template>
<xsl:call-template name="add-body-withnavbar">
<xsl:with-param name="contents">
<xsl:apply-templates select="ahelpindex/alphabet[@site=$site]"/>
</xsl:with-param>
<xsl:with-param name="navbar">
<xsl:call-template name="add-navbar">
<xsl:with-param name="navbar" select="$navbarname"/>
</xsl:call-template>
</xsl:with-param>
<!-- TODO: do we want to make this optional? -->
<xsl:with-param name="breadcrumbs" select="true()"/>
<xsl:with-param name="location" select="$filename"/>
<xsl:with-param name="ldepth" select="'2'"/>
</xsl:call-template>
</html>
</xsl:document>
</xsl:template> <!--* name=make-alphabet *-->
<!--* add a set of 'jump to' links for the alphabetical list *-->
<xsl:template name="add-alphabet-jump">
<div class="qlinkbar">Jump to:
<a title="Main Ahelp page" href="index.html">Main AHELP page</a> |
<a title="List by context" href="index_context.html">Contextual List</a>
</div>
</xsl:template>
<!--* add a set of 'jump to' links for the contextual list *-->
<xsl:template name="add-context-jump">
<div class="qlinkbar">Jump to:
<a title="Main Ahelp page" href="index.html">Main AHELP page</a> |
<a title="List by alphabet" href="index_alphabet.html">Alphabetical List</a>
</div>
</xsl:template>
<!--*
* Create the alphabetical index
*
* Output also depends on the value of $type.
* It *may* be that we can get away with assuming this is always going to
* have the correct site-specific alphabet list, but add separate rules to
* ensure this (and it appears that we need that rule)
*
* I did have
* xsl:template match="alphabet[@site=$site]"
* but
* xsltproc was compiled against libxml 20628, libxslt 10121 and libexslt 813
* complained (libxslt 10115 and earlier did not). Is this valid XSLT or not?
* Decided to try and work around this rather than work out what should be
* be going on.
*
* With further review/reqrite it may be that we should only ever be processing
* alphabet nodes for which @site = $site anyway, which will avoid this sissue
*-->
<xsl:template match="alphabet">
<xsl:if test="@site = $site">
<xsl:call-template name="handle-alphabet"/>
</xsl:if>
</xsl:template> <!--* match=alphabet *-->
<xsl:template name="handle-alphabet">
<!--* title *-->
<h2 class="pagetitle">Alphabetical List of Ahelp Files</h2>
<!--* add text/links *-->
<xsl:call-template name="add-alphabet-jump"/>
<hr/>
<!--* create the list of letters/links *-->
<div class="navlinkbar">
<p>
<xsl:for-each select="term">
<xsl:variable name="letter"
select="translate(name,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
<a title="Jump to the letter {$letter}" href="#{$letter}"><xsl:value-of select="$letter"/></a>
<xsl:text> </xsl:text>
</xsl:for-each>
</p>
</div>
<!--* begin the table *-->
<table class="ahelptable">
<!--* the header *-->
<thead>
<tr>
<th><xsl:call-template name="add-nbsp"/><xsl:call-template name="add-nbsp"/><xsl:call-template name="add-nbsp"/></th>
<th>Topic</th>
<th>Context</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
<!--* loop through each 'letter' *-->
<xsl:for-each select="term">
<xsl:variable name="letter"
select="translate(name,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
<!--*
* loop through each help file
* - unlike navbar, don't need to bother about same
* key but different contexts, since we give the context
*-->
<xsl:for-each select="itemlist/item">
<xsl:variable name="thisid" select="@id"/>
<xsl:variable name="ahelpobj" select="/ahelpindex/ahelplist/ahelp[@id = $thisid]"/>
<xsl:variable name="thiskey" select="$ahelpobj/key"/>
<xsl:variable name="thiscon" select="$ahelpobj/context"/>
<tr>
<!--* do we need to add the 'label' *-->
<xsl:if test="position() = 1">
<th class="topalign" rowspan="{last()}" id="{$letter}">
<xsl:value-of select="$letter"/>
</th>
</xsl:if>
<!--* and the actual data *-->
<td class="topalign">
<xsl:call-template name="add-table-bg-color"/>
<a href="{$ahelpobj/page}.html"><xsl:value-of select="$thiskey"/></a>
</td>
<td class="topalign">
<xsl:call-template name="add-table-bg-color"/>
<a href="index_context.html#{$thiscon}"><xsl:value-of select="$thiscon"/></a>
</td>
<td>
<xsl:call-template name="add-table-bg-color"/>
<xsl:value-of select="$ahelpobj/summary"/>
</td>
</tr>
</xsl:for-each> <!--* indexlist/index *-->
<!--* do we add a HR? *-->
<xsl:if test="position() != last()">
<tr><td colspan="4"><hr/></td></tr>
</xsl:if>
</xsl:for-each> <!--* term *-->
</tbody>
</table>
<!--* jump back links *-->
<xsl:call-template name="add-alphabet-jump"/>
</xsl:template> <!--* name=handle-alphabet *-->
<!--*
* create: index_context.html (Web)
*-->
<xsl:template name="make-context">
<xsl:variable name="pagename">index_context</xsl:variable>
<xsl:variable name="filename"><xsl:value-of select="$outdir"/><xsl:value-of select="$pagename"/>.html</xsl:variable>
<!--* output filename to stdout *-->
<xsl:value-of select="$filename"/><xsl:call-template name="newline"/>
<!--* create document *-->
<xsl:document href="{$filename}" method="html" media-type="text/html"
doctype-system="about:legacy-compat"
version="5.0">
<html lang="en-US">
<xsl:call-template name="add-htmlhead">
<xsl:with-param name="title">Ahelp (contextual) - <xsl:value-of select="$headtitlepostfix"/></xsl:with-param>
<xsl:with-param name="pagename" select="$pagename"/>
</xsl:call-template>
<xsl:call-template name="add-body-withnavbar">
<xsl:with-param name="contents">
<xsl:apply-templates select="ahelpindex/context[@site=$site]"/>
</xsl:with-param>
<xsl:with-param name="navbar">
<xsl:call-template name="add-navbar">
<xsl:with-param name="navbar" select="$navbarname"/>
</xsl:call-template>
</xsl:with-param>
<!-- TODO: do we want to make this optional? -->
<xsl:with-param name="breadcrumbs" select="true()"/>
<xsl:with-param name="location" select="$filename"/>
<xsl:with-param name="ldepth" select="'2'"/>
</xsl:call-template>
</html>
</xsl:document>
</xsl:template> <!--* name=make-context *-->
<!--*
* Create the contextual index
*
* Output also depends on the value of $type
* It *may* be that we can get away with assuming this is always going to
* have the correct site-specific context list, but add separate rules to
* ensure this
*
* I did have
* xsl:template match="context[@site=$site]"
* but
* xsltproc was compiled against libxml 20628, libxslt 10121 and libexslt 813
* complained (libxslt 10115 and earlier did not). Is this valid XSLT or not?
* Decided to try and work around this rather than work out what should be
* be going on.
*
* With further review/reqrite it may be that we should only ever be processing
* context nodes for which @site = $site anyway, which will avoid this sissue
*-->
<xsl:template match="context">
<xsl:if test="@site = $site">
<xsl:call-template name="handle-context"/>
</xsl:if>
</xsl:template> <!--* match=context *-->
<xsl:template name="handle-context">
<!--* title *-->
<h2 class="pagetitle">Contextual List of Ahelp Files</h2>
<!--* add text/links *-->
<xsl:call-template name="add-context-jump"/>
<hr/>
<!--* create the list of concepts/links *-->
<div class="navlinkbar">
<p>
<xsl:for-each select="term">
<a title="Jump to context '{name}'" href="#{name}"><xsl:value-of select="name"/></a>
<xsl:if test="position() != last()">
<xsl:text> | </xsl:text>
</xsl:if>
</xsl:for-each>
</p>
</div>
<!--* begin the table *-->
<table class="ahelptable">
<!--* the header *-->
<thead>
<tr>
<th>Context</th>
<th>Topic</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
<!--* loop through each 'context' *-->
<xsl:for-each select="term">
<xsl:variable name="context" select="name"/>
<!--*
* loop through each help file
* - unlike navbar, don't need to bother about same
* key but different contexts since list context explicitly
*-->
<xsl:for-each select="itemlist/item">
<xsl:variable name="thisid" select="@id"/>
<xsl:variable name="ahelpobj" select="/ahelpindex/ahelplist/ahelp[@id = $thisid]"/>
<xsl:variable name="thiskey" select="$ahelpobj/key"/>
<tr>
<!--* do we need to add the 'label' *-->
<xsl:if test="position() = 1">
<th class="topalign" rowspan="{last()}" id="{$context}"><xsl:value-of select="$context"/></th>
</xsl:if>
<!--* and the actual data *-->
<td class="topalign">
<xsl:call-template name="add-table-bg-color"/>
<a href="{$ahelpobj/page}.html"><xsl:value-of select="$thiskey"/></a>
</td>
<td>
<xsl:call-template name="add-table-bg-color"/>
<xsl:value-of select="$ahelpobj/summary"/>
</td>
</tr>
</xsl:for-each> <!--* indexlist/index *-->
<!--* do we add a HR? *-->
<xsl:if test="position() != last()">
<tr><td colspan="3"><hr/></td></tr>
</xsl:if>
</xsl:for-each> <!--* ahelpindex/context/term *-->
</tbody>
</table>
<!--* jump back links *-->
<xsl:call-template name="add-context-jump"/>
</xsl:template> <!--* name=handle-context *-->
<!--* taken from helper.xsl *-->
<xsl:template name="newline">
<xsl:text>
</xsl:text>
</xsl:template>
<!--*
* for writing out a link to a text file: only needed to create
* the navbar output file (where output format=text but want it to
* include html)
*
* Parameters:
* url, string, required
* txt, string, required
* class, string, optional
* title, string, optional
*-->
<xsl:template name="add-link-to-text">
<xsl:param name="url"/>
<xsl:param name="txt"/>
<xsl:param name="class"/>
<xsl:param name="title"/>
<xsl:text disable-output-escaping="yes">
<a href="</xsl:text><xsl:value-of select="$url"/><xsl:text disable-output-escaping="yes">"</xsl:text>
<xsl:if test="$class != ''">
<xsl:value-of select="concat(' class="',$class,'"')"/>
</xsl:if>
<!--*
* we know some summaries contain " and < characters so protect them
*-->
<xsl:if test="$title != ''">
<xsl:variable name="ntitle"><xsl:call-template name="protect-a-title">
<xsl:with-param name="initial" select="$title"/></xsl:call-template></xsl:variable>
<xsl:value-of select="concat(' title="',$ntitle,'"')"/>
</xsl:if>
<xsl:text>></xsl:text><xsl:value-of select="$txt"/><xsl:text disable-output-escaping="yes"></a></xsl:text>
</xsl:template> <!--* name=add-link-to-text *-->
<!-- add the altrow class as necessary; this should not be needed with CSS support -->
<xsl:template name="add-table-bg-color">
<xsl:if test="@number mod 2 = 0">
<xsl:attribute name="class">altrow</xsl:attribute>
</xsl:if>
</xsl:template>
<!--*
* Given a title string, create the HTML head block
*
* input variables:
* title - string, required
* pagename - string, required
* withcss - 0 or 1, defaults to 1
*-->
<xsl:template name="add-htmlhead">
<xsl:param name='title'/>
<xsl:param name='pagename'/>
<xsl:param name='withcss' select="1"/>
<head>
<title><xsl:value-of select="$title"/></title>
<!--* add main stylesheet - if wanted *-->
<xsl:if test="$withcss = 1">
<link rel="stylesheet" title="Default stylesheet for CIAO-related pages" href="{$cssfile}"/>
<link rel="stylesheet" title="Default stylesheet for CIAO-related pages" media="print" href="{$cssprintfile}"/>
</xsl:if>
<!-- canonical link -->
<link rel="canonical" href="{concat($urlbase, 'ahelp/', $pagename, '.html')}"/>
<xsl:call-template name="add-sao-metadata">
<xsl:with-param name="title" select="normalize-space($title)"/>
</xsl:call-template>
</head>
</xsl:template> <!--* add-htmlhead *-->
<!--*
* protect-a-title
*
* paramters:
* initial - string, required
*
* tries to convert ", <, and > to ", <, and > in the string
* (which is "returned"). Ideally would like to say soemthing like:
*
* <xsl:value-of select="concat(' title="',
* translate( translate( translate($title,'<','&lt;'), '>','&gt;'), '"','&quot;' ),
* '"')"/>
*
* rather than this recursive loop but translate only does single-string replacement - ie
* the above code just replaces ",<,> by &