metanorma-iec 2.6.3 → 2.6.5

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.
@@ -1,14 +1,13 @@
1
1
  module IsoDoc
2
2
  module Iec
3
3
  class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
4
- def termclause1(elem)
5
- @is_iev or return clause1(elem)
4
+ def iev_termclause1(elem)
6
5
  @suppressheadingnumbers || elem["unnumbered"] or
7
- lbl = @xrefs.anchor(elem["id"], :label, true)
6
+ lbl = @xrefs.anchor(elem["id"], :label, true)
8
7
  if lbl
9
- prefix_name(elem, { caption: " " }, "#{lbl}#{clausedelim}", "title")
8
+ prefix_name(elem, { caption: " " }, "#{lbl}#{clausedelim}", "title")
10
9
  else
11
- prefix_name(elem, {}, nil, "title")
10
+ prefix_name(elem, {}, nil, "title")
12
11
  end
13
12
  end
14
13
 
@@ -46,8 +45,8 @@ module IsoDoc
46
45
 
47
46
  def termdomain(elem, fmt_defn)
48
47
  if @is_iev
49
- #d = elem.at(ns("./domain")) or return
50
- #d["hidden"] = true
48
+ # d = elem.at(ns("./domain")) or return
49
+ # d["hidden"] = true
51
50
  else super
52
51
  end
53
52
  end
@@ -60,19 +59,21 @@ module IsoDoc
60
59
  end
61
60
  # renumber
62
61
  @xrefs.parse_inclusions(clauses: true).parse docxml
63
- docxml.xpath(ns("//term/fmt-name | //term/fmt-xref-label")).each(&:remove)
62
+ docxml.xpath(ns("//term/fmt-name | //term/fmt-xref-label"))
63
+ .each(&:remove)
64
64
  term(docxml)
65
65
  end
66
66
 
67
67
  def merge_fr_into_en_term1(en_term, fr_term)
68
68
  dl = en_term&.at(ns("./dl[@type = 'other-lang']"))&.remove
69
- #en_term << fr_term.remove.children
69
+ # en_term << fr_term.remove.children
70
70
  dup = semx_fmt_dup(fr_term)
71
71
  dup.xpath(ns("./fmt-name | ./fmt-xref-label")).each(&:remove)
72
72
  en_term << dup
73
73
  fr_term.xpath(ns(".//fmt-name | .//fmt-xref-label | " \
74
74
  ".//fmt-preferred | .//fmt-admitted | .//fmt-deprecates | " \
75
- ".//fmt-definition | .//fmt-related | .//fmt-termsource")).each(&:remove)
75
+ ".//fmt-definition | .//fmt-related | .//fmt-termsource"))
76
+ .each(&:remove)
76
77
  fr_term["unnumbered"] = "true"
77
78
  en_term << dl if dl
78
79
  en_term["language"] = "en,fr"
@@ -89,28 +90,15 @@ module IsoDoc
89
90
  def remove_otherlang_designations(docxml)
90
91
  @is_iev or return
91
92
  docxml.xpath(ns("//term")).each do |t|
92
- remove_otherlang_designations1(t, t["language"]&.split(",") || %w(en fr))
93
+ remove_otherlang_designations1(t,
94
+ t["language"]&.split(",") || %w(en fr))
93
95
  end
94
96
  end
95
97
 
96
- # KILL
97
98
  def extract_otherlang_designations(term, lgs)
98
99
  term.xpath(ns(".//preferred/expression[@language]"))
99
100
  .each_with_object([]) do |d, m|
100
101
  lg = d["language"]
101
- d.delete("language")
102
- lgs.include?(lg) and next
103
- p = d.parent
104
- designation_annotate(p, p.at(ns("./name")))
105
- m << { lang: lg, script: Metanorma::Utils.default_script(lg),
106
- designation: to_xml(l10n_recursive(p.remove, lg)).strip }
107
- end
108
- end
109
-
110
- def extract_otherlang_designations(term, lgs)
111
- term.xpath(ns(".//preferred/expression[@language]"))
112
- .each_with_object([]) do |d, m|
113
- lg = d["language"]
114
102
  lgs.include?(lg) and next
115
103
  p = semx_fmt_dup(d.parent)
116
104
  e = p.at(ns("./expression"))
@@ -156,52 +144,32 @@ module IsoDoc
156
144
  end
157
145
 
158
146
  def remove_otherlang_designations1(term, lgs)
