Module: IsoDoc::XrefGen::Blocks

Included in:
IsoDoc::Xref
Defined in:
lib/isodoc/xref/xref_gen.rb,
lib/isodoc/xref/xref_util.rb,
lib/isodoc/xref/xref_gen_seq.rb

Constant Summary collapse

NUMBERED_BLOCKS =
%w(termnote termexample note example requirement
recommendation permission figure table formula
admonition sourcecode).freeze
SECTIONS_XPATH =
"//foreword | //introduction | //acknowledgements | " \
"//preface/terms | preface/definitions | preface/references | " \
"//preface/clause | //sections/terms | //annex | " \
"//sections/clause | //sections/definitions | " \
"//bibliography/references | //bibliography/clause".freeze
CHILD_SECTIONS =
"./clause | ./appendix | ./terms | ./definitions | " \
"./references".freeze
FIGURE_NO_CLASS =
<<~XPATH.freeze
  .//figure[not(@class)] | .//figure[@class = 'pseudocode'] | .//sourcecode[not(ancestor::example)]
XPATH
FIRST_LVL_REQ_RULE =
<<~XPATH.freeze
  [not(ancestor::permission or ancestor::requirement or ancestor::recommendation)]
XPATH
FIRST_LVL_REQ =
<<~XPATH.freeze
  .//permission#{FIRST_LVL_REQ_RULE} | .//requirement#{FIRST_LVL_REQ_RULE} | .//recommendation#{FIRST_LVL_REQ_RULE}
XPATH
REQ_CHILDREN =
<<~XPATH.freeze
  ./permission | ./requirement | ./recommendation
XPATH

Instance Method Summary collapse

Instance Method Details

#admonition_anchor_names(sections) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/isodoc/xref/xref_gen.rb', line 89

def admonition_anchor_names(sections)
  sections.each do |s|
    s.at(ns(".//admonition[@type = 'box']")) or next
    notes = s.xpath(child_asset_path("admonition[@type = 'box']"))
    admonition_anchor_names1(notes, Counter.new)
    admonition_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
  end
end

#admonition_anchor_names1(notes, counter) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/isodoc/xref/xref_gen.rb', line 98

def admonition_anchor_names1(notes, counter)
  notes.noblank.each do |n|
    @anchors[n["id"]] ||=
      anchor_struct(increment_label(notes, n, counter), n,
                    @labels["box"], "admonition", n["unnumbered"])
  end
end

#amend_autonums(amend) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/isodoc/xref/xref_gen.rb', line 23

def amend_autonums(amend)
  autonum = {}
  amend.xpath(ns("./autonumber")).each do |n|
    autonum[n["type"]] = n.text
  end
  autonum
end

#amend_preprocess(xmldoc) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/isodoc/xref/xref_gen.rb', line 11

def amend_preprocess(xmldoc)
  xmldoc.xpath(ns("//amend[newcontent]")).each do |a|
    autonum = amend_autonums(a)
    NUMBERED_BLOCKS.each do |b|
      a.xpath(ns("./newcontent//#{b}")).each_with_index do |e, i|
        autonum[b] && i.zero? and e["number"] = autonum[b]
        !autonum[b] and e["unnumbered"] = "true"
      end
    end
  end
end

#blank?(text) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/isodoc/xref/xref_util.rb', line 12

def blank?(text)
  text.nil? || text.empty?
end

#bookmark_anchor_names(xml) ⇒ Object



227
228
229
230
231
232
233
234
235
# File 'lib/isodoc/xref/xref_gen.rb', line 227

def bookmark_anchor_names(xml)
  xml.xpath(ns(".//bookmark")).noblank.each do |n|
    _parent, id = id_ancestor(n)
    #container = bookmark_container(parent)
    @anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
                          xref: @anchors.dig(id, :xref) || "???",
                          container: @anchors.dig(id, :container) }
  end
end

#bookmark_container(parent) ⇒ Object



216
217
218
219
220
221
222
223
224
225
# File 'lib/isodoc/xref/xref_gen.rb', line 216

def bookmark_container(parent)
  if parent
    clause = parent.xpath(CLAUSE_ANCESTOR)&.last
    if clause["id"] == id
      nil
    else
      @anchors.dig(clause["id"], :xref)
    end
  end
