metanorma-ogc 2.0.2 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/ogc/base_convert.rb +8 -6
  3. data/lib/isodoc/ogc/html/ogc.css +1 -2
  4. data/lib/isodoc/ogc/html/ogc.scss +0 -1
  5. data/lib/isodoc/ogc/html/ogc_wp.css +1 -2
  6. data/lib/isodoc/ogc/html/ogc_wp.scss +0 -1
  7. data/lib/isodoc/ogc/html_convert.rb +6 -6
  8. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +1258 -513
  9. data/lib/isodoc/ogc/ogc.best-practice.xsl +1258 -513
  10. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +1258 -513
  11. data/lib/isodoc/ogc/ogc.community-practice.xsl +1258 -513
  12. data/lib/isodoc/ogc/ogc.community-standard.xsl +1258 -513
  13. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +1258 -513
  14. data/lib/isodoc/ogc/ogc.engineering-report.xsl +1258 -513
  15. data/lib/isodoc/ogc/ogc.other.xsl +1258 -513
  16. data/lib/isodoc/ogc/ogc.policy.xsl +1258 -513
  17. data/lib/isodoc/ogc/ogc.reference-model.xsl +1258 -513
  18. data/lib/isodoc/ogc/ogc.release-notes.xsl +1258 -513
  19. data/lib/isodoc/ogc/ogc.standard.xsl +1258 -513
  20. data/lib/isodoc/ogc/ogc.test-suite.xsl +1258 -513
  21. data/lib/isodoc/ogc/ogc.user-guide.xsl +1258 -513
  22. data/lib/isodoc/ogc/ogc.white-paper.xsl +1120 -397
  23. data/lib/isodoc/ogc/presentation_xml_convert.rb +25 -34
  24. data/lib/isodoc/ogc/reqt.rb +2 -1
  25. data/lib/isodoc/ogc/word_convert.rb +2 -78
  26. data/lib/isodoc/ogc/xref.rb +13 -6
  27. data/lib/metanorma/ogc/basicdoc.rng +5 -3
  28. data/lib/metanorma/ogc/biblio.rng +5 -3
  29. data/lib/metanorma/ogc/converter.rb +7 -0
  30. data/lib/metanorma/ogc/isodoc.rng +73 -3
  31. data/lib/metanorma/ogc/processor.rb +10 -10
  32. data/lib/metanorma/ogc/version.rb +1 -1
  33. metadata +2 -2
@@ -12,11 +12,16 @@ module IsoDoc
12
12
  super
13
13
  end
14
14
 
15
- def insert_preface_sections(docxml)
16
- insert_executivesummary(docxml)
17
- insert_submitting_orgs(docxml)
18
- insert_security(docxml)
19
- insert_keywords(docxml)
15
+ def insert_preface_sections(doc)
16
+ preface_insert(doc&.at(ns("//preface/clause"\
17
+ "[@type = 'executivesummary']")),
18
+ doc.at(ns("//preface/abstract")), doc)
19
+ preface_insert(doc&.at(ns("//preface//submitters")),
20
+ submit_orgs_append_pt(doc), doc)
21
+ insert_submitting_orgs(doc)
22
+ preface_insert(doc&.at(ns("//preface/clause[@type = 'security']")),
23
+ submit_orgs_append_pt(doc), doc)
24
+ insert_keywords(doc)
20
25
  end
21
26
 
22
27
  def preface_init_insert_pt(docxml)
@@ -25,31 +30,22 @@ module IsoDoc
25
30
  .add_previous_sibling("<preface> </preface>").first
26
31
  end
27
32
 
28
- def submit_orgs_append_pt(docxml)
29
- docxml.at(ns("//introduction")) ||
30
- docxml.at(ns("//foreword")) ||
31
- docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
32
- docxml.at(ns("//preface/abstract"))
33
- end
33
+ def preface_insert(clause, after, docxml)
34
+ return unless clause
34
35
 
35
- def insert_security(docxml)
36
- s = docxml&.at(ns("//preface/clause[@type = 'security']"))&.remove or
37
- return
38
- if a = submit_orgs_append_pt(docxml) then a.next = s
36
+ clause.remove
37
+ if after then after.next = clause
39
38
  else
