From fef6b91336e84a7fc53e41e5c65b0268481a6723 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Mon, 4 Mar 2024 23:50:07 +1100 Subject: [PATCH] defensive coding, authoritative identifiers: metanorma/metanorma-iso#1114 --- lib/isodoc/function/references.rb | 21 ++------------------- lib/isodoc/version.rb | 2 +- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/lib/isodoc/function/references.rb b/lib/isodoc/function/references.rb index fd9d8d6d..4feb86b9 100644 --- a/lib/isodoc/function/references.rb +++ b/lib/isodoc/function/references.rb @@ -29,33 +29,16 @@ def std_bibitem_entry(list, bib, _ordinal, biblio) SKIP_DOCID = <<~XPATH.strip.freeze @type = 'DOI' or @type = 'doi' or @type = 'ISSN' or @type = 'issn' or @type = 'ISBN' or @type = 'isbn' or starts-with(@type, 'ISSN.') or starts-with(@type, 'ISBN.') or starts-with(@type, 'issn.') or starts-with(@type, 'isbn.') XPATH -=begin - SKIP_DOC1 = <<~XPATH.strip.freeze - #{SKIP_DOCID} or @type = 'metanorma-ordinal' or @type = 'metanorma' - XPATH - PRIMARY_ID = "docidentifier[@primary = 'true']".freeze -=end def pref_ref_code(bib) bib["suppress_identifier"] == "true" and return nil @bibrenderer ||= bibrenderer data, = @bibrenderer.parse(bib) - ret = data[:authoritative_identifier] + ret = data[:authoritative_identifier] or return nil ret.empty? and return nil ret end -=begin - def pref_ref_code1(bib) - lang = "[@language = '#{@lang}']" - ret = bib.xpath(ns("./#{PRIMARY_ID}[not(#{SKIP_DOCID})]#{lang}")) - ret.empty? and - ret = bib.xpath(ns("./#{PRIMARY_ID}[not(#{SKIP_DOCID})]")) - ret.empty? and - ret = bib.at(ns("./docidentifier[not(#{SKIP_DOC1})]#{lang}")) || - bib.at(ns("./docidentifier[not(#{SKIP_DOC1})]")) - ret - end -=end + # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers def bibitem_ref_code(bib) id = bib.at(ns("./docidentifier[@type = 'metanorma']")) diff --git a/lib/isodoc/version.rb b/lib/isodoc/version.rb index 4865875f..9257543f 100644 --- a/lib/isodoc/version.rb +++ b/lib/isodoc/version.rb @@ -1,3 +1,3 @@ module IsoDoc - VERSION = "2.9.1".freeze + VERSION = "2.9.2".freeze end