metanorma-ogc 1.3.6 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/ogc/boilerplate.xml +6 -6
  3. data/lib/asciidoctor/ogc/converter.rb +91 -36
  4. data/lib/asciidoctor/ogc/front.rb +1 -1
  5. data/lib/asciidoctor/ogc/isodoc.rng +67 -16
  6. data/lib/asciidoctor/ogc/ogc.rng +13 -13
  7. data/lib/asciidoctor/ogc/reqt.rng +15 -4
  8. data/lib/isodoc/ogc/biblio.rb +57 -51
  9. data/lib/isodoc/ogc/i18n-en.yaml +17 -3
  10. data/lib/isodoc/ogc/metadata.rb +1 -1
  11. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +494 -139
  12. data/lib/isodoc/ogc/ogc.best-practice.xsl +494 -139
  13. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +494 -139
  14. data/lib/isodoc/ogc/ogc.community-practice.xsl +494 -139
  15. data/lib/isodoc/ogc/ogc.community-standard.xsl +494 -139
  16. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +494 -139
  17. data/lib/isodoc/ogc/ogc.engineering-report.xsl +494 -139
  18. data/lib/isodoc/ogc/ogc.other.xsl +494 -139
  19. data/lib/isodoc/ogc/ogc.policy.xsl +494 -139
  20. data/lib/isodoc/ogc/ogc.reference-model.xsl +494 -139
  21. data/lib/isodoc/ogc/ogc.release-notes.xsl +494 -139
  22. data/lib/isodoc/ogc/ogc.standard.xsl +494 -139
  23. data/lib/isodoc/ogc/ogc.test-suite.xsl +494 -139
  24. data/lib/isodoc/ogc/ogc.user-guide.xsl +494 -139
  25. data/lib/isodoc/ogc/ogc.white-paper.xsl +451 -100
  26. data/lib/isodoc/ogc/presentation_xml_convert.rb +53 -46
  27. data/lib/isodoc/ogc/reqt.rb +73 -24
  28. data/lib/isodoc/ogc/word_convert.rb +13 -12
  29. data/lib/isodoc/ogc/xref.rb +58 -41
  30. data/lib/metanorma/ogc/processor.rb +2 -1
  31. data/lib/metanorma/ogc/version.rb +1 -1
  32. metadata +2 -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,8 +37,8 @@ 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
 
@@ -46,33 +46,34 @@ module IsoDoc
46
46
  orgs = []
47
47
  docxml.xpath(ns(submittingorgs_path)).each { |org| orgs << org.text }
48
48
  return if orgs.empty?
49
+
49
50
  if a = submit_orgs_append_pt(docxml)
50
51
  a.next = submitting_orgs_clause(orgs)
51
52
  else
52
- preface_init_insert_pt(docxml)&.children&.first&.
53
- add_previous_sibling(submitting_orgs_clause(orgs))
53
+ preface_init_insert_pt(docxml)&.children&.first
54
+ &.add_previous_sibling(submitting_orgs_clause(orgs))
54
55
  end
55
56
  end
56
57
 
57
58
  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
59
+ <<~SUBMITTING
60
+ <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
61
+ <title>Submitting Organizations</title>
62
+ <p>The following organizations submitted this Document to the
63
+ Open Geospatial Consortium (OGC):</p>
64
+ <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
65
+ </clause>
66
+ SUBMITTING
67
+ end
68
+
69
+ def keyword_clause(kwords)
70
+ <<~KEYWORDS
71
+ <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
72
+ <title>Keywords</title>
73
+ <p>The following are keywords to be used by search engines and
74
+ document catalogues.</p>
75
+ <p>#{kwords.join(', ')}</p></clause>
76
+ KEYWORDS
76
77
  end
77
78
 
78
79
  def insert_keywords(docxml)
@@ -81,28 +82,29 @@ module IsoDoc
81
82
  if abstract = docxml.at(ns("//preface/abstract"))
82
83
  abstract.next = keyword_clause(kw)
83
84
  else
84
- preface_init_insert_pt(docxml)&.children&.first&.
85
- add_previous_sibling(keyword_clause(kw))
85
+ preface_init_insert_pt(docxml)&.children&.first
86
+ &.add_previous_sibling(keyword_clause(kw))
86
87
  end
87
88
  end
88
89
 
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")
90
+ def example1(elem)
91
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
92
+ prefix_name(elem, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"),
93
+ "name")
92
94
  end
