metanorma-iec 2.4.0 → 2.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2fa68ed5cd236ec7b2fe1a54c8207b6f1a0d00534c5520d4a1612d2217e336e
4
- data.tar.gz: f4bdf8df0de9bdb5b1dbe8e8338a858aef75cb7f524bfa480e3d08a585051fe9
3
+ metadata.gz: b329047e60d24ccacf88f54b8b6cfa17d7eed313b4badcf010edd7c68428d513
4
+ data.tar.gz: bfb37bf61f2b60538271615b357f765254dfe11d37c8521d311957c3d04418b4
5
5
  SHA512:
6
- metadata.gz: 4ff005a605d113a73422064cb7349c0a2398e01e6bb9a920fe18233e15bf51cf568678ddf80926f7eae5fc70508cce1427fe861ebb5e5736148bd4fa7f7f4c4e
7
- data.tar.gz: a673620b833a883c8f7ae50efc069ed71fbb50aa7150f21c9736022f5658efc7d08926f576135565e48861e270fcdb4c286e59b611a43657c2f41fe15874bbb1
6
+ metadata.gz: 516a7f7d89fb06ec86ad7d70e376c708fb623535a97e9f9441abde946b0889d98728f5e99df2fcb8951b4eaf273c47d1ebbd3a6dd34980536293aaa1e1dce29b
7
+ data.tar.gz: 316c640b39a4a56827d3e836e0d3ddbb752d4f7138b38d8730f62d515529c9d954921684ba9942b6012412f84d06f505d74c51509936d07d2761d63f1dca9e0b
@@ -3930,7 +3930,9 @@
3930
3930
  </xsl:template> <!-- license-statement/p -->
3931
3931
 
3932
3932
  <xsl:template match="*[local-name()='legal-statement']">
3933
+ <xsl:param name="isLegacy">false</xsl:param>
3933
3934
  <fo:block xsl:use-attribute-sets="legal-statement-style">
3935
+
3934
3936
  <xsl:apply-templates/>
3935
3937
  </fo:block>
3936
3938
  </xsl:template> <!-- legal-statement -->
@@ -6282,13 +6284,14 @@
6282
6284
  <!-- ================= -->
6283
6285
  <!-- Added,deleted text -->
6284
6286
  <!-- ================= -->
6285
- <xsl:template match="*[local-name()='add']" name="tag_add">
6287
+ <xsl:template match="*[local-name()='add'] | *[local-name() = 'change-open-tag'] | *[local-name() = 'change-close-tag']" name="tag_add">
6286
6288
  <xsl:param name="skip">true</xsl:param>
6287
6289
  <xsl:param name="block">false</xsl:param>
6288
6290
  <xsl:param name="type"/>
6289
6291
  <xsl:param name="text-align"/>
6290
6292
  <xsl:choose>
6291
- <xsl:when test="starts-with(., $ace_tag)"> <!-- examples: ace-tag_A1_start, ace-tag_A2_end, C1_start, AC_start -->
6293
+ <xsl:when test="starts-with(., $ace_tag) or local-name() = 'change-open-tag' or local-name() = 'change-close-tag'"> <!-- examples: ace-tag_A1_start, ace-tag_A2_end, C1_start, AC_start, or
6294
+ <change-open-tag>A<sub>1</sub></change-open-tag>, <change-close-tag>A<sub>1</sub></change-close-tag> -->
6292
6295
  <xsl:choose>
6293
6296
  <xsl:when test="$skip = 'true' and ((local-name(../..) = 'note' and not(preceding-sibling::node())) or (local-name(..) = 'title' and preceding-sibling::node()[1][local-name() = 'tab']) or local-name(..) = 'formattedref' and not(preceding-sibling::node())) and ../node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]"><!-- start tag displayed in template name="note" and title --></xsl:when>
6294
6297
  <xsl:otherwise>
@@ -6296,12 +6299,32 @@
6296
6299
  <xsl:call-template name="insertTag">
6297
6300
  <xsl:with-param name="type">
6298
6301
  <xsl:choose>
6302
+ <xsl:when test="local-name() = 'change-open-tag'">start</xsl:when>
6303
+ <xsl:when test="local-name() = 'change-close-tag'">end</xsl:when>
6299
6304
  <xsl:when test="$type = ''"><xsl:value-of select="substring-after(substring-after(., $ace_tag), '_')"/> <!-- start or end --></xsl:when>
