Project

Profile

Help

How to connect?
Download (30.4 KB) Statistics
| Branch: | Tag: | Revision:

he / latest9.9 / hec / saxonc-doc / xsl / jstree.xsl @ 34f79044

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
    xmlns:svg="http://www.w3.org/2000/svg"
5
    xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT"
6
    xmlns:js="http://saxonica.com/ns/globalJS"
7
    xmlns:cat="http://www.saxonica.com/ns/doc/catalog"
8
    xmlns:ch="http://www.saxonica.com/ns/doc/changes"
9
    xmlns:fnd="http://www.saxonica.com/ns/doc/functions"
10
    xmlns:f="urn:viewerapp.function"
11
    exclude-result-prefixes="#all" 
12
    expand-text="yes"
13
    extension-element-prefixes="ixsl"
14
    version="3.0">
15
    
16
    <!-- Stylesheet to generate the Saxon/C documentation viewer app using Saxon-JS in the browser. 
17
        The initial template is named 'main'.
18
        
19
        Note that functions-body.xsl and elements-body.xsl are adapted from the versions for the
20
        main Saxon documentation viewer_app: 
21
            - The versions here are as used for the Saxon-JS documentation.
22
            - e.g. Various simplifications are made to assume all instructions and functions referenced are
23
            those in the ixsl namespace
24
            - But these are not actually currently used in Saxon/C documentation
25
            
26
            - use shared templates in el-fnd-body.xsl for corresponding elements in fnd and el namespaces
27
    -->
28

    
29
    <xsl:import href="body.xsl"/>
30
    <xsl:import href="findtext.xsl"/>
31
    <xsl:import href="app-functions.xsl"/>
32
    <xsl:import href="el-fnd-body.xsl"/><!-- Must be imported before functions-body.xsl and
33
        elements-body.xsl to ensure correct import precedence -->
34
    <xsl:import href="functions-body.xsl"/>
35
    <xsl:import href="elements-body.xsl"/>
36
    <!--<xsl:import href="changes.xsl"/>-->
37
   
38
    <xsl:param name="product" select="'Saxon/C'" as="xs:string"/>
39
    <xsl:param name="SEFbuildDate" select="'2020-08-24'" as="xs:string" static="yes"/>
40
    <xsl:param name="showStatusMessage" select="false()" as="xs:boolean"/>
41

    
42
    <xsl:variable name="location" select="resolve-uri('doc', ixsl:location())"/>
43
    <xsl:variable name="implement-doc" select="concat($location, '/implement.xml')"/>
44
    
45
    <!--<xsl:variable name="docChanges" select="doc(concat($location, '/changes.xml'))"
46
        as="document-node()"/>-->
47

    
48
    <xsl:variable name="navlist" as="node()" select="ixsl:page()/html/body/div/div[@id = 'nav']"/>
49

    
50
    <xsl:template name="main">
51
        <xsl:variable name="catDocName" select="concat($location, '/catalog.xml')"/>
52
        
53
        <xsl:if test="$showStatusMessage">
54
            <xsl:message expand-text="yes">{$SEFbuildDate} {$product} documentation app running with Saxon-JS {ixsl:eval('SaxonJS.getProcessorInfo()["productVersion"]')}</xsl:message>
55
        </xsl:if>
56
        <ixsl:schedule-action document="{$catDocName}">
57
            <xsl:call-template name="list">
58
                <xsl:with-param name="docName" select="$catDocName"/>
59
            </xsl:call-template>
60
        </ixsl:schedule-action>
61
        
62
        <ixsl:schedule-action document="{$implement-doc}">
63
            <!-- This ensures that implement.xml has been loaded, and so future calls to
64
                doc($implement-doc) are fine -->
65
            <xsl:call-template name="get-implement-doc">
66
                <xsl:with-param name="implement-doc" select="$implement-doc"/>
67
            </xsl:call-template>
68
        </ixsl:schedule-action>
69
    </xsl:template>
70
    
71
    <xsl:template name="list"> 
72
        <!-- Called from within ixsl:schedule-action document={$docName} -->
73
        <xsl:param name="docName"/>
74
        <xsl:result-document href="#list" method="ixsl:replace-content">
75
            <xsl:apply-templates
