Class: IsoDoc::Iho::Xref
- Inherits:
-
Generic::Xref
- Object
- Generic::Xref
- IsoDoc::Iho::Xref
- Defined in:
- lib/isodoc/iho/xref.rb
Instance Method Summary collapse
- #annex_anchor_names(docxml) ⇒ Object
-
#annex_asset_names(clause, num, lbl) ⇒ Object
avoid ambiguity of Table 1-1 being in Appendix 1 or Clause 1.
- #annex_name_lbl(clause, num) ⇒ Object
- #annex_names(clause, num) ⇒ Object
- #annex_names1(clause, parentnum, num, level) ⇒ Object
- #annex_names_recurse(clause, num) ⇒ Object
- #annexlbl(cond) ⇒ Object
- #appendix_names(clause, _num) ⇒ Object
- #clause_order_annex(_docxml) ⇒ Object
-
#clause_order_main(docxml) ⇒ Object
end.
- #hiersep ⇒ Object
- #middle_section_asset_names(doc) ⇒ Object
- #middle_sections ⇒ Object
- #preface_names(clause) ⇒ Object
- #section_names1(clause, parentnum, num, level) ⇒ Object
Instance Method Details
#annex_anchor_names(docxml) ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/isodoc/iho/xref.rb', line 87 def annex_anchor_names(docxml) clause_order_annex(docxml).each_with_index do |a, i| n = i.zero? ? Counter.new("@") : Counter.new docxml.xpath(ns(a[:path])) .each do |c| annex_names(c, n.increment(c).print) a[:multi] or break end end end |
#annex_asset_names(clause, num, lbl) ⇒ Object
avoid ambiguity of Table 1-1 being in Appendix 1 or Clause 1
47 48 49 50 51 52 53 54 55 |
# File 'lib/isodoc/iho/xref.rb', line 47 def annex_asset_names(clause, num, lbl) #@annex_prefix = lbl #require "debug"; binding.b #hierarchical_asset_names(clause, num) n = num clause["obligation"] == "informative" and n = labelled_autonum(lbl, num) hierarchical_asset_names(clause, n) #@annex_prefix = nil end |
#annex_name_lbl(clause, num) ⇒ Object
17 18 19 20 21 |
# File 'lib/isodoc/iho/xref.rb', line 17 def annex_name_lbl(clause, num) lbl = annexlbl(clause["obligation"] == "informative") s = labelled_autonum(lbl, num) l10n("<strong>#{s}</strong>") end |
#annex_names(clause, num) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/isodoc/iho/xref.rb', line 23 def annex_names(clause, num) lbl = semx(clause, num) appendix_names(clause, lbl) elem = annexlbl(clause["obligation"] == "informative") @anchors[clause["id"]] = { label: annex_name_lbl(clause, lbl), type: "clause", elem: elem, xref: labelled_autonum(elem, lbl), level: 1, value: num } annex_names_recurse(clause, num) annex_asset_names(clause, num, elem) end |
#annex_names1(clause, parentnum, num, level) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/isodoc/iho/xref.rb', line 98 def annex_names1(clause, parentnum, num, level) elem = annexlbl(clause.at("./ancestor::xmlns:annex/@obligation") .text == "informative") lbl = clause_number_semx(parentnum, clause, num) @anchors[clause["id"]] = { label: lbl, xref: labelled_autonum(elem, lbl), level: level, type: "clause" } i = Counter.new(0) clause.xpath(ns("./clause | ./references | ./terms | ./definitions")) .each do |c| annex_names1(c, lbl, i.increment(c).print, level + 1) end end |
#annex_names_recurse(clause, num) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/isodoc/iho/xref.rb', line 34 def annex_names_recurse(clause, num) @klass.single_term_clause?(clause) and return annex_names1(clause.at(ns("./references | ./terms | ./definitions")), num.to_s, 1) i = Counter.new clause.xpath(ns("./clause | ./references | ./terms | ./definitions")) .each do |c| i.increment(c) annex_names1(c, semx(clause, num), i.print, 2) end end |
#annexlbl(cond) ⇒ Object
13 14 15 |
# File 'lib/isodoc/iho/xref.rb', line 13 def annexlbl(cond) cond ? @labels["appendix"] : @labels["annex"] end |
#appendix_names(clause, _num) ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/isodoc/iho/xref.rb', line 112 def appendix_names(clause, _num) i = Counter.new clause.xpath(ns("./appendix")).each do |c| i.increment(c) @anchors[c["id"]] = anchor_struct(i.print, c, @labels["appendix"], "clause", { container: true }) @anchors[c["id"]][:level] = 2 @anchors[c["id"]][:container] = clause["id"] end end |
#clause_order_annex(_docxml) ⇒ Object
82 83 84 85 |
# File 'lib/isodoc/iho/xref.rb', line 82 def clause_order_annex(_docxml) [{ path: "//annex[not(@obligation = 'informative')]", multi: true }, { path: "//annex[@obligation = 'informative']", multi: true }] end |
#clause_order_main(docxml) ⇒ Object
end
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/isodoc/iho/xref.rb', line 62 def clause_order_main(docxml) if docxml.at(ns("//bibliography//references[@normative = 'true']")) || docxml.at(ns("//sections/references[@normative = 'true']")) [ { path: "//sections/clause[@type = 'scope']" }, { path: "#{@klass.norm_ref_xpath} | //sections/references" }, { path: "//sections/terms | //sections/definitions | " \ "//sections/clause[not(@type = 'scope')]", multi: true }, ] else [ { path: "//sections/terms | //sections/definitions | " \ "//sections/references | " \ "//bibliography/references[@normative = 'true'] | " \ "//bibliography/clause[.//references[@normative = 'true']] | " \ "//sections/clause", multi: true }, ] end end |
#hiersep ⇒ Object
9 10 11 |
# File 'lib/isodoc/iho/xref.rb', line 9 def hiersep "-" end |
#middle_section_asset_names(doc) ⇒ Object
141 142 143 144 145 |
# File 'lib/isodoc/iho/xref.rb', line 141 def middle_section_asset_names(doc) doc.xpath(ns(middle_sections)).each do |c| hierarchical_asset_names(c, @anchors[c["id"]][:label]) end end |
#middle_sections ⇒ Object
136 137 138 139 |
# File 'lib/isodoc/iho/xref.rb', line 136 def middle_sections "//sections/clause | #{@klass.norm_ref_xpath} | " \ "//sections/terms | //sections/definitions | //sections/clause" end |
#preface_names(clause) ⇒ Object
147 148 149 150 |
# File 'lib/isodoc/iho/xref.rb', line 147 def preface_names(clause) super sequential_asset_names(clause, container: true) end |
#section_names1(clause, parentnum, num, level) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/isodoc/iho/xref.rb', line 123 def section_names1(clause, parentnum, num, level) lbl = clause_number_semx(parentnum, clause, num) @anchors[clause["id"]] = { label: lbl, level: level, #xref: l10n("#{@labels['subclause']} #{num}"), xref: labelled_autonum(@labels['subclause'], lbl), type: "clause", elem: @labels["subclause"] } i = Counter.new(0) clause.xpath(ns(SUBCLAUSES)).each do |c| section_names1(c, lbl, i.increment(c).print, level + 1) end end |