metanorma-iso 2.7.3 → 2.7.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.
@@ -79,6 +79,10 @@ module IsoDoc
79
79
  node["inline-header"] = "true"
80
80
  end
81
81
  super
82
+ if node["type"] == "section"
83
+ t = node.at(ns("./title/tab")) and
84
+ t.previous = @i18n.l10n(": ").sub(/\p{Zs}$/, "")
85
+ end
82
86
  end
83
87
 
84
88
  def clause(docxml)
@@ -12,12 +12,12 @@ module IsoDoc
12
12
  if @klass.amd?(docxml)
13
13
  [{ path: "//sections/clause", multi: true }]
14
14
  else
15
- [{ path: "//clause[@type = 'scope']" },
15
+ [{ path: "//sections/clause[@type = 'scope']" },
16
16
  { path: @klass.norm_ref_xpath },
17
17
  { path:
18
18
  "#{@klass.middle_clause(docxml)} | //sections/terms | " \
19
- "//sections/clause[descendant::terms or descendant::definitions] " \
20
- "| //sections/definitions", multi: true }]
19
+ "//sections/clause[descendant::terms or descendant::definitions] | " \
20
+ "//sections/definitions | //sections/clause[@type = 'section']", multi: true }]
21
21
  end
22
22
  end
23
23
 
@@ -46,9 +46,7 @@ module IsoDoc
46
46
 
47
47
  def hierarchical_formula_names(clause, num)
48
48
  c = IsoDoc::XrefGen::Counter.new
49
- clause.xpath(ns(".//formula")).each do |t|
50
- next if blank?(t["id"])
51
-
49
+ clause.xpath(ns(".//formula")).noblank.each do |t|
52
50
  @anchors[t["id"]] = anchor_struct(
53
51
  "#{num}#{hiersep}#{c.increment(t).print}", t,
54
52
  t["inequality"] ? @labels["inequality"] : @labels["formula"],
@@ -130,7 +128,7 @@ module IsoDoc
130
128
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
131
129
  s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
132
130
  c = Counter.new
133
- notes.reject { |n| blank?(n["id"]) }.each do |n|
131
+ notes.noblank.each do |n|
134
132
  @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
135
133
  @labels["list"], "list", false)
