metanorma-iso 3.1.1 → 3.1.2

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.
@@ -23,7 +23,7 @@ module IsoDoc
23
23
 
24
24
  def docstatus(isoxml, _out)
25
25
  docstatus = isoxml.at(ns("//bibdata/status/stage"))
26
- set(:unpublished, false)
26
+ published_default(isoxml)
27
27
  revdate = isoxml.at(ns("//bibdata/version/revision-date"))
28
28
  set(:revdate, revdate&.text)
29
29
  docstatus and docstatus1(isoxml, docstatus)
@@ -73,7 +73,7 @@ module IsoDoc
73
73
 
74
74
  def part_title(part, titlenums, lang)
75
75
  part or return ""
76
- suffix = part.children.to_xml
76
+ suffix = to_xml(part.children)
77
77
  p = titlenums[:part]
78
78
  titlenums[:part] && titlenums[:subpart] and
79
79
  p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
@@ -102,11 +102,11 @@ module IsoDoc
102
102
  end
103
103
 
104
104
  def compose_title(tparts, tnums, lang)
105
- t = tparts[:main].nil? ? "" : tparts[:main].children.to_xml
105
+ t = tparts[:main].nil? ? "" : to_xml(tparts[:main].children)
106
106
  tparts[:intro] and
107
- t = "#{tparts[:intro].children.to_xml} — #{t}"
107
+ t = "#{to_xml(tparts[:intro].children)} — #{t}"
108
108
  tparts[:complementary] and
109
- t = "#{t} — #{tparts[:complementary].children.to_xml}"
109
+ t = "#{t} — #{to_xml(tparts[:complementary].children)}"
110
110
  if tparts[:part]
111
111
  suffix = part_title(tparts[:part], tnums, lang)
112
112
  t = "#{t} — #{suffix}"
@@ -138,19 +138,19 @@ module IsoDoc
138
138
  # intro, main, complementary, part, amd = title_parts(isoxml, lang)
139
139
  tp = title_parts(isoxml, lang)
140
140
  tn = title_nums(isoxml)
141
- set(:doctitlemain, tp[:main] ? tp[:main].children.to_xml : "")
141
+ set(:doctitlemain, tp[:main] ? to_xml(tp[:main].children) : "")
142
142
  main = compose_title(tp, tn, lang)
143
143
  set(:doctitle, main)
144
- tp[:intro] and set(:doctitleintro, tp[:intro].children.to_xml)
144
+ tp[:intro] and set(:doctitleintro, to_xml(tp[:intro].children))
145
145
  tp[:complementary] and
146
- set(:doctitlecomplementary, tp[:complementary].children.to_xml)
146
+ set(:doctitlecomplementary, to_xml(tp[:complementary].children))
147
147
  set(:doctitlepartlabel, part_prefix(tn, lang))
