class IsoDoc::ITU::Xref
Public Class Methods
new(lang, script, klass, labels, options)
click to toggle source
Calls superclass method
# File lib/isodoc/itu/xref.rb, line 15 def initialize(lang, script, klass, labels, options) super @hierarchical_assets = options[:hierarchical_assets] end
Public Instance Methods
annex_name_lbl(clause, num)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 10 def annex_name_lbl(clause, num) lbl = annextype(clause) if @doctype == "resolution" l10n("#{lbl.upcase} #{num}") else l10n("<strong>#{lbl} #{num}</strong>") end end
annex_names(clause, num)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 19 def annex_names(clause, num) lbl = annextype(clause) @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause", xref: l10n("#{lbl} #{num}"), level: 1, value: num } if a = single_annex_special_section(clause) annex_names1(a, num.to_s, 1) else i = Counter.new clause.xpath(ns("./clause | ./references | ./terms | ./definitions")) .each do |c| i.increment(c) annex_names1(c, "#{num}.#{i.print}", 2) end end hierarchical_asset_names(clause, num) end
annex_names1(clause, num, level)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 37 def annex_names1(clause, num, level) @anchors[clause["id"]] = { label: num, xref: @doctype == "resolution" ? num : l10n("#{@labels['annex_subclause']} #{num}"), level: level, type: "clause" } i = Counter.new clause.xpath(ns("./clause | ./references | ./terms | ./definitions")) .each do |c| i.increment(c) annex_names1(c, "#{num}.#{i.print}", level + 1) end end
annextype(clause)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 4 def annextype(clause) if clause["obligation"] == "informative" then @labels["appendix"] else @labels["annex"] end end
back_anchor_names(docxml)
click to toggle source
Calls superclass method
# File lib/isodoc/itu/xref.rb, line 20 def back_anchor_names(docxml) super if annexid = docxml &.at(ns("//bibdata/ext/structuredidentifier/annexid"))&.text docxml.xpath(ns("//annex")).each { |c| annex_names(c, annexid) } else i = Counter.new(0, numerals: :roman) docxml.xpath(ns("//annex[@obligation = 'informative']")) .each do |c| i.increment(c) annex_names(c, i.print.upcase) end i = Counter.new("@", skip_i: true) docxml.xpath(ns("//annex[not(@obligation = 'informative')]")) .each do |c| i.increment(c) annex_names(c, i.print) end end end
clause_names(docxml, sect_num)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 50 def clause_names(docxml, sect_num) docxml.xpath(ns("//sections/clause[not(@unnumbered = 'true')]"\ "[not(@type = 'scope')][not(descendant::terms)]")) .each do |c| section_names(c, sect_num, 1) end docxml.xpath(ns("//sections/clause[@unnumbered = 'true']")).each do |c| unnumbered_section_names(c, 1) end end
hierarchical_figure_names(clause, num)
click to toggle source
# File lib/isodoc/itu/xref.rb, line 95 def hierarchical_figure_names(clause, num) c = Counter.new j = 0 clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t| if t.parent.name == "figure" then j += 1 else j = 0 c.increment(t) end label = "#{num}#{hiersep}#{c.print}" + (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr}") next if t["id"].nil? || t["id"].empty? @anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"]) end end
hierarchical_formula_names(clause, num)
click to toggle source
# File lib/isodoc/itu/xref.rb, line 122 def hierarchical_formula_names(clause, num) c = Counter.new clause.xpath(ns(".//formula")).each do |t| next if t["id"].nil? || t["id"].empty? @anchors[t["id"]] = anchor_struct( "#{num}-#{c.increment(t).print}", nil, t["inequality"] ? @labels["inequality"] : @labels["formula"], "formula", t["unnumbered"] ) end end
initial_anchor_names(doc)
click to toggle source
# File lib/isodoc/itu/xref.rb, line 41 def initial_anchor_names(doc) @doctype = doc&.at(ns("//bibdata/ext/doctype"))&.text doc.xpath(ns("//boilerplate//clause")).each { |c| preface_names(c) } doc.xpath("//xmlns:preface/child::*").each { |c| preface_names(c) } if @hierarchical_assets hierarchical_asset_names(doc.xpath("//xmlns:preface/child::*"), "Preface") else sequential_asset_names(doc.xpath("//xmlns:preface/child::*")) end n = Counter.new n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1) n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1) n = section_names(doc.at(ns("//sections/terms | //sections/clause[descendant::terms]")), n, 1) n = section_names(doc.at(ns("//sections/definitions")), n, 1) clause_names(doc, n) middle_section_asset_names(doc) termnote_anchor_names(doc) termexample_anchor_names(doc) end
middle_section_asset_names(doc)
click to toggle source
Calls superclass method
# File lib/isodoc/itu/xref.rb, line 70 def middle_section_asset_names(doc) return super unless @hierarchical_assets doc.xpath(ns(middle_sections)).each do |c| hierarchical_asset_names(c, @anchors[c["id"]][:label]) end end
middle_sections()
click to toggle source
# File lib/isodoc/itu/xref.rb, line 62 def middle_sections "//clause[@type = 'scope'] | "\ "//foreword | //introduction | //acknowledgements | "\ " #{@klass.norm_ref_xpath} | "\ "//sections/terms | //preface/clause | "\ "//sections/definitions | //clause[parent::sections]" end
reference_names(ref)
click to toggle source
Calls superclass method
# File lib/isodoc/itu/xref.rb, line 135 def reference_names(ref) super @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].sub(/^\[/, "").sub(/\]$/, "") } end
section_names(clause, num, lvl)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 61 def section_names(clause, num, lvl) return num if clause.nil? num.increment(clause) lbl = @doctype == "resolution" ? @labels["section"] : @labels["clause"] @anchors[clause["id"]] = { label: num.print, xref: l10n("#{lbl} #{num.print}"), level: lvl, type: "clause" } i = Counter.new clause.xpath(ns(SUBCLAUSES)).each do |c| i.increment(c) section_names1(c, "#{num.print}.#{i.print}", lvl + 1) end num end
section_names1(clause, num, level)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 77 def section_names1(clause, num, level) @anchors[clause["id"]] = { label: num, level: level, xref: @doctype == "resolution" ? num : l10n("#{@labels['clause']} #{num}") } i = Counter.new clause.xpath(ns(SUBCLAUSES)).each do |c| i.increment(c) section_names1(c, "#{num}.#{i.print}", level + 1) end end
sequential_figure_names(clause)
click to toggle source
# File lib/isodoc/itu/xref.rb, line 78 def sequential_figure_names(clause) c = Counter.new j = 0 clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t| if t.parent.name == "figure" then j += 1 else j = 0 c.increment(t) end label = c.print + (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr}") next if t["id"].nil? || t["id"].empty? @anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"], "figure", t["unnumbered"]) end end
sequential_formula_names(clause)
click to toggle source
# File lib/isodoc/itu/xref.rb, line 112 def sequential_formula_names(clause) clause&.first&.xpath(ns(middle_sections))&.each do |c| if c["id"] && @anchors[c["id"]] hierarchical_formula_names(c, @anchors[c["id"]][:label] || @anchors[c["id"]][:xref] || "???") else hierarchical_formula_names(c, "???") end end end
termnote_anchor_names(docxml)
click to toggle source
# File lib/isodoc/itu/xref.rb, line 141 def termnote_anchor_names(docxml) docxml.xpath(ns("//term[descendant::termnote]")).each do |t| c = Counter.new notes = t.xpath(ns(".//termnote")) notes.each do |n| return if n["id"].nil? || n["id"].empty? idx = notes.size == 1 ? "" : " #{c.increment(n).print}" @anchors[n["id"]] = { label: termnote_label(idx).strip, type: "termnote", value: idx, xref: l10n("#{anchor(t['id'], :xref)}, #{@labels['note_xref']} #{c.print}") } end end end
unnumbered_section_names(clause, lvl)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 88 def unnumbered_section_names(clause, lvl) return if clause.nil? lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]" @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}), level: lvl, type: "clause" } clause.xpath(ns(SUBCLAUSES)).each do |c| unnumbered_section_names1(c, lvl + 1) end end
unnumbered_section_names1(clause, level)
click to toggle source
# File lib/isodoc/itu/xref_section.rb, line 99 def unnumbered_section_names1(clause, level) lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]" @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}), level: level, type: "clause" } clause.xpath(ns(SUBCLAUSES)).each do |c| unnumbered_section_names1(c, level + 1) end end