skos2html 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/skos2html.rb +305 -285
- metadata +1 -1
data/lib/skos2html.rb
CHANGED
@@ -1,93 +1,94 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
2
|
+
#
|
3
|
+
module Skos2Html
|
4
|
+
require 'linkeddata'
|
5
|
+
require 'logger'
|
6
|
+
require 'builder'
|
7
|
+
|
8
|
+
# Converts a SKOS RDF file to a bare-bones HTML file
|
9
|
+
# readabale for humans. Rendering a HTML file consists of
|
10
|
+
# three basic steps:
|
11
|
+
# 1. Create a new instance of this class and specify input and output file.
|
12
|
+
# 2. Call load_and_parse.
|
13
|
+
# 3. Call generate_html_document.
|
14
|
+
# 4. Call the write method.
|
15
|
+
class Converter
|
16
|
+
|
17
|
+
# The output buffer to which we write all HTML.
|
18
|
+
attr_accessor :buffer
|
19
|
+
|
20
|
+
# Initialize the class.
|
21
|
+
#
|
22
|
+
# @param infile [String], a filepath to a SKOS RDF/XML file
|
23
|
+
# @param outfile [String], a filepath where the resulting file will be written (overwriting existing files)
|
24
|
+
def initialize(infile=nil, outfile="vocab.html")
|
25
|
+
@log = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
26
|
+
@log.info("init")
|
27
|
+
|
28
|
+
@infile = infile
|
29
|
+
@outfile = outfile
|
30
|
+
|
31
|
+
@default_lang = :en
|
32
|
+
|
33
|
+
@graph = nil
|
34
|
+
@vocabs = nil
|
35
|
+
set_up_vocabs
|
36
|
+
|
37
|
+
@buffer = ""
|
38
|
+
@builder = Builder::XmlMarkup.new(:target=>@buffer, :indent=>2)
|
39
|
+
|
40
|
+
@title = ""
|
5
41
|
|
42
|
+
end
|
6
43
|
|
7
|
-
# Converts a SKOS RDF file to a bare-bones HTML file
|
8
|
-
# readabale for humans. Rendering a HTML file consists of
|
9
|
-
# three basic steps:
|
10
|
-
# 1. Create a new instance of this class and specify input and output file.
|
11
|
-
# 2. Call load_and_parse.
|
12
|
-
# 3. Call generate_html_document.
|
13
|
-
# 4. Call the write method.
|
14
|
-
class Skos2Html
|
15
|
-
|
16
|
-
# The output buffer to which we write all HTML.
|
17
|
-
attr_accessor :buffer
|
18
|
-
|
19
|
-
# Initialize the class.
|
20
|
-
#
|
21
|
-
# @param infile [String], a filepath to a SKOS RDF/XML file
|
22
|
-
# @param outfile [String], a filepath where the resulting file will be written (overwriting existing files)
|
23
|
-
def initialize(infile=nil, outfile="vocab.html")
|
24
|
-
@log = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
25
|
-
@log.info("init")
|
26
|
-
|
27
|
-
@infile = infile
|
28
|
-
@outfile = outfile
|
29
|
-
|
30
|
-
@default_lang = :en
|
31
|
-
|
32
|
-
@graph = nil
|
33
|
-
@vocabs = nil
|
34
|
-
set_up_vocabs
|
35
|
-
|
36
|
-
@buffer = ""
|
37
|
-
@builder = Builder::XmlMarkup.new(:target=>@buffer, :indent=>2)
|
38
|
-
|
39
|
-
@title = ""
|
40
44
|
|
41
|
-
|
45
|
+
# Load some basic vocabularies in order to retrieve labels
|
46
|
+
# etc.
|
47
|
+
def set_up_vocabs
|
48
|
+
@vocabs = RDF::Graph.load(File.expand_path("skos.rdf", File.dirname(__FILE__)))
|
49
|
+
@vocabs << RDF::Graph.load(File.expand_path("dcterms.rdf", File.dirname(__FILE__)))
|
50
|
+
@vocabs << RDF::Graph.load(File.expand_path("rdf-schema.rdf", File.dirname(__FILE__)))
|
51
|
+
end
|
42
52
|
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
def set_up_vocabs
|
47
|
-
@vocabs = RDF::Graph.load(File.expand_path("skos.rdf", File.dirname(__FILE__)))
|
48
|
-
@vocabs << RDF::Graph.load(File.expand_path("dcterms.rdf", File.dirname(__FILE__)))
|
49
|
-
@vocabs << RDF::Graph.load(File.expand_path("rdf-schema.rdf", File.dirname(__FILE__)))
|
50
|
-
end
|
54
|
+
# Load the SKOS RDF file into a graph object.
|
55
|
+
def load_and_parse
|
51
56
|
|
57
|
+
if @infile
|
58
|
+
@graph = RDF::Graph.load(@infile)
|
59
|
+
end
|
52
60
|
|
53
|
-
# Load the SKOS RDF file into a graph object.
|
54
|
-
def load_and_parse
|
55
|
-
|
56
|
-
if @infile
|
57
|
-
@graph = RDF::Graph.load(@infile)
|
58
61
|
end
|
59
62
|
|
60
|
-
end
|
61
|
-
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
def generate_html_document
|
65
|
+
@builder.declare! :DOCTYPE, :html
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
@builder.html(:lang => @default_lang) { |html|
|
68
|
+
generate_html_head
|
69
|
+
generate_html_body
|
70
|
+
}
|
71
|
+
end
|
71
72
|
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
def generate_html_body
|
75
|
+
@builder.body { |body|
|
76
|
+
generate_conceptscheme_info
|
77
|
+
generate_concepts
|
78
|
+
}
|
79
|
+
end
|
79
80
|
|
80
81
|
|
81
|
-
|
82
|
+
def generate_html_head
|
82
83
|
|
83
|
-
|
84
|
+
title = concept_scheme_title
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
@builder.head { |head|
|
87
|
+
head.meta(:charset => "UTF-8")
|
88
|
+
head.title(title)
|
89
|
+
head.meta(:name => "generator", :content => "skos2html")
|
90
|
+
head.comment! "Edit styles and other html in this file as you like but do not change text or id-attributes."
|
91
|
+
head.style("""
|
91
92
|
html {
|
92
93
|
margin: auto;
|
93
94
|
max-width: 800px;
|
@@ -122,343 +123,362 @@ div.conceptscheme {
|
|
122
123
|
div.concept {
|
123
124
|
margin: 0 0 2.5em 0;
|
124
125
|
}
|
125
|
-
|
126
|
-
|
126
|
+
""")
|
127
|
+
}
|
127
128
|
|
128
|
-
|
129
|
+
end
|
129
130
|
|
130
131
|
|
131
132
|
|
132
|
-
|
133
|
+
def labels_for(uri)
|
133
134
|
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
solutions = RDF::Query.execute(@vocabs) do
|
136
|
+
pattern [RDF::URI.new(uri), RDF::RDFS.label, :label]
|
137
|
+
end
|
137
138
|
|
138
|
-
|
139
|
+
result = []
|
139
140
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
141
|
+
if solutions
|
142
|
+
solutions.each do |solution|
|
143
|
+
# adding RDF literals
|
144
|
+
result << solution.label
|
145
|
+
end
|
144
146
|
end
|
145
|
-
end
|
146
147
|
|
147
|
-
|
148
|
-
|
148
|
+
return result
|
149
|
+
end
|
149
150
|
|
150
151
|
|
151
152
|
|
152
|
-
|
153
|
-
|
154
|
-
|
153
|
+
def string_for(obj, lang)
|
154
|
+
# return a human readable representation of obj - for literals the literal
|
155
|
+
# value in lang. For URI:s lookup something.
|
155
156
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
157
|
+
case obj
|
158
|
+
when String
|
159
|
+
return obj
|
160
|
+
when RDF::Literal
|
161
|
+
if lang
|
162
|
+
if obj.language == lang
|
163
|
+
return obj.to_s
|
164
|
+
else
|
165
|
+
return "[Not available in #{lang}]"
|
166
|
+
end
|
163
167
|
else
|
164
|
-
return
|
168
|
+
return obj.to_s
|
165
169
|
end
|
170
|
+
when RDF::URI
|
171
|
+
# TODO: fetch it...
|
172
|
+
return "[fetched label for #{obj.to_s}]"
|
166
173
|
else
|
167
|
-
|
174
|
+
@log.info("unknown class")
|
168
175
|
end
|
169
|
-
when RDF::URI
|
170
|
-
# TODO: fetch it...
|
171
|
-
return "[fetched label for #{obj.to_s}]"
|
172
|
-
else
|
173
|
-
@log.info("unknown class")
|
174
176
|
end
|
175
|
-
end
|
176
177
|
|
177
178
|
|
178
179
|
|
179
|
-
|
180
|
+
def label_for(uri, lang)
|
180
181
|
|
181
|
-
|
182
|
+
@log.info("label_for #{uri} #{lang}")
|
182
183
|
|
183
|
-
|
184
|
+
labels = labels_for(uri)
|
184
185
|
|
185
|
-
|
186
|
+
@log.info("labels: #{labels.inspect}")
|
186
187
|
|
187
|
-
|
188
|
-
|
188
|
+
if labels
|
189
|
+
labels.each do |label|
|
189
190
|
|
190
|
-
|
191
|
+
@log.info("label: #{label}")
|
191
192
|
|
192
|
-
|
193
|
-
|
193
|
+
if label.language == lang
|
194
|
+
return label.value
|
195
|
+
end
|
194
196
|
end
|
195
197
|
end
|
196
198
|
end
|
197
|
-
end
|
198
199
|
|
199
200
|
|
200
|
-
|
201
|
+
def generate_conceptscheme_info
|
201
202
|
|
202
|
-
|
203
|
-
|
204
|
-
|
203
|
+
conceptschemes = RDF::Query.execute(@graph) do
|
204
|
+
pattern [:scheme, RDF.type, RDF::SKOS.ConceptScheme]
|
205
|
+
end
|
205
206
|
|
206
207
|
|
207
|
-
|
208
|
+
@log.info("Concept scheme count #{conceptschemes.size}")
|
208
209
|
|
209
210
|
|
210
|
-
|
211
|
+
if conceptschemes.size == 1
|
211
212
|
|
212
|
-
|
213
|
-
|
213
|
+
scheme = conceptschemes[0]
|
214
|
+
@log.info("Concept scheme " + scheme.scheme)
|
214
215
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
title = ""
|
220
|
-
description = ""
|
221
|
-
creators = []
|
222
|
-
contributors = []
|
216
|
+
scheme_info = RDF::Query.execute(@graph) do
|
217
|
+
pattern [scheme.scheme, :predicate, :object]
|
218
|
+
end
|
223
219
|
|
224
|
-
|
225
|
-
|
220
|
+
title = ""
|
221
|
+
description = ""
|
222
|
+
creators = []
|
223
|
+
contributors = []
|
224
|
+
version = nil
|
225
|
+
|
226
|
+
# get values
|
227
|
+
scheme_info.each do |solution|
|
228
|
+
|
229
|
+
case solution.predicate
|
230
|
+
when "http://purl.org/dc/terms/title", "http://www.w3.org/2000/01/rdf-schema#label"
|
231
|
+
title = string_for(solution.object, @default_lang)
|
232
|
+
when "http://purl.org/dc/terms/description"
|
233
|
+
description = string_for(solution.object, @default_lang)
|
234
|
+
when "http://purl.org/dc/terms/contributor"
|
235
|
+
contributors << string_for(solution.object, nil)
|
236
|
+
when "http://purl.org/dc/terms/creator"
|
237
|
+
creators << string_for(solution.object, nil)
|
238
|
+
end
|
226
239
|
|
227
|
-
case solution.predicate
|
228
|
-
when "http://purl.org/dc/terms/title", "http://www.w3.org/2000/01/rdf-schema#label"
|
229
|
-
title = string_for(solution.object, @default_lang)
|
230
|
-
when "http://purl.org/dc/terms/description"
|
231
|
-
description = string_for(solution.object, @default_lang)
|
232
|
-
when "http://purl.org/dc/terms/contributor"
|
233
|
-
contributors << string_for(solution.object, nil)
|
234
|
-
when "http://purl.org/dc/terms/creator"
|
235
|
-
creators << string_for(solution.object, nil)
|
236
240
|
end
|
237
241
|
|
238
|
-
|
239
|
-
|
240
|
-
@builder.div(:class => "conceptscheme") { |html|
|
242
|
+
@builder.div(:class => "conceptscheme") { |html|
|
241
243
|
|
242
|
-
|
244
|
+
html.h1(title)
|
243
245
|
|
244
|
-
|
246
|
+
html.dl { |html|
|
245
247
|
|
246
|
-
|
247
|
-
|
248
|
+
html.dt("Description")
|
249
|
+
html.dd(description, "class" => "description")
|
248
250
|
|
249
|
-
|
250
|
-
|
251
|
+
if contributors.size > 0
|
252
|
+
html.dt("Contributors")
|
251
253
|
|
252
|
-
|
253
|
-
|
254
|
+
contributors.each do |item|
|
255
|
+
html.dd(item, "class" => "contributor")
|
256
|
+
end
|
254
257
|
end
|
255
|
-
end
|
256
258
|
|
257
|
-
|
258
|
-
|
259
|
+
if creators.size > 0
|
260
|
+
html.dt("Creators")
|
259
261
|
|
260
|
-
|
261
|
-
|
262
|
+
creators.each do |item|
|
263
|
+
html.dd(item, "class" => "creator")
|
264
|
+
end
|
262
265
|
end
|
263
|
-
end
|
264
266
|
|
267
|
+
html.dt("Identifier")
|
268
|
+
html.dd(scheme.scheme, :class => "identifier")
|
269
|
+
|
270
|
+
}
|
265
271
|
}
|
266
|
-
}
|
267
272
|
|
268
|
-
|
269
|
-
|
273
|
+
else
|
274
|
+
@log.info("Concept scheme count wrong. Expected 1 was " + conceptschemes.size)
|
275
|
+
end
|
276
|
+
|
270
277
|
end
|
271
278
|
|
272
|
-
end
|
273
279
|
|
274
280
|
|
281
|
+
def generate_concepts
|
282
|
+
concepts = RDF::Query.execute(@graph) do
|
283
|
+
pattern [:concept_uri, RDF.type, RDF::SKOS.Concept]
|
284
|
+
end
|
275
285
|
|
276
|
-
|
277
|
-
concepts = RDF::Query.execute(@graph) do
|
278
|
-
pattern [:concept_uri, RDF.type, RDF::SKOS.Concept]
|
279
|
-
end
|
286
|
+
@log.info("Concept count: #{concepts.size}")
|
280
287
|
|
281
|
-
|
288
|
+
concepts.each do |concept|
|
289
|
+
generate_concept(concept.concept_uri)
|
290
|
+
end
|
282
291
|
|
283
|
-
concepts.each do |concept|
|
284
|
-
generate_concept(concept.concept_uri)
|
285
292
|
end
|
286
293
|
|
287
|
-
end
|
288
|
-
|
289
294
|
|
290
295
|
|
291
296
|
|
292
|
-
|
293
|
-
|
294
|
-
|
297
|
+
# Get the title of this vocabulary for use in the HTML
|
298
|
+
# title element
|
299
|
+
def concept_scheme_title
|
295
300
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
301
|
+
# Possible properties
|
302
|
+
title_properties = ["http://purl.org/dc/terms/title",
|
303
|
+
"http://www.w3.org/2000/01/rdf-schema#label",
|
304
|
+
"http://www.w3.org/2004/02/skos/core#prefLabel"]
|
300
305
|
|
301
|
-
|
306
|
+
title = ""
|
302
307
|
|
303
|
-
|
304
|
-
|
305
|
-
|
308
|
+
conceptschemes = RDF::Query.execute(@graph) do
|
309
|
+
pattern [:scheme, RDF.type, RDF::SKOS.ConceptScheme]
|
310
|
+
end
|
306
311
|
|
307
|
-
|
312
|
+
if conceptschemes.size == 1
|
308
313
|
|
309
|
-
|
310
|
-
|
314
|
+
scheme = conceptschemes[0]
|
315
|
+
@log.info("Looking for title for " + scheme.scheme)
|
311
316
|
|
312
|
-
|
313
|
-
|
314
|
-
|
317
|
+
scheme_info = RDF::Query.execute(@graph) do
|
318
|
+
pattern [scheme.scheme, :predicate, :object]
|
319
|
+
end
|
315
320
|
|
316
|
-
|
321
|
+
scheme_info.each do |solution|
|
317
322
|
|
318
|
-
|
319
|
-
|
320
|
-
|
323
|
+
case solution.predicate.to_s
|
324
|
+
when *title_properties
|
325
|
+
title = solution.object.value
|
326
|
+
end
|
321
327
|
end
|
322
|
-
end
|
323
328
|
|
324
|
-
|
329
|
+
return title
|
325
330
|
|
326
|
-
|
331
|
+
end
|
327
332
|
|
328
|
-
|
333
|
+
end
|
329
334
|
|
330
335
|
|
331
336
|
|
332
|
-
|
337
|
+
def concept_preflabel(concept_uri)
|
333
338
|
|
334
|
-
|
339
|
+
uri = RDF::URI.new(concept_uri)
|
335
340
|
|
336
|
-
|
337
|
-
|
338
|
-
|
341
|
+
labels = RDF::Query.execute(@graph) do
|
342
|
+
pattern [uri, RDF::SKOS.prefLabel, :object]
|
343
|
+
end
|
339
344
|
|
340
|
-
|
345
|
+
labels.filter { |label| label.object.language == @default_lang }
|
341
346
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
+
if labels.size > 0
|
348
|
+
return labels[0].object.value
|
349
|
+
else
|
350
|
+
@log.error("Preflabel missing for #{concept_uri}")
|
351
|
+
return ""
|
352
|
+
end
|
347
353
|
end
|
348
|
-
end
|
349
354
|
|
350
355
|
|
351
356
|
|
352
|
-
|
353
|
-
|
357
|
+
# Generate the HTML for an individual concept.
|
358
|
+
def generate_concept(concept_uri)
|
354
359
|
|
355
|
-
|
360
|
+
@log.info("Generate concept #{concept_uri}")
|
356
361
|
|
357
|
-
|
358
|
-
|
359
|
-
|
362
|
+
concept_info = RDF::Query.execute(@graph) do
|
363
|
+
pattern [concept_uri, :predicate, :object]
|
364
|
+
end
|
360
365
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
+
preflabels = []
|
367
|
+
altlabels = []
|
368
|
+
definition = ""
|
369
|
+
has_broader = nil
|
370
|
+
has_narrower = nil
|
371
|
+
editorialNote = nil
|
366
372
|
|
367
|
-
|
373
|
+
concept_info.each do |solution|
|
368
374
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
375
|
+
case solution.predicate
|
376
|
+
when "http://www.w3.org/2004/02/skos/core#prefLabel"
|
377
|
+
if solution.object.language?
|
378
|
+
preflabels << {"lang" => solution.object.language.to_sym, "val" => solution.object.to_s}
|
379
|
+
else
|
380
|
+
preflabels << {"lang" => nil, "val" => solution.object.to_s}
|
381
|
+
end
|
382
|
+
when "http://www.w3.org/2004/02/skos/core#altLabel"
|
383
|
+
if solution.object.language?
|
384
|
+
altlabels << {"lang" => solution.object.language.to_sym, "val" => solution.object.to_s}
|
385
|
+
else
|
386
|
+
altlabels << {"lang" => nil, "val" => solution.object.to_s}
|
387
|
+
end
|
388
|
+
when "http://www.w3.org/2004/02/skos/core#definition"
|
389
|
+
definition = string_for(solution.object, @default_lang)
|
390
|
+
when "http://www.w3.org/2004/02/skos/core#editorialNote"
|
391
|
+
editorialNote = string_for(solution.object, @default_lang)
|
392
|
+
when "http://www.w3.org/2004/02/skos/core#broader"
|
393
|
+
has_broader = solution.object.value
|
394
|
+
when "http://www.w3.org/2004/02/skos/core#narrower"
|
395
|
+
has_narrower = solution.object.value
|
381
396
|
end
|
382
|
-
|
383
|
-
definition = string_for(solution.object, @default_lang)
|
384
|
-
when "http://www.w3.org/2004/02/skos/core#broader"
|
385
|
-
has_broader = solution.object.value
|
386
|
-
when "http://www.w3.org/2004/02/skos/core#narrower"
|
387
|
-
has_narrower = solution.object.value
|
397
|
+
|
388
398
|
end
|
389
399
|
|
390
|
-
end
|
391
400
|
|
401
|
+
@builder.div(:id => concept_uri.fragment, :class => "concept") { |html|
|
402
|
+
# preflabel in defaultlang
|
403
|
+
html.h2(preflabels.detect {|label| label["lang"] == @default_lang}["val"])
|
404
|
+
html.dl {
|
405
|
+
html.dt("Definition", :class => "definition")
|
406
|
+
html.dd(definition, :class => "definition")
|
392
407
|
|
393
|
-
|
394
|
-
|
395
|
-
html.h2(preflabels.detect {|label| label["lang"] == @default_lang}["val"])
|
396
|
-
html.dl {
|
397
|
-
html.dt("Definition", :class => "definition")
|
398
|
-
html.dd(definition, :class => "definition")
|
408
|
+
if altlabels.size > 0
|
409
|
+
html.dt("Alternative labels", {:class => "altlabels"})
|
399
410
|
|
400
|
-
|
401
|
-
html.dt("Alternative labels", {:class => "altlabels"})
|
411
|
+
altlabels.each do |label|
|
402
412
|
|
403
|
-
|
413
|
+
if label["lang"]
|
404
414
|
|
405
|
-
|
415
|
+
if label["lang"] != @default_lang
|
416
|
+
html.dd(label["val"] + "(#{label['lang']})", :lang => label["lang"], :class => "altlabel")
|
417
|
+
else
|
418
|
+
html.dd(label["val"], :class => "altlabel")
|
419
|
+
end
|
406
420
|
|
407
|
-
if label["lang"] != @default_lang
|
408
|
-
html.dd(label["val"] + "(#{label['lang']})", :lang => label["lang"], :class => "altlabel")
|
409
421
|
else
|
410
422
|
html.dd(label["val"], :class => "altlabel")
|
411
423
|
end
|
412
|
-
|
413
|
-
else
|
414
|
-
html.dd(label["val"], :class => "altlabel")
|
415
424
|
end
|
416
425
|
end
|
417
|
-
end
|
418
426
|
|
419
427
|
|
420
|
-
|
428
|
+
if has_broader
|
421
429
|
|
422
|
-
|
430
|
+
has_broader_uri = has_broader
|
431
|
+
|
432
|
+
unless has_broader.start_with?("http://")
|
433
|
+
r = RDF::URI.new(concept_uri)
|
434
|
+
r.fragment = has_broader[1..-1]
|
435
|
+
has_broader_uri = r.to_s
|
436
|
+
end
|
423
437
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
438
|
+
html.dt("Has broader", :class => "broader")
|
439
|
+
html.dd(:class => "broader") {
|
440
|
+
html.a(concept_preflabel(has_broader_uri), :href => has_broader)
|
441
|
+
}
|
428
442
|
end
|
429
443
|
|
430
|
-
html.dt("Has broader", :class => "broader")
|
431
|
-
html.dd(:class => "broader") {
|
432
|
-
html.a(concept_preflabel(has_broader_uri), :href => has_broader)
|
433
|
-
}
|
434
|
-
end
|
435
444
|
|
445
|
+
if has_narrower
|
436
446
|
|
437
|
-
|
438
|
-
html.dt("Has narrower", :class => "narrower")
|
439
|
-
html.dd(:class => "narrower") {
|
440
|
-
html.a(has_narrower, :href => has_narrower)
|
441
|
-
}
|
442
|
-
end
|
447
|
+
has_narrower_uri = has_narrower
|
443
448
|
|
449
|
+
unless has_narrower.start_with?("http://")
|
450
|
+
r = RDF::URI.new(concept_uri)
|
451
|
+
r.fragment = has_narrower[1..-1]
|
452
|
+
has_narrower_uri = r.to_s
|
453
|
+
end
|
454
|
+
html.dt("Has narrower", :class => "narrower")
|
455
|
+
html.dd(:class => "narrower") {
|
456
|
+
html.a(concept_preflabel(has_narrower_uri), :href => has_narrower)
|
457
|
+
}
|
458
|
+
end
|
444
459
|
|
445
|
-
|
446
|
-
|
460
|
+
if editorialNote
|
461
|
+
html.dt(label_for(RDF::SKOS.editorialNote, @default_lang))
|
462
|
+
html.dd(editorialNote, :class => "editorial_note")
|
463
|
+
end
|
464
|
+
|
465
|
+
html.dt("Identifier", :class => "identifier")
|
466
|
+
html.dd(concept_uri, :class => "identifier")
|
467
|
+
}
|
447
468
|
}
|
448
|
-
}
|
449
469
|
|
450
|
-
|
470
|
+
end
|
451
471
|
|
452
472
|
|
453
473
|
|
454
|
-
|
455
|
-
|
474
|
+
# Write the output to disk as an UTF-8 encoded file.
|
475
|
+
def write
|
456
476
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
477
|
+
# output to disk
|
478
|
+
File.open(@outfile, 'w:UTF-8') { |file|
|
479
|
+
file.write(@buffer)
|
480
|
+
}
|
481
|
+
end
|
462
482
|
|
483
|
+
end
|
463
484
|
end
|
464
|
-
|