Module: Blacklight::Solr::Document::DublinCore

Defined in:
vendor/plugins/blacklight/lib/blacklight/solr/document/dublin_core.rb

Overview

This module provide Dublin Core export based on the document’s semantic values

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) extended(document)



3
4
5
6
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document/dublin_core.rb', line 3

def self.extended(document)
  # Register our exportable formats
  Blacklight::Solr::Document::DublinCore.register_export_formats( document )
end

+ (Object) register_export_formats(document)



8
9
10
11
12
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document/dublin_core.rb', line 8

def self.register_export_formats(document)
  document.will_export_as(:xml)
  document.will_export_as(:dc_xml, "text/xml")
  document.will_export_as(:oai_dc_xml, "text/xml")
end

Instance Method Details

- (Object) dublin_core_field_names



14
15
16
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document/dublin_core.rb', line 14

def dublin_core_field_names
  [:contributor, :coverage, :creator, :date, :description, :format, :identifier, :language, :publisher, :relation, :rights, :source, :subject, :title, :type]
end

- (Object) export_as_oai_dc_xml Also known as: export_as_dc_xml, export_as_xml

dublin core elements are mapped against the #dublin_core_field_names whitelist.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document/dublin_core.rb', line 19

def export_as_oai_dc_xml
  xml = Builder::XmlMarkup.new
  xml.tag!("oai_dc:dc",
           'xmlns:oai_dc' => "http://www.openarchives.org/OAI/2.0/oai_dc/",
           'xmlns:dc' => "http://purl.org/dc/elements/1.1/",
           'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
           'xsi:schemaLocation' => %{http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd}) do
     self.to_semantic_values.select { |field, values| dublin_core_field_names.include? field.to_sym }.each do |field,values|
       values.each do |v|
         xml.tag! 'dc:' + field.to_s, v
       end
     end
   end
  xml.target!
end