148
- set(:doctitlepart, tp[:part].children.to_xml) if tp[:part]
148
+ set(:doctitlepart, to_xml(tp[:part].children)) if tp[:part]
149
149
  set(:doctitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
150
- set(:doctitleamd, tp[:amd].children.to_xml) if tp[:amd]
150
+ set(:doctitleamd, to_xml(tp[:amd].children)) if tp[:amd]
151
151
  set(:doctitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
152
152
  set(:doctitleaddlabel, add_prefix(tn, lang)) if tn[:add]
153
- set(:doctitleadd, tp[:add].children.to_xml) if tp[:add]
153
+ set(:doctitleadd, to_xml(tp[:add].children)) if tp[:add]
154
154
  end
155
155
 
156
156
  def subtitle(isoxml, _out)
@@ -158,18 +158,18 @@ module IsoDoc
158
158
  tp = title_parts(isoxml, lang)
159
159
  tn = title_nums(isoxml)
160
160
 
161
- set(:docsubtitlemain, tp[:main] ? tp[:main].children.to_xml : "")
161
+ set(:docsubtitlemain, tp[:main] ? to_xml(tp[:main].children) : "")
162
162
  main = compose_title(tp, tn, lang)
163
163
  set(:docsubtitle, main)
164
- tp[:intro] and set(:docsubtitleintro, tp[:intro].children.to_xml)
164
+ tp[:intro] and set(:docsubtitleintro, to_xml(tp[:intro].children))
165
165
  tp[:complementary] and
166
- set(:docsubtitlecomplementary, tp[:complementary].children.to_xml)
166
+ set(:docsubtitlecomplementary, to_xml(tp[:complementary].children))
167
167
  set(:docsubtitlepartlabel, part_prefix(tn, lang))
168
- tp[:part] and set(:docsubtitlepart, tp[:part].children.to_xml)
168
+ tp[:part] and set(:docsubtitlepart, to_xml(tp[:part].children))
169
169
  set(:docsubtitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
170
- set(:docsubtitleamd, tp[:amd].children.to_xml) if tp[:amd]
170
+ set(:docsubtitleamd, to_xml(tp[:amd].children)) if tp[:amd]
171
171
  set(:docsubtitleaddlabel, add_prefix(tn, lang)) if tn[:add]
172
- set(:docsubtitleadd, tp[:add].children.to_xml) if tp[:add]
172
+ set(:docsubtitleadd, to_xml(tp[:add].children)) if tp[:add]
173
173
  set(:docsubtitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
174
174
  end
175
175
 
@@ -225,10 +225,17 @@ module IsoDoc
225
225
  end
226
226
 
227
227
  def editorialgroup(xml)
228
- a = xml.at(ns("//bibdata/ext/editorialgroup/@identifier")) and
229
- set(:editorialgroup, a.text)
230
- a = xml.at(ns("//bibdata/ext/approvalgroup/@identifier")) and
231
- set(:approvalgroup, a.text)
228
+ xpath = <<~XPATH
229
+ //contributor[role/@type = 'author'][role/description = 'Technical committee']/organization/subdivision/identifier[@type = 'full']
230
+ XPATH
231
+ a = xml.xpath(ns(xpath))
232
+ a.empty? or set(:editorialgroup,
233
+ connectives_strip(@i18n.boolean_conj(a.map(&:text),
234
+ "and")))
235
+ a = xml.xpath(ns(xpath.sub("author", "authorizer")))
236
+ a.empty? or set(:approvalgroup,
237
+ connectives_strip(@i18n.boolean_conj(a.map(&:text),
238
+ "and")))
232
239
  end
233
240
 
234
241
  def secretariat(xml)
@@ -37,6 +37,8 @@ module IsoDoc
37
37
  bib.at(ns("./ext/doctype")))
38
38
  hash_translate(bib, @i18n.get["substage_dict"],
39
39
  "./status/substage", nil, @lang)
40
+ hash_translate(bib, @i18n.get["contributor_role_desc_dict"],
41
+ "./contributor/role/description", nil, @lang)
40
42
  edition_translate(bib)
41
43
  end
42
44
 
@@ -1291,13 +1291,13 @@ Restricted recursively to contain only other such inline elements with no identi
1291
1291
  <ref name="pure_strike"/>
1292
1292
  <ref name="pure_smallcap"/>
1293
1293
  <ref name="br"/>
1294
+ <ref name="stem"/>
1294
1295
  </choice>
1295
1296
  </define>
1296
1297
  <define name="NestedTextElement">
1297
1298
  <a:documentation>Contents of TextElement tags: leaves out tags that should occur only at top level of block: bookmark image hr pagebreak</a:documentation>
1298
1299
  <choice>
1299
1300
  <ref name="PureTextElement"/>
1300
- <ref name="stem"/>
1301
1301
  <ref name="eref"/>
1302
1302
  <ref name="xref"/>
1303
1303
  <ref name="hyperlink"/>
@@ -1,17 +1,14 @@
1
1
  module Metanorma
2
2
  module Iso
3
3
  class Converter < Standoc::Converter
4
- # def home_agency
5
- # "ISO"
6
- # end
7
-
8
4
  def default_publisher
9
5
  "ISO"
10
6
  end
11
7
 
12
8
  def org_abbrev
13
9
  { "International Organization for Standardization" => "ISO",
14
- "International Electrotechnical Commission" => "IEC" }
10
+ "International Electrotechnical Commission" => "IEC",
11
+ "International Organization for Standardization, International Electrotechnical Commission" => "ISO/IEC" }
15
12
  end
16
13
 
17
14
  def metadata_author(node, xml)
@@ -22,23 +19,59 @@ module Metanorma
22
19
  end
23
20
 
24
21
  def org_organization(node, xml, org)
25
- org[:committee] and
26
- contrib_committee_build(xml, org[:agency], org) or
27
- super
22
+ if org[:committee]
23
+ contrib_committee_build(xml, org[:agency], org)
24
+ else super
25
+ end
28
26
  end
29
27
 
30
28
  def committee_contributors(node, xml, approval, agency)
31
- metadata_approval_committee_types(approval ? node : nil).each do |v|
32
- node.attr("#{v}-number") or next
29
+ t = metadata_approval_committee_types(approval ? node : nil)
30
+ v = t.first
31
+ if node.attr("#{v}-number")
33
32
  node.attr(v) or node.set_attr(v, "")
34
- o = { source: [v], role: approval ? "authorizer" : "author",
35
- default_org: false, committee: true, agency:,
36
- desc: v.sub(/^approval-/, "").tr("-", " ").capitalize }
33
+ o = committee_contrib_org_prep(node, v, approval, agency)
34
+ o[:groups] = t
35
+ o[:approval] = approval
37
36
  org_contributor(node, xml, o)
38
37
  end
39
38
  approval or committee_contributors_approval(node, xml, agency)
40
39
  end
41
40
 
41
+ def committee_contrib_org_prep(node, type, approval, agency)
42
+ agency_arr, agency_abbrev =
43
+ committee_org_prep_agency(node, type, agency, [], [])
44
+ { source: [type], role: approval ? "authorizer" : "author",
45
+ default_org: false, committee: true, agency: agency_arr,
46
+ agency_abbrev:,
47
+ desc: type.sub(/^approval-/, "").tr("-", " ").capitalize }.compact
48
+ end
49
+
50
+ def committee_org_prep_agency(node, type, agency, agency_arr, agency_abbr)
51
+ i = 1
52
+ suffix = ""
53
+ while node.attr("#{type}-number#{suffix}") ||
54
+ node.attr("#{type}#{suffix}")
55
+ agency_arr << (node.attr("#{type}-agency#{suffix}") || agency)
56
+ agency_abbr << node.attr("#{type}-agency-abbr#{suffix}")
57
+ i += 1
58
+ suffix = "_#{i}"
59
+ end
60
+ [agency_arr, agency_abbr]
61
+ end
62
+
63
+ def org_attrs_complex_parse(node, opts, source)
64
+ i = 1
65
+ suffix = ""
66
+ ret = []
67
+ while node.attr("#{source}-number#{suffix}") || node.attr("#{source}#{suffix}")
68
+ ret << extract_org_attrs_complex(node, opts, source, suffix)
69
+ i += 1
70
+ suffix = "_#{i}"
71
+ end
72
+ ret
73
+ end
74
+
42
75
  def committee_contributors_approval(node, xml, agency)
43
76
  o = { name: agency, role: "authorizer", default_org: false,
44
77
  desc: "Agency", committee: false }
@@ -52,13 +85,42 @@ module Metanorma
52
85
  end
53
86
 
54
87
  def contrib_committee_build(xml, agency, committee)
55
- name = org_abbrev.invert[agency] and agency = name
88
+ if name = org_abbrev.invert[agency]
89
+ committee[:agency_abbrev] = agency
90
+ agency = name
91
+ end
56
92
  xml.name agency
57
- xml.subdivision do |o|
58
- o.name committee[:name]
59
- committee[:abbr] and o.abbreviation committee[:abbr]
60
- committee[:ident] and o.identifier committee[:ident]
93
+ s = committee
94
+ loop do
95
+ contrib_committee_subdiv(xml, s)
96
+ s = s[:subdiv] or break
61
97
  end
98
+ abbr = committee[:agency_abbrev] and xml.abbreviation abbr
99
+ full_committee_id(xml.parent)
100
+ end
101
+
102
+ def contrib_committee_subdiv(xml, committee)
103
+ contributors_committees_filter_empty?(committee) and return
104
+ xml.subdivision **attr_code(type: committee[:desc]) do |o|
105
+ o.name committee[:name]
106
+ # s = committee[:subdiv] and contrib_committee_subdiv(o, s)
107
+ committee[:abbr] and o.abbreviation committee[:abbr]
108
+ committee[:ident] and o.identifier committee[:ident]
109
+ end
110
+ end
111
+
112
+ def full_committee_id(contrib)
113
+ ret = full_committee_agency_id(contrib)
114
+ ids = contrib.xpath("./subdivision").map { |x| x.at("./identifier")&.text }
115
+ ins = contrib.at("./subdivision/identifier") and
116
+ ins.next = "<identifier type='full'>#{ret}#{ids.join('/')}</identifier>"
117
+ end
118
+
119
+ def full_committee_agency_id(contrib)
120
+ agency = contrib.at("./abbreviation")&.text
121
+ ret = agency == default_publisher ? "" : "#{agency} "
122
+ /^\s+/.match?(ret) and ret = ""
123
+ ret
62
124
  end
63
125
 
64
126
  COMMITTEE_ABBREVS =
@@ -66,16 +128,58 @@ module Metanorma
66
128
  "workgroup" => "WG" }.freeze
67
129
 
68
130
  def committee_abbrev(type, number, level)
131
+ number.nil? || number.empty? and return
69
132
  type ||= COMMITTEE_ABBREVS[level.sub(/^approval-/, "")]
70
133
  type == "Other" and type = ""
71
134
  "#{type} #{number}".strip
72
135
  end
73
136
 
74
137
  def org_attrs_parse(node, opts)
75
- super&.map do |x|
76
- x.merge(agency: opts[:agency], abbr: opts[:abbr],
138
+ opts_orig = opts.dup
139
+ ret = []
140
+ ret << super&.map&.with_index do |x, i|
141
+ x.merge(agency: opts.dig(:agency, i),
142
+ agency_abbrev: opts.dig(:agency_abbrev, i), abbr: opts[:abbr],
77
143
  committee: opts[:committee], default_org: opts[:default_org])
78
144
  end
145
+ opts_orig[:groups]&.each_with_index do |g, i|
146
+ i.zero? and next
147
+ contributors_committees_pad_multiples(ret, node, g)
148
+ opts = committee_contrib_org_prep(node, g, opts_orig[:approval], nil)
149
+ ret << super
150
+ end
151
+ #ret = contributors_committees_filter_empty(ret)
152
+ #ret.first
153
+ ret = contributors_committees_nest1(ret)
154
+ end
155
+
156
+ # ensure there is subcommittee, workgroup -number_2, -number_3 etc
157
+ # to parse mutlple tech committees
158
+ def contributors_committees_pad_multiples(committees, node, group)
159
+ committees.each_with_index do |_r, j|
160
+ suffix = j.zero? ? "" : "_#{j + 1}"
161
+ node.attr("#{group}#{suffix}") or
162
+ node.set_attr("#{group}#{suffix}", "")
163
+ node.attr("#{group}-number#{suffix}") or
164
+ node.set_attr("#{group}-number#{suffix}", "")
165
+ end
166
+ end
167
+
168
+ def contributors_committees_filter_empty?(committee)
169
+ committee[:name].empty? &&
170
+ (committee[:ident].nil? || %w(WG TC SC).include?(committee[:ident]))
171
+ end
172
+
173
+ def contributors_committees_nest1(committees)
174
+ committees.empty? and return committees
175
+ committees = committees.reverse
176
+ committees.each_with_index do |m, i|
177
+ i.zero? and next
178
+ m.each_with_index do |m1, j|
179
+ m1[:subdiv] = committees[i - 1][j]
180
+ end
181
+ end
182
+ committees[-1]
79
183
  end
80
184
 
81
185
  def metadata_publisher(node, xml)
@@ -93,7 +197,10 @@ module Metanorma
93
197
  def metadata_editorial_committee(node, xml)
94
198
  xml.editorialgroup do |a|
95
199
  %w(technical-committee subcommittee workgroup).each do |v|
96
- node.attr("#{v}-number") and committee_component(v, node, a)
200
+ val = node.attr("#{v}-number")
201
+ val && !val.empty? and committee_component(v, node, a)
202
+ a.parent.xpath("./#{v.gsub('-', '_')}[not(node())][not(@number)]")
203
+ .each(&:remove)
97
204
  end
98
205
  node.attr("secretariat") and a.secretariat(node.attr("secretariat"))
99
206
  end
@@ -106,6 +213,8 @@ module Metanorma
106
213
  &.split(%r{[/,;]}))
107
214
  types.each do |v|
108
215
  node.attr("#{v}-number") and committee_component(v, node, a)
216
+ a.parent.xpath("./#{v.gsub('-', '_')}[not(node())][not(@number)]")
217
+ .each(&:remove)
109
218
  end
110
219
  end
111
220
  end
@@ -124,6 +233,21 @@ module Metanorma
124
233
  xml.agency v
125
234
  end
126
235
  end
236
+
237
+ def committee_component(compname, node, out)
238
+ i = 1
239
+ suffix = ""
240
+ while node.attr(compname + suffix)
241
+ num = node.attr("#{compname}-number#{suffix}")
242
+ name = node.attr(compname + suffix)
243
+ (!num.nil? && !num.empty?) || (!name.nil? && !name.empty?) and
244
+ out.send compname.gsub(/-/, "_"), name,
245
+ **attr_code(number: num,
246
+ type: node.attr("#{compname}-type#{suffix}"))
247
+ i += 1
248
+ suffix = "_#{i}"
249
+ end
250
+ end
127
251
  end
128
252
  end
129
253
  end
@@ -42,36 +42,6 @@ All IdRefType instances point not to `@id` in Semantic XML, which is the Content
42
42
  but to `@anchor`, the user-supplied cross-reference</a:documentation>
43
43
  <text/>
44
44
  </define>
45
- <define name="index-primary">
46
- <element name="primary">
47
- <oneOrMore>
48
- <choice>
49
- <ref name="PureTextElement"/>
50
- <ref name="stem"/>
51
- </choice>
52
- </oneOrMore>
53
- </element>
54
- </define>
55
- <define name="index-secondary">
56
- <element name="secondary">
57
- <oneOrMore>
58
- <choice>
59
- <ref name="PureTextElement"/>
60
- <ref name="stem"/>
61
- </choice>
62
- </oneOrMore>
63
- </element>
64
- </define>
65
- <define name="index-tertiary">
66
- <element name="tertiary">
67
- <oneOrMore>
68
- <choice>
69
- <ref name="PureTextElement"/>
70
- <ref name="stem"/>
71
- </choice>
72
- </oneOrMore>
73
- </element>
74
- </define>
75
45
  <define name="review">
76
46
  <a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
77
47
  the type attribute defaults to `review` for reviews</a:documentation>
@@ -592,28 +562,6 @@ normative or informative references, some split references into sections organiz
592
562
  </oneOrMore>
593
563
  </element>
594
564
  </define>
595
- <define name="sub">
596
- <a:documentation>Subscript text. Corresponds to HTML `sub</a:documentation>
597
- <element name="sub">
598
- <zeroOrMore>
599
- <choice>
600
- <ref name="PureTextElement"/>
601
- <ref name="stem"/>
602
- </choice>
603
- </zeroOrMore>
604
- </element>
605
- </define>
606
- <define name="sup">
607
- <a:documentation>Superscript text. Corresponds to HTML `sup`</a:documentation>
608
- <element name="sup">
609
- <zeroOrMore>
610
- <choice>
611
- <ref name="PureTextElement"/>
612
- <ref name="stem"/>
613
- </choice>
614
- </zeroOrMore>
615
- </element>
616
- </define>
617
565
  <define name="pagebreak">
618
566
  <a:documentation>Page break. Only applicable in paged layouts (e.g. PDF, Word), and not flow layouts (e.g. HTML)</a:documentation>
619
567
  <element name="pagebreak">
@@ -1094,7 +1042,6 @@ That concept may be defined as a term within the current document, or it may be
1094
1042
  <zeroOrMore>
1095
1043
  <choice>
1096
1044
  <ref name="PureTextElement"/>
1097
- <ref name="stem"/>
1098
1045
  <ref name="index"/>
1099
1046
  <ref name="index-xref"/>
1100
1047
  </choice>
@@ -1107,7 +1054,6 @@ That concept may be defined as a term within the current document, or it may be
1107
1054
  <zeroOrMore>
1108
1055
  <choice>
1109
1056
  <ref name="PureTextElement"/>
1110
- <ref name="stem"/>
1111
1057
  <ref name="index"/>
1112
1058
  <ref name="index-xref"/>
1113
1059
  </choice>
@@ -2025,10 +1971,7 @@ used in document amendments</a:documentation>
2025
1971
  <element name="name">
2026
1972
  <a:documentation>The symbolic form of the designation</a:documentation>
2027
1973
  <oneOrMore>
2028
- <choice>
2029
- <ref name="PureTextElement"/>
2030
- <ref name="stem"/>
2031
- </choice>
1974
+ <ref name="PureTextElement"/>
2032
1975
  </oneOrMore>
2033
1976
  </element>
2034
1977
  </element>
@@ -2081,7 +2024,6 @@ used in document amendments</a:documentation>
2081
2024
  <zeroOrMore>
2082
2025
  <choice>
2083
2026
  <ref name="PureTextElement"/>
2084
- <ref name="stem"/>
2085
2027
  <ref name="index"/>
2086
2028
  <ref name="index-xref"/>
2087
2029
  </choice>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iso
3
- VERSION = "3.1.1".freeze
3
+ VERSION = "3.1.2".freeze
4
4
  end
5
5
  end
@@ -50,5 +50,5 @@ spec.add_development_dependency "rubocop-performance"
50
50
  spec.add_development_dependency "simplecov", "~> 0.15"
51
51
  spec.add_development_dependency "timecop", "~> 0.9"
52
52
  spec.add_development_dependency "webmock"
53
- spec.add_development_dependency "xml-c14n"
53
+ spec.add_development_dependency "canon"
54
54
  end
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: 3.1.1
4
+ version: 3.1.2
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-07-21 00:00:00.000000000 Z
11
+ date: 2025-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -249,7 +249,7 @@ dependencies:
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
251
  - !ruby/object:Gem::Dependency
252
- name: xml-c14n
252
+ name: canon
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
255
  - - ">="