metanorma-ogc 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,78 +85,6 @@ module Metanorma
85
85
  @i18n&.termsdef, true)
86
86
  end
87
87
 
88
- def requirement_metadata_component_tags
89
- %w(test-purpose test-method test-method-type conditions part description
90
- reference step requirement permission recommendation)
91
- end
92
-
93
- def requirement_metadata1(reqt, dlist, ins)
94
- ins1 = super
95
- dlist.xpath("./dt").each do |e|
96
- tag = e&.text&.gsub(/ /, "-")&.downcase
97
- next unless requirement_metadata_component_tags.include? tag
98
-
99
- ins1.next = requirement_metadata1_component(e, tag)
100
- ins1 = ins1.next
101
- end
102
- end
103
-
104
- def requirement_metadata1_component(term, tag)
105
- val = term.at("./following::dd")
106
- val.name = tag
107
- val.xpath("./dl").each do |d|
108
- requirement_metadata1(val, d, d)
109
- d.remove
110
- end
111
- if %w(requirement permission
112
- recommendation).include?(term.text) && !val.text.empty?
113
- val["label"] = val.text.strip
114
- val.children.remove
115
- end
116
- val
117
- end
118
-
119
- def requirement_metadata(xmldoc)
120
- super
121
- xmldoc.xpath(REQRECPER).each do |r|
122
- requirement_metadata_to_component(r)
123
- requirement_metadata_to_requirement(r)
124
- requirement_subparts_to_blocks(r)
125
- requirement_target_identifiers(r)
126
- end
127
- end
128
-
129
- def requirement_target_identifiers(reqt)
130
- reqt.xpath("./classification[tag = 'target']/value[link]").each do |v|
131
- v.children = v.at("./link/@target").text
132
- end
133
- end
134
-
135
- def requirement_metadata_to_component(reqt)
136
- reqt.xpath(".//test-method | .//test-purpose | .//conditions | "\
137
- ".//part | .//test-method-type | .//step | .//reference")
138
- .each do |c|
139
- c["class"] = c.name
140
- c.name = "component"
141
- end
142
- end
143
-
144
- def requirement_metadata_to_requirement(reqt)
145
- reqt.xpath("./requirement | ./permission | ./recommendation")
146
- .each do |c|
147
- c["id"] = Metanorma::Utils::anchor_or_uuid
148
- end
149
- end
150
-
151
- def requirement_subparts_to_blocks(reqt)
152
- reqt.xpath(".//component | .//description").each do |c|
153
- next if %w(p ol ul dl table component description)
154
- .include?(c&.elements&.first&.name)
155
-
156
- c.children = "<p>#{c.children.to_xml}</p>"
157
- end
158
- end
159
-
160
88
  def termdef_cleanup(xmldoc)
161
89
  super
162
90
  termdef_subclause_cleanup(xmldoc)
@@ -172,31 +100,6 @@ module Metanorma
172
100
  end
173
101
  end
174
102
 
175
- def requirement_cleanup(xmldoc)
176
- requirement_type(xmldoc)
177
- super
178
- end
179
-
180
- def requirement_type(xmldoc)
181
- xmldoc.xpath(REQRECPER).each do |r|
182
- next unless r["type"]
183
-
184
- requirement_type1(r)
185
- end
186
- end
187
-
188
- def requirement_type1(reqt)
189
- reqt["type"] = case reqt["type"]
190
- when "requirement", "recommendation", "permission"
191
- "general"
192
- when "requirements_class" then "class"
193
- when "conformance_test" then "verification"
194
- when "conformance_class" then "conformanceclass"
195
- when "abstract_test" then "abstracttest"
196
- else reqt["type"]
197
- end
198
- end
199
-
200
103
  def normref_cleanup(xmldoc)
201
104
  r1 = xmldoc.at("//references[title[translate(text(), 'R', 'r') = "\
202
105
  "'Normative references']]")
@@ -233,6 +136,74 @@ module Metanorma
233
136
  last.previous = rev.remove
234
137
  last.remove
235
138
  end
