metanorma-itu 2.6.2 → 2.6.4

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,7 +1,7 @@
1
1
  module IsoDoc
2
2
  module Itu
3
3
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
- def clause1(elem)
4
+ def clause1(elem)
5
5
  clause1_super?(elem) and return super
6
6
  lbl = @xrefs.anchor(elem["id"], :label, false)
7
7
  oldsuppressheadingnumbers = @suppressheadingnumbers
@@ -11,8 +11,9 @@ module IsoDoc
11
11
  lbl.blank? || elem["unnumbered"] and return
12
12
  elem.previous =
13
13
  "<p keep-with-next='true' class='supertitle'>" \
14
- "#{labelled_autonum(@i18n.get['section'].upcase, elem["id"], lbl)}</p>"
15
- #"<span element='fmt-element-name'>#{@i18n.get['section'].upcase}</span> #{autonum(elem['id'], lbl)}</p>"
14
+ "#{labelled_autonum(@i18n.get['section'].upcase, elem['id'],
15
+ lbl)}</p>"
16
+ # "<span element='fmt-element-name'>#{@i18n.get['section'].upcase}</span> #{autonum(elem['id'], lbl)}</p>"
16
17
  end
17
18
 
18
19
  def clause1_super?(elem)
@@ -31,7 +32,7 @@ module IsoDoc
31
32
 
32
33
  def annex1_resolution(elem)
33
34
  elem.elements.first.previous = annex1_supertitle(elem)
34
- # TODO: do not alter title, alter semx/@element = title
35
+ # TODO: do not alter title, alter semx/@element = title
35
36
  t = elem.at(ns("./title")) and
36
37
  t.children = "<strong>#{to_xml(t.children)}</strong>"
37
38
  prefix_name(elem, {}, nil, "title")
@@ -49,12 +50,13 @@ module IsoDoc
49
50
  lbl = @xrefs.anchor(elem["id"], :label)
50
51
  res = elem.at(ns("//bibdata/title[@type = 'resolution']"))
51
52
  subhead = @i18n.l10n("(#{@i18n.get['to']} #{to_xml(res.children)})")
52
- "<p class='supertitle'>#{autonum(elem['id'], lbl)}<br/>#{subhead}</p>"
53
+ "<p class='supertitle'>#{autonum(elem['id'],
54
+ lbl)}<br/>#{subhead}</p>"
53
55
  end
54
56
 
55
57
  def middle_title(isoxml)
56
58
  s = isoxml.at(ns("//sections")) or return
57
- titfn = isoxml.at(ns("//note[@type = 'title-footnote']"))
59
+ isoxml.at(ns("//note[@type = 'title-footnote']"))
58
60
  case @doctype
59
61
  when "resolution"
60
62
  middle_title_resolution(isoxml, s.children.first)
@@ -62,16 +64,7 @@ module IsoDoc
62
64
  else
63
65
  middle_title_recommendation(isoxml, s.children.first)
64
66
  end
65
- #titfn and renumber_footnotes(isoxml)
66
- end
67
-
68
- # KILL
69
- def renumber_footnotesx(isoxml)
70
- (isoxml.xpath(ns("//fn")) -
71
- isoxml.xpath(ns("//table//fn | //figure//fn")))
72
- .each_with_index do |fn, i|
73
- fn["reference"] = (i + 1).to_s
74
- end
67
+ # titfn and renumber_footnotes(isoxml)
75
68
  end
76
69
 
77
70
  def middle_title_resolution(isoxml, out)
@@ -134,16 +134,8 @@ module IsoDoc
134
134
  { group: "'" }
135
135
  end
136
136
 