159
- term.xpath(ns(".//fmt-preferred/p/semx[@element = 'preferred']")).each do |s|
147
+ term.xpath(ns(".//fmt-preferred/p/semx[@element = 'preferred']"))
148
+ .each do |s|
160
149
  p = semx_orig(s, term)
161
150
  lg = p.at(ns("./expression/@language"))&.text or next
162
151
  lgs.include?(lg) and next
163
152
  s.parent.remove
164
- end
153
+ end
165
154
  end
166
155
 
167
156
  def related(docxml)
168
- #docxml.xpath(ns("//term[related]")).each { |f| move_related(f) }
169
157
  super
170
158
  docxml.xpath(ns("//term[related]")).each { |f| move_related(f) }
171
159
  end
172
160
 
173
- # KILL
174
- def move_related(term)
175
- defn = term.at(ns("./definition")) or return
176
- term.xpath(ns("./related")).reverse_each do |r|
177
- defn.next = r.remove
178
- end
179
- end
180
-
181
161
  def move_related(term)
182
162
  defn = term.at(ns("./fmt-definition")) or return
183
163
  rel = term.at(ns("./fmt-related")) or return
184
164
  defn << rel.children
185
165
  end
186
166
 
187
- # KILL
188
167
  def related1(node)
189
168
  lg = node.at("./ancestor::xmlns:term/@language")&.text
190
169
  @i18n = @i18n_lg[lg] if lg && @i18n_lg[lg]
191
- p = node.at(ns("./preferred"))
192
- ref = node.at(ns("./xref | ./eref | ./termref"))
193
- label = @i18n.relatedterms[node["type"]].upcase
194
- node.replace(l10n("<p>#{label}: " \
195
- "#{to_xml(p.children)} (#{to_xml(ref)})</p>"))
196
- @i18n = @i18n_lg["default"]
197
- end
198
-
199
- def related1(node)
200
- lg = node.at("./ancestor::xmlns:term/@language")&.text
201
- @i18n = @i18n_lg[lg] if lg && @i18n_lg[lg]
202
170
  p, ref, orig = related1_prep(node)