76
                select="doc($docName)/cat:catalog/cat:section"/>
77
        </xsl:result-document>
78
        
79
        <ixsl:schedule-action wait="1">
80
            <xsl:call-template name="init"/>
81
        </ixsl:schedule-action>
82
    </xsl:template>
83
    
84
    <xsl:template name="get-implement-doc">
85
        <xsl:param name="implement-doc"/>
86
        <xsl:sequence select="doc($implement-doc)[current-date() lt xs:date('2000-01-01')]"/>
87
    </xsl:template>
88

    
89
    <xsl:template name="init">
90
        <xsl:call-template name="process-hashchange"/>
91
    </xsl:template>
92

    
93
    <xsl:template match="cat:section">
94
        <li class="closed" id="{@ref}">
95
            <span class="item">
96
                <xsl:value-of select="."/>
97
            </span>
98
        </li>
99
    </xsl:template>
100

    
101

    
102
    <xsl:template match="." mode="ixsl:onhashchange">
103
        <xsl:call-template name="process-hashchange"/>
104
    </xsl:template>
105
    
106
    <!-- Arrow keys for navigation, and return key for search -->
107
    <xsl:template match="." mode="ixsl:onkeydown">
108
        <xsl:variable name="event" select="ixsl:event()"/>
109
        <xsl:variable name="key" select="ixsl:get($event, 'key')" as="xs:string"/>
110
        <xsl:variable name="class"
111
            select="if ($key = ('ArrowLeft', 'Left', 'PageUp')) then 'arrowLeft'
112
            else if ($key = ('ArrowRight', 'Right', 'PageDown')) then 'arrowRight'
113
            else if ($key eq 'Enter') then 'enter' else ()"/>
114
        <xsl:if test="exists($class)">
115
            <!--<xsl:message>keydown <xsl:value-of select="$key"/></xsl:message>-->
116
            <xsl:choose>
117
                <xsl:when test="$class eq 'enter'">
118
                    <xsl:call-template name="run-search"/>
119
                </xsl:when>
120
                <xsl:otherwise>
121
                    <xsl:sequence select="f:navpage($class)"/>
122
                </xsl:otherwise>
123
            </xsl:choose>
124
        </xsl:if>
125
    </xsl:template>
126

    
127
    <xsl:template match="p[@class eq 'arrowNone']" mode="ixsl:onclick">
128
        <xsl:for-each select="$navlist/ul/li">
129
            <ixsl:set-attribute name="class" select="'closed'"/>
130
        </xsl:for-each>
131
    </xsl:template>
132

    
133
    <xsl:template match="span[@data-href]" mode="ixsl:onclick">
134
        <xsl:sequence select="f:anchor-navigation(.)"/>
135
    </xsl:template>
136

    
137
    <xsl:template match="span[@data-href][@class eq 'flink']" mode="ixsl:onmouseover">
138
        <xsl:variable name="docName" select="concat($location, '/ixsl-extension.xml')"/>
139
        <ixsl:schedule-action document="{$docName}">
140
            <xsl:call-template name="show-fn">
141
                <xsl:with-param name="span" select="."/>
142
                <xsl:with-param name="docName" select="$docName"/>
143
            </xsl:call-template>
144
        </ixsl:schedule-action>
145
    </xsl:template>
146

    
147
    <xsl:template name="show-fn">
148
        <!-- Called from within ixsl:schedule-action document={$docName} -->
149
        <xsl:param name="span"/>
150
        <xsl:param name="docName"/>
151
        <xsl:variable name="href" select="$span/@data-href"/>
152
        <xsl:variable name="fn"
153
            select="doc($docName)/article/section[@id='functions']/fnd:function[fnd:name = $href]"/>
154
        <xsl:result-document href="#fn-desc" method="ixsl:replace-content">
155
            <h4>
156
                <xsl:value-of select="concat('ixsl:', $href)"/>
157
            </h4>
158
            <xsl:apply-templates select="$fn/fnd:description|$fn/fnd:signatures"
159
                mode="fn-description"/>
160
        </xsl:result-document>
161
    </xsl:template>
162

    
163
    
164
    <xsl:template name="process-hashchange">
165
        <xsl:variable name="hash-parts" select="tokenize(f:get-hash(),'/')"/>
