summaryrefslogtreecommitdiffstats
path: root/ns-schema.xsl
blob: 4d8baa823fcba9ab48a16f6b323075943f3a826f (plain)
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
 <!ENTITY rdf  'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
 <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
 <!ENTITY owl  'http://www.w3.org/2002/07/owl#'>
 <!ENTITY dc   'http://purl.org/dc/elements/1.1/'>
 <!ENTITY ont  'http://purl.org/net/ns/ontology-annot#'>
 <!ENTITY asserted-class  "local-name(.)='Class' or name()='owl:DeprecatedClass' or rdf:type/@rdf:resource='&rdfs;Class' or rdf:type/@rdf:resource='&owl;Class'"> 
 <!ENTITY inferred-class  "rdfs:subClassOf or parent::rdfs:domain or parent::rdfs:range"> 
 <!ENTITY class-cond  "&asserted-class; or &inferred-class;">
 <!ENTITY asserted-prop  "contains(local-name(.),'Property') or contains(rdf:type/@rdf:resource,'Property')"> 
 <!ENTITY inferred-prop  "rdfs:subPropertyOf or rdfs:domain or rdfs:range"> 
 <!ENTITY prop-cond  "&asserted-prop; or &inferred-prop;">
]>
<!--このファイルはUTF-8-->
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rdf="&rdf;"
  xmlns:rdfs="&rdfs;"
  xmlns:owl="&owl;"
  xmlns:h="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:dc="&dc;"
  xmlns:dcterms="http://purl.org/dc/terms/"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:ex="http://purl.org/net/ns/ex#"
  xmlns:doas="http://purl.org/net/ns/doas#"
  xmlns:ont="&ont;"
  xmlns:vs="http://www.w3.org/2003/06/sw-vocab-status/ns#"
  exclude-result-prefixes="rdf rdfs dc owl dcterms ex doas ont vs"