93
95
 
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)
96
+ def recommendation1(elem, _type)
97
+ type = recommendation_class_label(elem)
98
+ label = elem&.at(ns("./label"))&.text
99
+ if inject_crossreference_reqt?(elem, label)
98
100
  n = @xrefs.anchor(@xrefs.reqtlabels[label], :xref, false)
99
101
  lbl = (n.nil? ? type : n)
100
- f&.at(ns("./title"))&.remove # suppress from display if embedded
102
+ elem&.at(ns("./title"))&.remove # suppress from display if embedded
101
103
  else
102
- n = @xrefs.anchor(f['id'], :label, false)
104
+ n = @xrefs.anchor(elem["id"], :label, false)
103
105
  lbl = (n.nil? ? type : l10n("#{type} #{n}"))
104
106
  end
105
- prefix_name(f, "", lbl, "name")
107
+ prefix_name(elem, "", lbl, "name")
106
108
  end
107
109
 
108
110
  # embedded reqts xref to top level reqts via label lookup
@@ -126,23 +128,29 @@ module IsoDoc
126
128
  end
127
129
  end
128
130
 
129
- def annex1(f)
130
- lbl = @xrefs.anchor(f['id'], :label)
131
- if t = f.at(ns("./title"))
131
+ def annex1(elem)
132
+ lbl = @xrefs.anchor(elem["id"], :label)
133
+ if t = elem.at(ns("./title"))
132
134
  t.children = "<strong>#{t.children.to_xml}</strong>"
133
135
  end
134
- prefix_name(f, "<br/>", lbl, "title")
136
+ prefix_name(elem, "<br/>", lbl, "title")
135
137
  end
136
138
 
137
139
  def clause(docxml)
138
140
  super
139
141
  docxml.xpath(ns("//foreword | //preface/abstract | "\
140
- "//submitters | //introduction | //acknowledgements")).
141
- each do |f|
142
+ "//submitters | //introduction | //acknowledgements"))
143
+ .each do |f|
142
144
  clause1(f)
143
145
  end
144
146
  end
145
147
 
148
+ def clause1(elem)
149
+ return if elem.name == "terms" && elem.parent.name == "annex"
150
+
151
+ super
152
+ end
153
+
146
154
  def block(docxml)
147
155
  super
148
156
  recommendation_to_table(docxml)
@@ -166,4 +174,3 @@ module IsoDoc
166
174
  end
167
175
  end
168
176
  end
169
-
@@ -8,17 +8,26 @@ module IsoDoc
8
8
  return "recommendtest" if node["type"] == "abstracttest"
9
9
  return "recommendclass" if node["type"] == "class"
10
10
  return "recommendclass" if node["type"] == "conformanceclass"
11
+
11
12
  "recommend"
12
13
  end
13
14
 
15
+ def recommend_class?(node)
16
+ %w(recommendtest recommendclass recommend).include? node["type"]
17
+ end
18
+
14
19
  def recommendation_class(node)
15
- node["type"] == "recommendtest" ?
16
- "RecommendationTestTitle" : "RecommendationTitle"
20
+ if node["type"] == "recommendtest"
21
+ "RecommendationTestTitle"
22
+ else
23
+ "RecommendationTitle"
24
+ end
17
25
  end
18
26
 
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")))
27
+ def recommendation_header(recommend)
28
+ h = recommend.add_child("<thead><tr><th scope='colgroup' colspan='2'>"\
29
+ "</th></tr></thead>")
30
+ recommendation_name(recommend, h.at(ns(".//th")))
22
31
  end
23
32
 
24
33
  def recommendation_name(node, out)
@@ -27,7 +36,7 @@ module IsoDoc
27
36
  name.children.each { |n| b << n }
28
37
  b << l10n(":")
29
38
  end
30
- if title = node&.at(ns("./title"))&.remove
39
+ if title = node&.at(ns("./title"))&.remove
31
40
  b << l10n(" ") if name
32
41
  title.children.each { |n| b << n }
33
42
  end
@@ -41,20 +50,53 @@ module IsoDoc
41
50
  end
42
51
 
43
52
  def recommendation_attributes1(node)
44
- out = []
53
+ out = recommendation_attributes1_head(node, [])
54
+ out = recommendation_attributes1_component(node, out)
55
+ node.xpath(ns("./classification")).each do |c|
56
+ line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
57
+ end
58
+ out
59
+ end
60
+
61
+ def recommendation_attributes1_head(node, out)
45
62
  oblig = node["obligation"] and out << ["Obligation", oblig]