166
        <xsl:variable name="start" select="$hash-parts[1]"/>
167
        <xsl:variable name="docName"
168
            select="concat($location, '/', $start,'.xml')"/>
169

    
170

    
171
        <ixsl:schedule-action document="{$docName}">
172
            <xsl:call-template name="render-page">
173
                <xsl:with-param name="hash-parts" select="$hash-parts"/>
174
                <xsl:with-param name="docName" select="$docName"/>
175
            </xsl:call-template>
176
        </ixsl:schedule-action>
177
        
178
    </xsl:template>
179

    
180
    <xsl:template name="render-page">
181
        <!-- Called from within ixsl:schedule-action document={$docName} -->
182
        <xsl:param name="docName"/>
183
        <xsl:param name="hash-parts"/>
184
        <xsl:variable name="start" select="$hash-parts[1]"/>
185
        <xsl:variable name="first-item" select="f:get-first-item($start)" as="node()?"/> 
186
        <!-- $first-item is the li node of the navlist with the @id $start -->
187
        <xsl:variable name="doc" select="if (doc-available($docName)) then doc($docName) else ()"/>
188
        <xsl:choose>
189
            <xsl:when test="exists($doc) and exists($first-item)">
190
                <xsl:call-template name="show-listitems">
191
                    <xsl:with-param name="doc" select="$doc"/>
192
                    <xsl:with-param name="ids" select="$hash-parts"/>
193
                    <xsl:with-param name="index" select="1"/>
194
                    <xsl:with-param name="item" select="$first-item"/>
195
                </xsl:call-template>
196
                <xsl:variable name="count" select="count($hash-parts)"/>
197
                <xsl:variable name="isfunction"
198
                    select="$start eq 'ixsl-extension' and $hash-parts[2] eq 'functions'"
199
                    as="xs:boolean"/>
200
                <xsl:result-document href="#main" method="ixsl:replace-content">
201
                    <!--<xsl:message>replace-content #main: {$hash-parts}, count {$count}</xsl:message>-->
202
                    <xsl:choose>
203
                        <xsl:when test="$isfunction and $count eq 3">
204
                            <xsl:apply-templates mode="f"
205
                                select="$doc//fnd:function[string(fnd:name) eq $hash-parts[3]]"/>
206
                        </xsl:when>
207
                        <!--<xsl:when test="$start eq 'changes' and $count eq 1">
208
                            <xsl:apply-templates select="$doc" mode="changes"/>
209
                        </xsl:when>
210
                        <xsl:when test="$start eq 'changes' and $count eq 2">
211
                            <!-\-<xsl:message>changes <xsl:value-of select="$hash-parts[2]"/></xsl:message>-\->
212
                            <xsl:apply-templates select="$doc" mode="changes">
213
                                <xsl:with-param name="selectedCategory" select="$hash-parts[2]"/>
214
                            </xsl:apply-templates>
215
                        </xsl:when>
216
                        <xsl:when test="$start eq 'changes' and $count eq 3">
217
                            <!-\-<xsl:message>changes <xsl:value-of select="$hash-parts[2]"/> <xsl:value-of select="$hash-parts[3]"/></xsl:message>-\->
218
                            <xsl:apply-templates select="$doc" mode="changes">
219
                                <xsl:with-param name="selectedCategory"
220
                                    select="$hash-parts[2][. != '']"/>
221
                                <xsl:with-param name="selectedVersionRange"
222
                                    select="$hash-parts[3][. != '']"/>
223
                            </xsl:apply-templates>
224
                        </xsl:when>-->
225
                        <xsl:when test="$count eq 1">
226
                            <xsl:apply-templates select="$doc" mode="primary"/>
227
                        </xsl:when>
228
                        <xsl:otherwise>
229
                            <xsl:apply-templates select="$doc/*" mode="get-section">
230
                                <xsl:with-param name="ids" select="$hash-parts"/>
231
                                <xsl:with-param name="parent" select="$doc/*"/>
232
                                <xsl:with-param name="index" select="2"/>
233
                            </xsl:apply-templates>
234
                        </xsl:otherwise>
235
                    </xsl:choose>
236
                </xsl:result-document>
237
                
238
                <ixsl:schedule-action wait="1">
