metanorma-iso 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,225 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <include href="biblio-standoc.rng">
4
+ <define name="BibDataExtensionType">
5
+ <optional>
6
+ <attribute name="schema-version"/>
7
+ </optional>
8
+ <ref name="doctype"/>
9
+ <optional>
10
+ <ref name="docsubtype"/>
11
+ </optional>
12
+ <optional>
13
+ <ref name="horizontal"/>
14
+ </optional>
15
+ <ref name="editorialgroup"/>
16
+ <optional>
17
+ <ref name="approvalgroup"/>
18
+ </optional>
19
+ <zeroOrMore>
20
+ <ref name="ics"/>
21
+ </zeroOrMore>
22
+ <ref name="structuredidentifier"/>
23
+ <optional>
24
+ <ref name="stagename"/>
25
+ </optional>
26
+ <optional>
27
+ <ref name="updates_document_type"/>
28
+ </optional>
29
+ </define>
30
+ <define name="bdate">
31
+ <element name="date">
32
+ <attribute name="type">
33
+ <choice>
34
+ <ref name="BibliographicDateType"/>
35
+ <text/>
36
+ </choice>
37
+ </attribute>
38
+ <choice>
39
+ <group>
40
+ <element name="from">
41
+ <ref name="ISO8601Date"/>
42
+ </element>
43
+ <optional>
44
+ <element name="to">
45
+ <ref name="ISO8601Date"/>
46
+ </element>
47
+ </optional>
48
+ </group>
49
+ <element name="on">
50
+ <choice>
51
+ <ref name="ISO8601Date"/>
52
+ <value>--</value>
53
+ <value>–</value>
54
+ </choice>
55
+ </element>
56
+ </choice>
57
+ </element>
58
+ </define>
59
+ <define name="organization">
60
+ <element name="organization">
61
+ <oneOrMore>
62
+ <ref name="orgname"/>
63
+ </oneOrMore>
64
+ <optional>
65
+ <ref name="abbreviation"/>
66
+ </optional>
67
+ <optional>
68
+ <ref name="uri"/>
69
+ </optional>
70
+ <zeroOrMore>
71
+ <ref name="org-identifier"/>
72
+ </zeroOrMore>
73
+ <zeroOrMore>
74
+ <ref name="contact"/>
75
+ </zeroOrMore>
76
+ <optional>
77
+ <ref name="technical-committee"/>
78
+ </optional>
79
+ <optional>
80
+ <ref name="subcommittee"/>
81
+ </optional>
82
+ <optional>
83
+ <ref name="workgroup"/>
84
+ </optional>
85
+ <optional>
86
+ <ref name="secretariat"/>
87
+ </optional>
88
+ </element>
89
+ </define>
90
+ <define name="DocumentType">
91
+ <choice>
92
+ <value>international-standard</value>
93
+ <value>technical-specification</value>
94
+ <value>technical-report</value>
95
+ <value>publicly-available-specification</value>
96
+ <value>international-workshop-agreement</value>
97
+ <value>guide</value>
98
+ <value>amendment</value>
99
+ <value>technical-corrigendum</value>
100
+ <value>directive</value>
101
+ </choice>
102
+ </define>
103
+ <define name="DocumentSubtype">
104
+ <choice>
105
+ <value>specification</value>
106
+ <value>method-of-test</value>
107
+ <value>vocabulary</value>
108
+ <value>code-of-practice</value>
109
+ </choice>
110
+ </define>
111
+ <define name="structuredidentifier">
112
+ <element name="structuredidentifier">
113
+ <optional>
114
+ <attribute name="type"/>
115
+ </optional>
116
+ <group>
117
+ <ref name="documentnumber"/>
118
+ <optional>
119
+ <ref name="tc-documentnumber"/>
120
+ </optional>
121
+ </group>
122
+ </element>
123
+ </define>
124
+ <define name="editorialgroup">
125
+ <element name="editorialgroup">
126
+ <ref name="ISOProjectGroup"/>
127
+ </element>
128
+ </define>
129
+ </include>
130
+ <define name="updates_document_type">
131
+ <element name="updates-document-type">
132
+ <ref name="DocumentType"/>
133
+ </element>
134
+ </define>
135
+ <define name="ISOProjectGroup">
136
+ <zeroOrMore>
137
+ <ref name="agency"/>
138
+ </zeroOrMore>
139
+ <oneOrMore>
140
+ <ref name="technical-committee"/>
141
+ </oneOrMore>
142
+ <zeroOrMore>
143
+ <ref name="subcommittee"/>
144
+ </zeroOrMore>
145
+ <zeroOrMore>
146
+ <ref name="workgroup"/>
147
+ </zeroOrMore>
148
+ <optional>
149
+ <ref name="secretariat"/>
150
+ </optional>
151
+ </define>
152
+ <define name="approvalgroup">
153
+ <element name="approvalgroup">
154
+ <ref name="ISOProjectGroup"/>
155
+ </element>
156
+ </define>
157
+ <define name="agency">
158
+ <element name="agency">
159
+ <text/>
160
+ </element>
161
+ </define>
162
+ <define name="horizontal">
163
+ <element name="horizontal">
164
+ <data type="boolean"/>
165
+ </element>
166
+ </define>
167
+ <define name="documentnumber">
168
+ <element name="project-number">
169
+ <optional>
170
+ <attribute name="part">
171
+ <data type="int"/>
172
+ </attribute>
173
+ </optional>
174
+ <optional>
175
+ <attribute name="subpart">
176
+ <data type="int"/>
177
+ </attribute>
178
+ </optional>
179
+ <optional>
180
+ <attribute name="amendment">
181
+ <data type="int"/>
182
+ </attribute>
183
+ </optional>
184
+ <optional>
185
+ <attribute name="corrigendum">
186
+ <data type="int"/>
187
+ </attribute>
188
+ </optional>
189
+ <optional>
190
+ <attribute name="origyr">
191
+ <ref name="ISO8601Date"/>
192
+ </attribute>
193
+ </optional>
194
+ <text/>
195
+ </element>
196
+ </define>
197
+ <define name="tc-documentnumber">
198
+ <element name="tc-document-number">
199
+ <data type="int"/>
200
+ </element>
201
+ </define>
202
+ <define name="subcommittee">
203
+ <element name="subcommittee">
204
+ <ref name="IsoWorkgroup"/>
205
+ </element>
206
+ </define>
207
+ <define name="workgroup">
208
+ <element name="workgroup">
209
+ <ref name="IsoWorkgroup"/>
210
+ </element>
211
+ </define>
212
+ <define name="secretariat">
213
+ <element name="secretariat">
214
+ <text/>
215
+ </element>
216
+ </define>
217
+ <define name="stagename">
218
+ <element name="stagename">
219
+ <optional>
220
+ <attribute name="abbreviation"/>
221
+ </optional>
222
+ <text/>
223
+ </element>
224
+ </define>
225
+ </grammar>
@@ -66,7 +66,7 @@ module Metanorma
66
66
  if /^(ISO|IEC)/.match?(t["citeas"]) &&
