Skip to content

Commit

Permalink
defensive coding, authoritative identifiers: metanorma/metanorma-iso#…
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Mar 4, 2024
1 parent 84148ce commit fef6b91
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
21 changes: 2 additions & 19 deletions lib/isodoc/function/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']"))
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module IsoDoc
VERSION = "2.9.1".freeze
VERSION = "2.9.2".freeze
end

0 comments on commit fef6b91

Please sign in to comment.