139
+
140
+ def sort_biblio(bib)
141
+ bib.sort do |a, b|
142
+ sort_biblio_key(a) <=> sort_biblio_key(b)
143
+ end
144
+ end
145
+
146
+ PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
147
+
148
+ OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
149
+ "@type = 'ISBN'".freeze
150
+
151
+ def pub_class(bib)
152
+ return 1 if bib.at("#{PUBLISHER}[abbreviation = 'OGC']")
153
+ return 1 if bib.at("#{PUBLISHER}[name = 'Open Geospatial "\
154
+ "Consortium']")
155
+ return 2 if bib.at("./docidentifier[@type][not(#{OTHERIDS})]")
156
+
157
+ 3
158
+ end
159
+
160
+ # sort by: doc class (OGC, other standard (not DOI &c), other
161
+ # then standard class (docid class other than DOI &c)
162
+ # then if OGC, doc title else if other, authors
163
+ # then docnumber if present, numeric sort
164
+ # else alphanumeric metanorma id (abbreviation)
165
+ # then doc part number if present, numeric sort
166
+ # then doc id (not DOI &c)
167
+ # then title
168
+ def sort_biblio_key(bib)
169
+ pubclass = pub_class(bib)
170
+ ids = sort_biblio_ids_key(bib)
171
+ title = title_key(bib)
172
+ sortkey3 = author_title_key(pubclass, title, bib)
173
+ num = if ids[:num].nil? then ids[:abbrid]
174
+ else sprintf("%09d", ids[:num].to_i)
175
+ end
176
+ "#{pubclass} :: #{ids[:type]} :: #{sortkey3} :: #{num} :: "\
177
+ "#{sprintf('%09d', ids[:partid])} :: #{ids[:id]} :: #{title}"
178
+ end
179
+
180
+ def author_title_key(pubclass, title, bib)
181
+ case pubclass
182
+ when 1, 2 then title
183
+ when 3
184
+ cite = ::Relaton::Render::General.new
185
+ .render_all("<references>#{bib.to_xml}</references>")
186
+ cite[:author]
187
+ end
188
+ end
189
+
190
+ def title_key(bib)
191
+ title = bib.at("./title[@type = 'main']") ||
192
+ bib.at("./title") || bib.at("./formattedref")
193
+ title&.text&.sub!(/^(OGC|Open Geospatial Consortium)\b/, "")
194
+ end
195
+
196
+ def sort_biblio_ids_key(bib)
197
+ id = bib.at("./docidentifier[@primary]") ||
198
+ bib.at("./docidentifier[not(#{OTHERIDS})]")
199
+ metaid = bib.at("./docidentifier[@type = 'metanorma']")&.text
200
+ /\d-(?<partid>\d+)/ =~ id&.text
201
+ { id: id&.text,
202
+ num: bib.at("./docnumber")&.text,
203
+ abbrid: /^\[\d+\]$/.match?(metaid) ? metaid : nil,
204
+ partid: partid&.to_i || 0,
205
+ type: id ? id["type"] : nil }
206
+ end
236
207
  end
237
208
  end
238
209
  end
@@ -26,6 +26,10 @@ module Metanorma
26
26
  # ignore, we generate ToC outside of asciidoctor
27
27
  def toc(value); end
28
28
 
29
+ def default_requirement_model
30
+ "ogc"
31
+ end
32
+
29
33
  def makexml(node)
30
34
  @draft = node.attributes.has_key?("draft")
31
35
  super
@@ -33,10 +33,10 @@ module Metanorma
33
33
  ids[reqtclass]&.each do |r|
34
34
  (r[:label] && ids[confclass]&.any? do |x|
35
35
  x[:subject] == r[:label]
36
- end) or
37
- @log.add("Requirements", r[:elem],
38
- "#{reqtlabel} #{r[:label] || r[:id]} "\
39
- "has no corresponding #{conflabel}")
36
+ end) and next
37
+ @log.add("Requirements", r[:elem],
38
+ "#{reqtlabel} #{r[:label] || r[:id]} "\
39
+ "has no corresponding #{conflabel}")
40
40
  end
41
41
  end
42
42
 
@@ -44,17 +44,18 @@ module Metanorma
44
44
  ids[confclass]&.each do |x|
45
45
  (x[:subject] && ids[reqtclass]&.any? do |r|
46
46
  x[:subject] == r[:label]
47
- end) or
48
- @log.add("Requirements", x[:elem],
49
- "#{conflabel} #{x[:label] || x[:id]} "\
50
- "has no corresponding #{reqtlabel}")
47
+ end) and next
48
+ @log.add("Requirements", x[:elem],
49
+ "#{conflabel} #{x[:label] || x[:id]} "\
50
+ "has no corresponding #{reqtlabel}")
51
51
  end
52
52
  end
53
53
 
54
54
  def reqt_links(docxml)
55
55
  docxml.xpath("//requirement | //recommendation | //permission")
