lib/bolognese/readers/datacite_reader.rb in bolognese-1.0.20 vs lib/bolognese/readers/datacite_reader.rb in bolognese-1.0.21

- old
+ new

@@ -50,11 +50,15 @@ def read_datacite(string: nil, **options) read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:string, :sandbox)) doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks) - ns = doc.collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") } - schema_version = Array.wrap(ns).last || "http://datacite.org/schema/kernel-4" + if read_options.present? + schema_version = "http://datacite.org/schema/kernel-4" + else + ns = doc.collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") } + schema_version = Array.wrap(ns).last || "http://datacite.org/schema/kernel-4" + end doc.remove_namespaces! string = doc.to_xml(:indent => 2) meta = Maremma.from_xml(string).to_h.fetch("resource", {})