137
- def ol_depth(node)
138
- node["class"] == "steps" ||
139
- node.at(".//ancestor::xmlns:ol[@class = 'steps']") or return super
140
- depth = node.ancestors("ul, ol").size + 1
141
- type = :arabic
142
- type = :alphabet if [2, 7].include? depth
143
- type = :roman if [3, 8].include? depth
144
- type = :alphabet_upper if [4, 9].include? depth
145
- type = :roman_upper if [5, 10].include? depth
146
- type
137
+ def ul_label_list(_elem)
138
+ %w(&#x2013; &#x2022; &#x6f;)
147
139
  end
148
140
 
149
141
  def dl(xml)
@@ -2,7 +2,25 @@ require "isodoc"
2
2
  require "fileutils"
3
3
  require_relative "xref_section"
4
4
 
5
+
5
6
  module IsoDoc
7
+ module XrefGen
8
+ module OlTypeProvider
9
+ def ol_type(list, depth)
10
+ steps = list["class"] == "steps" ||
11
+ list.at(".//ancestor::xmlns:ol[@class = 'steps']")
12
+ !steps && list["type"] and return list["type"].to_sym if list["type"]
13
+ type = steps ? :arabic : :alphabet
14
+ type = (steps ? :alphabet : :arabic) if [2, 7].include? depth
15
+ type = :roman if [3, 8].include? depth
16
+ type = :alphabet_upper if [4, 9].include? depth
17
+ type = :roman_upper if [5, 10].include? depth
18
+ type
19
+ end
20
+ end
21
+ end
22
+
23
+
6
24
  module Itu
7
25
  class Counter < IsoDoc::XrefGen::Counter
8
26
  def print
@@ -82,7 +100,7 @@ module IsoDoc
82
100
  @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] +
83
101
  delim_wrap("-") + semx(elem, sublabel)
84
102
  x = @anchors[elem.parent["id"]][:container] and
85
- @anchors[elem["id"]][:container] = x
103
+ @anchors[elem["id"]][:container] = x
86
104
  end
87
105
  end
88
106
 
@@ -44,9 +44,13 @@ module IsoDoc
44
44
  def annex_name_lbl(clause, num)
45
45
  lbl = annextype(clause)
46
46
  if @doctype == "resolution"
47
- l10n("<span class='fmt-element-name'>#{lbl.upcase}</span> #{semx(clause, num)}")
47
+ l10n("<span class='fmt-element-name'>#{lbl.upcase}</span> #{semx(
48
+ clause, num
49
+ )}")
48
50
  else
49
- l10n("<strong><span class='fmt-caption-label'><span class='fmt-element-name'>#{lbl}</span> #{semx(clause, num)}</span></strong>")
51
+ l10n("<strong><span class='fmt-caption-label'><span class='fmt-element-name'>#{lbl}</span> #{semx(
52
+ clause, num
53
+ )}</span></strong>")
50
54
  end
51
55
  end
52
56
 
@@ -56,30 +60,12 @@ module IsoDoc
56
60
  { label: annex_name_lbl(clause, num),
57
61
  elem: lbl,
58
62
  type: "clause", value: num.to_s, level: level,
59
- #xref: l10n("#{lbl} #{num}") }
60
- xref: labelled_autonum(lbl, num)
61
- }
62
- end
63
-
64
- # KILL
65
- def annex_names1x(clause, parentnum, num, level)
66
- lbl = clause_number_semx(parentnum, clause, num)
67
- #require 'debug'; binding.b
68
- @anchors[clause["id"]] =
69
- { label: lbl, elem: @labels["annex_subclause"],
70
- xref: @doctype == "resolution" ? lbl : labelled_autonum(@labels['annex_subclause'], lbl), # l10n("#{@labels['annex_subclause']} #{num}"),
71
- level: level, type: "clause" }
72
- i = Counter.new(0)
73
- clause.xpath(ns("./clause | ./references | ./terms | ./definitions"))
74
- .each do |c|
75
- #require 'debug'; binding.b
76
- annex_names1(c, lbl, i.increment(c).print, level + 1)
77
- end
63
+ xref: labelled_autonum(lbl, num) }
78
64
  end
79
65
 
80
66
  def annex_name_anchors1(clause, lbl, level)
