Class: IsoDoc::Ogc::Xref
- Inherits:
-
Xref
- Object
- Xref
- IsoDoc::Ogc::Xref
- Defined in:
- lib/isodoc/ogc/xref.rb
Instance Method Summary collapse
- #clause_order_main(docxml) ⇒ Object
-
#middle_section_asset_names(doc) ⇒ Object
[“//preface/abstract”, “//preface/clause[@type = ‘executivesummary’]”, “//preface/clause[@type = ‘keywords’]”, “//foreword”, “//preface/clause[@type = ‘security’]”, “//preface/clause[@type = ‘submitting_orgs’]”, “//submitters”, “//introduction”].
- #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_permission_body(id, block, label, klass, model, 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 |
#middle_section_asset_names(doc) ⇒ Object
- “//preface/abstract”, “//preface/clause[@type = ‘executivesummary’]”, “//preface/clause[@type = ‘keywords’]”, “//foreword”, “//preface/clause[@type = ‘security’]”, “//preface/clause[@type = ‘submitting_orgs’]”, “//submitters”, “//introduction”
24 25 26 27 28 29 30 31 32 |
# File 'lib/isodoc/ogc/xref.rb', line 24 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
34 35 36 37 |
# File 'lib/isodoc/ogc/xref.rb', line 34 def preface_anchor_names(xml) @prefacenum = 0 super end |
#preface_names(clause) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/isodoc/ogc/xref.rb', line 39 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
52 53 54 55 56 57 58 59 60 |
# File 'lib/isodoc/ogc/xref.rb', line 52 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
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/isodoc/ogc/xref.rb', line 62 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
76 77 78 79 80 81 |
# File 'lib/isodoc/ogc/xref.rb', line 76 def reference_names(ref) super return unless @klass.ogc_draft_ref?(ref) @anchors[ref["id"]] = { xref: "#{@anchors[ref['id']][:xref]} (draft)" } end |
#sequential_permission_body(id, block, label, klass, model, container: false) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/isodoc/ogc/xref.rb', line 83 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 |