Class: DarwinCore::Generator::EmlXml

Inherits:
Object
  • Object
show all
Defined in:
lib/dwc_archive/generator_eml_xml.rb

Overview

Creates EML file with meta information about archive

Constant Summary collapse

SCHEMA_DATA =
{
  :"xml:lang" =>           "en",
  :"xmlns:eml" =>          "eml://ecoinformatics.org/eml-2.1.1",
  :"xmlns:md" =>           "eml://ecoinformatics.org/methods-2.1.1",
  :"xmlns:proj" =>         "eml://ecoinformatics.org/project-2.1.1",
  :"xmlns:d" =>            "eml://ecoinformatics.org/dataset-2.1.1",
  :"xmlns:res" =>          "eml://ecoinformatics.org/resource-2.1.1",
  :"xmlns:dc" =>           "http://purl.org/dc/terms/",
  :"xmlns:xsi" =>          "http://www.w3.org/2001/XMLSchema-instance",
  :"xsi:schemaLocation" => "eml://ecoinformatics.org/eml-2.1.1 "\
    "http://rs.gbif.org/schema/eml-gbif-profile/1.0.1/eml.xsd"
}

Instance Method Summary collapse

Constructor Details

#initialize(data, path) ⇒ EmlXml

Returns a new instance of EmlXml.



18
19
20
21
22
# File 'lib/dwc_archive/generator_eml_xml.rb', line 18

def initialize(data, path)
  @data = data
  @path = path
  @write = "w:utf-8"
end

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dwc_archive/generator_eml_xml.rb', line 24

def create
  schema_data = {
    packageId: "#{@data[:id]}/#{timestamp}",
    system: @data[:system] || "http://globalnames.org"
  }.merge(SCHEMA_DATA)
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.eml(schema_data) do
      build_body(xml)
    end
  end
  save_eml(builder)
end