metanorma-iso 3.1.8 → 3.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.
- checksums.yaml +4 -4
- data/lib/isodoc/iso/i18n-de.yaml +2 -0
- data/lib/isodoc/iso/i18n-en.yaml +3 -0
- data/lib/isodoc/iso/i18n-fr.yaml +3 -1
- data/lib/isodoc/iso/i18n-ja.yaml +2 -2
- data/lib/isodoc/iso/i18n-ru.yaml +3 -1
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +2 -0
- data/lib/isodoc/iso/iso.amendment.xsl +386 -290
- data/lib/isodoc/iso/iso.international-standard.xsl +386 -290
- data/lib/isodoc/iso/presentation_origin.rb +119 -0
- data/lib/isodoc/iso/presentation_xml_convert.rb +1 -1
- data/lib/isodoc/iso/presentation_xref.rb +0 -71
- data/lib/isodoc/iso/xref.rb +0 -23
- data/lib/isodoc/iso/xref_section.rb +25 -1
- data/lib/metanorma/iso/biblio.rng +4 -4
- data/lib/metanorma/iso/cleanup.rb +1 -2
- data/lib/metanorma/iso/converter.rb +2 -0
- data/lib/metanorma/iso/front.rb +9 -9
- data/lib/metanorma/iso/front_contributor.rb +2 -4
- data/lib/metanorma/iso/front_id.rb +20 -16
- data/lib/metanorma/iso/isodoc.rng +27 -10
- data/lib/metanorma/iso/log.rb +148 -0
- data/lib/metanorma/iso/validate.rb +10 -17
- data/lib/metanorma/iso/validate_section.rb +24 -48
- data/lib/metanorma/iso/validate_style.rb +1 -1
- data/lib/metanorma/iso/validate_title.rb +13 -16
- data/lib/metanorma/iso/validate_xref.rb +8 -18
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/relaton/render/config.yml +51 -11
- data/metanorma-iso.gemspec +2 -1
- metadata +20 -4
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
module IsoDoc
|
|
2
|
+
module Iso
|
|
3
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
|
4
|
+
def origin(docxml)
|
|
5
|
+
short_style_origin(docxml)
|
|
6
|
+
super
|
|
7
|
+
bracketed_refs_processing(docxml)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def short_style_origin(docxml)
|
|
11
|
+
docxml.xpath(ns("//fmt-origin")).each do |o|
|
|
12
|
+
xref_empty?(o) or next
|
|
13
|
+
fmt_origin_cite_full?(o) and o["style"] ||= "short"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def fmt_origin_cite_full?(elem)
|
|
18
|
+
sem_xml_descendant?(elem) and return
|
|
19
|
+
id = elem["bibitemid"] or return
|
|
20
|
+
b = @bibitem_lookup[id] or return
|
|
21
|
+
b["type"] != "standard" ||
|
|
22
|
+
!b.at(ns("./docidentifier[not(@type = 'metanorma' or @type = 'metanorma-ordinal')]"))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# style [1] references as [Reference 1], eref or origin
|
|
26
|
+
def bracketed_refs_processing(docxml)
|
|
27
|
+
(docxml.xpath(ns("//semx[@element = 'eref']")) -
|
|
28
|
+
docxml.xpath(ns("//semx[@element = 'erefstack']//semx[@element = 'eref']")))
|
|
29
|
+
.each { |n| bracket_eref_style(n) }
|
|
30
|
+
docxml.xpath(ns("//semx[@element = 'erefstack']")).each do |n|
|
|
31
|
+
bracket_erefstack_style(n)
|
|
32
|
+
end
|
|
33
|
+
docxml.xpath(ns("//semx[@element = 'origin']")).each do |n|
|
|
34
|
+
bracket_origin_style(n)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def bracket_eref_style(elem)
|
|
39
|
+
semx = bracket_eref_original(elem) or return
|
|
40
|
+
if semx["style"] == "superscript"
|
|
41
|
+
elem.children.wrap("<sup></sup>")
|
|
42
|
+
remove_preceding_space(elem)
|
|
43
|
+
else
|
|
44
|
+
r = @i18n.reference
|
|
45
|
+
elem.add_first_child l10n("#{r} ")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# is the eref corresponding to this semx a simple [n] reference?
|
|
50
|
+
def bracket_eref_original(elem)
|
|
51
|
+
semx = elem.document.at("//*[@id = '#{elem['source']}']") or return
|
|
52
|
+
dup = elem.at(ns(".//fmt-eref | .//fmt-xref | .//fmt-origin"))
|
|
53
|
+
non_locality_elems(semx).empty? or return
|
|
54
|
+
/^\[\d+\]$/.match?(semx["citeas"]) or return
|
|
55
|
+
%w(full short).include?(dup["style"]) and return
|
|
56
|
+
semx
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def bracket_erefstack_style(elem)
|
|
60
|
+
semx, erefstack_orig = bracket_erefstack_style_prep(elem)
|
|
61
|
+
semx.empty? and return
|
|
62
|
+
if erefstack_orig && erefstack_orig["style"]
|
|
63
|
+
elem.children.each do |e|
|
|
64
|
+
e.name == "span" and e.remove
|
|
65
|
+
e.text.strip.empty? and e.remove
|
|
66
|
+
end
|
|
67
|
+
elem.children.wrap("<sup></sup>")
|
|
68
|
+
remove_preceding_space(elem)
|
|
69
|
+
else
|
|
70
|
+
r = @i18n.inflect(@i18n.reference, number: "pl")
|
|
71
|
+
elem.add_first_child l10n("#{r} ")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def bracket_erefstack_style_prep(elem)
|
|
76
|
+
semx = elem.xpath(ns(".//semx[@element = 'eref']"))
|
|
77
|
+
.map { |e| bracket_eref_original(e) }.compact
|
|
78
|
+
erefstack_orig = elem.document.at("//*[@id = '#{elem['source']}']")
|
|
79
|
+
[semx, erefstack_orig]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def bracket_origin_style(elem)
|
|
83
|
+
bracket_eref_style(elem)
|
|
84
|
+
insert_biblio_callout(elem)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# TODO share with metanorma dir
|
|
88
|
+
ISO_PUBLISHER_XPATH = <<~XPATH.freeze
|
|
89
|
+
./contributor[role/@type = 'publisher']/organization[abbreviation = 'ISO' or abbreviation = 'IEC' or name = 'International Organization for Standardization' or name = 'International Electrotechnical Commission']
|
|
90
|
+
XPATH
|
|
91
|
+
|
|
92
|
+
def insert_biblio_callout(elem)
|
|
93
|
+
semx = elem.document.at("//*[@id = '#{elem['source']}']") or return
|
|
94
|
+
if ref = @bibitem_lookup[semx["bibitemid"]]
|
|
95
|
+
ref.at(ns(ISO_PUBLISHER_XPATH)) and return
|
|
96
|
+
# is this reference cited with a [n],
|
|
97
|
+
# even if it has its own SDO identifier?
|
|
98
|
+
citeas = ref.at(ns("./docidentifier[@type = 'metanorma-ordinal']")) ||
|
|
99
|
+
ref.at(ns("./docidentifier[@type = 'metanorma']")) ||
|
|
100
|
+
ref.at(ns("./docidentifier[@scope = 'biblio-tag']"))
|
|
101
|
+
citeas = citeas.text
|
|
102
|
+
else
|
|
103
|
+
citeas = semx["citeas"]
|
|
104
|
+
end
|
|
105
|
+
/^\[\d+\]$/.match?(citeas) or return
|
|
106
|
+
elem << <<~XML
|
|
107
|
+
<fmt-xref target='#{semx['bibitemid']}'><sup>#{citeas}</sup></fmt-xref>
|
|
108
|
+
XML
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def remove_preceding_space(elem)
|
|
112
|
+
# Find the preceding text node that has actual content
|
|
113
|
+
prec = elem.at("./preceding-sibling::text()" \
|
|
114
|
+
"[normalize-space(.) != ''][1]") or return
|
|
115
|
+
prec.content.end_with?(" ") and prec.content = prec.content.rstrip
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -4,6 +4,7 @@ require_relative "presentation_xref"
|
|
|
4
4
|
require_relative "presentation_bibdata"
|
|
5
5
|
require_relative "presentation_section"
|
|
6
6
|
require_relative "presentation_terms"
|
|
7
|
+
require_relative "presentation_origin"
|
|
7
8
|
require_relative "../../relaton/render/general"
|
|
8
9
|
|
|
9
10
|
module IsoDoc
|
|
@@ -126,7 +127,6 @@ module IsoDoc
|
|
|
126
127
|
|
|
127
128
|
def table1(elem)
|
|
128
129
|
table1_key(elem)
|
|
129
|
-
#require "debug"; binding.b
|
|
130
130
|
if elem["class"] == "modspec"
|
|
131
131
|
if n = elem.at(ns(".//fmt-name"))
|
|
132
132
|
n.remove.name = "name"
|
|
@@ -147,77 +147,6 @@ module IsoDoc
|
|
|
147
147
|
locality_span_wrap(super, @xrefs.anchor(node["target"], :subtype) ||
|
|
148
148
|
@xrefs.anchor(node["target"], :type))
|
|
149
149
|
end
|
|
150
|
-
|
|
151
|
-
def origin(docxml)
|
|
152
|
-
super
|
|
153
|
-
bracketed_refs_processing(docxml)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
# style [1] references as [Reference 1], eref or origin
|
|
157
|
-
def bracketed_refs_processing(docxml)
|
|
158
|
-
(docxml.xpath(ns("//semx[@element = 'eref']")) -
|
|
159
|
-
docxml.xpath(ns("//semx[@element = 'erefstack']//semx[@element = 'eref']")))
|
|
160
|
-
.each { |n| bracket_eref_style(n) }
|
|
161
|
-
docxml.xpath(ns("//semx[@element = 'erefstack']")).each do |n|
|
|
162
|
-
bracket_erefstack_style(n)
|
|
163
|
-
end
|
|
164
|
-
docxml.xpath(ns("//semx[@element = 'origin']")).each do |n|
|
|
165
|
-
bracket_origin_style(n)
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
def bracket_eref_style(elem)
|
|
170
|
-
semx = bracket_eref_original(elem) or return
|
|
171
|
-
if semx["style"] == "superscript"
|
|
172
|
-
elem.children.wrap("<sup></sup>")
|
|
173
|
-
remove_preceding_space(elem)
|
|
174
|
-
else
|
|
175
|
-
r = @i18n.reference
|
|
176
|
-
elem.add_first_child l10n("#{r} ")
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
# is the eref corresponding to this semx a simple [n] reference?
|
|
181
|
-
def bracket_eref_original(elem)
|
|
182
|
-
semx = elem.document.at("//*[@id = '#{elem['source']}']") or return
|
|
183
|
-
non_locality_elems(semx).empty? or return
|
|
184
|
-
/^\[\d+\]$/.match?(semx["citeas"]) or return
|
|
185
|
-
semx
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def bracket_erefstack_style(elem)
|
|
189
|
-
semx, erefstack_orig = bracket_erefstack_style_prep(elem)
|
|
190
|
-
semx.empty? and return
|
|
191
|
-
if erefstack_orig && erefstack_orig["style"]
|
|
192
|
-
elem.children.each do |e|
|
|
193
|
-
e.name == "span" and e.remove
|
|
194
|
-
e.text.strip.empty? and e.remove
|
|
195
|
-
end
|
|
196
|
-
elem.children.wrap("<sup></sup>")
|
|
197
|
-
remove_preceding_space(elem)
|
|
198
|
-
else
|
|
199
|
-
r = @i18n.inflect(@i18n.reference, number: "pl")
|
|
200
|
-
elem.add_first_child l10n("#{r} ")
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def bracket_erefstack_style_prep(elem)
|
|
205
|
-
semx = elem.xpath(ns(".//semx[@element = 'eref']"))
|
|
206
|
-
.map { |e| bracket_eref_original(e) }.compact
|
|
207
|
-
erefstack_orig = elem.document.at("//*[@id = '#{elem['source']}']")
|
|
208
|
-
[semx, erefstack_orig]
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
def bracket_origin_style(elem)
|
|
212
|
-
bracket_eref_style(elem)
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
def remove_preceding_space(elem)
|
|
216
|
-
# Find the preceding text node that has actual content
|
|
217
|
-
prec = elem.at("./preceding-sibling::text()" \
|
|
218
|
-
"[normalize-space(.) != ''][1]") or return
|
|
219
|
-
prec.content.end_with?(" ") and prec.content = prec.content.rstrip
|
|
220
|
-
end
|
|
221
150
|
end
|
|
222
151
|
end
|
|
223
152
|
end
|
data/lib/isodoc/iso/xref.rb
CHANGED
|
@@ -8,29 +8,6 @@ module IsoDoc
|
|
|
8
8
|
class Xref < IsoDoc::Xref
|
|
9
9
|
attr_accessor :anchors_previous, :anchors
|
|
10
10
|
|
|
11
|
-
def clause_order_main(docxml)
|
|
12
|
-
if @klass.amd?(docxml)
|
|
13
|
-
[{ path: "//sections/clause", multi: true }]
|
|
14
|
-
else
|
|
15
|
-
[{ path: "//sections/clause[@type = 'scope']" },
|
|
16
|
-
{ path: @klass.norm_ref_xpath },
|
|
17
|
-
{ path:
|
|
18
|
-
"#{@klass.middle_clause(docxml)} | //sections/terms | " \
|
|
19
|
-
"//sections/clause[descendant::terms or descendant::definitions] | " \
|
|
20
|
-
"//sections/definitions | //sections/clause[@type = 'section']", multi: true }]
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def clause_order_back(docxml)
|
|
25
|
-
if @klass.amd?(docxml)
|
|
26
|
-
[{ path: @klass.norm_ref_xpath },
|
|
27
|
-
{ path: @klass.bibliography_xpath },
|
|
28
|
-
{ path: "//indexsect", multi: true },
|
|
29
|
-
{ path: "//colophon/*", multi: true }]
|
|
30
|
-
else super
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
11
|
def initial_anchor_names(doc)
|
|
35
12
|
super
|
|
36
13
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
module IsoDoc
|
|
2
2
|
module Iso
|
|
3
3
|
class Xref < IsoDoc::Xref
|
|
4
|
+
def clause_order_main(docxml)
|
|
5
|
+
if @klass.amd?(docxml)
|
|
6
|
+
[{ path: "//sections/clause", multi: true }]
|
|
7
|
+
else
|
|
8
|
+
[{ path: "//sections/clause[@type = 'scope']" },
|
|
9
|
+
{ path: @klass.norm_ref_xpath },
|
|
10
|
+
{ path:
|
|
11
|
+
"#{@klass.middle_clause(docxml)} | //sections/terms | " \
|
|
12
|
+
"//sections/clause[descendant::terms or descendant::definitions] | " \
|
|
13
|
+
"//sections/definitions | //sections/clause[@type = 'section']", multi: true }]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def clause_order_back(docxml)
|
|
18
|
+
if @klass.amd?(docxml)
|
|
19
|
+
[{ path: @klass.norm_ref_xpath },
|
|
20
|
+
{ path: @klass.bibliography_xpath },
|
|
21
|
+
{ path: "//indexsect", multi: true },
|
|
22
|
+
{ path: "//colophon/*", multi: true }]
|
|
23
|
+
else super
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
4
27
|
# we can reference 0-number clauses in introduction
|
|
5
28
|
def introduction_names(clause)
|
|
6
29
|
clause.nil? and return
|
|
@@ -25,7 +48,8 @@ module IsoDoc
|
|
|
25
48
|
elsif level > 1
|
|
26
49
|
@anchors[clause["id"]] =
|
|
27
50
|
{ label: num, level: level, xref: num, subtype: "clause" }
|
|
28
|
-
else super
|
|
51
|
+
else super
|
|
52
|
+
end
|
|
29
53
|
end
|
|
30
54
|
|
|
31
55
|
def annex_name_anchors1(clause, num, level)
|
|
@@ -690,7 +690,7 @@ Examples include GRID, LEI, CrossRef, and Ringgold</a:documentation>
|
|
|
690
690
|
<define name="CitationType">
|
|
691
691
|
<attribute name="bibitemid">
|
|
692
692
|
<a:documentation>Bibliographic item that the citation applies to, referenced as the anchor of a bibliographic description</a:documentation>
|
|
693
|
-
<
|
|
693
|
+
<ref name="IdRefType"/>
|
|
694
694
|
</attribute>
|
|
695
695
|
<choice>
|
|
696
696
|
<zeroOrMore>
|
|
@@ -1296,17 +1296,17 @@ for which this claim of validity is made, if applicable</a:documentation>
|
|
|
1296
1296
|
</define>
|
|
1297
1297
|
<define name="validityBegins">
|
|
1298
1298
|
<element name="validityBegins">
|
|
1299
|
-
<ref name="
|
|
1299
|
+
<ref name="ISO8601DateTime"/>
|
|
1300
1300
|
</element>
|
|
1301
1301
|
</define>
|
|
1302
1302
|
<define name="validityEnds">
|
|
1303
1303
|
<element name="validityEnds">
|
|
1304
|
-
<ref name="
|
|
1304
|
+
<ref name="ISO8601DateTime"/>
|
|
1305
1305
|
</element>
|
|
1306
1306
|
</define>
|
|
1307
1307
|
<define name="validityRevision">
|
|
1308
1308
|
<element name="revision">
|
|
1309
|
-
<ref name="
|
|
1309
|
+
<ref name="ISO8601DateTime"/>
|
|
1310
1310
|
</element>
|
|
1311
1311
|
</define>
|
|
1312
1312
|
<define name="TypedTitleString">
|
data/lib/metanorma/iso/front.rb
CHANGED
|
@@ -16,12 +16,13 @@ module Metanorma
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def metadata_ext_iso(node, xml)
|
|
19
|
-
|
|
19
|
+
add_noko_elem(xml, "horizontal", node.attr("horizontal"))
|
|
20
20
|
metadata_stage(node, xml)
|
|
21
|
-
@amd
|
|
22
|
-
xml
|
|
21
|
+
@amd and
|
|
22
|
+
add_noko_elem(xml, "updates_document_type",
|
|
23
|
+
node.attr("updates-document-type"))
|
|
23
24
|
a = node.attr("fast-track") and xml.send "fast-track", a != "false"
|
|
24
|
-
|
|
25
|
+
add_noko_elem(xml, "price_code", node.attr("price-code"))
|
|
25
26
|
node.attr("iso-cen-parallel") and xml.iso_cen_parallel true
|
|
26
27
|
end
|
|
27
28
|
|
|
@@ -58,17 +59,16 @@ module Metanorma
|
|
|
58
59
|
substage = get_substage(node)
|
|
59
60
|
abbrev = iso_id_default(iso_id_params(node)).stage&.abbr&.upcase
|
|
60
61
|
xml.status do |s|
|
|
61
|
-
s
|
|
62
|
-
s
|
|
63
|
-
|
|
62
|
+
add_noko_elem(s, "stage", stage, **attr_code(abbreviation: abbrev))
|
|
63
|
+
add_noko_elem(s, "substage", substage)
|
|
64
|
+
add_noko_elem(s, "iteration", node.attr("iteration"))
|
|
64
65
|
end
|
|
65
66
|
rescue *STAGE_ERROR
|
|
66
67
|
report_illegal_stage(stage, substage)
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
def report_illegal_stage(stage, substage)
|
|
70
|
-
|
|
71
|
-
@log.add("Document Attributes", nil, err)
|
|
71
|
+
@log.add("ISO_9", nil, params: [stage, substage])
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def title_component(node, xml, lang, comp)
|
|
@@ -16,8 +16,6 @@ module Metanorma
|
|
|
16
16
|
secretariat_contributor(node, xml, default_publisher)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def personal_author(node, xml); end
|
|
20
|
-
|
|
21
19
|
def org_organization(node, xml, org)
|
|
22
20
|
if org[:committee]
|
|
23
21
|
contrib_committee_build(xml, org[:agency], org)
|
|
@@ -87,8 +85,8 @@ module Metanorma
|
|
|
87
85
|
|
|
88
86
|
def contributors_committees_filter_empty?(committee)
|
|
89
87
|
committee[:name].empty? &&
|
|
90
|
-
(committee[:ident].nil? ||
|
|
91
|
-
|
|
88
|
+
(committee[:ident].nil? ||
|
|
89
|
+
%w(WG TC SC).include?(committee[:ident]))
|
|
92
90
|
end
|
|
93
91
|
|
|
94
92
|
def metadata_publisher(node, xml)
|
|
@@ -9,11 +9,11 @@ module Metanorma
|
|
|
9
9
|
class Converter < Standoc::Converter
|
|
10
10
|
def metadata_id(node, xml)
|
|
11
11
|
if id = node.attr("docidentifier")
|
|
12
|
-
xml
|
|
12
|
+
add_noko_elem(xml, "docidentifier", id, type: "ISO", primary: "true")
|
|
13
13
|
else iso_id(node, xml)
|
|
14
14
|
end
|
|
15
15
|
node.attr("tc-docnumber")&.split(/,\s*/)&.each do |n|
|
|
16
|
-
xml
|
|
16
|
+
add_noko_elem(xml, "docidentifier", n, type: "iso-tc")
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -164,25 +164,29 @@ module Metanorma
|
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
def cen_id_out(xml, params)
|
|
167
|
-
xml
|
|
168
|
-
|
|
167
|
+
add_noko_elem(xml, "docidentifier",
|
|
168
|
+
iso_id_default(params).to_s,
|
|
169
|
+
**attr_code(type: "CEN", primary: "true"))
|
|
169
170
|
end
|
|
170
171
|
|
|
171
172
|
def iso_id_out_common(xml, params, with_prf)
|
|
172
|
-
xml
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
add_noko_elem(xml, "docidentifier",
|
|
174
|
+
iso_id_default(params).to_s(with_prf:),
|
|
175
|
+
**attr_code(type: "ISO", primary: "true"))
|
|
176
|
+
add_noko_elem(xml, "docidentifier", iso_id_reference(params)
|
|
177
|
+
.to_s(format: :ref_num_short, with_prf:),
|
|
178
|
+
**attr_code(type: "iso-reference"))
|
|
179
|
+
add_noko_elem(xml, "docidentifier", iso_id_reference(params).urn,
|
|
180
|
+
**attr_code(type: "URN"))
|
|
178
181
|
end
|
|
179
182
|
|
|
180
183
|
def iso_id_out_non_amd(xml, params, with_prf)
|
|
181
|
-
xml
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
add_noko_elem(xml, "docidentifier",
|
|
185
|
+
iso_id_undated(params).to_s(with_prf:),
|
|
186
|
+
**attr_code(type: "iso-undated"))
|
|
187
|
+
add_noko_elem(xml, "docidentifier",
|
|
188
|
+
iso_id_with_lang(params).to_s(format: :ref_num_long, with_prf:),
|
|
189
|
+
**attr_code(type: "iso-with-lang"))
|
|
186
190
|
end
|
|
187
191
|
|
|
188
192
|
def iso_id_default(params)
|
|
@@ -216,7 +220,7 @@ module Metanorma
|
|
|
216
220
|
node.attr("docnumber") or return
|
|
217
221
|
part, subpart = node.attr("partnumber")&.split("-")
|
|
218
222
|
xml.structuredidentifier do |i|
|
|
219
|
-
i
|
|
223
|
+
add_noko_elem(i, "project-number", node.attr("docnumber"), **attr_code(
|
|
220
224
|
part:, subpart:,
|
|
221
225
|
amendment: node.attr("amendment-number"),
|
|
222
226
|
corrigendum: node.attr("corrigendum-number"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<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">
|
|
3
|
-
<!-- VERSION v2.1.
|
|
3
|
+
<!-- VERSION v2.1.4 -->
|
|
4
4
|
|
|
5
5
|
<!--
|
|
6
6
|
ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
|
|
@@ -905,15 +905,32 @@ titlecase, or lowercase</a:documentation>
|
|
|
905
905
|
</element>
|
|
906
906
|
</define>
|
|
907
907
|
<define name="image" combine="choice">
|
|
908
|
-
<
|
|
909
|
-
<
|
|
910
|
-
|
|
911
|
-
<
|
|
912
|
-
|
|
913
|
-
<
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
908
|
+
<choice>
|
|
909
|
+
<element name="image">
|
|
910
|
+
<ref name="RequiredId"/>
|
|
911
|
+
<ref name="ImageAttributes"/>
|
|
912
|
+
<optional>
|
|
913
|
+
<element name="svg">
|
|
914
|
+
<a:documentation>Allow svg in image/svg, for consistency</a:documentation>
|
|
915
|
+
<oneOrMore>
|
|
916
|
+
<choice>
|
|
917
|
+
<text/>
|
|
918
|
+
<ref name="AnyElement"/>
|
|
919
|
+
</choice>
|
|
920
|
+
</oneOrMore>
|
|
921
|
+
</element>
|
|
922
|
+
</optional>
|
|
923
|
+
</element>
|
|
924
|
+
<element name="svg">
|
|
925
|
+
<a:documentation>Add svg mark up to image</a:documentation>
|
|
926
|
+
<oneOrMore>
|
|
927
|
+
<choice>
|
|
928
|
+
<text/>
|
|
929
|
+
<ref name="AnyElement"/>
|
|
930
|
+
</choice>
|
|
931
|
+
</oneOrMore>
|
|
932
|
+
</element>
|
|
933
|
+
</choice>
|
|
917
934
|
</define>
|
|
918
935
|
<define name="ParagraphFnBody" combine="interleave">
|
|
919
936
|
<ref name="BlockSource">
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
module Metanorma
|
|
2
|
+
module Iso
|
|
3
|
+
class Converter
|
|
4
|
+
ISO_LOG_MESSAGES = {
|
|
5
|
+
# rubocop:disable Naming/VariableNumber
|
|
6
|
+
"ISO_1": { category: "Style",
|
|
7
|
+
error: "Style override set for ordered list",
|
|
8
|
+
severity: 2 },
|
|
9
|
+
"ISO_2": { category: "Document Attributes",
|
|
10
|
+
error: "invalid technical committee type %s",
|
|
11
|
+
severity: 2 },
|
|
12
|
+
"ISO_3": { category: "Document Attributes",
|
|
13
|
+
error: "invalid subcommittee type %s",
|
|
14
|
+
severity: 2 },
|
|
15
|
+
"ISO_4": { category: "Style",
|
|
16
|
+
error: "term definition starts with article: %s",
|
|
17
|
+
severity: 2 },
|
|
18
|
+
"ISO_5": { category: "Document Attributes",
|
|
19
|
+
error: "%s is not a recognised document type", severity: 2 },
|
|
20
|
+
"ISO_6": { category: "Document Attributes",
|
|
21
|
+
error: "%s is not a recognised iteration", severity: 2 },
|
|
22
|
+
"ISO_7": { category: "Style",
|
|
23
|
+
error: "%s is not permitted in a subfigure", severity: 2 },
|
|
24
|
+
"ISO_8": { category: "Style",
|
|
25
|
+
error: "Reference does not have an associated footnote indicating unpublished status",
|
|
26
|
+
severity: 2 },
|
|
27
|
+
"ISO_9": { category: "Document Attributes",
|
|
28
|
+
error: "Illegal document stage: %s.%s", severity: 2 },
|
|
29
|
+
"ISO_10": { category: "Style", error: "No English Title Intro!",
|
|
30
|
+
severity: 2 },
|
|
31
|
+
"ISO_11": { category: "Style", error: "No French Title Intro!",
|
|
32
|
+
severity: 2 },
|
|
33
|
+
"ISO_12": { category: "Style", error: "No English Title!",
|
|
34
|
+
severity: 2 },
|
|
35
|
+
"ISO_13": { category: "Style", error: "No French Title!", severity: 2 },
|
|
36
|
+
"ISO_14": { category: "Style", error: "No English Title Part!",
|
|
37
|
+
severity: 2 },
|
|
38
|
+
"ISO_15": { category: "Style", error: "No French Title Part!",
|
|
39
|
+
severity: 2 },
|
|
40
|
+
"ISO_16": { category: "Style",
|
|
41
|
+
error: "Subpart defined on non-IEC document!",
|
|
42
|
+
severity: 2 },
|
|
43
|
+
"ISO_17": { category: "Style",
|
|
44
|
+
error: "Main Title may name document type",
|
|
45
|
+
severity: 2 },
|
|
46
|
+
"ISO_18": { category: "Style",
|
|
47
|
+
error: "Title Intro may name document type",
|
|
48
|
+
severity: 2 },
|
|
49
|
+
"ISO_19": { category: "Style",
|
|
50
|
+
error: "%s: each first-level subclause must have a title",
|
|
51
|
+
severity: 2 },
|
|
52
|
+
"ISO_20": { category: "Style",
|
|
53
|
+
error: "%s: all subclauses must have a title, or none",
|
|
54
|
+
severity: 2 },
|
|
55
|
+
"ISO_21": { category: "Style", error: "%s %s has not been cross-referenced within document",
|
|
56
|
+
severity: 1 },
|
|
57
|
+
"ISO_22": { category: "Style", error: "(formula) %s %s has not been cross-referenced within document",
|
|
58
|
+
severity: 2 },
|
|
59
|
+
"ISO_23": { category: "Style", error: "foreword contains subclauses",
|
|
60
|
+
severity: 2 },
|
|
61
|
+
"ISO_24": { category: "Style",
|
|
62
|
+
error: "normative references contains subclauses",
|
|
63
|
+
severity: 2 },
|
|
64
|
+
"ISO_25": { category: "Style",
|
|
65
|
+
error: "Only one Symbols and Abbreviated Terms section in the standard",
|
|
66
|
+
severity: 2 },
|
|
67
|
+
"ISO_26": { category: "Style",
|
|
68
|
+
error: "Symbols and Abbreviated Terms can only contain a definition list",
|
|
69
|
+
severity: 2 },
|
|
70
|
+
"ISO_27": { category: "Style",
|
|
71
|
+
error: "In vocabulary documents, Symbols and Abbreviated Terms are only permitted in annexes",
|
|
72
|
+
severity: 2 },
|
|
73
|
+
"ISO_28": { category: "Style", error: "(section sequencing) %s",
|
|
74
|
+
severity: 2 },
|
|
75
|
+
"ISO_29": { category: "Style", error: "Scope clause missing",
|
|
76
|
+
severity: 2 },
|
|
77
|
+
"ISO_30": { category: "Style", error: "Normative references missing",
|
|
78
|
+
severity: 2 },
|
|
79
|
+
"ISO_31": { category: "Style", error: "Terms & definitions missing",
|
|
80
|
+
severity: 2 },
|
|
81
|
+
"ISO_32": { category: "Style",
|
|
82
|
+
error: "Document must contain at least one clause",
|
|
83
|
+
severity: 2 },
|
|
84
|
+
"ISO_33": { category: "Style",
|
|
85
|
+
error: "Document must contain clause after Terms and Definitions",
|
|
86
|
+
severity: 2 },
|
|
87
|
+
"ISO_34": { category: "Style",
|
|
88
|
+
error: "Scope must not occur after Terms and Definitions",
|
|
89
|
+
severity: 2 },
|
|
90
|
+
"ISO_35": { category: "Style",
|
|
91
|
+
error: "term definition ends with period: %s",
|
|
92
|
+
severity: 2 },
|
|
93
|
+
"ISO_36": { category: "Style",
|
|
94
|
+
error: "Only annexes and references can follow clauses",
|
|
95
|
+
severity: 2 },
|
|
96
|
+
"ISO_37": { category: "Style",
|
|
97
|
+
error: "Only annexes and references can follow terms and clauses",
|
|
98
|
+
severity: 2 },
|
|
99
|
+
"ISO_38": { category: "Style",
|
|
100
|
+
error: "Document must include (references) Normative References",
|
|
101
|
+
severity: 2 },
|
|
102
|
+
"ISO_39": { category: "Style",
|
|
103
|
+
error: "Scope contains subclauses: should be succinct",
|
|
104
|
+
severity: 2 },
|
|
105
|
+
"ISO_40": { category: "Style",
|
|
106
|
+
error: "Final section must be (references) Bibliography",
|
|
107
|
+
severity: 2 },
|
|
108
|
+
"ISO_41": { category: "Style",
|
|
109
|
+
error: "There are sections after the final Bibliography",
|
|
110
|
+
severity: 2 },
|
|
111
|
+
"ISO_42": { category: "Style",
|
|
112
|
+
error: "non-ISO/IEC reference is allowed as normative only subject to the conditions in ISO/IEC DIR 2 10.2: %s",
|
|
113
|
+
severity: 2 },
|
|
114
|
+
"ISO_43": { category: "Style", error: "subclause is only child",
|
|
115
|
+
severity: 2 },
|
|
116
|
+
"ISO_44": { category: "Style",
|
|
117
|
+
error: "Single terms clause in vocabulary document should have normal Terms and definitions heading",
|
|
118
|
+
severity: 2 },
|
|
119
|
+
"ISO_45": { category: "Style",
|
|
120
|
+
error: "Multiple terms clauses in vocabulary document should have 'Terms related to' heading",
|
|
121
|
+
severity: 2 },
|
|
122
|
+
"ISO_46": { category: "Style",
|
|
123
|
+
error: "'see %s' is pointing to a normative section",
|
|
124
|
+
severity: 2 },
|
|
125
|
+
"ISO_47": { category: "Bibliography",
|
|
126
|
+
error: "'%s is not pointing to a real reference",
|
|
127
|
+
severity: 2 },
|
|
128
|
+
"ISO_48": { category: "Style",
|
|
129
|
+
error: "'see %s' is pointing to a normative reference",
|
|
130
|
+
severity: 2 },
|
|
131
|
+
"ISO_49": { category: "Style",
|
|
132
|
+
error: "undated reference %s should not contain specific elements",
|
|
133
|
+
severity: 2 },
|
|
134
|
+
"ISO_50": { category: "Style",
|
|
135
|
+
error: "only terms clauses can cross-reference terms clause (%s)",
|
|
136
|
+
severity: 2 },
|
|
137
|
+
"ISO_51": { category: "Style",
|
|
138
|
+
error: "non-terms clauses cannot cross-reference terms clause (%s)",
|
|
139
|
+
severity: 2 },
|
|
140
|
+
}.freeze
|
|
141
|
+
# rubocop:enable Naming/VariableNumber
|
|
142
|
+
|
|
143
|
+
def log_messages
|
|
144
|
+
super.merge(ISO_LOG_MESSAGES)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|