metanorma-ogc 2.2.0 → 2.2.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/.github/workflows/rake.yml +1 -1
  3. data/.github/workflows/release.yml +24 -0
  4. data/lib/isodoc/ogc/html/htmlstyle.scss +1 -1
  5. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +128 -153
  6. data/lib/isodoc/ogc/ogc.best-practice.xsl +128 -153
  7. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +128 -153
  8. data/lib/isodoc/ogc/ogc.community-practice.xsl +128 -153
  9. data/lib/isodoc/ogc/ogc.community-standard.xsl +128 -153
  10. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +128 -153
  11. data/lib/isodoc/ogc/ogc.engineering-report.xsl +128 -153
  12. data/lib/isodoc/ogc/ogc.other.xsl +128 -153
  13. data/lib/isodoc/ogc/ogc.policy.xsl +128 -153
  14. data/lib/isodoc/ogc/ogc.reference-model.xsl +128 -153
  15. data/lib/isodoc/ogc/ogc.release-notes.xsl +128 -153
  16. data/lib/isodoc/ogc/ogc.standard.xsl +128 -153
  17. data/lib/isodoc/ogc/ogc.test-suite.xsl +128 -153
  18. data/lib/isodoc/ogc/ogc.user-guide.xsl +128 -153
  19. data/lib/isodoc/ogc/ogc.white-paper.xsl +128 -153
  20. data/lib/isodoc/ogc/presentation_xml_convert.rb +7 -12
  21. data/lib/isodoc/ogc/xref.rb +0 -125
  22. data/lib/metanorma/ogc/biblio.rng +8 -5
  23. data/lib/metanorma/ogc/cleanup.rb +68 -97
  24. data/lib/metanorma/ogc/converter.rb +4 -10
  25. data/lib/metanorma/ogc/validate.rb +0 -45
  26. data/lib/metanorma/ogc/version.rb +1 -1
  27. data/lib/metanorma-ogc.rb +2 -1
  28. data/lib/relaton/render/config.yml +27 -3
  29. data/metanorma-ogc.gemspec +2 -0
  30. metadata +35 -14
  31. data/lib/isodoc/ogc/html/_coverpage.css +0 -205
  32. data/lib/isodoc/ogc/html/htmlstyle.css +0 -1149
  33. data/lib/isodoc/ogc/html/ogc.css +0 -861
  34. data/lib/isodoc/ogc/html/ogc_wp.css +0 -774
  35. data/lib/isodoc/ogc/html/wordstyle.css +0 -1344
  36. data/lib/isodoc/ogc/html/wordstyle_wp.css +0 -1270
  37. data/lib/isodoc/ogc/reqt.rb +0 -215
  38. data/lib/isodoc/ogc/reqt_helper.rb +0 -83
