metanorma-iso 2.9.6 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,9 @@ module IsoDoc
9
9
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
10
10
  def concept(docxml)
11
11
  concept_term(docxml)
12
- docxml.xpath(ns("//concept")).each do |node|
13
- node.ancestors("definition, termsource, related").empty? and
12
+ (docxml.xpath(ns("//concept")) - docxml.xpath(ns("//term//concept")))
13
+ .each do |node|
14
+ node.ancestors("definition, termsource, related").empty? and
14
15
  concept_render(node, ital: "false", ref: "false",
15
16
  linkref: "true", linkmention: "false")
16
17
  end
@@ -207,22 +207,40 @@ module IsoDoc
207
207
  def table1(elem)
208
208
  table1_key(elem)
209
209
  if elem["class"] == "modspec"
210
- n = elem.at(ns(".//fmt-name")).remove
211
- n.name = "name"
210
+ if n = elem.at(ns(".//fmt-name"))
211
+ n.remove.name = "name"
212
212
  elem.add_first_child(n)
213
+ end
213
214
  elem.at(ns("./thead"))&.remove
214
215
  super
215
- elem.at(ns("./name")).remove
216
+ elem.at(ns("./name"))&.remove
217
+ table1_fmt_xref_modspec(elem)
216
218
  else super
217
219
  end
218
220
  end
219
221
 
222
+ def table1_fmt_xref_modspec(elem)
223
+ p = elem.parent.parent.at(ns("./fmt-xref-label"))
224
+ t = elem.at(ns("./fmt-xref-label"))&.remove or return
225
+ n = t.at(ns("./span[@class='fmt-element-name'][2]")) or return
226
+ while i = n.next
227
+ i.remove
228
+ end
229
+ n.remove
230
+ p.children.first.previous = to_xml(t.children)
231
+ end
232
+
220
233
  def table1_key(elem)
221
234
  elem.xpath(ns(".//dl[@key = 'true'][not(./name)]")).each do |dl|
222
235
  dl.add_first_child "<name>#{@i18n.key}</name>"
223
236
  end
224
237
  end
225
238
 
239
+ def labelled_ancestor(elem, exceptions = [])
240
+ elem["class"] == "modspec" and return false
241
+ super
242
+ end
243
+
226
244
  def toc_title(docxml)
227
245
  %w(amendment technical-corrigendum).include?(@doctype) and return
228
246
  super
@@ -197,15 +197,16 @@ module IsoDoc
197
197
  end
198
198
 
199
199
  def modspec_table_components_xrefs(table, table_label, container: false)
200
- table.xpath(ns(".//tr[@id]")).each do |tr|
200
+ table.xpath(ns(".//tr[@id] | .//td[@id] | .//bookmark[@id]")).each do |tr|
201
201
  xref_to_modspec(tr["id"], table_label) or next
202
202
  container or @anchors[tr["id"]].delete(:container)
203
203
  end
204
204
  end
205
205
 
206
206
  def xref_to_modspec(id, table_label)
207
- (@anchors[id] && !@anchors[id][:has_modspec]) or return
208
- @anchors[id][:has_modspec] = true
207
+ #(@anchors[id] && !@anchors[id][:has_modspec]) or return
208
+ (@anchors[id] && !@anchors[id][:has_table_prefix]) or return
209
+ @anchors[id][:has_table_prefix] = true
209
210
  x = @anchors_previous[id][:xref_bare] || @anchors_previous[id][:xref]
210
211
  # @anchors[id][:xref] = l10n("#{table_label}<span class='fmt-comma'>,</span> #{x}")
211
212
 
@@ -217,6 +218,17 @@ module IsoDoc
217
218
  true
218
219
  end
219
220
 
221
+ def bookmark_anchor_names(xml)
222
+ xml.xpath(ns(".//bookmark")).noblank.each do |n|
223
+ @anchors.dig(n["id"], :has_table_prefix) and next
224
+ _parent, id = id_ancestor(n)
225
+ # container = bookmark_container(parent)
226
+ @anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
227
+ xref: @anchors.dig(id, :xref) || "???",
228
+ container: @anchors.dig(id, :container) }
229
+ end
230
+ end
231
+
220
232
  def hierarchical_table_names(clause, _num)
221
233
  super
222
234
  modspec_table_xrefs(clause) if @anchors_previous
@@ -235,6 +247,12 @@ module IsoDoc
235
247
  { unnum: false, container: true })
236
248
  end
237
249
  end