239
                    <xsl:call-template name="scrollpage"/>
240
                </ixsl:schedule-action>
241

    
242
                <xsl:result-document href="#trail" method="ixsl:replace-content">
243
                    <xsl:variable name="ul"
244
                        select="ixsl:page()/html/body/div/div[@id = 'header']/ul[@class='trail']"/>
245
                    <xsl:copy-of select="$ul/li[@id eq 'trail1']"/>
246
                    <xsl:copy-of select="$ul/li[@id eq 'trail2']"/>
247
                    <xsl:call-template name="get-trail">
248
                        <xsl:with-param name="ids" select="$hash-parts"/>
249
                        <xsl:with-param name="parent" select="$doc"/>
250
                        <xsl:with-param name="index" select="1"/>
251
                    </xsl:call-template>
252
                </xsl:result-document>
253

    
254
                <ixsl:schedule-action wait="1">
255
                    <xsl:call-template name="highlight-item">
256
                        <xsl:with-param name="parent" select="$navlist"/>
257
                        <xsl:with-param name="ids" select="$hash-parts"/>
258
                        <xsl:with-param name="index" select="1"/>
259
                    </xsl:call-template>
260
                </ixsl:schedule-action>
261
            </xsl:when>
262
            <xsl:otherwise>
263
                <xsl:result-document href="#main" method="ixsl:replace-content">
264
                    <h1>Page Not Found</h1>
265
                    <p>Error in URI hash-path:</p>
266
                    <p><xsl:value-of
267
                            select="if (exists($doc)) then ('List Item ''', $start) else ('Document ''', $docName)"
268
                        />' not found</p>
269
                </xsl:result-document>
270
            </xsl:otherwise>
271
        </xsl:choose>
272
    </xsl:template>
273
    
274
    <xsl:template name="scrollpage">
275
        <ixsl:set-property
276
            object="ixsl:page()/html/body/div[@id = 'wrap']/div[@id = 'main']"
277
            name="scrollTop" select="0"/>
278
    </xsl:template>
279

    
280
    <xsl:template match="section|article" mode="get-section">
281
        <xsl:param name="ids" as="xs:string*"/>
282
        <xsl:param name="parent" as="node()?"/>
283
        <xsl:param name="index" as="xs:integer"/>
284
        <xsl:variable name="sectionEl" select="./(section|article)[@id eq $ids[$index]]"/>
285
        <xsl:choose>
286
            <xsl:when test="empty($sectionEl)">
287
                <p>Error in URI hash-path:</p>
288
                <p>Section '<xsl:value-of select="$ids[$index]"/>' not found in path: <xsl:value-of
289
                        select="$ids" separator="/"/></p>
290
            </xsl:when>
291
            <xsl:when test="$index gt count($ids)"/>
292
            <xsl:when test="$index eq count($ids)">
293
                <xsl:apply-templates select="$sectionEl" mode="primary"/>
294
            </xsl:when>
295
            <xsl:otherwise>
296
                <xsl:apply-templates select="$sectionEl" mode="get-section">
297
                    <xsl:with-param name="ids" select="$ids"/>
298
                    <xsl:with-param name="parent" select="$sectionEl"/>
299
                    <xsl:with-param name="index" select="$index + 1"/>
300
                </xsl:apply-templates>
301
            </xsl:otherwise>
302
        </xsl:choose>
303
    </xsl:template>
304

    
305

    
306
    <xsl:template match="span[@class eq 'item']|li[@class = ('closed','open','empty')]"
307
        mode="ixsl:onclick">
308
        <xsl:apply-templates select="." mode="handle-itemclick"/>
309
    </xsl:template>
310

    
311
    <xsl:template match="*" mode="handle-itemclick">
312
        <xsl:variable name="ids" select="(., ancestor::li)/@id" as="xs:string*"/>
313
        <xsl:variable name="new-hash" select="string-join($ids, '/')"/>
314
        <xsl:variable name="isSpan" select="@class eq 'item'" as="xs:boolean"/>
315
        <!--<xsl:message>new-hash {$new-hash}</xsl:message>-->
316
        <xsl:for-each select="if ($isSpan) then .. else .">
317
            <xsl:choose>
318
                <xsl:when test="@class eq 'open' and not($isSpan)">
