File: page.xsl

package info (click to toggle)
virtuoso-opensource 6.1.4%2Bdfsg1-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 245,116 kB
  • sloc: ansic: 639,631; sql: 439,225; xml: 287,085; java: 61,048; sh: 38,723; cpp: 36,889; cs: 25,240; php: 12,562; yacc: 9,036; lex: 7,149; makefile: 6,093; jsp: 4,447; awk: 1,643; perl: 1,017; ruby: 1,003; python: 329
file content (1546 lines) | stat: -rw-r--r-- 65,168 bytes parent folder | download | duplicates (2)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xhtml" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
  <xsl:include href="page_common.xsl"/>
  <xsl:include href="page_html_common.xsl"/>
  <xsl:template match="tutorial">
    <xsl:text disable-output-escaping="yes"><![CDATA[<?vsp
--
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--
--  Copyright (C) 1998-2006 OpenLink Software
--
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
?>]]></xsl:text>
    <?vsp
      declare _path,_domain varchar;
      _domain := 'http://' || regexp_replace(HTTP_GET_HOST(),':80$','');
      _path := _domain || http_map_get('domain') || '/'; 
    ?>
    <html>
      <head>
        <meta name="DESCRIPTION" content="Virtuoso Developer Tutorial"/>
        <title>
          <xsl:text>Virtuoso Tutorial</xsl:text>
          <xsl:if test="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]/title/@val != ''">
            <xsl:text> - </xsl:text>
            <xsl:value-of select="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]/title/@val"/>
          </xsl:if>
          <xsl:if test="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]//example[$path = @wwwpath]">
            <xsl:text> - </xsl:text>
            <xsl:value-of select="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]//example[$path = @wwwpath]/@id"/>
          </xsl:if>
        </title>
        <xsl:if test="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]/keywords">
          <meta name="KEYWORDS">
            <xsl:attribute name="content">
              <xsl:value-of select="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]/keywords"/>
            </xsl:attribute>
          </meta>
        </xsl:if>
        <link rel="alternate" type="application/rss+xml" title="Virtuoso Screencast Demos" href="http://support.openlinksw.com/viewlets/virtuoso_viewlets_rss.vsp" />
        <link rel="alternate" type="application/rss+xml" title="Virtuoso Tutorials" href="http://demo.openlinksw.com/tutorial/rss.vsp" />
        <link rel="alternate" type="application/rss+xml" title="Virtuoso Product Blog (RSS 2.0)" href="http://www.openlinksw.com/weblogs/virtuoso/gems/rss.xml" />
        <link rel="alternate" type="application/atom+xml" title="Virtuoso Product Blog (Atom)" href="http://www.openlinksw.com/weblogs/virtuoso/gems/atom.xml" />
        <link href="{concat($mount_point,'/tutorial3.css')}" rel="stylesheet" type="text/css"/>
        <link href="{concat($mount_point,'/syntax/SyntaxHighlighter.css')}" rel="stylesheet" type="text/css"/>
        <link rel="meta" type="application/rdf+xml" title="SIOC" href="{concat('<?V _path ?>','sioc.vsp')}" />
      </head>
      <body>
        <table border="0" cellpadding="0" cellspacing="0" id="top">
          <tr>
            <td id="topnav">
              <img src="{concat($mount_point,'/images/vtutorials_thin550.gif')}" alt="Virtuoso Developer Tutorial" width="550" height="75"/>
            </td>
          </tr>
        </table>
        <table border="0" cellpadding="0" cellspacing="0" id="main">
          <tr>
            <td id="left">
              <ul class="lftmenu">
                <li class="lftmenu_title">Tutorial Quick Links</li>
                <li class="lftmenu1">
                  <img src="{concat($mount_point,'/images/vglobe_16.png')}" alt="Virtuoso Start Menu" title="Virtuoso Start Menu" />
                  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                  <a target="_blank" href="/">Virtuoso Start Menu</a>
                </li>
                <li class="lftmenu1">
                  <img src="{concat($mount_point,'/images/nav_arrow1.gif')}" alt="Virtuoso Conductor" title="Virtuoso Conductor" />
                  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                  <a target="_blank" href="/conductor/">Virtuoso Conductor</a>
                </li>
              </ul>
              <ul class="lftmenu">
                <li class="lftmenu_title">Reference</li>
                <li class="lftmenu_info">For a quick look up of any feature, function, or review of language syntax</li>
                <li class="lftmenu1">
                  <img src="{concat($mount_point,'/images/docs_16.png')}" alt="Documentation" title="Documentation" hspace="2"/>
                  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                  <a href="/doc/docs.vsp" target="_empty">Documentation</a>
                </li>
                <li class="lftmenu1">
                  <img src="{concat($mount_point,'/images/nav_arrow1.gif')}" alt="Tutorial Quick Start Guide" title="Tutorial Quick Start Guide" hspace="2"/>
                  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                  <a href="{concat($mount_point,'/guide.vsp')}">Tutorial Quick Start Guide</a>
                </li>
                <li class="lftmenu1">
                  <img src="{concat($mount_point,'/images/docs_16.png')}" alt="Functions Index" title="Functions Index" hspace="2"/>
                  <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
                  <a href="/doc/html/functions.html" target="_empty">Functions Index</a>
                </li>
              </ul>
              <xsl:if test="$path != 'search.vsp'">
                <div class="lftmenu">
                  <div class="lftmenu_title">search</div>
                  <div class="lftmenu1">
                    <form method="get" action="{concat($mount_point,'/search.vsp')}" style="display:inline;">
                      <input type="text" name="q" id="q" value="" size="17"/>
                      <input name="post" value="Go" title="Search" alt="Search" type="submit"/>
                    </form>
                  </div>
                </div>
              </xsl:if>
              <ul class="lftmenu">
                <li class="lftmenu_title">
                  <a href="http://www.openlinksw.com/weblogs/virtuoso/" target="_blank">Virtuoso Blog</a>
                </li>
                <li class="lftmenu_info">Check out the latest technology buzz on the Virtuoso Blog</li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/atom.vsp')}"><img src="{concat($mount_point,'/images/blue-icon-16.gif')}" border="0" alt="ATOM" title="ATOM" hspace="3"/>Atom</a>
                </li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/rss.vsp')}"><img src="{concat($mount_point,'/images/rss-icon-16.gif')}" border="0" alt="RSS" title="RSS" hspace="3"/>RSS</a>
                </li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/rdf.vsp')}"><img src="{concat($mount_point,'/images/rdf-icon-16.gif')}" border="0" alt="RDF" title="RDF" hspace="3"/>RDF</a>
                </li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/ocs.vsp')}"><img src="{concat($mount_point,'/images/blue-icon-16.gif')}" border="0" alt="OCS" title="OCS" hspace="3"/>OCS</a>
                </li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/opml.vsp')}"><img src="{concat($mount_point,'/images/blue-icon-16.gif')}" border="0" alt="OPML" title="OPML" hspace="3"/>OPML</a>
                </li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/xbel.vsp')}"><img src="{concat($mount_point,'/images/blue-icon-16.gif')}" border="0" alt="XBEL" title="XBEL" hspace="3"/>XBEL</a>
                </li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/sioc.vsp')}"><img src="{concat($mount_point,'/images/rdf-icon-16.gif')}" border="0" alt="SIOC(RDF/XML)" title="SIOC(RDF/XML)" hspace="3"/>SIOC(RDF/XML)</a>
                </li>
                <li class="lftmenu1">
                  <a target="_blank" href="{concat($mount_point,'/sioc_ttl.vsp')}"><img src="{concat($mount_point,'/images/rdf-icon-16.gif')}" border="0" alt="SIOC(N3/Turtle)" title="SIOC(N3/Turtle)" hspace="3"/>SIOC(N3/Turtle)</a>
                </li>
              </ul>
              <div class="lftmenu">
                <div class="lftmenu_info">Version: <?V sys_stat ('st_dbms_ver') ?></div>
                <div class="lftmenu_info">Build: <?V sys_stat ('st_build_date') ?></div>
              </div>
              <a target="_blank" href="http://www.openlinksw.com/virtuoso"><img alt="Powered by OpenLink Virtuoso Universal Server" src="{concat($mount_point,'/images/PoweredByVirtuoso.gif')}" border="0" /></a>
            </td>
            <td id="right">
              <div id="navtabs">
                <table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <xsl:apply-templates select="section" mode="nav"/>
                  </tr>
                </table>
                <xsl:if test="section[subsection[@wwwpath = $subsecpath]]/subsection">
                  <table border="0" cellpadding="0" cellspacing="0" id="navtabs2">
                    <tr>
                      <xsl:apply-templates select="section[subsection[@wwwpath = $subsecpath]]/subsection" mode="nav"/>
                    </tr>
                  </table>
                 </xsl:if>
              </div>
              <div id="mainarea">
                <xsl:choose>
                  <xsl:when test="$path = 'search.vsp'">
                    <xsl:call-template name="search_code"/>
                  </xsl:when>
                  <xsl:when test="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]//example[$path = @wwwpath]">
                    <xsl:apply-templates select="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]//example[$path = @wwwpath]" mode="info"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:apply-templates select="section[subsection[@wwwpath = $subsecpath]]/subsection[@wwwpath = $subsecpath]/*"/>
                  </xsl:otherwise>
                </xsl:choose>
              </div>
            </td>
          </tr>
        </table>
        <div class="footer">
          <div id="w3cval">
            <a href="http://validator.w3.org/check?uri=referer">
              <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" />
            </a>
          </div>
          <a target="_blank" href="http://www.openlinksw.com">
            <img src="{concat($mount_point,'/images/web_24.png')}" border="0" alt="OpenLink Home" title="OpenLink Home"/>
            <xsl:text> OpenLink Home</xsl:text>
          </a>
          <xsl:text> | </xsl:text>
          <a target="_blank" href="http://www.openlinksw.com/virtuoso">
            <img src="{concat($mount_point,'/images/web_24.png')}" border="0" alt="Virtuoso Home" title="Virtuoso Home"/>
            <xsl:text> Virtuoso Home</xsl:text>
          </a>
          <xsl:text> | </xsl:text>
          <a target="_blank" href="mailto:support@openlinksw.com">
            <img src="{concat($mount_point,'/images/mail_24.png')}" border="0" alt="Technical Support" title="Technical Support"/>
            <xsl:text> Technical Support</xsl:text>
          </a>
          <xsl:text> | </xsl:text>
          <a target="_blank" href="http://www.openlinksw.com/main/contactu.html">
            <img src="{concat($mount_point,'/images/mail_24.png')}" border="0" alt="Contact Us" title="Contact Us"/>
            <xsl:text> Contact Us</xsl:text>
          </a>
           <p class="copyright">
            <xsl:text disable-output-escaping="yes">Copyright &amp;</xsl:text>
            <xsl:if test="ends-with($path,'.vspx') = 1">amp;</xsl:if>
            <xsl:text>copy; 1999-</xsl:text>
            <?V "LEFT" (datestring (now()), 4)?>
            <xsl:text> OpenLink Software</xsl:text>
          </p>
        </div>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="subsection/title | subsection/keywords"/>

  <xsl:template match="section" mode="nav">
    <td nowrap="nowrap">
      <xsl:choose>
        <xsl:when test="subsection[@wwwpath = $subsecpath]">
          <xsl:attribute name="class">navtab_sel</xsl:attribute>
          <xsl:choose>
            <xsl:when test="ends-with($path,'.vspx') = 1">
              <xsl:value-of select="replace(@Title,'&','&amp;amp;amp;');"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@Title"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="class">navtab_non_sel</xsl:attribute>
          <a href="{concat($mount_point,'/',subsection[1]/@wwwpath,'/')}">
            <xsl:choose>
              <xsl:when test="ends-with($path,'.vspx') = 1">
                <xsl:value-of select="replace(@Title,'&','&amp;amp;amp;');"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="@Title"/>
              </xsl:otherwise>
            </xsl:choose>
          </a>
        </xsl:otherwise>
      </xsl:choose>
    </td>
  </xsl:template>

  <xsl:template match="subsection[@ref]" mode="nav"/>

  <xsl:template match="subsection" mode="nav">
    <td nowrap="nowrap">
      <xsl:choose>
        <xsl:when test="@wwwpath = $subsecpath">
          <xsl:attribute name="class">navtab_sel2</xsl:attribute>
          <a href="{concat($mount_point,'/',@wwwpath,'/')}">
            <xsl:value-of select="@Title"/>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="class">navtab_non_sel2</xsl:attribute>
          <a href="{concat($mount_point,'/',@wwwpath,'/')}">
            <xsl:value-of select="@Title"/>
          </a>
        </xsl:otherwise>
      </xsl:choose>
    </td>
  </xsl:template>

  <xsl:template match="group[group]">
    <h1>
      <xsl:value-of select="@Title"/>
    </h1>
    <div class="tree_list">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template match="group">
    <h2>
      <xsl:value-of select="@Title"/>
    </h2>
    <ul>
      <xsl:apply-templates select="example"/>
    </ul>
  </xsl:template>

  <xsl:template match="example">
    <xsl:if test="init/onlyshow">
      <xsl:text disable-output-escaping="yes"><![CDATA[<?vsp if (sys_stat ('st_build_opsys_id') = ']]></xsl:text>
      <xsl:value-of select="init/onlyshow/@on"/>
      <xsl:text disable-output-escaping="yes"><![CDATA[') { ?>]]></xsl:text>
    </xsl:if>
    <li>
      <xsl:choose>
        <xsl:when test="init/@standalone">
          <a href="{init/@standalone}" target="_blank">
            <xsl:value-of select="refentry/refnamediv/refpurpose"/>
          </a>
        </xsl:when>
        <xsl:otherwise>
      <a href="{concat($mount_point,'/',@wwwpath)}">
        <xsl:value-of select="@id"/>
      </a>
      <xsl:text> </xsl:text>
      <xsl:value-of select="refentry/refnamediv/refpurpose"/>
        </xsl:otherwise>
      </xsl:choose>
    </li>
    <xsl:if test="init/onlyshow">
      <xsl:text disable-output-escaping="yes"><![CDATA[<?vsp } ?>]]></xsl:text>
    </xsl:if>
  </xsl:template>

  <xsl:template match="para">
    <xsl:choose>
      <xsl:when test="local-name(parent::*) = 'listitem'">
        <xsl:apply-templates />
      </xsl:when>
      <xsl:otherwise>
        <p><xsl:apply-templates /></p>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="ulink">
    <a>
      <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
      <xsl:apply-templates/>
    </a>
  </xsl:template>

  <xsl:template match="image">
    <img>
      <xsl:attribute name="src"><xsl:value-of select="@url"/></xsl:attribute>
      <xsl:apply-templates/>
    </img>
  </xsl:template>

  <xsl:template match="programlisting">
    <pre><xsl:value-of select="." /></pre>
  </xsl:template>

  <xsl:template match="itemizedlist">
    <ul>
      <xsl:for-each select="./listitem">
        <li><xsl:apply-templates /></li>
      </xsl:for-each>
    </ul>
  </xsl:template>

  <xsl:template match="orderedlist">
    <ol>
      <xsl:for-each select="./listitem">
        <li><xsl:apply-templates /></li>
      </xsl:for-each>
    </ol>
  </xsl:template>

  <xsl:template match="table | tr | th | td">
    <xsl:element name="{local-name()}">
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="refentry/refsect1/title">
    <h4><xsl:value-of select="."/></h4>
  </xsl:template>

  <xsl:template name="examples_nav">
    <xsl:param name="pos"/>
    <xsl:if test="$pos != ''">
      <a name="{$pos}"/>
    </xsl:if>
    <xsl:variable name="linkend">
      <xsl:if test="$pos != ''">#<xsl:value-of select="$pos"/></xsl:if>
    </xsl:variable>
    <div class="exp_nav">
      <xsl:choose>
        <xsl:when test="@previd">
          <img src="{concat($mount_point,'/images/rewnd_16.png')}" alt="previous example" title="previous example" />
          <xsl:text> </xsl:text>
          <a href="{concat($mount_point,'/',//example[@id = current()/@previd]/@wwwpath),$linkend}">
            <xsl:text>previous example</xsl:text>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <img src="{concat($mount_point,'/images/rewnd_16.png')}" alt="previous example" title="previous example" />
          <xsl:text> </xsl:text>
          <xsl:text>previous example</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:text> | </xsl:text>
        <a href="{concat($mount_point,'/',$subsecpath,'/')}">
          <xsl:text>index</xsl:text>
        </a>
      <xsl:text> | </xsl:text>
      <xsl:choose>
        <xsl:when test="@nextid">
          <a href="{concat($mount_point,'/',//example[@id = current()/@nextid]/@wwwpath),$linkend}">
            <xsl:text>next example</xsl:text>
          </a>
          <xsl:text> </xsl:text>
          <img src="{concat($mount_point,'/images/fastf_16.png')}" alt="next example" title="next example" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>next example</xsl:text>
          <xsl:text> </xsl:text>
          <img src="{concat($mount_point,'/images/fastf_16.png')}" alt="next example" title="next example" />
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>

  <xsl:template match="example" mode="info">
    <script language="JavaScript" type="text/javascript">
      var URL = '<?V http_path() ?>';
    </script>
    <script language="JavaScript" src="{concat($mount_point,'/example.js')}" type="text/javascript"></script>
    <xsl:call-template name="examples_nav"/>
     <div id="ex_navcontainer">
      <ul id="ex_navlist">
        <li><a href="#" id="tab_info" onclick="toggle_tab('info')" class="current">Info</a></li>
        <li><a href="#" id="tab_initial_state" onclick="toggle_tab('initial_state')">Initial State</a></li>
        <li><a href="#" id="tab_view_source" onclick="toggle_tab('view_source')">View Source</a></li>
        <li><a href="#" id="tab_run" onclick="toggle_tab('run')">Run</a></li>
      </ul>
    </div>
    <div id="info">
      <h1><xsl:value-of select="refentry/refmeta/refentrytitle"/></h1>
      <h2>
        <xsl:value-of select="refentry/@id"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="refentry/refnamediv/refname"/>
      </h2>
      <h3><xsl:value-of select="refentry/refnamediv/refpurpose"/></h3>
      <xsl:for-each select="refentry/refsect1">
        <xsl:apply-templates />
      </xsl:for-each>
      <xsl:choose>
        <xsl:when test="ends-with(@wwwpath,'.vspx') = 1">
          <v:page name="{@id}" xmlns:v="http://www.openlinksw.com/vspx/"  doctype="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <v:login name="tut_login" realm="vspx" mode="url" user-password="demo_user_password" user-password-check="demo_user_password_check" xmlns:v="http://www.openlinksw.com/vspx/">
              <v:after-data-bind>
                connection_set ('vspx_user','demo');
              </v:after-data-bind>
              <v:template type="if-no-login">
                <input type="hidden" name="f" value="<?V get_keyword ('f', self.vc_event.ve_params, '') ?>" />
                <p>You are not logged in</p>
              </v:template>
              <v:login-form name="tut_login_form" required="1" >
                <table border="0">
                  <tr>
                    <td>User Name</td>
                    <td>
                       <v:text name="username" value="" xhtml_size="20" default_value="<SQL user account>" />
                    </td>
                  </tr>
                  <tr>
                    <td>Password</td>
                    <td>
                      <v:text name="password" value="" xhtml_size="20" type="password" />
                    </td>
                  </tr>
                  <tr>
                    <td></td>
                    <td>
                       <v:button action="simple" name="login" value="Login" />
                    </td>
                  </tr>
                 </table>
                <p><small>You can use 'demo' or other SQL user account</small></p>
              </v:login-form>
              <v:template type="if-login">
                <p> SID: <?vsp http (self.sid); ?> </p>
                <p> UID: <?vsp http_value (connection_get ('vspx_user')); ?> </p>
                <?vsp
                  declare path, params, lines any;
                  path := self.vc_event.ve_path;
                  params := self.vc_event.ve_params;
                  lines := self.vc_event.ve_lines;

                  connection_set('sid',self.sid);
                   connection_set('realm',self.realm);
                ?>
                <xsl:call-template name="tutorial_code"/>
               </v:template>
            </v:login>
          </v:page>
          <?vsp
            if (connection_get('stop_execution') = '1') return(0);
          ?>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="tutorial_code"/>
        </xsl:otherwise>
      </xsl:choose>
    </div>
    <script language="JavaScript" type="text/javascript">
      if (!HaveInitialState)
        document.getElementById('tab_initial_state').parentNode.className = 'disabled';
      if (Files.length == 0)
        document.getElementById('tab_view_source').parentNode.className = 'disabled';
      if (RunFiles.length == 0)
        document.getElementById('tab_run').parentNode.className = 'disabled';
    </script>
    <div id="initial_state" style="display:none;">
      <div id="progressBar">
        <div id="PBcompleted"></div>
        <div id="PBcontent">0%</div>
      </div>
      <input type="button" id="bt_SetInitialState" onclick="SetInitialState()" value="Set the initial state"/>
      <input type="button" onclick="CancelInitialState()" value="Cancel"/>
      <div id="initial_state_content">
        <p>Checking state, please wait...</p>
      </div>
    </div>
    <div id="view_source" style="display:none;">
      <script language="JavaScript" src="{concat($mount_point,'/syntax/shCore.js')}" type="text/javascript"></script>
      <script language="JavaScript" src="{concat($mount_point,'/syntax/shBrushSql.js')}" type="text/javascript"></script>
      <script language="JavaScript" src="{concat($mount_point,'/syntax/shBrushXml.js')}" type="text/javascript"></script>
      <script language="JavaScript" src="{concat($mount_point,'/syntax/shBrushCSharp.js')}" type="text/javascript"></script>
      <script language="JavaScript" src="{concat($mount_point,'/syntax/shBrushPhp.js')}" type="text/javascript"></script>
      <script language="JavaScript" src="{concat($mount_point,'/syntax/shBrushPython.js')}" type="text/javascript"></script>
      <script language="JavaScript" src="{concat($mount_point,'/syntax/shBrushVb.js')}" type="text/javascript"></script>
      <div>
        <input type="button" id="hilite" name="hilite" value="Show Syntax Highlight" onclick="doSyntax (this);" disabled="disabled"/>
      </div>
      <div> <!-- this div is to prevent flickering FF problem -->
        <div id="filelist">
          <ul id="filelist_nav">
            <li>~no files~</li>
          </ul>
          <script language="JavaScript" type="text/javascript">
            FileListInit();
          </script>
        </div>
        <div id="filesource"></div>
      </div>
    </div>
    <div id="run" style="display:none;">
      <div id="runfilelist">
        <ul id="runfilelist_nav">
          <li>~no files~</li>
        </ul>
        <script language="JavaScript" type="text/javascript">
          RunFileListInit();
        </script>
      </div>
      <iframe id="run_frame" name="run_frame" src="{concat($mount_point,'/1x1.html')}"></iframe>
    </div>
    <div id="debug">
    </div>
    <xsl:call-template name="examples_nav">
      <xsl:with-param name="pos" select="'exp_bot'"/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="tutorial_code">
<xsl:text disable-output-escaping="yes">
<![CDATA[
<?vsp
  declare f, tmp, description, pwd, current_page, current_loc, title, ht_description, ht_path, start_view, error varchar;
  declare sources, xt, start_l, load_l, load_c, demo_db, dep_vdb, dav_vsp, http_thr, xform_br, xslt_result any;
  declare i, j, len, sl, have_vsp, have_sql, have_init, show_desc integer;
  declare src_path, tutcss varchar;
  declare srv_cert, srv_key, srv_ca, cli_cert, deps, dependa, uagent varchar;
  declare is_moz, is_ie int;
  declare listed_src any;
  declare auth, current_page_auth varchar;
  declare user_agent,only_browser varchar;
  declare no_run int;
  declare showed_init_state int;
  no_run := 0;
  showed_init_state := 0;

  user_agent := http_request_header(lines, 'User-Agent', null, '');

  f := {?'f'};
  if (f is null)
    f := '1';
  f := '1';
  error := ''; show_desc := 1; src_path := ''; dependa := '';
  ht_path := http_physical_path ();
  if (ht_path like '%/dev.vsp')   -- exeption in development state
    ht_path := substring(http_physical_path(),1,length(http_physical_path()) - 8) || substring(http_path (),length(http_map_get('domain')) + 1,length(http_path ()));
  sl := strrchr (ht_path, '/');
  current_loc := substring (http_path(), 1, strrchr(http_path(),'/'));
  pwd := t_get_pwd (substring (ht_path, 1, sl));
  current_page := substring (ht_path, sl + 2, length (ht_path));
  current_page_auth := current_page;
  auth := '';
  if (connection_get('sid') is not null)
  {
   auth := auth || '?sid=' || connection_get('sid');
   auth := auth || '&realm=' || connection_get('realm') || '&';
  } else
     auth := '?';
  current_page_auth := current_page_auth || auth;
  start_view := null;
  listed_src := null;

  if (get_keyword ('load_scr_reset', params, '') <> '')
  {
    http_rewrite ();
    http_header ('Content-Type: text/html\r\n');

    if(not(registry_get('tutorial_'||current_page||'_completed') <> 0
       and cast(registry_get('tutorial_'||current_page||'_completed') as integer) < 100
       and cast(registry_get('tutorial_'||current_page||'_completed') as integer) > 0
       and registry_get('tutorial_'||current_page||'_started') <> 0
       and cast(registry_get('tutorial_'||current_page||'_started') as datetime ) > dateadd('second',(msec_time()/1000) * -1,now())))
    {
      registry_set('tutorial_'||current_page||'_completed','0');
      registry_set('tutorial_'||current_page||'_content','');
      registry_set('tutorial_'||current_page||'_started',datestring(now()));
    };
    connection_set('stop_execution','1');
    return (0);
  };

  if (get_keyword ('load_scr_status', params, '') <> '')
  {
    http_rewrite ();
    http_header ('Content-Type: text/html\r\n');
    if (registry_get('tutorial_'||current_page||'_content') = 0)
      http('noinit');
    else
      http(cast(registry_get('tutorial_'||current_page||'_completed') as varchar));
    http(':');
    if (registry_get('tutorial_'||current_page||'_content') = 0)
      http('This example has not been initialized yet.');
    else
      http(registry_get('tutorial_'||current_page||'_content'));
    connection_set('stop_execution','1');
    return (0);
  }

  is_moz := 0; is_ie := 0;
  uagent := lower (http_request_header (lines, 'User-Agent', null, ''));

  if (strstr (uagent, 'mozilla') is not null and strstr (uagent, 'gecko') is not null)
    is_moz := 1;
  else if (strstr (uagent, 'msie') is not null and strstr (uagent, 'opera') is null)
    is_ie := 1;

  start_l := vector ();
  load_l := ''; load_c := ''; dav_vsp := null; http_thr := null; xform_br := null;
  if (0 <> t_file_stat (concat (pwd, '/options.xml')))
  {
    declare exit handler for sqlstate '*' { error := concat (__SQL_STATE, '', __SQL_MESSAGE); start_view := null; goto err; };
    {
      start_view := t_file_to_string (concat (pwd, '/options.xml'));
      start_view := xml_tree_doc (start_view);
      only_browser := cast ( xpath_eval ('/init/@only_browser', start_view, 1) as varchar);
      start_l := xpath_eval ('/init/src/@start', start_view, 0);
      load_l  := cast (xpath_eval ('/init/src/@load_at_start',  start_view, 1) as varchar);
      load_c  := cast (xpath_eval ('/init/src/@load_to_clean',  start_view, 1) as varchar);
      if ( (only_browser is not null)  and (strcasestr (user_agent, only_browser) is null))
      {
        dependa := concat (dependa,
         sprintf ('<p style="color: red"><small>This example depends browser "%s" if you are using a diffrent browser the example may not function properly.</small></p>', only_browser));
      }
      demo_db  := cast (xpath_eval ('/init/depend/@demo_db',  start_view, 1) as varchar);
      xform_br  := cast (xpath_eval ('/init/depend/@xform_br',  start_view, 1) as varchar);
      dep_vdb   := cast (xpath_eval ('/init/depend/@vdb',  start_view, 1) as varchar);
      start_view := t_file_to_string (concat (pwd, '/options.xml'));
      start_view := xml_tree_doc (start_view);
      dav_vsp := cast (xpath_eval ('/init/dav_vsp/@val', start_view, 1) as varchar);
      http_thr := cast (xpath_eval ('/init/http_threads/@val', start_view, 1) as varchar);
      src_path := cast (xpath_eval ('/init/srcdir/@srcpath', start_view, 1) as varchar);
      srv_ca := cast (xpath_eval ('/init/https_server/@ca', start_view, 1) as varchar);
      srv_cert := cast (xpath_eval ('/init/https_server/@cert', start_view, 1) as varchar);
      srv_key := cast (xpath_eval ('/init/https_server/@key', start_view, 1) as varchar);
      cli_cert := cast (xpath_eval ('/init/https_client/@cert', start_view, 1) as varchar);
      deps  := xpath_eval ('/init/deps[@item and @example and @type]',  start_view, 0);
      listed_src := xpath_eval ('/init/files/file/@name', start_view, 0);
      if (length (listed_src) = 0)
        listed_src := null;
    }
  }

  if (get_keyword ('src', params, '') <> '')
  {
    declare ses any;
    ses := string_output ();
    http ('<html>\r\n<body>\r\n', ses);
    http ('<pre>\r\n', ses);
    http_rewrite ();
    http_header ('Content-Type: text/html\r\n');
    if (isstring (src_path) and length(src_path) > 1)
      http_value (t_file_to_string (concat (http_root (), src_path , get_keyword ('src', params, ''))), NULL, ses);
    else
      http_value (t_file_to_string (concat (pwd, '/', get_keyword ('src', params, ''))), NULL, ses);
    http ('\r\n</pre>\r\n', ses);
    http ('<div style="float:right"><a href="javascript:window.close();"><img src="'|| http_map_get('domain') ||'/images/close_16.png" border="0" alt="close this window" title="close this window" /> close this window</a></div>\r\n', ses);
    http ('<div style="position:absolute;top:10px;right:10px"><a href="javascript:window.close();"><img src="'|| http_map_get('domain') ||'/images/close_16.png" border="0" alt="close this window" title="close this window" /> close this window</a></div>\r\n', ses);
    http ('\r\n</body>\r\n</html>\r\n', ses);
    http (string_output_string (ses));
    connection_set('stop_execution','1');
    return (0);
  }

  {
    declare exit handler for sqlstate '*' { error := 'Warning: The Demo Database is not running, but is required for correct operation of the examples.'; };
    if (demo_db = 'yes')
    {
       declare num integer;
       select count (distinct KEY_TABLE) into num from DB.DBA.SYS_KEYS where KEY_TABLE like 'Demo.demo.%';
       if (num < 8)
         signal ('.....', 'The demo DB is not installed');
    }
  }
  -- vdb check
  if (dep_vdb = 'yes')
  {
    if (sys_stat('st_has_vdb') = 0)
        dependa := concat (dependa,
         '<div>
            <p style="color: red">This Virtual Database feature is available only in the commercial release of Virtuoso Universal Server.
            For more information on the commercial release of the Virtuoso Universal Server,
            click on the following links to learn more:</p>
            <small>
            <a href="http://virtuoso.openlinksw.com/">Virtual Database Home Page</a><br/>
            <a href="http://demo.openlinksw.com/tutorial">Virtual Database Tutorials</a><br/>
            <a href="http://docs.openlinksw.com/virtuoso">Virtual Database Documentation</a><br/>
            <a href="http://www.openlinksw.com/">OpenLink Software</a><br/>
            </small>
          </div>');
  }


  -- dependancy tests
  if (isarray (deps))
  {
    declare cn, ln integer;
    declare item, exam, type varchar;
    declare hosting_name,hosting_fail any;
    cn := 0; ln := length (deps);
    while (cn < ln)
    {
      item := cast (xpath_eval ('@item', deps[cn], 1) as varchar);
      exam := cast (xpath_eval ('@example', deps[cn], 1) as varchar);
      type := cast (xpath_eval ('@type', deps[cn], 1) as varchar);
      if (lower(type) = 'table' and not exists (select 1 from DB.DBA.SYS_KEYS where 0 = casemode_strcmp (KEY_TABLE, item)))
      {
        dependa := concat (dependa,
         sprintf ('<p style="color: red"><small>This example depends of table "%s" from "%s" demo, which isn''t initialized.</small></p>', item, exam));
      }
      else if (lower(type) = 'user' and not exists (select 1 from DB.DBA.SYS_USERS where 0 = casemode_strcmp (U_NAME, item)))
      {
        dependa := concat (dependa,
         sprintf ('<p style="color: red"><small>This example depends of user account "%s" from "%s" demo, which isn''t initialized.</small></p>', item, exam));
      }
      else if (lower(type) = 'procedure' and not exists (select 1 from DB.DBA.SYS_PROCEDURES where 0 = casemode_strcmp (P_NAME, item)))
      {
        dependa := concat (dependa,
         sprintf ('<p style="color: red"><small>This example depends of procedure "%s" from "%s" demo, which it isn''t initialized.</small></p>', item, exam));
      }
       else if (lower(type) = 'package' and not(tcheck_package(item)) )
      {
        dependa := concat (dependa,
         sprintf ('<p style="color: red"><small>This example depends of package "%s", which is not installed.</small></p>', item));
      }
       else if (lower(type) = 'hosting')
      {
        hosting_fail := 0;
        hosting_name := '';
        if (lower(item) = 'clr_mono' and isnull(__proc_exists ('clr_runtime_name', 2)))
        {
          hosting_fail := 1;
          hosting_name := 'Virtuoso Universal Server for Linux with Mono Hosting or Virtuoso Universal Server for Windows with .NET CLR Hosting';
        }
        else if (lower(item) = 'clr' and (isnull(__proc_exists ('clr_runtime_name', 2)) or lower(clr_runtime_name()) = 'mono'))
        {
          hosting_fail := 1;
          hosting_name := 'Virtuoso Universal Server for Windows with .NET CLR Hosting';
        }
        else if (lower(item) = 'mono' and (isnull(__proc_exists ('clr_runtime_name', 2)) or lower(clr_runtime_name()) <> 'mono'))
        {
          hosting_fail := 1;
          hosting_name := 'Virtuoso Universal Server for Linux with Mono Hosting';
        }
        else if (lower(item) = 'java' and isnull(__proc_exists ('java_vm_attach', 2)))
        {
          hosting_fail := 1;
          hosting_name := 'Java Runtime Hosting Enabled';
--        JSP hosting

	  tut_generate_tomcat_url ('', lines);
          if (connection_get ('TomcatStatus') = 'BAD')
             dependa := concat (dependa, '<p style="color: red">
		 <small>In order to run this example you need start tomcat.</small></p>');

--      end JSP hosting
        }
        else if (lower(item) = 'php' and isnull(__proc_exists ('__http_handler_php', 2)))
        {
          hosting_fail := 1;
          hosting_name := 'PHP Runtime Hosting Enabled';
        }
        else if (lower(item) = 'perl' and isnull(__proc_exists ('WS.WS.__http_handler_pl')))
        {
          hosting_fail := 1;
          hosting_name := 'Perl Runtime Hosting Plugin Enabled';
        }
        else if (lower(item) = 'python' and isnull(__proc_exists ('WS.WS.__http_handler_py')))
        {
          hosting_fail := 1;
          hosting_name := 'Python Runtime Hosting Plugin Enabled';
        }
        else if (lower(item) = 'ruby' and isnull(__proc_exists ('WS.WS.__http_handler_rb')))
        {
          hosting_fail := 1;
          hosting_name := 'Ruby Runtime Hosting Plugin Enabled';
        }

        if (hosting_fail)
          dependa := concat (dependa, sprintf ('<p style="color: red"><small>In order to run this example you need %s.</small></p>', hosting_name));

      }
      cn := cn + 1;
    }
  }

  if (dav_vsp = '1')
  {
    if (cfg_item_value (virtuoso_ini_path(), 'HTTPServer', 'EnabledDavVSP') <> dav_vsp)
      error := 'Warning: WebDAV VSP Page Execution is currently disabled. Please enable in order to use this service.  Go to the Config file for the demo database (the file "demo.ini") and edit the section-key: EnabledDavVSP = 0 by uncommenting and then changing the 0 to 1.';
  }

  if (http_thr is not null and atoi(http_thr) > 1)
  {
    if (atoi (cfg_item_value (virtuoso_ini_path(), 'HTTPServer', 'ServerThreads')) < atoi (http_thr))
    {
      error := sprintf ('Warning: This example needs at least %s HTTP server threads configured.', http_thr);
    }
  }

  if (isstring (srv_cert))
  {
    if (t_file_stat (srv_cert) = 0 or
        t_file_stat (srv_key) = 0 or
        t_file_stat (srv_ca) = 0 or
        t_file_stat (cli_cert) = 0)
    {
      error := sprintf ('Warning: This example needs of following files to be installed:
      HTTPS Server: CA list:%s,  Certificate:%s, Private Key:%s and Client certificate:%s.',
      srv_ca, srv_cert, srv_key, cli_cert);
    }
  }

  if (isstring (src_path) and length(src_path) > 1)
    sources := t_sys_dirlist (concat (http_root(), src_path), 1, null, 1);
  else
    sources := t_sys_dirlist (pwd, 1, null, 1);

  len := length (sources); i := 0;
  if (isstring (load_l) and load_l <> '')
    t_load_script (concat (pwd, '/', load_l));

  if (get_keyword ('load_scr', params, '') <> '')
  {
    if(registry_get('tutorial_'||current_page||'_completed') <> 0
       and cast(registry_get('tutorial_'||current_page||'_completed') as integer) < 100
       and cast(registry_get('tutorial_'||current_page||'_completed') as integer) > 0)
    {
      http_rewrite ();
      http_header ('Content-Type: text/html\r\n');
      http('already running');
      http_flush ();
      connection_set('stop_execution','1');
      return (0);
    }

    declare cnt, parts, tm, res any;
    declare stat, msg any;
    declare sql_files any;
    declare count_all,count_executed integer;

    sql_files := vector();
    count_all := 0;
    count_executed := 0;

    res := string_output();

    while (i < len)
    {
      if ((load_c <> '' and aref (sources, i) = load_c) or (load_c = '' and aref (sources, i) like '%.sql'))
      {
        cnt := t_file_to_string (concat (pwd, '/', aref (sources, i)));
        parts := sql_split_text (cnt);
        sql_files := vector_concat(sql_files,vector(vector(aref (sources, i),parts)));
        count_all := count_all + length(parts);
      }
      i := i + 1;
    }

    http_rewrite ();
    http_header ('Content-Type: text/html\r\n');
    http_flush (1);
    http ('<html>\r\n<body>\r\n');
    http ('<pre>\r\n');

    foreach (any sql_file in sql_files) do
    {
      http (sprintf('Loading file: %s\r\n\r\n',sql_file[0]));
      http (sprintf('Loading file: %s\r\n\r\n',sql_file[0]),res);
      foreach (varchar s in sql_file[1]) do
      {
        stat := '00000';
        msg := '';
        tm := msec_time();
        exec (s, stat, msg);
        count_executed := count_executed + 1;
        if (stat <> '00000')
        {
          rollback work;
          if (lower (trim (s, ' \r\n')) like 'drop %')
          {
            http (sprintf ('<span style="color:green;">It is normal to see errors from drop statements, if this is the first time the sql is executed.<br/>*** Error %s: %s</span>',stat,msg));
            http (sprintf ('<span style="color:green;">It is normal to see errors from drop statements, if this is the first time the sql is executed.<br/>*** Error %s: %s</span>',stat,msg),res);
          }
          else
          {
            http (sprintf ('<span style="color:red;">*** Error %s: %s</span>',stat,msg));
             http (sprintf ('<span style="color:red;">*** Error %s: %s</span>',stat,msg),res);
          }
        }
        else
        {
          commit work;
          http (sprintf ('Done. -- %s msec.',cast(msec_time() - tm as varchar)));
          http (sprintf ('Done. -- %s msec.',cast(msec_time() - tm as varchar)),res);
        }
        http ('\r\n\r\n');
        http ('\r\n\r\n',res);
        registry_set('tutorial_'||current_page||'_completed',cast(ceiling(((100.0/count_all) * count_executed)) - 1 as varchar));
        registry_set('tutorial_'||current_page||'_content',string_output_string(res));
        http_flush (1);
      }
    }

    http ('Finished.\r\n');
    http ('Finished.\r\n',res);
    registry_set('tutorial_'||current_page||'_completed','100');
    registry_set('tutorial_'||current_page||'_content',string_output_string(res));
    http ('</pre>\r\n');
    http ('<div style="float:right"><a href="javascript:window.close();"><img src="'|| http_map_get('domain') ||'/images/close_16.png" border="0" alt="close this window" title="close this window" /> close this window</a></div>\r\n');
    http ('<div style="position:absolute;top:10px;right:10px"><a href="javascript:window.close();"><img src="'|| http_map_get('domain') ||'/images/close_16.png" border="0" alt="close this window" title="close this window" /> close this window</a></div>\r\n');
    http ('</body>\r\n</html>\r\n');
    http_flush(1);
    connection_set('stop_execution','1');
    return (0);
  }

  err:
  len := length (sources); i := 0; j := 0; have_vsp := 0; have_sql := 0; have_init := 0;
  if (isentity(start_view) and xpath_eval ('/init/run[@name and @link]',  start_view))
    have_vsp := have_vsp + 1;
  while (i < len)
  {
    if (listed_src is not null and not position (aref (sources, i), listed_src))
      ;
    else if (aref (sources, i) <> current_page and (
          aref (sources, i) like '%.vsp' or
          aref (sources, i) like '%.rq' or
          aref (sources, i) like '%.isparql' or
          aref (sources, i) like '%.csdl' or
          aref (sources, i) like '%.owl' or
          aref (sources, i) like '%.html' or
          aref (sources, i) like '%.vspx' or
          aref (sources, i) like '%.aspx' or
          aref (sources, i) like '%.pl' or
          aref (sources, i) like '%.py' or
          aref (sources, i) like '%.rb' or
          aref (sources, i) like '%.jsp' or
          (aref (sources, i) like '%.php' and
            aref (sources, i) not like '.%.php')))
      have_vsp := have_vsp + 1;
    else if (aref (sources, i) like '%.sql')
    {
      if (listed_src is not null and not position (sources[i], listed_src))
        ;
      else
        have_sql := have_sql + 1;
      if ((load_c <> '' and sources[i] = load_c) or (load_c = '' and sources[i] like '%.sql'))
        have_init := have_init + 1;
    }
    else if (listed_src is not null and position (sources[i], listed_src))
      have_vsp := have_vsp + 1;
    i := i + 1;
  }

  erri:
?>
<?vsp
  if (error <> '' and not show_desc)
    http (concat ('<p style="color: red"><b>', error,'</b></p>'));
?>
<?vsp
  if (not(have_init)) {
?>
    <script language="JavaScript" type="text/javascript">
      HaveInitialState = 0;
    </script>
<?vsp
  }
?>
  <a name="launchtable"> <!-- If we don't have at least space here IE will give unknown runtime error --></a>
<?vsp
  if (xform_br = 'yes')
  {
    http ('<object id="FormsPlayer" classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58"><p style="color: red"><b>Warning: FormsPlayer has failed to load! Please check your installation.</b></p><p><b>The FormsPlayer is needed in order to run this sample.</b></p><br /></object>');
   }
  if (dependa <> '' and show_desc)
    http (dependa);
  if (have_vsp or have_sql)
  {
?>
<?vsp
     if (error <> '' and show_desc)
      http (concat ('<p style="color: red"><b>', error,'</b></p>'));
?>
  <table class="source_table_">
    <tr class="source_table_header">
      <th nowrap="nowrap"><b>View the source</b></th>
      <th><b>&nbsp;Action&nbsp;</b></th>
    </tr>
<?vsp
  }
  len := length (sources); i := 0; j := 0;
  -- Set Initial State
  while (i < len)
  {
    if (listed_src is not null and not position (sources[i], listed_src))
      ;
    else if (sources[i] like '%.sql' and ((load_c <> '' and sources[i] = load_c) or (load_c = '' and sources[i] like '%.sql')))
    {
      j := j + 1;
?>
      <tr>
        <td class="source_table_data">
           <?V j ?>.
          <a onclick="ViewSourceLink('<?V aref (sources, i) ?>')" href="#"><?V aref (sources, i) ?></a>
          <script language="JavaScript" type="text/javascript">Files.push('<?V aref (sources, i) ?>');</script>
        </td>
        <td class="source_table_action">
          <?vsp
            if (showed_init_state = 0)
            {
              showed_init_state := 1;
          ?>
              <a onclick="InitialStateLink()" href="#">Set the initial state</a>
          <?vsp
            }
          ?>
        </td>
      </tr>
<?vsp
    }
    i := i + 1;
  }
  -- dummy run links
  if (isentity(start_view))
  {
    declare run_name, run_link varchar;
    foreach(any xrun in xpath_eval ('/init/run[@name and @link ]',  start_view, 0))do
    {
      run_name := cast(xpath_eval('@name',xrun) as varchar);
      run_link := cast(xpath_eval('@link',xrun) as varchar);
      j := j + 1;
?>
      <tr>
        <td class="source_table_data">
          <?V j ?>.
          <?V run_name ?>
        </td>
        <td class="source_table_action">
          <a target="run_frame" onclick="RunLink('<?V replace(run_link,'''','\\''') ?>')" href="<?V run_link?>">Run</a>
          <script language="JavaScript" type="text/javascript">RunFiles.push(Array('<?V run_link ?>','<?V run_name ?>'));</script>
        </td>
      </tr>
<?vsp
    }
  }
  -- list of files
  i := 0;
  while (i < len)
  {
    declare src_name, source_ext, dot_pos any;

    src_name := sources[i];
    dot_pos := strrchr (src_name, '.');
    if (dot_pos is not null)
      source_ext := subseq (src_name, dot_pos + 1, length (src_name));
    else
      source_ext := null;

    if (listed_src is not null and not position (src_name, listed_src))
      ;
    else if (
      src_name <> current_page and
      src_name[0] <> ascii ('.') and
      src_name <> 'options.xml' and
      src_name <> regexp_replace (current_page, '.vspx?$', '.xml') and
      source_ext in
      ('rq', 'csdl', 'isparql', 'owl', 'vsp', 'sql','xsl','xml','xsd','html','java','pl','pm','py','rb','cs','vspx','aspx','wsdl','bpel','php', 'xq', 'xslt', 'cpp', 'h', 'jsp'))
    {
      if (sources[i] like '%.sql' and ((load_c <> '' and sources[i] = load_c) or (load_c = '' and sources[i] like '%.sql')))
        goto next_item;
      j := j + 1;
?>
      <tr>
        <td class="source_table_data">
          <?V j ?>.
          <a onclick="ViewSourceLink('<?V aref (sources, i) ?>')" href="#"><?V aref (sources, i) ?></a>
          <script language="JavaScript" type="text/javascript">Files.push('<?V aref (sources, i) ?>');</script>
        </td>
        <td class="source_table_action">
<?vsp
          if ((not no_run) and
            aref (sources, i) like '%.jsp')
	    {
          ?>
	  <a target="run_frame_java" href="<?=tut_generate_tomcat_url (sources[i], lines)?>">Run</a>
          <?vsp
	    }
          if ( (not no_run) and
            (aref (sources, i) like '%.vsp'
            or aref (sources, i) like '%.html'
            or aref (sources, i) like '%.pl'
            or aref (sources, i) like '%.py'
            or aref (sources, i) like '%.isparql'
            or aref (sources, i) like '%.rb'
            or aref (sources, i) like '%.vspx'
            or aref (sources, i) like '%.aspx'
            or aref (sources, i) like '%.php'))
          {
            declare ii, ll, show_run integer;
            declare where_to_run varchar;
            if (start_view is not null)
            {
              declare fhost, furl, whost any;
              fhost := http_request_header (lines, 'Host', null, 'localhost');
              fhost := split_and_decode (fhost, 0, ':=:');
              where_to_run := cast (xpath_eval (sprintf ('/init/src[@start = ''%s'']/@link', sources [i]), start_view, 1) as varchar);

              furl := WS.WS.PARSE_URI (coalesce (where_to_run, ''));
              if (furl[0] <> '' and furl[1] <> '')
              {
                declare nhostp varchar;
                whost := split_and_decode (furl[1], 0, ':=:');
                if (length (whost) > 1)
                {
                  if (whost[1] = '<port>')
                  {
                    declare new_port any;
                    new_port := sprintf ('%d', atoi(server_http_port ()));
                    nhostp := sprintf ('%s:%s', fhost[0], new_port);
                  }
                  else if (whost[1] <> '<port+1>')
                    nhostp := sprintf ('%s:%s', fhost[0], whost[1]);
                  else
                  {
                    declare new_port any;
                    new_port := sprintf ('%d', atoi(server_http_port ())+1);
                    nhostp := sprintf ('%s:%s', fhost[0], new_port);
                  }
                }
                else
                  nhostp := fhost [0];
                where_to_run := sprintf ('%s://%s%s', furl[0], nhostp, furl[2]);
              }
            }

            show_run := 0;
            if (start_view is null or (isarray (start_l) and length (start_l) = 0))
            {
          ?>
              <a target="run_frame" onclick="RunLink('<?V concat(current_loc, '/', aref (sources, i)) ?><?Vauth?>')" href="<?V concat(current_loc, '/', aref (sources, i)) ?><?Vauth?>">Run</a>
              <script language="JavaScript" type="text/javascript">RunFiles.push(Array('<?V concat(current_loc, '/', aref (sources, i)) ?><?Vauth?>','<?V aref (sources, i) ?>'));</script>
          <?vsp
            }
            else if (isstring (where_to_run))
            {
              -- frame run
              if (strchr (where_to_run, '/') is null)
              {
                where_to_run := sprintf ('%s/%s', current_loc, where_to_run);
              }
            ?>
              <a target="run_frame" onclick="RunLink('<?V where_to_run ?>')" href="<?V where_to_run ?>">Run</a>
              <script language="JavaScript" type="text/javascript">RunFiles.push(Array('<?V where_to_run ?>','<?V aref (sources, i) ?>'));</script>
            <?vsp
            }
            else
              http('&nbsp;');
          }
          else
             http('&nbsp;');
      ?>
      </td>
    </tr>
<?vsp
    }
    next_item:
    i := i + 1;
  }
?>
<?vsp
  if (have_vsp or have_sql)
  {
?>
     </table>
<?vsp
  }
?>
]]>
</xsl:text>
  </xsl:template>

  <xsl:template name="search_code">
    <xsl:text disable-output-escaping="yes">
    <![CDATA[
    <?vsp
      if (get_keyword('OpenSearch',params) is not null) {
        declare sho varchar;
        declare host, title, about, copyr, home, name, descr, mail, author, discl, kwds, bid, opts any;

        kwds := get_keyword('kwds',params);
        sho := regexp_match ('[[:alnum:]_]+', kwds);

        http_header ('Content-Type: text/xml; charset=UTF-8\r\n');
        host := http_request_header (lines, 'Host');

        http_rewrite ();
        http ('<?xml version="1.0" ?>');
        http ('<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">');
        http ('<Url>http://'|| regexp_replace(HTTP_GET_HOST(),':80$','') || http_path() || '?q={searchTerms}&amp;cnt={count}&amp;sp={startPage}&amp;output=xml' || '</Url>');
        http ('<Format>http://a9.com/-/spec/opensearchrss/1.0/</Format>');
        http ('<ShortName>OpenLink Virtuoso Tutorial</ShortName>');
        http ('<LongName>OpenLink Virtuoso Features Demonstrations and Tutorials</LongName>');
        http ('<Description>About: ');
        http_value (kwds);
        http ('</Description>');
        http ('<Tags>');
        http_value (kwds);
        http ('</Tags>');
        http ('<Image>http://'|| regexp_replace(HTTP_GET_HOST(),':80$','') || http_map_get('domain') || '/leftlogo.gif</Image>');
        http ('<SampleSearch>');
        http_value (kwds);
        http ('</SampleSearch>');
        http ('<Developer>OpenLink Software</Developer>');
        http ('<Contact>support@openlinksw.com</Contact>');
        http ('<Attribution></Attribution>');
        http ('<SyndicationRight>open</SyndicationRight>');
        http ('<AdultContent>false</AdultContent>');
        http ('</OpenSearchDescription>');
        return;
      }

      declare qry varchar;
      declare start_page, per_page, in_list integer;
      declare match_mode varchar;
      declare matchmodes, perpages any;
      declare i, all_res,pages integer;
      declare qry_exp varchar;
      declare qry_words any;
      declare valid_qry integer;
      declare show_res any;
      declare output varchar;
      declare max_score integer;
      declare score_ratio float;

      matchmodes := vector('all','All of the words',
                           'phrase','The exact phrase',
                           'one','At least one of the words',
                           'none','Not containing the words');

      perpages := vector(10,20,30,50);
      valid_qry := 0;
      score_ratio := 1;

      qry := get_keyword('q',params,'');
      match_mode := get_keyword('match',params,'');
      start_page := cast(get_keyword('sp',params,'') as integer);
      per_page := cast(get_keyword('cnt',params) as integer);
      output := get_keyword('output',params,'text');

      if (output not in ('text','html','xml','rdf','atom','xbel'))
        output := 'text';

      if (start_page <= 0 or isnull(start_page))
        start_page := 1;
      if (per_page < 0 or isnull(per_page))
        per_page := 10;
      if (get_keyword(match_mode,matchmodes,'') = '')
        match_mode := 'all';
    ?>
    <div id="search">
      <?vsp
        if (output = 'text') {
      ?>
      <form method="get" action="search.vsp">
        <fieldset>
          <legend>Search</legend>
          <label for="q">Search query:</label>
          <input type="text" name="q" id="q" value="<?V qry ?>" size="40"/>
          <input name="post" value="Search" title="Search" alt="Search" type="submit"/>
          <br/>
          <label for="match">match:</label>
          <select name="match" id="match">
            <?vsp
              for (declare i any, i := 0; i < length(matchmodes); i := i + 2){
            ?>
              <option value="<?V matchmodes[i] ?>"<?vsp if(matchmodes[i] = match_mode) http(' selected="selected"'); ?>><?V matchmodes[i + 1] ?></option>
            <?vsp
              }
            ?>
          </select>
          <br/>
          <label for="cnt">results per page:</label>
          <select name="cnt" id="cnt">
            <?vsp
              in_list := 0;
              foreach (any p in perpages)do{
                if (p = per_page){
                  in_list := 1;
            ?>
              <option value="<?V p ?>" selected="selected"><?V p ?></option>
            <?vsp
                } else {
            ?>
              <option value="<?V p ?>"><?V p ?></option>
            <?vsp
                }
              }
              if (in_list = 0) {
            ?>
              <option value="<?V per_page ?>" selected="selected"><?V per_page ?></option>
            <?vsp
              }
            ?>
          </select>
        </fieldset>
      </form>
      <?vsp
        }
      ?>

      <?vsp
        if (regexp_match('[a-zA-Z0-9]',qry))
          valid_qry := 1;

        declare qes any;
        declare qurl varchar;
        qes := string_output ();
        http_escape (qry, 8, qes);
        qurl := sprintf ('%s?q=%s&match=all&cnt=%d&sp=%d&output=',http_path(), string_output_string (qes), per_page, start_page);

        if (qry <> '' and valid_qry = 0) {
      ?>
        <h1 style="color: red">You have not entered a valid query. Your query should contain at least one charecter or number.</h1>
      <?vsp
        };

        if (qry <> '' and valid_qry = 1)
        {
          qry_exp := regexp_replace(qry,'[^a-zA-Z0-9\\-_ ]','',1,null);
          if (match_mode = 'phrase') {
            qry_exp := '"' || qry_exp || '"';
          } else {
            qry_words := split_and_decode(qry_exp,0,'\0\0 ');
            qry_exp := '';
            foreach (varchar qry_word in qry_words) do {
              if (qry_word <> '') {
                if (match_mode = 'none')
                  qry_exp := qry_exp || ' AND NOT "' || qry_word || '"';
                else if (qry_exp = '')
                  qry_exp := '"' || qry_word || '"';
                else if (match_mode = 'one')
                  qry_exp := qry_exp || ' OR "' || qry_word || '"';
                else
                  qry_exp := qry_exp || ' AND "' || qry_word || '"';
              };
            };
            if (match_mode = 'none')
              qry_exp := 'tutsearchmatchallexamples' || qry_exp || '';
          }

          i := 0;
          show_res := vector();
          max_score := 0;
          for (SELECT TS_NAME,TS_TITLE,TS_PATH,SCORE
                FROM DB.DBA.TUT_SEARCH
               WHERE contains(TS_TITLE,qry_exp) ORDER BY SCORE DESC)do{
            i := i + 1;
            if (max_score < SCORE)
              max_score := SCORE;
            if (per_page = 0 or (i > ((start_page - 1) * per_page) and i <= start_page*per_page)) {
              show_res := vector_concat(show_res,vector(vector(i,TS_NAME,TS_TITLE,TS_PATH,SCORE)));
            }
          }
          all_res := i;
          if (max_score > 200)
            score_ratio := cast ( ( 200.0 / max_score ) as float);
        } else {
          all_res := 0;
          show_res := vector();
        }

        if (output = 'xml' or output = 'rdf' or output = 'xbel' or output = 'atom') {
          http_rewrite ();
          http_header ('Content-Type: text/xml; charset=UTF-8\r\n');
          http ('<rss version="2.0" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">\r\n<channel>\r\n');
          http ('<title>');
          http ('OpenLink Virtuoso Features Demonstrations and Tutorials');
          http ('</title>');
          http ('<link>');
          http (sprintf ('http://%s', regexp_replace(HTTP_GET_HOST(),':80$','')));
          http_value (qurl || 'text');
          http ('</link>');
          http ('<description>About ');
          http_value (qry);
          http ('</description>');
          http ('<pubDate>');
          http_value (date_rfc1123(now()));
          http ('</pubDate>');
          http (sprintf ('<openSearch:totalResults>%d</openSearch:totalResults>\r\n', all_res));
          http (sprintf ('<openSearch:startIndex>%d</openSearch:startIndex>\r\n', ((start_page - 1)*per_page + 1)));
          http (sprintf ('<openSearch:itemsPerPage>%d</openSearch:itemsPerPage>\r\n', per_page));
          foreach(any res in show_res)do{
            http ('<item>');
            http ('<description>');
            http_value (res[2]);
            http ('</description>');
            http ('<title>');
            http_value (res[1]);
            http ('</title>');
            http (sprintf ('<link>http://%s%s/', regexp_replace(HTTP_GET_HOST(),':80$',''), http_map_get('domain')));
            http_value (res[3]);
            http ('</link>');
            http (sprintf ('<guid>http://%s%s/', regexp_replace(HTTP_GET_HOST(),':80$',''), http_map_get('domain')));
            http_value (res[3]);
            http ('</guid>');
            http ('<pubDate>');
            http_value (date_rfc1123(now()));
            http ('</pubDate>');
            http ('</item>');
          }
          http ('</channel></rss>');
          if (output = 'rdf')
            http_xslt (TUTORIAL_XSL_DIR() || '/tutorial/rss2rdf.xsl');
          else if (output = 'xbel')
            http_xslt (TUTORIAL_XSL_DIR() || '/tutorial/rss2xbel.xsl');
          else if (output = 'atom')
            http_xslt (TUTORIAL_XSL_DIR() || '/tutorial/rss2atom.xsl');
          return;
        }

      ?>

      <?vsp
        if (qry <> '') {
      ?>
        <h1>Found <?V all_res ?> results for <?V lower(get_keyword(match_mode,matchmodes)) ?> "<?V qry ?>"</h1>
      <?vsp
        }
      ?>

      <?vsp
        if (all_res > 0) {
      ?>
      <h2>Results as:
        <a href="<?V qurl ?>html"><img src="<?V http_map_get('domain') ?>/images/html401.gif" border="0" title="HTML" alt="HTML" hspace="3"/></a>
        <a href="<?V qurl ?>xml"><img src="<?V http_map_get('domain') ?>/images/rss-icon-16.gif" border="0" title="RSS" alt="RSS" hspace="3"/>RSS</a>
        <a href="<?V qurl ?>atom"><img src="<?V http_map_get('domain') ?>/images/blue-icon-16.gif" border="0" title="ATOM" alt="ATOM" hspace="3"/>Atom</a>
        <a href="<?V qurl ?>rdf"><img src="<?V http_map_get('domain') ?>/images/rdf-icon-16.gif" border="0" title="RDF" alt="RDF" hspace="3"/>RDF</a>
        <a href="<?V qurl ?>xbel"><img src="<?V http_map_get('domain') ?>/images/blue-icon-16.gif" border="0" title="XBEL" alt="XBEL" hspace="3"/>XBEL</a>
        <a href="<?V sprintf ('%s?kwds=%s&OpenSearch', http_path(), string_output_string (qes))  ?>"><img src="<?V http_map_get('domain') ?>/images/blue-icon-16.gif" border="0" title="OpenSearch" alt="OpenSearch" hspace="3"/>OpenSearch</a>
      </h2>
      <table>
        <tr>
          <th>N</th>
          <th>Example</th>
          <th>Score</th>
        </tr>
        <?vsp
          foreach(any res in show_res)do{
        ?>
        <tr>
          <td><?V res[0] ?>.</td>
          <td>
            <a href="<?V res[3] ?>"><?V res[1] ?></a>
            <?V res[2] ?>
          </td>
          <td>
            <img src="<?V http_map_get('domain') ?>/images/score.gif" height="5" width="<?V cast(res[4] * score_ratio as integer) ?>" title="<?V res[4] ?>" alt="<?V res[4] ?>"/>
          </td>
        </tr>
        <?vsp
          }
        ?>
      </table>
      <?vsp
        if (all_res > per_page and per_page <> 0) {
          pages := floor(all_res / per_page);
          if (mod(all_res,per_page))
            pages := pages + 1;
          if (start_page > pages)
            start_page := pages;
      ?>
        <div class="search_nav">Result pages:
      <?vsp
          for(declare p integer,p:=1; p <= pages; p := p + 1){
            if (p = start_page) {
      ?>
            <?V p ?>
      <?vsp
            } else {
      ?>
            <a href="./search.vsp?q=<?V qry ?>&amp;match=<?V match_mode ?>&amp;cnt=<?V per_page ?>&amp;sp=<?V p ?>"><?V p ?></a>
      <?vsp
            };
          };
      ?>
        </div>
      <?vsp
        };
      ?>
      <?vsp
        }
      ?>
    </div>
    ]]>
    </xsl:text>
  </xsl:template>

</xsl:stylesheet>