module IsoDoc::Ogc::BaseConvert
Public Instance Methods
abstract(isoxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 40 def abstract(isoxml, out) f = isoxml.at(ns("//preface/abstract")) || return page_break(out) out.div **attr_code(id: f["id"]) do |s| clause_name(nil, f&.at(ns("./title")), s, class: "AbstractTitle") f.elements.each { |e| parse(e, s) unless e.name == "title" } end end
acknowledgements(isoxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 58 def acknowledgements(isoxml, out) f = isoxml.at(ns("//acknowledgements")) || return intro_clause(f, out) end
admitted_term_parse(node, out)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 63 def admitted_term_parse(node, out) out.p **{ class: "AltTerms" } do |p| node.children.each { |c| parse(c, p) } p << " " p.span **{ class: "AdmittedLabel" } do |s| s << l10n(@i18n.admitted) end end end
cleanup(docxml)
click to toggle source
Calls superclass method
# File lib/isodoc/ogc/base_convert.rb, line 23 def cleanup(docxml) super term_cleanup(docxml) end
conformance(isoxml, out, num)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 63 def conformance(isoxml, out, num) f = isoxml.at(ns("//clause[@type = 'conformance']")) or return num out.div **attr_code(id: f["id"]) do |div| clause_name(nil, f&.at(ns("./title")), div, nil) f.elements.each { |e| parse(e, div) unless e.name == "title" } end num end
date_render(date)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 87 def date_render(date) return nil if date.nil? on = date&.at(ns("./on"))&.text from = date&.at(ns("./from"))&.text to = date&.at(ns("./to"))&.text return on if on && !on.empty? return "#{from}–#{to}" if from && !from.empty? nil end
deprecated_term_parse(node, out)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 53 def deprecated_term_parse(node, out) out.p **{ class: "DeprecatedTerms" } do |p| node.children.each { |c| parse(c, p) } p << " " p.span **{ class: "AdmittedLabel" } do |s| s << l10n(@i18n.deprecated) end end end
error_parse(node, out)
click to toggle source
Calls superclass method
# File lib/isodoc/ogc/base_convert.rb, line 9 def error_parse(node, out) case node.name when "hi" then hi_parse(node, out) else super end end
example_label(node, div, name)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 79 def example_label(node, div, name); end
example_name_parse(_node, div, name)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 81 def example_name_parse(_node, div, name) div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p| name&.children&.each { |n| parse(n, p) } end end
example_parse(node, out)
click to toggle source
Calls superclass method
# File lib/isodoc/ogc/base_convert.rb, line 73 def example_parse(node, out) name = node.at(ns("./name")) example_name_parse(node, out, name) # if name super end
extract_city(bib)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 107 def extract_city(bib) bib.at(ns("./place")) end
extract_person_name(bib)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 76 def extract_person_name(bib) p = bib.at(ns("./person/name")) or return c = p.at(ns("./completename")) and return c.text s = p&.at(ns("./surname"))&.text or return i = p.xpath(ns("./initial")) and front = i.map { |e| e.text.gsub(/[^[:upper:]]/, "") }.join i.empty? and f = p.xpath(ns("./forename")) and front = f.map { |e| e.text[0].upcase }.join front ? "#{s} #{front}" : s end
extract_publisher(bib)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 52 def extract_publisher(bib) abbrs = [] names = [] bib.xpath(ns("./contributor[role/@type = 'publisher']"\ "[organization]"))&.each do |c1| n = c1.at(ns("./organization/name")) or next abbrs << (c1.at(ns("./organization/abbreviation")) || n) names << nodes_to_span(n) end return [nil, nil] if names.empty? [multiplenames_and(names), abbrs.map(&:text).join("/")] end
extract_uri(bib)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 111 def extract_uri(bib) bib.at(ns("./uri")) end
extract_year(bib)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 99 def extract_year(bib) d = bib.at(ns("./date[@type = 'published']")) || bib.at(ns("./date[@type = 'issued']")) || bib.at(ns("./date[@type = 'circulated']")) || bib.at(ns("./date")) date_render(d) end
foreword(isoxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 49 def foreword(isoxml, out) f = isoxml.at(ns("//foreword")) || return page_break(out) out.div **attr_code(id: f["id"]) do |s| clause_name(nil, f&.at(ns("./title")), s, class: "ForewordTitle") f.elements.each { |e| parse(e, s) unless e.name == "title" } end end
hi_parse(node, out)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 17 def hi_parse(node, out) out.span **{ class: "hi" } do |e| node.children.each { |n| parse(n, e) } end end
inline_bibitem_ref_code(bib)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 143 def inline_bibitem_ref_code(bib) id = bib.at(ns("./docidentifier[not(@type = 'DOI' "\ "or @type = 'metanorma' or @type = 'ISSN' "\ "or @type = 'ISBN' or @type = 'rfc-anchor')]")) id ||= bib.at(ns("./docidentifier[not(@type = 'metanorma')]")) return [nil, id, nil] if id id = Nokogiri::XML::Node.new("docidentifier", bib.document) id << "(NO ID)" [nil, id, nil] end
intro_clause(elem, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 4 def intro_clause(elem, out) out.div **{ class: "Section3", id: elem["id"] } do |div| clause_name(nil, elem&.at(ns("./title")), div, class: "IntroTitle") elem.elements.each { |e| parse(e, div) unless e.name == "title" } end end
is_clause?(name)
click to toggle source
Calls superclass method
# File lib/isodoc/ogc/base_convert.rb, line 92 def is_clause?(name) return true if name == "submitters" super end
keywords(docxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 11 def keywords(docxml, out) f = docxml.at(ns("//preface/clause[@type = 'keywords']")) || return intro_clause(f, out) end
make_tr_attr(td, row, totalrows, header)
click to toggle source
Calls superclass method
# File lib/isodoc/ogc/base_convert.rb, line 120 def make_tr_attr(td, row, totalrows, header) ret = super if td.at("./ancestor::xmlns:table[@class = 'recommendation'] | "\ "./ancestor::xmlns:table[@class = 'requirement'] | "\ "./ancestor::xmlns:table[@class = 'permission']") ret[:style] = "vertical-align:top;" ret[:class] = "recommend" end ret end
middle(isoxml, out)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 98 def middle(isoxml, out) middle_title(isoxml, out) middle_admonitions(isoxml, out) i = scope isoxml, out, 0 i = conformance isoxml, out, i i = norm_ref isoxml, out, i i = terms_defs isoxml, out, i i = symbols_abbrevs isoxml, out, i clause isoxml, out annex isoxml, out bibliography isoxml, out end
middle_clause(_docxml)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 87 def middle_clause(_docxml) "//clause[parent::sections][not(@type = 'scope' or "\ "@type = 'conformance')][not(descendant::terms)]" end
multiplenames(names)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 32 def multiplenames(names) names.join(", ") end
multiplenames_and(names)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 36 def multiplenames_and(names) return "" if names.empty? return names[0] if names.length == 1 return "#{names[0]} and #{names[1]}" if names.length == 2 names[0..-2].join(", ") + " and #{names[-1]}" end
nodes_to_span(node)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 44 def nodes_to_span(node) noko do |xml| xml.span do |s| node&.children&.each { |x| parse(x, s) } end end.join end
nonstd_bibitem(list, bib, ordinal, bibliography)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 11 def nonstd_bibitem(list, bib, ordinal, bibliography) list.p **attr_code(iso_bibitem_entry_attrs(bib, bibliography)) do |r| id = bibitem_ref_code(bib) identifier = render_identifier(id) identifier[1] = nil if bibliography ref_entry_code(r, ordinal, identifier, id) end reference_format(bib, r) end end
para_class(node)
click to toggle source
Calls superclass method
# File lib/isodoc/ogc/base_convert.rb, line 131 def para_class(node) return node["class"] if node["class"] super end
preface(isoxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 32 def preface(isoxml, out) isoxml.xpath(ns("//preface/clause[not(@type = 'keywords' or "\ "@type = 'submitting_orgs' or @type = 'security')]")) .each do |f| intro_clause(f, out) end end
reference_format(bib, ref)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 23 def reference_format(bib, ref) if ftitle = bib.at(ns("./formattedref")) ftitle&.children&.each { |n| parse(n, ref) } else # eventually will be full LNCS reference standard_citation(ref, bib) end end
security(docxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 22 def security(docxml, out) f = docxml.at(ns("//preface/clause[@type = 'security']")) || return intro_clause(f, out) end
standard_citation(out, bib)
click to toggle source
{author}: {document identifier}, {title}. {publisher}, {city} ({year})
# File lib/isodoc/ogc/biblio.rb, line 116 def standard_citation(out, bib) if ftitle = bib.at(ns("./formattedref")) ftitle&.children&.each { |n| parse(n, out) } else pub, pub_abbrev = extract_publisher(bib) author = extract_author(bib) c = extract_city(bib) y = extract_year(bib) u = extract_uri(bib) out << "#{author || pub_abbrev}: " if author || pub_abbrev id = render_identifier(inline_bibitem_ref_code(bib)) out << id[1] if id[1] out << " (Draft)" if ogc_draft_ref?(bib) out << ", " out.i do |i| iso_title(bib)&.children&.each { |n| parse(n, i) } end out << ". " out << pub if pub out << ", " if pub && c c&.children&.each { |n| parse(n, out) } out << " " if (pub || c) && y out << "(#{y}). " if y u and out << "<a href='#{u.text}'>#{u.text}</a>" end end
std_bibitem_entry(list, bib, ordinal, biblio)
click to toggle source
# File lib/isodoc/ogc/biblio.rb, line 4 def std_bibitem_entry(list, bib, ordinal, biblio) list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref| prefix_bracketed_ref(ref, "[#{ordinal}]") if biblio standard_citation(ref, bib) end end
submitters(docxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 27 def submitters(docxml, out) f = docxml.at(ns("//submitters")) || return intro_clause(f, out) end
submittingorgs(docxml, out)
click to toggle source
# File lib/isodoc/ogc/sections.rb, line 16 def submittingorgs(docxml, out) f = docxml.at(ns("//preface/clause[@type = 'submitting_orgs']")) or return intro_clause(f, out) end
table_attrs(node)
click to toggle source
Calls superclass method
# File lib/isodoc/ogc/base_convert.rb, line 111 def table_attrs(node) ret = super %w(recommendation requirement permission).include?(node["class"]) and ret = ret.merge(class: node["type"], style: "border-collapse:collapse;border-spacing:0;"\ "#{keep_style(node)}") ret end
term_cleanup(docxml)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 28 def term_cleanup(docxml) docxml.xpath("//p[@class = 'Terms']").each do |d| term_cleanup_merge_termnum(d) term_cleanup_merge_admitted(d) end docxml end
term_cleanup_merge_admitted(term)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 44 def term_cleanup_merge_admitted(term) term.xpath("./following-sibling::p[@class = 'AltTerms' or "\ "@class = 'DeprecatedTerms']").each do |a| term << " " term << a.children a.remove end end
term_cleanup_merge_termnum(term)
click to toggle source
# File lib/isodoc/ogc/base_convert.rb, line 36 def term_cleanup_merge_termnum(term) h2 = term.at("./preceding-sibling::*[@class = 'TermNum'][1]") term["class"] = h2["class"] term["id"] = h2["id"] term.children.first.previous = " " term.children.first.previous = h2.remove.children end