136
134
  list_item_anchor_names(n, @anchors[n["id"]], 1, "",
@@ -47,6 +47,17 @@ module IsoDoc
47
47
  end
48
48
  end
49
49
 
50
+ def section_name_anchors(clause, num, level)
51
+ if clause["type"] == "section"
52
+ @anchors[clause["id"]] =
53
+ { label: l10n("#{@labels['section']} #{num}"),
54
+ xref: l10n("#{@labels['section']} #{num}"),
55
+ title: clause_title(clause), level: level, type: "clause",
56
+ elem: @labels["section"] }
57
+ else super
58
+ end
59
+ end
60
+
50
61
  def annex_names1(clause, num, level)
51
62
  @anchors[clause["id"]] = { label: num, xref: num, level: level,
52
63
  subtype: "annex" }
@@ -83,14 +83,6 @@ module Metanorma
83
83
  node.attr("document-scheme") || "2024"
84
84
  end
85
85
 
86
- def metadata_attrs(node)
87
- ret = super
88
- a = document_scheme(node) and
89
- ret += "<presentation-metadata><name>document-scheme</name>" \
90
- "<value>#{a}</value></presentation-metadata>"
91
- ret
92
- end
93
-
94
86
  def outputs(node, ret)
95
87
  File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
96
88
  presentation_xml_converter(node).convert("#{@filename}.xml")
@@ -208,7 +208,9 @@
208
208
  </define>
209
209
  <define name="roledescription">
210
210
  <element name="description">
211
- <ref name="FormattedString"/>
211
+ <oneOrMore>
212
+ <ref name="TextElement"/>
213
+ </oneOrMore>
212
214
  </element>
213
215
  </define>
214
216
  <define name="person">
@@ -333,7 +335,9 @@
333
335
  </define>
334
336
  <define name="affiliationdescription">
335
337
  <element name="description">
336
- <ref name="FormattedString"/>
338
+ <oneOrMore>
339
+ <ref name="TextElement"/>
340
+ </oneOrMore>
337
341
  </element>
338
342
  </define>
339
343
  <define name="organization">
@@ -897,7 +901,9 @@
897
901
  </define>
898
902
  <define name="formattedref">
899
903
  <element name="formattedref">
900
- <ref name="FormattedString"/>
904
+ <oneOrMore>
905
+ <ref name="TextElement"/>
906
+ </oneOrMore>
901
907
  </element>
902
908
  </define>
903
909
  <define name="license">
@@ -942,7 +948,9 @@
942
948
  <optional>
943
949
  <attribute name="type"/>
944
950
  </optional>
945
- <ref name="FormattedString"/>
951
+ <zeroOrMore>
952
+ <ref name="TextElement"/>
953
+ </zeroOrMore>
946
954
  </define>
947
955
  <!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
948
956
  <define name="TypedUri">
@@ -1042,7 +1050,9 @@
1042
1050
  <optional>
1043
1051
  <attribute name="script"/>
1044
1052
  </optional>
1045
- <text/>
1053
+ <oneOrMore>
1054
+ <ref name="TextElement"/>
1055
+ </oneOrMore>
1046
1056
  </element>
1047
1057
  </define>
1048
1058
  <define name="docnumber">
@@ -1267,12 +1277,16 @@
1267
1277
  <optional>
1268
1278
  <attribute name="type"/>
1269
1279
  </optional>
1270
- <ref name="FormattedString"/>
1280
+ <oneOrMore>
1281
+ <ref name="TextElement"/>
1282
+ </oneOrMore>
1271
1283
  </element>
1272
1284
  </define>
1273
1285
  <define name="bibabstract">
1274
1286
  <element name="abstract">
1275
- <ref name="FormattedString"/>
1287
+ <oneOrMore>
1288
+ <ref name="TextElement"/>
1289
+ </oneOrMore>
1276
1290
  </element>
1277
1291
  </define>
1278
1292
  <define name="copyright">
@@ -1377,7 +1391,9 @@
1377
1391
  </attribute>
1378
1392
  <optional>
1379
1393
  <element name="description">
1380
- <ref name="FormattedString"/>
1394
+ <oneOrMore>
1395
+ <ref name="TextElement"/>
1396
+ </oneOrMore>
1381
1397
  </element>
1382
1398
  </optional>
1383
1399
  <element name="bibitem">
@@ -18,11 +18,45 @@ Imprimé en Suisse
18
18
  Ce document est également édité en anglais et en russe. Il peut être obtenu auprès des organisations +
19
19
  nationales de normalisation.
20
20
 
21
+ {% elsif document_scheme == "1972" or document_scheme == "1987" %}
22
+
23
+ === {blank}
24
+
25
+ [[boilerplate-year]]
26
+ &#xa9;&#xa0;&#xa0;&#xa0;span:std_publisher[*Organisation Nationale de Normalisation*], span:date[*{{ docyear }}*]&#xa0;&#xa0;&#xa0;&#x25cf;
27
+
28
+ [[boilerplate-place]]
29
+ Publié en Suisse
30
+
31
+
32
+ {% elsif document_scheme == "1989" %}
33
+
34
+ === {blank}
35
+
36
+ [[boilerplate-year]]
37
+ &#xa9; span:std_publisher[{{ agency }}&#xa0;]span:date[{{ docyear }}]
38
+
39
+ [[boilerplate-message]]
40
+ Droits de reproduction réservés. Sauf prescription différente, aucune partie de cette publication
41
+ ne peut être reproduite ni utilisée sous quelque forme que ce soit et par aucun procédé,
42
+ électronique ou mécanique, y compris la photocopie et les microfilms, sans l'accord écrit de l'éditeur.
43
+
44
+ [[boilerplate-address]]
45
+ [align=left]
46
+ Organisation internationale de normalisation +
47
+ Case postale 56 &#x2022; CH-1211 Genève 20 &#x2022; Suisse +
48
+ Internet&#xa0;&#xa0;&#xa0;central@iso.ch +
49
+ X.400&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;c=ch; a=400net; p=iso; o=isocs; s=central
50
+
51
+ [[boilerplate-place]]
52
+ Imprimé en Suisse
53
+
54
+
21
55
  {% else %}
22
56
  === {% if stage_int >= 40 %}DOCUMENT PROTÉGÉ PAR COPYRIGHT{%else%}{blank}{%endif%}
23
57
 
24
58
  [[boilerplate-year]]
25
- &#xa9; span:std_publisher:[{{ agency }}&#xa0;]span:std_docNumber[{{ docyear }}]
59
+ &#xa9; span:std_publisher:[{{ agency }}&#xa0;]span:date[{{ docyear }}]
26
60
 
27
61
  [[boilerplate-message]]
28
62
  Droits de reproduction réservés. Sauf indication contraire, ou requise dans le cadre de sa mise en œuvre,
@@ -39,7 +73,7 @@ CP 401 &#x2022; Ch. de Blandonnet 8 +
39
73
  CH-1214 Vernier, Geneva +
40
74
  Tél: +41 22 749 01 11 +
41
75
  Email: copyright@iso.org +
42
- Website: www.iso.org
76
+ Website: {% if document_scheme == "2024" %}https://www.iso.org/[www.iso.org]{% else %}www.iso.org{% endif %}
43
77
 
44
78
  [[boilerplate-place]]
45
79
  Publié en Suisse
@@ -1,9 +1,43 @@
1
1
  == copyright-statement
2
2
 
3
+ {% if document_scheme == "1972" or document_scheme == "1987" %}
4
+
5
+ === {blank}
6
+
7
+ [[boilerplate-year]]
8
+ &#xa9;&#xa0;&#xa0;&#xa0;span:std_publisher[*Международная Организация по Стандартизации*], span:date[*{{ docyear }}*]&#xa0;&#xa0;&#xa0;&#x25cf;
9
+
10
+ [[boilerplate-place]]
11
+ Издано в Швейцарии
12
+
13
+ {% elsif document_scheme == "1989" %}
14
+
15
+ === {blank}
16
+
17
+ [[boilerplate-year]]
18
+ &#xa9; span:std_publisher[{{ agency }}&#xa0;]span:date[{{ docyear }}]
19
+
20
+ [[boilerplate-message]]
21
+ Охраняется авторским правом. Если это особо не указано, то никакая часть данной публикации не может быть воспроизведена и
22
+ использована в любой форме или любыми средствами, электронными или механическими, включая фотокопирование и
23
+ микрофильмирование, без предварительного письменного разрешения издателя.
24
+
25
+ [[boilerplate-address]]
26
+ [align=left]
27
+ Международная Организация по Стандартизации +
28
+ Почтовый адрес: 56 &#x2022; CH-1211 Geneva 20 &#x2022; Switzerland +
29
+ Адрес в Интернете:&#xa0;central@iso.ch +
30
+ X.400&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;c=ch; a=400net; p=iso; o=isocs; s=central
31
+
32
+ [[boilerplate-place]]
33
+ Напечатано в Швейцарии
34
+
35
+ {% else %}
36
+
3
37
  === {% if stage_int >= 40 %}ДОКУМЕНТ, ОХРАНЯЕМЫЙ АВТОРСКИМ ПРАВОМ{% else %}{blank}{% endif %}
4
38
 
5
39
  [[boilerplate-year]]
6
- &#xa9; span:std_publisher[{{ agency }}&#xa0;]span:std_docNumber[{{ docyear }}]
40
+ &#xa9; span:std_publisher[{{ agency }}&#xa0;]span:date[{{ docyear }}]
7
41
 
8
42
  [[boilerplate-message]]
9
43
  Все права защищены. Если иначе не определено или не требуется в контексте его реализации, никакая часть этой публикации не может быть воспроизведена или использована иначе в любой форме или каким-либо образом, электронным или механическим, включая фотокопирование, или публикацию в Интернете или интранете, без предварительного письменного разрешения. Разрешение может быть запрошено ISO по адресу, указанному ниже, или у органа — члена ISO страны запрашивающего.
@@ -15,7 +49,7 @@ CP 401 &#x2022; Ch. de Blandonnet 8 +
15
49
  CH-1214 Vernier, Geneva +
16
50
  Тел: +41 22 749 01 11 +
17
51
  Электронная почта: copyright@iso.org +
18
- Сайт: www.iso.org
52
+ Сайт: {% if document_scheme == "2024" %}https://www.iso.org/[www.iso.org]{% else %}www.iso.org{% endif %}
19
53
 
20
54
  [[boilerplate-place]]
21
55
  Издано в Швейцарии
@@ -28,3 +62,4 @@ CH-1214 Vernier, Geneva +
28
62
 
29
63
  Получателям этого проекта предлагается представить вместе со своими комментариями уведомление о любых соответствующих патентных правах, о которых им известно, и предоставить подтверждающую документацию.
30
64
  {% endif %}
65
+ {% endif %}
@@ -18,12 +18,45 @@ Printed in Switzerland
18
18
 
19
19
  Also issued in French and Russian. Copies to be obtained through the national standards organizations.
20
20
 
21
+ {% elsif document_scheme == "1972" or document_scheme == "1987" %}
22
+
23
+ === {blank}
24
+
25
+ [[boilerplate-year]]
26
+ &#xa9;&#xa0;&#xa0;&#xa0;span:std_publisher[*International Organization for Standardization*], span:date[*{{ docyear }}*]&#xa0;&#xa0;&#xa0;&#x25cf;
27
+
28
+ [[boilerplate-place]]
29
+ Printed in Switzerland
30
+
31
+
32
+ {% elsif document_scheme == "1989" %}
33
+
34
+ === {blank}
35
+
36
+ [[boilerplate-year]]
37
+ &#xa9; span:std_publisher[{{ agency }}&#xa0;]span:date[{{ docyear }}]
38
+
39
+ [[boilerplate-message]]
40
+ All rights reserved. Unless otherwise specified, no part of this publication may be reproduced
41
+ or utilized in any form or by any means, electronic or mechanical, including photocopying and
42
+ microfilm, without permission in writing from the publisher.
43
+
44
+ [[boilerplate-address]]
45
+ [align=left]
46
+ International Organization for Standardization +
47
+ Case postale 56 &#x2022; CH-1211 Genève 20 &#x2022; Switzerland +
48
+ Internet&#xa0;&#xa0;&#xa0;central@iso.ch +
49
+ X.400&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;c=ch; a=400net; p=iso; o=isocs; s=central
50
+
51
+ [[boilerplate-place]]
52
+ Printed in Switzerland
53
+
21
54
  {% else %}
22
55
 
23
56
  === {% if stage_int >= 40 %}COPYRIGHT PROTECTED DOCUMENT{% else %}{blank}{% endif %}
24
57
 
25
58
  [[boilerplate-year]]
26
- &#xa9; span:std_publisher[{{ agency }}&#xa0;]span:std_docNumber[{{ docyear }}]
59
+ &#xa9; span:std_publisher[{{ agency }}&#xa0;]span:date[{{ docyear }}]
27
60
 
28
61
  [[boilerplate-message]]
29
62
  All rights reserved. Unless otherwise specified, or required in the context of its implementation,
@@ -40,7 +73,7 @@ CP 401 &#x2022; Ch. de Blandonnet 8 +
40
73
  CH-1214 Vernier, Geneva +
41
74
  Phone: +41 22 749 01 11 +
42
75
  Email: copyright@iso.org +
43
- Website: www.iso.org
76
+ Website: {% if document_scheme == "2024" %}https://www.iso.org/[www.iso.org]{% else %}www.iso.org{% endif %}
44
77
 
45
78
  [[boilerplate-place]]
46
79
  Published in Switzerland
@@ -1,3 +1,5 @@
1
+ require_relative "cleanup_biblio"
2
+
1
3
  module Metanorma
2
4
  module ISO
3
5
  class Converter < Standoc::Converter
@@ -24,80 +26,20 @@ module Metanorma
24
26
  end
25
27
  end
26
28
 
27
- def id_prefix(prefix, id)
28
- # we're just inheriting the prefixes from parent doc
29
- @amd and return id.text
30
- prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text
31
- end
32
-
33
- def get_id_prefix(xmldoc)
34
- xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']" \
35
- "/organization").each_with_object([]) do |x, prefix|
36
- x1 = x.at("abbreviation")&.text || x.at("name")&.text
37
- prefix << x1
29
+ def ol_cleanup(doc)
30
+ doc.xpath("//ol[@explicit-type]").each do |x|
31
+ x["type"] = x["explicit-type"]
32
+ x.delete("explicit-type")
33
+ @log.add("Style", x,
34
+ "Style override set for ordered list")
38
35
  end
