metanorma-ogc 1.3.7 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/ogc/boilerplate.xml +6 -6
  3. data/lib/asciidoctor/ogc/cleanup.rb +145 -0
  4. data/lib/asciidoctor/ogc/converter.rb +52 -64
  5. data/lib/asciidoctor/ogc/front.rb +1 -1
  6. data/lib/asciidoctor/ogc/isodoc.rng +52 -11
  7. data/lib/asciidoctor/ogc/ogc.rng +13 -13
  8. data/lib/asciidoctor/ogc/reqt.rng +15 -4
  9. data/lib/asciidoctor/ogc/validate.rb +35 -20
  10. data/lib/isodoc/ogc/base_convert.rb +47 -10
  11. data/lib/isodoc/ogc/biblio.rb +57 -51
  12. data/lib/isodoc/ogc/html/htmlstyle.css +10 -0
  13. data/lib/isodoc/ogc/html/htmlstyle.scss +12 -0
  14. data/lib/isodoc/ogc/html/ogc.css +4 -0
  15. data/lib/isodoc/ogc/html/ogc.scss +4 -0
  16. data/lib/isodoc/ogc/i18n-en.yaml +24 -8
  17. data/lib/isodoc/ogc/metadata.rb +1 -1
  18. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +398 -143
  19. data/lib/isodoc/ogc/ogc.best-practice.xsl +398 -143
  20. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +398 -143
  21. data/lib/isodoc/ogc/ogc.community-practice.xsl +398 -143
  22. data/lib/isodoc/ogc/ogc.community-standard.xsl +398 -143
  23. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +398 -143
  24. data/lib/isodoc/ogc/ogc.engineering-report.xsl +398 -143
  25. data/lib/isodoc/ogc/ogc.other.xsl +398 -143
  26. data/lib/isodoc/ogc/ogc.policy.xsl +398 -143
  27. data/lib/isodoc/ogc/ogc.reference-model.xsl +398 -143
  28. data/lib/isodoc/ogc/ogc.release-notes.xsl +398 -143
  29. data/lib/isodoc/ogc/ogc.standard.xsl +398 -143
  30. data/lib/isodoc/ogc/ogc.test-suite.xsl +398 -143
  31. data/lib/isodoc/ogc/ogc.user-guide.xsl +398 -143
  32. data/lib/isodoc/ogc/ogc.white-paper.xsl +330 -98
  33. data/lib/isodoc/ogc/presentation_xml_convert.rb +58 -48
  34. data/lib/isodoc/ogc/reqt.rb +99 -38
  35. data/lib/isodoc/ogc/xref.rb +59 -43
  36. data/lib/metanorma/ogc/processor.rb +2 -1
  37. data/lib/metanorma/ogc/version.rb +1 -1
  38. metadata +3 -2
@@ -20,15 +20,15 @@ module IsoDoc
20
20
 
21
21
  def preface_init_insert_pt(docxml)
22
22
  docxml.at(ns("//preface")) ||
23
- docxml.at(ns("//sections")).
24
- add_previous_sibling("<preface> </preface>").first
23
+ docxml.at(ns("//sections"))
24
+ .add_previous_sibling("<preface> </preface>").first
25
25
  end
26
26
 
27
27
  def submit_orgs_append_pt(docxml)
28
28
  docxml.at(ns("//introduction")) ||
29
- docxml.at(ns("//foreword")) ||
30
- docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
31
- docxml.at(ns("//preface/abstract"))
29
+ docxml.at(ns("//foreword")) ||
30
+ docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
31
+ docxml.at(ns("//preface/abstract"))
32
32
  end
33
33
 
34
34
  def insert_security(docxml)
@@ -37,42 +37,45 @@ module IsoDoc
37
37
  if a = submit_orgs_append_pt(docxml)
38
38
  a.next = s
39
39
  else
40
- preface_init_insert_pt(docxml)&.children&.first&.
41
- add_previous_sibling(s)
40
+ preface_init_insert_pt(docxml)&.children&.first
41
+ &.add_previous_sibling(s)
42
42
  end