319
                    <ixsl:set-attribute name="class" select="'closed'"/>
320
                </xsl:when>
321
                <xsl:otherwise>
322
                    <xsl:sequence select="js:disableScroll()"/>
323
                    <xsl:choose>
324
                        <xsl:when test="f:get-hash() eq $new-hash">
325
                            <xsl:variable name="new-class" select="f:get-open-class(@class)"/>
326
                            <ixsl:set-attribute name="class" select="$new-class"/>
327
                            <xsl:if test="empty(ul)">
328
                                <xsl:call-template name="process-hashchange"/>
329
                            </xsl:if>
330
                        </xsl:when>
331
                        <xsl:otherwise>
332
                            <xsl:sequence select="f:set-hash($new-hash)"/>
333
                        </xsl:otherwise>
334
                    </xsl:choose>
335
                </xsl:otherwise>
336
            </xsl:choose>
337
        </xsl:for-each>
338
    </xsl:template>
339

    
340
    <xsl:template match="li[@class eq 'trail']" mode="ixsl:onclick">
341
        <xsl:sequence select="f:crumb-navigation(.)"/>
342
    </xsl:template>
343

    
344
    <xsl:template match="p[@class = ('arrowLeft','arrowRight')]" mode="ixsl:onclick">
345
        <xsl:sequence select="f:navpage(@class)"/>
346
    </xsl:template>
347

    
348
    <xsl:function name="f:navpage">
349
        <xsl:param name="class"/>
350
        <ixsl:schedule-action wait="16">
351
            <xsl:call-template name="navpage">
352
                <xsl:with-param name="class" select="$class"/>
353
            </xsl:call-template>
354
        </ixsl:schedule-action>
355
    </xsl:function>
356

    
357
    <xsl:template name="navpage">
358
        <xsl:param name="class" as="xs:string"/>
359
        <!--<xsl:message>navpage</xsl:message>-->
360
        <xsl:variable name="ids" select="tokenize(f:get-hash(),'/')"/>
361
        <xsl:variable name="start" select="$ids[1]"/>
362
        <xsl:variable name="push" as="xs:string">
363
            <!--<xsl:choose>-->
364
                <!--<xsl:when test="$start eq 'changes' and count($ids) ge 2">
365
                    <xsl:variable name="next-cat"
366
                        select="$docChanges/ch:changes/ch:categories/ch:cat[@name=$ids[2]]/
367
                        (if ($class eq 'arrowLeft') then preceding-sibling::*[1] else following-sibling::*[1])/@name"/>
368
                    <xsl:sequence
369
                        select="concat('changes/', $next-cat, if (count($ids) eq 2) then () else concat('/', $ids[3]))"
370
                    />
371
                </xsl:when>-->
372
                <!--<xsl:otherwise>-->
373
                    <xsl:variable name="c" as="node()"
374
                        select="f:get-item($ids, f:get-first-item($start), 1)"/>
375
                    <xsl:variable name="new-li"
376
                        select="if ($class eq 'arrowLeft') then
377
                        ($c/preceding::li[1] union $c/parent::ul/parent::li)[last()]
378
                        else ($c/ul/li union $c/following::li)[1]"/>
379

    
380
                    <xsl:sequence select="string-join(($new-li/ancestor::li union $new-li)/@id,'/')"
381
                    />
382
                <!--</xsl:otherwise>-->
383
            <!--</xsl:choose>-->
384
        </xsl:variable>
385

    
386
        <xsl:sequence select="f:set-hash($push)"/>
387
    </xsl:template>
388

    
389
    <xsl:function name="f:get-item" as="node()">
390
        <xsl:param name="ids" as="xs:string*"/>
391
        <xsl:param name="item" as="node()"/>
392
        <xsl:param name="index" as="xs:integer"/>
393
        <xsl:choose>
394
            <xsl:when test="$index eq count($ids)">
395
                <xsl:sequence select="$item"/>
396
            </xsl:when>
397
            <xsl:otherwise>
398
                <xsl:variable name="new-item" select="$item/ul/li[@id eq $ids[$index+1]]"/>
399
                <xsl:sequence select="f:get-item($ids, $new-item, $index + 1)"/>
400
            </xsl:otherwise>
401
        </xsl:choose>