end

#child_asset_path(asset) ⇒ Object



31
32
33
34
35
# File 'lib/isodoc/xref/xref_util.rb', line 31

def child_asset_path(asset)
  "./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and " \
  "not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:X | " \
  "./xmlns:X".gsub("X", asset)
end

#deflist_anchor_names(sections) ⇒ Object



170
171
172
173
174
175
176
177
# File 'lib/isodoc/xref/xref_gen.rb', line 170

def deflist_anchor_names(sections)
  sections.each do |s|
    notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
      s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
    deflist_anchor_names1(notes, Counter.new)
    deflist_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
  end
end

#deflist_anchor_names1(notes, counter) ⇒ Object



179
180
181
182
183
184
185
186
# File 'lib/isodoc/xref/xref_gen.rb', line 179

def deflist_anchor_names1(notes, counter)
  notes.noblank.each do |n|
    @anchors[n["id"]] =
      anchor_struct(increment_label(notes, n, counter), n,
                    @labels["deflist"], "deflist", false)
    deflist_term_anchor_names(n, @anchors[n["id"]])
  end
end

#deflist_term_anchor_names(list, list_anchor) ⇒ Object



188
189
190
191
192
193
194
195
196
197
198
# File 'lib/isodoc/xref/xref_gen.rb', line 188

def deflist_term_anchor_names(list, list_anchor)
  list.xpath(ns("./dt")).each do |li|
    label = l10n("#{list_anchor[:xref]}: #{dt2xreflabel(li)}")
    li["id"] and @anchors[li["id"]] =
                   { xref: label, type: "deflistitem",
                     container: list_anchor[:container] }
    li.xpath(ns("./dl")).each do |dl|
      deflist_term_anchor_names(dl, list_anchor)
    end
  end
end

#dt2xreflabel(dterm) ⇒ Object



200
201
202
203
204
205
# File 'lib/isodoc/xref/xref_gen.rb', line 200

def dt2xreflabel(dterm)
  label = dterm.dup
  label.xpath(ns(".//p")).each { |x| x.replace(x.children) }
  label.xpath(ns(".//index")).each(&:remove)
  Common::to_xml(label.children)
end

#example_anchor_names(sections) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/isodoc/xref/xref_gen.rb', line 106

def example_anchor_names(sections)
  sections.each do |s|
    notes = s.xpath(child_asset_path("example"))
    example_anchor_names1(notes, Counter.new)
    example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
  end
end

#example_anchor_names1(notes, counter) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/isodoc/xref/xref_gen.rb', line 114

def example_anchor_names1(notes, counter)
  notes.noblank.each do |n|
    @anchors[n["id"]] ||=
      anchor_struct(increment_label(notes, n, counter), n,
                    @labels["example_xref"], "example", n["unnumbered"])
  end
end

#hierarchical_asset_names(clause, num) ⇒ Object



195
196
197
198
199
200
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 195

def hierarchical_asset_names(clause, num)
  hierarchical_table_names(clause, num)
  hierarchical_figure_names(clause, num)
  hierarchical_formula_names(clause, num)
  hierarchical_permission_names(clause, num)
end

#hierarchical_figure_body(num, subfignum, counter, block, klass) ⇒ Object



177
178
179
180
181
182
183
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 177

def hierarchical_figure_body(num, subfignum, counter, block, klass)
  label = "#{num}#{hiersep}#{counter.print}" +
    subfigure_label(subfignum)
  @anchors[block["id"]] =
    anchor_struct(label, nil, @labels[klass] || klass.capitalize,
                  klass, block["unnumbered"])
end

#hierarchical_figure_class_names(clause, num) ⇒ Object



166
167
168
169
170
171
172
173
174
175
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 166

def hierarchical_figure_class_names(clause, num)
  c = {}
  j = 0
  clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
    .noblank.each do |t|
    c[t["class"]] ||= Counter.new
    j = subfigure_increment(j, c[t["class"]], t)
    hierarchical_figure_body(num, j, c[t["class"]], t, t["class"])
  end
end

#hierarchical_figure_names(clause, num) ⇒ Object



155
156
157
158
159
160
161
162
163
164
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 155

