Module: IsoDoc::Ogc::BaseConvert

Included in:
HtmlConvert, WordConvert
Defined in:
lib/isodoc/ogc/biblio.rb,
lib/isodoc/ogc/sections.rb,
lib/isodoc/ogc/base_convert.rb

Instance Method Summary collapse

Instance Method Details

#abstract(isoxml, out) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/isodoc/ogc/sections.rb', line 47

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) ⇒ Object



65
66
67
68
# File 'lib/isodoc/ogc/sections.rb', line 65

def acknowledgements(isoxml, out)
  f = isoxml.at(ns("//acknowledgements")) || return
  intro_clause(f, out)
end

#admitted_term_parse(node, out) ⇒ Object



63
64
65
66
67
68
69
70
71
# 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 << "&#xa0;"
    p.span **{ class: "AdmittedLabel" } do |s|
      s << l10n(@i18n.admitted)
    end
  end
end

#cleanup(docxml) ⇒ Object



23
24
25
26
# File 'lib/isodoc/ogc/base_convert.rb', line 23

def cleanup(docxml)
  super
  term_cleanup(docxml)
end

#conformance(isoxml, out, num) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/isodoc/ogc/sections.rb', line 70

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

#deprecated_term_parse(node, out) ⇒ Object



53
54
55
56
57
58
59
60
61
# 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 << "&#xa0;"
    p.span **{ class: "AdmittedLabel" } do |s|
      s << l10n(@i18n.deprecated)
    end
  end
end

#error_parse(node, out) ⇒ Object



9
10
11
12
13
14
15
# 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) ⇒ Object



79
# File 'lib/isodoc/ogc/base_convert.rb', line 79

def example_label(node, div, name); end

#example_name_parse(_node, div, name) ⇒ Object



81
82
83
84
85
# 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) ⇒ Object



73
74
75
76
77
# 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

#executivesummary(docxml, out) ⇒ Object



27
28
29
30
31
# File 'lib/isodoc/ogc/sections.rb', line 27

def executivesummary(docxml, out)
  f = docxml.at(ns("//preface/clause[@type = 'executivesummary']")) or
    return
  intro_clause(f, out)
end

#foreword(isoxml, out) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/isodoc/ogc/sections.rb', line 56

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) ⇒ Object



17
18
19
20
21
# 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

#intro_clause(elem, out) ⇒ Object



4
5
6
7
8
9
# 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) ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
95
96
# File 'lib/isodoc/ogc/base_convert.rb', line 92

def is_clause?(name)
  return true if name == "submitters"

  super
end

#keywords(docxml, out) ⇒ Object



11
12
13
14
# 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(cell, row, totalrows, header) ⇒ Object



120
121
122
123
124
125
126
127
128
129
# File 'lib/isodoc/ogc/base_convert.rb', line 120

def make_tr_attr(cell, row, totalrows, header)
  ret = super
  if cell.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) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
# 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) ⇒ Object



87
88
89
90
# 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

#nonstd_bibitem(list, bib, ordinal, bibliography) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# 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[:sdo] = nil
    if bibliography
      ref_entry_code(r, ordinal, identifier, id)
    end
    reference_format(bib, r)
  end
end

#ol_depth(node) ⇒ Object



138
139
140
141
142
143
144
145
# File 'lib/isodoc/ogc/base_convert.rb', line 138

def ol_depth(node)
  return super unless (node["class"] == "steps") ||
    node.at(".//ancestor::xmlns:ol[@class = 'steps']")

  idx = node.xpath("./ancestor-or-self::xmlns:ol[@class = 'steps']").size
  styles = %i(arabic alphabet roman alphabet_upper roman_upper)
  ol_style(styles[(idx - 1) % 5])
end

#para_class(node) ⇒ Object



131
132
133
134
135
136
# File 'lib/isodoc/ogc/base_convert.rb', line 131

def para_class(node)
  return node["class"] if node["class"] &&
    node["class"] != "RecommendationLabel"

  super
end

#preface(isoxml, out) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/isodoc/ogc/sections.rb', line 38

def preface(isoxml, out)
  isoxml.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
                  "@type = 'submitting_orgs' or @type = 'security' or "\
                  "@type = 'executivesummary')]"))
    .each do |f|
    intro_clause(f, out)
  end
end

#security(docxml, out) ⇒ Object



22
23
24
25
# File 'lib/isodoc/ogc/sections.rb', line 22

def security(docxml, out)
  f = docxml.at(ns("//preface/clause[@type = 'security']")) or return
  intro_clause(f, out)
end

#std_bibitem_entry(list, bib, ordinal, biblio) ⇒ Object



4
5
6
7
8
9
# 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
    reference_format(bib, ref)
  end
end

#submitters(docxml, out) ⇒ Object



33
34
35
36
# File 'lib/isodoc/ogc/sections.rb', line 33

def submitters(docxml, out)
  f = docxml.at(ns("//submitters")) || return
  intro_clause(f, out)
end

#submittingorgs(docxml, out) ⇒ Object



16
17
18
19
20
# 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) ⇒ Object



111
112
113
114
115
116
117
118
# 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) ⇒ Object



28
29
30
31
32
33
34
# 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) ⇒ Object



44
45
46
47
48
49
50
51
# 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) ⇒ Object



36
37
38
39
40
41
42
# 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 = "&#xa0;"
  term.children.first.previous = h2.remove.children
end