lib/isodoc/nist/metadata.rb in metanorma-nist-0.0.5 vs lib/isodoc/nist/metadata.rb in metanorma-nist-0.0.6
- old
+ new
@@ -9,17 +9,19 @@
super
set(:status, "XXX")
end
def title(isoxml, out)
- main = isoxml&.at(ns("//bibdata/title/title-main"))&.text
+ main = isoxml&.at(ns("//bibdata/title[@type = 'main']"))&.text
set(:doctitle, main)
end
def subtitle(isoxml, _out)
- main = isoxml&.at(ns("//bibdata/title/title-sub"))&.text or return
- set(:docsubtitle, main)
+ main = isoxml&.at(ns("//bibdata/title[@type = 'subtitle']"))&.text
+ set(:docsubtitle, main) if main
+ main = isoxml&.at(ns("//bibdata/title[@type = 'document-class']"))&.text
+ set(:docclasstitle, main) if main
end
def author(isoxml, _out)
tc = isoxml.at(ns("//bibdata/editorialgroup/committee"))
set(:tc, tc.text.upcase) if tc
@@ -30,24 +32,25 @@
docid = isoxml.at(ns("//bibdata/docidentifier[@type = 'nist']"))&.text
docid_long = isoxml.at(ns("//bibdata/docidentifier"\
"[@type = 'nist-long']"))&.text
docnumber = isoxml.at(ns("//bibdata/docnumber"))&.text
set(:docidentifier, docid)
- set(:docidentifier_long, draft_prefix(docid_long, isoxml))
+ set(:docidentifier_long, docid_long)
+ d = draft_prefix(isoxml) and set(:draft_prefix, d)
set(:docnumber, docnumber)
end
- def draft_prefix(docidentifier_long, isoxml)
- return nil if docidentifier_long.nil?
+ def draft_prefix(isoxml)
docstatus = isoxml.at(ns("//bibdata/status/stage"))&.text
- return docidentifier_long unless docstatus && docstatus != "final"
+ return nil unless docstatus &&
+ !%w(final withdrawn).include?(docstatus)
iter = isoxml.at(ns("//bibdata/status/iteration"))&.text
prefix = "DRAFT "
/^\d+$/.match iter and
iter = iter.to_i.localize.to_rbnf_s("OrdinalRules", "digits-ordinal")
prefix += "(#{iter}) " if iter
- prefix + docidentifier_long
+ prefix
end
def draftinfo(draft, revdate)
draftinfo = ""
if draft
@@ -65,19 +68,20 @@
set(:iteration, iter) if iter
set(:status, status_print(docstatus || "final"))
end
def adjust_docstatus(status, iter)
- return unless iter and status
+ return status unless iter and status
status = "initial-public-draft" if status == "public-draft" &&
(iter == "1" || iter == "initial")
status = "final-public-draft" if status == "public-draft" &&
(iter == "final")
status
end
def version(isoxml, _out)
+ #require "byebug"; byebug
super
revdate = get[:revdate]
set(:revdate_monthyear, monthyr(revdate))
end
@@ -131,9 +135,28 @@
super
a = xml.at(ns("//bibdata/uri[@type = 'email']")) and set(:email, a.text)
a = xml.at(ns("//bibdata/uri[@type = 'doi']")) and set(:doi, a.text)
a = xml.at(ns("//bibdata/uri[@type = 'uri' or not(@type)]")) and
set(:url, a.text)
+ end
+
+ def relations1(isoxml, type)
+ ret = []
+ isoxml.xpath(ns("//bibdata/relation[@type = '#{type}']")).each do |x|
+ ret << x.at(ns(".//docidentifier")).text if x.at(ns(".//docidentifier"))
+ end
+ ret
+ end
+
+ def relations(isoxml, _out)
+ ret = relations1(isoxml, "obsoletes")
+ set(:obsoletes, ret) unless ret.empty?
+ ret = relations1(isoxml, "obsoletedBy")
+ set(:obsoletedby, ret) unless ret.empty?
+ ret = relations1(isoxml, "supersedes")
+ set(:supersedes, ret) unless ret.empty?
+ ret = relations1(isoxml, "supersededBy")
+ set(:supersededby, ret) unless ret.empty?
end
end
end
end