40
39
  preface_init_insert_pt(docxml)&.children&.first
41
- &.add_previous_sibling(s)
40
+ &.add_previous_sibling(clause)
42
41
  end
43
42
  end
44
43
 
45
- def insert_executivesummary(docxml)
46
- s = docxml&.at(ns("//preface/clause[@type = 'executivesummary']"))
47
- &.remove or return
48
- if a = docxml.at(ns("//preface/abstract")) then a.next = s
49
- else
50
- preface_init_insert_pt(docxml)&.children&.first
51
- &.add_previous_sibling(s)
52
- end
44
+ def submit_orgs_append_pt(docxml)
45
+ docxml.at(ns("//foreword")) ||
46
+ docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
47
+ docxml.at(ns("//preface/clause[@type = 'executivesummary']")) ||
48
+ docxml.at(ns("//preface/abstract"))
53
49
  end
54
50
 
55
51
  def insert_submitting_orgs(docxml)
@@ -166,7 +162,6 @@ module IsoDoc
166
162
  def block(docxml)
167
163
  super
168
164
  recommendation_to_table(docxml)
169
- ol docxml
170
165
  end
171
166
 
172
167
  def section(docxml)
@@ -213,16 +208,12 @@ module IsoDoc
213
208
  doctype.children = "technical-paper"
214
209
  end
215
210
 
216
- def ol(docxml)
217
- docxml.xpath(ns("//ol")).each { |f| ol1(f) }
218
- end
219
-
220
- def ol1(elem)
221
- return unless elem["class"] == "steps"
211
+ def ol_depth(node)
212
+ return super unless node["class"] == "steps" ||
213
+ node.at(".//ancestor::xmlns:ol[@class = 'steps']")
222
214
 
223
- idx = elem.xpath("./ancestor-or-self::xmlns:ol[@class = 'steps']").size
224
- elem["type"] = %w(arabic alphabet roman alphabet_upper
225
- roman_upper)[(idx - 1) % 5]
215
+ idx = node.xpath("./ancestor-or-self::xmlns:ol[@class = 'steps']").size
216
+ %i(arabic alphabet roman alphabet_upper roman_upper)[(idx - 1) % 5]
226
217
  end
227
218
 
228
219
  def termsource1(elem)
@@ -48,6 +48,7 @@ module IsoDoc
48
48
  label.xpath(ns(".//concept")).each { |f| concept1(f) }
49
49
  b = out.add_child("<tr><td colspan='2'><p></p></td></tr>")
50
50
  p = b.at(ns(".//p"))
51
+ p["class"] = "RecommendationLabel"
51
52
  p << label.children.to_xml
52
53
  end
53
54
 
@@ -103,7 +104,7 @@ module IsoDoc
103
104
  def recommendation_attr_keyvalue(node, key, value)
104
105
  tag = node&.at(ns("./#{key}"))&.remove
105
106
  value = node.at(ns("./#{value}"))&.remove
106
- tag && value or return nil
107
+ (tag && value) or return nil
107
108
  node.remove
108
109
  [tag.text.capitalize, value.children]
109
110
  end
@@ -64,87 +64,11 @@ module IsoDoc
64
64
  end
65
65
  end
66
66
 