def hierarchical_figure_names(clause, num)
  c = Counter.new
  j = 0
  clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
    # next if labelled_ancestor(t) && t.ancestors("figure").empty?
    j = subfigure_increment(j, c, t)
    hierarchical_figure_body(num, j, c, t, "figure")
  end
  hierarchical_figure_class_names(clause, num)
end

#hierarchical_formula_names(clause, num) ⇒ Object



202
203
204
205
206
207
208
209
210
211
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 202

def hierarchical_formula_names(clause, num)
  c = Counter.new
  clause.xpath(ns(".//formula")).noblank.each do |t|
    @anchors[t["id"]] = anchor_struct(
      "#{num}#{hiersep}#{c.increment(t).print}", nil,
      t["inequality"] ? @labels["inequality"] : @labels["formula"],
      "formula", t["unnumbered"]
    )
  end
end

#hierarchical_permission_body(id, block, label, klass, model) ⇒ Object



235
236
237
238
239
240
241
242
243
244
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 235

def hierarchical_permission_body(id, block, label, klass, model)
  @anchors[block["id"]] = model.postprocess_anchor_struct(
    block, anchor_struct(id, nil,
                         label, klass, block["unnumbered"])
  )
  model.permission_parts(block, id, label, klass).each do |n|
    @anchors[n[:id]] = anchor_struct(n[:number], nil, n[:label],
                                     n[:klass], false)
  end
end

#hierarchical_permission_children(block, lbl) ⇒ Object



224
225
226
227
228
229
230
231
232
233
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 224

def hierarchical_permission_children(block, lbl)
  c = ReqCounter.new
  block.xpath(ns(REQ_CHILDREN)).noblank.each do |t|
    m = @reqt_models.model(t["model"])
    klass, label = reqt2class_nested_label(t, m)
    id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}"
    hierarchical_permission_body(id, t, label, klass, m)
    hierarchical_permission_children(t, id)
  end
end

#hierarchical_permission_names(clause, num) ⇒ Object



213
214
215
216
217
218
219
220
221
222
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 213

def hierarchical_permission_names(clause, num)
  c = ReqCounter.new
  clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t|
    m = @reqt_models.model(t["model"])
    klass, label = reqt2class_label(t, m)
    id = "#{num}#{hiersep}#{c.increment(label, t).print}"
    hierarchical_permission_body(id, t, label, klass, m)
    hierarchical_permission_children(t, id)
  end
end

#hierarchical_table_names(clause, num) ⇒ Object



185
186
187
188
189
190
191
192
193
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 185

def hierarchical_table_names(clause, num)
  c = Counter.new
  clause.xpath(ns(".//table")).noblank.each do |t|
    labelled_ancestor(t) and next
    @anchors[t["id"]] =
      anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
                    nil, @labels["table"], "table", t["unnumbered"])
  end
end

#hierfigsepObject



10
11
12
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 10

def hierfigsep
  "-"
end

#hiersepObject



6
7
8
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 6

def hiersep
  "."
end

#id_ancestor(node) ⇒ Object



207
208
209
210
211
212
213
214
# File 'lib/isodoc/xref/xref_gen.rb', line 207

def id_ancestor(node)
  parent = nil
  node.ancestors.each do |a|
    (a["id"] && (parent = a) && @anchors.dig(a["id"], :xref)) or next
    break
  end
  parent ? [parent, parent["id"]] : [nil, nil]
end

#increment_label(elems, node, counter, increment: true) ⇒ Object



35
36
37
38
39
40
# File 'lib/isodoc/xref/xref_gen.rb', line 35

def increment_label(elems, node, counter, increment: true)
  return "" if elems.size == 1 && !node["number"]

  counter.increment(node) if increment
  " #{counter.print}"
end

#list_anchor_names(sections) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/isodoc/xref/xref_gen.rb', line 122

def list_anchor_names(sections)
  sections.each do |s|
    notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
      s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
    c = Counter.new
    notes.noblank.each do |n|
      @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
                                        @labels["list"], "list", false)
      list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
    end
    list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
  end
end

#list_item_anchor_label(label, list_anchor, prev_label, refer_list) ⇒ Object



160
161
162
163
164
165
166
167
168
# File 'lib/isodoc/xref/xref_gen.rb', line 160

