Method: ContentDm::GenericMapper#to_xml
- Defined in:
- lib/contentdm/mapper.rb
#to_xml(record, opts = {}) ⇒ Object
Serialize the given Record to a Qualified Dublin Core XML string
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/contentdm/mapper.rb', line 27 def to_xml(record, opts = {}) builder = Nokogiri::XML::Builder.new do |doc| doc.qualifieddc('xmlns:qdc' => "http://epubs.cclrc.ac.uk/xmlns/qdc/", 'xmlns:dc' => "http://purl.org/dc/elements/1.1/", 'xmlns:dcterms' => "http://purl.org/dc/terms/") { record..each_pair { |k,v| (prefix,tag) = k.split(/\./) if v.is_a?(Array) v.each { |value| doc[prefix].send(tag.to_sym) { doc.text(value) } } else doc[prefix].send(tag.to_sym) { doc.text(v) } end } } end builder.to_xml end |