46
- subj = node&.at(ns("./subject"))&.remove&.children and out << [rec_subj(node), subj]
63
+ subj = node&.at(ns("./subject"))&.remove&.children and
64
+ out << [rec_subj(node), subj]
47
65
  node.xpath(ns("./inherit")).each do |i|
48
66
  out << ["Dependency", i.remove.children]
49
67
  end
50
- node.xpath(ns("./classification")).each do |c|
51
- line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
68
+ out
69
+ end
70
+
71
+ def strict_capitalize_phrase(str)
72
+ str.split(/ /).map do |w|
73
+ letters = w.chars
74
+ letters.first.upcase!
75
+ letters.join
76
+ end.join(" ")
77
+ end
78
+
79
+ def recommendation_attributes1_component(node, out)
80
+ node.xpath(ns("./component[not(@class = 'part')]")).each do |c|
81
+ out << case c["class"]
82
+ when "test-purpose" then ["Test Purpose", c.remove.children]
83
+ when "test-method" then ["Test Method", c.remove.children]
84
+ else [strict_capitalize_phrase(c["class"]), c.remove.children]
85
+ end
86
+ end
87
+ node.xpath(ns("./component[@class = 'part']")).each_with_index do |c, i|
88
+ out << [(i + "A".ord).chr.to_s, c.remove.children]
52
89
  end
53
90
  out
54
91
  end
55
92
 
56
93
  def rec_subj(node)
57
- node["type"] == "recommendclass" ? "Target Type" : "Subject"
94
+ case node["type_original"]
95
+ when "class" then "Target Type"
96
+ when "conformanceclass" then "Requirements Class"
97
+ when "verification", "abstracttest" then "Requirement"
98
+ else "Subject"
99
+ end
58
100
  end
59
101
 
60
102
  def recommendation_attr_keyvalue(node, key, value)
@@ -72,13 +114,16 @@ module IsoDoc
72
114
  end
73
115
 
74
116
  def preserve_in_nested_table?(node)
75
- return true if %w(recommendation requirement permission table).include?(node.name)
117
+ return true if %w(recommendation requirement permission
118
+ table).include?(node.name)
119
+
76
120
  false
77
121
  end
78
122
 
79
123
  def requirement_component_parse(node, out)
80
124
  node.remove
81
125
  return if node["exclude"] == "true"
126
+
82
127
  node.elements.size == 1 && node.first_element_child.name == "dl" and
83
128
  return reqt_dl(node.first_element_child, out)
84
129
  b = out.add_child("<tr><td colspan='2'></td></tr>").first
@@ -99,6 +144,7 @@ module IsoDoc
99
144
  def recommendation_base(node, klass)
100
145
  node.name = "table"
101
146
  node["class"] = klass
147
+ node["type_original"] = node["type"]
102
148
  node["type"] = recommend_class(node)
103
149
  end
104
150
 
@@ -110,8 +156,10 @@ module IsoDoc
110
156
  recommendation_attributes(node, b)
111
157
  node.elements.each do |n|
112
158
  next if %w(thead tbody).include?(n.name)
159
+
113
160
  requirement_component_parse(n, b)
114
161
  end
162
+ node.delete("type_original")
115
163
  end
116
164
 
117
165
  def recommendation_to_table(docxml)
@@ -128,25 +176,26 @@ module IsoDoc
128
176
  end
129
177
 
130
178
  # 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
179
+ def requirement_table_cleanup1(outer, inner)
180
+ outer.delete("colspan")
181
+ outer.delete("scope")
182
+ inner.delete("colspan")
183
+ inner.delete("scope")
184
+ outer.name = "td"
185
+ p = outer.at(ns("./p[@class = 'RecommendationTitle']")) and
138
186
  p.delete("class")
139
- x.parent << y.dup
140
- y.parent.remove
187
+ outer.parent << inner.dup
188
+ inner.parent.remove
141
189
  end
142
190
 
143
191
  def requirement_table_cleanup(docxml)
144
- docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table")).each do |t|
192
+ docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table"))
193
+ .each do |t|
145
194
  x = t.at(ns("./thead")) and x.replace(x.children)
146
195
  x = t.at(ns("./tbody")) and x.replace(x.children)
147
196
  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']"))