43
43
  end
44
44
 
45
45
  def insert_submitting_orgs(docxml)
46
- orgs = []
47
- docxml.xpath(ns(submittingorgs_path)).each { |org| orgs << org.text }
46
+ orgs = docxml.xpath(ns(submittingorgs_path))
47
+ .each_with_object([]) do |org, m|
48
+ m << org.text
49
+ end
48
50
  return if orgs.empty?
51
+
49
52
  if a = submit_orgs_append_pt(docxml)
50
53
  a.next = submitting_orgs_clause(orgs)
51
54
  else
52
- preface_init_insert_pt(docxml)&.children&.first&.
53
- add_previous_sibling(submitting_orgs_clause(orgs))
55
+ preface_init_insert_pt(docxml)&.children&.first
56
+ &.add_previous_sibling(submitting_orgs_clause(orgs))
54
57
  end
55
58
  end
56
59
 
57
60
  def submitting_orgs_clause(orgs)
58
- <<~END
59
- <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
60
- <title>Submitting Organizations</title>
61
- <p>The following organizations submitted this Document to the
62
- Open Geospatial Consortium (OGC):</p>
63
- <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
64
- </clause>
65
- END
66
- end
67
-
68
- def keyword_clause(kw)
69
- <<~END
70
- <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
71
- <title>Keywords</title>
72
- <p>The following are keywords to be used by search engines and
73
- document catalogues.</p>
74
- <p>#{kw.join(", ")}</p></clause>
75
- END
61
+ <<~SUBMITTING
62
+ <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
63
+ <title>Submitting Organizations</title>
64
+ <p>The following organizations submitted this Document to the
65
+ Open Geospatial Consortium (OGC):</p>
66
+ <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
67
+ </clause>
68
+ SUBMITTING
69
+ end
70
+
71
+ def keyword_clause(kwords)
72
+ <<~KEYWORDS
73
+ <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
74
+ <title>Keywords</title>
75
+ <p>The following are keywords to be used by search engines and
76
+ document catalogues.</p>
77
+ <p>#{kwords.join(', ')}</p></clause>
78
+ KEYWORDS
76
79
  end
77
80
 
78
81
  def insert_keywords(docxml)
@@ -81,28 +84,29 @@ module IsoDoc
81
84
  if abstract = docxml.at(ns("//preface/abstract"))
82
85
  abstract.next = keyword_clause(kw)
83
86
  else
84
- preface_init_insert_pt(docxml)&.children&.first&.
85
- add_previous_sibling(keyword_clause(kw))
87
+ preface_init_insert_pt(docxml)&.children&.first
88
+ &.add_previous_sibling(keyword_clause(kw))
86
89
  end
87
90
  end
88
91
 
89
- def example1(f)
90
- lbl = @xrefs.anchor(f['id'], :label, false) or return
91
- prefix_name(f, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"), "name")
92
+ def example1(elem)
93
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
94
+ prefix_name(elem, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"),
95
+ "name")
92
96
  end
93
97
 
94
- def recommendation1(f, type)
95
- type = recommendation_class_label(f)
96
- label = f&.at(ns("./label"))&.text
97
- if inject_crossreference_reqt?(f, label)
98
+ def recommendation1(elem, _type)
99
+ type = recommendation_class_label(elem)
100
+ label = elem&.at(ns("./label"))&.text
101
+ if inject_crossreference_reqt?(elem, label)
98
102
  n = @xrefs.anchor(@xrefs.reqtlabels[label], :xref, false)
99
103
  lbl = (n.nil? ? type : n)
100
- f&.at(ns("./title"))&.remove # suppress from display if embedded
104
+ elem&.at(ns("./title"))&.remove # suppress from display if embedded
101
105
  else
102
- n = @xrefs.anchor(f['id'], :label, false)
106
+ n = @xrefs.anchor(elem["id"], :label, false)
103
107
  lbl = (n.nil? ? type : l10n("#{type} #{n}"))
104
108
  end
105
- prefix_name(f, "", lbl, "name")
109
+ prefix_name(elem, "", lbl, "name")
106
110
  end
107
111
 
108
112
  # embedded reqts xref to top level reqts via label lookup
@@ -126,23 +130,30 @@ module IsoDoc
126
130
  end
127
131
  end
128
132
 
129
- def annex1(f)
130
- lbl = @xrefs.anchor(f['id'], :label)
131
- if t = f.at(ns("./title"))
133
+ def annex1(elem)
134
+ lbl = @xrefs.anchor(elem["id"], :label)
135
+ if t = elem.at(ns("./title"))
132
136
  t.children = "<strong>#{t.children.to_xml}</strong>"
133
137
  end
134
- prefix_name(f, "<br/>", lbl, "title")
138
+ prefix_name(elem, "<br/>", lbl, "title")
135
139
  end
136
140
 
137
141
  def clause(docxml)
138
142
  super
139
143
  docxml.xpath(ns("//foreword | //preface/abstract | "\
140
- "//submitters | //introduction | //acknowledgements")).
141
- each do |f|
144
+ "//submitters | //introduction | //acknowledgements"))
145
+ .each do |f|
142
146
  clause1(f)