39
36
  end
40
37
 
41
- # ISO as a prefix goes first
42
- def docidentifier_cleanup(xmldoc)
43
- prefix = get_id_prefix(xmldoc)
44
- id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
45
- id.content = id_prefix(prefix, id)
46
- end
47
-
48
- def format_ref(ref, type)
49
- ref = ref.sub(/ \(All Parts\)/i, "")
50
- super
51
- end
52
-
53
38
  TERM_CLAUSE =
54
39
  "//sections//terms | " \
55
40
  "//sections//clause[descendant::terms][not(descendant::definitions)]"
56
41
  .freeze
57
42
 
58
- PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
59
-
60
- def pub_class(bib)
61
- return 1 if bib.at("#{PUBLISHER}[abbreviation = 'ISO']")
62
- return 1 if bib.at("#{PUBLISHER}[name = 'International Organization " \
63
- "for Standardization']")
64
- return 2 if bib.at("#{PUBLISHER}[abbreviation = 'IEC']")
65
- return 2 if bib.at("#{PUBLISHER}[name = 'International " \
66
- "Electrotechnical Commission']")
67
- return 3 if bib.at("./docidentifier[@type]" \
68
- "[not(#{skip_docid} or @type = 'metanorma')]") ||
69
- bib.at("./docidentifier[not(@type)]")
70
-
71
- 4
72
- end
73
-
74
- def sort_biblio(bib)
75
- bib.sort { |a, b| sort_biblio_key(a) <=> sort_biblio_key(b) }
76
- end
77
-
78
- # sort by: doc class (ISO, IEC, other standard (not DOI &c), other
79
- # then standard class (docid class other than DOI &c)
80
- # then docnumber if present, numeric sort
81
- # else alphanumeric metanorma id (abbreviation)
82
- # then doc part number if present, numeric sort
83
- # then doc id (not DOI &c)
84
- # then title
85
- def sort_biblio_key(bib)
86
- pubclass = pub_class(bib)
87
- num = bib.at("./docnumber")&.text
88
- id = bib.at("./docidentifier[@primary]") ||
89
- bib.at("./docidentifier[not(#{skip_docid} or @type = 'metanorma')]")
90
- metaid = bib.at("./docidentifier[@type = 'metanorma']")&.text
91
- abbrid = metaid unless /^\[\d+\]$/.match?(metaid)
92
- /\d-(?<partid>\d+)/ =~ id&.text
93
- type = id["type"] if id
94
- title = bib.at("./title[@type = 'main']")&.text ||
95
- bib.at("./title")&.text || bib&.at("./formattedref")&.text
96
- "#{pubclass} :: #{type} :: " \
97
- "#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: " \
98
- "#{sprintf('%09d', partid.to_i)} :: #{id&.text} :: #{title}"
99
- end
100
-
101
43
  def sections_cleanup(xml)