>

 <xsl:output indent="yes"
  encoding="UTF-8"
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
 <xsl:param name="xmlfile"/><!--** target xml file name if the parameter is provided by system -->
 <xsl:param name="res-prefix" select="'parts/'"/>
 <xsl:param name="inject-ccs" select="''"/>
 <!-- avoid Opera error
 <xsl:variable name="_doas" select="document('')//rdf:Description[1]"/>
 -->

 <xsl:template name="_doas_description">
  <rdf:RDF xmlns="http://purl.org/net/ns/doas#">
   <rdf:Description rdf:about="">
    <title>RDFS/OWL presentation stylesheet</title>
    <description>This stylesheet is designed to convert RDF Schema / OWL Ontology file to visible XHTML with structured definition list, with class/property trees as the table of contents.</description>
    <author rdf:parseType="Resource">
     <name>Masahide Kanzaki</name>
     <homepage rdf:resource="http://www.kanzaki.com/"/>
    </author>
    <created>2003</created>
    <release rdf:parseType="Resource">
     <revision>2.3.8</revision>
     <created>2010-11-12</created>
    </release>
    <rights>(c) 2003-2008 by the author, copyleft under LGPL</rights>
    <license rdf:resource="http://creativecommons.org/licenses/LGPL/2.1/"/>
   </rdf:Description>
  </rdf:RDF>
 </xsl:template>


 <xsl:variable name="classes" select="/rdf:RDF/*[&class-cond;]"/><!--** all class elements -->
 <xsl:variable name="properties" select="/rdf:RDF/*[&prop-cond;]"/><!--** all property elements -->
 <!-- find namespace URI -->
 <xsl:variable name="defns" select="/rdf:RDF/namespace::*[name()='']"/><!--** default namespace URI (Note namespace:: does not work in Mozilla) -->

 <xsl:variable name="nsuri-body"><!--** find namespace uri 'body' (difficult !)-->
  <xsl:variable name="nstestlen" select="string-length($xmlfile)-9"/><!-- -->
  <xsl:choose>
   <!-- if xml:base found, use it -->
   <xsl:when test="/rdf:RDF/@xml:base">
    <xsl:value-of select="/rdf:RDF/@xml:base"/>
   </xsl:when>
   <!-- if isDefinedBy found, use it -->
   <xsl:when test="/rdf:RDF/*/rdfs:isDefinedBy">
    <xsl:value-of select="/rdf:RDF/*/rdfs:isDefinedBy/@rdf:resource"/>
   </xsl:when>
   <!-- if $xmlfile provided, use it -->
   <xsl:when test="$xmlfile != ''">
    <xsl:choose>
     <xsl:when test="substring($xmlfile,$nstestlen)='/index.rdf'">
      <xsl:value-of select="substring($xmlfile,1,$nstestlen)"/>
     </xsl:when>
     <!-- otherwise, use xmlfile if possible -->
     <xsl:otherwise>
      <xsl:value-of select="$xmlfile"/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <!-- if ontology/schema description has non empty rdf:about, use it -->
   <xsl:when test="starts-with(/rdf:RDF/owl:Ontology/@rdf:about,'http:')">
    <xsl:value-of select="/rdf:RDF/owl:Ontology/@rdf:about"/>
   </xsl:when>
   <!-- if first item of classes or properties has uri with '#', use upto '#' -->
   <xsl:when test="contains(substring($classes[1]/@rdf:about,2),'#')">
    <xsl:value-of select="concat(substring-before($classes[1]/@rdf:about,'#'),'#')"/>
   </xsl:when>
   <xsl:when test="contains(substring($properties[1]/@rdf:about,2),'#')">
    <xsl:value-of select="concat(substring-before($properties[1]/@rdf:about,'#'),'#')"/>
   </xsl:when>
   <!-- if first item of classes or properties has isDefinedBy, use it -->
   <xsl:when test="$classes[1]/rdfs:isDefinedBy">
    <xsl:value-of select="$classes[1]/rdfs:isDefinedBy/@rdf:resource"/>
   </xsl:when>
   <xsl:when test="$properties[1]/rdfs:isDefinedBy">
    <xsl:value-of select="$properties[1]/rdfs:isDefinedBy/@rdf:resource"/>
   </xsl:when>
   <!-- if default namespace uri presents, use it -->
   <xsl:when test="$defns">
    <xsl:value-of select="$defns"/>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="'unknown'"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
 
 <xsl:variable name="defnspfx">
  <xsl:choose>
   <xsl:when test="$defns='&owl;'">owl:</xsl:when>
   <xsl:when test="$defns='&rdfs;'">rdfs:</xsl:when>
   <xsl:when test="$defns='&rdf;'">rdf:</xsl:when>
  </xsl:choose>
 </xsl:variable>

 <xsl:variable name="termchar" select="substring($nsuri-body,string-length($nsuri-body))"/><!-- length of nsuri-body-->
 <xsl:variable name="nsuri"><!--** $nsuri-body + '#' if body is not end with '/' -->
  <!-- <xsl:variable name="nsblen" select="string-length($nsuri-body)"/>length of nsuri-body-->
  <xsl:choose>
   <xsl:when test="$termchar='/'">
    <xsl:choose>
     <xsl:when test="starts-with($classes[1]/@rdf:about,concat($nsuri-body,'#')) or starts-with($properties[1]/@rdf:about,concat($nsuri-body,'#'))">
      <!-- case: http://example.org/ns/# -->
      <xsl:value-of select="concat($nsuri-body,'#')"/>
     </xsl:when>
     <xsl:otherwise>
      <!-- case: http://example.org/ns/ -->
      <xsl:value-of select="$nsuri-body"/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test="$termchar='#'">
    <!-- case: http://example.org/ns# -->
    <xsl:value-of select="$nsuri-body"/>
   </xsl:when>
   <xsl:otherwise>
    <!-- case: http://example.org/ns -->
    <xsl:value-of select="concat($nsuri-body,'#')"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
 <xsl:variable name="localst" select="string-length($nsuri)"/><!--** length of $nsuri -->

 <xsl:variable name="indiv" select="/rdf:RDF/*[not((&class-cond;) or (&prop-cond;) or name(.)='owl:Ontology' or name(.)='ex:Example' or @rdf:about='' or @rdf:about=$nsuri)]"/><!--** all individual elements -->



 <!--========================== Main processing ==========================-->
 <xsl:template match="/">
  <xsl:apply-templates select="rdf:RDF"/>
 </xsl:template>

 <xsl:template match="rdf:RDF">
  <!--** to generate root element and common parts, and call main part -->
  <xsl:variable name="self" select="*[@rdf:about='' or @rdf:about='#' or @rdf:about=$nsuri][*]"/><!--** ontology/schema self description-->
  <html>
   <xsl:if test="@xml:lang"><xsl:attribute name="lang"><xsl:value-of select="@xml:lang"/></xsl:attribute></xsl:if>
   <head>
    <title><xsl:value-of select="$self/dc:title|$self/rdfs:label"/> - XHTML view</title>
    <xsl:call-template name="htmlhead"/>
   </head>
   <body>
    <xsl:call-template name="toc"/>
    <xsl:choose>
     <xsl:when test="$self">
      <xsl:apply-templates select="$self" mode="ontelt"/>
     </xsl:when>
     <xsl:otherwise>
      <dl><dt>Namespace</dt><dd><xsl:value-of select="$nsuri"/></dd></dl>
     </xsl:otherwise>
    </xsl:choose>

    <xsl:call-template name="dummy-for-opera"/>
    <xsl:call-template name="generalexamples"/>

    <div class="sec">
     <h2 id="_class_def">Classes</h2>
     <span class="legend">
      <span class="owl Class">owl:Class</span>
      <span class="rdfs Class">rdfs:Class</span>
      <span class="inferred Class">inferred</span>
     </span>
     <xsl:call-template name="cptree">
      <!-- start with classes that are not subClassOf any other class or subClassOf that is not defined here-->
      <xsl:with-param name="l" select="$classes[
       not(rdfs:subClassOf[
         @rdf:resource = /rdf:RDF/*/@rdf:about or 
         substring(@rdf:resource,2) = /rdf:RDF/*/@rdf:ID or
         */@rdf:about = /rdf:RDF/*/@rdf:about or 
         substring(*/@rdf:about,2) = /rdf:RDF/*/@rdf:ID
         ])
       ]"/>
      <!--
      <xsl:with-param name="l" select="$classes[
       not(rdfs:subClassOf) or 
       (rdfs:subClassOf[ not (
         owl:Restriction or
         @rdf:resource = /rdf:RDF/*/@rdf:about or 
         substring(@rdf:resource,2) = /rdf:RDF/*/@rdf:ID or
         */@rdf:about = /rdf:RDF/*/@rdf:about or 
         substring(*/@rdf:about,2) = /rdf:RDF/*/@rdf:ID)
         ])
       ]"/>
       -->
      <xsl:with-param name="nest">0</xsl:with-param>
      <xsl:with-param name="cp">c</xsl:with-param>
     </xsl:call-template>
     <dl id="_class_def_list">
      <xsl:comment>class processing</xsl:comment>
      <xsl:apply-templates select="$classes" mode="pcproc"/>
     </dl>
    </div>
 
    <div class="sec">
     <h2 id="_property_def">Properties</h2>
     <span class="legend">
      <span class="owl ObjectProperty">Object</span>
      <span class="owl DatatypeProperty">Datatype</span>
      <span class="rdf Property">rdf:Prop</span>
      <span class="inferred Property">inferred</span>
     </span>
     <xsl:call-template name="cptree">
      <xsl:with-param name="l" select="$properties[
       not(rdfs:subPropertyOf) or
       (rdfs:subPropertyOf[ not (
         @rdf:resource = /rdf:RDF/*/@rdf:about or 
         substring(@rdf:resource,2) = /rdf:RDF/*/@rdf:ID or
         */@rdf:about = /rdf:RDF/*/@rdf:about or 
         substring(*/@rdf:about,2) = /rdf:RDF/*/@rdf:ID)
         ])
       ]"/>
      <xsl:with-param name="nest">0</xsl:with-param>
      <xsl:with-param name="cp">p</xsl:with-param>
     </xsl:call-template>
     <dl id="_prop_def_list">
      <xsl:comment>property processing</xsl:comment>
      <xsl:apply-templates select="$properties" mode="pcproc"/>
     </dl>
    </div>

    <div class="sec">
     <xsl:call-template name="findmore">
      <xsl:with-param name="l" select="$indiv"/>
     </xsl:call-template>
    </div>

   </body>
  </html>
 </xsl:template>

 <!--========================== Ontology info processing ==========================-->
 
 <xsl:template match="*" mode="ontelt">
 <!--** Description of this ontoloty/schema itself  -->
  <hgroup>
  <h1><xsl:value-of select="rdfs:label|dc:title|dcterms:title|@dc:title"/></h1>
  </hgroup>
  <div class="abstract" id="_descr">
   <xsl:comment>ontology description</xsl:comment><!--to avoid empty element-->
   <xsl:apply-templates select="rdfs:comment|dc:description|dcterms:description|@rdfs:comment|@dc:description" mode="ontdesc"/>
  </div>
  <script type="text/javascript">
    (function () {
        var desc = document.getElementById('_descr');
        var p = desc.getElementsByTagName('p');
        var div = desc.getElementsByTagName('div');
        for(var i=0; div.length-i != 0; i++){
            div[i].innerHTML = ('<p>' + div[i].innerHTML.replace(/^\n/m,'').replace(/\n\n/g,'</p><p>') + '</p>');
        };
        for(var i=0; p.length-i != 0; i++){
            p[i].innerHTML = ('<div>' + p[i].innerHTML.replace(/^\n/m,'').replace(/\n\n/g,'</div><div>') + '</div>');
        };
    }());
  </script>
  <dl>
   <dt>Namespace</dt>
   <dd><xsl:value-of select="$nsuri"/></dd>
   <xsl:apply-templates select="*[not(contains('|comment|description|label|title|',local-name()))]" mode="ontdesc"/>
<!--
   <xsl:apply-templates select="ont:created|dcterms:created" mode="ontdesc"/>
   <xsl:apply-templates select="ont:modified|dcterms:modified" mode="ontdesc"/>
   <xsl:apply-templates select="dc:date"/>
   <xsl:apply-templates select="ont:creator|foaf:maker|dc:creator" mode="ontdesc"/>
   <xsl:apply-templates select="owl:versionInfo" mode="ontdesc"/>
   <xsl:apply-templates select="owl:priorVersion" mode="ontdesc"/>
   <xsl:apply-templates select="ont:source|dc:source" mode="ontdesc"/>
   <xsl:apply-templates select="ont:relation|dc:relation" mode="ontdesc"/>
-->
   <xsl:if test="$xmlfile != ''">
    <dt>Ontology document</dt>
    <dd><a href="{$xmlfile}"><xsl:value-of select="$xmlfile"/></a></dd>
   </xsl:if>
  </dl>
 </xsl:template>

 <xsl:template match="*" mode="ontdesc">
 <!--** Annotation properties in ontology/schema description  -->
  <dt title="{name()}"><xsl:value-of select="local-name()"/></dt>
  <dd><xsl:value-of select="."/></dd>
 </xsl:template>

 <xsl:template match="*[@rdf:resource]" mode="ontdesc">
 <!--** source, relation be put hyper link  -->
  <dt title="{name()}"><xsl:value-of select="local-name()"/></dt>
  <dd>
   <a href="{@rdf:resource}">
    <xsl:call-template name="find-label"/>
   </a>
   <xsl:apply-templates select="@dc:format"/>
  </dd>
 </xsl:template>

 <xsl:template match="ont:creator|foaf:maker|dc:creator" mode="ontdesc">
 <!--** maker (author) of the ontology/schema -->
  <dt>author</dt>
  <dd>
   <xsl:choose>
    <xsl:when test=".//foaf:homepage">
     <a href="{.//foaf:homepage/@rdf:resource}"><xsl:call-template name="author-name"/></a>
    </xsl:when>
    <xsl:when test=".//rdfs:seeAlso">
     <a href="{.//rdfs:seeAlso/@rdf:resource}"><xsl:call-template name="author-name"/></a>
    </xsl:when>
    <xsl:otherwise>
     <xsl:call-template name="author-name"/>
    </xsl:otherwise>
   </xsl:choose>
   <xsl:if test=".//foaf:mbox">
    <xsl:text> (</xsl:text>
    <xsl:choose>
     <xsl:when test="starts-with(.//foaf:mbox/@rdf:resource,'mailto:webmaster@kanzaki')">
      <a href="/info/disclaimer#webmastermail">See contact information</a>
     </xsl:when>
     <xsl:when test="starts-with(.//foaf:mbox/@rdf:resource,'mailto:')">
      <a href="{.//foaf:mbox/@rdf:resource}"><xsl:value-of select="substring-after(.//foaf:mbox/@rdf:resource,'mailto:')"/></a>
     </xsl:when>
     <xsl:otherwise>
      <a href="mailto:{.//foaf:mbox/@rdf:resource}"><xsl:value-of select=".//foaf:mbox/@rdf:resource"/></a>
     </xsl:otherwise>
    </xsl:choose>
    <xsl:text>)</xsl:text>
   </xsl:if>
  </dd>
 </xsl:template>

 <xsl:template name="author-name">
  <xsl:choose>
   <xsl:when test=".//foaf:name">
    <xsl:value-of select=".//foaf:name[1]"/>
    <xsl:if test=".//foaf:name[2]">
    (<xsl:value-of select=".//foaf:name[2]"/>)
   </xsl:if>
   </xsl:when>
   <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template match="dc:description|rdfs:comment|@rdfs:comment|@dc:description" mode="ontdesc">
 <!--** Ontology/Schema description property -->
  <p>
   <xsl:if test="@xml:lang='ja'"><img src="{concat($res-prefix, 'ja.png')}" alt="[ja]"/></xsl:if>
   <xsl:value-of select="."/>
  </p>
 </xsl:template>

 <xsl:template match="*[@rdf:parseType='Literal']" mode="ontdesc">
 <!--** show as literal XML -->
  <div>
   <xsl:copy-of select="."/>
  </div>
 </xsl:template>

 <!--========================== Common handling ==========================-->

 <xsl:template match="*">
 <!--** Catch all - general properties handler: displays element name and values as dt/dd, and apply templates for children -->
  <dt>
   <xsl:value-of select="name()"/>
   <xsl:if test="@xml:lang">
    (@<xsl:value-of select="@xml:lang"/>)
   </xsl:if>
  </dt>
  <dd>
   <xsl:choose>
    <xsl:when test="@rdf:parseType='Literal'">
     <xsl:copy-of select="."/>
    </xsl:when>
    <xsl:when test="*|@*[name!='xml:lang']">
     <dl>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="*"/>
     </dl>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="."/>
    </xsl:otherwise>
   </xsl:choose>
  </dd>
 </xsl:template>

 <xsl:template match="@*">
 <!--** Displays attribute name and values as dt/dd-->
  <dt><xsl:value-of select="name()"/></dt>
  <dd><xsl:value-of select="."/></dd>
 </xsl:template>

 <xsl:template match="@rdf:parseType">
 <!--** ignore parseType-->
 </xsl:template>


 <xsl:template match="@xml:lang">
 <!--** xml:lang is displayed with element name as (@en) etc.  -->
 </xsl:template>

 <xsl:template match="*[@rdf:resource or @rdf:about]">
 <!--** If the element has URI ref (rdf:about/rdf:resource), display QName as <dt>, and reference as <dd> by calling href-dispname -->
  <dt><xsl:value-of select="name()"/></dt>
  <dd>
   <xsl:call-template name="href-dispname">
    <xsl:with-param name="id"><xsl:call-template name="idabout"/></xsl:with-param>
    <xsl:with-param name="hash" select="'#'"/>
   </xsl:call-template>
  </dd>
 </xsl:template>

 <xsl:template match="rdfs:*[@rdf:resource or @rdf:about]" priority="1.0">
 <!--** RDFS element with URI ref (rdf:about/rdf:resource), display local name as <dt>, and reference as <dd> by calling href-dispname -->
  <dt><xsl:value-of select="local-name()"/></dt>
  <dd>
   <xsl:call-template name="href-dispname">
    <xsl:with-param name="id"><xsl:call-template name="idabout"/></xsl:with-param>
    <xsl:with-param name="hash" select="'#'"/>
   </xsl:call-template>
  </dd>
 </xsl:template>


 <!--========================== Class/Property processing ==========================-->
 
 <xsl:template match="rdf:RDF/*[&class-cond; or &prop-cond;]" mode="pcproc">
 <!--** main temlate: Class and Property definition. Steps:  -->
  <xsl:if test="starts-with(preceding-sibling::node()[2],'****')">
   <dt class="group"><xsl:value-of select="normalize-space(translate(preceding-sibling::node()[2],'*',''))"/></dt>
  </xsl:if>
  <!--@ get id/about of the term as $id, by calling idabout -->
  <xsl:variable name="id">
   <xsl:call-template name="idabout"/>
  </xsl:variable>
  <!--@ generates <dt> of the definition by calling elt-dt -->
  <dt>
   <xsl:call-template name="elt-dt">
    <xsl:with-param name="id" select="$id"/>
   </xsl:call-template>
  </dt>
  <!--@ generates <dd> of the definition and shows attributes of definition as sub <dl> -->
  <dd>
   <dl>
    <!--@ _ rdfs:comment of the term -->
    <xsl:comment><xsl:value-of select="local-name()"/></xsl:comment><!-- to avoid empty <dl/> -->
    <!--@ _ apply templates for children other than id/about or label or type -->
    <xsl:apply-templates select="@*[not(name()='rdf:about' or name()='rdf:ID' or name()='rdfs:label')]"/>
    <xsl:apply-templates select="*[not(name()='rdfs:label' or name()='rdf:type')]"/>
    <!--@ _ check if in domain/range of any property by calling domain-range -->
    <xsl:call-template name="domain-range">
     <xsl:with-param name="nodes" select="$properties[rdfs:domain/@rdf:resource=concat('#',$id) or rdfs:domain/@rdf:resource=concat($nsuri,$id)]"/>
     <xsl:with-param name="type" select="'domain'"/>
    </xsl:call-template>
    <xsl:call-template name="domain-range">
     <xsl:with-param name="nodes" select="$properties[rdfs:range/@rdf:resource=concat('#',$id) or rdfs:range/@rdf:resource=concat($nsuri,$id)]"/>
     <xsl:with-param name="type" select="'range'"/>
    </xsl:call-template>
   </dl>
  </dd>
 </xsl:template>

 <xsl:template name="domain-range">
 <!--** finds if a class is in-domain-of or in-range-of any property -->
  <xsl:param name="nodes"/>
  <xsl:param name="type"/>
  <xsl:if test="$nodes != ''">
   <dt>in <xsl:value-of select="$type"/> of</dt>
   <dd>
    <xsl:for-each select="$nodes">
     <xsl:call-template name="href-dispname">
      <xsl:with-param name="id"><xsl:call-template name="idabout"/></xsl:with-param>
      <xsl:with-param name="hash" select="'#'"/>
     </xsl:call-template>
     ; 
    </xsl:for-each>
   </dd>
  </xsl:if>
 </xsl:template>

 <xsl:template match="rdfs:domain[@rdf:resource]|rdfs:range[@rdf:resource]|rdfs:subClassOf[@rdf:resource]|rdfs:subPropertyOf[@rdf:resource]" priority="2.0">
 <!--** domain, range, subClassOf, subPropertyOf treated specially  -->
  <dt class="essential" title="{name()}"><xsl:value-of select="local-name()"/></dt>
  <dd class="essential">
   <xsl:call-template name="href-dispname">
    <xsl:with-param name="id"><xsl:call-template name="idabout"/></xsl:with-param>
    <xsl:with-param name="hash" select="'#'"/>
   </xsl:call-template>
  </dd>
 </xsl:template>

 <xsl:template match="rdfs:seeAlso[@rdf:resource or */@rdf:about]|ont:relation" priority="2.0">
 <!--** more info  -->
  <dt title="{name()}"><xsl:value-of select="local-name()"/></dt>
  <dd>
   <a href="{@rdf:resource|*/@rdf:about}">
    <xsl:call-template name="find-label"/>
   </a>
  </dd>
 </xsl:template>

 <xsl:template match="@dc:format">
  (<xsl:value-of select="."/>)
 </xsl:template>

 <xsl:template match="*/rdfs:label|*/@rdfs:label" mode="heading">
 <!--** Labels of class/property will be shown in a [] blacket for heading. -->
  <span class="label"> [<xsl:value-of select="."/>]</span>
 </xsl:template>
 
 <xsl:template match="*/rdfs:label|*/@rdfs:label">
 <!--** do noting for rdfs:label if not heading mode. -->
 </xsl:template>

 <xsl:template match="ex:example">
 <!--** Show examples provided in a term definition. Note general examples (top level ex:Example) are treated by named template 'generalexamples' -->
  <dt>Example</dt>
  <dd>
   <xsl:if test=".//dc:description"><p><xsl:value-of select=".//dc:description"/></p></xsl:if>
   <div class="example"><pre class="ex {.././@rdf:ID}"><xsl:value-of select=".//ex:code"/></pre></div>
  </dd>
 </xsl:template>


 <!--=========== named templates ============-->

 <xsl:template name="toc">
 <!--** head table of contents with number of Classes and /Proprties -->
  <p>
   <xsl:if test="/rdf:RDF/ex:Example"><a href="#_ex_usage">Example</a> (<xsl:value-of select="count(/rdf:RDF/ex:Example)"/>) | </xsl:if>
   <a href="#_class_def">Class</a> (<xsl:value-of select="count($classes)"/>) | 
   <a href="#_property_def">Property</a> (<xsl:value-of select="count($properties)"/>)
   <xsl:if test="$indiv"> | <a href="#_individual_def">Individuals</a> (<xsl:value-of select="count($indiv)"/>)</xsl:if>
  </p>
  <p id="ie-notice">This is an XHTML presentation of an RDF/XML file via XSLT. Internet Explorer user might not be able to view source, but still can save the RDF from file menu. </p>
  <script type="text/javascript">//<![CDATA[