143
147
  end
144
148
  end
145
149
 
150
+ def clause1(elem)
151
+ return if elem.name == "terms" && elem.parent.name == "annex" &&
152
+ elem.parent.xpath(ns("./terms")).size == 1
153
+
154
+ super
155
+ end
156
+
146
157
  def block(docxml)
147
158
  super
148
159
  recommendation_to_table(docxml)
@@ -166,4 +177,3 @@ module IsoDoc
166
177
  end
167
178
  end
168
179
  end
169
-
@@ -1,4 +1,5 @@
1
1
  require "isodoc"
2
+ require "metanorma-utils"
2
3
 
3
4
  module IsoDoc
4
5
  module Ogc
@@ -8,53 +9,91 @@ module IsoDoc
8
9
  return "recommendtest" if node["type"] == "abstracttest"
9
10
  return "recommendclass" if node["type"] == "class"
10
11
  return "recommendclass" if node["type"] == "conformanceclass"
12
+
11
13
  "recommend"
12
14
  end
13
15
 
16
+ def recommend_class?(node)
17
+ %w(recommendtest recommendclass recommend).include? node["type"]
18
+ end
19
+
14
20
  def recommendation_class(node)
15
- node["type"] == "recommendtest" ?
16
- "RecommendationTestTitle" : "RecommendationTitle"
21
+ if node["type"] == "recommendtest"
22
+ "RecommendationTestTitle"
23
+ else
24
+ "RecommendationTitle"
25
+ end
17
26
  end
18
27
 
19
- def recommendation_header(r)
20
- h = r.add_child("<thead><tr><th scope='colgroup' colspan='2'></th></tr></thead>")
21
- recommendation_name(r, h.at(ns(".//th")))
28
+ def recommendation_header(recommend)
29
+ h = recommend.add_child("<thead><tr><th scope='colgroup' colspan='2'>"\
30
+ "</th></tr></thead>")
31
+ recommendation_name(recommend, h.at(ns(".//th")))
22
32
  end
23
33
 
24
34
  def recommendation_name(node, out)
25
35
  b = out.add_child("<p class='#{recommendation_class(node)}'></p>").first
26
36
  if name = node&.at(ns("./name"))&.remove
27
37
  name.children.each { |n| b << n }
28
- b << l10n(":")
29
38
  end
30
- if title = node&.at(ns("./title"))&.remove
31
- b << l10n(" ") if name
39
+ if title = node&.at(ns("./title"))&.remove
40
+ b << l10n(": ") if name
32
41
  title.children.each { |n| b << n }
33
42
  end
34
43
  end
35
44
 
36
45
  def recommend_title(node, out)
37
46
  label = node&.at(ns("./label"))&.remove or return