def list_item_anchor_label(label, list_anchor, prev_label, refer_list)
  prev_label.empty? or
    label = @i18n.list_nested_xref.sub("%1", "#{prev_label})")
      .sub("%2", label)
  refer_list and
    label = @i18n.list_nested_xref.sub("%1", list_anchor[:xref])
      .sub("%2", label)
  label
end

#list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/isodoc/xref/xref_gen.rb', line 136

def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
  c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
  list.xpath(ns("./li")).each do |li|
    bare_label, label =
      list_item_value(li, c, depth, { list_anchor: list_anchor, prev_label: prev_label,
                                      refer_list: depth == 1 ? refer_list : nil })
    li["id"] and @anchors[li["id"]] =
                   { label: bare_label, bare_xref: "#{label})",
                     xref: "#{label})",
                     type: "listitem", refer_list: refer_list,
                     container: list_anchor[:container] }
    (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
      list_item_anchor_names(ol, list_anchor, depth + 1, label, refer_list)
    end
  end
end

#list_item_value(entry, counter, depth, opts) ⇒ Object



153
154
155
156
157
158
# File 'lib/isodoc/xref/xref_gen.rb', line 153

def list_item_value(entry, counter, depth, opts)
  label = counter.increment(entry).listlabel(entry.parent, depth)
  [label,
   list_item_anchor_label(label, opts[:list_anchor], opts[:prev_label],
                          opts[:refer_list])]
end

#noblank(xpath) ⇒ Object



16
17
18
# File 'lib/isodoc/xref/xref_util.rb', line 16

def noblank(xpath)
  xpath.reject { |n| blank?(n["id"]) }
end

#note_anchor_names(sections) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/isodoc/xref/xref_gen.rb', line 72

def note_anchor_names(sections)
  sections.each do |s|
    notes = s.xpath(child_asset_path("note")) -
      s.xpath(ns(".//figure//note | .//table//note"))
    note_anchor_names1(notes, Counter.new)
    note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
  end
end

#note_anchor_names1(notes, counter) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/isodoc/xref/xref_gen.rb', line 81

def note_anchor_names1(notes, counter)
  notes.noblank.each do |n|
    @anchors[n["id"]] =
      anchor_struct(increment_label(notes, n, counter), n,
                    @labels["note_xref"], "note", false)
  end
end

#reqt2class_label(elem, model) ⇒ Object



131
132
133
134
135
136
137
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 131

def reqt2class_label(elem, model)
  model.req_class_paths.each do |n|
    v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "")
    elem.at("./self::#{v1}") and return [n[:klass], n[:label]]
  end
  [nil, nil]
end

#reqt2class_nested_label(elem, model) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 139

def reqt2class_nested_label(elem, model)
  model.req_nested_class_paths.each do |n|
    v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "")
    elem.at("./self::#{v1}") and return [n[:klass], n[:label]]
  end
  [nil, nil]
end

#sections_xpathObject



27
28
29
# File 'lib/isodoc/xref/xref_util.rb', line 27

def sections_xpath
  SECTIONS_XPATH
end

#sequential_asset_names(clause, container: false) ⇒ Object

container makes numbering be prefixed with the parent clause reference



148
149
150
151
152
153
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 148

def sequential_asset_names(clause, container: false)
  sequential_table_names(clause, container: container)
  sequential_figure_names(clause, container: container)
  sequential_formula_names(clause, container: container)
  sequential_permission_names(clause, container: container)
end

#sequential_figure_body(subfig, counter, elem, klass, container: false) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 54

def sequential_figure_body(subfig, counter, elem, klass, container: false)
  label = counter.print
  label &&= label + subfigure_label(subfig)
  @anchors[elem["id"]] = anchor_struct(
    label, container ? elem : nil,
    @labels[klass] || klass.capitalize, klass,
    elem["unnumbered"]
  )
end

#sequential_figure_class_names(clause, container: false) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 37

def sequential_figure_class_names(clause, container: false)
  c = {}
  j = 0
  clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
    .each do |t|
    c[t["class"]] ||= Counter.new
    j = subfigure_increment(j, c[t["class"]], t)
    sequential_figure_body(j, c[t["class"]], t, t["class"],
                           container: container)
  end
end

#sequential_figure_names(clause, container: false) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 27