if(navigator.userAgent.indexOf('MSIE') != -1) document.getElementById('ie-notice').style.display = 'block';
  //]]></script>
 </xsl:template>

 <xsl:template name="find-label">
 <!--** finds label of a term from rdfs:label, dc:title or just its uri -->
  <xsl:choose>
   <xsl:when test="@rdfs:label or @dc:title">
    <xsl:value-of select="@rdfs:label|@dc:title"/>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="@rdf:resource"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template name="namespace">
 <!--** displays namespace information -->
  <dt>Namespace</dt>
  <dd>
   <xsl:choose>
    <xsl:when test="@xml:base"><xsl:value-of select="@xml:base"/>#</xsl:when>
    <xsl:when test="$xmlfile"><xsl:value-of select="$xmlfile"/># (guess from source)</xsl:when>
    <xsl:otherwise>unknown</xsl:otherwise>
   </xsl:choose>
  </dd>
 </xsl:template>

 <xsl:template name="dummy-for-opera">
  <!--Opera cannot process a template after xsl:choose ??? it ignores generalexample if without this dummy template -->
 </xsl:template>

 <xsl:template name="generalexamples">
 <!--** generates example sections from top level ex:Example. Note examples in term definition will be treated by match template. -->
  <xsl:variable name="ex" select="./*[local-name()='Example']"/>
  <xsl:variable name="exc" select="count($ex)"/>
  <xsl:if test="$ex">
   <div class="sec">
    <h2 id="_ex_usage">Example<xsl:if test="$exc &gt; 1">s</xsl:if></h2>
    <xsl:for-each select="$ex">
     <xsl:if test="$exc &gt; 1"><h3>Example <xsl:value-of select="position()"/></h3></xsl:if>
     <!--@ description of this example -->
     <p><xsl:value-of select="rdfs:comment|dc:description"/></p>
     <xsl:if test="rdfs:comment[@xml:lang='ja']|dc:description[@xml:lang='ja']">
      <p><img src="{concat($res-prefix, 'ja.png')}" alt="[ja]"/> <xsl:value-of select="rdfs:comment[@xml:lang='ja']|dc:description[@xml:lang='ja']"/></p>
     </xsl:if>
     <xsl:apply-templates select="ex:pfx"/>
     
     <!--@ link to trial example (e.g. web app) -->
     <xsl:if test="ex:trial">
      <p>Try example(s) at <a href="{ex:trial/@rdf:resource}"><xsl:value-of select="ex:trial/@rdf:resource"/></a> .</p>
     </xsl:if>
     <!--@ h:img comes before code example -->
     <xsl:if test="h:img">
      <p><img src="{h:img/@rdf:resource}"/></p>
     </xsl:if>
     <!--@ code example -->
     <div class="example"><pre class="{ex:pfx}"><xsl:value-of select="ex:code"/></pre></div>
     <!--@ link to related documents -->
     <xsl:if test="ont:relation">
      <p>related resouce(s):
      <xsl:for-each select="ont:relation">
       <a href="{@rdf:resource}"><xsl:value-of select="@rdfs:label|rdfs:label"/></a>; 
      </xsl:for-each>
      </p>
     </xsl:if>
     <!--@ ex:image comes after code example -->
     <xsl:if test="ex:image">
      <p>
       <xsl:choose>
        <xsl:when test="ex:image/foaf:Image">
         See <a href="{ex:image/foaf:Image/@rdf:about}"><xsl:value-of select="ex:image/foaf:Image/@rdfs:label"/></a>.
        </xsl:when>
        <xsl:otherwise><a href="{ex:image/@rdf:resource}"><img src="{ex:image/@rdf:resource}"/></a></xsl:otherwise>
       </xsl:choose>
      </p>
     </xsl:if>
    </xsl:for-each>
   </div>
  </xsl:if>
 </xsl:template>

 <!-- for example prefix -->
 <xsl:template match="ex:pfx">
  <p>(Note: vocabulary of this schema represented with prefix <strong><xsl:value-of select="."/></strong>)</p>
 </xsl:template>


 <xsl:template name="topnode">
 <!--** TEST for root of class/propety tree that is just referred by @rdf:resource. Steps: -->
  <xsl:param name="l"/><!--** list of subClassOf/subPropertyOf nodes -->
  <xsl:param name="cp"/><!--** whether class or property -->
  <ul>
   <xsl:for-each select="$l">
    <xsl:sort select="@rdf:resource"/>
    <xsl:variable name="p" select="position()"/>
