libis-metadata 0.2.0

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