-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxqdoc-display.xqy
executable file
·1681 lines (1598 loc) · 60.9 KB
/
xqdoc-display.xqy
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
(:
: Copyright (c)2006 Elsevier, Inc.
:
: Licensed under the Apache License, Version 2.0 (the "License");
: you may not use this file except in compliance with the License.
: You may obtain a copy of the License at
:
: http://www.apache.org/licenses/LICENSE-2.0
:
: Unless required by applicable law or agreed to in writing, software
: distributed under the License is distributed on an "AS IS" BASIS,
: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
: See the License for the specific language governing permissions and
: limitations under the License.
:
: The use of the Apache License does not indicate that this project is
: affiliated with the Apache Software Foundation.
:)
(:~
: This module provides the functions that control the Web presentation
: of xqDoc. The logic contained in this module is not specific to any
: XQuery implementation and is written to the Nov 2005 XQuery working
: draft specification.
:
: It should also be noted that these functions not only support the
: real-time presentation of the xqDoc information but are also used
: for the static offline presentation mode as well. The static offline
: presentation mode has advantages because access to a native XML
: database is not needed when viewing the xqDoc information ... it is
: only needed when generating the offline materials.
:
: @author Darin McBeath
: @since June 9, 2006
: @version 1.3
:)
module namespace display="xqdoc/xqdoc-display";
declare namespace xq="http://www.xqdoc.org/1.0";
(:~
: This variable defines the name for the xqDoc collection.
: The xqDoc XML for all modules should be stored into the
: XML database with this collection value.
:)
declare variable $display:XQDOC_COLLECTION as xs:string := "xqdoc";
(:~
: This variable contains the list of URIs for all of the modules
: available to xqDoc for presentation. Each module should be identified by
: a unique URI in the XML databse.
:)
declare variable $display:XQDOC_URIS as xs:string* := for $x in fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc
order by $x/xq:module/xq:uri
return fn:string($x/xq:module/xq:uri);
(:~
: Construct the welcome banner for the xqDoc home page.
:
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic linke for real-time viewing.
: @return HTML.
:)
declare function display:print-intro($local as xs:boolean) as element()+
{
(<h3>Welcome to xqDoc</h3>,
<div class="overview">
<p>This site presents documentation and cross-referencing information for both XQuery library
and main modules that have been converted into xqDoc XML.
Visit <a href="http://www.xqdoc.org">xqdoc.org</a> to find the latest developments for this XQuery
open source tool.</p>
</div>
)
};
(:~
: Construct the welcome banner for the xqDoc module page.
:
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML.
:)
declare function display:print-module-intro($local as xs:boolean) as element()
{
display:build-link("default", $local, (), ())
};
(:~
: Construct the list of modules available to xqDoc for presentation.
: The list of modules is availalbe on the xqDoc home page.
:
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML.
:)
declare function display:print-modules($local as xs:boolean) as element()+
{
(<div class="home">
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:module[@type="library"])) then
(<h4>Library Modules</h4>,
<br/>,<br/>,
for $x in fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/@type="library"]
order by $x/xq:module/xq:uri
return
( display:build-link("get-module",
$local,
(fn:string($x/xq:module/xq:uri)),
display:decode-uri(fn:string($x/xq:module/xq:uri))),
<br/> )
)
else
()
}
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:module[@type="main"])) then
(<h4>Main Modules</h4>,
<br/>,<br/>,
for $x in fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/@type="main"]
let $file-uri := fn:base-uri($x)
order by $file-uri
return
( display:build-link("get-module",
$local,
(fn:string($file-uri)),
display:decode-uri(xs:string($file-uri))),
<br/> )
)
else
()
}
</div>)
};
declare function display:get-module-document($uri as xs:string) as element()
{
(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri], fn:doc($uri)/xq:xqdoc)[1]
};
(:~
: The controller for constructing the xqDoc HTML information for
: the specified module. The following information for
: each module will be generated.
: <ul>
: <li> Module introductory information</li>
: <li> Global variables declared in this module</li>
: <li> Modules imported by this module</li>
: <li> Summary information for each function defined in the module</li>
: <li> Detailed information for each function defined in the module</li>
: </ul>
:
: @param $uri the URI for the module
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML.
:)
declare function display:print-module-control($uri as xs:string, $local as xs:boolean) as item()+
{
( display:print-module($uri, $local),
display:print-variables($uri, $local),
" ",
display:print-imports($uri, $local),
" ",
display:print-method-summary($uri),
" ",
display:print-method-detail($uri, $local),
display:print-footer($uri) )
};
(:~
: Construct the high-level xqDoc HTML for the module.
: This is essentially any introductory xqDoc comments that might
: be associated with the module.
:
: @param $uri the URI for the module
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML.
:)
declare function display:print-module($uri as xs:string, $local as xs:boolean) as element()*
{
let $doc := display:get-module-document($uri)
return
(<h4>Module URI</h4>,
<h1>{ display:decode-uri(xs:string($doc/xq:module/xq:uri)) }</h1>,
if (fn:exists($doc/xq:module/xq:body)) then
display:build-link("get-code",
$local,
$uri,
())
else
(),
if (fn:exists($doc/xq:module/xq:comment/xq:description) or
fn:exists($doc/xq:module/xq:comment/xq:author) or
fn:exists($doc/xq:module/xq:comment/xq:version) or
fn:exists($doc/xq:module/xq:comment/xq:since) or
fn:exists($doc/xq:module/xq:comment/xq:see)) then
(<h4>Module Description</h4>,
display:print-comment($doc/xq:module/xq:comment/xq:description, (), $local),
<ul>
{
(display:print-comment($doc/xq:module/xq:comment/xq:author, "Author:", $local),
display:print-comment($doc/xq:module/xq:comment/xq:version, "Version:", $local),
display:print-comment($doc/xq:module/xq:comment/xq:since, "Since:", $local),
display:print-comment($doc/xq:module/xq:comment/xq:see, "See:", $local))
}
</ul>)
else
()
)
};
(:~
: Construct the high-level xqDoc HTML for any global variables
: declared in the module. In addition, cross-reference
: links will be included for the following:
: <ul>
: <li>Functions (contained in this module) that <i>use</i> this variable</li>
: <li>Functions (not contained in this module) that <i>use</i> this variable</li>
: </ul>
: @param $uri the URI for the module
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML.
:)
declare function display:print-variables($uri as xs:string, $local as xs:boolean) as element()*
{
let $doc := display:get-module-document($uri)
return
if (fn:exists($doc/xq:variables/xq:variable)) then
(<h4>Variables</h4>,
<div id="variables">
{
for $v in $doc/xq:variables/xq:variable
return
<div>
<a name="{ fn:concat("$", xs:string($v/xq:uri)) }"/>
<ul class="method">
<li class="left">{ fn:concat("$", xs:string($v/xq:uri)) }</li>
<li class="right">{ $v/xq:comment/xq:description/node() }</li>
</ul>
<ul>
{ display:print-comment($v/xq:comment/xq:since, "Since:", $local) }
{ display:print-comment($v/xq:comment/xq:see, "See:", $local) }
</ul>
{ display:print-internal-variable-references($v, $local) }
{ display:print-external-variable-references($v, $local) }
</div>
}
</div>)
else
()
};
(:~
: Construct the high-level xqDoc HTML for any modules
: imported by the module.
:
: @param $uri the URI for the module
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML.
:)
declare function display:print-imports($uri as xs:string, $local as xs:boolean) as element()*
{
let $doc := display:get-module-document($uri)
return
if (fn:exists($doc/xq:imports/xq:import)) then
(<h4>Imported Modules</h4>,
<div id="imports">
{
for $v in $doc/xq:imports/xq:import
return
<div>
<ul class="method">
<li class="left">
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:module[xq:uri = $v/xq:uri])) then
display:build-link("get-module",
$local,
display:module-uri(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:module[xq:uri = $v/xq:uri]),
display:decode-uri(xs:string($v/xq:uri)))
else
display:decode-uri(xs:string($v/xq:uri))
}
</li>
<li class="right"> {$v/xq:comment/xq:description/node() }</li>
</ul>
<ul>
{ display:print-comment($v/xq:comment/xq:since, "Since:", $local) }
{ display:print-comment($v/xq:comment/xq:see, "See:", $local) }
</ul>
</div>
}
</div>)
else
()
};
(:~
: Construct the xqDoc HTML method summary for each function defined
: in the module. The method summary will contain the function
: signature and the first <i>sentence</i> of any xqDoc comments associated
: with the function.
:
: @param $uri the URI for the module
: @return HTML.
:)
declare function display:print-method-summary($uri as xs:string) as element()*
{
let $doc := display:get-module-document($uri)
return
if (fn:exists($doc/xq:functions/xq:function)) then
(<h4>Function Summary</h4>,
<div id="methods">
<a name="methods"/>
{
for $f in $doc/xq:functions/xq:function
order by fn:normalize-space(xs:string($f/xq:name)) ascending
return
<ul class="method">
<li class="left">
<a href="{fn:concat('#', fn:normalize-space(xs:string($f/xq:name)))}">{fn:normalize-space(xs:string($f/xq:name))}</a>
<div class="description">
{
if (fn:exists($f/xq:comment/xq:description)) then
if (fn:substring-before($f/xq:comment/xq:description, ".")) then
fn:concat(fn:substring-before($f/xq:comment/xq:description, "."), ".")
else
xs:string($f/xq:comment/xq:description)
else
()
}
</div>
</li>
<li class="right">
{display:print-signature($f/xq:signature, fn:true())}
</li>
</ul>
}
</div>)
else
()
};
(:~
: Construct the xqDoc HTML method detail for each function defined
: in the module. The method detail will contain the function
: signature and all xqDoc comments associated with the function. In
: addition, cross-reference links will be included for the following:
: <ul>
: <li>Functions (contained in this module) that <i>are used</i> by this function</li>
: <li>Functions (not contained in this module) that <i>are used</i> by this function</li>
: <li>Functions (contained in this module) that <i>use</i> this function</li>
: <li>Functions (not contained in this module) that <i>use</i> this function</li>
: <li>Variables (contained in this module) that <i>are used</i> by this function</li>
: <li>Variables (not contained in this module) that <i>are used</i> by this function</li>
: </ul>
:
: @param $uri the URI for the module
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML.
:)
declare function display:print-method-detail($uri as xs:string, $local as xs:boolean) as item()*
{
let $doc := display:get-module-document($uri)
return
if (fn:exists($doc/xq:functions/xq:function)) then
(<h4>Function Detail</h4>,
<div id="methoddetail">
{
for $f in $doc/xq:functions/xq:function
order by fn:normalize-space(xs:string($f/xq:name)) ascending
return
(<div id="{fn:normalize-space(xs:string($f/xq:name))}" class="methoddetail">
<h5><a name="{fn:normalize-space(xs:string($f/xq:name))}"/>{fn:normalize-space(xs:string($f/xq:name))}</h5>
<ul class="method">
<li class="left">
{
if (fn:exists($f/xq:body)) then
display:build-link("get-code",
$local,
($uri,fn:normalize-space(xs:string($f/xq:name))),
fn:normalize-space(xs:string($f/xq:name)))
else
()
}
</li>
<li class="right">
{ display:print-signature($f/xq:signature, fn:false()) }
</li>
</ul>
{display:print-detail-comment($f/xq:comment/xq:description, (), $local)}
<ul>
{
(display:print-detail-comment($f/xq:comment/xq:param, "Parameters:", $local),
display:print-detail-comment($f/xq:comment/xq:return, "Return:", $local),
display:print-detail-comment($f/xq:comment/xq:error, "Errors:", $local),
display:print-detail-comment($f/xq:comment/xq:since, "Since:", $local),
display:print-detail-comment($f/xq:comment/xq:see, "See:", $local),
display:print-detail-comment($f/xq:comment/xq:deprecated, "Deprecated:", $local) )
}
</ul>
{
display:print-external-functions-invoked($f, $local),
display:print-external-functions-invoked-by($f, $local),
display:print-internal-functions-invoked($f, $local),
display:print-internal-functions-invoked-by($f, $local),
display:print-internal-variables-referenced($f, $local),
display:print-external-variables-referenced($f, $local)
}
</div>, " ")
}
</div>, " ")
else
()
};
(:~
: Construct the xqDoc HTML for the function signature.
:
: @param $sigs the signatures associated with the current function. Although only one
: signature is allowed for user-defined functions, more than one signature
: is required to support other 'modules' such as XPath F & O.
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return String containing the marked up function signature.
:)
declare function display:print-signature($sigs as xs:string*, $local as xs:boolean) as item()*
{
for $sig at $cnt in $sigs
return
(let $params := fn:substring-after($sig, "(")
let $tokens := fn:tokenize($params, ",")
let $count := fn:count($tokens)
return
(if ($cnt > 1) then
("OR", <br/>,<br/>)
else
(),
for $token at $index in $tokens
return
(if ($index = 1) then
xs:string("(")
else
(),
if ($index = 1) then
fn:normalize-space($token)
else
(" ", fn:normalize-space($token)),
if ($index < $count) then
xs:string(",")
else
(),
<br/>)),
<br/>)
};
(:~
: Construct the xqDoc HTML for the specified xqDoc comment. The following
: xqDoc comment values are supported.
: <ul>
: <li>author</li>
: <li>version</li>
: <li>param</li>
: <li>return</li>
: <li>error</li>
: <li>deprecated</li>
: <li>see</li>
: <li>since</li>
: <li><i>empty</i> which indicates a <i>description</i></li>
: </ul>
:
: @param $comment the xqDoc comment element associated with a function
: @param $name the xqDoc comment name to process (i.e. author, version, etc.)
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-comment($comment as element()*, $name as xs:string?, $local as xs:boolean) as element()*
{
if (fn:exists($comment)) then
for $i in $comment
return
if (fn:not(fn:exists($name))) then
<p>{$i/node()}</p>
else if ($name = "See:") then
<li><strong>{fn:concat($name, " ")}</strong>{display:print-comment-see($i, $local)}</li>
else
<li><strong>{fn:concat($name, " ")}</strong>{$i/node()}</li>
else
()
};
(:~
: Construct the <i>detailed</i> xqDoc HTML for the specified xqDoc comment.
: Detailed essentially implies the xqDoc comments for the method detail. The following
: xqDoc comment values are supported.
: <ul>
: <li>author</li>
: <li>version</li>
: <li>param</li>
: <li>return</li>
: <li>error</li>
: <li>deprecated</li>
: <li>see</li>
: <li>since</li>
: <li><i>empty</i> which indicates a <i>description</i></li>
: </ul>
:
: @param $comment the xqDoc comment element associated with a function
: @param $name the xqDoc comment name to process (i.e. author, version, etc.)
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-detail-comment($comment as element()*, $name as xs:string?, $local as xs:boolean) as element()*
{
if (fn:exists($comment)) then
if (fn:exists($name)) then
(<li>{$name}</li>,
<ul>
{
for $i in $comment
return
if ($name = "Parameters:") then
<li>{display:print-comment-param($i)}</li>
else if ($name = "See:") then
<li>{display:print-comment-see($i, $local)}</li>
else
<li>{$i/node()}</li>
}
</ul>)
else
<p>{$comment/node()}</p>
else
()
};
(:~
: Construct the xqDoc HTML for the specified xqDoc <i>param</i> comment element.
:
: @param $entry the xqDoc <i>param</i> comment element associated with a function
: @return HTML
:)
declare function display:print-comment-param($entry as element()) as item()*
{
let $tmp := xs:string(($entry/node())[1])
let $bef := fn:substring-before(fn:normalize-space($tmp), " ")
let $aft := fn:substring-after(fn:normalize-space($tmp), " ")
return
(if (fn:string-length($bef) > 0) then
fn:concat($bef, " - ", $aft)
else
$tmp,
(for $x at $y in $entry/node()
return
if ($y > 1) then
(" ", $x, " ")
else
()),
<br/>)
};
(:~
: Construct the xqDoc HTML for the specified xqDoc <i>see</i> comment element.
: If the comment is a URI that exists for a module contained within
: xqDoc, build a link to this module (and optionally method or variable
: name. If the comment is a 'http://' URL, then build a link to the URL. If the
: comment is simply text, return the text. With version 1.1, it is now also
: possible to specify the visible display name for the link. This is accomplished
: by specifying an option second semi-colon followed by the link name. So, the
: format for the parameter would be as follows:
: <p/>
:
: a mandatory uri (or text) ';' an optional variable or method name ';' an optional link name
:
: @param $entry the xqDoc param comment element associated with a function
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-comment-see($entry as element(), $local as xs:boolean) as item()*
{
let $tmp := fn:normalize-space(xs:string($entry))
let $tokens := fn:tokenize($tmp, ";")
return
if (fn:count($tokens) = 1) then
if (fn:not(fn:contains($tokens,"#")) and fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:module[xq:uri = $tokens])) then
display:build-link("get-module",
$local,
$tokens,
$tmp)
else if (fn:starts-with($tokens, "http")) then
<a href="{$tokens}">{$tokens}</a>
else
$entry/node()
else if (fn:count($tokens) = 2) then
if (fn:not(fn:contains($tokens[1],"#")) and fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $tokens[1]]/xq:functions/xq:function[xq:name = fn:normalize-space($tokens[2])])) then
display:build-link("get-module",
$local,
$tokens,
$tmp)
else
$entry/node()
else if (fn:count($tokens) = 3) then
if (fn:string-length($tokens[2]) = 0 and fn:not(fn:contains($tokens[1],"#")) and fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:module[xq:uri = $tokens[1]])) then
display:build-link("get-module",
$local,
$tokens,
$tokens[3])
else if (fn:string-length($tokens[2]) = 0 and fn:starts-with($tokens[1], "http")) then
<a href="{$tokens[1]}">{$tokens[3]}</a>
else if (fn:string-length($tokens[2]) > 0 and fn:not(fn:contains($tokens[1],"#")) and fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $tokens[1]]/xq:functions/xq:function[xq:name = fn:normalize-space($tokens[2])])) then
display:build-link("get-module",
$local,
$tokens,
$tokens[3])
else
$entry/node()
else
$entry/node()
};
(:~
: Construct the information to identify those functions (contained in
: other modules) that are <i>used by</i> the current function. If that
: module exists in xqDoc, construct a link to the module and function.
: If that module does not exist in xqDoc, simply identify the
: module and function name.
:
: @param $function the current function
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-external-functions-invoked($function as element(), $local as xs:boolean) as element()*
{
if (fn:exists($function/xq:invoked[xq:uri != display:module-uri($function)])) then
<div class="methoddetail">
<h6>External Functions that are used by this Function</h6>
<table class="inexternal">
<tr>
<th align="left">Module URI</th>
<th align="left">Function Name</th>
</tr>
{
let $uris := for $x in fn:distinct-values($function/xq:invoked/xq:uri)
where $x != display:module-uri($function)
order by xs:string($x)
return xs:string($x)
for $uri in $uris
let $names := for $y in $function/xq:invoked[xq:uri=$uri]
order by xs:string($y/xq:name)
return xs:string($y/xq:name)
for $name at $i in $names
return
if ($i = 1) then
(<tr><td>{" "}</td><td>{" "}</td></tr>,
<tr>
<td rowspan="{fn:count($names)}">{display:decode-uri($uri)}</td>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, $name),
$name)
}
</td>
else
<td>{$name}</td>
}
</tr>)
else
<tr>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, $name),
$name)
}
</td>
else
<td>{$name}</td>
}
</tr>
}
</table>
</div>
else
()
};
(:~
: Construct the information to identify those functions (contained in
: other modules) that <i>use</i> the current function. If that
: module exists in xqDoc, construct a link to the module and function.
: If that module does not exist in xqDoc, simply identify the
: module and function name.
:
: @param $function the current function
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-external-functions-invoked-by($function as element(), $local as xs:boolean) as element()*
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:functions/xq:function/xq:invoked[display:module-uri(.) != display:module-uri($function) and xq:uri=display:module-uri($function) and xq:name=xs:string($function/xq:name)])) then
<div class="methoddetail">
<h6>External Functions that invoke this Function</h6>
<table class="inexternal">
<tr>
<th align="left">Module URI</th>
<th align="left">Function Name</th>
</tr>
{
let $list := for $x in fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:functions/xq:function/xq:invoked[xq:uri=display:module-uri($function) and xq:name=xs:string($function/xq:name)]
return $x
let $uris := fn:distinct-values(for $y in $list
where display:module-uri($y) != display:module-uri($function)
order by display:module-uri($y)
return
display:module-uri($y))
for $uri in $uris
let $entries := for $entry in $list
where display:module-uri($entry)=$uri
order by $entry/../xq:name
return $entry
for $entry at $i in $entries
return
if ($i = 1) then
(<tr><td>{" "}</td><td>{" "}</td></tr>,
<tr>
<td rowspan="{fn:count($entries)}">{display:decode-uri($uri)}</td>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $entry/../xq:name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, xs:string($entry/../xq:name)),
xs:string($entry/../xq:name))
}
</td>
else
<td>{xs:string($entry/../xq:name)}</td>
}
</tr>)
else
<tr>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $entry/../xq:name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, xs:string($entry/../xq:name)),
xs:string($entry/../xq:name))
}
</td>
else
<td>{xs:string($entry/../xq:name)}</td>
}
</tr>
}
</table>
</div>
else
()
};
(:~
: Construct the information to identify those functions (contained in the module
: for the current function) that are <i>used by</i> the current function.
: Construct a link to the module and function.
:
: @param $function the current function
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-internal-functions-invoked($function as element(), $local as xs:boolean) as element()*
{
if (fn:exists($function/xq:invoked[xq:uri = display:module-uri($function)])) then
<div class="methoddetail">
<h6>Internal Functions used by this Function</h6>
<table class="inexternal">
<tr>
<th align="left">Module URI</th>
<th align="left">Function Name</th>
</tr>
{
let $uris := for $x in fn:distinct-values($function/xq:invoked/xq:uri)
where $x = display:module-uri($function)
order by xs:string($x)
return xs:string($x)
for $uri in $uris
let $names := for $y in $function/xq:invoked[xq:uri=$uri]
order by xs:string($y/xq:name)
return xs:string($y/xq:name)
for $name at $i in $names
return
if ($i = 1) then
(<tr><td>{" "}</td><td>{" "}</td></tr>,
<tr>
<td rowspan="{fn:count($names)}">{display:decode-uri($uri)}</td>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, $name),
$name)
}
</td>
else
<td>{$name}</td>
}
</tr>)
else
<tr>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, $name),
$name)
}
</td>
else
<td>{$name}</td>
}
</tr>
}
</table>
</div>
else
()
};
(:~
: Construct the information to identify those functions (contained in the module
: for the current function) that <i>use</i> the current function.
: Construct a link to the module and function.
:
: @param $function the current function
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-internal-functions-invoked-by($function as element(), $local as xs:boolean) as element()*
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:functions/xq:function/xq:invoked[display:module-uri(.) = display:module-uri($function) and xq:uri=display:module-uri($function) and xq:name=xs:string($function/xq:name)])) then
<div class="methoddetail">
<h6>Internal Functions that invoke this Function</h6>
<table class="inexternal">
<tr>
<th align="left">Module URI</th>
<th align="left">Function Name</th>
</tr>
{
let $list := for $x in fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:functions/xq:function/xq:invoked[xq:uri=display:module-uri($function) and xq:name=xs:string($function/xq:name)]
return $x
let $uris := fn:distinct-values(for $y in $list
where display:module-uri($y) = display:module-uri($function)
order by display:module-uri($y)
return
display:module-uri($y))
for $uri in $uris
let $entries := for $entry in $list
where display:module-uri($entry)=$uri
order by $entry/../xq:name
return $entry
for $entry at $i in $entries
return
if ($i = 1) then
(<tr><td>{" "}</td><td>{" "}</td></tr>,
<tr>
<td rowspan="{fn:count($entries)}">{display:decode-uri($uri)}</td>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $entry/../xq:name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, xs:string($entry/../xq:name)),
xs:string($entry/../xq:name))
}
</td>
else
<td>{xs:string($entry/../xq:name)}</td>
}
</tr>)
else
<tr>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $entry/../xq:name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, xs:string($entry/../xq:name)),
xs:string($entry/../xq:name))
}
</td>
else
<td>{xs:string($entry/../xq:name)}</td>
}
</tr>
}
</table>
</div>
else
()
};
(:~
: Construct the information to identify those functions (defined in other modules
: from the current variable) that <i>used</i> the current variable. If that
: module exists in xqDoc, construct a link to the module and function.
: If that module does not exist in xqDoc, simply identify the
: module and function name.
:
: @param $variable the current variable
: @param $local indicates whether to build static HTML link for offline
: viewing or dynamic links for real-time viewing.
: @return HTML
:)
declare function display:print-external-variable-references($variable as element(), $local as xs:boolean) as element()*
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:functions/xq:function/xq:ref-variable[display:module-uri(.) != display:module-uri($variable) and xq:uri=display:module-uri($variable) and xq:name=xs:string($variable/xq:uri)])) then
<div class="methoddetail">
<h6>External Functions that reference this Variable</h6>
<table class="inexternal">
<tr>
<th align="left">Module URI</th>
<th align="left">Function Name</th>
</tr>
{
let $list := for $x in fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc/xq:functions/xq:function/xq:ref-variable[xq:uri=display:module-uri($variable) and xq:name=xs:string($variable/xq:uri)]
return $x
let $uris := fn:distinct-values(for $y in $list
where display:module-uri($y) != display:module-uri($variable)
order by display:module-uri($y)
return
display:module-uri($y))
for $uri in $uris
let $entries := for $entry in $list
where display:module-uri($entry)=$uri
order by $entry/../xq:name
return $entry
for $entry at $i in $entries
return
if ($i = 1) then
(<tr><td>{" "}</td><td>{" "}</td></tr>,
<tr>
<td rowspan="{fn:count($entries)}">{display:decode-uri($uri)}</td>
{
if (fn:exists(fn:collection($display:XQDOC_COLLECTION)/xq:xqdoc[xq:module/xq:uri = $uri]/xq:functions/xq:function[xq:name = $entry/../xq:name])) then
<td>
{
display:build-link("get-module",
$local,
($uri, xs:string($entry/../xq:name)),