102
44
  super
103
45
  @amd or return
@@ -127,52 +69,6 @@ module Metanorma
127
69
  end
128
70
  end
129
71
 
130
- def bibitem_cleanup(xmldoc)
131
- super
132
- unpublished_note(xmldoc)
133
- withdrawn_note(xmldoc)
134
- end
135
-
136
- def unpublished_note(xmldoc)
137
- xmldoc.xpath("//bibitem[not(./ancestor::bibitem)]" \
138
- "[not(note[@type = 'Unpublished-Status'])]").each do |b|
139
- pub_class(b) > 2 and next
140
- ((s = b.at("./status/stage")) && s.text.match?(/\d/) &&
141
- (s.text.to_i < 60)) or next
142
- insert_unpub_note(b, @i18n.under_preparation
143
- .sub("%", b.at("docidentifier").text))
144
- end
145
- end
146
-
147
- def withdrawn_note(xmldoc)
148
- xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
149
- .each do |b|
150
- withdrawn_ref?(b) or next
151
- if id = replacement_standard(b)
152
- insert_unpub_note(b, @i18n.cancelled_and_replaced.sub("%", id))
153
- else insert_unpub_note(b, @i18n.withdrawn)
154
- end
155
- end
156
- end
157
-
158
- def withdrawn_ref?(biblio)
159
- pub_class(biblio) > 2 and return false
160
- (s = biblio.at("./status/stage")) && (s.text.to_i == 95) &&
161
- (t = biblio.at("./status/substage")) && (t.text.to_i == 99)
162
- end
163
-
164
- def replacement_standard(biblio)
165
- r = biblio.at("./relation[@type = 'updates']/bibitem") or return nil
166
- id = r.at("./formattedref | ./docidentifier[@primary = 'true'] | " \
167
- "./docidentifier | ./formattedref") or return nil
168
- id.text
169
- end
170
-
171
- def insert_unpub_note(biblio, msg)
172
- biblio.at("./language | ./script | ./abstract | ./status")
173
- .previous = %(<note type="Unpublished-Status"><p>#{msg}</p></note>)
174
- end
175
-
176
72
  def termdef_boilerplate_insert(xmldoc, isodoc, once = false)
177
73
  once = true
178
74
  super
@@ -0,0 +1,120 @@
1
+ module Metanorma
2
+ module ISO
3
+ class Converter < Standoc::Converter
4
+ def id_prefix(prefix, id)
5
+ # we're just inheriting the prefixes from parent doc
6
+ @amd and return id.text
7
+ prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text
8
+ end
9
+
10
+ def get_id_prefix(xmldoc)
11
+ xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']" \
12
+ "/organization").each_with_object([]) do |x, prefix|
13
+ x1 = x.at("abbreviation")&.text || x.at("name")&.text
14
+ prefix << x1
15
+ end
16
+ end
17
+
18
+ # ISO as a prefix goes first
19
+ def docidentifier_cleanup(xmldoc)
20
+ prefix = get_id_prefix(xmldoc)
21
+ id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
22
+ id.content = id_prefix(prefix, id)
23
+ end
24
+
25
+ def format_ref(ref, type)
26
+ ref = ref.sub(/ \(All Parts\)/i, "")
27
+ super
28
+ end
29
+
30
+ PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
31
+
32
+ def pub_class(bib)
33
+ return 1 if bib.at("#{PUBLISHER}[abbreviation = 'ISO']")
34
+ return 1 if bib.at("#{PUBLISHER}[name = 'International Organization " \
35
+ "for Standardization']")
36
+ return 2 if bib.at("#{PUBLISHER}[abbreviation = 'IEC']")
37
+ return 2 if bib.at("#{PUBLISHER}[name = 'International " \
38
+ "Electrotechnical Commission']")
39
+ return 3 if bib.at("./docidentifier[@type]" \
40
+ "[not(#{skip_docid} or @type = 'metanorma')]") ||
41
+ bib.at("./docidentifier[not(@type)]")
42
+
43
+ 4
44
+ end
45
+
46
+ def sort_biblio(bib)
47
+ bib.sort { |a, b| sort_biblio_key(a) <=> sort_biblio_key(b) }
48
+ end
49
+
50
+ # sort by: doc class (ISO, IEC, other standard (not DOI &c), other
51
+ # then standard class (docid class other than DOI &c)
52
+ # then docnumber if present, numeric sort
53
+ # else alphanumeric metanorma id (abbreviation)
54
+ # then doc part number if present, numeric sort
55
+ # then doc id (not DOI &c)
56
+ # then title
57
+ def sort_biblio_key(bib)
58
+ pubclass = pub_class(bib)
59
+ num = bib.at("./docnumber")&.text
60
+ id = bib.at("./docidentifier[@primary]") ||
61
+ bib.at("./docidentifier[not(#{skip_docid} or @type = 'metanorma')]")
62
+ metaid = bib.at("./docidentifier[@type = 'metanorma']")&.text
63
+ abbrid = metaid unless /^\[\d+\]$/.match?(metaid)
64
+ /\d-(?<partid>\d+)/ =~ id&.text
65
+ type = id["type"] if id
66
+ title = bib.at("./title[@type = 'main']")&.text ||
67
+ bib.at("./title")&.text || bib&.at("./formattedref")&.text
68
+ "#{pubclass} :: #{type} :: " \
69
+ "#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: " \
70
+ "#{sprintf('%09d', partid.to_i)} :: #{id&.text} :: #{title}"
71
+ end
72
+
73
+ def bibitem_cleanup(xmldoc)
74
+ super
75
+ unpublished_note(xmldoc)
76
+ withdrawn_note(xmldoc)
77
+ end
78
+
79
+ def unpublished_note(xmldoc)
80
+ xmldoc.xpath("//bibitem[not(./ancestor::bibitem)]" \
81
+ "[not(note[@type = 'Unpublished-Status'])]").each do |b|
82
+ pub_class(b) > 2 and next
83
+ ((s = b.at("./status/stage")) && s.text.match?(/\d/) &&
84
+ (s.text.to_i < 60)) or next
85
+ insert_unpub_note(b, @i18n.under_preparation
86
+ .sub("%", b.at("docidentifier").text))
87
+ end
88
+ end
89
+
90
+ def withdrawn_note(xmldoc)
91
+ xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
92
+ .each do |b|
93
+ withdrawn_ref?(b) or next
94
+ if id = replacement_standard(b)
95
+ insert_unpub_note(b, @i18n.cancelled_and_replaced.sub("%", id))
96
+ else insert_unpub_note(b, @i18n.withdrawn)
97
+ end
98
+ end
99
+ end
100
+
101
+ def withdrawn_ref?(biblio)
102
+ pub_class(biblio) > 2 and return false
103
+ (s = biblio.at("./status/stage")) && (s.text.to_i == 95) &&
104
+ (t = biblio.at("./status/substage")) && (t.text.to_i == 99)
105
+ end
106
+
107
+ def replacement_standard(biblio)
108
+ r = biblio.at("./relation[@type = 'updates']/bibitem") or return nil
109
+ id = r.at("./formattedref | ./docidentifier[@primary = 'true'] | " \
110
+ "./docidentifier | ./formattedref") or return nil
111
+ id.text
112
+ end
113
+
114
+ def insert_unpub_note(biblio, msg)
115
+ biblio.at("./language | ./script | ./abstract | ./status")
116
+ .previous = %(<note type="Unpublished-Status"><p>#{msg}</p></note>)
117
+ end
118
+ end
119
+ end
120
+ end
@@ -9,7 +9,7 @@ module Metanorma
9
9
  class Converter < Standoc::Converter
10
10
  def metadata_id(node, xml)
11
11
  if id = node.attr("docidentifier")
12
- xml.docidentifier id, **attr_code(type: "ISO")
12
+ xml.docidentifier id, **attr_code(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|
@@ -161,12 +161,13 @@ module Metanorma
161
161
  end
162
162
 
163
163
  def cen_id_out(xml, params)
164
- xml.docidentifier iso_id_default(params).to_s, **attr_code(type: "CEN")
164
+ xml.docidentifier iso_id_default(params).to_s,
165
+ **attr_code(type: "CEN", primary: "true")
165
166
  end
166
167
 
167
168
  def iso_id_out_common(xml, params, with_prf)
168
169
  xml.docidentifier iso_id_default(params).to_s(with_prf: with_prf),
169
- **attr_code(type: "ISO")
170
+ **attr_code(type: "ISO", primary: "true")
170
171
  xml.docidentifier iso_id_reference(params)
171
172
  .to_s(format: :ref_num_short, with_prf: with_prf),
172
173
  **attr_code(type: "iso-reference")
@@ -185,8 +186,7 @@ module Metanorma
185
186
  params_nolang = params.dup.tap { |hs| hs.delete(:language) }
186
187
  params1 = if params[:unpublished]
187
188
  params_nolang.dup.tap { |hs| hs.delete(:year) }
188
- else params_nolang
189
- end
189
+ else params_nolang end
190
190
  params1.delete(:unpublished)
191
191
  pubid_select(params1).create(**params1)
192
192
  end