6300
6305
  <xsl:otherwise><xsl:value-of select="$type"/></xsl:otherwise>
6301
6306
  </xsl:choose>
6302
6307
  </xsl:with-param>
6303
- <xsl:with-param name="kind" select="substring(substring-before(substring-after(., $ace_tag), '_'), 1, 1)"/> <!-- A or C -->
6304
- <xsl:with-param name="value" select="substring(substring-before(substring-after(., $ace_tag), '_'), 2)"/> <!-- 1, 2, C -->
6308
+ <xsl:with-param name="kind">
6309
+ <xsl:choose>
6310
+ <xsl:when test="local-name() = 'change-open-tag' or local-name() = 'change-close-tag'">
6311
+ <xsl:value-of select="text()"/>
6312
+ </xsl:when>
6313
+ <xsl:otherwise>
6314
+ <xsl:value-of select="substring(substring-before(substring-after(., $ace_tag), '_'), 1, 1)"/> <!-- A or C -->
6315
+ </xsl:otherwise>
6316
+ </xsl:choose>
6317
+ </xsl:with-param>
6318
+ <xsl:with-param name="value">
6319
+ <xsl:choose>
6320
+ <xsl:when test="local-name() = 'change-open-tag' or local-name() = 'change-close-tag'">
6321
+ <xsl:value-of select="*[local-name() = 'sub']"/>
6322
+ </xsl:when>
6323
+ <xsl:otherwise>
6324
+ <xsl:value-of select="substring(substring-before(substring-after(., $ace_tag), '_'), 2)"/> <!-- 1, 2, C -->
6325
+ </xsl:otherwise>
6326
+ </xsl:choose>
6327
+ </xsl:with-param>
6305
6328
  </xsl:call-template>
6306
6329
  </xsl:variable>
6307
6330
  <xsl:choose>
@@ -8580,11 +8603,17 @@
8580
8603
  </xsl:when>
8581
8604
  <xsl:otherwise>
8582
8605
 
8606
+ <xsl:variable name="image_class" select="ancestor::*[local-name() = 'image']/@class"/>
8607
+ <xsl:variable name="ancestor_table_cell" select="normalize-space(ancestor::*[local-name() = 'td'] or ancestor::*[local-name() = 'th'])"/>
8608
+
8583
8609
  <xsl:variable name="element">
8584
8610
  <xsl:choose>
8585
8611
  <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
8586
8612
  <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
8587
8613
  </xsl:when>
8614
+ <xsl:when test="not(ancestor::*[local-name() = 'figure'])">
8615
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
8616
+ </xsl:when>
8588
8617
  <xsl:otherwise>
8589
8618
  <fo:block xsl:use-attribute-sets="image-style">
8590
8619
  <xsl:if test="ancestor::*[local-name() = 'dt']">
@@ -8600,10 +8629,24 @@
8600
8629
  <xsl:copy-of select="@*"/>
8601
8630
  <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
8602
8631
  <fo:instream-foreign-object fox:alt-text="{$alt-text}">
8603
- <xsl:if test="$isGenerateTableIF = 'false'">
8604
- <xsl:attribute name="width">100%</xsl:attribute>
8605
- </xsl:if>
8606
- <xsl:attribute name="content-height">100%</xsl:attribute>
8632
+
8633
+ <xsl:choose>
8634
+ <xsl:when test="$image_class = 'corrigenda-tag'">
8635
+ <xsl:attribute name="fox:alt-text">CorrigendaTag</xsl:attribute>
8636
+ <xsl:attribute name="baseline-shift">-10%</xsl:attribute>
8637
+ <xsl:if test="$ancestor_table_cell = 'true'">
8638
+ <xsl:attribute name="baseline-shift">-25%</xsl:attribute>
8639
+ </xsl:if>
8640
+ <xsl:attribute name="height">3.5mm</xsl:attribute>
8641
+ </xsl:when>
8642
+ <xsl:otherwise>
8643
+ <xsl:if test="$isGenerateTableIF = 'false'">
8644
+ <xsl:attribute name="width">100%</xsl:attribute>
8645
+ </xsl:if>
8646
+ <xsl:attribute name="content-height">100%</xsl:attribute>
8647
+ </xsl:otherwise>
8648
+ </xsl:choose>
8649
+
8607
8650
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8608
8651
  <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
8609
8652
  <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
@@ -10823,13 +10866,19 @@
10823
10866
  <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10824
10867
  </xsl:when>