250
+
251
+ # KILL
252
+ def sequential_permission_childrenx(elem, lbl, klass, container: false)
253
+ container = true
254
+ super
255
+ end
238
256
  end
239
257
  end
240
258
  end
@@ -947,6 +947,8 @@ May be electronic (e.g. Twitter direct message, email) or voice (e.g. a remark m
947
947
  typically cited as "personal communication")</a:documentation>
948
948
  <value>conversation</value>
949
949
  <a:documentation>An exchange of messages between two or more persons. May be electronic (e.g. web chat) or voice (e.g. phone call)</a:documentation>
950
+ <value>collection</value>
951
+ <a:documentation>A compound resource consisting of other resources, which are themselves presupposed to have their type specified..</a:documentation>
950
952
  <value>misc</value>
951
953
  <a:documentation>Bibliographic type not adequately described in the foregoing</a:documentation>
952
954
  </choice>
@@ -187,9 +187,10 @@ module Metanorma
187
187
 
188
188
  def iso_id_default(params)
189
189
  params_nolang = params.dup.tap { |hs| hs.delete(:language) }
190
- params1 = if params[:unpublished]
191
- params_nolang.dup.tap { |hs| hs.delete(:year) }
192
- else params_nolang end
190
+ #params1 = if params[:unpublished]
191
+ #params_nolang.dup.tap { |hs| hs.delete(:year) }
192
+ #else params_nolang end
193
+ params1 = params_nolang
193
194
  params1.delete(:unpublished)
194
195
  pubid_select(params1).create(**params1)
195
196
  end
@@ -204,9 +205,10 @@ module Metanorma
204
205
  end
205
206
 
206
207
  def iso_id_with_lang(params)
207
- params1 = if params[:unpublished]
208
- params.dup.tap { |hs| hs.delete(:year) }
209
- else params end
208
+ #params1 = if params[:unpublished]
209
+ #params.dup.tap { |hs| hs.delete(:year) }
210
+ #else params end
211
+ params1 = params
210
212
  params1.delete(:unpublished)
211
213
  pubid_select(params1).create(**params1)
212
214
  end
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.4.1 -->
20
+ <!-- VERSION v2.0.0 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -459,11 +459,14 @@ gives an explicit page orientation</a:documentation>
459
459
  <a:documentation>Description of location in a reference, which can be combined with other locations in a single citation</a:documentation>
460
460
  </ref>
461
461
  </zeroOrMore>
462
- <zeroOrMore>
463
- <ref name="PureTextElement">
462
+ <optional>
463
+ <element name="display-text">
464
464
  <a:documentation>The textual content of the element. The `text` is what we wish to show the link as (e.g., the "content" of `&lt;xx&gt;my link text&lt;/xx&gt;`)</a:documentation>
465
- </ref>
466
- </zeroOrMore>
465
+ <oneOrMore>
466
+ <ref name="PureTextElement"/>
467
+ </oneOrMore>
468
+ </element>
469
+ </optional>
467
470
  </define>
468
471
  </include>
469
472
  <!-- end overrides -->
@@ -1205,10 +1208,13 @@ numbers</a:documentation>
1205
1208
  <value>presentation</value>
1206
1209
  </choice>
1207
1210
  </attribute>
1211
+ <attribute name="flavor">
1212
+ <a:documentation>Metanorma flavor, indicating SDO whose requiremnts the realisation aligns to</a:documentation>
1213
+ </attribute>
1208
1214
  </define>
1209
1215
  <define name="standard-document">
1210
1216
  <a:documentation>Representation of a standardisation document</a:documentation>
1211
- <element name="standard-document">
1217
+ <element name="metanorma">
1212
1218
  <ref name="Root-Attributes"/>
1213
1219
  <ref name="bibdata">
1214
1220
  <a:documentation>Bibliographic description of the document itself, expressed in the Relaton model</a:documentation>
@@ -1,14 +1,11 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns="https://www.metanorma.org/ns/iso" xmlns="http://relaxng.org/ns/structure/1.0">
2
+ <grammar ns="https://www.metanorma.org/ns/standoc" xmlns="http://relaxng.org/ns/structure/1.0">
3
3
  <!--
4
4
  VERSION v1.2.1
5
5
  default namespace isostandard = "https://www.metanorma.com/ns/iso"
6
6
  -->
7
7
  <include href="relaton-iso.rng"/>
8
8
  <include href="isostandard.rng">
9
- <start>
10
- <ref name="iso-standard"/>
11
- </start>
12
9
  <define name="sections">