47
+ label.xpath(ns(".//xref | .//eref | .//quote/source"))
48
+ .each { |f| xref1(f) }
49
+ label.xpath(ns(".//concept")).each { |f| concept1(f) }
38
50
  b = out.add_child("<tr><td colspan='2'><p></p></td></tr>")
39
51
  p = b.at(ns(".//p"))
40
- p << label.children
52
+ p << label.text
41
53
  end
42
54
 
43
55
  def recommendation_attributes1(node)
44
- out = []
56
+ out = recommendation_attributes1_head(node, [])
57
+ node.xpath(ns("./classification")).each do |c|
58
+ line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
59
+ end
60
+ out
61
+ end
62
+
63
+ def recommendation_attributes1_head(node, out)
45
64
  oblig = node["obligation"] and out << ["Obligation", oblig]
46
- subj = node&.at(ns("./subject"))&.remove&.children and out << [rec_subj(node), subj]
65
+ subj = node&.at(ns("./subject"))&.remove&.children and
66
+ out << [rec_subj(node), subj]
47
67
  node.xpath(ns("./inherit")).each do |i|
48
68
  out << ["Dependency", i.remove.children]
49
69
  end
50
- node.xpath(ns("./classification")).each do |c|
51
- line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
52
- end
53
70
  out
54
71
  end
55
72
 
73
+ def recommendation_steps(node)
74
+ node.elements.each { |e| recommendation_steps(e) }
75
+ return node unless node.at(ns("./component[@class = 'step']"))
76
+
77
+ d = node.at(ns("./component[@class = 'step']"))
78
+ d = d.replace("<ol><li>#{d.children.to_xml}</li></ol>").first
79
+ node.xpath(ns("./component[@class = 'step']")).each do |f|
80
+ f = f.replace("<li>#{f.children.to_xml}</li>").first
81
+ d << f
82
+ end
83
+ end
84
+
85
+ def recommendation_attributes1_component(node, out)
86
+ node = recommendation_steps(node)
87
+ out << "<tr><td>#{node['label']}</td><td>#{node.children}</td></tr>"
88
+ end
89
+
56
90
  def rec_subj(node)
57
- node["type"] == "recommendclass" ? "Target Type" : "Subject"
91
+ case node["type_original"]
92
+ when "class" then "Target type"
93
+ when "conformanceclass" then "Requirements class"
94
+ when "verification", "abstracttest" then "Requirement"
95
+ else "Subject"
96
+ end
58
97
  end
59
98
 
60
99
  def recommendation_attr_keyvalue(node, key, value)
@@ -66,23 +105,30 @@ module IsoDoc
66
105
  end
67
106
 
68
107
  def recommendation_attributes(node, out)
108
+ recommend_title(node, out)
69
109
  recommendation_attributes1(node).each do |i|
70
110
  out.add_child("<tr><td>#{i[0]}</td><td>#{i[1]}</td></tr>")
71
111
  end
72
112
  end
73
113
 
74
114
  def preserve_in_nested_table?(node)
75
- return true if %w(recommendation requirement permission table).include?(node.name)
115
+ return true if %w(recommendation requirement permission
116
+ table).include?(node.name)
117
+
76
118
  false
77
119
  end
78
120
 
79
121
  def requirement_component_parse(node, out)
80
122
  node.remove
81
123
  return if node["exclude"] == "true"
124
+
82
125
  node.elements.size == 1 && node.first_element_child.name == "dl" and
83
126
  return reqt_dl(node.first_element_child, out)
127
+ node.name == "component" and
128
+ return recommendation_attributes1_component(node, out)
84
129
  b = out.add_child("<tr><td colspan='2'></td></tr>").first
85
- b.at(ns(".//td")) << (preserve_in_nested_table?(node) ? node : node.children)
130
+ b.at(ns(".//td")) <<
131
+ (preserve_in_nested_table?(node) ? node : node.children)
86
132
  end
87
133
 
88
134
  def reqt_dl(node, out)
@@ -99,19 +145,34 @@ module IsoDoc
99
145
  def recommendation_base(node, klass)
100
146
  node.name = "table"