203
- label = @i18n.relatedterms[orig["type"]].upcase
204
- node.children =(l10n("<p>#{label}: " \
171
+ label = @i18n.relatedterms[orig["type"]].upcase
172
+ node.children = (l10n("<p>#{label}: " \
205
173
  "#{to_xml(p)} (#{Common::to_xml(ref)})</p>"))
206
174
  @i18n = @i18n_lg["default"]
207
175
  end
@@ -213,31 +181,13 @@ module IsoDoc
213
181
  @i18n = @i18n_lg["default"]
214
182
  end
215
183
 
216
- # KILL
217
- def termsource1xx(node)
218
- lg = node&.at("./ancestor::xmlns:term/@language")&.text
219
- @i18n = @i18n_lg[lg] if lg && @i18n_lg[lg]
220
- if @is_iev then termsource1_iev(node)
221
- else super
222
- end
223
- @i18n = @i18n_lg["default"]
224
- end
225
-
226
- # KILL
227
- def termsource1_iev(elem)
228
- while elem&.next_element&.name == "termsource"
229
- elem << "; #{to_xml(elem.next_element.remove.children)}"
230
- end
231
- elem.children = l10n("#{@i18n.source}: #{to_xml(elem.children).strip}")
232
- end
233
-
234
184
  def termsource_label(elem, sources)
235
185
  @is_iev or return super
236
186
  lg = elem&.at("./ancestor::xmlns:term/@language")&.text
237
187
  @i18n = @i18n_lg[lg] if lg && @i18n_lg[lg]
238
- elem.replace(l10n("#{@i18n.source}: #{sources}"))
239
- @i18n = @i18n_lg["default"]
240
- end
188
+ elem.replace(l10n("#{@i18n.source}: #{sources}"))
189
+ @i18n = @i18n_lg["default"]
190
+ end
241
191
 
242
192
  def termexample(docxml)
243
193
  docxml.xpath(ns("//termexample")).each do |f|
@@ -247,7 +197,6 @@ module IsoDoc
247
197
 
248
198
  def termexample1(elem)
249
199
  lg = elem&.at("./ancestor::xmlns:term/@language")&.text
250
- #require "debug"; binding.b
251
200
  @i18n = @i18n_lg[lg] if lg && @i18n_lg[lg]
252
201
  example1(elem)
253
202
  @i18n = @i18n_lg["default"]
@@ -263,11 +212,6 @@ module IsoDoc
263
212
  @i18n = @i18n_lg["default"]
264
213
  ret
265
214
  end
266
-
267
- def term1(elem)
268
- #require 'debug'; binding.b
269
- super
270
- end
271
215
  end
272
216
  end
273
217
  end
@@ -14,21 +14,18 @@ module IsoDoc
14
14
  @i18n_lg["default"] = @i18n
15
15
  end
16
16
 
17
- def clause(docxml)
18
- docxml.xpath(ns("//clause | //definitions | //references | //appendix | " \
19
- "//introduction | //foreword | //preface/abstract | " \
20
- "//acknowledgements | //colophon | //indexsect "))
21
- .each do |f|
22
- f.parent.name == "annex" &&
23
- @xrefs.klass.single_term_clause?(f.parent) and next
24
- clause1(f)
25
- end
17
+ # KILL
18
+ def clausex(docxml)
19
+ super
26
20
  docxml.xpath(ns("//terms")).each { |f| termclause1(f) }
27
21
  end
28
22
 
29
23
  def clause1(elem)
24
+ if elem.name == "terms" && @is_iev then iev_termclause1(elem)
25
+ else
30
26
  IsoDoc::PresentationXMLConvert.instance_method(:clause1).bind(self)
31
27
  .call(elem)
28
+ end
32
29
  end
33
30
 
34
31
  DICT_PATHS = { doctype_dict: "./ext/doctype",
@@ -71,7 +68,7 @@ module IsoDoc
71
68
  ins = elem.at(ns("./title")) || elem.children.first.before(" ").previous
72
69
  ins.next = <<~CLAUSE
73
70
  <clause type='boilerplate_legal'>#{to_xml(boilerplate.children)}</clause>
74
- CLAUSE
71
+ CLAUSE
75
72
  end
76
73
 
77
74
  def insert_middle_title(docxml)
@@ -124,6 +121,10 @@ module IsoDoc
124
121
  s.add_first_child ret
125
122
  end
126
123
 
124
+ def ul_label_list(_elem)
125
+ %w(&#x2022; &#x2014; &#x6f;)
126
+ end
127
+
127
128
  include Init
128
129
  end
129
130
  end
@@ -1701,16 +1701,22 @@ which can be bookmarks as well as block or section references</a:documentation>
1701
1701
  <a:documentation>Inline reference to a paragraph or paragraphs, appearing as a footnote.
1702
1702
  The target of a footnote is the location it is embedded in within the text</a:documentation>
1703
1703
  <element name="fn">
1704
- <attribute name="reference">
1705
- <a:documentation>The number of the footnote, used to identify it visually</a:documentation>
1706
- </attribute>
1707
- <oneOrMore>
1708
- <ref name="paragraph">
1709
- <a:documentation>The content of the footnote</a:documentation>
1710
- </ref>
1711
- </oneOrMore>
1704
+ <ref name="FnAttributes"/>
1705
+ <ref name="FnBody"/>
1712
1706
  </element>
1713
1707
  </define>
1708
+ <define name="FnBody">
1709
+ <oneOrMore>
1710
+ <ref name="paragraph">
1711
+ <a:documentation>The content of the footnote</a:documentation>
1712
+ </ref>
1713
+ </oneOrMore>
1714
+ </define>
1715
+ <define name="FnAttributes">
1716
+ <attribute name="reference">
1717
+ <a:documentation>The number of the footnote, used to identify it visually</a:documentation>
1718
+ </attribute>
1719
+ </define>
1714
1720
  <define name="callout">
1715
1721
  <a:documentation>Inline reference to a paragraph or paragraphs, appearing as annotation of source code</a:documentation>
1716
1722
  <element name="callout">
@@ -1,13 +1,14 @@
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">
3
- <!--
4
- Add-ons to biblio.rnc for standoc model: defines the extension point BibDataExtensionType
5
- of relaton
6
-
7
- Specialisations as for biblio.rnc. Extension point can be redefined completely for a flavour of standoc
8
- (SDO); but other elements in Bibdata can only be extended (more specialised vocabularies for Bibdata)
9
- -->
10
3
  <include href="biblio.rng">
4
+ <!-- ALERT: we cannot have comments on root element, as they intervene with https://github.com/metanorma/metanorma/issues/437 fix -->
5
+ <!--
6
+ Add-ons to biblio.rnc for standoc model: defines the extension point BibDataExtensionType
7
+ of relaton
8
+
9
+ Specialisations as for biblio.rnc. Extension point can be redefined completely for a flavour of standoc
10
+ (SDO); but other elements in Bibdata can only be extended (more specialised vocabularies for Bibdata)
11
+ -->
11
12
  <define name="BibData">
12
13
  <a:documentation>The bibliographic description of a standardisation document</a:documentation>
13
14
  <ref name="StandardBibliographicItem"/>
@@ -91,6 +92,9 @@ a standards definition organization</a:documentation>
91
92
  <a:documentation>Representation of the identifier for the standardisation document, giving its individual semantic components</a:documentation>
92
93
  </ref>
93
94
  </zeroOrMore>
95
+ <ref name="DocumentImages">
96
+ <a:documentation>Coverpage and other images to be rendered with document</a:documentation>
97
+ </ref>
94
98
  </define>
95
99
  <define name="doctype">
96
100
  <a:documentation>Classification of the standardisation document</a:documentation>
@@ -268,6 +272,32 @@ and not those document components</a:documentation>
268
272
  </optional>
269
273
  </element>
270
274
  </define>
275
+ <define name="DocumentImages">
276
+ <zeroOrMore>
277
+ <element name="coverpage-image">
278
+ <a:documentation>Images to be displayed on the coverpage of the document</a:documentation>
279
+ <ref name="image-no-id"/>
280
+ </element>
281
+ </zeroOrMore>
282
+ <zeroOrMore>
283
+ <element name="innercoverpage-image">
284
+ <a:documentation>Images to be displayed on the inner coverpage of the document</a:documentation>
285
+ <ref name="image-no-id"/>
286
+ </element>
287
+ </zeroOrMore>
288
+ <zeroOrMore>
289
+ <element name="tocside-image">
290
+ <a:documentation>Images to be displayed on the Table of Contents page of the document</a:documentation>
291
+ <ref name="image-no-id"/>
292
+ </element>
293
+ </zeroOrMore>
294
+ <zeroOrMore>
295
+ <element name="backpage-image">
296
+ <a:documentation>Images to be displayed on the backpage of the document</a:documentation>
297
+ <ref name="image-no-id"/>
298
+ </element>
299
+ </zeroOrMore>
300
+ </define>
271
301
  <define name="StandardBibliographicItem">
272
302
  <ref name="BibliographicItem"/>
273
303
  <zeroOrMore>
@@ -1,23 +1,25 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <!--
3
- instantiations of this grammar may replace leaf strings
4
- with more elaborated types; e.g. title (text) replaced with
5
- title-main, title-intro, title-part; type replaced with
6
- enum.
7
-
8
- some renaming at leaf nodes is permissible
9
-
10
- obligations can change both from optional to mandatory,
11
- and from mandatory to optional; optional elements may
12
- be omitted; freely positioned alternatives may be replaced
13
- with strict ordering
14
-
15
- DO NOT introduce a namespace here. We do not want a distinct namespace
16
- for these elements, and a distinct namespace for any grammar inheriting
17
- these elements; we just want one namespace for any child grammars
18
- of this.
19
- -->
20
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
+ <!--
4
+ ALERT: we cannot have comments on root element, as they intervene with https://github.com/metanorma/metanorma/issues/437 fix
5
+
6
+ Instantiations of this grammar may replace leaf strings
7
+ with more elaborated types; e.g. title (text) replaced with
8
+ title-main, title-intro, title-part; type replaced with
9
+ enum.
10
+
11
+ Some renaming at leaf nodes is permissible
12
+
13
+ Obligations can change both from optional to mandatory,
14
+ and from mandatory to optional; optional elements may
15
+ be omitted; freely positioned alternatives may be replaced
16
+ with strict ordering
17
+
18
+ DO NOT introduce a namespace here. We do not want a distinct namespace
19
+ for these elements, and a distinct namespace for any grammar inheriting
20
+ these elements; we just want one namespace for any child grammars
21
+ of this.
22
+ -->
21
23
  <!--
22
24
  https://www.myintervals.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/
23
25
  iso8601date = xsd:string { pattern = "([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?" }
@@ -1241,6 +1243,11 @@ Refer to `BibliographicItem` for definitions</a:documentation>
1241
1243
  </define>
1242
1244
  <define name="formattedref">
1243
1245
  <element name="formattedref">
1246
+ <optional>
1247
+ <attribute name="format">
1248
+ <a:documentation>format of formatted reference; Metanorma assumes references are formatted as Metanorma XML</a:documentation>
1249
+ </attribute>
1250
+ </optional>
1244
1251
  <oneOrMore>
1245
1252
  <ref name="TextElement"/>
1246
1253
  </oneOrMore>
@@ -1812,6 +1819,11 @@ May be used to differentiate rendering of notes in bibliographies</a:documentati
1812
1819
  <a:documentation>Abstract of bibliographic item</a:documentation>
1813
1820
  <element name="abstract">
1814
1821
  <ref name="LocalizedStringAttributes"/>
1822
+ <optional>
1823
+ <attribute name="format">
1824
+ <a:documentation>What format the formatted abstract is in. In Metanorma, assumed to be Metanorma XML</a:documentation>
1825
+ </attribute>
1826
+ </optional>
1815
1827
  <choice>
1816
1828
  <oneOrMore>
1817
1829
  <ref name="BasicBlockNoId">
@@ -45,10 +45,8 @@ module Metanorma
45
45
  end
46
46
  end
47
47
 
48
- def validate(doc)
49
- content_validate(doc)
50
- schema_validate(formattedstr_strip(doc.dup),
51
- File.join(File.dirname(__FILE__), "iec.rng"))
48
+ def schema_file
49
+ "iec.rng"
52
50
  end
53
51
 
54
52
  def html_converter(node)
@@ -157,7 +155,6 @@ module Metanorma
157
155
  end
158
156
 
159
157
  # TODO remove when I adopt pubid-iec
160
- #
161
158
  def get_id_prefix(xmldoc)
162
159
  xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']" \
163
160
  "/organization").each_with_object([]) do |x, prefix|
@@ -157,13 +157,9 @@ module Metanorma
157
157
  @log.add("Document Attributes", nil, err)
158
158
  end
159
159
 
160
- def metadata_subdoctype(node, xml)
161
- super
162
- a = node.attr("function") and xml.function a
163
- end
164
-
165
160
  def metadata_ext(node, xml)
166
161
  super
162
+ a = node.attr("function") and xml.function a
167
163
  a = node.attr("accessibility-color-inside") and
168
164
  xml.accessibility_color_inside a
169
165
  a = node.attr("cen-processing") and xml.cen_processing a
@@ -1,25 +1,10 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!--
4
- VERSION v1.2.1
5
- default namespace = "https://www.metanorma.com/ns/iec"
6
- -->
2
+ <grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0">
7
3
  <include href="relaton-iec.rng"/>
8
4
  <include href="isostandard.rng">
9
5
  <define name="term">
10
6
  <element name="term">
11
- <optional>
12
- <attribute name="id">
13
- <data type="ID"/>
14
- </attribute>
15
- </optional>
16
- <optional>
17
- <attribute name="language"/>
18
- </optional>
19
- <optional>
20
- <attribute name="script"/>
21
- </optional>
22
- <ref name="BlockAttributes"/>
7
+ <ref name="TermAttributes"/>
23
8
  <oneOrMore>
24
9
  <ref name="preferred"/>
25
10
  </oneOrMore>
@@ -47,36 +32,6 @@
47
32
  </zeroOrMore>
48
33
  </element>
49
34
  </define>
50
- <!--
51
- We display the Normative References between scope and terms; but to keep the
52
- grammar simple, we keep the references together
53
- -->
54
- <define name="standard-document">
55
- <element name="metanorma">
56
- <ref name="Root-Attributes"/>
57
- <ref name="bibdata"/>
58
- <zeroOrMore>
59
- <ref name="termdocsource"/>
60
- </zeroOrMore>
61
- <optional>
62
- <ref name="misccontainer"/>
63
- </optional>
64
- <optional>
65
- <ref name="boilerplate"/>
66
- </optional>
67
- <ref name="preface"/>
68
- <oneOrMore>
69
- <ref name="sections"/>
70
- </oneOrMore>
71
- <zeroOrMore>
72
- <ref name="annex"/>
73
- </zeroOrMore>
74
- <ref name="bibliography"/>
75
- <zeroOrMore>
76
- <ref name="indexsect"/>
77
- </zeroOrMore>
78
- </element>
79
- </define>
80
35
  </include>
81
36
  </grammar>
82
37
  <!-- end overrides -->