@@ -1,215 +0,0 @@
1
- require_relative "reqt_helper"
2
-
3
- module IsoDoc
4
- module Ogc
5
- class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
6
- def recommendation1(elem, _type)
7
- type = recommendation_class_label(elem)
8
- label = elem.at(ns("./identifier"))&.text
9
- if inject_crossreference_reqt?(elem, label)
10
- n = @xrefs.anchor(@xrefs.reqtlabels[label], :xref, false)
11
- lbl = (n.nil? ? type : n)
12
- elem&.at(ns("./title"))&.remove # suppress from display if embedded
13
- else
14
- n = @xrefs.anchor(elem["id"], :label, false)
15
- lbl = (n.nil? ? type : l10n("#{type} #{n}"))
16
- end
17
- prefix_name(elem, "", lbl, "name")
18
- end
19
-
20
- # embedded reqts xref to top level reqts via label lookup
21
- def inject_crossreference_reqt?(node, label)
22
- !node.ancestors("requirement, recommendation, permission").empty? &&
23
- @xrefs.reqtlabels[label]
24
- end
25
-
26
- def recommendation_header(recommend, out)
27
- h = out.add_child("<thead><tr><th scope='colgroup' colspan='2'>"\
28
- "</th></tr></thead>").first
29
- recommendation_name(recommend, h.at(".//th"))
30
- end
31
-
32
- def recommendation_name(node, out)
33
- b = out.add_child("<p class='#{recommend_name_class(node)}'></p>").first
34
- name = node.at(ns("./name")) and name.children.each { |n| b << n }
35
- return unless title = node.at(ns("./title"))
36
-
37
- b << l10n(": ") if name
38
- title.children.each { |n| b << n }
39
- end
40
-
41
- def recommend_title(node, out)
42
- label = node.at(ns("./identifier")) or return
43
- b = out.add_child("<tr><td colspan='2'><p></p></td></tr>")
44
- p = b.at(".//p")
45
- p["class"] = "RecommendationLabel"
46
- p << label.children.to_xml
47
- end
48
-
49
- def recommendation_attributes1(node)
50
- ret = recommendation_attributes1_head(node, [])
51
- node.xpath(ns("./classification")).each do |c|
52
- line = recommendation_attr_keyvalue(c, "tag",
53
- "value") and ret << line
54
- end
55
- ret
56
- end
57
-
58
- def recommendation_attributes1_head(node, head)
59
- oblig = node["obligation"] and head << ["Obligation", oblig]
60
- subj = node.at(ns("./subject"))&.children and
61
- head << [rec_subj(node), subj]
62
- xref = recommendation_id(node.at(ns("./classification[tag = 'target']/"\
63
- "value"))&.text) and
64
- head << [rec_target(node), xref]
65
- %w(general class).include?(node["type"]) and
66
- xref = recommendation_link(node.at(ns("./identifier"))&.text) and
67
- head << ["Conformance test", xref]
68
- node.xpath(ns("./inherit")).each do |i|
69
- head << ["Dependency", i.children]
70
- end
71
- head
72
- end
73
-
74
- def recommendation_steps(node)
75
- node.elements.each { |e| recommendation_steps(e) }
76
- return node unless node.at(ns("./component[@class = 'step']"))
77
-
78
- d = node.at(ns("./component[@class = 'step']"))
79
- d = d.replace("<ol class='steps'><li>#{d.children.to_xml}</li></ol>")
80
- .first
81
- node.xpath(ns("./component[@class = 'step']")).each do |f|
82
- f = f.replace("<li>#{f.children.to_xml}</li>").first
83
- d << f
84
- end
85
- node
86
- end
87
-
88
- def recommendation_attributes1_component(node, out)
89
- node = recommendation_steps(node)
90
- out << "<tr><td>#{node['label']}</td><td>#{node.children}</td></tr>"
91
- end
92
-
93
- def recommendation_attr_keyvalue(node, key, value)
94
- tag = node.at(ns("./#{key}"))
95
- value = node.at(ns("./#{value}"))
96
- (tag && value && tag.text != "target") or return nil
97
- [tag.text.capitalize, value.children]
98
- end
99
-
100
- def recommendation_attributes(node, out)
101
- recommend_title(node, out)
102
- recommendation_attributes1(node).each do |i|
103
- out.add_child("<tr><td>#{i[0]}</td><td>#{i[1]}</td></tr>")
104
- end
105
- end
106
-
107
- def preserve_in_nested_table?(node)
108
- %w(recommendation requirement permission
109
- table ol dl ul).include?(node.name)
110
- end
111
-
112
- def requirement_component_parse(node, out)
113
- return if node["exclude"] == "true"
114
-
115
- node.elements.size == 1 && node.first_element_child.name == "dl" and
116
- return reqt_dl(node.first_element_child, out)
117
- node.name == "component" and
118
- return recommendation_attributes1_component(node, out)
119
- b = out.add_child("<tr><td colspan='2'></td></tr>").first
120
- b.at(".//td") <<
121
- (preserve_in_nested_table?(node) ? node : node.children)
122
- end
123
-
124
- def reqt_dl(node, out)
125
- node.xpath(ns("./dt")).each do |dt|
126
- dd = dt.next_element
127
- dd&.name == "dd" or next
128
- out.add_child("<tr><td>#{dt.children.to_xml}</td>"\
129
- "<td>#{dd.children.to_xml}</td></tr>")
130
- end
131
- end
132
-
133
- def recommendation_base(node, klass)
134
- out = node.document.create_element("table")
135
- out["id"] = node["id"]
136
- %w(keep-with-next keep-lines-together unnumbered).each do |x|
137
- out[x] = node[x] if node[x]
138
- end
139
- out["class"] = klass
140
- out["type"] = recommend_class(node)
141
- recommendation_component_labels(node)
142
- out
143
- end
144
-
145
- def recommendation_component_labels(node)
146
- node.xpath(ns("./component[@class = 'part']")).each_with_index do |c, i|
147
- c["label"] = (i + "A".ord).chr.to_s
148
- end
149
- node.xpath(ns("./component[not(@class = 'part')]")).each do |c|
150
- c["label"] = case c["class"]
151
- when "test-purpose" then "Test purpose"
152
- when "test-method" then "Test method"
153
- else Metanorma::Utils.strict_capitalize_first(c["class"])
154
- end
155
- end
156
- end
157
-
158
- def recommendation_parse1(node, klass)
159
- out = recommendation_base(node, klass)
160
- recommendation_header(node, out)
161
- b = out.add_child("<tbody></tbody>").first
162
- recommendation_attributes(node, b)
163
- node.elements.reject do |n|
164
- %w(classification subject name identifier title
165
- inherit).include?(n.name)
166
- end.each { |n| requirement_component_parse(n, b) }
167
- node.replace(out)
168
- end
169
-
170
- REQS = %w(recommendation requirement permission).freeze
171
-
172
- def recommendation_to_table(docxml)
173
- @reqt_links = reqt_links(docxml)
174
- @reqt_ids = reqt_ids(docxml)
175
- REQS.each do |x|
176
- REQS.each do |y|
177
- docxml.xpath(ns("//#{x}//#{y}")).each do |r|
178
- recommendation_parse1(r, y)
179
- end
180
- end
181
- docxml.xpath(ns("//#{x}")).each do |r|
182
- recommendation_parse1(r, x)
183
- end
184
- end
185
- requirement_table_cleanup(docxml)
186
- end
187
-
188
- # table nested in table: merge label and caption into a single row
189
- def requirement_table_cleanup1(outer, inner)
190
- outer.delete("colspan")
191
- outer.delete("scope")
192
- inner.delete("colspan")
193
- inner.delete("scope")
194
- outer.name = "td"
195
- p = outer.at(ns("./p[@class = 'RecommendationTitle']")) and
196
- p.delete("class")
197
- outer.parent << inner.dup
198
- inner.parent.remove
199
- end
200
-
201
- def requirement_table_cleanup(docxml)
202
- docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table"))
203
- .each do |t|
204
- t.xpath(ns("./thead | ./tbody |./tfoot")).each do |x|
205
- x.replace(x.children)
206
- end
207
- (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
208
- (y = t.at(ns("./tr/td[@colspan = '2']"))) and
209
- requirement_table_cleanup1(x, y)
210
- t.parent.parent.replace(t.children)
211
- end
212
- end
213
- end
214
- end
215
- end
@@ -1,83 +0,0 @@
1
- module IsoDoc
2
- module Ogc
3
- class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
- def reqt_ids(docxml)
5
- docxml.xpath(ns("//requirement | //recommendation | //permission"))
6
- .each_with_object({}) do |r, m|
7
- id = r.at(ns("./identifier")) or next
8
- m[id.text] = r["id"]
9
- end
10
- end
11
-
12
- def reqt_links(docxml)
13
- docxml.xpath(ns("//requirement | //recommendation | //permission"))
14
- .each_with_object({}) do |r, m|
15
- next unless %w(conformanceclass
16
- verification).include?(r["type"])
17
-
18
- subj = r.at(ns("./classification[tag = 'target']/value"))
19
- id = r.at(ns("./identifier"))
20
- next unless subj && id
21
-
22
- m[subj.text] = { lbl: id.text, id: r["id"] }
23
- end
24
- end
25
-
26
- def rec_subj(node)
27
- case node["type"]
28
- when "class" then "Target type"
29
- else "Subject"
30
- end
31
- end
32
-
33
- def rec_target(node)
34
- case node["type"]
35
- when "class" then "Target type"
36
- when "conformanceclass" then "Requirements class"
37
- when "verification", "abstracttest" then "Requirement"
38
- else "Target"
39
- end
40
- end
41
-
42
- def recommendation_link(ident)
43
- test = @reqt_links[ident&.strip] or return nil
44
- "<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
45
- end
46
-
47
- def recommendation_id(ident)
48
- test = @reqt_ids[ident&.strip] or return nil
49
- "<xref target='#{test}'>#{ident.strip}</xref>"
50
- end
51
-
52
- def recommendation_class_label(node)
53
- case node["type"]
54
- when "verification" then @i18n.get["#{node.name}test"]
55
- when "class" then @i18n.get["#{node.name}class"]
56
- when "abstracttest" then @i18n.get["abstracttest"]
57
- when "conformanceclass" then @i18n.get["conformanceclass"]
58
- else
59
- case node.name
60
- when "recommendation" then @i18n.recommendation
61
- when "requirement" then @i18n.requirement
62
- when "permission" then @i18n.permission
63
- end
64
- end
65
- end
66
-
67
- def recommend_class(node)
68
- case node["type"]
69
- when "verification", "abstracttest" then "recommendtest"
70
- when "class", "conformanceclass" then "recommendclass"
71
- else "recommend"
72
- end
73
- end
74
-
75
- def recommend_name_class(node)
76
- if %w(verification abstracttest).include?(node["type"])
77
- "RecommendationTestTitle"
78
- else "RecommendationTitle"
79
- end
80
- end
81
- end
82
- end
83
- end