Module: IsoDoc::Ogc::BaseConvert

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

Instance Method Summary collapse

Instance Method Details

#abstract(clause, out) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/isodoc/ogc/sections.rb', line 23

def abstract(clause, out)
  page_break(out)
  out.div **attr_code(id: clause["id"]) do |s|
    clause_name(clause, clause.at(ns("./fmt-title")), s,
                class: "AbstractTitle")
    clause.elements.each do |e|
      parse(e, s) unless e.name == "fmt-title"
    end
  end
end

#acknowledgements(clause, out) ⇒ Object



45
46
47
# File 'lib/isodoc/ogc/sections.rb', line 45

def acknowledgements(clause, out)
  intro_clause(clause, out)
end

#cleanup(docxml) ⇒ Object



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

def cleanup(docxml)
  super
  term_cleanup(docxml)
end

#error_parsex(node, out) ⇒ Object

KILL



9
10
11
12
13
14
15
# File 'lib/isodoc/ogc/base_convert.rb', line 9

def error_parsex(node, out)
  case node.name
  when "hi" then hi_parse(node, out)
  else
    super
  end
end

#example_label(node, div, name) ⇒ Object



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

def example_label(node, div, name); end

#example_name_parse(_node, div, name) ⇒ Object



63
64
65
66
67
# File 'lib/isodoc/ogc/base_convert.rb', line 63

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



55
56
57
58
59
# File 'lib/isodoc/ogc/base_convert.rb', line 55

def example_parse(node, out)
  name = node.at(ns("./fmt-name"))
  example_name_parse(node, out, name) # if name
  super
end

#foreword(clause, out) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/isodoc/ogc/sections.rb', line 34

def foreword(clause, out)
  page_break(out)
  out.div **attr_code(id: clause["id"]) do |s|
    clause_name(clause, clause&.at(ns("./fmt-title")), s,
                class: "ForewordTitle")
    clause.elements.each do |e|
      parse(e, s) unless e.name == "fmt-title"
    end
  end
end

#hi_parse(node, out) ⇒ Object

KILL



18
19
20
21
22
# File 'lib/isodoc/ogc/base_convert.rb', line 18

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



13
14
15
16
17
18
19
20
21
# File 'lib/isodoc/ogc/sections.rb', line 13

def intro_clause(elem, out)
  out.div class: "Section3", id: elem["id"] do |div|
    clause_name(elem, elem&.at(ns("./fmt-title")), div,
                class: "IntroTitle")
    elem.elements.each do |e|
      parse(e, div) unless e.name == "fmt-title"
    end
  end
end

#make_tr_attr(cell, row, totalrows, header, bordered) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/isodoc/ogc/base_convert.rb', line 84

def make_tr_attr(cell, row, totalrows, header, bordered)
  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['style']}"
    ret[:class] = "recommend"
  end
  ret
end

#middle_clause(_docxml) ⇒ Object



69
70
71
72
73
# File 'lib/isodoc/ogc/base_convert.rb', line 69

def middle_clause(_docxml)
  "//clause[parent::sections][not(@type = 'scope' or " \
    "@type = 'conformance')][not(descendant::terms)]" \
    "[not(descendant::references)]"
end

#para_class(node) ⇒ Object



95
96
97
98
99
100
101
102
103
# File 'lib/isodoc/ogc/base_convert.rb', line 95

def para_class(node)
  if node["class"] == "RecommendationLabel"
    node["class"] = nil
    ret = super
    node["class"] = "RecommendationLabel"
    ret
  else super
  end
end

#preface(clause, out) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/isodoc/ogc/sections.rb', line 4

def preface(clause, out)
  case clause["type"]
  when "toc"
    table_of_contents(clause, out)
  else
    intro_clause(clause, out)
  end
end

#table_attrs(node) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/isodoc/ogc/base_convert.rb', line 75

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



29
30
31
32
33
34
35
# File 'lib/isodoc/ogc/base_convert.rb', line 29

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



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

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



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

def term_cleanup_merge_termnum(term)
  h2 = term.at("./preceding-sibling::*[@class = 'TermNum'][1]")
  term["class"] = h2["class"]
  term["id"] = h2["id"]
  # TODO to PresentationXML
  term.add_first_child "&#xa0;"
  term.add_first_child h2.remove.children
end