lib/relaton_nist/xml_parser.rb in relaton-nist-1.2.1 vs lib/relaton_nist/xml_parser.rb in relaton-nist-1.2.2

- old
+ new

@@ -41,8 +41,22 @@ CommentPeriod.new( from: cp.at("from").text, to: cp.at("to")&.text, extended: cp.at("extended")&.text ) end + + # @param item [Nokogiri::XML::Element] + # @return [Array<RelatonBib::DocumentRelation>] + def fetch_relations(item) + item.xpath("./relation").map do |rel| + DocumentRelation.new( + type: rel[:type]&.empty? ? nil : rel[:type], + description: relation_description(rel), + bibitem: bib_item(item_data(rel.at("./bibitem"))), + locality: localities(rel), + source_locality: source_localities(rel), + ) + end + end end end end