<!--
    <xsl:value-of select="$p"/>:<xsl:value-of select="$l[$p]/@rdf:resource"/> (<xsl:value-of select="$p+1"/>):<xsl:value-of select="$l[$p+1]/@rdf:resource"/><br/>
-->
    <xsl:if test="$l[$p]/@rdf:resource != $l[$p+1]/@rdf:resource">
     <!--@@ソートして、次のノードとの比較で同じでなければ処理することで重複を回避できると思ったが、うまくいかない。$pはソート後のコンテキスト位置だが、$l自身の順序は元のままなので、これではソートしていないのと同じこと。ソート後の順序で「次」のノードにアクセスする方法はないものか-->
     <xsl:variable name="r" select="$l[$p]/@rdf:resource"/>
     <li>
      <xsl:value-of select="$r"/>
      <xsl:choose>
       <xsl:when test="$cp='c'">
        <xsl:call-template name="cptree">
         <xsl:with-param name="l" select="$classes[rdfs:subClassOf/@rdf:resource=$r]"/>
         <xsl:with-param name="nest" select="1"/>
         <xsl:with-param name="cp" select="$cp"/>
        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
        <xsl:call-template name="cptree">
         <xsl:with-param name="l" select="$properties[rdfs:subPropertyOf/@rdf:resource=$r]"/>
         <xsl:with-param name="nest" select="1"/>
         <xsl:with-param name="cp" select="$cp"/>
        </xsl:call-template>
       </xsl:otherwise>
      </xsl:choose>
     </li>
    </xsl:if>
   </xsl:for-each>
  </ul>

 </xsl:template>

 <xsl:template name="cptree">
 <!--** displays Classes/Proprties as a tree with links to their definitions. Starts with those that (1)do not have any subClassOf/subPropertyOf construct with @rdf:ersource or (2)have subClassOf/subPropertyOf whose object is not defined in top level (i.e. external). Steps: -->
  <xsl:param name="l"/><!--** list of classes/properties -->
  <xsl:param name="nest"/><!--** nest level to avoid infinit loop -->
  <xsl:param name="cp"/><!--** whether class or property -->
  <xsl:if test="count($l)">
  <!--@ If $l has any class or property, then generate <ul> list.-->
   <ul>
    <xsl:for-each select="$l">
    <!--@ For each member of the list as <li>, -->
     <xsl:choose>
      <xsl:when test="not(starts-with(local-name(),'Deprecate'))">
      <!--<xsl:sort select="@rdf:resource"/>@rdf:resourceだけで上位を参照しているものの整理が必要@@@@-->
       <xsl:variable name="id">
        <xsl:call-template name="idabout"/>
       </xsl:variable>
       <li>
        <!--@ _ determine the link target from ID or about, and set hyperlink to the class/property description in this presentation, by calling href-dispname -->
        <xsl:call-template name="href-dispname">
         <xsl:with-param name="id" select="$id"/>
        </xsl:call-template>

        <!--@ _ call this template recursively with parameter of list of classes/properties that are subClassOf/subPropertyOf this item, provided the nest level is within the limit-->
        <xsl:variable name="myrefid">
         <xsl:choose>
          <xsl:when test="substring($id,1,1)='!'"><xsl:value-of select="substring($id,2)"/></xsl:when>
          <xsl:otherwise>#<xsl:value-of select="$id"/></xsl:otherwise>
         </xsl:choose>
        </xsl:variable>
        <xsl:variable name="longrefid" select="concat($nsuri,$id)"/>
        
        <xsl:choose>
         <xsl:when test="$nest &gt; 8"></xsl:when>
         <xsl:when test="$cp='c'">
          <xsl:call-template name="cptree">
           <xsl:with-param name="l" select="$classes[rdfs:subClassOf[
              @rdf:resource=$myrefid or 
              @rdf:resource=$longrefid or
              */@rdf:about=$myrefid or
              */@rdf:about=$longrefid]
            ]"/>
           <xsl:with-param name="nest" select="$nest + 1"/>
           <xsl:with-param name="cp" select="$cp"/>
          </xsl:call-template>
         </xsl:when>
         <xsl:otherwise>
          <xsl:call-template name="cptree">
           <xsl:with-param name="l" select="$properties[rdfs:subPropertyOf[
              @rdf:resource=$myrefid or 
              @rdf:resource=$longrefid or
              */@rdf:about=$myrefid or
              */@rdf:about=$longrefid]
            ]"/>
           <xsl:with-param name="nest" select="$nest + 1"/>
           <xsl:with-param name="cp" select="$cp"/>
          </xsl:call-template>
         </xsl:otherwise>
        </xsl:choose>
       </li>
      </xsl:when>
      <xsl:otherwise>
       <xsl:comment><xsl:value-of select="local-name()"/></xsl:comment><!-- avoid blank ul -->
      </xsl:otherwise>
     </xsl:choose><!-- end of if not deprecate-->
    </xsl:for-each>
   </ul>
  </xsl:if>
 </xsl:template>



 <xsl:template name="findmore">
 <!--** find and listup definitions with unexpected sytax or individuals -->
  <xsl:param name="l"/>
  <xsl:if test="$l">
   <h2 id="_individual_def">Other Descriptions and Individuals</h2>
   <dl>
    <xsl:for-each select="$l">
     <dt>
      <xsl:call-template name="elt-dt">
       <xsl:with-param name="id"><xsl:call-template name="idabout"/></xsl:with-param>
       <xsl:with-param name="c">more-elt </xsl:with-param>
      </xsl:call-template>
     </dt>
     <dd><dl>
     <!--
      <xsl:if test="not(namespace-uri()='&rdf;' and local-name()='Description')">
       <dt>rdf:type</dt><dd class="rdftype"><xsl:value-of select="name()"/></dd>
      </xsl:if>
      -->
      <xsl:apply-templates select="@*[not(name()='rdf:ID' or name()='rdf:about')]|*"/>
     </dl></dd>
   </xsl:for-each>
   </dl>
  </xsl:if>
 </xsl:template>

 <xsl:template name="idabout">
  <!--** assign name with local/outer information. Steps: -->
  <xsl:choose>
   <!--@ if @rdf:ID presents, use it -->
   <xsl:when test="@rdf:ID">
    <xsl:value-of select="@rdf:ID"/>
   </xsl:when>

   <!--@ else if @rdf:about or @rdf:resource presents, switch: -->
   <xsl:when test="@rdf:about or @rdf:resource">
    <xsl:variable name="ref" select="@rdf:about|@rdf:resource"/>
    <xsl:choose>
     <!--@ _case: blank uri = self -->
     <xsl:when test="$ref=''">(self)</xsl:when>
     <!--@ _case: starts-with '#' = local vocab. trim '#' and return local name only -->
     <xsl:when test="starts-with($ref,'#')">
      <xsl:value-of select="substring($ref,2)"/>
     </xsl:when>
     <!--@ _case: outside uri or nsuri itself = add ! before uri as a mark -->
     <xsl:when test="not(contains($ref,$nsuri)) or $ref=$nsuri">
      <xsl:value-of select="concat('!',$ref)"/>
     </xsl:when>
<!--
     <xsl:when test="contains($ref,'#')">
      <xsl:value-of select="substring-after($ref,'#')"/>
     </xsl:when>
-->
     <!--@ _otherwise: local vocab. return local name (after nsuri) -->
     <xsl:otherwise>
      <xsl:value-of select="substring($ref,$localst + 1)"/>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>

   <!--@ else if @rdf:nodeID presents, use it with bnode prefix '_:' before nodeID -->
   <xsl:when test="@rdf:nodeID">
    <xsl:value-of select="concat('_:',@rdf:nodeID)"/>)
   </xsl:when>

   <!--@ otherwise, return string (anonymous) -->
   <xsl:otherwise>(anonymous)</xsl:otherwise>
  </xsl:choose>

 </xsl:template>

 <xsl:template name="elt-dt">
 <!--** determines class and id of the node for <dt> element. Steps: -->
  <xsl:param name="id"/>
  <xsl:param name="c"/>
  <!--@ test for the type (asserted Class, inferred Property etc. -->
  <xsl:variable name="class">
   <xsl:value-of select="$c"/>
   <xsl:value-of select="translate(name(),':',' ')"/>
   <xsl:if test="rdf:type">
    <xsl:variable name="tns" select="concat(substring-before(rdf:type/@rdf:resource,'#'),'#')"/>
    <xsl:if test="$tns='&owl;'"> owl</xsl:if>
    <xsl:if test="$tns='&rdfs;'"> rdfs</xsl:if>
    <xsl:value-of select="concat(' ',substring-after(rdf:type/@rdf:resource,'#'))"/>
   </xsl:if>
   <xsl:if test="(&inferred-class;) and not(&asserted-class;)"> inferred Class</xsl:if>
   <xsl:if test="(&inferred-prop;) and not(&asserted-prop;)"> inferred Property</xsl:if>
   <xsl:if test="not(@rdf:ID) and not(starts-with(@rdf:about,$nsuri)) and not(starts-with(@rdf:about,'#'))">
    <xsl:text> outer</xsl:text>
   </xsl:if>
  </xsl:variable>
  <xsl:variable name="errorclass">
   <!-- because IE doesn't recognize selector like td.Class.Property-->
   <xsl:if test="contains($class,'Class') and contains($class,'Property')"> error</xsl:if>
  </xsl:variable>

  <!--@ and assign the tyep as @class attribute. -->
  <xsl:attribute name="class"><xsl:value-of select="concat($class,$errorclass)"/></xsl:attribute>
  <!--@ set @id attribute and display name by calling id-dispname. -->
  <xsl:call-template name="id-dispname">
   <xsl:with-param name="id" select="$id"/>
  </xsl:call-template>

  <!--@ assign label -->
  <xsl:apply-templates select="rdfs:label|@rdfs:label" mode="heading"/>
  <!--@ show icon if status is testing or unstable -->
  <xsl:if test="vs:term_status or @vs:term_status">
   <xsl:choose>
    <xsl:when test="vs:term_status='testing' or @vs:term_status='testing'">
     <img class="term_status" src="{concat($res-prefix, 'construction.gif')}" alt="testing term"/>
    </xsl:when>
    <xsl:when test="vs:term_status='unstable' or @vs:term_status='unstable'">
     <img class="term_status" src="{concat($res-prefix, 'watchout.gif')}" alt="unstable term"/>
    </xsl:when>
    <xsl:when test="vs:term_status='deprecated' or @vs:term_status='deprecated'">
     <img class="term_status" src="{concat($res-prefix, 'deprecated.gif')}" alt="deprecated term"/>
    </xsl:when>
   </xsl:choose>
  </xsl:if>
  <!--@ and show class/property type -->
  <xsl:variable name="tpfx">
   <xsl:choose>
    <xsl:when test="contains($class,'inferred Class')">rdfs:</xsl:when>
    <xsl:when test="contains($class,'inferred Property')">rdf:</xsl:when>
    <xsl:when test="contains($class,'owl')">owl:</xsl:when>
    <xsl:when test="contains($class,'rdfs')">rdfs:</xsl:when>
    <xsl:when test="contains($class,'rdf')">rdf:</xsl:when>
    <xsl:when test="$defnspfx != ''"><xsl:value-of select="$defnspfx"/></xsl:when><!--(Note namespace:: does not work in Mozilla)-->
   </xsl:choose>
  </xsl:variable>
  <span class="cp-type">
   <xsl:choose>
  <!--@ _ alert if the term is both Class and Property (inferred) -->
    <xsl:when test="contains($class,'Class') and contains($class,'Property')">
     <!-- inconsistent Class/Property -->
     <span class="error">Class as well as Property ?</span>
    </xsl:when>
    <xsl:when test="name()='Class' or name()='Property'">
     <!-- default ns Class/Property -->
     <xsl:value-of select="concat($tpfx,name())"/>
    </xsl:when>
    <xsl:when test="contains(name(),'Class') or contains(name(),'Property')">
     <!-- explicit ns Class/Property -->
     <xsl:value-of select="name()"/>
    </xsl:when>
    <xsl:when test="contains($class,'inferred')">
     <!-- inferred Class/Property -->
     <span class="inferred"> 
     <xsl:choose>
      <xsl:when test="contains($class,'Class')"><xsl:value-of select="$tpfx"/>Class</xsl:when>
      <xsl:otherwise>rdf:Property</xsl:otherwise>
     </xsl:choose>
     </span>
    </xsl:when>
    <xsl:when test="contains($class,'Class')"><xsl:value-of select="$tpfx"/>Class</xsl:when>
    <xsl:when test="contains($class,'Property')"><xsl:value-of select="$tpfx"/>Property</xsl:when>
    <xsl:otherwise><xsl:value-of select="name()"/></xsl:otherwise>
   </xsl:choose>
   <xsl:call-template name="owltypes"/>
  </span>
 </xsl:template>

 <xsl:template name="id-dispname">
  <!--** gives id attribute and display name. Steps: -->
  <xsl:param name="id"/>
    
  <!--@ generate id attribute by calling idhref-attr (attr='id'). -->
  <xsl:call-template name="idhref-attr">
   <xsl:with-param name="id" select="$id"/>
   <xsl:with-param name="attr" select="'id'"/>
  </xsl:call-template>

  <!--@ and give the name of the term, by calling idhref-term. -->
  <xsl:call-template name="idhref-term">
   <xsl:with-param name="id" select="$id"/>
  </xsl:call-template>
 </xsl:template>

 <xsl:template name="href-dispname">
  <!--** gives href attribute and display name. Steps: -->
  <xsl:param name="id"/>
  <xsl:param name="hash"/>
  <!--xsl:value-of select="concat('{',$id,'}')"/-->
  <xsl:choose>
   <!--@ if $id starts with '!' or '(', outer reference. Just present uri (no link)-->
   <xsl:when test="starts-with($id,'!') or starts-with($id,'(')">
    <xsl:call-template name="idhref-term">
     <xsl:with-param name="id" select="$id"/>
    </xsl:call-template>
   </xsl:when>
   <!--@ else it is local term. -->
   <xsl:otherwise>
    <!--@ _ create a link to local term definition, by calling idhref-attr (attr='href'). -->
    <a>
     <xsl:call-template name="idhref-attr">
      <xsl:with-param name="id" select="$id"/>
      <xsl:with-param name="attr" select="'href'"/>
      <xsl:with-param name="hash" select="'#'"/>
     </xsl:call-template>
<!--
     <xsl:if test="starts-with($id,'!')">
      <xsl:attribute name="class">outer</xsl:attribute>
     </xsl:if>
-->
     <!--@ _ and the name of the term (with $hash before it), by calling idhref-term. -->
     <xsl:call-template name="idhref-term">
      <xsl:with-param name="id" select="$id"/>
      <xsl:with-param name="hash" select="$hash"/>
     </xsl:call-template>
    </a>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template name="idhref-attr">
  <!--** generates id or href attribute. Steps: -->
  <xsl:param name="id"/>
  <xsl:param name="attr"/>
  <xsl:param name="hash"/>
  
  <!--@geneates attribute, according to param 'attr', and switch:-->
  <xsl:attribute name="{$attr}">
   <xsl:choose>
    <!--@ _case: starts-with '!' or '(' = not local name, so assing id by generate-id()-->
    <xsl:when test="starts-with($id,'!') or starts-with($id,'(')">
     <xsl:value-of select="concat($hash,generate-id(.))"/>
    </xsl:when>
    <!--@ _case: starts-with '_:' = blank node. use nodeID as html id -->
    <xsl:when test="starts-with($id,'_:')">
     <xsl:value-of select="concat($hash,substring($id,3))"/>
    </xsl:when>
    <!--@ _otherwise: use id as html id -->
    <xsl:otherwise>
     <xsl:value-of select="concat($hash,$id)"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:attribute>

 </xsl:template>

 <xsl:template name="idhref-term">
  <!--** give a display label to a term based on its id. Steps: -->
  <xsl:param name="id"/>
  <xsl:param name="hash"/>
  <!--@switch:-->
  <xsl:choose>
   <!--@ _case: starts-with '!' = not local name, so just use whole uri as label-->
   <xsl:when test="substring($id,1,1)='!'">
    <xsl:value-of select="substring($id,2)"/>
   </xsl:when>
   <!--@ _case: (self) = document itself, so use $nsuri as label-->
   <xsl:when test="$id='(self)'">
    <xsl:value-of select="$nsuri"/>
   </xsl:when>
   <!--@ otherwise: local name, so use ($hash +) $id as label-->
   <xsl:otherwise>
    <xsl:value-of select="concat($hash,$id)"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template name="owltypes">
  <!--** find if any of the term's rdf:types comes from owl: namespace -->
  <xsl:for-each select="./rdf:type/@rdf:resource">
   <xsl:if test="contains(.,'&owl;')">
    <xsl:value-of select="concat(', owl:', substring-after(.,'#'))"/>
   </xsl:if>
  </xsl:for-each>
 </xsl:template>

 <xsl:template name="htmlhead">
 <!--** Generates some XHTML head elements, especially style sheet and javascript -->
  <xsl:if test="$inject-ccs != ''">
   <link rel="stylesheet" href="{$inject-ccs}" type="text/css" />
  </xsl:if>
  <xsl:if test="/rdf:RDF/ex:Example"><link rel="bookmark" href="#_ex_usage" /></xsl:if>
  <xsl:if test="$classes"><link rel="bookmark" href="#_class_def" /></xsl:if>
  <xsl:if test="$properties"><link rel="bookmark" href="#_property_def" /></xsl:if>
  <xsl:if test="$indiv"><link rel="bookmark" href="#_individual_def" /></xsl:if>
  <style type="text/css">/*<![CDATA[*/
.Class, .Property, .DatatypeProperty, .ObjectProperty, .AnnotationProperty, .FunctionalProperty, .InverseFunctionalProperty, .more-elt,.DeprecatedClass, .DepricatedProperty {padding:0.4em; width:100%; border-width: 1px; border-style: dashed; position:relative; margin-top: 1.5em}

/* solid border=owl names, dashed border: rdf(s) names */
.rdfs, .rdf {border-style:dashed}
.owl {border-style:solid}

.Class {background:#fee; border-color: maroon}
.Property, .DatatypeProperty, .AnnotationProperty {background:#eef; border-color: navy}
.ObjectProperty, /*.FunctionalProperty,*/ .InverseFunctionalProperty {background:#cdf; border-color: navy; border:#33c 1px solid}
.DeprecatedClass, .DeprecatedProperty {color: gray; border:none; background:#eee}

.more-elt {background:#eee; border-color: green; border-style: solid}
    /*.DatatypeProperty {border:#88f 1px solid}*/

dt.inferred, .legend span.inferred {/*border-color:silver;*/background-color:white}
/*dt.Class.Property*/ dt.error {border: red 2px solid}
span.inferred {color: gray}
.label {font-weight: normal; color: #555}
.cp-type {font-weight: normal; font-size:90%; color: maroon; position:absolute; right:20px}
.outer .cp-type {color: gray}
dd dt {font-weight: normal; color: #060}
dt.essential {font-weight:bold}
dd.rdftype {color:maroon}
.abstract {border: dotted 1px gray; padding: 0 1em}
.abstract p {line-height: 1.4}
pre b {color:#b00; font-weight:normal}
pre .comment {color:#3a3}
dt.outer {border:none; color:gray; font-weight:normal}
a.outer {color: #66a}
img.term_status {position:absolute; right:1px}
/*dd.dr {color:#00c}*/
#ie-notice {background: #efe; padding: 0.5em; display:none}
div.sec {border-top: silver 1px dashed; margin-top: 3em}
div.sec h2 {margin-top: 1em; font-size:1.75em}
div.sec img {max-width: 960px}
p {line-height: 1.3}
dt.group {font-size:1.6em; color: navy; margin-top:1.5em}
span.legend {font-size:0.7em; float:right; line-height:1; } span.legend span {display:block; float:left; margin:2px; width:4em; height:1em}
/*   ]]>*/</style>
  <script type="text/javascript" src="{concat($res-prefix, 'ns-schema.js')}">//</script>
 </xsl:template>

 
</xsl:stylesheet>