Sha256: 08c818c903e0d82eaf514948f00194af9a197e3f5fd3a4ed287b0d2bb1c52512

Contents?: true

Size: 665 Bytes

Versions: 13

Compression:

Stored size: 665 Bytes

Contents

require "nokogiri"

module RelatonIetf
  class XMLParser < RelatonBib::XMLParser
    class << self
      def from_xml(xml)
        doc = Nokogiri::XML(xml)
        doc.remove_namespaces!
        ietfitem = doc.at("/bibitem|/bibdata")
        if ietfitem
          RelatonIetf::IetfBibliographicItem.new(item_data(ietfitem))
        elsif
          warn "[relato-ietf] can't find bibitem or bibdata element in the XML"
        end
      end

      private

      def item_data(ietfitem)
        data = super
        ext = ietfitem.at "./ext"
        return data unless ext

        data[:doctype] = ext.at("./doctype")&.text
        data
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
relaton-ietf-1.1.4 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.1.3 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.1.2 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.1.1 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.1.0 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.0.4 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.0.3 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.0.2 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.0.1 lib/relaton_ietf/xml_parser.rb
relaton-ietf-1.0.0 lib/relaton_ietf/xml_parser.rb
relaton-ietf-0.12.1 lib/relaton_ietf/xml_parser.rb
relaton-ietf-0.12.0 lib/relaton_ietf/xml_parser.rb
relaton-ietf-0.11.1 lib/relaton_ietf/xml_parser.rb