81
- xref = labelled_autonum(@labels['annex_subclause'], lbl)
82
- @doctype == "resolution" and xref = lbl
67
+ xref = labelled_autonum(@labels["annex_subclause"], lbl)
68
+ @doctype == "resolution" and xref = lbl
83
69
  @anchors[clause["id"]] =
84
70
  { label: lbl, elem: @labels["annex_subclause"],
85
71
  xref: xref, level: level, type: "clause" }
@@ -105,7 +91,7 @@ module IsoDoc
105
91
  elem = @doctype == "resolution" ? @labels["section"] : @labels["clause"]
106
92
  lbl = semx(clause, num.print)
107
93
  @anchors[clause["id"]] =
108
- { label: lbl, xref: labelled_autonum(elem, lbl),# l10n("#{lbl} #{num.print}"),
94
+ { label: lbl, xref: labelled_autonum(elem, lbl),
109
95
  level: lvl, type: "clause", elem: elem }
110
96
  i = Counter.new(0)
111
97
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -116,7 +102,7 @@ module IsoDoc
116
102
 
117
103
  def section_names1(clause, parentnum, num, level)
118
104
  lbl = clause_number_semx(parentnum, clause, num)
119
- x = @doctype == "resolution" ? semx(clause, lbl) : labelled_autonum(@labels['clause'], lbl) #l10n("#{@labels['clause']} #{num}")
105
+ x = @doctype == "resolution" ? semx(clause, lbl) : labelled_autonum(@labels["clause"], lbl) # l10n("#{@labels['clause']} #{num}")
120
106
  @anchors[clause["id"]] =
121
107
  { label: lbl, level: level,
122
108
  elem: @doctype == "resolution" ? "" : @labels["clause"],
@@ -131,8 +117,7 @@ module IsoDoc
131
117
  clause.nil? and return
132
118
  lbl = clause.at(ns("./title"))&.text || "[#{clause['id']}]"
133
119
  @anchors[clause["id"]] =
134
- { label: lbl,
135
- # xref: l10n(%{"#{lbl}"}),
120
+ { label: lbl,
136
121
  xref: semx(clause, lbl),
137
122
  level: lvl,
138
123
  type: "clause" }
@@ -145,7 +130,6 @@ module IsoDoc
145
130
  lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
146
131
  @anchors[clause["id"]] =
147
132
  { label: lbl,
148
- #xref: l10n(%{"#{lbl}"}),
149
133
  xref: semx(clause, lbl),
150
134
  level: level,
151
135
  type: "clause" }
@@ -382,33 +382,7 @@ in a document (e.g. sourcecode annotations)</a:documentation>
382
382
  <a:documentation>Block intended to capture reviewer comments about some text in the document</a:documentation>
383
383
  <element name="review">
384
384
  <ref name="RequiredId"/>
385
- <attribute name="reviewer">
386
- <a:documentation>The party who has offered the comment</a:documentation>
387
- </attribute>
388
- <optional>
389
- <attribute name="type">
390
- <a:documentation>The type of reviewer comment</a:documentation>
391
- </attribute>
392
- </optional>
393
- <optional>
394
- <attribute name="date">
395
- <a:documentation>The date when the comment was made</a:documentation>
396
- <data type="dateTime"/>
397
- </attribute>
398
- </optional>
399
- <optional>
400
- <attribute name="from">
401
- <a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
402
- If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
403
- <data type="IDREF"/>
404
- </attribute>
405
- </optional>
406
- <optional>
407
- <attribute name="to">
408
- <a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
409
- <data type="IDREF"/>
410
- </attribute>
411
- </optional>
385
+ <ref name="ReviewAttributes"/>
412
386
  <oneOrMore>
413
387
  <ref name="paragraph">
414
388
  <a:documentation>Reviewer comments content</a:documentation>
@@ -416,6 +390,35 @@ If not provided, the comment applies in the vicinity of the place it has been in
416
390
  </oneOrMore>
417
391
  </element>
418
392
  </define>
393
+ <define name="ReviewAttributes">
394
+ <attribute name="reviewer">
395
+ <a:documentation>The party who has offered the comment</a:documentation>
396
+ </attribute>
397
+ <optional>
398
+ <attribute name="type">
399
+ <a:documentation>The type of reviewer comment</a:documentation>
400
+ </attribute>
401
+ </optional>
402
+ <optional>
403
+ <attribute name="date">
404
+ <a:documentation>The date when the comment was made</a:documentation>
405
+ <data type="dateTime"/>
406
+ </attribute>
407
+ </optional>
408
+ <optional>
409
+ <attribute name="from">
410
+ <a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
411
+ If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
412
+ <data type="IDREF"/>
413
+ </attribute>
414
+ </optional>
415
+ <optional>
416
+ <attribute name="to">
417
+ <a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
418
+ <data type="IDREF"/>
419
+ </attribute>
420
+ </optional>
421
+ </define>
419
422
  <define name="NumberingAttributes">
420
423
  <optional>
421
424
  <attribute name="unnumbered">
@@ -857,6 +860,7 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
857
860
  <define name="tr">
858
861
  <a:documentation>Sequence of cells to be displayed as a row in a table</a:documentation>
859
862
  <element name="tr">
863
+ <ref name="TrAttributes"/>
860
864
  <oneOrMore>
861
865
  <choice>
862
866
  <ref name="td">
@@ -869,6 +873,9 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
869
873
  </oneOrMore>
870
874
  </element>
871
875
  </define>
876
+ <define name="TrAttributes">
877
+ <empty/>
878
+ </define>
872
879
  <define name="tr-no-id">
873
880
  <a:documentation>Sequence of cells to be displayed as a row in a table: optional ID attributes recursively (for use in Relaton, metadata)</a:documentation>
874
881
  <element name="tr">
@@ -1694,16 +1701,22 @@ which can be bookmarks as well as block or section references</a:documentation>
1694
1701
  <a:documentation>Inline reference to a paragraph or paragraphs, appearing as a footnote.
1695
1702
  The target of a footnote is the location it is embedded in within the text</a:documentation>
1696
1703
  <element name="fn">
1697
- <attribute name="reference">
1698
- <a:documentation>The number of the footnote, used to identify it visually</a:documentation>
1699
- </attribute>
1700
- <oneOrMore>
1701
- <ref name="paragraph">
1702
- <a:documentation>The content of the footnote</a:documentation>
1703
- </ref>
1704
- </oneOrMore>
1704
+ <ref name="FnAttributes"/>
1705
+ <ref name="FnBody"/>
1705
1706
  </element>
1706
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>
1707
1720
  <define name="callout">
1708
1721
  <a:documentation>Inline reference to a paragraph or paragraphs, appearing as annotation of source code</a:documentation>
1709
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">
@@ -62,10 +62,8 @@ module Metanorma
62
62
  nil, false, "#{@filename}.pdf")
63
63
  end
64
64
 
65
- def validate(doc)
66
- content_validate(doc)
67
- schema_validate(formattedstr_strip(doc.dup),
68
- File.join(File.dirname(__FILE__), "itu.rng"))
65
+ def schema_file
66
+ "itu.rng"
69
67
  end
70
68
 
71
69
  def style(_node, _text)
@@ -83,7 +83,6 @@ module Metanorma
83
83
  metadata_committee1(node, xml, "_#{suffix}")
84
84
  suffix += 1
85
85
  end
86
- metadata_question(node, xml)
87
86
  end
88
87
 
89
88
  def hyphenate_node_attributes(node)
@@ -216,11 +215,11 @@ module Metanorma
216
215
 
217
216
  def metadata_ext(node, xml)
218
217
  super
218
+ metadata_question(node, xml)
219
219
  metadata_recommendationstatus(node, xml)
220
220
  metadata_ip_notice(node, xml)
221
221
  metadata_techreport(node, xml)
222
222
  metadata_contribution(node, xml)
223
- structured_id(node, xml)
224
223
  end
225
224
  end
226
225
  end