Sha256: dcb3cf363b732a5186e8a6fc866f35c21bc0e1e6421b0436d3a8a79b6f453def

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require "nokogiri"

module RelatonOgc
  class XMLParser < RelatonIsoBib::XMLParser
    class << self
      # Override RelatonIsoBib::XMLParser.form_xml method.
      # @param xml [String]
      # @return [RelatonOgc::OgcBibliographicItem]
      def from_xml(xml)
        doc = Nokogiri::XML(xml)
        isoitem = doc.at "/bibitem|/bibdata"
        if isoitem
          OgcBibliographicItem.new item_data(isoitem)
        else
          warn "[relaton-ogc] can't find bibitem or bibdata element in the XML"
        end
      end

      private

      # @TODO Organization doesn't recreated
      # @param ext [Nokogiri::XML::Element]
      # @return [RelatonIsoBib::EditorialGroup]
      def fetch_editorialgroup(ext)
        eg = ext.at("./editorialgroup")
        return unless eg

        committe = eg&.at("committee")&.text
        sc = iso_subgroup eg&.at("subcommittee")
        wg = iso_subgroup eg&.at("workgroup")
        EditorialGroup.new(
          committee: committe, subcommittee: sc, workgroup: wg,
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-ogc-0.7.0 lib/relaton_ogc/xml_parser.rb