Class: IsoDoc::Ogc::Xref
- Inherits:
-
Xref
- Object
- Xref
- IsoDoc::Ogc::Xref
- Defined in:
- lib/isodoc/ogc/xref.rb
Constant Summary collapse
- FIGURE_NO_CLASS =
".//figure[not(@class)]".freeze
- LISTING =
<<~XPATH.freeze .//figure[@class = 'pseudocode'] | .//sourcecode[not(ancestor::example)] XPATH
Instance Method Summary collapse
- #clause_order_main(docxml) ⇒ Object
- #hierarchical_asset_names(clause, num) ⇒ Object
- #hierarchical_sourcecode_names(clause, num) ⇒ Object
- #middle_section_asset_names(doc) ⇒ Object
- #preface_anchor_names(xml) ⇒ Object
- #preface_names(clause) ⇒ Object
- #preface_names_numbered1(clause, num, level) ⇒ Object
- #preface_number(num, level) ⇒ Object
- #reference_names(ref) ⇒ Object
- #sequential_asset_names(clause, container: false) ⇒ Object
- #sequential_permission_body(id, block, label, klass, model, container: false) ⇒ Object
- #sequential_sourcecode_names(clause, container: false) ⇒ Object
Instance Method Details
#clause_order_main(docxml) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/isodoc/ogc/xref.rb', line 7 def clause_order_main(docxml) ret = [{ path: "//clause[@type = 'scope']" }, { path: "//clause[@type = 'conformance']" }, { path: @klass.norm_ref_xpath }] a = ["//sections/terms | //sections/clause[descendant::terms]", "//sections/definitions | " \ "//sections/clause[descendant::definitions][not(descendant::terms)]", @klass.middle_clause(docxml)] ret + if @doctype == "engineering-report" [{ path: a.join(" | "), multi: true }] else [{ path: a[0] }, { path: a[1] }, { path: a[2], multi: true }] end end |
#hierarchical_asset_names(clause, num) ⇒ Object
116 117 118 119 |
# File 'lib/isodoc/ogc/xref.rb', line 116 def hierarchical_asset_names(clause, num) super hierarchical_sourcecode_names(clause, num) end |
#hierarchical_sourcecode_names(clause, num) ⇒ Object
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/isodoc/ogc/xref.rb', line 121 def hierarchical_sourcecode_names(clause, num) c = Counter.new clause.xpath(ns(LISTING)).noblank.each do |t| c.increment(t) label = "#{num}#{hiersep}#{c.print}" @anchors[t["id"]] = anchor_struct(label, nil, @labels["sourcecode"], "sourcecode", t["unnumbered"]) end end |
#middle_section_asset_names(doc) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/isodoc/ogc/xref.rb', line 22 def middle_section_asset_names(doc) middle_sections = "//clause[@type = 'scope' or @type = 'conformance'] | //foreword | " \ "//introduction | //preface/abstract | //submitters | " \ "//acknowledgements | //preface/clause | " \ "#{@klass.norm_ref_xpath} | //sections/terms | " \ "//sections/definitions | //clause[parent::sections]" sequential_asset_names(doc.xpath(ns(middle_sections))) end |
#preface_anchor_names(xml) ⇒ Object
32 33 34 35 |
# File 'lib/isodoc/ogc/xref.rb', line 32 def preface_anchor_names(xml) @prefacenum = 0 super end |
#preface_names(clause) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/isodoc/ogc/xref.rb', line 37 def preface_names(clause) clause.nil? and return clause["type"] == "toc" and return @prefacenum += 1 pref = preface_number(@prefacenum, 1) @anchors[clause["id"]] = { label: pref, level: 1, xref: clause_title(clause), type: "clause" } clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i| preface_names_numbered1(c, "#{pref}.#{preface_number(i + 1, 2)}", 2) end end |
#preface_names_numbered1(clause, num, level) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/isodoc/ogc/xref.rb', line 50 def preface_names_numbered1(clause, num, level) @anchors[clause["id"]] = { label: num, level: level, xref: l10n("#{@labels['clause']} #{num}"), type: "clause", elem: @labels["clause"] } clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i| lbl = "#{num}.#{preface_number(i + 1, level + 1)}" preface_names_numbered1(c, lbl, level + 1) end end |
#preface_number(num, level) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/isodoc/ogc/xref.rb', line 60 def preface_number(num, level) case level when 1 then RomanNumerals.to_roman(num).upcase when 2 then (64 + num).chr.to_s when 3 then num.to_s when 4 then (96 + num).chr.to_s when 5 then RomanNumerals.to_roman(num).downcase when 6 then "(#{num})" when 7 then "(#{(96 + num).chr})" when 8 then "(#{RomanNumerals.to_roman(num).downcase})" else num.to_s end end |
#reference_names(ref) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/isodoc/ogc/xref.rb', line 74 def reference_names(ref) super return unless @klass.ogc_draft_ref?(ref) @anchors[ref["id"]] = { xref: "#{@anchors[ref['id']][:xref]} (draft)" } end |
#sequential_asset_names(clause, container: false) ⇒ Object
99 100 101 102 |
# File 'lib/isodoc/ogc/xref.rb', line 99 def sequential_asset_names(clause, container: false) super sequential_sourcecode_names(clause, container: container) end |
#sequential_permission_body(id, block, label, klass, model, container: false) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/isodoc/ogc/xref.rb', line 81 def (id, block, label, klass, model, container: false) @anchors[block["id"]] = model.postprocess_anchor_struct( block, anchor_struct(id, container ? block : nil, label, klass, block["unnumbered"]) ) model.(block, id, label, klass).each do |n| @anchors[n[:id]] = anchor_struct(n[:number], nil, n[:label], n[:klass], false) end end |
#sequential_sourcecode_names(clause, container: false) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/isodoc/ogc/xref.rb', line 104 def sequential_sourcecode_names(clause, container: false) c = Counter.new clause.xpath(ns(LISTING)).noblank.each do |t| c.increment(t) @anchors[t["id"]] = anchor_struct( c.print, container ? t : nil, @labels["sourcecode"], "sourcecode", t["unnumbered"] ) end end |