56
56
  .each_with_object({}) do |r, m|
57
- type = r["type"] || "general"
57
+ type = r["type"]
58
+ type.empty? and type = "general"
58
59
  m[type] ||= []
59
60
  m[type] << { id: r["id"], elem: r, label: r.at("./identifier")&.text,
60
61
  subject: r.at("./classification[tag = 'target']/value")&.text }
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "2.2.0".freeze
3
+ VERSION = "2.2.1".freeze
4
4
  end
5
5
  end
@@ -3,8 +3,32 @@ template:
3
3
  standard: "{% if creatornames %}{{ creatornames }} ({{role}}){%else%}{{ publisher_abbrev}}{%endif%} : {{standardidentifier|first}} {{draft}} , <em>{{ title }}</em>. {{ publisher }}{%if place%},{%endif%} {{ place }} ({{date}}). {{uri}}."
4
4
  misc: standard
5
5
  techreport: standard
6
+ book: "{{ creatornames }} ({{role}}) : <em>{{ title }}</em> . {{ publisher }}, {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%} ({{date}})."
7
+ booklet: book
8
+ manual: book
9
+ proceedings: book
10
+ software: book
11
+ electronic resource: book
12
+ website: book
13
+ webresource: book
14
+ unpublished: book
15
+ presentation: book
16
+ inbook: "{{ creatornames }} ({{role}}) : {{ title }} . {{ labels['in'] | capitalize }}: {{ host_creatornames}} ({{ host_role}}) : <em>{{host_title}}</em>. {{ extent}}. {{ publisher }}{%if place%},{%endif%} {{ place }} . ({{date}})."
17
+ inproceedings: inbook
18
+ incollection: inbook
19
+ journal: "<em>{{ title}}</em> . {{ publisher }}{%if place%},{%endif%} {{ place }} . ({{date}})."
20
+ article: "{{ creatornames }} ({{role}}) : {{ title }}. {{ series }} {{ extent }} ({{date}})."
6
21
  nametemplate:
7
- one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0]}}{% endif %}"
8
- two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0]}}{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1]}}{% endif %}"
9
- more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0]}} {% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1]}} {% endif %} , {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2]}} {{initials[2]}}{% endif %}"
22
+ one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0] | join: '' | remove: '.' | remove: '_' }}{% endif %}"
23
+ two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0] | join: '' | remove: '.' | remove: '_' }}{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1] | join: '' | remove: '.' | remove: '_' }}{% endif %}"
24
+ more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0] | join: '' | remove: '.' | remove: '_' }} {% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1] | join: '' | remove: '.' | remove: '_' }} {% endif %} , {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2]}} {{initials[2] | join: '' | remove: '.' | remove: '_'}}{% endif %}"
25
+ extenttemplate:
26
+ book: "{{ volume }}, {{ page }}"
27
+ booklet: book
28
+ proceedings: book
29
+ journal: book
30
+ standard: book
31
+ techreport: book
32
+ inbook: "{{ volume }}: {{ page }}"
33
+ misc: "{{ volume }} ({{issue}}) , {{ page }}, {{ duration }}"
10
34
 
@@ -37,4 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "sassc", "2.4.0"
38
38
  spec.add_development_dependency "simplecov", "~> 0.15"
39
39
  spec.add_development_dependency "timecop", "~> 0.9"
40
+ spec.add_development_dependency "vcr", "~> 6.1.0"
41
+ spec.add_development_dependency "webmock"
40
42
  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.2.0
4
+ version: 2.2.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-08-08 00:00:00.000000000 Z
11
+ date: 2022-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -178,6 +178,34 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.9'
181
+ - !ruby/object:Gem::Dependency
182
+ name: vcr
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 6.1.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 6.1.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: webmock
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
181
209
  description: 'Metanorma for the Open Geospatial Consortium.
182
210
 
183
211
  '
@@ -247,8 +275,6 @@ files:
247
275
  - lib/isodoc/ogc/ogc.white-paper.xsl
248
276
  - lib/isodoc/ogc/pdf_convert.rb
249
277
  - lib/isodoc/ogc/presentation_xml_convert.rb
250
- - lib/isodoc/ogc/reqt.rb
251
- - lib/isodoc/ogc/reqt_helper.rb
252
278
  - lib/isodoc/ogc/sections.rb
253
279
  - lib/isodoc/ogc/word_convert.rb
254
280
  - lib/isodoc/ogc/xref.rb
@@ -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