Method: IsoDoc::Function::References#pref_ref_code

Defined in:
lib/isodoc/function/references.rb

#pref_ref_code(bib) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/isodoc/function/references.rb', line 52

def pref_ref_code(bib)
  return nil if bib["suppress_identifier"] == "true"

  ret = bib.xpath(ns("./docidentifier[@primary = 'true'][@language = '#{@lang}']"))
  ret.empty? and
    ret = bib.xpath(ns("./docidentifier[@primary = 'true']"))
  ret.empty? and
    ret = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
                    "@type = 'metanorma' "\
                    "or @type = 'metanorma-ordinal' or "\
                    "@type = 'ISSN' or @type = 'ISBN')]"\
                    "[@language = '#{@lang}']")) ||
      bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
                "@type = 'metanorma' "\
                "or @type = 'metanorma-ordinal' or "\
                "@type = 'ISSN' or @type = 'ISBN')]"))
  ret
end