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