67
67
  !/: ?(\d+{4}|–)$/.match?(t["citeas"])
68
68
  @log.add("Style", t,
69
- "undated reference #{t['citeas']} should not contain "\
69
+ "undated reference #{t['citeas']} should not contain " \
70
70
  "specific elements")
71
71
  end
72
72
  end
@@ -79,7 +79,7 @@ module Metanorma
79
79
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-r-ref_clause3
80
80
  def term_xrefs_validate(xmldoc)
81
81
  termids = xmldoc
82
- .xpath("//sections/terms | //sections/clause[.//terms] | "\
82
+ .xpath("//sections/terms | //sections/clause[.//terms] | " \
83
83
  "//annex[.//terms]").each_with_object({}) do |t, m|
84
84
  t.xpath(".//*/@id").each { |a| m[a.text] = true }
85
85
  t.name == "terms" and m[t["id"]] = true
@@ -93,11 +93,11 @@ module Metanorma
93
93
  closest_id = xref.xpath("./ancestor::*[@id]")&.last or return
94
94
  (termids[xref["target"]] && !termids[closest_id["id"]]) and
95
95
  @log.add("Style", xref,
96
- "only terms clauses can cross-reference terms clause "\
96
+ "only terms clauses can cross-reference terms clause " \
97
97
  "(#{xref['target']})")
98
98
  (!termids[xref["target"]] && termids[closest_id["id"]]) and
99
99
  @log.add("Style", xref,
100
- "non-terms clauses cannot cross-reference terms clause "\
100
+ "non-terms clauses cannot cross-reference terms clause " \
101
101
  "(#{xref['target']})")
102
102
  end
103
103
 
@@ -179,7 +179,7 @@ module Metanorma
179
179
  xmldoc.xpath("//bibitem[date/on = '–']").each do |b|
180
180
  b.at("./note[@type = 'Unpublished-Status']") or
181
181
  @log.add("Style", b,
182
- "Reference #{b&.at('./@id')&.text} does not have an "\
182
+ "Reference #{b&.at('./@id')&.text} does not have an " \
183
183
  "associated footnote indicating unpublished status")
184
184
  end
185
185
  end
@@ -191,7 +191,7 @@ module Metanorma
191
191
  when "amendment", "technical-corrigendum" # @amd
192
192
  "isostandard-amd.rng"
193
193
  else
194
- "isostandard.rng"
194
+ "isostandard-compile.rng"
195
195
  end
196
196
  schema_validate(formattedstr_strip(doc.dup),
197
197
  File.join(File.dirname(__FILE__), schema))
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.2.1".freeze
3
+ VERSION = "2.2.2".freeze
4
4
  end
5
5
  end
@@ -29,41 +29,28 @@ module Metanorma
29
29
  out
30
30
  end
31
31
 
32
- def recommend_title(node, out)
33
- label = node.at(ns("./identifier")) or return
34
- out.add_child("<tr><td>#{@labels['modspec']['identifier']}</td>"\
35
- "<td><tt>#{label.children.to_xml}</tt></td>")
36
- end
37
-
38
- def requirement_component_parse(node, out)
39
- if node["exclude"] != "true" && node.name == "description"
40
- lbl = "statement"
41
- recommend_class(node.parent) == "recommendclass" and
42
- lbl = "description"
43
- out << "<tr><td>#{@labels['modspec'][lbl]}</td>"\
44
- "<td>#{node.children.to_xml}</td></tr>"
45
- else
46
- super
47
- end
48
- end
49
-
50
- def requirement_table_cleanup(node, table)
51
- return table unless table["type"] == "recommendclass"
52
-
53
- label = if node["type"] == "conformanceclass" then "conformancetests"
54
- else "provisions" end
32
+ def requirement_table_nested_cleanup(node, table)
33
+ table["type"] == "recommendclass" or return table
55
34
  ins = table.at(ns("./tbody/tr[td/table]")) or return table
56
- ins.replace("<tr><td>#{@labels['modspec'][label]}</td>" +
57
- "<td>#{nested_tables_names(table)}</td></tr>")
35
+ ins.replace(requirement_table_cleanup_nested_replacement(node, table))
58
36
  table.xpath(ns("./tbody/tr[td/table]")).each(&:remove)
59
37
  table
60
38
  end
61
39
 
40
+ def requirement_table_cleanup_nested_replacement(node, table)
41
+ label = "provision"
42
+ node["type"] == "conformanceclass" and label = "conformancetest"
43
+ n = nested_tables_names(table)
44
+ hdr = @i18n.inflect(@labels["modspec"][label],
45
+ number: n.size == 1 ? "sg" : "pl")
46
+ "<tr><th>#{hdr}</th><td>#{n.join('<br/>')}</td></tr>"
47
+ end
48
+
62
49
  def nested_tables_names(table)
63
50
  table.xpath(ns("./tbody/tr/td/table"))
64
51
  .each_with_object([]) do |t, m|
65
52
  m << t.at(ns("./name")).children.to_xml
66
- end.join("<br/>")
53
+ end
67
54
  end
68
55
 
69
56
  def postprocess_anchor_struct(block, anchor)
@@ -86,20 +73,17 @@ module Metanorma
86
73
  end
87
74
  end
88
75
 
89
- def reqt_links_test(docxml)
90
- docxml.xpath(ns("//requirement | //recommendation | //permission"))
91
- .each_with_object({}) do |r, m|
92
- next unless %w(conformanceclass
93
- verification).include?(r["type"])
76
+ def reqt_links_test1(reqt, acc)
77
+ return unless %w(conformanceclass
78
+ verification).include?(reqt["type"])
94
79
 
95
- subj = r.at(ns("./classification[tag = 'target']/value"))
96
- id = r.at(ns("./identifier")) or next
97
- lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref_reqt2reqt,
98
- false)
99
- next unless subj
80
+ subj = reqt_extract_target(reqt)
81
+ id = reqt.at(ns("./identifier")) or return
82
+ lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref_reqt2reqt,
83
+ false)
84
+ return unless subj
100
85
 
101
- m[subj.text] = { lbl: lbl, id: r["id"] }
102
- end
86
+ acc[subj.text] = { lbl: lbl, id: reqt["id"] }
103
87
  end
104
88
 
105
89
  def reqt_links_class(docxml)
@@ -118,7 +118,7 @@ RSpec.describe IsoDoc do
118
118
 
119
119
  it "processes AsciiMath and MathML" do
120
120
  output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)
121
- <iso-standard xmlns="http://riboseinc.com/isoxml">
121
+ <iso-standard xmlns="http://riboseinc.com/isoxml" xmlns:m="http://www.w3.org/1998/Math/MathML">
122
122
  <preface>
123
123
  <foreword>
124
124
  <p>