metanorma-ieee 1.4.3 → 1.4.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,6 +1,7 @@
1
1
  require_relative "init"
2
2
  require_relative "presentation_bibdata"
3
3
  require_relative "presentation_terms"
4
+ require_relative "presentation_concepts"
4
5
  require_relative "presentation_ref"
5
6
  require "isodoc"
6
7
 
@@ -35,7 +36,7 @@ module IsoDoc
35
36
  end
36
37
 
37
38
  def subclause?(target, type, from)
38
- (from&.match?(/\./) && type == "clause") ||
39
+ (from&.include?(".") && type == "clause") ||
39
40
  target&.gsub(/<[^<>]+>/, "")&.match?(/^IEV$|^IEC 60050-/)
40
41
  end
41
42
 
@@ -104,16 +105,7 @@ module IsoDoc
104
105
  end
105
106
 
106
107
  def annex_delim(_elem)
107
- "<br/>"
108
- end
109
-
110
- # KILL
111
- def annex1_default(elem)
112
- lbl = @xrefs.anchor(elem["id"], :label)
113
- if t = elem.at(ns("./title"))
114
- t.children = "<strong>#{to_xml(t.children)}</strong>"
115
- end
116
- prefix_name(elem, { caption: "<br/>" }, lbl, "title")
108
+ "<br/>"
117
109
  end
118
110
 
119
111
  def amend1(elem)
@@ -184,6 +176,8 @@ module IsoDoc
184
176
  end
185
177
  end
186
178
 
179
+ # overrides IsoDoc:: XrefGen::OlTypeProvider: we trigger
180
+ # @xrefs.list_anchor_names after this is called, with elem["type"] set
187
181
  def ol_depth_rotate(node, idx)
188
182
  depth = node.ancestors("ol").size + idx
189
183
  type = :alphabet
@@ -192,6 +186,15 @@ module IsoDoc
192
186
  type
193
187
  end
194
188
 
