-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlistSKOSBegreper.vbs
1678 lines (1466 loc) · 76.2 KB
/
listSKOSBegreper.vbs
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
option explicit
!INC Local Scripts.EAConstants-VBScript
' script: listSKOSBegreper
' purpose: Generere filer på standard html og skos-format for alle begreper i en UML-modell
' version: 2020-04-23, 04-26, 04-27, 04-29
' version: 2020-11-24/25 lager ei owl/rdf/turtle-fil
' author: Kent Jonsrud
'
' Genererer ei fil på standard SKOS-format med alle begreper listet opp
' Generere ei SKOS-fil og ei html-fil pr. begrep, for direkte oppslag på hver http-URI.
' TBD: / i rolle og egenskapsnavn, feiler unødvendig på nøsting av første konkrete subtype
' TBD: alle tagger, stereotyper og multiplisiteter o.l vises i html, med tagzzz = abc, stereotype = CodeList, multiplisitet = 1..2 etc.
' TBD: rydde i koden, http://skjema.geonorge.no/basistype/Punkt + Flate + Kurve ++ selvom de er linket opp
' TBD: liste ut navn på hvilke underpakke som elementet er definet i
' TBD: hente fra tagged value definition og designation på alle mdoellelementer
' TBD erstatte blanke i pakkenavn med - ?, nå fjernes blanke
' TBD småfeil: doble , - app->pp - trailing space (?) - hasValueFrom på kodelisteegenskaper
DIM kortnavnFSO
DIM pkgFSO
DIM skosFSO
DIM htmlFSO
DIM ttlFSO
DIM skos2FSO
DIM html2FSO
DIM skosFile
DIM htmlFile
DIM ttlFile
DIM skos2File
DIM html2File
DIM skosFileName
DIM htmlFileName
DIM ttlFileName
DIM skos2FileName
DIM html2FileName
DIM debug, namespace, kortnavn, pnteller, cuteller, suteller, soteller, obteller, label, pkgname, pkgNCname, pkgNCFolder, nsprefix, supertype
debug = false
sub listSKOSBegreper()
' Show and clear the script output window
Repository.EnsureOutputVisible "Script"
Dim tittel, klasseliste
Dim theElement as EA.Element
Set theElement = Repository.GetTreeSelectedObject()
if not theElement is nothing then
'if theElement.Type="Package" and UCASE(theElement.Stereotype) = "APPLICATIONSCHEMA" then
if Repository.GetTreeSelectedItemType() = otPackage then
if UCASE(theElement.Element.Stereotype) = "APPLICATIONSCHEMA" then
'Repository.WriteOutput "Script", Now & " " & theElement.Stereotype & " " & theElement.Name, 0
dim message, indent
' dim box
' box = Msgbox ("Script listGMLExample" & vbCrLf & vbCrLf & "Scriptversion 2018-09-16" & vbCrLf & "Listing to GML example for package : [" & theElement.Name & "].",1)
' select case box
' case vbOK
dim xsdfile
'tømmer System Output for lettere å fange opp hele gml-fila
Repository.ClearOutput "Script"
Repository.CreateOutputTab "Error"
Repository.ClearOutput "Error"
kortnavn = getPackageTaggedValue(theElement,"SOSI_kortnavn")
if kortnavn = "" then
kortnavn = theElement.Name
' Repository.WriteOutput "Script", "Pakken mangler tagged value SOSI_kortnavn! Kjører midlertidig videre med pakkenavnet som forslag til kortnavn: " & vbCrLf & kortnavn, 0
end if
namespace = getPackageTaggedValue(theElement,"targetNamespace")
if namespace = "" then
namespace = kortnavn
end if
xsdfile = getPackageTaggedValue(theElement,"xsdDocument")
if xsdfile = "" then
xsdfile = kortnavn & ".xsd"
end if
nsprefix = getPackageTaggedValue(theElement,"xmlns")
if nsprefix = "" then
nsprefix = "app"
end if
SessionOutput("<?xml version=""1.0"" encoding=""utf-8""?>")
SessionOutput("<wfs:FeatureCollection")
SessionOutput(" xmlns=""" & utf8(namespace) & """")
SessionOutput(" xmlns:wfs=""http://www.opengis.net/wfs/2.0""")
SessionOutput(" xmlns:gml=""http://www.opengis.net/gml/3.2""")
SessionOutput(" xmlns:xlink=""http://www.w3.org/1999/xlink""")
SessionOutput(" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""")
SessionOutput(" xsi:schemaLocation=""" & utf8(namespace))
'SessionOutput(" """ & namespace & "." & kortnavn & ".xsd""")
SessionOutput(" " & utf8(namespace) & "/" & utf8(xsdfile))
SessionOutput(" http://www.opengis.net/wfs/2.0")
SessionOutput(" http://schemas.opengis.net/wfs/2.0/wfs.xsd""")
'SessionOutput(" timeStamp=""" & now & """")
'SessionOutput(" timeStamp=""" & Year(Date) & "-" & FormatNumber(Month(Date),0,-1,0,0) & "-" & Day(Date) & "T" & Hour(Time) & ":" & Minute(Time) & ":" & Second(Time) & "Z""")
'SessionOutput(" timeStamp=""" & Year(Date) & "-" & LPad(Month(Date),"0",2) & "-" & Day(Date) & "T" & Hour(Time) & ":" & Minute(Time) & ":" & Second(Time) & "Z""")
' I will have a correct xml timestamp to document when the script was run
dim m,d,t,min,sek,tm,td,tt,tmin,tsek
m = Month(Date)
if m < 10 then
tm = "0" & FormatNumber(m,0,0,0,0)
else
tm = FormatNumber(m,0,0,0,0)
end if
d = Day(Date)
if d < 10 then
td = "0" & FormatNumber(d,0,0,0,0)
else
td = FormatNumber(d,0,0,0,0)
end if
t = Hour(Time)
if t < 10 then
tt = "0" & FormatNumber(t,0,0,0,0)
else
tt = FormatNumber(t,0,0,0,0)
end if
if t = 0 then tt = "00"
min = Minute(Time)
if min < 10 then
tmin = "0" & FormatNumber(min,0,0,0,0)
else
tmin = FormatNumber(min,0,0,0,0)
end if
if min = 0 then tmin = "00"
sek = Second(Time)
if sek < 10 then
tsek = "0" & FormatNumber(sek,0,0,0,0)
else
tsek = FormatNumber(sek,0,0,0,0)
end if
if sek = 0 then tsek = "00"
SessionOutput(" timeStamp=""" & Year(Date) & "-" & tm & "-" & td & "T" & tt & ":" & tmin & ":" & tsek & "Z""")
SessionOutput(" numberMatched=""unknown""")
SessionOutput(" numberReturned=""0"">")
pnteller=0
cuteller=0
suteller=0
soteller=0
obteller=0
'katalog for kortnavnet
' Set kortnavnFSO=CreateObject("Scripting.FileSystemObject")
' kortnavn = getNCNameX(kortnavn)
' if not kortnavnFSO.FolderExists(kortnavn) then
' kortnavnFSO.CreateFolder kortnavn
' end if
'katalog for pakken
pkgname = kortnavn & "/" & getNCNameX(theElement.Name)
pkgNCname = getNCNameX(theElement.Name)
Set pkgFSO=CreateObject("Scripting.FileSystemObject")
SessionOutput(" pkgNCname: " & pkgNCname & "...")
SessionOutput(" pkgFSO.GetAbsolutePathName: " & pkgFSO.GetAbsolutePathName("./") & "...")
SessionOutput(" Repository.ConnectionString: " & Repository.ConnectionString() & "...")
SessionOutput(" pkgFSO.GetBaseName: " & pkgFSO.GetBaseName(Repository.ConnectionString()) & "...")
SessionOutput(" pkgFSO.GetParentFolderName: " & pkgFSO.GetParentFolderName(Repository.ConnectionString()) & "...")
pkgNCFolder = pkgFSO.GetParentFolderName(Repository.ConnectionString()) & "\" & pkgNCname
if not pkgFSO.FolderExists(pkgNCFolder) then
pkgFSO.CreateFolder pkgNCFolder
end if
label = getPackageTaggedValue(theElement,"SOSI_presentasjonsnavn")
if label = "" then label = theElement.Name
' filer for pakken
htmlFileName = pkgNCFolder & "/index.html"
SessionOutput(" htmlFileName: " & htmlFileName )
Set htmlFSO = CreateObject("Scripting.FileSystemObject")
Set htmlFile = htmlFSO.CreateTextFile(htmlFileName,True,False)
htmlFile.Write"<!DOCTYPE html>" & vbCrLf
htmlFile.Write"<html lang=""no"">" & vbCrLf
htmlFile.Write" <head>" & vbCrLf
htmlFile.Write" <meta charset=""utf-8""/>" & vbCrLf
htmlFile.Write" <title>" & utf8(kortnavn) & "</title>" & vbCrLf
htmlFile.Write" </head>" & vbCrLf
htmlFile.Write" <body>" & vbCrLf
'htmlFile.Write" <p>xml:base=" & utf8(namespace) & "</p>" & vbCrLf
htmlFile.Write" <h1>" & utf8(kortnavn) & "</h1>" & vbCrLf
if getPackageTaggedValue(theElement,"SOSI_presentasjonsnavn") <> "" then
htmlFile.Write" <p>presentasjonsnavn = " & utf8(getPackageTaggedValue(theElement,"SOSI_presentasjonsnavn")) & "</p>" & vbCrLf
end if
htmlFile.Write" <p>applikasjonsskjemaets definisjon = " & utf8(getCleanDefinitionText(theElement.Notes)) & "</p>" & vbCrLf
htmlFile.Write" <p>publiseringstidspunkt = " & Year(Date) & "-" & tm & "-" & td & "T" & tt & ":" & tmin & ":" & tsek & "Z</p>" & vbCrLf
htmlFile.Write" <p>http-URI = " & utf8(namespace) & "/" & utf8(kortnavn) & "</p>" & vbCrLf
'htmlFile.Write" <table border=""1"">" & vbCrLf
htmlFile.Write" <table>" & vbCrLf
htmlFile.Write" <tbody align=""left"">" & vbCrLf
'htmlFile.Write" <tbody>" & vbCrLf
htmlFile.Write" <tr>" & vbCrLf
htmlFile.Write" <th>_______Modellbegrep___________</th> <th>Definisjon___________</th></tr><tr>" & vbCrLf
skosFileName = pkgNCFolder & ".rdf"
SessionOutput(" skosFileName: " & skosFileName )
Set skosFSO = CreateObject("Scripting.FileSystemObject")
Set skosFile = skosFSO.CreateTextFile(skosFileName,True,False)
skosFile.Write"<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
skosFile.Write"<rdf:RDF" & vbCrLf
skosFile.Write" xmlns:skos=""http://www.w3.org/2004/02/skos/core#""" & vbCrLf
skosFile.Write" xmlns:rdf=""http://www.w3.org/1999/02/22-rdf-syntax-ns#""" & vbCrLf
skosFile.Write" xml:base=""" & utf8(namespace) & "/"">" & vbCrLf
skosFile.Write" <skos:Concept rdf:about=""" & utf8(namespace) & "/" & utf8(pkgNCname) & """>" & vbCrLf
skosFile.Write" <skos:inScheme rdf:resource=""" & utf8(namespace) & """/>" & vbCrLf
skosFile.Write" <skos:prefLabel xml:lang=""no"">" & utf8(label) & "</skos:prefLabel>" & vbCrLf
skosFile.Write" <skos:definition xml:lang=""no"">" & utf8(getCleanDefinitionText(theElement.Notes)) & "</skos:definition>" & vbCrLf
'skosFile.Write" <skos:broader rdf:resource="http://skjema.geonorge.no/SOSI/kodeliste/AdmEnheter/2020/Fylkesnummer/01"/>" & vbCrLf
skosFile.Write" </skos:Concept>" & vbCrLf
skosFile.Write" <skos:Collection rdf:about=""" & utf8(namespace) & "/" & utf8(pkgNCname) & "Collection"">" & vbCrLf
ttlFileName = pkgNCFolder & ".ttl"
SessionOutput(" ttlFileName: " & ttlFileName )
Set ttlFSO = CreateObject("Scripting.FileSystemObject")
Set ttlFile = skosFSO.CreateTextFile(ttlFileName,True,False)
ttlFile.Write"@prefix " & nsprefix & ": <" & utf8(namespace) & "/" & utf8(pkgNCname) & "/> ." & vbCrLf
ttlFile.Write"@prefix sosi: <http://skjema.geonorge.no/SOSI/basistype/> ." & vbCrLf
ttlFile.Write"@prefix adms: <http://www.w3.org/ns/adms#> ." & vbCrLf
ttlFile.Write"@prefix dct: <http://purl.org/dc/terms/> ." & vbCrLf
ttlFile.Write"@prefix owl: <http://www.w3.org/2002/07/owl#> ." & vbCrLf
ttlFile.Write"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> ." & vbCrLf
ttlFile.Write"@prefix dcat: <http://www.w3.org/ns/dcat#> ." & vbCrLf
ttlFile.Write"@prefix foaf: <http://xmlns.com/foaf/0.1/> ." & vbCrLf
ttlFile.Write"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> ." & vbCrLf
ttlFile.Write"@prefix locn: <http://www.w3.org/ns/locn#> ." & vbCrLf
ttlFile.Write"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ." & vbCrLf
ttlFile.Write"@prefix skos: <http://www.w3.org/2004/02/skos/core#> ." & vbCrLf
ttlFile.Write"@prefix xkos: <https://rdf-vocabulary.ddialliance.org/xkos/> ." & vbCrLf
ttlFile.Write"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> ." & vbCrLf
ttlFile.Write"@prefix modelldcatno: <https://data.norge.no/vocabulary/modelldcatno#> ." & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":" & utf8(pkgNCname) & " a modelldcatno:InformationModel , owl:NamedIndividual ;" & vbCrLf
ttlFile.Write"modelldcatno:containsModelElement" & vbCrLf
klasseliste = getClassList(nsprefix, theElement)
ttlFile.Write" " & utf8(Mid(klasseliste,3,Len(klasseliste))) & " ;" & vbCrLf
' ttlFile.Write" app:Sted , app:Stedsnavn , app:Skrivemåte ;" & vbCrLf
ttlFile.Write" dct:identifier """ & utf8(namespace) & "/" & utf8(pkgNCname) & """^^xsd:string ;" & vbCrLf
ttlFile.Write" dct:publisher <https://organization-catalogue.fellesdatakatalog.digdir.no/organizations/971040238> ;" & vbCrLf
ttlFile.Write" dct:description """ & utf8(getCleanDefinitionText(theElement.Notes)) & """@nb ;" & vbCrLf
tittel = getPackageTaggedValue(theElement,"SOSI_langnavn")
if tittel = "" then
tittel = theElement.Name
end if
ttlFile.Write" dct:title """ & utf8(tittel) & """@nb ;" & vbCrLf
ttlFile.Write" dct:issued """ & Year(Date) & "-" & tm & "-" & td & "T" & tt & ":" & tmin & ":" & tsek & "+01:00""^^xsd:dateTime ;" & vbCrLf
ttlFile.Write" dct:language <http://publications.europa.eu/resource/authority/language/NOB> ;" & vbCrLf
ttlFile.Write" owl:versionInfo """ & getPackageTaggedValue(theElement,"version") & """^^xsd:string ;" & vbCrLf
ttlFile.Write" adms:status <http://purl.org/adms/status/Completed> ;" & vbCrLf ' =SOSI_modellstatus?
ttlFile.Write" dct:license <http://creativecommons.org/licenses/by/4.0/deed.no> ;" & vbCrLf 'TBD?
ttlFile.Write" dcat:contactPoint " & nsprefix & ":standardiseringssekretariatet ;" & vbCrLf
ttlFile.Write" dcat:keyword """ & utf8(label) & """@nb ;" & vbCrLf
ttlFile.Write" foaf:homepage <http://sosi.geonorge.no> ;" & vbCrLf
ttlFile.Write" dct:spatial <http://publications.europa.eu/resource/authority/country/NOR> ;" & vbCrLf
ttlFile.Write" dcat:theme <https://psi.norge.no/los/tema/eiendom> ." & vbCrLf & vbCrLf 'ikke eiendom!-???
ttlFile.Write nsprefix & ":Katalog a owl:NamedIndividual , dcat:Catalog ;" & vbCrLf
ttlFile.Write" dct:description ""SOSI-modellregister med geografiske modeller""@nb ;" & vbCrLf
ttlFile.Write" dct:identifier ""https://sosi.geonorge.no/svn""^^xsd:string ;" & vbCrLf
ttlFile.Write" dct:publisher <https://organization-catalogue.fellesdatakatalog.digdir.no/organizations/971040238> ;" & vbCrLf
ttlFile.Write" dct:title ""SOSI-modellregister""@nb ;" & vbCrLf
ttlFile.Write" dct:license <http://creativecommons.org/licenses/by/4.0/deed.no> ;" & vbCrLf 'TBD?
ttlFile.Write" modelldcatno:model " & nsprefix & ":" & utf8(pkgNCname) & " ." & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":standardiseringssekretariatet a vcard:Kind , owl:NamedIndividual ;" & vbCrLf
ttlFile.Write" vcard:hasOrganizationName ""Norwegian Mapping Authority""@en , ""Kartverket""@nn , ""Kartverket""@nb ;" & vbCrLf
ttlFile.Write" vcard:hasEmail <mailto:[email protected]> ;" & vbCrLf
ttlFile.Write" vcard:hasTelephone <tel:04732118000> ." & vbCrLf & vbCrLf
' ----------------------
call listFeatureTypes(theElement)
' ----------------------
SessionOutput("</wfs:FeatureCollection>")
skosFile.Write" </skos:Collection>" & vbCrLf
skosFile.Write"</rdf:RDF>"
skosFile.Close
Set skosFSO= Nothing
htmlFile.Write" </tr>" & vbCrLf
htmlFile.Write" </tbody>" & vbCrLf
htmlFile.Write" </table>" & vbCrLf
htmlFile.Write" </body>" & vbCrLf
htmlFile.Write"</html>" & vbCrLf
htmlFile.Close
Set htmlFSO= Nothing
ttlFile.Close
Set ttlFSO= Nothing
' case VBcancel
' end select
else 'No «ApplicationSchema» Package or a «FeatureType» Class selected in the tree
MsgBox( "This script requires a «ApplicationSchema» Package or a «FeatureType» Class to be selected in the Project Browser." & vbCrLf & _
"Please select a «ApplicationSchema» Package or a «FeatureType» Class in the Project Browser and try again." )
end if
Else
if Repository.GetTreeSelectedItemType() = otElement then
if theElement.Type="Class" and UCASE(theElement.Stereotype) = "FEATURETYPE" then
if debug then Repository.WriteOutput "Script", "Debug: theElement.Name [«" & theElement.Stereotype & "» " & theElement.Name & "] currentElement.Type [" & theElement.Type & "] currentElement.Abstract [" & theElement.Abstract & "].",0
Repository.ClearOutput "Script"
Repository.CreateOutputTab "Error"
Repository.ClearOutput "Error"
namespace = "http://some.server.no/namespace"
kortnavn = "shortNamespace"
pnteller=0
cuteller=0
suteller=0
soteller=0
obteller=0
SessionOutput(" <wfs:member>")
SessionOutput(" <" & utf8(theElement.Name) & " gml:id="""& utf8(theElement.Name) & ".1"">")
indent = " "
' ----------------------
call listDatatypes(theElement.Name,theElement,indent)
' ----------------------
SessionOutput(" </" & utf8(theElement.Name) & ">")
SessionOutput(" </wfs:member>")
else
'Other than «ApplicationSchema» Package or a «FeatureType» Class selected in the tree
MsgBox( "This script requires a «ApplicationSchema» Package or a «FeatureType» Class to be selected in the Project Browser." & vbCrLf & _
"Please select a «ApplicationSchema» Package or a «FeatureType» Class in the Project Browser and try again." )
end if
else
'Other than «ApplicationSchema» Package or a «FeatureType» Class selected in the tree
MsgBox( "Element type selected: " & theElement.Type & vbCrLf & _
"This script requires a «ApplicationSchema» Package or a «FeatureType» Class to be selected in the Project Browser." & vbCrLf & _
"Please select a «ApplicationSchema» Package or a «FeatureType» Class in the Project Browser and try again." )
end If
end if
'Repository.WriteOutput "Script", Now & " Finished, check the Error and Types tabs", 0
end if
end sub
sub listFeatureTypes(pkg)
dim presentasjonsnavn
dim elements as EA.Collection
dim super as EA.Element
dim datatype as EA.Element
dim conn as EA.Collection
set elements = pkg.Elements
dim i, sosinavn, sositype, sosilengde, sosimin, sosimax, koder, prikkniv, sosierlik, superlist
dim indent, ftname, tittel, propertylist
if debug then Repository.WriteOutput "Script", "Debug: pkg.Name [" & pkg.Name & "].",0
for i = 0 to elements.Count - 1
dim currentElement as EA.Element
set currentElement = elements.GetAt( i )
if debug then Repository.WriteOutput "Script", "Debug: currentElement.Name [«" & currentElement.Stereotype & "» " & currentElement.Name & "] currentElement.Type [" & currentElement.Type & "] currentElement.Abstract [" & currentElement.Abstract & "].",0
if currentElement.Type = "Class" and LCase(currentElement.Stereotype) = "featuretype" and currentElement.Abstract = 0 then
SessionOutput(" <wfs:member>")
SessionOutput(" <" & utf8(currentElement.Name) & " gml:id="""& utf8(currentElement.Name) & ".1"">")
ftname = currentElement.Name
superlist = ""
indent = " "
call listDatatypes(ftname,currentElement,indent)
SessionOutput(" </" & utf8(currentElement.Name) & ">")
SessionOutput(" </wfs:member>")
end if
if currentElement.Type = "Class" or currentElement.Type = "Enumeration" then
Call writeSkosElement(utf8(namespace),pkgNCFolder,currentElement.Name,utf8(getTaggedValue(currentElement,"SOSI_presentasjonsnavn")),utf8(getCleanDefinitionText(currentElement.Notes)))
Call writeHtmlElement(utf8(namespace),pkgNCFolder & "/" & currentElement.Name,utf8(currentElement.Name),utf8(getTaggedValue(currentElement,"SOSI_presentasjonsnavn")),utf8(getCleanDefinitionText(currentElement.Notes)))
if getTaggedValue(currentElement,"SOSI_presentasjonsnavn") <> "" then
tittel = """" & utf8(getTaggedValue(currentElement,"SOSI_presentasjonsnavn")) & """@nb"
else
tittel = """" & utf8(currentElement.Name) & """@nb"
end if
supertype = ""
for each super in currentElement.BaseClasses
supertype = super.name
next
' SessionOutput(" -------------------------------supertype : " & supertype)
if supertype <> "" then
propertylist = nsprefix & ":" & supertype & "_supertype , " & getPropertyList(nsprefix,currentElement)
else
propertylist = getPropertyList(nsprefix,currentElement)
end if
'skosFile.Write" <skos:Collection rdf:about=""" & utf8(namespace) & "/" & utf8(kortnavn) & "/Collection"">" & vbCrLf
skosFile.Write" <skos:member rdf:resource=""" & utf8(namespace) & "/" & utf8(pkgNCname) & "/" & utf8(currentElement.Name) & """/>" & vbCrLf
'idxFile.Write" <td>kode <a href=" & utf8(namespace) & "/" & utf8(codelist) & "/" & utf8(uricode) & "> " & utf8(presentasjonsnavn) & "</a></td><td>" & utf8(getCleanDefinitionText(attr)) & "</td></tr><tr>" & vbCrLf
htmlFile.Write" <td><a href=" & utf8(currentElement.Name) & "> " & utf8(toLabel(currentElement.Name)) & "</a></td><td>" & utf8(getCleanDefinitionText(currentElement.Notes)) & "</td></tr><tr>" & vbCrLf
'htmlFile.Write" <td><a href=" & utf8(pkgNCname) & "/" & utf8(currentElement.Name) & "> " & utf8(toLabel(currentElement.Name)) & "</a></td><td>" & utf8(getCleanDefinitionText(currentElement.Notes)) & "</td></tr><tr>" & vbCrLf
'htmlFile.Write" <td><a href=" & utf8(pkgNCname) & "/" & utf8(currentElement.Name) & "> " & utf8(toLabel(currentElement.Name)) & "</a></td><td>" & utf8(getCleanDefinitionText(currentElement.Notes)) & "</td></tr><tr>" & vbCrLf
'htmlFile.Write" <td>kode <a href=" & utf8(pkgname) & "/" & utf8(currentElement.Name) & "> " & utf8(currentElement.Name) & "</a></td><td>" & utf8(currentElement.Notes) & "</td></tr><tr>" & vbCrLf
if LCase(currentElement.Stereotype) = "featuretype" then
ttlFile.Write nsprefix & ":" & utf8(currentElement.Name) & " a owl:NamedIndividual , modelldcatno:ObjectType ;" & vbCrLf
' dct:subject <https://data.skatteetaten.no/begreper/20b52aba-9fe1-11e5-a9f8-e4115b280940> ;
ttlFile.Write" modelldcatno:hasProperty"
ttlFile.Write" " & utf8(propertylist) & " ;" & vbCrLf
' ttlFile.Write" app:stedsnavn , app:posisjon ;" & vbCrLf
end if
if LCase(currentElement.Stereotype) = "datatype" then
ttlFile.Write nsprefix & ":" & utf8(currentElement.Name) & " a owl:NamedIndividual , modelldcatno:DataType ;" & vbCrLf
ttlFile.Write" modelldcatno:hasProperty"
ttlFile.Write" " & utf8(propertylist) & " ;" & vbCrLf
' ttlFile.Write" app:skrivemåte , app:kasuser ;" & vbCrLf
end if
if LCase(currentElement.Stereotype) = "union" then
ttlFile.Write nsprefix & ":" & utf8(currentElement.Name) & " a owl:NamedIndividual , modelldcatno:Choice ;" & vbCrLf
ttlFile.Write" modelldcatno:hasProperty"
ttlFile.Write" " & utf8(propertylist) & " ;" & vbCrLf
' ttlFile.Write" app:alternativ1 , app:alternativ2 ;" & vbCrLf
end if
if LCase(currentElement.Stereotype) = "codelist" or LCase(currentElement.Stereotype) = "enumeration" or currentElement.Type = "Enumeration" then
ttlFile.Write nsprefix & ":" & utf8(currentElement.Name) & " a owl:NamedIndividual , modelldcatno:CodeList ;" & vbCrLf
end if
ttlFile.Write" dct:description """ & utf8(getCleanDefinitionText(currentElement.Notes)) & """@nb ;" & vbCrLf
ttlFile.Write" dct:identifier """ & utf8(namespace) & "/" & utf8(pkgNCname) & "/" & utf8(currentElement.Name) & """^^xsd:anyURI ; " & vbCrLf
ttlFile.Write" dct:title " & tittel & " ;" & vbCrLf
' ttlFile.Write" modelldcatno:typeDefinitionReference """ & utf8(namespace) & "/" & utf8(pkgNCname) & "/" & utf8(currentElement.Name) & """^^xsd:anyURI ; " & vbCrLf
ttlFile.Write" modelldcatno:belongsToModule """ & utf8(pkg.Element.Name) & """@nb ." & vbCrLf & vbCrLf
if supertype <> "" then
ttlFile.Write nsprefix & ":" & utf8(currentElement.Name) & "_supertype a owl:NamedIndividual , modelldcatno:Specialization ;" & vbCrLf
ttlFile.Write" modelldcatno:hasGeneralConcept " & nsprefix & ":" & utf8(supertype) & " ;" & vbCrLf
ttlFile.Write" dct:identifier """ & utf8(namespace) & "/" & utf8(pkgNCname) & "/" & utf8(currentElement.Name) & "_supertype""^^xsd:anyURI ; " & vbCrLf
ttlFile.Write" dct:title ""Spesialisering av " & utf8(supertype) & """@nb ." & vbCrLf & vbCrLf
end if
' ----------------------
call listClassProperties(namespace,pkgNCFolder,currentElement)
' ----------------------
end if
next
dim subP as EA.Package
for each subP in pkg.packages
call listFeatureTypes(subP)
next
' må lage lokale kopier av ISO-basistypene for å peke på
ttlFile.Write nsprefix & ":Integer a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Integer""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Real a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Real""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":CharacterString a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/CharacterString""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":LanguageString a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/LanguageString""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Date a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Date""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":DateTime a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/DateTime""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Boolean a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Boolean""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Uri a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Uri""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Punkt a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Punkt""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Sverm a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Sverm""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Kurve a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Kurve""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":Flate a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/Flate""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":GM_Point a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/GM_Point""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":GM_Curve a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/GM_Curve""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":GM_Surface a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/GM_Surface""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":GM_Solid a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/GM_Solid""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":GM_MultiPoint a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/GM_MultiPoint""^^xsd:anyURI . " & vbCrLf & vbCrLf
ttlFile.Write nsprefix & ":GM_Object a owl:NamedIndividual , modelldcatno:SimpleType ;" & vbCrLf
ttlFile.Write" modelldcatno:typeDefinitionReference ""http://skjema.geonorge.no/basistype/GM_Object""^^xsd:anyURI . " & vbCrLf & vbCrLf
end sub
sub listClassProperties(ns,path,element)
dim presentasjonsnavn
dim elements as EA.Collection
dim element0 as EA.Element
dim super as EA.Element
dim datatype as EA.Element
dim subbtype as EA.Element
dim conn as EA.Collection
dim connEnd as EA.ConnectorEnd
dim i, umlnavn, definisjon, sosinavn, sositype, sosilengde, sosimin, sosimax, sosierlik, koder, prikkniv1, roleEndElementID, sosidef, selfref, subID
dim indent0, indent1, superlist, tittel, attnavn
'if element.Type = "Datatype" or (element.Type = "Class" and LCase(element.Stereotype) = "datatype" or LCase(element.Stereotype) = "union" or LCase(element.Stereotype) = "featuretype") then
if debug then Repository.WriteOutput "Script", "Debug: --------listDatatypes element.Name [" & element.Name & "] element.ElementID [" & element.ElementID & "].",0
dim attr as EA.Attribute
for each attr in element.Attributes
if getTaggedValue(attr,"SOSI_presentasjonsnavn") <> "" then
tittel = """" & utf8(getTaggedValue(attr,"SOSI_presentasjonsnavn")) & """@nb"
else
tittel = """" & utf8(attr.Name) & """@nb"
end if
if getTaggedValue(attr,"designation") <> "" then
tittel = tittel & " , " & utf8(getTaggedValue(attr,"designation"))
end if
skosFile.Write" <skos:member rdf:resource=""" & utf8(ns) & "/" & utf8(pkgNCname) & "/" & utf8(element.Name) & "/" & utf8(attr.Name) & """/>" & vbCrLf
'htmlFile.Write" <td><a href=" & utf8(path) & "/" & utf8(element.Name) & "/" & utf8(attr.Name) & "> " & utf8(toLabel(attr.Name)) & "</a></td><td>" & utf8(getCleanDefinitionText(attr.Notes)) & "</td></tr><tr>" & vbCrLf
htmlFile.Write" <td><a href=" & utf8(element.Name) & "/" & utf8(attr.Name) & "> " & utf8(toLabel(attr.Name)) & "</a></td><td>" & utf8(getCleanDefinitionText(attr.Notes)) & "</td></tr><tr>" & vbCrLf
attnavn = attr.Name
if attr.default <> "" then
attnavn = Trim(attr.Default)
end if
Call writeSkosElement(utf8(ns),path & "/" & element.Name,attnavn,utf8(getTaggedValue(attr,"SOSI_presentasjonsnavn")),utf8(getCleanDefinitionText(attr.Notes)))
Call writeHtmlElement(utf8(ns),path & "/" & element.Name & "/" & attnavn,utf8(attr.Name),utf8(getTaggedValue(attr,"SOSI_presentasjonsnavn")),utf8(getCleanDefinitionText(attr.Notes)))
if LCase(element.Stereotype) = "featuretype" or LCase(element.Stereotype) = "datatype" or LCase(element.Stereotype) = "union" then
ttlFile.Write nsprefix & ":" & utf8(element.Name) & "_" & utf8(attr.Name) & " a owl:NamedIndividual , modelldcatno:Attribute ;" & vbCrLf
if attr.ClassifierID = 0 or isBasicType(attr.Type) or isGeometryType(attr.Type) then
' if attr.ClassifierID = 0 then
' ttlFile.Write" modelldcatno:hasSimpleType http://skjema.geonorge.no/basistype/" & attr.Type & " ;" & vbCrLf
ttlFile.Write" modelldcatno:hasSimpleType " & nsprefix & ":" & utf8(attr.Type) & " ;" & vbCrLf
else
ttlFile.Write" modelldcatno:hasDataType " & nsprefix & ":" & utf8(attr.Type) & " ;" & vbCrLf
end if
ttlFile.Write" dct:description """ & utf8(getCleanDefinitionText(attr.Notes)) & """@nb ;" & vbCrLf
ttlFile.Write" dct:identifier """ & utf8(ns) & "/" & utf8(pkgNCname) & "/" & utf8(element.Name) & "/" & utf8(attr.Name) & """^^xsd:anyURI ; " & vbCrLf
ttlFile.Write" dct:title " & tittel & " ;" & vbCrLf
' ttlFile.Write" modelldcatno:typeDefinitionReference """ & utf8(ns) & "/" & utf8(pkgNCname) & "/" & utf8(element.Name) & "/" & utf8(attr.Name) & """^^xsd:anyURI ; " & vbCrLf
ttlFile.Write" xsd:maxOccurs """ & attr.UpperBound & """^^xsd:string ; " & vbCrLf
ttlFile.Write" xsd:minOccurs """ & attr.LowerBound & """^^xsd:nonNegativeInteger . " & vbCrLf & vbCrLf
end if
if LCase(element.Stereotype) = "codelist" or LCase(element.Stereotype) = "enumeration" or element.Type = "Enumeration" then
ttlFile.Write nsprefix & ":" & utf8(element.Name) & "_" & utf8(attr.Name) & " a owl:NamedIndividual , modelldcatno:CodeElement ;" & vbCrLf
ttlFile.Write" skos:definition """ & utf8(getCleanDefinitionText(attr.Notes)) & """@nb"
if getTaggedValue(attr,"definition") <> "" then
ttlFile.Write" , " & utf8(getTaggedValue(attr,"definition"))
end if
ttlFile.Write" ;" & vbCrLf
' ttlFile.Write" dct:description """"" & utf8(getCleanDefinitionText(attr.Notes)) & """@nb ;" & vbCrLf
ttlFile.Write" dct:identifier """ & utf8(ns) & "/" & utf8(pkgNCname) & "/" & utf8(element.Name) & "/" & utf8(attr.Name) & """^^xsd:anyURI ; " & vbCrLf
' ttlFile.Write" dct:title """ & utf8(getTaggedValue(attr,"SOSI_presentasjonsnavn")) & """@nb ;" & vbCrLf
' ttlFile.Write" dct:title " & tittel & " ;" & vbCrLf
ttlFile.Write" skos:prefLabel " & tittel & " ;" & vbCrLf
ttlFile.Write" skos:inScheme " & nsprefix & ":" & utf8(element.Name) & " ." & vbCrLf & vbCrLf
' ttlFile.Write" modelldcatno:typeDefinitionReference """ & utf8(ns) & "/" & utf8(pkgNCname) & "/" & utf8(element.Name) & "/" & utf8(attr.Name) & """^^xsd:anyURI . " & vbCrLf & vbCrLf
end if
next
for each conn in element.Connectors
if conn.Type = "Generalization" or conn.Type = "Realisation" or conn.Type = "NoteLink" then
sosimin= "0"
sosimax = "*"
else
umlnavn = ""
definisjon = ""
if conn.ClientID = element.ElementID then
set datatype = Repository.GetElementByID(conn.SupplierID)
umlnavn = getNCNameY(conn.SupplierEnd.Role)
definisjon = conn.SupplierEnd.RoleNote
presentasjonsnavn = getConnectorEndTaggedValue(conn.SupplierEnd,"SOSI_presentasjonsnavn")
if presentasjonsnavn = "" then
presentasjonsnavn = umlnavn
end if
if conn.SupplierEnd.Cardinality <> "" then
if Mid(conn.SupplierEnd.Cardinality,1,1) <> "*" then
sosimin = Mid(conn.SupplierEnd.Cardinality,1,1)
end if
if Mid(conn.SupplierEnd.Cardinality,Len(conn.SupplierEnd.Cardinality),1) <> "*" then
sosimax = Mid(conn.SupplierEnd.Cardinality,Len(conn.SupplierEnd.Cardinality),1)
end if
end if
else
set datatype = Repository.GetElementByID(conn.ClientID)
umlnavn = getNCNameY(conn.ClientEnd.Role)
definisjon = conn.ClientEnd.RoleNote
presentasjonsnavn = getConnectorEndTaggedValue(conn.ClientEnd,"SOSI_presentasjonsnavn")
if presentasjonsnavn = "" then
presentasjonsnavn = umlnavn
end if
if conn.ClientEnd.Cardinality <> "" then
if Mid(conn.ClientEnd.Cardinality,1,1) <> "*" then
sosimin = Mid(conn.ClientEnd.Cardinality,1,1)
end if
if Mid(conn.ClientEnd.Cardinality,Len(conn.ClientEnd.Cardinality),1) <> "*" then
sosimax = Mid(conn.ClientEnd.Cardinality,Len(conn.ClientEnd.Cardinality),1)
end if
end if
end if
if umlnavn <> "" then
skosFile.Write" <skos:member rdf:resource=""" & utf8(ns) & "/" & utf8(element.Name) &"/" & utf8(umlnavn) & """/>" & vbCrLf
htmlFile.Write" <td><a href=" & utf8(path) & "/" & utf8(element.Name) & "> " & utf8(toLabel(umlnavn)) & "</a></td><td>" & utf8(getCleanDefinitionText(definisjon)) & "</td></tr><tr>" & vbCrLf
Call writeSkosElement(utf8(ns),path & "/" & element.Name,utf8(umlnavn),utf8(presentasjonsnavn),utf8(getCleanDefinitionText(definisjon)))
Call writeHtmlElement(utf8(ns),path & "/" & element.Name & "/" & umlnavn,utf8(umlnavn),utf8(presentasjonsnavn),utf8(getCleanDefinitionText(definisjon)))
' if LCase(element.Stereotype) = "featuretype" or LCase(element.Stereotype) = "datatype" or LCase(element.Stereotype) = "union" then
' ttlFile.Write nsprefix & ":" & utf8(umlnavn) & " a owl:NamedIndividual , modelldcatno:Role ;" & vbCrLf
ttlFile.Write nsprefix & ":" & element.Name & "_" & utf8(umlnavn) & " a owl:NamedIndividual , modelldcatno:Role ;" & vbCrLf
ttlFile.Write" modelldcatno:hasDataType " & nsprefix & ":" & utf8(datatype.Name) & " ;" & vbCrLf
ttlFile.Write" dct:description """ & utf8(getCleanDefinitionText(definisjon)) & """@nb ;" & vbCrLf
ttlFile.Write" dct:identifier """ & utf8(ns) & "/" & utf8(pkgNCname) & "/" & utf8(element.Name) & "/" & utf8(umlnavn) & """^^xsd:anyURI ; " & vbCrLf
ttlFile.Write" dct:title """ & utf8(presentasjonsnavn) & """@nb ;" & vbCrLf
' ttlFile.Write" modelldcatno:typeDefinitionReference " & utf8(ns) & "/" & utf8(pkgNCname) & "/" & utf8(element.Name) & "/" & utf8(umlnavn) & """^^xsd:anyURI ; " & vbCrLf
ttlFile.Write" xsd:maxOccurs """ & sosimax & """^^xsd:string ; " & vbCrLf
ttlFile.Write" xsd:minOccurs """ & sosimin & """^^xsd:nonNegativeInteger . " & vbCrLf & vbCrLf
' end if
end if
end if
next
end sub
sub listDatatypes(ftname,element,indent)
dim presentasjonsnavn
dim elements as EA.Collection
dim element0 as EA.Element
dim super as EA.Element
dim datatype as EA.Element
dim subbtype as EA.Element
dim conn as EA.Collection
dim connEnd as EA.ConnectorEnd
dim i, umlnavn, sosinavn, sositype, sosilengde, sosimin, sosimax, sosierlik, koder, prikkniv1, roleEndElementID, sosidef, selfref, subID
dim indent0, indent1, superlist
if element.Type = "Datatype" or (element.Type = "Class" and LCase(element.Stereotype) = "datatype" or LCase(element.Stereotype) = "union" or LCase(element.Stereotype) = "featuretype") then
if debug then Repository.WriteOutput "Script", "Debug: --------listDatatypes element.Name [" & element.Name & "] element.ElementID [" & element.ElementID & "].",0
dim attr as EA.Attribute
for each attr in element.Attributes
'SessionOutput(indent & "<" & attr.Name & ">")
if getSosiGeometritype(attr) = "" then
if debug then Repository.WriteOutput "Script", "Debug: attr.Name [" & attr.Name & "] not geometry.",0
if attr.ClassifierID <> 0 and getBasicSOSIType(attr.Type) = "*" then
set datatype = Repository.GetElementByID(attr.ClassifierID)
'see if the datatype has a supertype, if so then write all its elements first - TBD
if datatype.Name = element.Name and datatype.ParentID = element.ParentID then
'if datatype.ClassifierID = element.ClassifierID then
Repository.WriteOutput "Script", "Error - circular self reference: datatype.Name [" & datatype.Name & "] from attribute name [" & element.Name & "." & attr.Name & "].",0
exit sub
else
if datatype.Type = "Enumeration" or LCase(datatype.Stereotype) = "codelist" or LCase(datatype.Stereotype) = "enumeration" then
'list first code in the list
if getTaggedValue(attr,"inlineOrByReference") = "byReference" then
'variant gml:ReferenceType
'if debug then
SessionOutput(indent & "<" & attr.Name & " xlink:href=""" & namespace & "/" & attr.Type & "/" & listCodeType(datatype) & """/>")
'SessionOutput(indent & "<" & attr.Name & " xlink:href=""" & listReferenceType(attr.Type) & """/>")
if attr.UpperBound <> "1" then
' SessionOutput(indent & "<" & attr.Name & ">" & listCodeType(datatype) & "</" & attr.Name & ">")
SessionOutput(indent & "<" & attr.Name & " xlink:href=""" & namespace & "/" & attr.Type & "/" & listCodeType(datatype) & """/>")
end if
else
'variant gml:CodeType
SessionOutput(indent & "<" & attr.Name & ">" & listCodeType(datatype) & "</" & attr.Name & ">")
if attr.UpperBound <> "1" then
SessionOutput(indent & "<" & attr.Name & ">" & listCodeType(datatype) & "</" & attr.Name & ">")
end if
end if
'listCodeType(attr)
else
SessionOutput(indent & "<" & utf8(attr.Name) & ">")
indent0 = indent & " "
SessionOutput(indent0 & "<" & utf8(datatype.Name) & ">")
indent1 = indent0 & " "
call listDatatypes(ftname, datatype,indent1)
SessionOutput(indent0 & "</" & utf8(datatype.Name) & ">")
SessionOutput(indent & "</" & utf8(attr.Name) & ">")
if attr.UpperBound <> "1" then
' write a second instance of the attribute, currently with exactly same content
' but should be made to pick a different value or the second code (TBD)
SessionOutput(indent & "<" & utf8(attr.Name) & ">")
indent0 = indent & " "
SessionOutput(indent0 & "<" & utf8(datatype.Name) & ">")
indent1 = indent0 & " "
call listDatatypes(ftname, datatype,indent1)
SessionOutput(indent0 & "</" & utf8(datatype.Name) & ">")
SessionOutput(indent & "</" & utf8(attr.Name) & ">")
end if
end if
end if
else
'base type
SessionOutput(indent & "<" & utf8(attr.Name) & ">" & listBaseType(ftname, attr.Name,attr.Type) & "</" & utf8(attr.Name) & ">")
if attr.UpperBound <> "1" then
SessionOutput(indent & "<" & utf8(attr.Name) & ">" & listBaseType(ftname, attr.Name,attr.Type) & "</" & utf8(attr.Name) & ">")
end if
end if
else
'geometry type
if debug then Repository.WriteOutput "Script", "Debug: attr.Name [" & attr.Name & "] is geometry: " & getSosiGeometritype(attr) & ".",0
SessionOutput(indent & "<" & utf8(attr.Name) & ">")
call listGeometryType(ftname, attr.Type, indent & " ")
SessionOutput(indent & "</" & utf8(attr.Name) & ">")
if attr.UpperBound <> "1" then
SessionOutput(indent & "<" & utf8(attr.Name) & ">")
call listGeometryType(ftname, attr.Type, indent & " ")
SessionOutput(indent & "</" & utf8(attr.Name) & ">")
end if
end if
'if Union then jump out of the loop after first(!) variant, this does not support well Unions having several different datatypes
if LCase(element.Stereotype) = "union" then
Exit For
end if
'SessionOutput(indent & "</" & attr.Name & ">")
next
for each conn in element.Connectors
if conn.Type = "Generalization" or conn.Type = "Realisation" or conn.Type = "NoteLink" then
else
'Repository.WriteOutput "Script", "Debug: Supplier Role.Name [" & conn.SupplierEnd.Role & "] datatypens SOSI_navn [" & getTaggedValue(Repository.GetElementByID(conn.ClientID).Name,"SOSI_navn") & "].",0
'Repository.WriteOutput "Script", "Debug: Client Role.Name [" & conn.ClientEnd.Role & "] datatypens SOSI_navn [" & getTaggedValue(Repository.GetElementByID(conn.ClientID).Name,"SOSI_navn") & "].",0
if debug then Repository.WriteOutput "Script", "Debug: Supplier Role.Name [" & conn.SupplierEnd.Role & "] datatypens navn [" & Repository.GetElementByID(conn.SupplierID).Name & "], conn.SupplierID [" & conn.SupplierID & "].",0
if debug then Repository.WriteOutput "Script", "Debug: Client Role.Name [" & conn.ClientEnd.Role & "] datatypens navn [" & Repository.GetElementByID(conn.ClientID).Name & "], conn.ClientID [" & conn.ClientID & "].",0
if conn.ClientID = element.ElementID then
if getConnectorEndTaggedValue(conn.SupplierEnd,"xsdEncodingRule") <> "notEncoded" then
set datatype = Repository.GetElementByID(conn.SupplierID)
umlnavn = conn.SupplierEnd.Role
if conn.ClientEnd.Aggregation = 2 and conn.SupplierID <> conn.ClientID then
'composition+mandatory->nest as datatype inline?
SessionOutput(indent & "<" & utf8(umlnavn) & ">")
indent0 = indent & " "
' ' SessionOutput(indent0 & "<" & utf8(datatype.Name) & ">")
indent1 = indent0 & " "
if datatype.Abstract = 1 then
'must move down to make an example of a instanciable subtype of the class pointed to TODO, NB needed on mandatory attributes!
call getFirstConcreteSubtypeName(datatype,subID)
set subbtype = Repository.GetElementByID(subID)
SessionOutput(indent0 & "<" & utf8(subbtype.Name) & ">")
call listDatatypes(ftname, subbtype,indent1)
SessionOutput(indent0 & "</" & utf8(subbtype.Name) & ">")
else
SessionOutput(indent0 & "<" & utf8(datatype.Name) & ">")
call listDatatypes(ftname, datatype,indent1)
SessionOutput(indent0 & "</" & utf8(datatype.Name) & ">")
end if
' call listDatatypes(ftname, datatype,indent1)
' ' SessionOutput(indent0 & "</" & utf8(datatype.Name) & ">")
SessionOutput(indent & "</" & utf8(umlnavn) & ">")
if conn.SupplierEnd.Cardinality <> "0..1" and conn.SupplierEnd.Cardinality <> "1..1" and conn.SupplierEnd.Cardinality <> "1" then
SessionOutput(indent & "<" & utf8(umlnavn) & ">")
indent0 = indent & " "
SessionOutput(indent0 & "<" & utf8(datatype.Name) & ">")
indent1 = indent0 & " "
if datatype.Abstract = 1 then
'must move down to make an example of a instanciable subtype of the class pointed to TODO, NB needed on mandatory attributes!
call getFirstConcreteSubtypeName(datatype,subID)
set subbtype = Repository.GetElementByID(subID)
call listDatatypes(ftname, subbtype,indent1)
else
call listDatatypes(ftname, datatype,indent1)
end if
SessionOutput(indent0 & "</" & utf8(datatype.Name) & ">")
SessionOutput(indent & "</" & utf8(umlnavn) & ">")
end if
else
if conn.SupplierEnd.Navigable = "Navigable" then
'self assoc? if so make xlinks to other (imaginary) instances of the same class
selfref = 1
if datatype.Name = element.Name and datatype.ElementID = element.ElementID then
selfref = 2
end if
'navigable->make xlink?
if datatype.Abstract = 1 then
'must move down to make an example of a instanciable subtype of the class pointed to TODO, NB needed on mandatory attributes!
SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(getFirstConcreteSubtypeName(datatype,subID)) & "." & selfref & """/>")
else
SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(datatype.Name) & "." & selfref & """/>")
end if
' SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(datatype.Name) & "." & selfref & """/>")
if debug then Repository.WriteOutput "Script", "Debug: SupplierEnd.Cardinality [" & conn.SupplierEnd.Cardinality & "].",0
if conn.SupplierEnd.Cardinality <> "0..1" and conn.SupplierEnd.Cardinality <> "1..1" and conn.SupplierEnd.Cardinality <> "1" then
if datatype.Abstract = 1 then
'must move down to make an example of a instanciable subtype of the class pointed to TODO, NB needed on mandatory attributes!
SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(getFirstConcreteSubtypeName(datatype,subID)) & "." & selfref + 1 & """/>")
else
SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(datatype.Name) & "." & selfref + 1 & """/>")
end if
end if
end if
end if
end if
else
if getConnectorEndTaggedValue(conn.ClientEnd,"xsdEncodingRule") <> "notEncoded" then
set datatype = Repository.GetElementByID(conn.ClientID)
umlnavn = conn.ClientEnd.Role
if conn.SupplierEnd.Aggregation = 2 then
'composition+mandatory->nest as datatype inline?
SessionOutput(indent & "<" & utf8(umlnavn) & ">")
indent0 = indent & " "
SessionOutput(indent0 & "<" & utf8(datatype.Name) & ">")
indent1 = indent0 & " "
call listDatatypes(ftname, datatype,indent1)
SessionOutput(indent0 & "</" & utf8(datatype.Name) & ">")
SessionOutput(indent & "</" & utf8(umlnavn) & ">")
if conn.ClientEnd.Cardinality <> "0..1" and conn.ClientEnd.Cardinality <> "1..1" and conn.ClientEnd.Cardinality <> "1" then
SessionOutput(indent & "<" & utf8(umlnavn) & ">")
indent0 = indent & " "
SessionOutput(indent0 & "<" & utf8(datatype.Name) & ">")
indent1 = indent0 & " "
if datatype.Abstract = 1 then
'must move down to make an example of a instanciable subtype of the class pointed to TODO, NB needed on mandatory attributes!
call getFirstConcreteSubtypeName(datatype,subID)
set subbtype = Repository.GetElementByID(subID)
call listDatatypes(ftname, subbtype,indent1)
else
call listDatatypes(ftname, datatype,indent1)
end if
SessionOutput(indent0 & "</" & utf8(datatype.Name) & ">")
SessionOutput(indent & "</" & utf8(umlnavn) & ">")
end if
else
if conn.ClientEnd.Navigable = "Navigable" then
'self assoc? if so make xlinks to other (imaginary) instances of the same class
selfref = 1
if datatype.Name = element.Name and datatype.ElementID = element.ElementID then
selfref = 2
end if
'navigable->make xlink?
SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(datatype.Name) & "." & selfref & """/>")
if debug then Repository.WriteOutput "Script", "Debug: ClientEnd.Cardinality [" & conn.ClientEnd.Cardinality & "].",0
if conn.ClientEnd.Cardinality <> "0..1" and conn.ClientEnd.Cardinality <> "1..1" and conn.ClientEnd.Cardinality <> "1" then
if datatype.Abstract = 1 then
'must move down to make an example of a instanciable subtype of the class pointed to TODO, NB needed on mandatory attributes!
SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(getFirstConcreteSubtypeName(datatype,subID)) & "." & selfref + 1 & """/>")
else
SessionOutput(indent & "<" & utf8(umlnavn) & " xlink:href=""#" & utf8(datatype.Name) & "." & selfref + 1 & """/>")
end if
end if
end if
end if
end if
end if
end if
next
end if
end sub
function listBaseType(ftname,umlname, umltype)
listBaseType = "*"
if umltype = "CharacterString" then
if umlname = "navnerom" or umlname = "namespace" then
listBaseType = "http://data.geonorge.no/SOSI/" & Kortnavn
else
if umlname = "lokalId" or umlname = "localId" then
listBaseType = ftname & ".1"
else
listBaseType = "Some text"
end if
end if
end if
if umltype = "Boolean" then
listBaseType = "true"
end if
if umltype = "Date" then
listBaseType = "2019-05-04"
end if
if umltype = "DateTime" then
listBaseType = "2019-05-04T21:08:00Z"
end if
if umltype = "Integer" then
listBaseType = "42"
end if
if umltype = "Real" then
listBaseType = "92.92"
end if
end function
function listCodeType(element)
listCodeType = "*"
dim attr as EA.Attribute
for each attr in element.Attributes
listCodeType = attr.Name
if attr.Default <> "" then listCodeType = attr.Default
exit for
next
end function
sub listGeometryType(elementName, geomtype, indent)
if geomtype = "Punkt" or geomtype = "GM_Point" then
pnteller = pnteller + 1
SessionOutput(indent & "<gml:Point gml:id=""" & elementName & ".pn." & pnteller & """ srsName=""http://www.opengis.net/def/crs/epsg/0/4258"">")
SessionOutput(indent & " <gml:pos>60.02 10.1</gml:pos>")
SessionOutput(indent & "</gml:Point>")
end if
if geomtype = "Sverm" or geomtype = "GM_MultiPoint" then
'getSosiGeometritype = "SVERM"
end if
if geomtype = "Kurve" or geomtype = "GM_Curve" or geomtype = "GM_CompositeCurve" then
cuteller = cuteller + 1
' SessionOutput(indent & "<gml:Curve gml:id = """ & elementName & ".cu." & cuteller & """ srsName=""http://www.opengis.net/def/crs/epsg/0/4258"">")
' SessionOutput(indent & " <gml:segments>
' SessionOutput(indent & " <gml:LineStringSegment>
' SessionOutput(indent & " <gml:posList>60.02 10.1 60.02 10.3 60.03 10.2</gml:posList>")
' SessionOutput(indent & " </gml:LineStringSegment>
' SessionOutput(indent & " </gml:segments>
' SessionOutput(indent & "</gml:Curve>
SessionOutput(indent & "<gml:LineString gml:id=""" & elementName & ".cu." & cuteller & """ srsName=""http://www.opengis.net/def/crs/epsg/0/4258"">")
SessionOutput(indent & " <gml:posList>60.02 10.1 60.02 10.3 60.03 10.2</gml:posList>")
SessionOutput(indent & "</gml:LineString>")
end if
if geomtype = "Flate" or geomtype = "GM_Surface" or geomtype = "GM_CompositeSurface" then
' SessionOutput(indent & "<gml:Surface gml:id = """ & elementName & ".su.1"" srsName=""http://www.opengis.net/def/crs/epsg/0/4258"">")
suteller = suteller + 1
SessionOutput(indent & "<gml:Polygon gml:id=""" & elementName & ".su." & suteller & """ srsName=""http://www.opengis.net/def/crs/epsg/0/4258"">")
SessionOutput(indent & " <gml:exterior>")
SessionOutput(indent & " <gml:LinearRing>")
SessionOutput(indent & " <gml:posList>60.02 10.1 60.02 10.3 60.03 10.2 60.02 10.1</gml:posList>")
SessionOutput(indent & " </gml:LinearRing>")
SessionOutput(indent & " </gml:exterior>")
SessionOutput(indent & "</gml:Polygon>")
' SessionOutput(indent & "</gml:Surface>")
end if
if geomtype = "GM_Solid" or geomtype = "GM_CompositeSolid" then
'getSosiGeometritype = "NO GO"
dim height
height = 6.0
call generateSolidExample(elementName, indent, height)
end if
if geomtype = "GM_Object" or geomtype = "GM_Primitive" then
obteller = obteller + 1
SessionOutput(indent & "<gml:Point gml:id=""" & elementName & ".ob." & obteller & """ srsName=""http://www.opengis.net/def/crs/epsg/0/4258"">")
SessionOutput(indent & " <gml:pos>60.02 10.1</gml:pos>")
SessionOutput(indent & "</gml:Point>")
end if
end sub
function isBasicType(dtype)
isBasicType = false
if dtype = "Integer" or dtype = "Real" or dtype = "CharacterString" or dtype = "Boolean" or dtype = "Date" or dtype = "DateTime" or dtype = "Uri" or dtype = "LanguageString" then