10825
10868
  <!-- if there isn't element with id 'from', then create 'bookmark' here -->
10826
- <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
10869
+ <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
10870
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10871
+ </xsl:when>
10872
+ <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
10827
10873
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10828
10874
  </xsl:when>
10829
10875
  </xsl:choose>
10830
10876
 
10831
10877
  </xsl:template>
10832
10878
 
10879
+ <!-- https://github.com/metanorma/mn-samples-bsi/issues/312 -->
10880
+ <xsl:template match="*[local-name() = 'review'][@type = 'other']"/>
10881
+
10833
10882
  <xsl:template match="*[local-name() = 'name']/text()">
10834
10883
  <!-- 0xA0 to space replacement -->
10835
10884
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -12442,7 +12491,7 @@
12442
12491
 
12443
12492
  <xsl:template name="printEdition">
12444
12493
  <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
12445
- <xsl:text> </xsl:text>
12494
+
12446
12495
  <xsl:choose>
12447
12496
  <xsl:when test="$edition_i18n != ''">
12448
12497
  <!-- Example: <edition language="fr">deuxième édition</edition> -->
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -28,6 +28,10 @@ module Metanorma
28
28
  File.join(@libdir, "iec_intro_#{lang}.xml")
29
29
  end
30
30
 
31
+ def id_prefix(_prefix, id)
32
+ id.text
33
+ end
34
+
31
35
  def doctype_validate(xmldoc)