402
    </xsl:function>
403

    
404
    <xsl:function name="f:get-function">
405
        <xsl:param name="prefix" as="xs:string"/>
406
        <xsl:param name="local" as="xs:string"/>
407
        <!-- This function is called from navpage template, when stepping through functions pages, in which case
408
            the document 'saxonc-extension.xml' has certainly already been loaded -->
409
        <xsl:sequence
410
            select="doc(concat($location, '/ixsl-extension.xml'))//fnd:function[fnd:name[. = $local
411
            and 'ixsl' = $prefix]]"
412
        />
413
    </xsl:function>
414

    
415
    <xsl:template name="get-trail">
416
        <xsl:param name="ids" as="xs:string*"/>
417
        <xsl:param name="parent" as="node()?"/>
418
        <xsl:param name="index" as="xs:integer"/>
419
        <xsl:variable name="section" select="$parent/*[@id eq $ids[$index]]"/>
420
        <xsl:variable name="title" select="($section/@title, $section/@id, $ids[$index])[1]"/>
421
        <xsl:choose>
422
            <xsl:when test="$index gt count($ids)"/>
423
            <xsl:when test="$index eq count($ids) and empty($section)">
424
                <!-- $section will be empty when the page is an ixsl-extension function -->
425
                <xsl:variable name="last" select="$ids[$index]"/>
426
                <xsl:variable name="function" select="$parent/fnd:function[fnd:name = $last]"/>
427
                <xsl:variable name="prefix"
428
                    select="f:usual-prefix($function/fnd:name/@namespace)"/>
429
                <xsl:variable name="preName" select="if ($prefix ne '') then concat($prefix,
430
                    ':', $last) else $last"/>
431
                <li idt="{$last}" class="trail">
432
                    <xsl:value-of select="$preName"/>
433
                </li>
434
            </xsl:when>
435
            <xsl:when test="$index eq count($ids)">
436
                <li idt="{$section/@id}" class="trail">
437
                    <xsl:value-of select="$title"/>
438
                </li>
439
            </xsl:when>
440
            <xsl:otherwise>
441
                <li idt="{$section/@id}" class="trail">
442
                    <xsl:value-of select="$title"/> &#x25b7;</li>
443
                <xsl:call-template name="get-trail">
444
                    <xsl:with-param name="ids" select="$ids"/>
445
                    <xsl:with-param name="parent" select="$section"/>
446
                    <xsl:with-param name="index" select="$index + 1"/>
447
                </xsl:call-template>
448
            </xsl:otherwise>
449
        </xsl:choose>
450
    </xsl:template>
451

    
452
    <xsl:template name="show-listitems">
453
        <xsl:param name="doc" as="node()"/>
454
        <xsl:param name="ids"/>
455
        <xsl:param name="index" as="xs:integer"/>
456
        <xsl:param name="item" as="node()?"/>
457
        <xsl:variable name="id" select="$ids[$index]"/>
458

    
459
        <xsl:for-each select="$item">
460
            <ixsl:set-attribute name="class" select="f:get-open-class(@class)"/>
461
            <xsl:choose>
462
                <!--<xsl:when test="$index eq 1 and $item/@id eq 'changes'">
463
                    <xsl:result-document href="?." method="ixsl:replace-content">
464
                        <xsl:call-template name="add-list-changes">
465
                            <xsl:with-param name="top-name" select="span"/>
466
                            <xsl:with-param name="cat-name" select="$ids[2]"/>
467
                        </xsl:call-template>
468
                    </xsl:result-document>
469
                </xsl:when>-->
470
                <xsl:when test="exists(ul)">
471
                    <xsl:if test="$index lt count($ids)">
472
                        <xsl:call-template name="show-listitems">
473
                            <xsl:with-param name="doc" select="$doc/*[@id eq $id]"/>
474
                            <xsl:with-param name="ids" select="$ids"/>
475
                            <xsl:with-param name="index" select="$index + 1"/>
476
                            <xsl:with-param name="item" select="ul/li[@id eq $ids[$index + 1]]"/>
477
                        </xsl:call-template>
478
                    </xsl:if>
479
                </xsl:when>
480
                <xsl:otherwise>
481
                    <xsl:result-document href="?." method="ixsl:append-content">