101
147
  node["class"] = klass
148
+ node["type_original"] = node["type"]
102
149
  node["type"] = recommend_class(node)
150
+ recommendation_component_labels(node)
151
+ end
152
+
153
+ def recommendation_component_labels(node)
154
+ node.xpath(ns("./component[@class = 'part']")).each_with_index do |c, i|
155
+ c["label"] = (i + "A".ord).chr.to_s
156
+ end
157
+ node.xpath(ns("./component[not(@class = 'part')]")).each do |c|
158
+ c["label"] = case c["class"]
159
+ when "test-purpose" then "Test purpose"
160
+ when "test-method" then "Test method"
161
+ else Metanorma::Utils.strict_capitalize_first(c["class"])
162
+ end
163
+ end
103
164
  end
104
165
 
105
166
  def recommendation_parse1(node, klass)
106
167
  recommendation_base(node, klass)
107
168
  recommendation_header(node)
108
169
  b = node.add_child("<tbody></tbody>").first
109
- recommend_title(node, b)
110
170
  recommendation_attributes(node, b)
111
- node.elements.each do |n|
112
- next if %w(thead tbody).include?(n.name)
113
- requirement_component_parse(n, b)
114
- end
171
+ node.elements.reject do |n|
172
+ %w(thead tbody classification subject
173
+ inherit).include?(n.name)
174
+ end.each { |n| requirement_component_parse(n, b) }
175
+ node.delete("type_original")
115
176
  end
116
177
 
117
178
  def recommendation_to_table(docxml)
@@ -128,27 +189,27 @@ module IsoDoc
128
189
  end
129
190
 
130
191
  # table nested in table: merge label and caption into a single row
131
- def requirement_table_cleanup1(x, y)
132
- x.delete("colspan")
133
- x.delete("scope")
134
- y.delete("colspan")
135
- y.delete("scope")
136
- x.name = "td"
137
- p = x.at(ns("./p[@class = 'RecommendationTitle']")) and
192
+ def requirement_table_cleanup1(outer, inner)
193
+ outer.delete("colspan")
194
+ outer.delete("scope")
195
+ inner.delete("colspan")
196
+ inner.delete("scope")
197
+ outer.name = "td"
198
+ p = outer.at(ns("./p[@class = 'RecommendationTitle']")) and
138
199
  p.delete("class")
139
- x.parent << y.dup
140
- y.parent.remove
200
+ outer.parent << inner.dup
201
+ inner.parent.remove
141
202
  end
142
203
 
143
204
  def requirement_table_cleanup(docxml)
144
- docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table")).each do |t|
145
- x = t.at(ns("./thead")) and x.replace(x.children)
146
- x = t.at(ns("./tbody")) and x.replace(x.children)
147
- x = t.at(ns("./tfoot")) and x.replace(x.children)
148
- if x = t.at(ns("./tr/th[@colspan = '2']")) and
149
- y = t.at(ns("./tr/td[@colspan = '2']"))
150
- requirement_table_cleanup1(x, y)
205
+ docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table"))
206
+ .each do |t|
207
+ t.xpath(ns("./thead | ./tbody |./tfoot")).each do |x|
208
+ x.replace(x.children)
151
209
  end
210
+ (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
211
+ (y = t.at(ns("./tr/td[@colspan = '2']"))) and
212
+ requirement_table_cleanup1(x, y)
152
213
  t.parent.parent.replace(t.children)
153
214
  end
154
215
  end
@@ -24,6 +24,7 @@ module IsoDoc
24
24
  @anchors[t["id"]] = anchor_struct(id, t, label, klass,
25
25
  t["unnumbered"])
26
26
  l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
27
+ permission_parts(t, label, klass)
27
28
  sequential_permission_children(t, id)
28
29
  end
29
30
  end
@@ -32,7 +33,7 @@ module IsoDoc
32
33
  { "class" => "@type = 'class'",
33
34
  "test" => "@type = 'verification'",
34
35
  "" => "not(@type = 'verification' or @type = 'class' or "\
35
- "@type = 'abstracttest' or @type = 'conformanceclass')" }
36
+ "@type = 'abstracttest' or @type = 'conformanceclass')" }
36
37
  end