67
- def insert_toc(intro, docxml, level)
68
- toc = ""
69
- toc += make_WordToC(docxml, level)
70
- if docxml.at("//p[@class = 'TableTitle']")
71
- toc += %{<p class="TOCTitle">List of Tables</p>}
72
- toc += make_TableWordToC(docxml)
73
- end
74
- if docxml.at("//p[@class = 'FigureTitle']")
75
- toc += %{<p class="TOCTitle">List of Figures</p>}
76
- toc += make_FigureWordToC(docxml)
77
- end
78
- if docxml.at("//p[@class = 'RecommendationTitle']")
79
- toc += %{<p class="TOCTitle">List of Recommendations</p>}
80
- toc += make_RecommendationWordToC(docxml)
81
- end
82
- intro.sub(/WORDTOC/, toc)
83
- end
84
-
85
- WORD_TOC_RECOMMENDATION_PREFACE1 = <<~TOC.freeze
86
- <span lang="EN-GB"><span
87
- style='mso-element:field-begin'></span><span
88
- style='mso-spacerun:yes'>&#xA0;</span>TOC
89
- \\h \\z \\t &quot;RecommendationTitle,RecommendationTestTitle,recommendationtitle,recommendationtesttitle&quot;#{' '}
90
- <span style='mso-element:field-separator'></span></span>
91
- TOC
92
-
93
- WORD_TOC_TABLE_PREFACE1 = <<~TOC.freeze
94
- <span lang="EN-GB"><span
95
- style='mso-element:field-begin'></span><span
96
- style='mso-spacerun:yes'>&#xA0;</span>TOC
97
- \\h \\z \\t &quot;TableTitle,tabletitle&quot; <span
98
- style='mso-element:field-separator'></span></span>
99
- TOC
100
-
101
- WORD_TOC_FIGURE_PREFACE1 = <<~TOC.freeze
102
- <span lang="EN-GB"><span
103
- style='mso-element:field-begin'></span><span
104
- style='mso-spacerun:yes'>&#xA0;</span>TOC
105
- \\h \\z \\t &quot;FigureTitle,figuretitle&quot; <span
106
- style='mso-element:field-separator'></span></span>
107
- TOC
108
-
109
- def header_strip(h)
110
- h = h.to_s.gsub(/<\/?p[^>]*>/, "")
67
+ def header_strip(hdr)
68
+ hdr = hdr.to_s.gsub(/<\/?p[^>]*>/, "")
111
69
  super
112
70
  end
113
71
 