482
                        <xsl:call-template name="add-list">
483
                            <xsl:with-param name="section" 
484
                                select="$doc/*[@id eq $id]|$doc/fnd:function[string(fnd:name) eq $id]"/>
485
                            <xsl:with-param name="ids" select="$ids"/>
486
                            <xsl:with-param name="index" select="$index"/>
487
                        </xsl:call-template>
488
                    </xsl:result-document>
489
                </xsl:otherwise>
490
            </xsl:choose>
491
        </xsl:for-each>
492
    </xsl:template>
493

    
494
    <xsl:template name="add-list">
495
        <!-- This now works for ixsl-extension/functions too: 
496
            see if test="exists($section/fnd:function)" branch -->
497
        <xsl:param name="section" as="node()"/>
498
        <xsl:param name="ids" as="xs:string*"/>
499
        <xsl:param name="index" as="xs:integer"/>
500
        <!--<xsl:message>CALL TEMPLATE add-list</xsl:message>
501
        <xsl:if test="empty($section)">
502
            <xsl:message>!!!!!!!!!!WARNING section is empty</xsl:message>
503
        </xsl:if>-->
504

    
505
        <xsl:if test="exists($section/(section|j))">
506
            <ul>
507
                <xsl:for-each select="$section/(section|j)">
508
                    <xsl:variable name="onpath" as="xs:boolean*"
509
                        select="$index lt count($ids) and @id eq $ids[$index + 1]"/>
510
                    <xsl:variable name="contains" select="exists(section|j|fnd:function)"/>
511
                    <li id="{@id}">
512
                        <xsl:attribute name="class"
513
                            select="if ($onpath and $contains) then 'open'
514
                            else if ($contains) then 'closed'
515
                                    else 'empty'"/>
516
                        <span class="item">
517
                            <xsl:value-of select="if (@title) then @title else @id"/>
518
                        </span>
519
                        <xsl:if test="$onpath and $contains">
520
                            <xsl:call-template name="add-list">
521
                                <xsl:with-param name="section" select="$section/(section|j)[@id = $ids[$index + 1]]"/>
522
                                <xsl:with-param name="ids" select="$ids"/>
523
                                <xsl:with-param name="index" select="$index + 1"/>
524
                            </xsl:call-template>
525
                        </xsl:if>
526
                    </li>
527
                </xsl:for-each>
528
            </ul>
529
        </xsl:if>
530
        <xsl:if test="exists($section/fnd:function)">
531
            <ul>
532
                <xsl:for-each select="$section/fnd:function">
533
                    <!-- Does not have an @id, use value-of name child -->
534
                    <xsl:variable name="fn-name" select="string(fnd:name)"/>
535
                    <xsl:variable name="onpath" as="xs:boolean*"
536
                        select="$index lt count($ids) and $fn-name eq $ids[$index + 1]"/>
537
                    <xsl:variable name="prefix" select="f:usual-prefix(fnd:name/@namespace)"/>
538
                    <xsl:variable name="preName" select="if ($prefix ne '') then concat($prefix,
539
                        ':', $fn-name) else $fn-name"/>
540
                    <li id="{$fn-name}">
541
                        <xsl:attribute name="class" select="'empty'"/>
542
                        <span class="item">
543
                            <xsl:value-of select="$preName"/>
544
                        </span>
545
                    </li>
546
                    <!-- fnd:function elements do not have section children -->
547
                </xsl:for-each>
548
            </ul>
549
        </xsl:if>
550
    </xsl:template>
551

    
552
    <!--<xsl:template name="add-list-changes">
553
        <xsl:param name="top-name" as="xs:string?"/>
554
        <xsl:param name="cat-name" as="xs:string?"/>
555
        <span class="item">
556
            <xsl:value-of select="$top-name"/>
557
        </span>
558
        <xsl:if test="exists($cat-name)">
559
            <ul>
560
                <xsl:for-each select="$docChanges/ch:changes/ch:categories/ch:cat">
561
                    <li id="{@name}" class="empty">
562
                        <span class="item">
563
                            <xsl:value-of select="@title"/>
564
                        </span>
565
                    </li>
566
                </xsl:for-each>
567
            </ul>
568
        </xsl:if>
569
    </xsl:template>-->