def sequential_figure_names(clause, container: false)
  c = Counter.new
  j = 0
  clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
    j = subfigure_increment(j, c, t)
    sequential_figure_body(j, c, t, "figure", container: container)
  end
  sequential_figure_class_names(clause, container: container)
end

#sequential_formula_names(clause, container: false) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 75

def sequential_formula_names(clause, container: false)
  c = Counter.new
  clause.xpath(ns(".//formula")).noblank.each do |t|
    @anchors[t["id"]] = anchor_struct(
      c.increment(t).print, t,
      t["inequality"] ? @labels["inequality"] : @labels["formula"],
      "formula", t["unnumbered"]
    )
  end
end

#sequential_permission_body(id, elem, label, klass, model, container: false) ⇒ Object



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

def sequential_permission_body(id, elem, label, klass, model, container: false)
  @anchors[elem["id"]] = model.postprocess_anchor_struct(
    elem, anchor_struct(id, elem,
                        label, klass, elem["unnumbered"])
  )
  model.permission_parts(elem, id, label, klass).each do |n|
    @anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label],
                                     n[:klass], false)
  end
end

#sequential_permission_children(elem, lbl, container: false) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 108

def sequential_permission_children(elem, lbl, container: false)
  c = ReqCounter.new
  elem.xpath(ns(REQ_CHILDREN)).noblank.each do |t|
    m = @reqt_models.model(t["model"])
    klass, label = reqt2class_nested_label(t, m)
    id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}"
    sequential_permission_body(id, t, label, klass, m,
                               container: container)
    sequential_permission_children(t, id, container: container)
  end
end

#sequential_permission_names(clause, container: false) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 96

def sequential_permission_names(clause, container: false)
  c = ReqCounter.new
  clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t|
    m = @reqt_models.model(t["model"])
    klass, label = reqt2class_label(t, m)
    id = c.increment(label, t).print
    sequential_permission_body(id, t, label, klass, m,
                               container: container)
    sequential_permission_children(t, id, container: container)
  end
end

#sequential_table_names(clause, container: false) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 64

def sequential_table_names(clause, container: false)
  c = Counter.new
  clause.xpath(ns(".//table")).noblank.each do |t|
    labelled_ancestor(t) and next
    @anchors[t["id"]] = anchor_struct(
      c.increment(t).print, container ? t : nil,
      @labels["table"], "table", t["unnumbered"]
    )
  end
end

#subfigure_increment(idx, counter, elem) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 14

def subfigure_increment(idx, counter, elem)
  if elem.parent.name == "figure" then idx += 1
  else
    idx = 0
    counter.increment(elem)
  end
  idx
end

#subfigure_label(subfignum) ⇒ Object



49
50
51
52
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 49

def subfigure_label(subfignum)
  subfignum.zero? and return ""
  "-#{subfignum}"
end

#termexample_anchor_names(docxml) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/isodoc/xref/xref_gen.rb', line 56

def termexample_anchor_names(docxml)
  docxml.xpath(ns("//*[termexample]")).each do |t|
    examples = t.xpath(ns("./termexample"))
    c = Counter.new
    examples.noblank.each do |n|
      c.increment(n)
      idx = increment_label(examples, n, c, increment: false)
      @anchors[n["id"]] =
        { label: idx, type: "termexample",
          value: idx, elem: @labels["example_xref"],
          container: t["id"],
          xref: l10n("#{@labels['example_xref']} #{idx}") }
    end
  end
end

#termnote_anchor_names(docxml) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/isodoc/xref/xref_gen.rb', line 42

def termnote_anchor_names(docxml)
  docxml.xpath(ns("//*[termnote]")).each do |t|
    c = Counter.new
    t.xpath(ns("./termnote")).noblank.each do |n|
      c.increment(n)
      @anchors[n["id"]] =
        { label: termnote_label(c.print), type: "termnote",
          value: c.print, elem: @labels["termnote"],
          container: t["id"],
          xref: l10n("#{@labels['note_xref']} #{c.print}") }
    end
  end
end

#termnote_label(note) ⇒ Object



31
32
33
# File 'lib/isodoc/xref/xref_gen.rb', line 31

def termnote_label(note)
  @labels["termnote"].gsub("%", note.to_s)
end