37
38
 
38
39
  def req_class_paths2
@@ -40,15 +41,27 @@ module IsoDoc
40
41
  "conformanceclass" => "@type = 'conformanceclass'" }
41
42
  end
42
43
 
43
- def sequential_permission_children(t, id)
44
+ def permission_parts(block, label, klass)
45
+ block.xpath(ns("./component[@class = 'part']"))
46
+ .each_with_index do |c, i|
47
+ next if c["id"].nil? || c["id"].empty?
48
+
49
+ @anchors[c["id"]] = anchor_struct((i + "A".ord).chr.to_s, c, label,
50
+ klass, c["unnumbered"])
51
+ end
52
+ end
53
+
54
+ REQS = %w(permission requirement recommendation).freeze
55
+
56
+ def sequential_permission_children(block, idx)
44
57
  req_class_paths.each do |k, v|
45
- %w(permission requirement recommendation).each do |r|
46
- sequential_permission_names1(t, id, "#{r}[#{v}]",
58
+ REQS.each do |r|
59
+ sequential_permission_names1(block, idx, "#{r}[#{v}]",
47
60
  @labels["#{r}#{k}"])
48
61
  end
49
62
  end
50
63
  req_class_paths2.each do |k, v|
51
- sequential_permission_names1(t, id, "*[#{v}]", @labels[k])
64
+ sequential_permission_names1(block, idx, "*[#{v}]", @labels[k])
52
65
  end
53
66
  end
54
67
 
@@ -60,6 +73,7 @@ module IsoDoc
60
73
  id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
61
74
  @anchors[t["id"]] = anchor_struct(id, t, label, klass,
62
75
  t["unnumbered"])
76
+ permission_parts(t, label, klass)
63
77
  sequential_permission_children(t, id)
64
78
  end
65
79
  end
@@ -69,7 +83,7 @@ module IsoDoc
69
83
  sequential_figure_names(clause)
70
84
  sequential_formula_names(clause)
71
85
  req_class_paths.each do |k, v|
72
- %w(permission requirement recommendation).each do |r|
86
+ REQS.each do |r|
73
87
  sequential_permission_names(clause, "#{r}[#{v}]",
74
88
  @labels["#{r}#{k}"])
75
89
  end
@@ -84,7 +98,7 @@ module IsoDoc
84
98
  hierarchical_figure_names(clause, num)
85
99
  hierarchical_formula_names(clause, num)
86
100
  req_class_paths.each do |k, v|
87
- %w(permission requirement recommendation).each do |r|
101
+ REQS.each do |r|
88
102
  hierarchical_permission_names(clause, num, "#{r}[#{v}]",
89
103
  @labels["#{r}#{k}"])
90
104
  end
@@ -103,51 +117,54 @@ module IsoDoc
103
117
  @anchors[t["id"]] = anchor_struct(lbl, t, label, klass,
104
118
  t["unnumbered"])
105
119
  l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
120
+ permission_parts(t, label, klass)
106
121
  sequential_permission_children(t, lbl)
107
122
  end
108
123
  end
109
124
 
110
- def initial_anchor_names(d)
111
- @prefacenum = 0
112
- preface_names_numbered(d.at(ns("//preface/abstract")))
113
- preface_names_numbered(d.at(ns("//preface/clause[@type = 'keywords']")))
114
- preface_names_numbered(d.at(ns("//foreword")))
115
- preface_names_numbered(d.at(ns("//introduction")))
116
- preface_names_numbered(d.at(ns("//preface/clause[@type = 'security']")))
117
- preface_names_numbered(d.at(ns("//preface/clause"\
118
- "[@type = 'submitting_orgs']")))
119
- preface_names_numbered(d.at(ns("//submitters")))
120
- d.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
121
- "@type = 'submitting_orgs' or @type = 'security')]")).each do |c|
122
- preface_names_numbered(c)
123
- end
124
- preface_names_numbered(d.at(ns("//acknowledgements")))
125
- sequential_asset_names(d.xpath(ns(
126
- "//preface/abstract | //foreword | //introduction | "\
127
- "//submitters | //acknowledgements | //preface/clause",
128
- )))
125
+ def initial_anchor_names(doc)
126
+ preface_anchor_names(doc)
129
127
  n = Counter.new