13
10
  <element name="sections">
14
11
  <oneOrMore>
@@ -33,8 +30,8 @@
33
30
  <ref name="Clause-Section"/>
34
31
  </element>
35
32
  </define>
36
- <define name="iso-standard">
37
- <element name="iso-standard">
33
+ <define name="standard-document">
34
+ <element name="metanorma">
38
35
  <ref name="Root-Attributes"/>
39
36
  <ref name="bibdata"/>
40
37
  <optional>
@@ -1,6 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns="https://www.metanorma.org/ns/iso" xmlns="http://relaxng.org/ns/structure/1.0">
3
- <!-- default namespace isostandard = "https://www.metanorma.com/ns/iso" -->
2
+ <grammar ns="https://www.metanorma.org/ns/standoc" xmlns="http://relaxng.org/ns/structure/1.0">
4
3
  <include href="relaton-iso.rng"/>
5
4
  <include href="isostandard.rng"/>
6
5
  </grammar>
@@ -5,9 +5,6 @@
5
5
  default namespace isostandard = "https://www.metanorma.com/ns/iso"
6
6
  -->
7
7
  <include href="isodoc.rng">
8
- <start>
9
- <ref name="iso-standard"/>
10
- </start>
11
8
  <define name="sections">
12
9
  <element name="sections">
13
10
  <zeroOrMore>
@@ -238,38 +235,38 @@
238
235
  </oneOrMore>
239
236
  </choice>
240
237
  </define>
238
+ <!--
239
+ We display the Normative References between scope and terms; but to keep the
240
+ grammar simple, we keep the references together
241
+ -->
242
+ <define name="standard-document">
243
+ <element name="metanorma">
244
+ <ref name="Root-Attributes"/>
245
+ <ref name="bibdata"/>
246
+ <zeroOrMore>
247
+ <ref name="termdocsource"/>
248
+ </zeroOrMore>
249
+ <optional>
250
+ <ref name="misccontainer"/>
251
+ </optional>
252
+ <optional>
253
+ <ref name="boilerplate"/>
254
+ </optional>
255
+ <ref name="preface"/>
256
+ <oneOrMore>
257
+ <ref name="sections"/>
258
+ </oneOrMore>
259
+ <zeroOrMore>
260
+ <ref name="annex"/>
261
+ </zeroOrMore>
262
+ <ref name="bibliography"/>
263
+ <zeroOrMore>
264
+ <ref name="indexsect"/>
265
+ </zeroOrMore>
266
+ </element>
267
+ </define>
241
268
  </include>
242
269
  <!-- end overrides -->
243
- <!--
244
- We display the Normative References between scope and terms; but to keep the
245
- grammar simple, we keep the references together
246
- -->
247
- <define name="iso-standard">
248
- <element name="iso-standard">
249
- <ref name="Root-Attributes"/>
250
- <ref name="bibdata"/>
251
- <zeroOrMore>
252
- <ref name="termdocsource"/>
253
- </zeroOrMore>
254
- <optional>
255
- <ref name="misccontainer"/>
256
- </optional>
257
- <optional>
258
- <ref name="boilerplate"/>
259
- </optional>
260
- <ref name="preface"/>
261
- <oneOrMore>
262
- <ref name="sections"/>
263
- </oneOrMore>
264
- <zeroOrMore>
265
- <ref name="annex"/>
266
- </zeroOrMore>
267
- <ref name="bibliography"/>
268
- <zeroOrMore>
269
- <ref name="indexsect"/>
270
- </zeroOrMore>
271
- </element>
272
- </define>
273
270
  <define name="clause-hanging-paragraph-with-footnote">
274
271
  <element name="clause">
275
272
  <optional>
@@ -63,19 +63,13 @@
63
63
  </choice>
64
64
  </element>
65
65
  </define>
66
- <define name="OrganizationType" combine="interleave">
67
- <optional>
68
- <ref name="technical-committee"/>
69
- </optional>
70
- <optional>
71
- <ref name="subcommittee"/>
72
- </optional>
73
- <optional>
74
- <ref name="workgroup"/>
75
- </optional>
76
- <optional>
77
- <ref name="secretariat"/>
78
- </optional>
66
+ <define name="organization">
67
+ <element name="organization">
68
+ <choice>
69
+ <ref name="OrganizationType"/>
70
+ <ref name="IsoOrganizationType"/>
71
+ </choice>
72
+ </element>
79
73
  </define>
80
74
  <define name="DocumentType">
81
75
  <choice>
