libis-tools 0.9.9 → 0.9.10

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -2
  3. data/README.md +19 -0
  4. data/lib/libis/tools.rb +1 -0
  5. data/lib/libis/tools/config_file.rb +1 -1
  6. data/lib/libis/tools/extend/kernel.rb +16 -0
  7. data/lib/libis/tools/metadata.rb +20 -0
  8. data/lib/libis/tools/metadata/dublin_core_record.rb +1 -1
  9. data/lib/libis/tools/metadata/{field_spec.rb → field_format.rb} +7 -7
  10. data/lib/libis/tools/metadata/fix_field.rb +6 -1
  11. data/lib/libis/tools/metadata/mapper.rb +80 -0
  12. data/lib/libis/tools/metadata/mappers/flandrica.rb +69 -0
  13. data/lib/libis/tools/metadata/mappers/kuleuven.rb +1702 -0
  14. data/lib/libis/tools/metadata/marc21_record.rb +5 -4
  15. data/lib/libis/tools/metadata/marc_record.rb +96 -37
  16. data/lib/libis/tools/metadata/parser/basic_parser.rb +118 -0
  17. data/lib/libis/tools/metadata/parser/dublin_core_parser.rb +36 -0
  18. data/lib/libis/tools/metadata/parser/marc21_parser.rb +206 -0
  19. data/lib/libis/tools/metadata/parser/marc_format_parser.rb +52 -0
  20. data/lib/libis/tools/metadata/parser/marc_rules.rb +35 -0
  21. data/lib/libis/tools/metadata/parser/marc_select_parser.rb +25 -0
  22. data/lib/libis/tools/metadata/parser/patch.rb +21 -0
  23. data/lib/libis/tools/metadata/parser/subfield_criteria_parser.rb +71 -0
  24. data/lib/libis/tools/metadata/parsers.rb +12 -0
  25. data/lib/libis/tools/metadata/var_field.rb +57 -47
  26. data/lib/libis/tools/parameter.rb +12 -2
  27. data/lib/libis/tools/version.rb +1 -1
  28. data/libis-tools.gemspec +4 -3
  29. data/spec/config_spec.rb +3 -1
  30. data/spec/data/MetadataMapping.xlsx +0 -0
  31. data/spec/metadata/8389207.marc +96 -0
  32. data/spec/metadata/dublin_core_parser_spec.rb +48 -0
  33. data/spec/metadata/marc21_parser_data.rb +382 -0
  34. data/spec/metadata/marc21_parser_spec.rb +67 -0
  35. data/spec/metadata/marc21_spec.rb +116 -0
  36. data/spec/metadata/metadata_mapper_spec.rb +23 -0
  37. data/spec/spec_helper.rb +13 -0
  38. data/test.rb +61 -0
  39. metadata +77 -7
  40. data/lib/libis/tools/dc_record.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f35282647506db8de43d2a9963bd3aabaa944788
4
- data.tar.gz: 476b0593171ce67aec1e15a33d75e5e72751b2fa
3
+ metadata.gz: b01ca03040ec809f70ec3d43df73b70f043da800
4
+ data.tar.gz: f114d4ad472bf6bdc15afc3838294c148db7faee
5
5
  SHA512:
6
- metadata.gz: aa6158973c7ac9f8a1ef9fc1bfa5406bcb0cce7651592488ede57a245c4a3e9e04ec8eb89f14e194d58e00cc3f025896238c98d495ca609d8f17acc6556fe2ac
7
- data.tar.gz: e11e56b324b2a3e58e27f8ac5770b383246cec7c09af4800ddb61e6385d95b433bc1608c54a4a83606d701ab272991e3fb421f4032e0a77ebd7b29b7bb7ed0a0
6
+ metadata.gz: 0c761e895cc23ce58742d04d8d6d1788bf169d9d438683004e9f7eb0f190f85944fb1db2eb26a1fccf11a9db66017953d5ba6663e915f0c29d2c30937da8933e
7
+ data.tar.gz: 3c04c7eff20a8ab20393a50b8992e4763408da4819445be3f7821bca5bfe307d3188784951d3f44693a85081e04e077c82e0b9d02e1e4b8c8ef1b8cc1df34171
data/.travis.yml CHANGED
@@ -1,11 +1,14 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ sudo: false
3
4
  rvm:
4
5
  - 1.9.3
5
6
  - 2.1.0
6
7
  - 2.2.0
7
8
  - ruby-head
8
- - jruby-19mode
9
+ - jruby-1.7.20
10
+ - jruby-9.0.1.0
11
+ - jruby-head
9
12
  jdk:
10
13
  - openjdk7
11
14
  - oraclejdk7
@@ -34,4 +37,3 @@ branches:
34
37
  addons:
35
38
  code_climate:
36
39
  repo_token: f6978964f55e6543befb82373651365f8195677816af6ff40ad70c82f7f22f09
37
-
data/README.md CHANGED
@@ -300,6 +300,25 @@ produces:
300
300
  <email>harry.potter@hogwarts.edu</email>
301
301
  <email>hpotter@JKRowling.com</email>
302
302
  </patron>
303
+
304
+ ## Metadata
305
+
306
+ This gem also provides some modules and classes that assist in working with metadata. There are classes that allow to
307
+ create and/or read metadata for MARC(21), Dublin Core and SharePoint. These classes all live in the
308
+ Libis::Tools::Metadata namespace.
309
+
310
+ ### MARC
311
+
312
+ The classes Libis::Tools::Metadata::MarcRecord and it's child class Libis::Tools::Metadata::Marc21Record are mainly
313
+ built for reading MARC(21) records. Most of the class logic is in the base class MarcRecord, which is incomplete and
314
+ should be considered an abstract class. Marc21Record on the other hand only contains the logic to parse the XML data
315
+ into the internal structure. A MarcRecord is created by supplying it an XML node (from Nokogiri or
316
+ Libis::Tools::XmlDocument) that contains child nodes with the MARC data of a single record. The code will strip
317
+ namespaces from the input in order to greatly simplify working with the XML.
318
+
319
+
320
+
321
+
303
322
 
304
323
  ## Contributing
305
324
 
data/lib/libis/tools.rb CHANGED
@@ -15,4 +15,5 @@ module Libis
15
15
  end
16
16
  end
17
17
 
18
+ require_relative 'tools/metadata'
18
19
  require_relative 'tools/extend/struct'
@@ -67,7 +67,7 @@ module Libis
67
67
  yield file_or_hash if block_given?
68
68
  file_or_hash
69
69
  when String
70
- return unless File.exist?(file_or_hash)
70
+ return {} unless File.exist?(file_or_hash)
71
71
  yield File.absolute_path(file_or_hash) if block_given?
72
72
  # noinspection RubyResolve
73
73
  YAML.load(ERB.new(open(file_or_hash).read).result) rescue {}