570

    
571
    <xsl:template name="highlight-item">
572
        <xsl:param name="parent" as="node()?"/> <!-- navlist from first call -->
573
        <xsl:param name="ids" as="xs:string*"/>
574
        <xsl:param name="index" as="xs:integer"/>
575
        <xsl:variable name="hitem" select="$parent/ul/li[@id eq $ids[$index]]"/>
576
        <xsl:choose>
577
            <xsl:when test="$index lt count($ids)">
578
                <xsl:call-template name="highlight-item">
579
                    <xsl:with-param name="parent" select="$hitem"/>
580
                    <xsl:with-param name="ids" select="$ids"/>
581
                    <xsl:with-param name="index" select="$index + 1"/>
582
                </xsl:call-template>
583
            </xsl:when>
584
            <xsl:otherwise>
585
                <xsl:for-each select="$hitem/span">
586
                    <xsl:for-each select="js:swapItem(.)">
587
                        <ixsl:set-attribute name="class" select="'item'"/>
588
                    </xsl:for-each>
589
                    <xsl:sequence select="js:enableScroll()"/>
590
                    <ixsl:set-attribute name="class" select="'hot'"/>
591
                </xsl:for-each>
592
                <!--<xsl:message>style.display of div/@class=found {ixsl:style($navlist/../div[@class eq 'found'])?display}</xsl:message>-->
593
                <xsl:if test="ixsl:style(ixsl:page()/html/body/div/div[@class eq 'found'])?display ne 'none'">
594
                    <!--<xsl:sequence select="f:highlight-finds()"/>-->
595
                    <xsl:call-template name="highlighting"/>
596
                </xsl:if>
597
            </xsl:otherwise>
598
        </xsl:choose>
599
    </xsl:template>
600

    
601
    <xsl:function name="f:crumb-navigation">
602
        <xsl:param name="c" as="node()"/>
603
        <xsl:variable name="seq" select="$c/preceding-sibling::*/@idt|$c/@idt" as="xs:string*"/>
604
        <xsl:variable name="new-hash" select="string-join($seq,'/')"/>
605
        <xsl:sequence select="f:set-hash($new-hash)"/>
606
    </xsl:function>
607

    
608
    <xsl:function name="f:anchor-navigation">
609
        <xsl:param name="c" as="node()"/>
610
        <xsl:variable name="href">
611
            <xsl:variable name="ahref"
612
                select="resolve-uri($c/@data-href, concat('http://a.com/', f:get-hash(),'/'))"/>
613
            <xsl:value-of select="substring(string($ahref), 14)"/>
614
        </xsl:variable>
615
        <xsl:sequence select="f:set-hash(translate($href, '#','@'))"/>
616
    </xsl:function>
617

    
618
    <xsl:function name="f:set-hash">
619
        <xsl:param name="hash"/>
620
        <!--<xsl:message>f:set-hash {$hash}</xsl:message>-->
621
        <ixsl:set-property name="location.hash" select="concat('!',$hash)"/>
622
    </xsl:function>
623

    
624
    <xsl:function name="f:get-open-class" as="xs:string">
625
        <xsl:param name="class" as="xs:string"/>
626
        <xsl:sequence select="if ($class eq 'empty') then 'empty' else 'open'"/>
627
    </xsl:function>
628

    
629
    <xsl:function name="f:get-first-item" as="node()?">
630
        <xsl:param name="start"/>
631
        <xsl:sequence select="$navlist/ul/li[@id = $start]"/>
632
    </xsl:function>
633

    
634
    <!-- hash is prefixed with ! as the 'hashbang' SEO measure: eg. http:/a.com#!about/gwt -->
635
    <xsl:function name="f:get-hash">
636
        <xsl:variable name="url" select="ixsl:location()"/>
637
        <!--<xsl:message>current url {$url}</xsl:message>-->
638
        <xsl:variable name="hash"
639
            select="if(contains($url, '%21')) then substring-after($url, '%21') else substring(ixsl:get(ixsl:window() , 'location.hash'),3)"/>
640
        <xsl:sequence select="if (string-length($hash) gt 0) then $hash else ($navlist/ul/li)[1]/@id"/>
641
    </xsl:function>
642

    
643
</xsl:transform>
(9-9/9)