-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.xsl
719 lines (628 loc) · 24.2 KB
/
common.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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet>
<!--*
* Templates that are used by both the ahelp and generic code.
* The ahelp code should be re-written so that they use the
* same set up as everything else, but doing this incrementally,
* and very slowly.
*
* Requires:
* sourcedir - "global" parameter used by add-disclaimer
* gives location of sourcedir (eg /data/da/Docs/chartweb/navbar)
* pagename - "global" parameter used by add-disclaimer
*
*-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:func="http://exslt.org/functions"
xmlns:djb="http://hea-www.harvard.edu/~dburke/xsl/"
xmlns:extfuncs="http://hea-www.harvard.edu/~dburke/xsl/extfuncs"
extension-element-prefixes="date func djb extfuncs">
<!--* Change this if the filename changes *-->
<xsl:variable name="hack-import-common" select="extfuncs:register-import-dependency('common.xsl')"/>
<!--*
* add "do not edit this file" comment
* - uses contents of variable $sourcedir to indicate the
* directory containing the source file
*-->
<xsl:template name="add-disclaimer">
<xsl:call-template name="newline"/>
<xsl:call-template name="newline"/>
<xsl:comment> THIS FILE IS CREATED AUTOMATICALLY - DO NOT EDIT MANUALLY </xsl:comment>
<xsl:call-template name="newline"/>
<xsl:comment> SEE: <xsl:value-of select="$sourcedir"/><xsl:value-of select="$pagename"/>.xml </xsl:comment>
<xsl:call-template name="newline"/>
<xsl:call-template name="newline"/>
</xsl:template> <!--* name= add-disclaimer *-->
<!--*
* check that a parameter is not empty, exiting if it is.
*
* Parameters:
* name - string, required
* name of parameter
*
* value - string, required
* input value of parameter
*
* template - string, required
* name of template
*
*-->
<xsl:template name="check-nonempty-param">
<xsl:param name="name"/>
<xsl:param name="value"/>
<xsl:param name="template"/>
<xsl:if test="$value = ''">
<xsl:message terminate="yes">
Error: <xsl:value-of select="$template"/> called without a <xsl:value-of select="$name"/> parameter
</xsl:message>
</xsl:if>
</xsl:template> <!--* name=check-nonempty-param *-->
<!--*
* SAO/SI mandated header items and attempts to stop
* cross-frame scripting attacks, taken from Gary Galstian
* and http://securestate.blogspot.com/2010/08/xfs-101-cross-frame-scripting-explained.html
* in particular the presentation at
* https://www.owasp.org/images/0/0e/OWASP_AppSec_Research_2010_Busting_Frame_Busting_by_Rydstedt.pdf
*
* Similar information is at http://javascript.info/tutorial/clickjacking
* which seems to suggest the X-Frames-Options should be added by the web server
* rather than as a meta tag. Also, we place the javascript within the head
* block out of convenience (not having to add info to too many places)
* but should it be in the body (as this page suggests); this just affects
* the download/rendering speed of the page as far as I can tell. For
* now leave as is.
*
* I have taken out the X-Frame-Options line with the change to HTML5
* as the W3C validator is complaining vociferously about it.
*
* Also add in the favicon here to make things simpler,
* if not cleaner/semantically sensible.
*
* Uses:
* $favicon
* $lastmodiso
* $site
* $desc
* info/metalist
*-->
<xsl:template name="add-sao-metadata">
<xsl:param name="title"/>
<!-- for now relax this, as seeing odd behavior in notebook.xsl
<xsl:if test="not(boolean($title))">
<xsl:message terminate="yes">
Internal Error: add-sao-metadata called but title parameter not set.
</xsl:message>
</xsl:if>
-->
<xsl:if test="$favicon != ''">
<link rel="icon" href="{$favicon}"/>
</xsl:if>
<xsl:if test="boolean($title)">
<meta name="title"><xsl:attribute name="content"><xsl:value-of select="$title"/></xsl:attribute></meta>
</xsl:if>
<meta name="creator" content="SAO-HEA"/>
<!-- a language tag on the html element is now used
<meta http-equiv="content-language" content="en-US"/>
-->
<xsl:if test="$lastmodiso != ''">
<meta name="date" content="{$lastmodiso}"/>
</xsl:if>
<!--*
* TODO: could add in tags/logic to set these to something more specific
*
* -->
<xsl:variable name="desc"><xsl:choose>
<xsl:when test="$site = 'ciao'">The CIAO software package for analyzing data from X-ray telescopes, including the Chandra X-ray telescope.</xsl:when>
<xsl:when test="$site = 'sherpa'">The Sherpa package for fitting and modeling data (part of CIAO).</xsl:when>
<xsl:when test="$site = 'csc'">The Chandra Source Catalog</xsl:when>
<xsl:when test="$site = 'iris'">IRIS - the VAO Spectral Energy Distribution Analysis Tool</xsl:when>
<xsl:otherwise>Information about the Chandra X-ray Telescope for Astronomers.</xsl:otherwise>
</xsl:choose></xsl:variable>
<!--* Fall backs, for the common case where pages do not have specific information *-->
<xsl:if test="not(boolean(info/metalist/meta[@name='subject']))">
<meta name="subject" content="{$desc}"/>
</xsl:if>
<xsl:if test="not(boolean(info/metalist/meta[@name='description']))">
<meta name="description" content="{$desc}"/>
</xsl:if>
<meta name="keywords" content="SI,Smithsonian,Smithsonian Institute"/>
<meta name="keywords" content="CfA,SAO,Harvard-Smithsonian,Center for Astrophysics"/>
<meta name="keywords" content="HEA,HEAD,High Energy Astrophysics Division"/>
<!--* cross-frame scripting 'protection' *-->
<!--
<xsl:comment>Frame busting from http://securestate.blogspot.com/2010/08/xfs-101-cross-frame-scripting-explained.html</xsl:comment>
<xsl:text>
</xsl:text>
<meta http-equiv="X-Frame-Options" content="Deny"/>
-->
<style>html { display: none; }</style>
<script>
if (self == top) {
document.documentElement.style.display = 'block';
} else {
top.location = self.location;
}
</script>
<!--// also apply 'no-web-index' tag to prevent web indexing if invoked //-->
<xsl:call-template name="add-noindex"/>
</xsl:template> <!--* name=add-sao-metadata *-->
<!--*
* prevent indexing by web search engines with a "no-web-index"
* tag in an XML file's "info" block
*
-->
<xsl:template name="add-noindex">
<xsl:choose>
<xsl:when test="info/no-web-index">
<meta name="robots" content="noindex,nofollow"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--*
* add a ssi include statement to the output, surrounded by new lines
* (because we are having issues with the register CGI stuff
* and I'm hoping that the carriage returns will improve
* things; it also lets us track the depency information)
*
* Parameters:
* file - string, required
* the file to include
*
*-->
<xsl:template name="add-ssi-include">
<xsl:param name='file' select="''"/>
<xsl:call-template name="check-nonempty-param">
<xsl:with-param name="name" select="'file'"/>
<xsl:with-param name="value" select="$file"/>
<xsl:with-param name="template" select="'add-ssi-include'"/>
</xsl:call-template>
<xsl:variable name="hack-register-ssi"
select="extfuncs:register-ssi-file($file)"/>
<xsl:call-template name="newline"/>
<xsl:comment>#include virtual="<xsl:value-of select="$file"/>"</xsl:comment>
<xsl:call-template name="newline"/>
</xsl:template> <!--* name=add-ssi *-->
<!--*
* Add a site-specific include file, specialised for
* iCXC and IRIS sites, others use /incl/[type].html.
*
* Parameters:
* type - string, required
* gives the filename (without trailing .html);
* should also be vao[type].html and cxc[type].html
* variants.
*-->
<xsl:template name="add-site-include">
<xsl:param name="type" select="''"/>
<xsl:call-template name="check-nonempty-param">
<xsl:with-param name="name" select="'type'"/>
<xsl:with-param name="value" select="$type"/>
<xsl:with-param name="template" select="'add-site-include'"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="$site='icxc'">
<xsl:call-template name="add-ssi-include">
<xsl:with-param name="file" select="concat('/incl/', $type, '.html')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$site='iris'">
<xsl:call-template name="add-ssi-include">
<xsl:with-param name="file" select="concat('/iris/vao', $type, '.html')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="add-ssi-include">
<xsl:with-param name="file" select="concat('/incl/cxc', $type, '.html')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template> <!--* name=add-site-include *-->
<!--*
* Add the last-modified bar.
*
* Parameters:
* lastmodvalue - string, optional; if not given
* (or empty), use the global $lastmod parameter
*-->
<xsl:template name="add-lastmodbar">
<xsl:param name="lastmodvalue" select="''"/>
<div class="lastmodbar">Last modified: <xsl:choose>
<xsl:when test="$lastmodvalue = ''"><xsl:value-of select="$lastmod"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$lastmodvalue"/></xsl:otherwise>
</xsl:choose></div>
</xsl:template> <!--* name=add-lastmodbar *-->
<!--*
* Add the URL bar (only shown for hardcopy outputs)
*
* Parameters:
* uses the global $url parameter
*-->
<xsl:template name="add-urlbar">
<xsl:if test="$url != ''">
<!--* this is a safety check for now *-->
<br class="hideme"/>
<div class="urlbar">URL: <xsl:value-of select="$url"/></div>
</xsl:if>
</xsl:template> <!--* name=add-urlbar *-->
<!--*
* add the standard header, specialized for
* iCXC and IRIS sites, others use /incl/cxcheader.html.
*
* Parameters:
* lastmodvalue - string, optional; if not given
* (or empty), use the global $lastmod parameter
*
* with-navbar - 1, optional
* if given it is expected to be 1, and says that
* the page contains a navbar element (this should
* only be used for situations like the ahelp
* pages where this can not be determined by the
* template itself), or 0 to turn off the navbar,
* which is useful for multi-page templates like the
* FAQ where the index has a navbar but the individual
* pages do not.
*
* Also depends on the package-wide params/variables:
* $site, $type, $updateby, $url [kind of]
*
* For now we only add a "URL:" bar if the global $url
* variable is not ''. We need to sort this out so that we
* can have one for all pages.
*
*-->
<xsl:template name="add-header">
<xsl:param name="lastmodvalue" select="''"/>
<xsl:param name="with-navbar" select="''"/>
<xsl:if test="$lastmodvalue = '' and $lastmod = ''">
<xsl:message terminate="yes">
ERROR: add-header has empty lastmodvalue and lastmod parameters
</xsl:message>
</xsl:if>
<!-- It would be nice if the metadata for all pages was the same;
for instance threadindex pages have a top-level navbar tag
rather than within an info section. -->
<xsl:variable name="has-navbar"
select="$with-navbar != 0 and (boolean(//info/navbar) or boolean (//navbar) or $with-navbar = 1)"/>
<header>
<nav>
<!-- hopefully the site include works well within nav -->
<xsl:call-template name="add-site-include">
<xsl:with-param name="type" select="'header'"/>
</xsl:call-template>
</nav>
<!--* we break up into lots of different sections to try and make lynx happier *-->
<!--*
* this is only going to be picked up by user agents that do not process
* stylesheets - as long as the stylesheet has a rule
* .hideme { display: none; }
* so it's a good way of getting to lynx users
*-->
<xsl:if test="$has-navbar">
<div class="hideme">
<a href="#navtext" accesskey="s"
title="Skip to the navigation links">Skip to the navigation links</a>
</div>
</xsl:if>
<!-- *
* Really this should be called topbar but to avoid
* renaming stylesheets, use the ugly name of topbarcontainer,
* and add in an extra class, withnavbar, if a navbar is
* to be displayed on the page (used for styling).
*-->
<xsl:variable name="classes">
<xsl:text>topbarcontainer</xsl:text>
<xsl:if test="$has-navbar"><xsl:text> withnavbar</xsl:text></xsl:if>
</xsl:variable>
<div class="{$classes}">
<xsl:if test="$site != 'icxc'">
<div class="topbar">
<xsl:call-template name="add-search-ssi"/>
</div>
</xsl:if>
<div class="topbar">
<xsl:call-template name="add-lastmodbar">
<xsl:with-param name="lastmodvalue" select="$lastmodvalue"/>
</xsl:call-template>
<xsl:call-template name="add-urlbar"/>
</div>
</div>
</header>
</xsl:template> <!--* name=add-header *-->
<!--*
* add the standard footer, specialized for
* iCXC and IRIS sites, others use /incl/cxcfooter.html.
*
* Parameters:
* lastmodvalue - string, optional; if not given
* (or empty), use the global $lastmod parameter
*
* Also depends on the package-wide params/variables:
* $site, $type
*
*-->
<xsl:template name="add-footer">
<xsl:param name="lastmodvalue" select="''"/>
<xsl:param name="with-navbar" select="''"/>
<xsl:if test="$lastmodvalue = '' and $lastmod = ''">
<xsl:message terminate="yes">
ERROR: add-footer has empty lastmodvalue and lastmod parameters
</xsl:message>
</xsl:if>
<!-- It would be nice if the metadata for all pages was the same;
for instance threadindex pages have a top-level navbar tag
rather than within an info section. -->
<xsl:variable name="has-navbar"
select="$with-navbar != 0 and (boolean(//info/navbar) or boolean(//navbar))"/>
<footer>
<div class="bottombar">
<xsl:attribute name="class">bottombar<xsl:if test="$has-navbar"> withnavbar</xsl:if></xsl:attribute>
<xsl:call-template name="add-lastmodbar">
<xsl:with-param name="lastmodvalue" select="$lastmodvalue"/>
</xsl:call-template>
</div>
<xsl:if test="($site = 'ciao' or $site = 'sherpa' or $site = 'chart' or $site = 'obsvis' or $site = 'iris' or $site = 'csc') and $type = 'live'">
<xsl:call-template name="add-ssi-include">
<xsl:with-param name="file" select="$googlessi"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="add-site-include">
<xsl:with-param name="type" select="'footer'"/>
</xsl:call-template>
</footer>
</xsl:template> <!--* name=add-footer *-->
<!--*
* add the necessary SSI to get the search bar
*-->
<xsl:template name="add-search-ssi">
<xsl:call-template name="add-ssi-include">
<xsl:with-param name="file" select="$searchssi"/>
</xsl:call-template>
</xsl:template> <!--* add-search-ssi *-->
<!--*
* The "standard" body for a page where there's no
* navigation bar. Breadcrumbs are added if the
* //info/breadcrumbs exists.
*
* Any attributes of the parent element are added to the
* body tag: this is a hacky way to support setting
* on* attributes. *THIS LEADS TO SURPRISING ATTRIBUTES *
*
*-->
<xsl:template name="add-body-nonavbar">
<xsl:param name="contents" select="''"/>
<xsl:param name="breadcrumbs" select="boolean(//info/breadcrumbs)"/>
<!-- pass through to add-breadcrumbs -->
<xsl:param name="location" select="$url"/>
<xsl:param name="ldepth" select="$depth"/>
<xsl:if test="$contents = ''">
<xsl:message terminate="yes">
ERROR: add-body-nonavbar called with empty contents parameter!
</xsl:message>
</xsl:if>
<body class="nonavbar">
<!--*
* copy the attributes of the text node into the body element
* - ideally we'd just select the known supported values,
* but that's hard to set up
-->
<xsl:copy-of select="@*[name() != 'name']"/>
<xsl:call-template name="add-disclaimer"/>
<xsl:call-template name="add-header">
<xsl:with-param name="with-navbar" select="0"/>
</xsl:call-template>
<main id="content">
<xsl:if test="$breadcrumbs">
<xsl:call-template name="add-breadcrumbs">
<xsl:with-param name="location" select="$location"/>
<xsl:with-param name="ldepth" select="$ldepth"/>
</xsl:call-template>
</xsl:if>
<div class="wrap">
<xsl:call-template name="add-sitewide-banner"/>
<xsl:copy-of select="$contents"/>
</div>
<xsl:if test="$breadcrumbs">
<xsl:call-template name="add-breadcrumbs">
<xsl:with-param name="pos" select="'bottom'"/>
<xsl:with-param name="location" select="$location"/>
<xsl:with-param name="ldepth" select="$ldepth"/>
</xsl:call-template>
</xsl:if>
</main>
<xsl:call-template name="add-footer">
<xsl:with-param name="with-navbar" select="0"/>
</xsl:call-template>
</body>
</xsl:template> <!--* add-body-nonavbar *-->
<!--*
* The "standard" body for a page where there is a
* navigation bar. Breadcrumbs are added if the
* //info/breadcrumbs exists.
*
* Any attributes of the parent element are added to the
* body tag: this is a hacky way to support setting
* on* attributes. *THIS LEADS TO SURPRISING ATTRIBUTES *
*
*-->
<xsl:template name="add-body-withnavbar">
<xsl:param name="contents" select="''"/>
<xsl:param name="navbar" select="''"/>
<xsl:param name="breadcrumbs" select="boolean(//info/breadcrumbs)"/>
<!-- pass through to add-breadcrumbs -->
<xsl:param name="location" select="$url"/>
<xsl:param name="ldepth" select="$depth"/>
<xsl:if test="$contents = ''">
<xsl:message terminate="yes">
ERROR: add-body-withnavbar called with empty contents parameter!
</xsl:message>
</xsl:if>
<xsl:if test="$navbar = ''">
<xsl:message terminate="yes">
ERROR: add-body-withnavbar called with empty navbar parameter!
</xsl:message>
</xsl:if>
<body class="withnavbar">
<!--*
* copy the attributes of the text node into the body element
* - ideally we'd just select the known supported values,
* but that's hard to set up
-->
<xsl:copy-of select="@*[name() != 'name']"/>
<xsl:call-template name="add-disclaimer"/>
<xsl:call-template name="add-header"/>
<main id="content">
<xsl:if test="$breadcrumbs">
<xsl:call-template name="add-breadcrumbs">
<xsl:with-param name="location" select="$location"/>
<xsl:with-param name="ldepth" select="$ldepth"/>
</xsl:call-template>
</xsl:if>
<div class="wrap">
<xsl:call-template name="add-sitewide-banner"/>
<xsl:copy-of select="$contents"/>
</div>
<xsl:if test="$breadcrumbs">
<xsl:call-template name="add-breadcrumbs">
<xsl:with-param name="pos" select="'bottom'"/>
<xsl:with-param name="location" select="$location"/>
<xsl:with-param name="ldepth" select="$ldepth"/>
</xsl:call-template>
</xsl:if>
</main>
<aside id="navbar">
<div id="navtext" class="wrap">
<xsl:copy-of select="$navbar"/>
</div>
</aside>
<xsl:call-template name="add-footer"/>
</body>
</xsl:template> <!--* add-body-withnavbar *-->
<!--*
* Add the contents of the sitewide banner.
*
* The location of the banner is given by the global parameter
* sitebanner, and the banner is not used if this
* variable is not set (i.e. is the default ""), or
* //info/nobanner exists.
*
* The root node should be xinclude, otherwise it is not
* guaranteed to be processed correctly.
*
* TODO: does this work if we create multiple pages, at different
* depths?
*
*-->
<xsl:template name="add-sitewide-banner">
<xsl:if test="$sitebanner != '' and not(boolean(//info/nobanner))">
<!-- hack to support ahelp files -->
<xsl:variable name="idepth"><xsl:choose>
<xsl:when test="$depth"><xsl:value-of select="$depth"/></xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose></xsl:variable>
<xsl:variable name="filename"><xsl:call-template name="add-path">
<xsl:with-param name="idepth" select="$idepth"/>
</xsl:call-template><xsl:value-of select="$sitebanner"/></xsl:variable>
<xsl:apply-templates select="document(concat($sourcedir,$filename))"
mode="include"/>
</xsl:if>
</xsl:template>
<!-- used by add-sitewide-banner and others -->
<xsl:template match="/" mode="include">
<xsl:apply-templates/>
</xsl:template>
<!-- may also be used by add-sitewide-banner-->
<!--*
* Handle XInclude files when the whole text is included, not
* a fragment. The idea is that the contents are within an
* xinclude tag, so we can just process the contents.
* -->
<xsl:template match="xinclude">
<xsl:apply-templates/>
</xsl:template>
<!--* Was in helper.xsl, but moved over for add-sitewide-banner -->
<!--*
* recursive system to add on the correct number of '../' to the path
* parameter:
* idepth: "depth" of path (1 means at the top level)
* should be an integer >=1
*-->
<xsl:template name="add-path">
<xsl:param name="idepth" select="1"/>
<xsl:param name="path" select="''"/>
<xsl:choose>
<xsl:when test="$idepth='' or $idepth<1">
<!--* safety check *-->
<xsl:message terminate="yes">
ERROR: add-path called with idepth < 1 or undefined (<xsl:value-of select="$idepth"/>)
</xsl:message>
</xsl:when>
<xsl:when test="$idepth=1">
<!--* stop recursion *-->
<xsl:value-of select="$path"/>
</xsl:when>
<xsl:otherwise>
<!--* recurse *-->
<xsl:call-template name="add-path">
<xsl:with-param name="idepth" select="$idepth - 1"/>
<xsl:with-param name="path" select="concat($path,'../')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template> <!--* name=add-path *-->
<!--*
* Add a breadcrumbs element for navigation.
*
* The styling requires that .breadcrumbs is a child of
* #content.
*
* It's the last $depth path elements (give or take 1) that count.
*
* /Experimental/
*-->
<xsl:template name="add-breadcrumbs">
<xsl:param name="pos" select="'top'"/>
<xsl:param name="location" select="$url"/>
<xsl:param name="ldepth" select="$depth"/>
<div class="breadcrumbs breadcrumbs-{$pos}">
<xsl:value-of disable-output-escaping="yes"
select="extfuncs:get-breadcrumbs($location, $ldepth)"/>
</div>
</xsl:template>
<!--*
* With the move to HTML5, there are a number of "presentational" tags
* that the W3C validator does not like.
*
* Try and address these automatically. Go for very simple cases at
* present.
*-->
<xsl:template match="tt[count(@*)=0]">
<span class="tt"><xsl:apply-templates/></span>
</xsl:template>
<!--*
* pass-through handling, needed to support [x]include handling
* above
*-->
<!--*
* handle unknown tags
* - perhaps we should exit with an error when we find an unknown tag?
* - currently the metalist template requires that we copy over unknown data
* any others?
*
* - this causes problems: have removed and handling meta tags
* [by copying over the attributes]
*
*-->
<xsl:template match="@*|node()">
<xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
</xsl:template>
<!--*
* explicitly ignore comments
* - this means that we need explicit markup for SSI's
<xsl:template match="comment()">
<xsl:comment><xsl:value-of select="."/></xsl:comment>
</xsl:template>
*-->
<xsl:template match="comment()"/>
</xsl:stylesheet>