@@ -225,4 +219,18 @@
225
219
  <text/>
226
220
  </element>
227
221
  </define>
222
+ <define name="IsoOrganizationType">
223
+ <optional>
224
+ <ref name="technical-committee"/>
225
+ </optional>
226
+ <optional>
227
+ <ref name="subcommittee"/>
228
+ </optional>
229
+ <optional>
230
+ <ref name="workgroup"/>
231
+ </optional>
232
+ <optional>
233
+ <ref name="secretariat"/>
234
+ </optional>
235
+ </define>
228
236
  </grammar>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iso
3
- VERSION = "2.9.6".freeze
3
+ VERSION = "3.0.0".freeze
4
4
  end
5
5
  end
@@ -2,35 +2,19 @@ module Metanorma
2
2
  class Requirements
3
3
  class Modspec
4
4
  class Iso < ::Metanorma::Requirements::Modspec
5
- =begin
6
- def recommendation_label(elem, type, xrefs)
7
- lbl = super
8
- title = elem.at(ns("./title"))
9
- return lbl unless title &&
10
- elem.ancestors("requirement, recommendation, permission").empty?
11
-
12
- lbl += "<span class='fmt-caption-delim'>: </span>" if lbl
13
- lbl += "<semx element='title' source='#{elem['id']}'>#{title.children.to_xml}</semx>"
14
- require "debug"; binding.b
15
- l10n(lbl)
16
- end
17
-
18
- # ISO labels modspec reqt as table, with reqt label as title
19
- def recommendation_header(reqt, out)
20
- n = reqt.at(ns("./fmt-name")) and out << n
21
- out
22
- end
23
- =end
24
-
25
- def requirement_table_nested_cleanup(node, table)
26
- table["type"] == "recommendclass" or return table
27
- ins = table.at(ns("./tbody/tr[td/table]")) or return table
28
- ins.replace(requirement_table_cleanup_nested_replacement(node, table))
29
- table.xpath(ns("./tbody/tr[td/table]")).each(&:remove)
5
+ def requirement_table_nested_cleanup(node, out, table)
6
+ (out.xpath(ns(".//table")) - out.xpath(ns("./fmt-provision/table"))).each do |x|
7
+ x["unnumbered"] = "true"
8
+ end
9
+ table["type"] == "recommendclass" or return super # table
10
+ ins = table.at(ns("./tbody/tr[td/*/fmt-provision/table]")) or return table
11
+ ins.replace(requirement_table_cleanup_nested_replacement(node, out, table))
12
+ table.xpath(ns("./tbody/tr[td/*/fmt-provision/table]")).each(&:remove)
13
+ out.xpath(ns("./*/fmt-provision")).each(&:remove)
30
14
  table
31
15
  end
32
16
 
33
- def requirement_table_cleanup_nested_replacement(node, table)
17
+ def requirement_table_cleanup_nested_replacement(node, out, table)
34
18
  label = "provision"
35
19
  node["type"] == "conformanceclass" and label = "conformancetest"
36
20
  n = nested_tables_names(table)
@@ -40,14 +24,18 @@ module Metanorma
40
24
  end
41
25
 
42
26
  def nested_tables_names(table)
43
- table.xpath(ns("./tbody/tr/td/table"))
27
+ table.xpath(ns("./tbody/tr/td/*/fmt-provision/table"))
44
28
  .each_with_object([]) do |t, m|
45
- m << t.at(ns(".//fmt-name")).children.to_xml
29
+ id = t["original-id"] || t["id"]
30
+ id and b = "<bookmark id='#{id}'/>"
31
+ m << b + to_xml(t.at(ns(".//fmt-name")).children).strip
46
32
  end
47
33
  end
48
34
 
49
35
  def postprocess_anchor_struct(block, anchor)
50
36
  super
37
+ t = block.at(ns("./fmt-provision/table")) and
38
+ anchor[:container] = t["id"]
51
39
  anchor[:modspec] = anchor[:xref_bare]
52
40
  if l = block.at(ns("./title"))
53
41
  anchor[:modspec] =
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
33
33
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
34
34
 
35
- spec.add_dependency "metanorma-standoc", "~> 2.10.2"
35
+ spec.add_dependency "metanorma-standoc", "~> 3.0.0"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
37
  spec.add_dependency "pubid"
38
38
  spec.add_dependency "tokenizer", "~> 0.3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.6
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-03 00:00:00.000000000 Z
11
+ date: 2025-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.10.2
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.10.2
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement