Sha256: 892da7bfb22d85a080c9f3b3e994fe17d173ef9327b9aae46db6829d11969f86

Contents?: true

Size: 1.67 KB

Versions: 44

Compression:

Stored size: 1.67 KB

Contents

class DarwinCore
  class Generator
    class EmlXml
      def initialize(data, path)
        @data = data
        @path = path
        @write = R19 ? 'w:utf-8' : 'w'
      end
      def create
        builder = Nokogiri::XML::Builder.new do |xml|
          xml.eml( :packageId => "eml.1.1",
                 :system => "knb",
                 'xmlns:eml' => "eml://ecoinformatics.org/eml-2.1.0", 
                 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
                 'xsi:schemaLocation' => "eml://ecoinformatics.org/eml-2.1.0 eml.xsd" ) do
            xml.dataset(:id => @data[:id]) do
              xml.title(@data[:title])
              contacts = []
              @data[:authors].each_with_index do |a, i|
                creator_id = i + 1
                contacts << creator_id
                xml.creator(:id => creator_id, :scope => 'document') do
                  xml.individualName do
                    xml.givenName(a[:first_name])
                    xml.surName(a[:last_name])
                  end
                  xml.electronicMailAddress(a[:email])
                end
              end
              xml.abstract(@data[:abstract])
              contacts.each do |contact|
                xml.contact { xml.references(contact) }
              end
            end
            xml.additionalMetadata do
              xml.metadata do
                xml.citation(@data[:citation])
              end
            end
            xml.parent.namespace = xml.parent.namespace_definitions.first
          end
        end
        data = builder.to_xml
        f = open(File.join(@path, 'eml.xml'), @write)
        f.write(data)
        f.close
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
dwc-archive-0.7.6 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.7.5 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.7.4 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.7.3 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.7.2 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.7.1 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.7.0 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.6.0 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.18 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.17 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.16 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.15 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.14 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.13 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.12 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.11 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.10 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.9 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.8 lib/dwc-archive/generator_eml_xml.rb
dwc-archive-0.5.7 lib/dwc-archive/generator_eml_xml.rb