114
- def make_TableWordToC(docxml)
115
- toc = ""
116
- docxml.xpath("//p[@class = 'TableTitle']").each do |h|
117
- toc += word_toc_entry(1, header_strip(h))
118
- end
119
- toc.sub(/(<p class="MsoToc1">)/,
120
- %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
121
- end
122
-
123
- def make_FigureWordToC(docxml)
124
- toc = ""
125
- docxml.xpath("//p[@class = 'FigureTitle']").each do |h|
126
- toc += word_toc_entry(1, header_strip(h))
127
- end
128
- toc.sub(/(<p class="MsoToc1">)/,
129
- %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
130
- end
131
-
132
- def make_RecommendationWordToC(docxml)
133
- toc = ""
134
- docxml.xpath("//p[@class = 'RecommendationTitle' or @class = 'RecommendationTestTitle']").sort_by do |h|
135
- recommmendation_sort_key(h.text)
136
- end.each do |h|
137
- toc += word_toc_entry(1, header_strip(h))
138
- end
139
- toc.sub(/(<p class="MsoToc1">)/,
140
- %{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
141
- end
142
-
143
- def recommmendation_sort_key(header)
144
- m = /^([^0-9]+) (\d+)/.match(header) || /^([^:]+)/.match(header)
145
- "#{recommmendation_sort_key1(m[1])}::#{'%04d' % m[2].to_i}"
146
- end
147
-
148
72
  def recommmendation_sort_key1(type)
149
73
  case type.downcase
150
74
  when "requirements class" then "01"
@@ -23,7 +23,7 @@ module IsoDoc
23
23
  id = c.increment(t).print
24
24
  @anchors[t["id"]] = anchor_struct(id, t, label, klass,
25
25
  t["unnumbered"])
26
- l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
26
+ reqt_suffix_label(t)
27
27
  permission_parts(t, label, klass)
28
28
  sequential_permission_children(t, id)
29
29
  end
@@ -41,6 +41,13 @@ module IsoDoc
41
41
  "conformanceclass" => "@type = 'conformanceclass'" }
42
42
  end
43
43
 
44
+ def reqt_suffix_label(reqt)
45
+ if l = reqt.at(ns("./label"))&.text
46
+ @reqtlabels[l] = reqt["id"]
47
+ @anchors[reqt["id"]][:xref] += ": <tt>#{l}</tt>"
48
+ end
49
+ end
50
+
44
51
  def permission_parts(block, label, klass)
45
52
  block.xpath(ns("./component[@class = 'part']"))
46
53
  .each_with_index do |c, i|
@@ -116,7 +123,7 @@ module IsoDoc
116
123
  lbl = "#{num}#{hiersep}#{c.increment(t).print}"
117
124
  @anchors[t["id"]] = anchor_struct(lbl, t, label, klass,
118
125
  t["unnumbered"])
119
- l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
126
+ reqt_suffix_label(t)
120
127
  permission_parts(t, label, klass)
121
128
  sequential_permission_children(t, lbl)
122
129
  end
@@ -143,9 +150,9 @@ module IsoDoc
143
150
  @prefacenum = 0
144
151
  ["//preface/abstract", "//preface/clause[@type = 'executivesummary']",
145
152
  "//preface/clause[@type = 'keywords']",
146
- "//foreword", "//introduction", "//preface/clause[@type = 'security']",
147
- "//preface/clause[@type = 'submitting_orgs']",
148
- "//submitters"].each do |path|
153
+ "//foreword", "//preface/clause[@type = 'security']",
154
+ "//preface/clause[@type = 'submitting_orgs']", "//submitters",
155
+ "//introduction"].each do |path|
149
156
  preface_names_numbered(doc.at(ns(path)))
150
157
  end
151
158
  doc.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
@@ -185,7 +192,7 @@ module IsoDoc
185
192
  def preface_names_numbered1(clause, num, level)
186
193
  @anchors[clause["id"]] =
187
194
  { label: num, level: level, xref: l10n("#{@labels['clause']} #{num}"),
188
- type: "clause" }
195
+ type: "clause", elem: @labels["clause"] }
189
196
  clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
190
197
  lbl = "#{num}.#{preface_number(i + 1, level + 1)}"
191
198
  preface_names_numbered1(c, lbl, level + 1)
@@ -173,9 +173,11 @@
173
173
  <data type="dateTime"/>
174
174
  </attribute>
175
175
  </optional>
176
- <attribute name="from">
177
- <data type="IDREF"/>
178
- </attribute>
176
+ <optional>
177
+ <attribute name="from">
178
+ <data type="IDREF"/>
179
+ </attribute>
180
+ </optional>
179
181
  <optional>
180
182
  <attribute name="to">
181
183
  <data type="IDREF"/>
@@ -209,9 +209,6 @@
209
209
  <zeroOrMore>
210
210
  <ref name="contact"/>
211
211
  </zeroOrMore>
212
- <zeroOrMore>
213
- <ref name="uri"/>
214
- </zeroOrMore>
215
212
  </element>
216
213
  </define>
217
214
  <define name="fullname">
@@ -828,6 +825,11 @@
828
825
  <optional>
829
826
  <attribute name="scope"/>
830
827
  </optional>
828
+ <optional>
829
+ <attribute name="primary">
830
+ <data type="boolean"/>
831
+ </attribute>
832
+ </optional>
831
833
  <text/>
832
834
  </element>
833
835
  </define>
@@ -16,6 +16,13 @@ module Metanorma
16
16
 
17
17
  register_for "ogc"
18
18
 
19
+ def init_toc(node)
20
+ super
21
+ @tocfigures = true
22
+ @toctables = true
23
+ @tocrecommendations = true
24
+ end
25
+
19
26
  # ignore, we generate ToC outside of asciidoctor
20
27
  def toc(value); end
21
28
 
@@ -152,9 +152,7 @@
152
152
  <data type="boolean"/>
153
153
  </attribute>
154
154
  </optional>
155
- <oneOrMore>
156
- <ref name="PureTextElement"/>
157
- </oneOrMore>
155
+ <ref name="XrefBody"/>
158
156
  </element>
159
157
  </define>
160
158
  <define name="erefType">
@@ -188,6 +186,42 @@
188
186
  <ref name="PureTextElement"/>
189
187
  </oneOrMore>
190
188
  </define>
189
+ <define name="localityStack">
190
+ <element name="localityStack">
191
+ <optional>
192
+ <attribute name="connective">
193
+ <choice>
194
+ <value>and</value>
195
+ <value>or</value>
196
+ <value>from</value>
197
+ <value>to</value>
198
+ <value/>
199
+ </choice>
200
+ </attribute>
201
+ </optional>
202
+ <zeroOrMore>
203
+ <ref name="locality"/>
204
+ </zeroOrMore>
205
+ </element>
206
+ </define>
207
+ <define name="sourceLocalityStack">
208
+ <element name="sourceLocalityStack">
209
+ <optional>
210
+ <attribute name="connective">
211
+ <choice>
212
+ <value>and</value>
213
+ <value>or</value>
214
+ <value>from</value>
215
+ <value>to</value>
216
+ <value/>
217
+ </choice>
218
+ </attribute>
219
+ </optional>
220
+ <zeroOrMore>
221
+ <ref name="sourceLocality"/>
222
+ </zeroOrMore>
223
+ </element>
224
+ </define>
191
225
  <define name="ul">
192
226
  <element name="ul">
193
227
  <attribute name="id">
@@ -1098,6 +1132,16 @@
1098
1132
  </define>
1099
1133
  </include>
1100
1134
  <!-- end overrides -->
1135
+ <define name="image" combine="choice">
1136
+ <element name="svg">
1137
+ <oneOrMore>
1138
+ <choice>
1139
+ <text/>
1140
+ <ref name="AnyElement"/>
1141
+ </choice>
1142
+ </oneOrMore>
1143
+ </element>
1144
+ </define>
1101
1145
  <define name="MultilingualRenderingType">
1102
1146
  <choice>
1103
1147
  <value>common</value>
@@ -2631,4 +2675,30 @@
2631
2675
  </zeroOrMore>
2632
2676
  </element>
2633
2677
  </define>
2678
+ <define name="XrefBody">
2679
+ <zeroOrMore>
2680
+ <ref name="XrefTarget"/>
2681
+ </zeroOrMore>
2682
+ <oneOrMore>
2683
+ <ref name="PureTextElement"/>
2684
+ </oneOrMore>
2685
+ </define>
2686
+ <define name="XrefTarget">
2687
+ <element name="location">
2688
+ <attribute name="target">
2689
+ <data type="string">
2690
+ <param name="pattern">\i\c*|\c+#\c+</param>
2691
+ </data>
2692
+ </attribute>
2693
+ <attribute name="connective">
2694
+ <choice>
2695
+ <value>and</value>
2696
+ <value>or</value>
2697
+ <value>from</value>
2698
+ <value>to</value>
2699
+ <value/>
2700
+ </choice>
2701
+ </attribute>
2702
+ </element>
2703
+ </define>
2634
2704
  </grammar>
@@ -4,7 +4,7 @@ module Metanorma
4
4
  module Ogc
5
5
  class Processor < Metanorma::Processor
6
6
 
7
- def initialize
7
+ def initialize # rubocop:disable Lint/MissingSuper
8
8
  @short = :ogc
9
9
  @input_format = :asciidoc
10
10
  @asciidoctor_backend = :ogc
@@ -14,7 +14,7 @@ module Metanorma
14
14
  super.merge(
15
15
  html: "html",
16
16
  doc: "doc",
17
- pdf: "pdf"
17
+ pdf: "pdf",
18
18
  )
19
19
  end
20
20
 
@@ -41,14 +41,14 @@ module Metanorma
41
41
 
42
42
  def output(isodoc_node, inname, outname, format, options={})
43
43
  case format
44
- when :html
45
- IsoDoc::Ogc::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
46
- when :doc
47
- IsoDoc::Ogc::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
48
- when :pdf
49
- IsoDoc::Ogc::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
50
- when :presentation
51
- IsoDoc::Ogc::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
44
+ when :html then IsoDoc::Ogc::HtmlConvert.new(options)
45
+ .convert(inname, isodoc_node, nil, outname)
46
+ when :doc then IsoDoc::Ogc::WordConvert.new(options)
47
+ .convert(inname, isodoc_node, nil, outname)
48
+ when :pdf then IsoDoc::Ogc::PdfConvert.new(options)
49
+ .convert(inname, isodoc_node, nil, outname)
50
+ when :presentation then IsoDoc::Ogc::PresentationXMLConvert.new(options)
51
+ .convert(inname, isodoc_node, nil, outname)
52
52
  else
53
53
  super
54
54
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "2.0.2".freeze
3
+ VERSION = "2.0.5".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.2
4
+ version: 2.0.5
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-22 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639