197
+ if (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
198
+ (y = t.at(ns("./tr/td[@colspan = '2']")))
150
199
  requirement_table_cleanup1(x, y)
151
200
  end
152
201
  t.parent.parent.replace(t.children)
@@ -15,7 +15,7 @@ module IsoDoc
15
15
  super
16
16
  end
17
17
 
18
- def default_fonts(options)
18
+ def default_fonts(_options)
19
19
  {
20
20
  bodyfont: '"Times New Roman",serif',
21
21
  headerfont: '"Times New Roman",serif',
@@ -27,7 +27,7 @@ module IsoDoc
27
27
  }
28
28
  end
29
29
 
30
- def default_file_locations(options)
30
+ def default_file_locations(_options)
31
31
  {
32
32
  wordstylesheet: html_doc_path("wordstyle.scss"),
33
33
  standardstylesheet: html_doc_path("ogc.scss"),
@@ -40,7 +40,7 @@ module IsoDoc
40
40
  end
41
41
 
42
42
  def convert1(docxml, filename, dir)
43
- if docxml&.at(ns('//bibdata/ext/doctype'))&.text == "white-paper"
43
+ if docxml&.at(ns("//bibdata/ext/doctype"))&.text == "white-paper"
44
44
  @wordstylesheet_name = html_doc_path("wordstyle_wp.scss")
45
45
  @standardstylesheet_name = html_doc_path("ogc_wp.scss")
46
46
  @wordcoverpage = html_doc_path("word_ogc_titlepage_wp.html")
@@ -86,7 +86,7 @@ module IsoDoc
86
86
  <span lang="EN-GB"><span
87
87
  style='mso-element:field-begin'></span><span
88
88
  style='mso-spacerun:yes'>&#xA0;</span>TOC
89
- \\h \\z \\t &quot;RecommendationTitle,recommendationtitle&quot;
89
+ \\h \\z \\t &quot;RecommendationTitle,recommendationtitle&quot;#{' '}
90
90
  <span style='mso-element:field-separator'></span></span>
91
91
  TOC
92
92
 
@@ -117,7 +117,7 @@ module IsoDoc
117
117
  toc += word_toc_entry(1, header_strip(h))
118
118
  end
119
119
  toc.sub(/(<p class="MsoToc1">)/,
120
- %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
120
+ %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
121
121
  end
122
122
 
123
123
  def make_FigureWordToC(docxml)
@@ -126,7 +126,7 @@ module IsoDoc
126
126
  toc += word_toc_entry(1, header_strip(h))
127
127
  end
128
128
  toc.sub(/(<p class="MsoToc1">)/,
129
- %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
129
+ %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
130
130
  end
131
131
 
132
132
  def make_RecommendationWordToC(docxml)
@@ -135,7 +135,7 @@ module IsoDoc
135
135
  toc += word_toc_entry(1, header_strip(h))
136
136
  end
137
137
  toc.sub(/(<p class="MsoToc1">)/,
138
- %{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
138
+ %{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
139
139
  end
140
140
 
141
141
  def make_body2(body, docxml)
@@ -179,10 +179,11 @@ module IsoDoc
179
179
  x = "//div[@class = 'boilerplate-copyright']/div[1]/p[not(@class)]"
180
180
  docxml.xpath(x).each { |p| p["align"] = "center" }
181
181
  return unless @doctype == "white-paper"
182
- docxml.xpath("//div[@class = 'boilerplate-copyright']//p[not(@class)]").
183
- each { |p| p["class"] = "license" }
184
- docxml.xpath("//div[@class = 'boilerplate-legal']//p[not(@class)]").
185
- each { |p| p["class"] = "license" }
182
+
183
+ docxml.xpath("//div[@class = 'boilerplate-copyright']//p[not(@class)]")
184
+ .each { |p| p["class"] = "license" }
185
+ docxml.xpath("//div[@class = 'boilerplate-legal']//p[not(@class)]")
186
+ .each { |p| p["class"] = "license" }
186
187
  end
187
188
 
188
189
  def word_term_cleanup(docxml)
@@ -199,7 +200,7 @@ module IsoDoc
199
200
  style_update(tr, "background:#A5A5A5;")
200
201
  end
201
202
  docxml.xpath("//table[@class = 'recommend']/tbody").each do |tr|
202
- tr.xpath("./tr").each_slice(2) do |tr1, tr2|
203
+ tr.xpath("./tr").each_slice(2) do |_tr1, tr2|
203
204
  tr2 && style_update(tr2, "background:#C9C9C9;")
204
205
  end
205
206
  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)
@@ -192,7 +209,7 @@ module IsoDoc
192
209
  super
193
210
  return unless @klass.ogc_draft_ref?(ref)
194
211
 
195
- @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref] + " (draft)" }
212
+ @anchors[ref["id"]] = { xref: "#{@anchors[ref['id']][:xref]} (draft)" }
196
213
  end
197
214
  end
198
215
  end