@@ -0,0 +1,16 @@
1
+ module Kernel
2
+
3
+ def extract_argstring_from(name, call_stack)
4
+ file, line_number = call_stack.first.match(/^(.+):(\d+)/).captures
5
+ line = File.readlines(file)[line_number.to_i - 1].strip
6
+ argstring = line[/#{name}\s*\(?(.+?)\)?\s*($|#|\[|\})/, 1]
7
+ raise "unable to extract name for #{name} from #{file} line #{line_number}:\n #{line}" unless argstring
8
+ argstring
9
+ end
10
+
11
+ def dputs(value)
12
+ name = extract_argstring_from :dputs, caller
13
+ puts "#{name} : '#{value}'"
14
+ end
15
+
16
+ end
@@ -0,0 +1,20 @@
1
+ module Libis
2
+ module Tools
3
+ module Metadata
4
+
5
+ autoload :MarcRecord, 'libis/tools/metadata/marc_record'
6
+ autoload :Marc21Record, 'libis/tools/metadata/marc21_record'
7
+ autoload :DublinCoreRecord, 'libis/tools/metadata/dublin_core_record'
8
+
9
+ module Mappers
10
+
11
+ autoload :Kuleuven, 'libis/tools/metadata/mappers/kuleuven'
12
+ autoload :Flandrica, 'libis/tools/metadata/mappers/flandrica'
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+
20
+ require_relative 'metadata/parsers'
@@ -42,6 +42,7 @@ module Libis
42
42
  raise ArgumentError, "Invalid argument: #{doc.inspect}"
43
43
  end
44
44
  @document = xml_doc.document if xml_doc
45
+ raise ArgumentError, 'XML document not valid.' if self.invalid?
45
46
  end
46
47
 
47
48
  def all
@@ -52,7 +53,6 @@ module Libis
52
53
  m = /^([\/.]*\/)?(dc(terms)?:)?(.*)/.match(path.to_s)
53
54
  return [] unless m[4]
54
55
  path = (m[1] || '') + ('dc:' || m[2]) + m[4]
55
- raise ArgumentError, 'XML document not valid.' if self.invalid?
56
56
  @document.xpath(path.to_s)
57
57
  end
58
58
 
@@ -4,7 +4,7 @@ module Libis
4
4
  module Tools
5
5
  module Metadata
6
6
 
7
- class FieldSpec
7
+ class FieldFormat
8
8
 
9
9
  attr_accessor :parts
10
10
  attr_accessor :prefix
@@ -25,8 +25,8 @@ module Libis
25
25
  end
26
26
  end
27
27
  @join = options[:join] if options[:join]
28
- @prefix = FieldSpec::from(options[:prefix]) if options[:prefix]
29
- @postfix = FieldSpec::from(options[:postfix]) if options[:postfix]
28
+ @prefix = FieldFormat::from(options[:prefix]) if options[:prefix]
29
+ @postfix = FieldFormat::from(options[:postfix]) if options[:postfix]
30
30
  self
31
31
  end
32
32
 
@@ -40,21 +40,21 @@ module Libis
40
40
 
41
41
  def [](*parts)
42
42
  options = parts.last.is_a?(Hash) ? parts.pop : {}
43
- parts.each { |x| add x }
43
+ add parts
44
44
  x = options.delete(:parts)
45
45
  add x if x
46
46
  add_options options
47
47
  end
48
48
 
49
49
  def self.from(*h)
50
- FieldSpec.new(*h)
50
+ self.new(*h)
51
51
  end
52
52
 
53
53
  def to_s
54
54
  @parts.delete_if { |x|
55
55
  x.nil? or
56
56
  (x.is_a? String and x.empty?) or
57
- (x.is_a? FieldSpec and x.to_s.empty?)
57
+ (x.is_a? Libis::Tools::Metadata::FieldFormat and x.to_s.empty?)
58
58
  }
59
59
  result = @parts.join(@join)
60
60
  unless result.empty?
@@ -66,7 +66,7 @@ module Libis
66
66
  def add(part)
67
67
  case part
68
68
  when Hash
69
- @parts << FieldSpec::from(part)
69
+ @parts << Libis::Tools::Metadata::FieldFormat::from(part)
70
70
  when Array
71
71
  part.each { |x| add x }
72
72
  else
@@ -7,13 +7,18 @@ module Libis
7
7
  class FixField
8
8
 
9
9
  attr_reader :tag
10
- attr_reader :datas
10
+ attr_accessor :datas
11
11
 
12
12
  def initialize(tag, datas)
13
13
  @tag = tag
14
14
  @datas = datas || ''
15
15
  end
16
16
 
17
+ def [](from = nil, to = nil)
18
+ return @datas unless from
19
+ to ? @datas[from..to] : @datas[from]
20
+ end
21
+
17
22
  def dump
18
23
  "#{@tag}:'#{@datas}'\n"
19
24
  end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+
3
+ require 'simple_xlsx_reader'
4
+ require 'backports/rails/string'
5
+
6
+ require_relative 'parsers'
7
+
8
+ module Libis
9
+ module Tools
10
+ module Metadata
11
+
12
+ # noinspection RubyResolve
13
+ class Mapper
14
+
15
+ attr_reader :target_parser, :selection_parser, :format_parser
16
+ attr_reader :tables, :mapping
17
+
18
+ def initialize(selection_parser, target_parser, format_parser, config_xlsx)
19
+ @selection_parser = selection_parser
20
+ @target_parser = target_parser
21
+ @format_parser = format_parser
22
+ @mapping = []
23
+ @tables = {}
24
+ doc = SimpleXlsxReader.open(config_xlsx)
25
+ doc.sheets.each do |sheet|
26
+ if sheet.name == 'Mapping'
27
+ mapping = sheet_to_hash(sheet)
28
+ mapping.each do |rule|
29
+ @mapping << {
30
+ 'Selection' => begin
31
+ selection_parser.parse(rule['Selection'])
32
+ rescue Parslet::ParseFailed => error
33
+ puts "Error parsing '#{rule['Selection']}'"
34
+ puts error.cause.ascii_tree
35
+ end,
36
+ 'Target' => begin
37
+ target_parser.parse(rule['Target'])
38
+ rescue Parslet::ParseFailed => error
39
+ puts "Error parsing '#{rule['Target']}'"
40
+ puts error.cause.ascii_tree
41
+ end,
42
+ 'Format' => begin
43
+ format_parser.parse(rule['Format'])
44
+ rescue Parslet::ParseFailed => error
45
+ puts "Error parsing '#{rule['Format']}'"
46
+ puts error.cause.ascii_tree
47
+ end,
48
+ }
49
+ end
50
+ else
51
+ @tables[sheet.name] = sheet_to_hash(sheet)
52
+ end
53
+ end
54
+ if @mapping.empty?
55
+ raise RuntimeError, "Failure: config file '#{config_xlsx}' does not contain a 'Mapping' sheet."
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def sheet_to_hash(sheet)
62
+ data = sheet.rows
63
+ header = data.shift
64
+ result = []
65
+ data.each do |row|
66
+ x = {}
67
+ header.each_with_index { |col_name, col_index| x[col_name] = row[col_index] }
68
+ result << x
69
+ end
70
+ result
71
+ end
72
+
73
+ def lookup(table, key, constraints = {})
74
+ @tables[table].select { |value| constraints.map { |k, v| value[k] == v }.all? }.map { |v| v[key] }
75
+ end
76
+
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+
3
+ require 'libis/tools/metadata/mappers/kuleuven'
4
+
5
+ module Libis
6
+ module Tools
7
+ module Metadata
8
+ module Mappers
9
+
10
+ # noinspection RubyResolve
11
+ module Flandrica
12
+ include Libis::Tools::Metadata::Mappers::Kuleuven
13
+
14
+ def marc2dc_identifier(xml)
15
+ Libis::Tools::Metadata::Mappers::Kuleuven.marc2dc_identifier(xml)
16
+ marc2dc_identifier_040(xml)
17
+ end
18
+
19
+ def marc2dc_identifier_001(xml)
20
+ # "urn:ControlNumber:" [MARC 001]
21
+ tag('001').each { |t|
22
+ xml['dc'].identifier element(t.datas, prefix: '')
23
+ }
24
+ end
25
+
26
+ def marc2dc_identifier_040(xml)
27
+ # [MARC 040 $a]
28
+ tag('040', 'a').each { |t|
29
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text t._a
30
+ }
31
+ end
32
+
33
+ def marc2dc_alternative_240_a(xml)
34
+ # [MARC 240 #_ $a] ", " [MARC 240 #_ $f] ", " [MARC 240 #_ $g] ", "
35
+ tag('240#_', 'a f g').each { |t|
36
+ xml['dcterms'].alternative element(t._afg, join: ', ', postfix: ', ')
37
+ }
38
+ end
39
+
40
+ def marc2dc_alternative_240_l(xml)
41
+ # [MARC 240 #_ $l] ", " [MARC 240 #_ $m] ", " [MARC 240 #_ $n] ", " [MARC 240 #_ $o] ", " [MARC 240 #_ $p] ", " [MARC 240 #_ $r] ", " [MARC 240 #_ $s]
42
+ tag('240#_', 'l m n o p r s').each { |t|
43
+ xml['dcterms'].alternative element(t._lmnoprs, join: ', ')
44
+ }
45
+ end
46
+
47
+ def marc2dc_source_856(xml)
48
+ marc2dc_source_856__1(xml)
49
+ marc2dc_source_856__2(xml)
50
+ marc2dc_source_856___(xml)
51
+ end
52
+
53
+ def marc2dc_source_856___(xml)
54
+ # [MARC 856 ## $a]
55
+ tag('856', 'a').each { |t|
56
+ xml['dc'].source('xsi:type' => 'dcterms:URI').text element(t._a)
57
+ }
58
+ end
59
+
60
+ def check_name(_,_)
61
+ true
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,1702 @@
1
+ # encoding: utf-8
2
+
3
+ require 'libis/tools/metadata/marc_record'
4
+ require 'libis/tools/metadata/dublin_core_record'
5
+ require 'libis/tools/assert'
6
+
7
+ module Libis
8
+ module Tools
9
+ module Metadata
10
+ module Mappers
11
+
12
+ # noinspection RubyResolve
13
+ module Kuleuven
14
+
15
+ def to_dc(label = nil)
16
+ assert(self.is_a? Libis::Tools::Metadata::MarcRecord)
17
+
18
+ doc = Libis::Tools::Metadata::DublinCoreRecord.new do |xml|
19
+ marc2dc_identifier(xml, label)
20
+ marc2dc_title(xml)
21
+ marc2dc_ispartof(xml)
22
+ marc2dc_alternative(xml)
23
+ marc2dc_creator(xml)
24
+ marc2dc_subject(xml)
25
+ marc2dc_temporal(xml)
26
+ marc2dc_description(xml)
27
+ marc2dc_isversionof(xml)
28
+ marc2dc_abstract(xml)
29
+ marc2dc_tableofcontents(xml)
30
+ marc2dc_available(xml)
31
+ marc2dc_haspart(xml)
32
+ marc2dc_contributor(xml)
33
+ marc2dc_provenance(xml)
34
+ marc2dc_publisher(xml)
35
+ marc2dc_date(xml)
36
+ marc2dc_type(xml)
37
+ marc2dc_spatial(xml)
38
+ marc2dc_extent(xml)
39
+ marc2dc_accrualperiodicity(xml)
40
+ marc2dc_format(xml)
41
+ marc2dc_medium(xml)
42
+ marc2dc_relation(xml)
43
+ marc2dc_replaces(xml)
44
+ marc2dc_hasversion(xml)
45
+ marc2dc_source(xml)
46
+ marc2dc_language(xml)
47
+ marc2dc_rightsholder(xml)
48
+ marc2dc_references(xml)
49
+ marc2dc_isreferencedby(xml)
50
+
51
+ end
52
+
53
+ # deduplicate the XML
54
+ found = Set.new
55
+ doc.root.children.each { |node| node.unlink unless found.add?(node.to_xml) }
56
+
57
+ doc
58
+
59
+ end
60
+
61
+ protected
62
+
63
+ def marc2dc_identifier(xml, label = nil)
64
+ # DC:IDENTIFIER
65
+ marc2dc_identifier_label(label, xml)
66
+ marc2dc_identifier_001(xml)
67
+ marc2dc_identifier_035(xml)
68
+ marc2dc_identifier_024_8(xml)
69
+ marc2dc_identifier_028_4(xml)
70
+ marc2dc_identifier_028_5(xml)
71
+ marc2dc_identifier_029(xml)
72
+ marc2dc_identifier_700(xml)
73
+ marc2dc_identifier_710(xml)
74
+ marc2dc_identifier_752(xml)
75
+ marc2dc_identifier_020(xml)
76
+ marc2dc_identifier_020_9(xml)
77
+ marc2dc_identifier_022(xml)
78
+ marc2dc_identifier_024_2(xml)
79
+ marc2dc_identifier_024_3(xml)
80
+ marc2dc_identifier_690(xml)
81
+ marc2dc_identifier_856(xml)
82
+ end
83
+
84
+ def marc2dc_identifier_label(label, xml)
85
+ # noinspection RubyResolve
86
+ xml['dc'].identifier label if label
87
+ end
88
+
89
+ def marc2dc_identifier_001(xml)
90
+ # "urn:ControlNumber:" [MARC 001]
91
+ all_tags('001') { |t|
92
+ xml['dc'].identifier element(t.datas, prefix: 'urn:ControlNumber:')
93
+ }
94
+ end
95
+
96
+ def marc2dc_identifier_035(xml)
97
+ # [MARC 035__ $a]
98
+ each_field('035__', 'a') { |f| xml['dc'].identifier f }
99
+ end
100
+
101
+ def marc2dc_identifier_024_8(xml)
102
+ # [MARC 24 8_ $a]
103
+ each_field('0248_', 'a') { |f| xml['dc'].identifier f }
104
+ end
105
+
106
+ def marc2dc_identifier_028_4(xml)
107
+ # [MARC 28 40 $b]": "[MARC 28 40 $a]
108
+ all_tags('02840') { |t|
109
+ xml['dc'].identifier element(t._ba, join: ': ')
110
+ }
111
+ end
112
+
113
+ def marc2dc_identifier_028_5(xml)
114
+ # [MARC 28 50 $b]": "[MARC 28 50 $a]
115
+ all_tags('02850') { |t|
116
+ xml['dc'].identifier element(t._ba, join: ': ')
117
+ }
118
+ end
119
+
120
+ def marc2dc_identifier_029(xml)
121
+ # "Siglum: " [MARC 029 __ $a]
122
+ each_field('029__', 'a') { |f| xml['dc'].identifier element(f, prefix: 'Siglum: ') }
123
+ end
124
+
125
+ def marc2dc_identifier_700(xml)
126
+ # [MARC 700 #_ $0]
127
+ each_field('700#_', '0') { |f| xml['dc'].identifier f }
128
+ end
129
+
130
+ def marc2dc_identifier_710(xml)
131
+ # [MARC 710 #_ $0]
132
+ each_field('710#_', '0') { |f| xml['dc'].identifier f }
133
+ end
134
+
135
+ def marc2dc_identifier_752(xml)
136
+ # [MARC 752 __ $0]
137
+ each_field('752#_', '0') { |f| xml['dc'].identifier f }
138
+ end
139
+
140
+ def marc2dc_identifier_020(xml)
141
+ # "urn:ISBN:"[MARC 020 __ $a]
142
+ each_field('020__', 'a') { |f|
143
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text element(f, prefix: 'urn:ISBN:')
144
+ }
145
+ end
146
+
147
+ def marc2dc_identifier_020_9(xml)
148
+ # "urn:ISBN:"[MARC 020 9_ $a]
149
+ each_field('0209_', 'a') { |f|
150
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text element(f, prefix: 'urn:ISBN:')
151
+ }
152
+ end
153
+
154
+ def marc2dc_identifier_022(xml)
155
+ # "urn:ISSN:"[MARC 022 __ $a]
156
+ each_field('022__', 'a') { |f|
157
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text element(f, prefix: 'urn:ISSN:')
158
+ }
159
+ end
160
+
161
+ def marc2dc_identifier_024_2(xml)
162
+ # "urn:ISMN:"[MARC 024 2_ $a]
163
+ each_field('0242_', 'a') { |f|
164
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text element(f, prefix: 'urn:ISMN:')
165
+ }
166
+ end
167
+
168
+ def marc2dc_identifier_024_3(xml)
169
+ # "urn:EAN:"[MARC 024 3_ $a]
170
+ each_field('0243_', 'a') { |f|
171
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text element(f, prefix: 'urn:EAN:')
172
+ }
173
+ end
174
+
175
+ def marc2dc_identifier_690(xml)
176
+ # [MARC 690 02 $0]
177
+ all_tags('69002', '0a') { |t|
178
+ if t._0 =~ /^\(ODIS-(PS|ORG)\)(\d)+$/
179
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text odis_link($1, $2, CGI::escape(t._a))
180
+ else
181
+ xml['dc'].identifier t._a
182
+ end
183
+ }
184
+ end
185
+
186
+ def marc2dc_identifier_856(xml)
187
+ # [MARC 856 _2 $u]
188
+ all_tags('856_2', 'uy') { |t|
189
+ xml['dc'].identifier('xsi:type' => 'dcterms:URI').text element(t._u, CGI::escape(t._y), join: '#')
190
+ }
191
+ end
192
+
193
+ def marc2dc_title(xml)
194
+ # DC:TITLE
195
+ marc2dc_title_245(xml)
196
+ marc2dc_title_246(xml)
197
+ end
198
+
199
+ def marc2dc_title_245(xml)
200
+ marc2dc_title_245_0(xml)
201
+ marc2dc_title_245_1(xml)
202
+ end
203
+
204
+ def marc2dc_title_245_0(xml)
205
+ # [MARC 245 0# $a] " " [MARC 245 0# $b] " [" [MARC 245 0# $h] "]"
206
+ all_tags('2450#', 'a b h') { |t|
207
+ xml['dc'].title list_s(t._ab, opt_s(t._h))
208
+ }
209
+ end
210
+
211
+ def marc2dc_title_245_1(xml)
212
+ # [MARC 245 1# $a] " " [MARC 245 1# $b] " [" [MARC 245 1# $h] "]"
213
+ all_tags('2451#', 'a b h') { |t|
214
+ xml['dc'].title element(t._ab, opt_s(t._h), join: ' ')
215
+ }
216
+ end
217
+
218
+ def marc2dc_title_246(xml)
219
+ # [MARC 246 11 $a] " : " [MARC 246 11 $b]
220
+ all_tags('24611', 'a b') { |t|
221
+ xml['dc'].title element(t._ab, join: ' : ')
222
+ }
223
+ end
224
+
225
+ def marc2dc_ispartof(xml)
226
+ # DCTERMS:ISPARTOF
227
+ marc2dc_ispartof_243(xml)
228
+ marc2dc_ispartof_440(xml)
229
+ marc2dc_ispartof_lkr(xml)
230
+ marc2dc_ispartof_773(xml)
231
+ end
232
+
233
+ def marc2dc_ispartof_243(xml)
234
+ # [MARC 243 1# $a]
235
+ each_field('2431#', 'a') { |f| xml['dcterms'].isPartOf f }
236
+ end
237
+
238
+ def marc2dc_ispartof_440(xml)
239
+ # [MARC 440 _# $a] " : " [MARC 440 _# $b] " , " [MARC 440 _# $v]
240
+ all_tags('440_#', 'a b v') { |t|
241
+ xml['dcterms'].isPartOf element({parts: t._ab, join: ' : '}, t._v, join: ' , ')
242
+ }
243
+ end
244
+
245
+ def marc2dc_ispartof_lkr(xml)
246
+ # [MARC LKR $n]
247
+ each_field('LKR', 'n') { |f| xml['dcterms'].isPartOf f }
248
+ end
249
+
250
+ def marc2dc_ispartof_773(xml)
251
+ # [MARC 773 0_ $a] " (" [MARC 773 0_ $g*]")"
252
+ all_tags('7730_', 'a') { |t|
253
+ xml['dcterms'].isPartOf element(t._a, opt_r(repeat(t.a_g)), join: ' ')
254
+ }
255
+ end
256
+
257
+ def marc2dc_alternative(xml)
258
+ # DCTERMS:ALTERNATIVE
259
+ marc2dc_alternative_130(xml)
260
+ marc2dc_alternative_240(xml)
261
+ marc2dc_alternative_242(xml)
262
+ marc2dc_alternative_246(xml)
263
+ marc2dc_alternative_210(xml)
264
+ end
265
+
266
+ def marc2dc_alternative_130(xml)
267
+ marc2dc_alternative_130_a(xml)
268
+ marc2dc_alternative_130_l(xml)
269
+ end
270
+
271
+ def marc2dc_alternative_130_a(xml)
272
+ # [MARC 130 #_ $a] ", " [MARC 130 #_ $f] ", " [MARC 130 #_ $g] ", "
273
+ all_tags('130#_', 'a f g') { |t|
274
+ xml['dcterms'].alternative element(t._afg, join: ', ', postfix: ', ')
275
+ }
276
+ end
277
+
278
+ def marc2dc_alternative_130_l(xml)
279
+ # [MARC 130 #_ $l] ", " [MARC 130 #_ $m] ", " [MARC 130 #_ $n] ", " [MARC 130 #_ $o] ", " [MARC 130 #_ $p] ", " [MARC 130 #_ $r] ", " [MARC 130 #_ $s]
280
+ all_tags('130#_', 'l m n o p r s') { |t|
281
+ xml['dcterms'].alternative element(t._lmnoprs, join: ', ')
282
+ }
283
+ end
284
+
285
+ def marc2dc_alternative_240(xml)
286
+ marc2dc_alternative_240_a(xml)
287
+ marc2dc_alternative_240_l(xml)
288
+ end
289
+
290
+ def marc2dc_alternative_240_a(xml)
291
+ # [MARC 240 1# $a] ", " [MARC 240 1# $f] ", " [MARC 240 1# $g] ", "
292
+ all_tags('2401#', 'a f g') { |t|
293
+ xml['dcterms'].alternative element(t._afg, join: ', ', postfix: ', ')
294
+ }
295
+ end
296
+
297
+ def marc2dc_alternative_240_l(xml)
298
+ # [MARC 240 1# $l] ", " [MARC 240 1# $m] ", " [MARC 240 1# $n] ", " [MARC 240 1# $o] ", " [MARC 240 1# $p] ", " [MARC 240 1# $r] ", " [MARC 240 1# $s]
299
+ all_tags('2401#', 'l m n o p r s') { |t|
300
+ xml['dcterms'].alternative element(t._lmnoprs, join: ', ')
301
+ }
302
+ end
303
+
304
+ def marc2dc_alternative_242(xml)
305
+ # [MARC 242 1# $a] ". " [MARC 242 1# $b]
306
+ all_tags('2421#', 'a b') { |t|
307
+ xml['dcterms'].alternative element(t._ab, join: '. ')
308
+ }
309
+ end
310
+
311
+ def marc2dc_alternative_246(xml)
312
+ marc2dc_alternative_246_13(xml)
313
+ marc2dc_alternative_246_19(xml)
314
+ end
315
+
316
+ def marc2dc_alternative_246_13(xml)
317
+ # [MARC 246 13 $a] ". " [MARC 246 13 $b]
318
+ all_tags('24613', 'a b') { |t|
319
+ xml['dcterms'].alternative element(t._ab, join: '. ')
320
+ }
321
+ end
322
+
323
+ def marc2dc_alternative_246_19(xml)
324
+ # [MARC 246 19 $a] ". " [MARC 246 19 $b]
325
+ all_tags('24619', 'a b') { |t|
326
+ xml['dcterms'].alternative element(t._ab, join: '. ')
327
+ }
328
+ end
329
+
330
+ def marc2dc_alternative_210(xml)
331
+ # [MARC 210 10 $a]
332
+ each_field('21010', 'a') { |f| xml['dcterms'].alternative f }
333
+ end
334
+
335
+ def marc2dc_creator(xml)
336
+ # DC:CREATOR
337
+ marc2dc_creator_100(xml)
338
+ marc2dc_creator_700(xml)
339
+ marc2dc_creator_710(xml)
340
+ marc2dc_creator_711(xml)
341
+ end
342
+
343
+ def marc2dc_creator_100(xml)
344
+ marc2dc_creator_100_0(xml)
345
+ marc2dc_creator_100_1(xml)
346
+ end
347
+
348
+ def marc2dc_creator_100_0(xml)
349
+ # [MARC 100 0_ $a] " " [MARC 100 0_ $b] " ("[MARC 100 0_ $c] ") " "("[MARC 100 0_ $d]") ("[MARC 100 0_ $g] "), " [MARC 100 0_ $4]" (" [MARC 100 0_ $9]")"
350
+ all_tags('1000_', '4') { |t|
351
+ next unless check_name(t, :creator)
352
+ xml['dc'].creator element(list_s(t._ab, opt_r(t._c), opt_r(t._d), opt_r(t._g)),
353
+ list_s(full_name(t), opt_r(t._9)),
354
+ join: ', ')
355
+ }
356
+ end
357
+
358
+ def marc2dc_creator_100_1(xml)
359
+ # [MARC 100 1_ $a] " " [MARC 100 1_ $b] " ("[MARC 100 1_ $c] ") " "("[MARC 100 1_ $d]") ("[MARC 100 1_ $g]"), " [MARC 100 1_ $4]" ("[MARC 100 1_ $e]") (" [MARC 100 1_ $9]")"
360
+ all_tags('1001_', 'a b c d g e 9') { |t|
361
+ next unless check_name(t, :creator)
362
+ xml['dc'].creator element(list_s(t._ab, opt_r(t._c), opt_r(t._d), opt_r(t._g)),
363
+ list_s(full_name(t), opt_r(t._e), opt_r(t._9)),
364
+ join: ', ')
365
+ }
366
+ end
367
+
368
+ def marc2dc_creator_700(xml)
369
+ marc2dc_creator_700_0(xml)
370
+ marc2dc_creator_700_1(xml)
371
+ end
372
+
373
+ def marc2dc_creator_700_0(xml)
374
+ # [MARC 700 0_ $a] ", " [MARC 700 0_ $b] ", " [MARC 700 0_ $c] ", " [MARC 700 0_ $d] ", " [MARC 700 0_ $g] " (" [MARC 700 0_ $4] "), " [MARC 700 0_ $e]
375
+ all_tags('7000_', 'g c d e') { |t|
376
+ next unless check_name(t, :creator)
377
+ xml['dc'].creator element(t._abcd,
378
+ list_s(t._g, opt_r(full_name(t))),
379
+ t._e,
380
+ join: ', ')
381
+ }
382
+ end
383
+
384
+ def marc2dc_creator_700_1(xml)
385
+ # [MARC 700 1_ $a] ", " [MARC 700 1_ $b] ", " [MARC 700 1_ $c] ", " [MARC 700 1_ $d] ", " [MARC 700 1_ $g] " ( " [MARC 700 1_ $4] "), " [MARC 700 1_ $e]
386
+ all_tags('7001_', 'a b c d g e') { |t|
387
+ next unless check_name(t, :creator)
388
+ xml['dc'].creator element(t._abcd,
389
+ list_s(t._g, opt_r(full_name(t))),
390
+ t._e,
391
+ join: ', ')
392
+ }
393
+ end
394
+
395
+ def marc2dc_creator_710(xml)
396
+ marc2dc_creator_710_29(xml)
397
+ marc2dc_creator_710_2_(xml)
398
+ end
399
+
400
+ def marc2dc_creator_710_29(xml)
401
+ # [MARC 710 29 $a] "," [MARC 710 29 $g]" (" [MARC 710 29 $4] "), " [MARC 710 29 $e]
402
+ all_tags('71029', 'a g e') { |t|
403
+ next unless check_name(t, :creator)
404
+ xml['dc'].creator element(t._a,
405
+ list_s(t._g, opt_r(full_name(t))),
406
+ t._e,
407
+ join: ', ')
408
+ }
409
+ end
410
+
411
+ def marc2dc_creator_710_2_(xml)
412
+ # [MARC 710 2_ $a] " (" [MARC 710 2_ $g] "), " [MARC 710 2_ $4] " (" [MARC 710 2_ $9*] ") ("[MARC 710 2_ $e]")"
413
+ all_tags('7102_', 'a g e') { |t|
414
+ next unless check_name(t, :creator)
415
+ xml['dc'].creator element(list_s(t._a, opt_r(t._g)),
416
+ list_s(full_name(t), opt_r(repeat(t.a_9)), opt_r(t._e)),
417
+ join: ', ')
418
+ }
419
+ end
420
+
421
+ def marc2dc_creator_711(xml)
422
+ # [MARC 711 2_ $a] ", "[MARC 711 2_ $n] ", " [MARC 711 2_ $c] ", " [MARC 711 2_ $d] " (" [MARC 711 2_ $g] ")"
423
+ all_tags('7112_', 'a n c d g') { |t|
424
+ next unless check_name(t, :creator)
425
+ xml['dc'].creator element(t._ancd, join: ', ', postfix: opt_r(t._g, prefix: ' '))
426
+ }
427
+ end
428
+
429
+ def marc2dc_subject(xml)
430
+ # DC:SUBJECT
431
+ marc2dc_subject_600(xml)
432
+ marc2dc_subject_610(xml)
433
+ marc2dc_subject_611(xml)
434
+ marc2dc_subject_630(xml)
435
+ marc2dc_subject_650_x0(xml)
436
+ marc2dc_subject_650_x2(xml)
437
+ marc2dc_subject_691(xml)
438
+ marc2dc_subject_082(xml)
439
+ marc2dc_subject_690(xml)
440
+ end
441
+
442
+ def marc2dc_subject_600(xml)
443
+ # [MARC 600 #0 $a] " " [MARC 600 #0 $b] " " [MARC 600 #0 $c] " " [MARC 600 #0 $d] " " [MARC 600 #0 $g]
444
+ all_tags('600#0', 'a b c d g') { |t|
445
+ xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/LCSH').text list_s(t._abcdg)
446
+ }
447
+ end
448
+
449
+ def marc2dc_subject_610(xml)
450
+ # [MARC 610 #0 $a] " " [MARC 610 #0 $c] " " [MARC 610 #0 $d] " " [MARC 610 #0 $g]
451
+ all_tags('610#0', 'a c d g') { |t|
452
+ xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/LCSH').text list_s(t._acdg)
453
+ }
454
+ end
455
+
456
+ def marc2dc_subject_611(xml)
457
+ # [MARC 611 #0 $a] " " [MARC 611 #0 $c] " " [MARC 611 #0 $d] " " [MARC 611 #0 $g] " " [MARC 611 #0 $n]
458
+ all_tags('611#0', 'a c d g n') { |t|
459
+ xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/LCSH').text list_s(t._acdgn)
460
+ }
461
+ end
462
+
463
+ def marc2dc_subject_630(xml)
464
+ # [MARC 630 #0 $a] " " [MARC 630 #0 $f] " " [MARC 630 #0 $g] " " [MARC 630 #0 $l] " " [MARC 630 #0 $m] " " [MARC 630 #0 $n] " " [MARC 630 #0 $o] " " [MARC 630 #0 $p] " " [MARC 630 #0 $r] " " [MARC 630 #0 $s]
465
+ all_tags('630#0', 'a f g l m n o p r s') { |t|
466
+ xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/LCSH').text list_s(t._afglmnoprs)
467
+ }
468
+ end
469
+
470
+ def marc2dc_subject_650_x0(xml)
471
+ # [MARC 650 #0 $a] " " [MARC 650 #0 $x] " " [MARC 650 #0 $y] " " [MARC 650 #0 $z]
472
+ all_tags('650#0', 'a x y z') { |t|
473
+ xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/LCSH').text list_s(t._axyz)
474
+ }
475
+ end
476
+
477
+ def marc2dc_subject_650_x2(xml)
478
+ # [MARC 650 #2 $a] " " [MARC 650 #2 $x]
479
+ all_tags('650#2', 'a x') { |t|
480
+ attributes = {'xsi:type' => 'http://purl.org/dc/terms/MESH'}
481
+ xml['dc'].subject(attributes).text list_s(t._ax)
482
+ }
483
+ end
484
+
485
+ def marc2dc_subject_691(xml)
486
+ # [MARC 691 E1 $8] " " [ MARC 691 E1 $a]
487
+ all_tags('691E1', 'a8') { |t|
488
+ attributes = {'xsi:type' => 'http://purl.org/dc/terms/UDC'}
489
+ x = taalcode(t._9)
490
+ attributes['xml:lang'] = x if x
491
+ xml['dc'].subject(attributes).text list_s(t._ax)
492
+ }
493
+ end
494
+
495
+ def marc2dc_subject_082(xml)
496
+ # [MARC 082 14 $a] " " [MARC 082 14 $x]
497
+ all_tags('08214', 'a x') { |t|
498
+ xml['dc'].subject('xsi:type' => 'http://purl.org/dc/terms/DDC', 'xml:lang' => 'en').text list_s(t._ax)
499
+ }
500
+ end
501
+
502
+ def marc2dc_subject_690(xml)
503
+ # [MARC 690 [xx]$a]
504
+ # Set dedups the fields
505
+ Set.new(each_field('690##', 'a')) { |f| xml['dc'].subject f }
506
+ end
507
+
508
+ def marc2dc_temporal(xml)
509
+ # DC:TEMPORAL
510
+ marc2dc_temporal_648(xml)
511
+ marc2dc_temporal_362(xml)
512
+ marc2dc_temporal_752(xml)
513
+ end
514
+
515
+ def marc2dc_temporal_648(xml)
516
+ # [MARC 648 #0 $a] " " [MARC 648 #0 $x] " " [MARC 648 #0 $y] " " [MARC 648 #0 $z]
517
+ all_tags('648#0', 'a x y z') { |t|
518
+ xml['dc'].temporal('xsi:type' => 'http://purl.org/dc/terms/LCSH').text list_s(t._axyz)
519
+ }
520
+ end
521
+
522
+ def marc2dc_temporal_362(xml)
523
+ # [MARC 362 __ $a]
524
+ each_field('362__', 'a') { |f| xml['dc'].temporal f }
525
+ end
526
+
527
+ def marc2dc_temporal_752(xml)
528
+ # [MARC 752 9_ $9]
529
+ each_field('7529_', '9') { |f| xml['dc'].temporal f }
530
+
531
+ # [MARC 752 _9 $a] " (" [MARC 752 _9 $9]")"
532
+ all_tags('752_9', 'a 9') { |t|
533
+ xml['dc'].temporal list_s(t._a, opt_r(t._9))
534
+ }
535
+ end
536
+
537
+ def marc2dc_description(xml)
538
+ # DC:DESCRIPTION
539
+
540
+ x = element(
541
+ # [MARC 047 __ $a] " (" [MARC 047 __ $9]")"
542
+ all_tags('047__', 'a 9').collect { |t|
543
+ list_s(t._a, opt_r(t._9))
544
+ },
545
+ # [MARC 598 __ $a]
546
+ all_fields('598__', 'a'),
547
+ # [MARC 597 __ $a]
548
+ all_fields('597__', 'a'),
549
+ # [MARC 500 __ $a]
550
+ all_fields('500__', 'a'),
551
+ # [MARC 520 2_ $a]
552
+ all_fields('5202_', 'a'),
553
+ # "Projectie: " [MARC 093 __ $a]
554
+ all_tags('093__', 'a').collect { |t| element(t._a, prefix: 'Projectie: ') },
555
+ # "Equidistance " [MARC 094 __ $a*]
556
+ all_tags('094__', 'a').collect { |t| element(t.a_a, prefix: 'Equidistance ', join: ';') },
557
+ # [MARC 502 __ $a] ([MARC 502 __ $9])
558
+ all_tags('502__', 'a 9').collect { |t|
559
+ list_s(t._a, opt_r(t._9))
560
+ },
561
+ # [MARC 529 __ $a] ", " [MARC 529 __ $b] " (" [MARC 529 __ $c] ")"
562
+ all_tags('529__', 'a b 9').collect { |t|
563
+ element(t._ab,
564
+ join: ', ',
565
+ postfix: opt_r(t._9))
566
+ },
567
+ # [MARC 534 9_ $a]
568
+ all_fields('5349_', 'a'),
569
+ # [MARC 534 _9 $a] "(oorspronkelijke uitgever)"
570
+ all_fields('534_9', 'a').collect { |f| element(f, postfix: '(oorspronkelijke uitgever)') },
571
+ # [MARC 545 __ $a]
572
+ all_fields('545__', 'a'),
573
+ # [MARC 562 __ $a]
574
+ all_fields('562__', 'a'),
575
+ # [MARC 563 __ $a] " " [MARC 563 __ $9] " (" [MARC 563 __ $u] ")"
576
+ all_tags('563__', 'a 9 u').collect { |t|
577
+ list_s(t._a9, opt_r(t._u))
578
+ },
579
+ # [MARC 586 __ $a]
580
+ all_fields('586__', 'a'),
581
+ # [MARC 711 2_ $a] ", " [MARC 711 2_ $n] ", " [MARC 711 2_ $c] ", " [MARC 711 2_ $d] " (" [MARC 711 2_ $g]")"
582
+ all_tags('7112_', 'a n c d g').collect { |t|
583
+ element(t._ancd,
584
+ join: ', ',
585
+ postfix: opt_r(t._g))
586
+ },
587
+ # [MARC 585 __ $a]
588
+ all_fields('585__', 'a'),
589
+ join: "\n"
590
+ )
591
+ xml['dc'].description x unless x.empty?
592
+ end
593
+
594
+ def marc2dc_isversionof(xml)
595
+ # DCTERMS:ISVERSIONOF
596
+
597
+ # [MARC 250 __ $a] " (" [MARC 250 __ $b] ")"
598
+ all_tags('250__', 'a b') { |t|
599
+ xml['dcterms'].isVersionOf list_s(t._a, opt_r(t._b))
600
+ }
601
+ end
602
+
603
+ def marc2dc_abstract(xml)
604
+ # DC:ABSTRACT
605
+ marc2dc_abstract_520_3__a(xml)
606
+ marc2dc_abstract_520_39_a(xml)
607
+ marc2dc_abstract_520_3__u(xml)
608
+ marc2dc_abstract_520_39_u(xml)
609
+ end
610
+
611
+ def marc2dc_abstract_520_3__a(xml)
612
+ # [MARC 520 3_ $a]
613
+ each_field('5203_', 'a') { |f| xml['dc'].abstract f }
614
+ end
615
+
616
+ def marc2dc_abstract_520_39_a(xml)
617
+ # [MARC 520 39 $t] ": " [MARC 520 39 $a]
618
+ all_tags('52039', 'a t') { |t|
619
+ attributes = {}
620
+ attributes['xml:lang'] = taalcode(t._9) if t.subfield_array('9').size == 1
621
+ xml['dc'].abstract(attributes).text element(t._ta, join: ': ')
622
+ }
623
+ end
624
+
625
+ def marc2dc_abstract_520_3__u(xml)
626
+ # [MARC 520 3_ $u]
627
+ each_field('5203_', 'u') { |f| xml['dc'].abstract('xsi:type' => 'dcterms:URI').text element(f) }
628
+ end
629
+
630
+ def marc2dc_abstract_520_39_u(xml)
631
+ # [MARC 520 39 $u]
632
+ each_field('52039', 'u') { |f| xml['dc'].abstract('xsi:type' => 'dcterms:URI').text element(f) }
633
+ end
634
+
635
+ def marc2dc_tableofcontents(xml)
636
+ # DCTERMS:TABLEOFCONTENTS
637
+ marc2dc_tableofcontents_505_0_(xml)
638
+ marc2dc_tableofcontents_505_09(xml)
639
+ marc2dc_tableofcontents_505_2_(xml)
640
+ end
641
+
642
+ def marc2dc_tableofcontents_505_0_(xml)
643
+ # [MARC 505 0_ $a] " "[MARC 505 0_ $t]" / " [MARC 505 0_ $r*] " ("[MARC 505 0_ $9*]")"
644
+ all_tags('5050_', 'a t r 9') { |t|
645
+ xml['dcterms'].tableOfContents list_s(t._at,
646
+ repeat(t.a_r, prefix: '/ '),
647
+ opt_r(repeat(t.a_9)))
648
+ }
649
+ end
650
+
651
+ def marc2dc_tableofcontents_505_09(xml)
652
+ # [MARC 505 09 $a*] "\n" [MARC 505 09 $9*] "\n" [MARC 505 09 $u*]
653
+ all_tags('50509', 'a u 9') { |t|
654
+ xml['dcterms'].tableOfContents element(repeat(t.a_a),
655
+ repeat(t.a_9),
656
+ repeat(t.a_u),
657
+ join: "\n")
658
+ }
659
+ end
660
+
661
+ def marc2dc_tableofcontents_505_2_(xml)
662
+ # [MARC 505 2_ $a] " "[MARC 505 2_ $t]" / " [MARC 505 2_ $r*] " ("[MARC 505 2_ $9*]")"
663
+ all_tags('5052_', 'a t r 9') { |t|
664
+ xml['dcterms'].tableOfContents list_s(t._at,
665
+ repeat(t.a_r, prefix: '/ '),
666
+ opt_r(repeat(t.a_9)))
667
+ }
668
+ end
669
+
670
+ def marc2dc_available(xml)
671
+ # DCTERMS:AVAILABLE
672
+
673
+ # [MARC 591 ## $9] ":" [MARC 591 ## $a] " (" [MARC 591 ## $b] ")"
674
+ all_tags('591##', 'a b 9') { |t|
675
+ xml['dcterms'].available element(t._9a, join: ':', postfix: opt_r(t._b, prefix: ' '))
676
+ }
677
+ end
678
+
679
+ def marc2dc_haspart(xml)
680
+ # DCTERMS:HASPART
681
+
682
+ # [MARC LKR $m]
683
+ each_field('LKR', 'm') { |f| xml['dcterms'].hasPart f }
684
+ end
685
+
686
+ def marc2dc_contributor(xml)
687
+ # DC:CONTRIBUTOR
688
+ marc2dc_contributor_100_0(xml)
689
+ marc2dc_contributor_100_1(xml)
690
+ marc2dc_contributor_700(xml)
691
+ marc2dc_contributor_710_29(xml)
692
+ marc2dc_contributor_710_2_(xml)
693
+ marc2dc_contributor_711(xml)
694
+ end
695
+
696
+ def marc2dc_contributor_100_0(xml)
697
+ # [MARC 100 0_ $a] " " [MARC 100 0_ $b] " ("[MARC 100 0_ $c] ") (" [MARC 100 0_ $d]") ("[MARC 100 0_ $g]"), " [MARC 100 0_ $4]" (" [MARC 100 0_ $9]")"
698
+ all_tags('1000_', 'a b c d g 9') { |t|
699
+ next unless check_name(t, :contributor)
700
+ xml['dc'].contributor element(list_s(t._ab,
701
+ opt_r(t._c),
702
+ opt_r(t._d),
703
+ opt_r(t._g)),
704
+ list_s(full_name(t),
705
+ opt_r(t._9)),
706
+ join: ', ')
707
+ }
708
+ end
709
+
710
+ def marc2dc_contributor_100_1(xml)
711
+ # [MARC 100 1_ $a] " " [MARC 100 1_ $b] " ("[MARC 100 1_ $c] ") " "("[MARC 100 1_ $d]") ("[MARC 100 1_ $g]"), " [MARC 100 1_ $4]" ("[MARC 100 1_ $e]") (" [MARC 100 1_ $9]")"
712
+ all_tags('1001_', 'a b c d g e 9') { |t|
713
+ next unless check_name(t, :contributor)
714
+ xml['dc'].contributor element(list_s(t._ab,
715
+ opt_r(t._c),
716
+ opt_r(t._d),
717
+ opt_r(t._g)),
718
+ list_s(full_name(t),
719
+ opt_r(t._e),
720
+ opt_r(t._9)),
721
+ join: ', ')
722
+ }
723
+ end
724
+
725
+ def marc2dc_contributor_700(xml)
726
+ # [MARC 700 0_ $a] ", " [MARC 700 0_ $b] ", " [MARC 700 0_ $c] ", " [MARC 700 0_ $d] ", " [MARC 700 0_ $g] " ( " [MARC 700 0_ $4] "), " [MARC 700 0_ $e]
727
+ # [MARC 700 1_ $a] ", " [MARC 700 1_ $b] ", " [MARC 700 1_ $c] ", " [MARC 700 1_ $d] ", " [MARC 700 1_ $g] " ( " [MARC 700 1_ $4] "), " [MARC 700 1_ $e]
728
+ (all_tags('7000_', 'a b c d g e') + all_tags('7001_', 'a b c d g e')).each { |t|
729
+ next unless check_name(t, :contributor)
730
+ xml['dc'].contributor element(t._abcd,
731
+ list_s(t._g,
732
+ opt_r(full_name(t), fix: '( |)')),
733
+ t._e,
734
+ join: ', ')
735
+ }
736
+ end
737
+
738
+ def marc2dc_contributor_710_29(xml)
739
+ # [MARC 710 29 $a] "," [MARC 710 29 $g]" (" [MARC 710 29 $4] "), " [MARC 710 29 $e]
740
+ all_tags('71029', 'a g e') { |t|
741
+ next unless check_name(t, :contributor)
742
+ xml['dc'].contributor element(t._a,
743
+ list_s(t._g,
744
+ opt_r(full_name(t))),
745
+ t._e,
746
+ join: ', ')
747
+ }
748
+ end
749
+
750
+ def marc2dc_contributor_710_2_(xml)
751
+ # [MARC 710 2_ $a] " (" [MARC 710 2_ $g] "), " [MARC 710 2_ $4] " (" [MARC 710 2_ $9] ") ("[MARC 710 2_ $e]")"
752
+ all_tags('7102_', 'a g 9 e') { |t|
753
+ next unless check_name(t, :contributor)
754
+ xml['dc'].contributor element(list_s(t._a,
755
+ opt_r(t._g)),
756
+ list_s(full_name(t),
757
+ opt_r(t._9),
758
+ opt_r(t._e)),
759
+ join: ', ')
760
+ }
761
+ end
762
+
763
+ def marc2dc_contributor_711(xml)
764
+ # [MARC 711 2_ $a] ", "[MARC 711 2_ $n] ", " [MARC 711 2_ $c] ", " [MARC 711 2_ $d] " (" [MARC 711 2_ $g] ")"
765
+ all_tags('7112_', 'a n c d g') { |t|
766
+ next unless check_name(t, :contributor)
767
+ xml['dc'].contributor element(t._anc,
768
+ list_s(t._d,
769
+ opt_r(t._g)),
770
+ join: ', ')
771
+ }
772
+ end
773
+
774
+ def marc2dc_provenance(xml)
775
+ # DCTERMS:PROVENANCE
776
+ marc2dc_provenance_852(xml)
777
+ marc2dc_provenance_651(xml)
778
+ end
779
+
780
+ def marc2dc_provenance_852(xml)
781
+ # [MARC 852 __ $b] " " [MARC 852 __ $c]
782
+ all_tags('852__', 'b c') { |t|
783
+ xml['dcterms'].provenance list_s(t._b == t._c ? t._b : t._bc)
784
+ }
785
+ end
786
+
787
+ def marc2dc_provenance_651(xml)
788
+ # [MARC 561 ## $a] " " [MARC 561 ## $b] " " [MARC 561 ## $9]
789
+ all_tags('561##', 'a b 9') { |t|
790
+ xml['dcterms'].provenance list_s(t._ab9)
791
+ }
792
+ end
793
+
794
+ def marc2dc_publisher(xml)
795
+ # DC:PUBLISHER
796
+ marc2dc_publisher_260___(xml)
797
+ marc2dc_publisher_260__9(xml)
798
+ marc2dc_publisher_700(xml)
799
+ marc2dc_publisher_710(xml)
800
+ end
801
+
802
+ def marc2dc_publisher_260___(xml)
803
+ # [MARC 260 __ $e] " " [MARC 260 __ $f] " " [MARC 260 __ $c] " " [MARC 260 __ $9] " uitgave: " [MARC 260 __ $g]
804
+ all_tags('260__', 'e f c 9 g') { |t|
805
+ xml['dc'].publisher list_s(t._c9,
806
+ element(t._g, prefix: 'uitgave: '))
807
+ }
808
+ end
809
+
810
+ def marc2dc_publisher_260__9(xml)
811
+ # [MARC 260 _9 $c] " " [MARC 260 _9 $9*] " (druk: ) " [MARC 260 _9 $g]
812
+ all_tags('260_9', 'c 9 g') { |t|
813
+ xml['dc'].publisher list_s(t._c,
814
+ repeat(t.a_9),
815
+ element(t._g, prefix: 'uitgave: '))
816
+ }
817
+ end
818
+
819
+ def marc2dc_publisher_700(xml)
820
+ # [MARC 700 0_ $a] ", " [MARC 700 0_ $b] ", " [MARC 700 0_ $c] ", " [MARC 700 0_ $d] ", " [MARC 700 0_ $g] " ( " [MARC 700 0_ $4] "), " [MARC 700 0_ $e] "(uitgever)"
821
+ all_tags('7000_', 'a b c d e g 4') { |t|
822
+ next unless name_type(t) == :publisher
823
+ xml['dc'].publisher element(t._abcd,
824
+ list_s(t._g,
825
+ opt_r(full_name(t), fix: '( |)')),
826
+ t._e,
827
+ join: ', ',
828
+ postfix: '(uitgever)')
829
+ }
830
+ end
831
+
832
+ def marc2dc_publisher_710(xml)
833
+ # [MARC 710 29 $a] " (" [MARC 710 29 $c] "), " [MARC 710 29 $9] "," [710 29 $g] "(drukker)"
834
+ all_tags('71029', 'a c g 9 4') { |t|
835
+ xml['dc'].publisher element(list_s(t._a,
836
+ opt_r(t._c)),
837
+ t._9g,
838
+ join: ', ',
839
+ postfix: '(drukker)')
840
+ }
841
+ end
842
+
843
+ def marc2dc_date(xml)
844
+ # DC:DATE
845
+ marc2dc_date_008(xml)
846
+ marc2dc_date_130(xml)
847
+ marc2dc_date_240(xml)
848
+ end
849
+
850
+ def marc2dc_date_008(xml)
851
+ # [MARC 008 (07-10)] " - " [MARC 008 (11-14)]
852
+ all_tags('008') { |t|
853
+ a = t.datas[7..10].dup
854
+ b = t.datas[11..14].dup
855
+ # return if both parts contained 'uuuu'
856
+ next if a.gsub!(/^uuuu$/, 'xxxx') && b.gsub!(/^uuuu$/, 'xxxx')
857
+ xml['dc'].date element(a, b, join: ' - ')
858
+ }
859
+ end
860
+
861
+ def marc2dc_date_130(xml)
862
+ # "Datering origineel werk: " [MARC 130 #_ $f]
863
+ all_tags('130#_', 'f') { |t|
864
+ xml['dc'].date element(t._f, prefix: 'Datering origineel werk: ')
865
+ }
866
+ end
867
+
868
+ def marc2dc_date_240(xml)
869
+ # "Datering compositie: " [MARC 240 1# $f]
870
+ all_tags('2401#', 'f') { |t|
871
+ xml['dc'].date element(t._f, prefix: 'Datering compositie: ')
872
+ }
873
+ end
874
+
875
+ def marc2dc_type(xml)
876
+ # DC:TYPE
877
+ marc2dc_type_655_x9_a(xml)
878
+ marc2dc_type_655_9x_a(xml)
879
+ marc2dc_type_655__4_z(xml)
880
+ marc2dc_type_fmt(xml)
881
+ marc2dc_type_655_94_z(xml)
882
+ marc2dc_type_655_9__a(xml)
883
+ marc2dc_type_088_9__a(xml)
884
+ marc2dc_type_088____z(xml)
885
+ marc2dc_type_088____a(xml)
886
+ marc2dc_type_655__4_a(xml)
887
+ marc2dc_type_655_94_a(xml)
888
+ marc2dc_type_088____x(xml)
889
+ marc2dc_type_655__4_x(xml)
890
+ marc2dc_type_655_94_x(xml)
891
+ marc2dc_type_088____y(xml)
892
+ marc2dc_type_655__4_y(xml)
893
+ marc2dc_type_655_94_y(xml)
894
+ marc2dc_type_655__2(xml)
895
+ end
896
+
897
+ def marc2dc_type_655_x9_a(xml)
898
+ # [MARC 655 #9 $a]
899
+ each_field('655#9', 'a') { |f| xml['dc'].type f }
900
+ end
901
+
902
+ def marc2dc_type_655_9x_a(xml)
903
+ # [MARC 655 9# $a]
904
+ each_field('6559#', 'a') { |f| xml['dc'].type f }
905
+ end
906
+
907
+ def marc2dc_type_655__4_z(xml)
908
+ # [MARC 655 _4 $z]
909
+ each_field('655_4', 'z') { |f| xml['dc'].type f }
910
+ end
911
+
912
+ def marc2dc_type_fmt(xml)
913
+ # [MARC FMT]
914
+ all_tags('FMT') { |t| xml['dc'].type fmt(t.datas) }
915
+ end
916
+
917
+ def marc2dc_type_655_94_z(xml)
918
+ # [MARC 655 94 $z]
919
+ each_field('65594', 'z') { |f| xml['dc'].type f }
920
+ end
921
+
922
+ def marc2dc_type_655_9__a(xml)
923
+ # [MARC 655 9_ $a]
924
+ each_field('6559_', 'a') { |f| xml['dc'].type f }
925
+ end
926
+
927
+ def marc2dc_type_088_9__a(xml)
928
+ # [MARC 088 9_ $a]
929
+ each_field('0889_', 'a') { |f| xml['dc'].type f } if each_field('088__', 'axy').empty?
930
+ end
931
+
932
+ def marc2dc_type_088____z(xml)
933
+ # [MARC 088 __ $z]
934
+ each_field('088__', 'z') { |f| xml['dc'].type f }
935
+ end
936
+
937
+ def marc2dc_type_088____a(xml)
938
+ # [MARC 088 __ $a]
939
+ each_field('088__', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
940
+ end
941
+
942
+ def marc2dc_type_655__4_a(xml)
943
+ # [MARC 655 _4 $a]
944
+ each_field('655_4', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
945
+ end
946
+
947
+ def marc2dc_type_655_94_a(xml)
948
+ # [MARC 655 94 $a]
949
+ each_field('65594', 'a') { |f| xml['dc'].type('xml:lang' => 'en').text f }
950
+ end
951
+
952
+ def marc2dc_type_088____x(xml)
953
+ # [MARC 088 __ $x]
954
+ each_field('088__', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
955
+ end
956
+
957
+ def marc2dc_type_655__4_x(xml)
958
+ # [MARC 655 _4 $x]
959
+ each_field('655_4', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
960
+ end
961
+
962
+ def marc2dc_type_655_94_x(xml)
963
+ # [MARC 655 94 $x]
964
+ each_field('65594', 'x') { |f| xml['dc'].type('xml:lang' => 'nl').text f }
965
+ end
966
+
967
+ def marc2dc_type_088____y(xml)
968
+ # [MARC 088 __ $y]
969
+ each_field('088__', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
970
+ end
971
+
972
+ def marc2dc_type_655__4_y(xml)
973
+ # [MARC 655 _4 $y]
974
+ each_field('655_4', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
975
+ end
976
+
977
+ def marc2dc_type_655_94_y(xml)
978
+ # [MARC 655 94 $y]
979
+ each_field('65594', 'y') { |f| xml['dc'].type('xml:lang' => 'fr').text f }
980
+ end
981
+
982
+ def marc2dc_type_655__2(xml)
983
+ # [MARC 655 #2 $a] " " [MARC 655 #2 $x*] " " [MARC 655 #2 $9]
984
+ all_tags('655#2', 'a x 9') { |t|
985
+ xml['dc'].type({'xsi:type' => 'http://purl.org/dc/terms/MESH'}).text list_s(t._a,
986
+ repeat(t.a_x),
987
+ t._9)
988
+ }
989
+ end
990
+
991
+ def marc2dc_spatial(xml)
992
+ # DCTERMS:SPATIAL
993
+ marc2dc_spatial_752(xml)
994
+ marc2dc_spatial_034_1(xml)
995
+ marc2dc_spatial_034_3(xml)
996
+ marc2dc_spatial_034_9(xml)
997
+ marc2dc_spatial_507(xml)
998
+ marc2dc_spatial_651__0(xml)
999
+ marc2dc_spatial_651__2(xml)
1000
+ end
1001
+
1002
+ def marc2dc_spatial_752(xml)
1003
+ # [MARC 752 __ $a] " " [MARC 752 __ $c] " " [MARC 752 __ $d] " (" [MARC 752 __ $9] ")"
1004
+ all_tags('752__', 'a c d 9') { |t|
1005
+ xml['dcterms'].spatial list_s(t._acd,
1006
+ opt_r(t._9))
1007
+ }
1008
+ end
1009
+
1010
+ def marc2dc_spatial_034_1(xml)
1011
+ # "Schaal: " [MARC 034 1_ $a]
1012
+ each_field('0341_', 'a') { |f|
1013
+ xml['dcterms'].spatial element(f, prefix: 'Schaal: ')
1014
+ }
1015
+ end
1016
+
1017
+ def marc2dc_spatial_034_3(xml)
1018
+ # "Schaal: " [MARC 034 3_ $a*]
1019
+ all_tags('0343_', 'a') { |t|
1020
+ xml['dcterms'].spatial repeat(t.a_a, prefix: 'Schaal: ')
1021
+ }
1022
+ end
1023
+
1024
+ def marc2dc_spatial_034_9(xml)
1025
+ # [MARC 034 91 $d] " " [MARC 034 91 $e] " " [MARC 034 91 $f] " " [MARC 034 91 $g]
1026
+ all_tags('03491', 'd e f g') { |t| xml['dcterms'].spatial list_s(t._defg) }
1027
+ end
1028
+
1029
+ def marc2dc_spatial_507(xml)
1030
+ # [MARC 507 __ $a]
1031
+ each_field('507__', 'a') { |f| xml['dcterms'].spatial f }
1032
+ end
1033
+
1034
+ def marc2dc_spatial_651__0(xml)
1035
+ # [MARC 651 #0 $a] " " [MARC 651 #0 $x*] " " [MARC 651 #0 $y] " " [MARC 651 #0 $z]
1036
+ all_tags('651#0', 'a x y z') { |t|
1037
+ xml['dcterms'].spatial({'xsi:type' => 'http://purl.org/dc/terms/LCSH'}).text list_s(t._a,
1038
+ repeat(t.a_x),
1039
+ t._yz)
1040
+ }
1041
+ end
1042
+
1043
+ def marc2dc_spatial_651__2(xml)
1044
+ # [MARC 651 #2 $a] " " [MARC 651 #2 $x*]
1045
+ all_tags('651#2', 'a x') { |t|
1046
+ xml['dcterms'].spatial({'xsi:type' => 'http://purl.org/dc/terms/LCSH'}).text list_s(t._a,
1047
+ repeat(t.a_x))
1048
+ }
1049
+ end
1050
+
1051
+ def marc2dc_extent(xml)
1052
+ # DCTERMS:EXTENT
1053
+ marc2dc_extent_300__(xml)
1054
+ marc2dc_extent_300_9(xml)
1055
+ marc2dc_extent_306(xml)
1056
+ marc2dc_extent_309(xml)
1057
+ marc2dc_extent_339(xml)
1058
+ end
1059
+
1060
+ def marc2dc_extent_300__(xml)
1061
+ # [MARC 300 __ $a*] " " [MARC 300 __ $b] " " [MARC 300__ $c*] " " [MARC 300 __ $e] " (" [MARC 300 __ $9] ")"
1062
+ all_tags('300__', 'a b c e 9') { |t|
1063
+ xml['dcterms'].extent list_s(repeat(t.a_a),
1064
+ t._b,
1065
+ repeat(t.a_c),
1066
+ t._e,
1067
+ opt_r(t._9))
1068
+ }
1069
+ end
1070
+
1071
+ def marc2dc_extent_300_9(xml)
1072
+ # [MARC 300 9_ $a] " " [MARC 300 9_ $b] " " [MARC 300 9_ $c*] " " [MARC 300 9_ $e] " (" [MARC 300 9_ $9]")"
1073
+ all_tags('3009_', 'a b c e 9') { |t|
1074
+ xml['dcterms'].extent list_s(t._ab,
1075
+ repeat(t.a_c),
1076
+ t._e,
1077
+ opt_r(t._9))
1078
+ }
1079
+ end
1080
+
1081
+ def marc2dc_extent_306(xml)
1082
+ # [MARC 306 __ $a*]
1083
+ all_tags('306__', 'a') { |t| xml['dcterms'].extent repeat(t.a_a.collect { |y| y.scan(/(\d\d)(\d\d)(\d\d)/).join(':') }) }
1084
+ end
1085
+
1086
+ def marc2dc_extent_309(xml)
1087
+ # [MARC 309 __ $a]
1088
+ each_field('309__', 'a') { |f| xml['dcterms'].extent f }
1089
+ end
1090
+
1091
+ def marc2dc_extent_339(xml)
1092
+ # [MARC 339 __ $a*]
1093
+ all_tags('339__', 'a') { |t| xml['dcterms'].extent repeat(t.a_a) }
1094
+ end
1095
+
1096
+ def marc2dc_accrualperiodicity(xml)
1097
+ # DCTERMS:ACCRUALPERIODICITY
1098
+
1099
+ # [MARC 310 __ $a] " (" [MARC 310 __ $b] ")"
1100
+ all_tags('310__', 'a b') { |t|
1101
+ xml['dcterms'].accrualPeriodicity list_s(t._a,
1102
+ opt_r(t._b))
1103
+ }
1104
+ end
1105
+
1106
+ def marc2dc_format(xml)
1107
+ # DC:FORMAT
1108
+
1109
+ # [MARC 340 __ $a*]
1110
+ all_tags('340__', 'a') { |t|
1111
+ xml['dc'].format repeat(t.a_a)
1112
+ }
1113
+ end
1114
+
1115
+ def marc2dc_medium(xml)
1116
+ # DCTERMS:MEDIUM
1117
+ marc2dc_medium_319__(xml)
1118
+ marc2dc_medium_319_9(xml)
1119
+ marc2dc_medium_399(xml)
1120
+ end
1121
+
1122
+ def marc2dc_medium_319__(xml)
1123
+ # [MARC 319 __ $a]
1124
+ each_field('319__', 'a') { |f| xml['dcterms'].medium f }
1125
+ end
1126
+
1127
+ def marc2dc_medium_319_9(xml)
1128
+ # [MARC 319 9_ $a] " (" [MARC 319 9_ $9] ")"
1129
+ all_tags('3199_', 'a 9') { |t|
1130
+ xml['dcterms'].medium list_s(t._a,
1131
+ opt_r(t._9))
1132
+ }
1133
+ end
1134
+
1135
+ def marc2dc_medium_399(xml)
1136
+ # [MARC 399 __ $a] " " [MARC 399 __ $b] " (" [MARC 399 __ $9] ")"
1137
+ all_tags('399__', 'a b 9') { |t|
1138
+ xml['dcterms'].medium list_s(t._ab,
1139
+ opt_r(t._9))
1140
+ }
1141
+ end
1142
+
1143
+ def marc2dc_relation(xml)
1144
+ # DC:RELATION
1145
+
1146
+ # [MARC 580 __ $a]
1147
+ each_field('580__', 'a') { |e| xml['dc'].relation e }
1148
+ end
1149
+
1150
+ def marc2dc_replaces(xml)
1151
+ # DCTERMS:REPLACES
1152
+
1153
+ # [MARC 247 1# $a] " : " [MARC 247 1# $b] " (" [MARC 247 1# $9] ")"
1154
+ all_tags('2471#', 'a b 9') { |t|
1155
+ xml['dcterms'].replaces list_s(element(t._a, t._b, join: ' : '), opt_r(t._9))
1156
+ }
1157
+ end
1158
+
1159
+ def marc2dc_hasversion(xml)
1160
+ # DCTERMS:HASVERSION
1161
+
1162
+ # [MARC 534 __ $a]
1163
+ each_field('534__', 'a') { |f| xml['dcterms'].hasVersion f }
1164
+ end
1165
+
1166
+ def marc2dc_source(xml)
1167
+ # DC:SOURCE
1168
+ marc2dc_source_852___(xml)
1169
+ marc2dc_source_856(xml)
1170
+ end
1171
+
1172
+ def marc2dc_source_852___(xml)
1173
+ # [MARC 852 __ $b] " " [MARC 852 __ $c] " " [MARC 852 __ $k] " " [MARC 852 __ $h] " " [MARC 852 __ $9] " " [MARC 852 __ $l] " " [MARC 852 __ $m]
1174
+ all_tags('852__', 'b c k h 9 l m') { |t|
1175
+ xml['dc'].source list_s(t._bckh9lm)
1176
+ }
1177
+ end
1178
+
1179
+ def marc2dc_source_856(xml)
1180
+ marc2dc_source_856__1(xml)
1181
+ marc2dc_source_856__2(xml)
1182
+ marc2dc_source_856_4(xml)
1183
+ end
1184
+
1185
+ def marc2dc_source_856__1(xml)
1186
+ # [MARC 856 _1 $u]
1187
+ all_tags('856_1', 'uy') { |t|
1188
+ xml['dc'].source('xsi:type' => 'dcterms:URI').text element(t._u,
1189
+ repeat(t.a_y.collect { |y| CGI::escape(y) }),
1190
+ join: '#')
1191
+ }
1192
+ end
1193
+
1194
+ def marc2dc_source_856__2(xml)
1195
+ # [MARC 856 _2 $u]
1196
+ all_tags('856_2', 'uy') { |t|
1197
+ xml['dc'].source('xsi:type' => 'dcterms:URI').text element(t._u,
1198
+ repeat(t.a_y.collect { |y| CGI::escape(y) }),
1199
+ join: '#')
1200
+ }
1201
+ end
1202
+
1203
+ def marc2dc_source_856_4(xml)
1204
+ # [MARC 856 40 $u]
1205
+ all_tags('85640', 'u') { |t|
1206
+ xml['dc'].source('xsi:type' => 'dcterms:URI').text element(t._u)
1207
+ }
1208
+ end
1209
+
1210
+ def marc2dc_language(xml)
1211
+ # DC:LANGUAGE
1212
+ marc2dc_language_041_9(xml)
1213
+ marc2dc_language_008(xml)
1214
+ marc2dc_language_130(xml)
1215
+ marc2dc_language_240(xml)
1216
+ marc2dc_language_546(xml)
1217
+ end
1218
+
1219
+ def marc2dc_language_041_9(xml)
1220
+ marc2dc_language_041_9_(xml)
1221
+ marc2dc_language_041__9(xml)
1222
+ end
1223
+
1224
+ def marc2dc_language_041_9_(xml)
1225
+ marc2dc_language_041_9___a(xml)
1226
+ marc2dc_language_041_9__d(xml)
1227
+ marc2dc_language_041_9__e(xml)
1228
+ marc2dc_language_041_9__f(xml)
1229
+ marc2dc_language_041_9__h(xml)
1230
+ marc2dc_language_014_9__9(xml)
1231
+ end
1232
+
1233
+ def marc2dc_language_041_9___a(xml)
1234
+ # [MARC 041 9_ $a*]
1235
+ all_tags('0419_', 'a') { |t|
1236
+ xml['dc'].language repeat(t.a_a.collect { |y| taalcode(y) })
1237
+ }
1238
+ end
1239
+
1240
+ def marc2dc_language_041_9__d(xml)
1241
+ # [MARC 041 9_ $d*]
1242
+ all_tags('0419_', 'd') { |t|
1243
+ xml['dc'].language repeat(t.a_d.collect { |y| taalcode(y) })
1244
+ }
1245
+ end
1246
+
1247
+ def marc2dc_language_041_9__e(xml)
1248
+ # [MARC 041 9_ $e*]
1249
+ all_tags('0419_', 'e') { |t|
1250
+ xml['dc'].language repeat(t.a_e.collect { |y| taalcode(y) })
1251
+ }
1252
+ end
1253
+
1254
+ def marc2dc_language_041_9__f(xml)
1255
+ # [MARC 041 9_ $f*]
1256
+ all_tags('0419_', 'f') { |t|
1257
+ xml['dc'].language repeat(t.a_f.collect { |y| taalcode(y) })
1258
+ }
1259
+ end
1260
+
1261
+ def marc2dc_language_041_9__h(xml)
1262
+ # [MARC 041 9_ $h*]
1263
+ all_tags('0419_', 'h') { |t|
1264
+ xml['dc'].language repeat(t.a_h.collect { |y| taalcode(y) })
1265
+ }
1266
+ end
1267
+
1268
+ def marc2dc_language_014_9__9(xml)
1269
+ # [MARC 041 9_ $9*]
1270
+ all_tags('0419_', '9') { |t|
1271
+ xml['dc'].language repeat(t.a_9.collect { |y| taalcode(y) })
1272
+ }
1273
+ end
1274
+
1275
+ def marc2dc_language_041__9(xml)
1276
+ marc2dc_language_041__9_a(xml)
1277
+ marc2dc_language_041__9_h(xml)
1278
+ marc2dc_language_041__9_9(xml)
1279
+ end
1280
+
1281
+ def marc2dc_language_041__9_a(xml)
1282
+ # "Gedubde taal: " [MARC 041 _9 $a*]
1283
+ all_tags('041_9', 'a') { |t|
1284
+ xml['dc'].language repeat(t.a_a.collect { |y| taalcode(y) }, prefix: 'Gedubde taal:')
1285
+ }
1286
+ end
1287
+
1288
+ def marc2dc_language_041__9_h(xml)
1289
+ # [MARC 041 _9 $h*]
1290
+ all_tags('041_9', 'h') { |t|
1291
+ xml['dc'].language repeat(t.a_h.collect { |y| taalcode(y) })
1292
+ }
1293
+ end
1294
+
1295
+ def marc2dc_language_041__9_9(xml)
1296
+ # "Ondertitels: " [MARC 041 _9 $9*]
1297
+ all_tags('041_9', '9') { |t|
1298
+ xml['dc'].language element(t.a_9.collect { |y| taalcode(y) }, prefix: 'Ondertitels:')
1299
+ }
1300
+ end
1301
+
1302
+ def marc2dc_language_008(xml)
1303
+ # [MARC 008 (35-37)]
1304
+ all_tags('008') { |t|
1305
+ xml['dc'].language taalcode(t.datas[35..37])
1306
+ } if all_tags('041').empty?
1307
+ end
1308
+
1309
+ def marc2dc_language_130(xml)
1310
+ # [MARC 130 #_ $l]
1311
+ each_field('130#_', 'l') { |f| xml['dc'].language f }
1312
+ end
1313
+
1314
+ def marc2dc_language_240(xml)
1315
+ # [MARC 240 #_ $l]
1316
+ each_field('240#_', 'l') { |f| xml['dc'].language f }
1317
+ end
1318
+
1319
+ def marc2dc_language_546(xml)
1320
+ # [MARC 546 __ $a]
1321
+ each_field('546__', 'a') { |f| xml['dc'].language f }
1322
+
1323
+ # []MARC 546 9_ $a]
1324
+ each_field('5469_', 'a') { |f| xml['dc'].language f }
1325
+
1326
+ # [MARC 546 _9 $a]
1327
+ each_field('546_9', 'a') { |f| xml['dc'].language f }
1328
+ end
1329
+
1330
+ def marc2dc_rightsholder(xml)
1331
+ # DCTERMS:RIGHTSHOLDER
1332
+ marc2dc_rightsholder_700(xml)
1333
+ marc2dc_rightsholder_710(xml)
1334
+ end
1335
+
1336
+ def marc2dc_rightsholder_700(xml)
1337
+ # [MARC 700 0_ $a] ", " [MARC 700 0_ $b] ", " [MARC 700 0_ $c] ", " [MARC 700 0_ $d] ", " [MARC 700 0_ $g] ", " [MARC 700 0_ $e] (als $4 cph)
1338
+ all_tags('7000_', '4') { |t|
1339
+ next unless check_name(t, :rightsholder)
1340
+ xml['dcterms'].rightsholder element(t._abcdge, join: ', ')
1341
+ }
1342
+ end
1343
+
1344
+ def marc2dc_rightsholder_710(xml)
1345
+ # [MARC 710 2_ $a] " (" [MARC 710 2_ $g] "), (" [MARC 710 2_ $9] ") ("[MARC 710 2_ $e]")" (als $4 cph)
1346
+ all_tags('7102_', '4') { |t|
1347
+ next unless check_name(t, :rightsholder)
1348
+ xml['dcterms'].rightsholder element(list_s(t._a,
1349
+ opt_r(t._g)),
1350
+ list_s(opt_r(t._9),
1351
+ opt_r(t._e)),
1352
+ join: ', ')
1353
+ }
1354
+ end
1355
+
1356
+ def marc2dc_references(xml)
1357
+ # DCTERMS:REFERENCES
1358
+
1359
+ # [MARC 581 __ $a]
1360
+ each_field('581__', 'a') { |f| xml['dcterms'].references f }
1361
+ end
1362
+
1363
+ def marc2dc_isreferencedby(xml)
1364
+ # DCTERMS:ISREFERENCEDBY
1365
+ marc2dc_isreferencedby_510_0(xml)
1366
+ marc2dc_isreferencedby_510_3(xml)
1367
+ marc2dc_isreferencedby_510_4(xml)
1368
+ end
1369
+
1370
+ def marc2dc_isreferencedby_510_0(xml)
1371
+ # [MARC 510 0_ $a] ", " [MARC 510 0_ $c]
1372
+ all_tags('5100_', 'a c') { |t|
1373
+ xml['dcterms'].isReferencedBy element(t._ac, join: ', ')
1374
+ }
1375
+ end
1376
+
1377
+ def marc2dc_isreferencedby_510_3(xml)
1378
+ # [MARC 510 3_ $a] ", " [MARC 510 3_ $c]
1379
+ all_tags('5103_', 'a c') { |t|
1380
+ xml['dcterms'].isReferencedBy element(t._ac, join: ', ')
1381
+ }
1382
+ end
1383
+
1384
+ def marc2dc_isreferencedby_510_4(xml)
1385
+ # [MARC 510 4_ $a] ", " [MARC 510 4_ $c]
1386
+ all_tags('5104_', 'a c') { |t|
1387
+ xml['dcterms'].isReferencedBy element(t._ac, join: ', ')
1388
+ }
1389
+ end
1390
+
1391
+ protected
1392
+
1393
+ def check_name(data, b)
1394
+ name_type(data) == b
1395
+ end
1396
+
1397
+ def name_type(data)
1398
+ #noinspection RubyResolve
1399
+ code = data._4.to_sym
1400
+ if DOLLAR4TABLE[data.tag].has_key? code
1401
+ return DOLLAR4TABLE[data.tag][code][1]
1402
+ end
1403
+ Application.logger.warn(self.class) { "Did not find $4 value in lookuptable: #{data.dump_line}" }
1404
+ :contributor
1405
+ end
1406
+
1407
+ def full_name(data)
1408
+ #noinspection RubyResolve
1409
+ code = data._4.to_sym
1410
+ return '' unless DOLLAR4TABLE[data.tag].has_key? code
1411
+ DOLLAR4TABLE[data.tag][code][0]
1412
+ end
1413
+
1414
+ def taalcode(code)
1415
+ TAALCODES[code.to_sym]
1416
+ end
1417
+
1418
+ def bibnaam(code)
1419
+ BIBCODES[code] || ''
1420
+ end
1421
+
1422
+ def fmt(code)
1423
+ FMT[code.to_sym] || ''
1424
+ end
1425
+
1426
+ def lookup(table, key, constraints = {})
1427
+ table.select { |value| constraints.map { |k,v| value[k] == v }.all? }.map { |v| v[key] }
1428
+ end
1429
+
1430
+ #noinspection RubyStringKeysInHashInspection
1431
+ DOLLAR4TABLE = {
1432
+ '700' => {
1433
+ apb: ['approbation, approbatie, approbation', :contributor],
1434
+ apr: ['preface', nil],
1435
+ arc: ['architect', :contributor],
1436
+ arr: ['arranger', :contributor],
1437
+ art: ['artist', :creator],
1438
+ aui: ['author of introduction', :contributor ],
1439
+ aut: ['author', :creator],
1440
+ bbl: ['bibliography', :contributor],
1441
+ bdd: ['binder', :contributor],
1442
+ bsl: ['bookseller', :contributor],
1443
+ ccp: ['concept', :contributor],
1444
+ chr: ['choreographer', :contributor],
1445
+ clb: ['collaborator', :contributor],
1446
+ cmm: ['commentator (rare books only)', :contributor],
1447
+ cmp: ['composer', :contributor],
1448
+ cnd: ['conductor', :contributor],
1449
+ cns: ['censor, censeur', :contributor],
1450
+ cod: ['co-ordination', :contributor],
1451
+ cof: ['collection from', :contributor],
1452
+ coi: ['compiler index', :contributor],
1453
+ com: ['compiler', :contributor],
1454
+ con: ['consultant', :contributor],
1455
+ cov: ['cover designer', :contributor],
1456
+ cph: ['copyright holder', :rightsholder],
1457
+ cre: ['creator', :creator],
1458
+ csp: ['project manager', :contributor],
1459
+ ctb: ['contributor', :contributor],
1460
+ ctg: ['cartographer', :creator],
1461
+ cur: ['curator', :contributor],
1462
+ dfr: ['defender (rare books only)', :contributor],
1463
+ dgg: ['degree grantor', :contributor],
1464
+ dir: ['director', :creator],
1465
+ dnc: ['dancer', :contributor],
1466
+ dpc: ['depicted', :contributor],
1467
+ dsr: ['designer', :contributor],
1468
+ dte: ['dedicatee', :contributor],
1469
+ dub: ['dubious author', :creator],
1470
+ eda: ['editor assistant', :contributor],
1471
+ edc: ['editor in chief', :creator],
1472
+ ede: ['final editing', :creator],
1473
+ edt: ['editor', :creator],
1474
+ egr: ['engraver', :contributor],
1475
+ eim: ['editor of image', :contributor],
1476
+ eow: ['editor original work', :contributor],
1477
+ etc: ['etcher', :contributor],
1478
+ etr: ['etcher', :contributor],
1479
+ eul: ['eulogist, drempeldichter, panégyriste', :contributor],
1480
+ hnr: ['honoree', :contributor],
1481
+ ihd: ['expert trainee post (inhoudsdeskundige stageplaats)', :contributor],
1482
+ ill: ['illustrator', :contributor],
1483
+ ilu: ['illuminator', :contributor],
1484
+ itr: ['instrumentalist', :contributor],
1485
+ ive: ['interviewee', :contributor],
1486
+ ivr: ['interviewer', :contributor],
1487
+ lbt: ['librettist', :contributor],
1488
+ ltg: ['lithographer', :contributor],
1489
+ lyr: ['lyricist', :contributor],
1490
+ mus: ['musician', :contributor],
1491
+ nrt: ['narrator, reader', :contributor],
1492
+ ogz: ['started by', :creator],
1493
+ oqz: ['continued by', :creator],
1494
+ orc: ['orchestrator', :contributor],
1495
+ orm: ['organizer of meeting', :contributor],
1496
+ oth: ['other', :contributor],
1497
+ pat: ['patron, opdrachtgever, maître d\'oeuvre', :contributor],
1498
+ pht: ['photographer', :creator],
1499
+ prf: ['performer', :contributor],
1500
+ pro: ['producer', :contributor],
1501
+ prt: ['printer', :publisher],
1502
+ pub: ['publication about', :subject],
1503
+ rbr: ['rubricator', :contributor],
1504
+ rea: ['realization', :contributor],
1505
+ reb: ['revised by', :contributor],
1506
+ rev: ['reviewer', :contributor],
1507
+ rpt: ['reporter', :contributor],
1508
+ rpy: ['responsible party', :contributor],
1509
+ sad: ['scientific advice', :contributor],
1510
+ sce: ['scenarist', :contributor],
1511
+ sco: ['scientific co-operator', :contributor],
1512
+ scr: ['scribe', :contributor],
1513
+ sng: ['singer', :contributor],
1514
+ spn: ['sponsor', :contributor],
1515
+ tec: ['technical direction', :contributor],
1516
+ thc: ['thesis co-advisor(s)', :contributor],
1517
+ thj: ['member of the jury', :contributor],
1518
+ ths: ['thesis advisor', :contributor],
1519
+ trc: ['transcriber', :contributor],
1520
+ trl: ['translator', :contributor],
1521
+ udr: ['under direction of', :contributor],
1522
+ voc: ['vocalist', :contributor],
1523
+ },
1524
+ '710' => {
1525
+ adq: ['readapted by', :contributor],
1526
+ add: ['addressee, bestemmeling', :contributor],
1527
+ aow: ['author original work, auteur oorspronkelijk werk, auteur ouvrage original', :contributor],
1528
+ apr: ['preface', :/],
1529
+ arc: ['architect', :contributor],
1530
+ art: ['artist', :creator],
1531
+ aut: ['author', :creator],
1532
+ bbl: ['bibliography', :contributor],
1533
+ bdd: ['binder', :contributor],
1534
+ bsl: ['bookseller', :contributor],
1535
+ ccp: ['Conceptor', :contributor],
1536
+ clb: ['collaborator', :contributor],
1537
+ cod: ['co-ordination', :contributor],
1538
+ cof: ['collection from', :contributor],
1539
+ coi: ['compiler index', :contributor],
1540
+ com: ['compiler', :contributor],
1541
+ con: ['consultant', :contributor],
1542
+ cov: ['cover designer', :contributor],
1543
+ cph: ['copyright holder', :rightsholder],
1544
+ cre: ['creator', :creator],
1545
+ csp: ['project manager', :contributor],
1546
+ ctb: ['contributor', :contributor],
1547
+ ctg: ['cartographer', :contributor],
1548
+ cur: ['curator', :contributor],
1549
+ dgg: ['degree grantor', :contributor],
1550
+ dnc: ['dancer', :contributor],
1551
+ dsr: ['designer', :contributor],
1552
+ dte: ['dedicatee', :contributor],
1553
+ eda: ['editor assistant', :contributor],
1554
+ edc: ['editor in chief', :creator],
1555
+ ede: ['final editing', :creator],
1556
+ edt: ['editor', :creator],
1557
+ egr: ['engraver', :contributor],
1558
+ eim: ['editor of image', :contributor],
1559
+ eow: ['editor original work', :contributor],
1560
+ etc: ['etcher', :contributor],
1561
+ eul: ['eulogist, drempeldichter, panégyriste', :contributor],
1562
+ hnr: ['honoree', :contributor],
1563
+ itr: ['instrumentalist', :contributor],
1564
+ ltg: ['lithographer', :contributor],
1565
+ mus: ['musician', :contributor],
1566
+ ogz: ['started by', :creator],
1567
+ oqz: ['continued by', :creator],
1568
+ ori: ['org. institute (rare books/mss only)', :contributor],
1569
+ orm: ['organizer of meeting', :contributor],
1570
+ oth: ['other', :contributor],
1571
+ pat: ['patron', :contributor],
1572
+ pht: ['photographer', :creator],
1573
+ prf: ['performer', :contributor],
1574
+ pro: ['producer', :contributor],
1575
+ prt: ['printer', :publisher],
1576
+ pub: ['publication about', :subject],
1577
+ rea: ['realization', :contributor],
1578
+ rpt: ['reporter', :contributor],
1579
+ rpy: ['responsible party', :contributor],
1580
+ sad: ['scientific advice', :contributor],
1581
+ sco: ['scientific co-operator', :contributor],
1582
+ scp: ['scriptorium', :contributor],
1583
+ sng: ['singer', :contributor],
1584
+ spn: ['sponsor', :contributor],
1585
+ tec: ['technical direction', :contributor],
1586
+ trc: ['transcriber', :contributor],
1587
+ trl: ['translator', :contributor],
1588
+ udr: ['under direction of', :contributor],
1589
+ voc: ['vocalist', :contributor],
1590
+ },
1591
+ '711' => {
1592
+ oth: ['other', :contributor],
1593
+ },
1594
+ '100' => {
1595
+ arr: ['arranger', :contributor],
1596
+ aut: ['author', :creator],
1597
+ cmp: ['composer', :contributor],
1598
+ com: ['compiler', :contributor],
1599
+ cre: ['creator', :creator],
1600
+ ctg: ['cartographer', :creator],
1601
+ ill: ['illustrator', :contributor],
1602
+ ivr: ['interviewer', :contributor],
1603
+ lbt: ['librettist', :contributor],
1604
+ lyr: ['lyricist', :contributor],
1605
+ pht: ['photographer', :creator],
1606
+ }
1607
+ }
1608
+
1609
+ TAALCODES = {
1610
+ afr: 'af',
1611
+ ara: 'ar',
1612
+ chi: 'zh',
1613
+ cze: 'cs',
1614
+ dan: 'da',
1615
+ dum: 'dum',
1616
+ dut: 'nl',
1617
+ est: 'et',
1618
+ eng: 'en',
1619
+ fin: 'fi',
1620
+ fre: 'fr',
1621
+ frm: 'frm',
1622
+ ger: 'de',
1623
+ grc: 'grc',
1624
+ gre: 'el',
1625
+ hun: 'hu',
1626
+ fry: 'fy',
1627
+ ita: 'it',
1628
+ jpn: 'ja',
1629
+ lat: 'la',
1630
+ lav: 'lv',
1631
+ liv: 'lt',
1632
+ ltz: 'lb',
1633
+ mlt: 'mt',
1634
+ nor: 'no',
1635
+ pol: 'pl',
1636
+ por: 'pt',
1637
+ rus: 'ru',
1638
+ slo: 'sk',
1639
+ slv: 'sl',
1640
+ spa: 'es',
1641
+ swe: 'sv',
1642
+ tur: 'tr',
1643
+ ukr: 'uk',
1644
+ syc: '',
1645
+ syr: '',
1646
+ heb: '',
1647
+ cop: '',
1648
+ }
1649
+
1650
+ #noinspection RubyStringKeysInHashInspection
1651
+ BIBCODES = {
1652
+ '01' => 'K.U.Leuven',
1653
+ '02' => 'KADOC',
1654
+ '03' => 'BB(Boerenbond)/KBC',
1655
+ '04' => 'HUB',
1656
+ '05' => 'ACV',
1657
+ '06' => 'LIBAR',
1658
+ '07' => 'SHARE',
1659
+ '10' => 'BPB',
1660
+ '11' => 'VLP',
1661
+ '12' => 'TIFA',
1662
+ '13' => 'LESSIUS',
1663
+ '14' => 'SERV',
1664
+ '15' => 'ACBE',
1665
+ '16' => 'SLUCB',
1666
+ '17' => 'SLUCG',
1667
+ '18' => 'HUB',
1668
+ '19' => 'KHBO',
1669
+ '20' => 'FINBI',
1670
+ '21' => 'BIOET',
1671
+ '22' => 'LUKAS',
1672
+ '23' => 'KHM',
1673
+ '24' => 'Fonds',
1674
+ '25' => 'RBINS',
1675
+ '26' => 'RMCA',
1676
+ '27' => 'NBB',
1677
+ '28' => 'Pasteurinstituut',
1678
+ '29' => 'Vesalius',
1679
+ '30' => 'Lemmensinstituut',
1680
+ '31' => 'KHLIM',
1681
+ '32' => 'KATHO',
1682
+ '33' => 'KAHO',
1683
+ '34' => 'HUB',
1684
+ }
1685
+
1686
+ FMT = {
1687
+ BK: 'Books',
1688
+ SE: 'Continuing Resources',
1689
+ MU: 'Music',
1690
+ MP: 'Maps',
1691
+ VM: 'Visual Materials',
1692
+ AM: 'Audio Materials',
1693
+ CF: 'Computer Files',
1694
+ MX: 'Mixed Materials',
1695
+ }
1696
+
1697
+ end
1698
+
1699
+ end
1700
+ end
1701
+ end
1702
+ end