130
- n = section_names(d.at(ns("//clause[@type = 'scope']")), n, 1)
131
- n = section_names(d.at(ns("//clause[@type = 'conformance']")), n, 1)
132
- n = section_names(d.at(ns(@klass.norm_ref_xpath)), n, 1)
128
+ n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
129
+ n = section_names(doc.at(ns("//clause[@type = 'conformance']")), n, 1)
130
+ n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
133
131
  n = section_names(
134
- d.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
132
+ doc.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
135
133
  n, 1
136
134
  )
137
- n = section_names(d.at(ns("//sections/definitions")), n, 1)
138
- middle_section_asset_names(d)
139
- clause_names(d, n)
140
- termnote_anchor_names(d)
141
- termexample_anchor_names(d)
135
+ n = section_names(doc.at(ns("//sections/definitions")), n, 1)
136
+ middle_section_asset_names(doc)
137
+ clause_names(doc, n)
138
+ termnote_anchor_names(doc)
139
+ termexample_anchor_names(doc)
140
+ end
141
+
142
+ def preface_anchor_names(doc)
143
+ @prefacenum = 0
144
+ ["//preface/abstract", "//preface/clause[@type = 'keywords']",
145
+ "//foreword", "//introduction", "//preface/clause[@type = 'security']",
146
+ "//preface/clause[@type = 'submitting_orgs']",
147
+ "//submitters"].each do |path|
148
+ preface_names_numbered(doc.at(ns(path)))
149
+ end
150
+ doc.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
151
+ "@type = 'submitting_orgs' or @type = 'security')]"))
152
+ .each { |c| preface_names_numbered(c) }
153
+ preface_names_numbered(doc.at(ns("//acknowledgements")))
154
+ sequential_asset_names(
155
+ doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\
156
+ "//submitters | //acknowledgements | //preface/clause")),
157
+ )
142
158
  end
143
159
 
144
- def middle_section_asset_names(d)
145
- middle_sections = "//clause[@type = 'scope' or @type = 'conformance'] "\
146
- "| //foreword | //introduction | //preface/abstract | "\
147
- "//submitters | //acknowledgements | //preface/clause | "\
160
+ def middle_section_asset_names(doc)
161
+ middle_sections =
162
+ "//clause[@type = 'scope' or @type = 'conformance'] | //foreword | "\
163
+ "//introduction | //preface/abstract | //submitters | "\
164
+ "//acknowledgements | //preface/clause | "\
148
165
  " #{@klass.norm_ref_xpath} | //sections/terms | "\
149
166
  "//sections/definitions | //clause[parent::sections]"
150
- sequential_asset_names(d.xpath(ns(middle_sections)))
167
+ sequential_asset_names(doc.xpath(ns(middle_sections)))
151
168
  end
152
169
 
153
170
  def preface_names_numbered(clause)
@@ -183,8 +200,7 @@ module IsoDoc
183
200
  when 6 then "(#{num})"
184
201
  when 7 then "(#{(96 + num).chr})"
185
202
  when 8 then "(#{RomanNumerals.to_roman(num).downcase})"
186
- else
187
- num.to_s
203
+ else num.to_s
188
204
  end
189
205
  end
190
206
 
@@ -192,7 +208,7 @@ module IsoDoc
192
208
  super
193
209
  return unless @klass.ogc_draft_ref?(ref)
194
210
 
195
- @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref] + " (draft)" }
211
+ @anchors[ref["id"]] = { xref: "#{@anchors[ref['id']][:xref]} (draft)" }
196
212
  end
197
213
  end
198
214
  end