189
+ def ul_label_list(_elem)
190
+ if @doctype == "whitepaper" ||
191
+ %w(icap industry-connection-report).include?(@subdoctype)
192
+ %w(&#x25aa; &#x2014;)
193
+ else
194
+ %w(&#x2013;)
195
+ end
196
+ end
197
+
195
198
  def middle_title(docxml)
196
199
  s = middle_title_insert(docxml) or return
197
200
  s.previous = middle_title_body
@@ -50,13 +50,14 @@ module IsoDoc
50
50
  "#{@klass.norm_ref_xpath} | //sections/terms | " \
51
51
  "//sections/definitions | //clause[parent::sections]"
52
52
  if @hierarchical_assets
53
- hierarchical_asset_names(doc.xpath("//xmlns:preface/child::*"), "Preface")
53
+ hierarchical_asset_names(doc.xpath("//xmlns:preface/child::*"),
54
+ "Preface")
54
55
  doc.xpath(ns(middle_sections)).each do |c|
55
56
  hierarchical_asset_names(c, @anchors[c["id"]][:label])
56
57
  end
57
58
  else
58
- sequential_asset_names(doc.xpath(ns("//preface/* | " + middle_sections)))
59
- #sequential_asset_names(doc.xpath(ns(middle_sections)))
59
+ sequential_asset_names(doc.xpath(ns("//preface/* | #{middle_sections}")))
60
+ # sequential_asset_names(doc.xpath(ns(middle_sections)))
60
61
  end
61
62
  end
62
63
 
@@ -77,20 +78,12 @@ module IsoDoc
77
78
  sequence = UUIDTools::UUID.random_create.to_s
78
79
  notes = t.xpath(ns("./termnote"))
79
80
  notes.noblank.each do |n|
80
- @anchors[n["id"]] =
81
- { label: termnote_label(n, increment_label(notes, n, c)), type: "termnote",
81
+ @anchors[n["id"]] =
82
+ { label: termnote_label(n, increment_label(notes, n, c)),
82
83
  value: c.print, elem: @labels["termnote"],
83
- container: t["id"],
84
+ container: t["id"], type: "termnote",
84
85
  xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) }
85
- .merge(sequence: sequence)
86
- =begin
87
- anchor_struct(
88
- termnote_label(n, increment_label(notes, n, c)),
89
- #labelled_autonum(@labels["termnote"], increment_label(notes, n, c)),
90
- #"#{@labels['termnote']} #{increment_label(notes, n, c)}",
91
- n, @labels["note_xref"], "termnote", { container: true })
92
86
  .merge(sequence: sequence)
93
- =end
94
87
  end
95
88
  end
96
89
  end
@@ -111,7 +104,7 @@ module IsoDoc
111
104
  if @doctype == "whitepaper"
112
105
  title = Common::case_with_markup(@labels["annex"], "capital",
113
106
  @script)
114
- l10n(labelled_autonum(title, num))
107
+ l10n(labelled_autonum(title, num))
115
108
  else super
116
109
  end
117
110
  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">
@@ -31,23 +31,25 @@ module Metanorma
31
31
 
32
32
  # Alphabetic by rendering: author surname or designation, followed by title
33
33
  def sort_biblio_key(bib)
34
- name = designator_or_name(bib)
34
+ name, docid = designator_or_name(bib)
35
35
  title = bib.at("./title[@type = 'main']")&.text ||
36
36
  bib.at("./title")&.text || bib.at("./formattedref")&.text
37
37
  title.gsub!(/[[:punct:]]/, "")
38
- @c.decode("#{name} #{title}").strip.downcase
38
+ @c.decode("#{name} #{title} #{docid}").strip.downcase
39
39
  end
40
40
 
41
41
  def designator_or_name(bib)
42
- case bib["type"]
43
- when "standard", "techreport" then designator_docid(bib)
44
- else
45
- bib1 = bib.dup
46
- bib1.add_namespace(nil, self.class::XML_NAMESPACE)
47
- n = @i.creatornames(bib1)
48
- n.nil? && bib["type"].nil? and n = designator_docid(bib)
49
- n
50
- end
42
+ id = designator_docid(bib)
43
+ ret = case bib["type"]
44
+ when "standard", "techreport" then id
45
+ else
46
+ bib1 = bib.dup
47
+ bib1.add_namespace(nil, self.class::XML_NAMESPACE)
48
+ n = @i.creatornames(bib1)
49
+ n.nil? && bib["type"].nil? and n = id
50
+ n
51
+ end
52
+ [ret, id]
51
53
  end
52
54
 
53
55
  def designator_docid(bib)
@@ -66,7 +68,7 @@ module Metanorma
66
68
  def normref_no_ordinals(xmldoc)
67
69
  xmldoc.xpath("//references[@normative = 'true']/bibitem/" \
68
70
  "docidentifier[@type = 'metanorma']").each do |d|
69
- /^\[?\d+\]?$/.match?(d.text) and d.remove
71
+ /^\[?\d+\]?$/.match?(d.text) and d.remove
70
72
  end
71
73
  end
72
74
 
@@ -221,7 +223,7 @@ module Metanorma
221
223
  ret = xmldoc.xpath(BIBITEM_NO_AVAIL).detect do |b|
222
224
  has_itu_t = /^ITU-T/.match?(b.at("./docidentifier[@type = 'ITU']")&.text)
223
225
  bib_pubs(b).include?("International Telecommunication Union") &&
224
- (!has_itu_t && !itu_t) || (has_itu_t && itu_t)
226
+ !has_itu_t && !itu_t || (has_itu_t && itu_t)
225
227
  end
226
228
  insert_availability_note(ret, note)
227
229
  end
@@ -33,7 +33,7 @@ module Metanorma
33
33
  end
34
34
  end
35
35
 
36
- def clause_parse(attrs, xml, node)
36
+ def clause_attrs_preprocess(attrs, node)
37
37
  case node.title
38
38
  when "Purpose" then attrs[:type] = "purpose"
39
39
  when "Overview" then attrs[:type] = "overview"
@@ -126,7 +126,6 @@ module Metanorma
126
126
 
127
127
  def metadata_subdoctype(node, xml)
128
128
  xml.subdoctype (node.attr("docsubtype") || "document")
129
- s = node.attr("trial-use") and xml.trial_use s
130
129
  end
131
130
 
132
131
  def org_abbrev
@@ -141,7 +140,7 @@ module Metanorma
141
140
 
142
141
  def metadata_ext(node, xml)
143
142
  super
144
- structured_id(node, xml)
143
+ s = node.attr("trial-use") and xml.trial_use s
145
144
  program(node, xml)
146
145
  end
147
146
 
@@ -1,11 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0">
3
- <!--
4
- VERSION v1.2.1
5
- Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
6
- we cannot have a new default namespace: we will end up with a grammar with two different
7
- namespaces, one for isostandard and one for csand additions. And we do not want that.
8
- -->
9
3
  <include href="relaton-ieee.rng"/>
10
4
  <include href="isodoc.rng">
11
5
  <define name="sections">
@@ -24,31 +18,5 @@
24
18
  </oneOrMore>
25
19
  </element>
26
20
  </define>
27
- <define name="standard-document">
28
- <element name="metanorma">
29
- <ref name="Root-Attributes"/>
30
- <ref name="bibdata"/>
31
- <zeroOrMore>
32
- <ref name="termdocsource"/>
33
- </zeroOrMore>
34
- <optional>
35
- <ref name="misccontainer"/>
36
- </optional>
37
- <optional>
38
- <ref name="boilerplate"/>
39
- </optional>
40
- <ref name="preface"/>
41
- <oneOrMore>
42
- <ref name="sections"/>
43
- </oneOrMore>
44
- <zeroOrMore>
45
- <ref name="annex"/>
46
- </zeroOrMore>
47
- <ref name="bibliography"/>
48
- <zeroOrMore>
49
- <ref name="indexsect"/>
50
- </zeroOrMore>
51
- </element>
52
- </define>
53
21
  </include>
54
22
  </grammar>