From 0471800f559ad225fc5490061a4e32e9dbaaaa82 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 24 Jul 2024 23:27:07 +1000 Subject: [PATCH] multilingual publisher processing for metadata: https://github.com/relaton/relaton-models/issues/56 --- lib/isodoc/metadata_contributor.rb | 13 ++++--------- lib/isodoc/presentation_function/inline.rb | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/isodoc/metadata_contributor.rb b/lib/isodoc/metadata_contributor.rb index b72b8849..7ae357f1 100644 --- a/lib/isodoc/metadata_contributor.rb +++ b/lib/isodoc/metadata_contributor.rb @@ -67,20 +67,15 @@ def agency1(xml) publisher = [] xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/" \ "organization")).each do |org| - name = extract_variant(org.at(ns("./name"))) - agency1 = org.at(ns("./abbreviation"))&.text || name - publisher << name if name + name = org.at(ns("./name[@language = '#{@lang}']")) || + org.at(ns("./name")) + agency1 = org.at(ns("./abbreviation"))&.text || name&.text + publisher << name.text if name agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/" end [agency, publisher] end - def extract_variant(node) - node.nil? and return node - x = node.at(ns("./variant[@language = '#{@lang}']")) and node = x - node.text - end - def agency(xml) agency, publisher = agency1(xml) set(:agency, agency.sub(%r{/$}, "")) diff --git a/lib/isodoc/presentation_function/inline.rb b/lib/isodoc/presentation_function/inline.rb index 6eba8b0b..bd88690d 100644 --- a/lib/isodoc/presentation_function/inline.rb +++ b/lib/isodoc/presentation_function/inline.rb @@ -64,6 +64,7 @@ def xref1(node) get_linkend(node) end + # there should be no //variant in bibdata now def variant(xml) b = xml.xpath(ns("//bibdata//variant")) (xml.xpath(ns("//variant")) - b).each { |f| variant1(f) }