metanorma-ogc 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,9 +33,8 @@ module IsoDoc
33
33
 
34
34
  def recommendation_name(node, out)
35
35
  b = out.add_child("<p class='#{recommendation_class(node)}'></p>").first
36
- if name = node&.at(ns("./name"))&.remove
36
+ name = node&.at(ns("./name"))&.remove and
37
37
  name.children.each { |n| b << n }
38
- end
39
38
  if title = node&.at(ns("./title"))&.remove
40
39
  b << l10n(": ") if name
41
40
  title.children.each { |n| b << n }
@@ -64,6 +63,9 @@ module IsoDoc
64
63
  oblig = node["obligation"] and out << ["Obligation", oblig]
65
64
  subj = node&.at(ns("./subject"))&.remove&.children and
66
65
  out << [rec_subj(node), subj]
66
+ %w(general class).include?(node["type_original"]) and
67
+ test = @reqt_links[node["id"]] and
68
+ out << ["Conformance test", "<xref target='#{test}'/>"]
67
69
  node.xpath(ns("./inherit")).each do |i|
68
70
  out << ["Dependency", i.remove.children]
69
71
  end
@@ -75,7 +77,8 @@ module IsoDoc
75
77
  return node unless node.at(ns("./component[@class = 'step']"))
76
78
 
77
79
  d = node.at(ns("./component[@class = 'step']"))
78
- d = d.replace("<ol class='steps'><li>#{d.children.to_xml}</li></ol>").first
80
+ d = d.replace("<ol class='steps'><li>#{d.children.to_xml}</li></ol>")
81
+ .first
79
82
  node.xpath(ns("./component[@class = 'step']")).each do |f|
80
83
  f = f.replace("<li>#{f.children.to_xml}</li>").first
81
84
  d << f
@@ -177,6 +180,7 @@ module IsoDoc
177
180
  end
178
181
 
179
182
  def recommendation_to_table(docxml)
183
+ @reqt_links = reqt_links(docxml)
180
184
  docxml.xpath(ns("//recommendation")).each do |r|
181
185
  recommendation_parse1(r, "recommendation")
182
186
  end
@@ -189,6 +193,16 @@ module IsoDoc
189
193
  requirement_table_cleanup(docxml)
190
194
  end
191
195
 
196
+ def reqt_links(docxml)
197
+ docxml.xpath(ns("//requirement | //recommendation | //permission"))
198
+ .each_with_object({}) do |r, m|
199
+ next unless %w(conformanceclass verification).include?(r["type"])
200
+ next unless subject = r&.at(ns("./subject/xref/@target"))&.text
201
+
202
+ m[subject] = r["id"]
203
+ end
204
+ end
205
+
192
206
  # table nested in table: merge label and caption into a single row
193
207
  def requirement_table_cleanup1(outer, inner)
194
208
  outer.delete("colspan")
@@ -211,6 +211,21 @@ module Metanorma
211
211
  o = r&.at("./ancestor::*/@obligation")&.text and r["obligation"] = o
212
212
  end
213
213
  end
214
+
215
+ def sections_order_cleanup(xml)
216
+ super
217
+ sort_annexes(xml)
218
+ end
219
+
220
+ def sort_annexes(xml)
221
+ last = xml.at("//annex[last()]") or return
222
+ last.next = "<sentinel/>" and last = last.next_element
223
+ gl = xml.at("//annex[.//term]") and last.previous = gl.remove
224
+ rev = xml.at("//annex[title[normalize-space(.) = 'Revision history']]") ||
225
+ xml.at("//annex[title[normalize-space(.) = 'Revision History']]") and
226
+ last.previous = rev.remove
227
+ last.remove
228
+ end
214
229
  end
215
230
  end
216
231
  end
@@ -14,6 +14,44 @@ module Metanorma
14
14
  def content_validate(doc)
15
15
  super
16
16
  bibdata_validate(doc.root)
17
+ reqt_link_validate(doc.root)
18
+ end
19
+
20
+ def reqt_link_validate(docxml)
21
+ ids = reqt_links(docxml)
22
+ reqt_to_conformance(ids, "general", "verification", "Requirement",
23
+ "Conformance test")
24
+ reqt_to_conformance(ids, "class", "conformanceclass",
25
+ "Requirement class", "Conformance class test")
26
+ conformance_to_reqt(ids, "general", "verification", "Requirement",
27
+ "Conformance test")
28
+ conformance_to_reqt(ids, "class", "conformanceclass",
29
+ "Requirement class", "Conformance class test")
30
+ end
31
+
32
+ def reqt_to_conformance(ids, reqtclass, confclass, reqtlabel, conflabel)
33
+ ids[reqtclass]&.each do |r|
34
+ ids[confclass]&.any? { |x| x[:subject] == r[:id] } or
35
+ @log.add("Requirements", r[:elem],
36
+ "#{reqtlabel} #{r[:id]} has no corresponding #{conflabel}")
37
+ end
38
+ end
39
+
40
+ def conformance_to_reqt(ids, reqtclass, confclass, reqtlabel, conflabel)
41
+ ids[confclass]&.each do |x|
42
+ ids[reqtclass]&.any? { |r| x[:subject] == r[:id] } or
43
+ @log.add("Requirements", x[:elem],
44
+ "#{conflabel} #{x[:id]} has no corresponding #{reqtlabel}")
45
+ end
46
+ end
47
+
48
+ def reqt_links(docxml)
49
+ docxml.xpath("//requirement | //recommendation | //permission")
50
+ .each_with_object({}) do |r, m|
51
+ m[r["type"]] ||= []
52
+ m[r["type"]] << { id: r["id"], elem: r,
53
+ subject: r&.at("./subject/xref/@target")&.text }
54
+ end
17
55
  end
18
56
 
19
57
  def bibdata_validate(doc)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "2.0.0".freeze
3
+ VERSION = "2.0.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639