32
36
  %w(international-standard technical-specification technical-report
33
37
  publicly-available-specification international-workshop-agreement
@@ -150,6 +154,10 @@ module Metanorma
150
154
  end
151
155
  end
152
156
 
157
+ def document_scheme(node)
158
+ node.attr("document-scheme")
159
+ end
160
+
153
161
  def docidentifier_cleanup(xmldoc)
154
162
  prefix = get_id_prefix(xmldoc)
155
163
  id = xmldoc.at("//bibdata/docidentifier[@type = 'ISO']") or return
@@ -7,200 +7,154 @@ module Metanorma
7
7
  "IEC"
8
8
  end
9
9
 
10
- def iso_id(node, xml)
11
- node.attr("docnumber") || node.attr("docidentifier") or return
12
- unless dn = node.attr("docidentifier")
13
- part, subpart = node&.attr("partnumber")&.split(/-/)
14
- dn = add_id_parts(node.attr("docnumber"), part, subpart)
15
- dn = id_stage_prefix(dn, node)
16
- dn = id_edition_suffix(dn, node)
10
+ def metadata_stagename(id)
11
+ if @amd
12
+ id.amendments&.first&.stage&.name ||
13
+ id.corrigendums&.first&.stage&.name
14
+ else
15
+ begin
16
+ id.typed_stage_name
17
+ rescue StandardError
18
+ id.stage&.name
19
+ end
17
20
  end
18
- xml.docidentifier dn, **attr_code(type: "ISO")
19
21
  end
20
22
 
21
- def add_id_parts(docnum, part, subpart)
22
- docnum += "-#{part}" if part
23
- docnum += "-#{subpart}" if subpart
24
- docnum
23
+ def metadata_status(node, xml)
24
+ x = iso_id_default(iso_id_params(node)).stage
25
+ xml.status do |s|
26
+ s.stage x.harmonized_code.stage, **attr_code(abbreviation: x.abbr)
27
+ s.substage x.harmonized_code.substage
28
+ end
29
+ rescue *STAGE_ERROR
30
+ report_illegal_stage(get_stage(node), get_substage(node))
25
31
  end
26
32
 
27
- def id_stage_prefix(docnum, node)
28
- stage = get_stage(node)
29
- typeabbr = get_typeabbr(node)&.upcase
30
- if stage && (stage.to_i < 60)
31
- docnum = unpub_stage_prefix(docnum, stage, typeabbr, node)
32
- elsif typeabbr == "DIR " then docnum = "#{typeabbr}#{docnum}"
33
- elsif typeabbr && !@amd then docnum = "/#{typeabbr}#{docnum}"
33
+ def get_typeabbr(node, amd: false)
34
+ node.attr("amendment-number") and return :amd
35
+ node.attr("corrigendum-number") and return :cor
36
+ case doctype(node)
37
+ when "directive" then :dir
38
+ when "white-paper" then :wp
39
+ when "technology-report" then :tec
40
+ when "social-technology-trend-report" then :sttr
41
+ when "component-specification" then :cs
42
+ when "systems-reference-document" then :srd
43
+ when "operational-document" then :od
44
+ when "conformity-assessment" then :ca
45
+ when "test-report-form" then :trf
46
+ when "technical-report" then :tr
47
+ when "technical-specification" then :ts
48
+ when "publicly-available-specification" then :pas
49
+ when "guide" then :guide
50
+ else :is
34
51
  end
35
- docnum
36
- end
37
-
38
- def unpub_stage_prefix(docnum, stage, typeabbr, node)
39
- abbr = id_stage_abbr(stage, get_substage(node), node)
40
- %w(40 50).include?(stage) && i = node.attr("iteration") and
41
- itersuffix = ".#{i}"
42
- return docnum if abbr.nil? || abbr.empty? # prefixes added in cleanup
43
-
44
- typeabbr = "" if %w(DTS FDTS).include?(abbr.sub(/\s+$/, ""))
45
- return "/#{abbr}#{typeabbr} #{docnum}#{itersuffix}" unless @amd
46
-
47
- a = docnum.split(%r{/})
48
- a[-1] = "#{abbr}#{a[-1]}#{itersuffix}"
49
- a.join("/")
50
- end
51
-
52
- def id_edition_suffix(docnum, node)
53
- ed = node.attr("edition") || 1
54
- docnum += " ED #{ed}"
55
- docnum
56
- end
57
-
58
- STAGE_CODES = {
59
- "PNW" => "1000", "ANW" => "2000", "CAN" => "2098", "ACD" => "2099",
60
- "CD" => "3020", "BWG" => "3092", "A2CD" => "3099", "2CD" => "3520",
61
- "3CD" => "3520", "4CD" => "3520", "5CD" => "3520", "6CD" => "3520",
62
- "7CD" => "3520", "8CD" => "3520", "9CD" => "3520", "CDM" => "3591",
63
- "A3CD" => "3592", "A4CD" => "3592", "A5CD" => "3592", "A6CD" => "3592",
64
- "A7CD" => "3592", "A8CD" => "3592", "A9CD" => "3592", "ACDV" => "3599",
65
- "CCDV" => "4020", "CDVM" => "4091", "NCDV" => "4092",
66
- "NADIS" => "4093", "ADIS" => "4099", "ADTR" => "4099",
67
- "ADTS" => "4099", "RDISH" => "5000", "RFDIS" => "5000",
68
- "CDISH" => "5020", "CDPAS" => "5020", "CDTR" => "5020",
69
- "CDTS" => "5020", "CFDIS" => "5020", "DTRM" => "5092",
70
- "DTSM" => "5092", "NDTR" => "5092", "NDTS" => "5092",
71
- "NFDIS" => "5092", "APUB" => "5099", "BPUB" => "6000",
72
- "PPUB" => "6060", "RR" => "9092", "AMW" => "9220", "WPUB" => "9599",
73
- "DELPUB" => "9960", "PWI" => "0000", "NWIP" => "1000", "WD" => "2000",
74
- "CDV" => "4000", "FDIS" => "5000"
75
- }.freeze
76
-
77
- DOC_STAGE = {
78
- "00": "PWI",
79
- "10": "NWIP",
80
- "20": "WD",
81
- "30": "CD",
82
- "40": "CDV",
83
- "50": "FDIS",
84
- "60": "PPUB",
85
- "90": "RR",
86
- "92": "AMW",
87
- "95": "WPUB",
88
- "99": "DELPUB",
89
- }.freeze
90
-
91
- STAGE_ABBRS = {
92
- "00" => { "00" => "PWI" },
93
- "10" => { "00" => "PNW" },
94
- "20" => { "00" => "ANW", "98" => "CAN", "99" => "ACD" },
95
- "30" => { "00" => "CD", "20" => "CD", "92" => "BWG", "97" => "MERGED",
96
- "98" => "DREJ", "99" => "A2CD" },
97
- "35" => { "00" => "CD", "20" => "CD", "91" => "CDM", "92" => "ACD",
98
- "99" => "ACDV" },
99
- "40" => { "00" => "CCDV", "20" => "CCDV", "91" => "CDVM",
100
- "92" => "NCDV", "93" => "NADIS",
101
- "95" => "ADISSB", "99" => "ADIS" },
102
- "50" => { "00" => "RFDIS", "20" => "CFDIS", "92" => "NFDIS",
103
- "95" => "APUBSB", "99" => "APUB" },
104
- "60" => { "00" => "BPUB", "60" => "PPUB" },
105
- "90" => { "00" => "RR", "92" => "RR" },
106
- "92" => { "00" => "AMW", "20" => "AMW" },
107
- "95" => { "00" => "WPUB", "99" => "WPUB" },
108
- "99" => { "00" => "DELPUB", "60" => "DELPUB" },
109
- }.freeze
110
-
111
- STAGE_NAMES = {
112
- "00": "Preliminary work item",
113
- "10": "New work item proposal",
114
- "20": "Working draft",
115
- "30": "Committee draft",
116
- "35": "Committee draft",
117
- "40": "Committed draft for vote",
118
- "50": "Final draft international standard",
119
- "60": "International standard",
120
- "90": "Review",
121
- "92": "Review",
122
- "95": "Withdrawal",
123
- "99": "Deleted",
124
- }.freeze
125
-
126
- def status_abbrev1(stage, substage, iter, doctype, _draft)
127
- return "" unless stage
128
-
129
- abbr = STAGE_ABBRS.dig(stage, substage) || "??"
130
- if stage == "35" && substage == "92"
131
- iter = (iter.to_i + 1) % "02"
132
- end
133
- case doctype
134
- when "technical-report"
135
- abbr = "ADTR" if stage == "40" && substage == "99"
136
- abbr = "CDTR" if stage == "50" && substage == "20"
137
- abbr = "DTRM" if stage == "50" && substage == "92"
138
- when "technical-specification"
139
- abbr = "ADTS" if stage == "40" && substage == "99"
140
- abbr = "CDTS" if stage == "50" && substage == "20"
141
- abbr = "DTSM" if stage == "50" && substage == "92"
142
- when "interpretation-sheet"
143
- abbr = "RDISH" if stage == "50" && substage == "00"
144
- abbr = "CDISH" if stage == "50" && substage == "20"
145
- when "publicly-available-specification"
146
- abbr = "CDPAS" if stage == "50" && substage == "20"
52
+ end
53
+
54
+ def base_pubid
55
+ Pubid::Iec::Identifier
56
+ end
57
+
58
+ def iso_id_params_core(node)
59
+ pub = iso_id_pub(node)
60
+ ret = { number: node.attr("docnumber"),
61
+ part: node.attr("partnumber"),
62
+ language: node.attr("language")&.split(/,\s*/) || "en",
63
+ type: get_typeabbr(node),
64
+ edition: node.attr("edition"), publisher: pub[0],
65
+ unpublished: /^[0-5]/.match?(get_stage(node)),
66
+ copublisher: pub[1..-1] }.compact
67
+ ret[:copublisher].empty? and ret.delete(:copublisher)
68
+ ret
69
+ end
70
+
71
+ def iso_id_stage(node)
72
+ ret = "#{get_stage(node)}.#{get_substage(node)}"
73
+ if /[A-Z]/.match?(ret) # abbreviation
74
+ ret = get_stage(node)
147
75
  end
148
- abbr = abbr.sub(/CD$/, "#{iter}CD") if iter
149
- abbr
76
+ ret
77
+ end
78
+
79
+ def iso_id_params_resolve(params, params2, node, orig_id)
80
+ ret = super
81
+ params[:number].nil? && !@amd and ret[:number] = "0"
82
+ ret
150
83
  end
151
84
 
152
- def stage_abbr(stage, _substage, _doctype)
153
- return "PPUB" if stage == "60"
85
+ def iso_id_out(xml, params, _with_prf)
86
+ params[:stage] == "60.60" and params.delete(:stage)
87
+ super
88
+ end
89
+
90
+ def iso_id_out_common(xml, params, _with_prf)
91
+ xml.docidentifier iso_id_default(params).to_s,
92
+ **attr_code(type: "ISO")
93
+ xml.docidentifier iso_id_reference(params).to_s,
94
+ **attr_code(type: "iso-reference")
95
+ @id_revdate and
96
+ xml.docidentifier iso_id_revdate(params.merge(year: @id_revdate))
97
+ .to_s(with_edition_month_date: true),
98
+ **attr_code(type: "iso-revdate")
99
+ xml.docidentifier iso_id_reference(params).urn,
100
+ **attr_code(type: "URN")
101
+ end
102
+
103
+ def iso_id_out_non_amd(xml, params, _with_prf)
104
+ xml.docidentifier iso_id_undated(params).to_s,
105
+ **attr_code(type: "iso-undated")
106
+ xml.docidentifier iso_id_with_lang(params).to_s,
107
+ **attr_code(type: "iso-with-lang")
108
+ end
154
109
 
155
- DOC_STAGE[stage.to_sym] || "??"
110
+ def iso_id_revdate(params)
111
+ params1 = params.dup.tap { |hs| hs.delete(:unpublished) }
112
+ m = params1[:year].match(/^(\d{4})(-\d{2})?(-\d{2})?/)
113
+ params1[:year] = m[1]
114
+ params1[:month] = m[2].sub(/^-/, "")
115
+ # skipping day for now
116
+ pubid_select(params1).create(**params1)
156
117
  end
157
118
 
158
- def stage_name(stage, _substage, _doctype, _iteration)
159
- STAGE_NAMES[stage.to_sym]
119
+ def status_abbrev1(node)
120
+ id = iso_id_default({ stage: "60.60" }.merge(iso_id_params(node)))
121
+ id.stage or return ""
122
+ id.stage.abbr
160
123
  end
161
124
 
162
125
  def get_stage(node)
163
126
  stage = node.attr("status") || node.attr("docstage") || "60"
164
127
  m = /([0-9])CD$/.match(stage) and node.set_attr("iteration", m[1])
165
- STAGE_CODES[stage] and stage = STAGE_CODES[stage][0..1]
166
128
  stage
167
129
  end
168
130
 
169
131
  def get_substage(node)
170
- st = node.attr("status") || node.attr("docstage")
171
- stage = get_stage(node)
172
- node.attr("docsubstage") ||
173
- (if stage == "60"
174
- "60"
175
- else
176
- STAGE_CODES[st] ? STAGE_CODES[st][2..3] : "00"
177
- end)
132
+ ret = node.attr("docsubstage") and return ret
133
+ st = get_stage(node)
134
+ case st
135
+ when "60" then "60"
136
+ when "30", "40", "50" then "20"
137
+ else "00"
138
+ end
178
139
  end
179
140
 
180
- def id_stage_abbr(stage, _substage, node)
181
- return "" if stage == "60"
182
-
183
- abbr = DOC_STAGE[stage.to_sym] || ""
184
- abbr = node.attr("iteration") + abbr if node.attr("iteration")
185
- abbr
141
+ def iso_id_params_add(node)
142
+ stage = iso_id_stage(node)
143
+ @id_revdate = node.attr("revdate")
144
+ ret = { number: node.attr("amendment-number") ||
145
+ node.attr("corrigendum-number"),
146
+ year: iso_id_year(node) }.compact
147
+ if stage && !cen?(node.attr("publisher"))
148
+ ret[:stage] = stage
149
+ end
150
+ ret
186
151
  end
187
152
 
188
- # TODO: replace by ISO call
189
- def metadata_status(node, xml)
190
- stage = get_stage(node)
191
- substage = get_substage(node)
192
- xml.status do |s|
193
- s.stage stage,
194
- **attr_code(abbreviation: stage_abbr(stage, substage, nil))
195
- subst = status_abbrev1(stage, substage, node.attr("iteration"),
196
- doctype(node), node.attr("draft"))
197
- s.substage substage, **attr_code(abbreviation: subst)
198
- node.attr("iteration") && (s.iteration node.attr("iteration"))
199
- end
200
- iso_id_default(iso_id_params(node))
201
- rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
202
- Pubid::Core::Errors::TypeStageParseError
203
- report_illegal_stage(stage, substage)
153
+ def report_illegal_stage(stage, substage)
154
+ out = stage || ""
155
+ /[A-Z]/.match?(out) or out += ".#{substage}"
156
+ err = "Illegal document stage: #{out}"
157
+ @log.add("Document Attributes", nil, err)
204
158
  end
205
159
 
206
160
  def metadata_subdoctype(node, xml)
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.12 -->
20
+ <!-- VERSION v1.3.0 -->
21
21
  <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">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -146,6 +146,9 @@
146
146
  <data type="boolean"/>
147
147
  </attribute>
148
148
  </optional>
149
+ <optional>
150
+ <attribute name="style"/>
151
+ </optional>
149
152
  <oneOrMore>
150
153
  <ref name="PureTextElement"/>
151
154
  </oneOrMore>
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "2.4.0".freeze
3
+ VERSION = "2.4.1".freeze
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso