metanorma-iso 2.1.2 → 2.1.3

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.
@@ -38,7 +38,7 @@ module IsoDoc
38
38
  lbl = if n.nil? || blank?(n[:label]) then @i18n.example
39
39
  else l10n("#{@i18n.example} #{n[:label]}")
40
40
  end
41
- prefix_name(node, " — ", lbl, "name")
41
+ prefix_name(node, block_delim, lbl, "name")
42
42
  end
43
43
 
44
44
  def example_span_label(_node, div, name)
@@ -623,6 +623,97 @@
623
623
  <zeroOrMore>
624
624
  <ref name="bsource"/>
625
625
  </zeroOrMore>
626
+ <oneOrMore>
627
+ <ref name="docidentifier"/>
628
+ </oneOrMore>
629
+ <optional>
630
+ <ref name="docnumber"/>
631
+ </optional>
632
+ <zeroOrMore>
633
+ <ref name="bdate"/>
634
+ </zeroOrMore>
635
+ <zeroOrMore>
636
+ <ref name="contributor"/>
637
+ </zeroOrMore>
638
+ <optional>
639
+ <ref name="edition"/>
640
+ </optional>
641
+ <zeroOrMore>
642
+ <ref name="version"/>
643
+ </zeroOrMore>
644
+ <zeroOrMore>
645
+ <ref name="biblionote"/>
646
+ </zeroOrMore>
647
+ <zeroOrMore>
648
+ <ref name="language"/>
649
+ </zeroOrMore>
650
+ <zeroOrMore>
651
+ <ref name="script"/>
652
+ </zeroOrMore>
653
+ <zeroOrMore>
654
+ <ref name="bibabstract"/>
655
+ </zeroOrMore>
656
+ <optional>
657
+ <ref name="status"/>
658
+ </optional>
659
+ <zeroOrMore>
660
+ <ref name="copyright"/>
661
+ </zeroOrMore>
662
+ <zeroOrMore>
663
+ <ref name="docrelation"/>
664
+ </zeroOrMore>
665
+ <zeroOrMore>
666
+ <ref name="series"/>
667
+ </zeroOrMore>
668
+ <optional>
669
+ <ref name="medium"/>
670
+ </optional>
671
+ <zeroOrMore>
672
+ <ref name="bplace"/>
673
+ </zeroOrMore>
674
+ <zeroOrMore>
675
+ <ref name="bprice"/>
676
+ </zeroOrMore>
677
+ <zeroOrMore>
678
+ <ref name="extent"/>
679
+ </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
683
+ <zeroOrMore>
684
+ <ref name="accesslocation"/>
685
+ </zeroOrMore>
686
+ <zeroOrMore>
687
+ <ref name="license"/>
688
+ </zeroOrMore>
689
+ <zeroOrMore>
690
+ <ref name="bclassification"/>
691
+ </zeroOrMore>
692
+ <zeroOrMore>
693
+ <ref name="bkeyword"/>
694
+ </zeroOrMore>
695
+ <optional>
696
+ <ref name="validity"/>
697
+ </optional>
698
+ </define>
699
+ <define name="ReducedBibliographicItem">
700
+ <optional>
701
+ <attribute name="type">
702
+ <ref name="BibItemType"/>
703
+ </attribute>
704
+ </optional>
705
+ <optional>
706
+ <ref name="fetched"/>
707
+ </optional>
708
+ <optional>
709
+ <ref name="formattedref"/>
710
+ </optional>
711
+ <zeroOrMore>
712
+ <ref name="btitle"/>
713
+ </zeroOrMore>
714
+ <zeroOrMore>
715
+ <ref name="bsource"/>
716
+ </zeroOrMore>
626
717
  <zeroOrMore>
627
718
  <ref name="docidentifier"/>
628
719
  </zeroOrMore>
@@ -638,9 +729,9 @@
638
729
  <optional>
639
730
  <ref name="edition"/>
640
731
  </optional>
641
- <optional>
732
+ <zeroOrMore>
642
733
  <ref name="version"/>
643
- </optional>
734
+ </zeroOrMore>
644
735
  <zeroOrMore>
645
736
  <ref name="biblionote"/>
646
737
  </zeroOrMore>
@@ -833,6 +924,12 @@
833
924
  <data type="boolean"/>
834
925
  </attribute>
835
926
  </optional>
927
+ <optional>
928
+ <attribute name="language"/>
929
+ </optional>
930
+ <optional>
931
+ <attribute name="script"/>
932
+ </optional>
836
933
  <text/>
837
934
  </element>
838
935
  </define>
@@ -1172,7 +1269,7 @@
1172
1269
  </element>
1173
1270
  </optional>
1174
1271
  <element name="bibitem">
1175
- <ref name="BibliographicItem"/>
1272
+ <ref name="ReducedBibliographicItem"/>
1176
1273
  </element>
1177
1274
  <choice>
1178
1275
  <zeroOrMore>
@@ -1197,9 +1294,9 @@
1197
1294
  <optional>
1198
1295
  <ref name="revision-date"/>
1199
1296
  </optional>
1200
- <zeroOrMore>
1297
+ <optional>
1201
1298
  <ref name="draft"/>
1202
- </zeroOrMore>
1299
+ </optional>
1203
1300
  </element>
1204
1301
  </define>
1205
1302
  <define name="vedition">
@@ -1,8 +1,5 @@
1
1
  require "date"
2
- require "nokogiri"
3
2
  require "htmlentities"
4
- require "json"
5
- require "pathname"
6
3
 
7
4
  module Metanorma
8
5
  module ISO
@@ -15,8 +12,7 @@ module Metanorma
15
12
 
16
13
  POST_NORMREF_FOOTNOTES =
17
14
  "//sections//clause[not(@type = 'scope')]//fn | "\
18
- "//annex//fn | "\
19
- "//references[@normative = 'false']//fn".freeze
15
+ "//annex//fn | //references[@normative = 'false']//fn".freeze
20
16
 
21
17
  def other_footnote_renumber(xmldoc)
22
18
  seen = {}
@@ -118,9 +114,7 @@ module Metanorma
118
114
  super
119
115
  return unless @amd
120
116
 
121
- xml.xpath("//*[@inline-header]").each do |h|
122
- h.delete("inline-header")
123
- end
117
+ xml.xpath("//*[@inline-header]").each { |h| h.delete("inline-header") }
124
118
  end
125
119
 
126
120
  def boilerplate_file(_xmldoc)
@@ -170,8 +164,7 @@ module Metanorma
170
164
 
171
165
  if id = replacement_standard(b)
172
166
  insert_unpub_note(b, @i18n.cancelled_and_replaced.sub(/%/, id))
173
- else
174
- insert_unpub_note(b, @i18n.withdrawn)
167
+ else insert_unpub_note(b, @i18n.withdrawn)
175
168
  end
176
169
  end
177
170
  end
@@ -214,25 +207,43 @@ module Metanorma
214
207
  super
215
208
  approval_groups_rename(xmldoc)
216
209
  editorial_groups_agency(xmldoc)
210
+ editorial_group_types(xmldoc)
217
211
  end
218
212
 
219
213
  def approval_groups_rename(xmldoc)
220
214
  %w(technical-committee subcommittee workgroup).each do |v|
221
- xmldoc.xpath("//bibdata//approval-#{v}").each do |a|
222
- a.name = v
223
- end
215
+ xmldoc.xpath("//bibdata//approval-#{v}").each { |a| a.name = v }
224
216
  end
225
217
  end
226
218
 
227
219
  def editorial_groups_agency(xmldoc)
228
- pubs = xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']/"\
229
- "organization").each_with_object([]) do |p, m|
220
+ pubs = extract_publishers(xmldoc)
221
+ xmldoc.xpath("//bibdata/ext/editorialgroup").each do |e|
222
+ pubs.reverse.each do |p|
223
+ if e.children.empty? then e << "<agency>#{p}</agency>"
224
+ else e.children.first.previous = "<agency>#{p}</agency>"
225
+ end
226
+ end
227
+ end
228
+ end
229
+
230
+ def extract_publishers(xmldoc)
231
+ xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']/"\
232
+ "organization").each_with_object([]) do |p, m|
230
233
  x = p.at("./abbreviation") || p.at("./name") or next
231
234
  m << x.text
232
235
  end
233
- xmldoc.xpath("//bibdata/ext/editorialgroup").each do |e|
234
- pubs.reverse.each do |p|
235
- e.children.first.previous = "<agency>#{p}</agency>"
236
+ end
237
+
238
+ DEFAULT_EDGROUP_TYPE = { "technical-committee": "TC",
239
+ subcommittee: "SC", workgroup: "WG" }.freeze
240
+
241
+ def editorial_group_types(xmldoc)
242
+ %w(technical-committee subcommittee workgroup).each do |v|
243
+ xmldoc.xpath("//bibdata//#{v} | //bibdata//approval-#{v}").each do |g|
244
+ next if g["type"]
245
+
246
+ g["type"] = DEFAULT_EDGROUP_TYPE[v.to_sym]
236
247
  end
237
248
  end
238
249
  end
@@ -88,24 +88,31 @@ module Metanorma
88
88
  def metadata_editorial_committee(node, xml)
89
89
  xml.editorialgroup do |a|
90
90
  %w(technical-committee subcommittee workgroup).each do |v|
91
- committee_component(v, node, a)
91
+ node.attr("#{v}-number") and committee_component(v, node, a)
92
92
  end
93
93
  node.attr("secretariat") and a.secretariat(node.attr("secretariat"))
94
94
  end
95
95
  end
96
96
 
97
97
  def metadata_approval_committee(node, xml)
98
- types = %w(technical-committee subcommittee workgroup)
99
- node.attr("approval-technical-committee-number") and
100
- types = %w(approval-technical-committee approval-subcommittee
101
- approval-workgroup)
98
+ types = metadata_approval_committee_types(node)
102
99
  xml.approvalgroup do |a|
103
100
  metadata_approval_agency(a, node.attr("approval-agency")
104
101
  &.split(%r{[/,;]}))
105
- types.each { |v| committee_component(v, node, a) }
102
+ types.each do |v|
103
+ node.attr("#{v}-number") and committee_component(v, node, a)
104
+ end
106
105
  end
107
106
  end
108
107
 
108
+ def metadata_approval_committee_types(node)
109
+ types = %w(technical-committee subcommittee workgroup)
110
+ node.attr("approval-technical-committee-number") and
111
+ types = %w(approval-technical-committee approval-subcommittee
112
+ approval-workgroup)
113
+ types
114
+ end
115
+
109
116
  def metadata_approval_agency(xml, list)
110
117
  list = ["ISO"] if list.nil? || list.empty?
111
118
  list.each do |v|
@@ -703,6 +703,9 @@
703
703
  <optional>
704
704
  <attribute name="tag"/>
705
705
  </optional>
706
+ <optional>
707
+ <attribute name="type"/>
708
+ </optional>
706
709
  <optional>
707
710
  <attribute name="multilingual-rendering">
708
711
  <ref name="MultilingualRenderingType"/>
@@ -738,6 +741,9 @@
738
741
  <optional>
739
742
  <attribute name="tag"/>
740
743
  </optional>
744
+ <optional>
745
+ <attribute name="type"/>
746
+ </optional>
741
747
  <optional>
742
748
  <attribute name="multilingual-rendering">
743
749
  <ref name="MultilingualRenderingType"/>
@@ -2059,6 +2065,7 @@
2059
2065
  <value>compare</value>
2060
2066
  <value>contrast</value>
2061
2067
  <value>see</value>
2068
+ <value>seealso</value>
2062
2069
  </choice>
2063
2070
  </define>
2064
2071
  <define name="deprecates">
@@ -202,18 +202,6 @@ module Metanorma
202
202
  end
203
203
  end
204
204
 
205
- def asset_style(root)
206
- root.xpath("//example | //termexample").each { |e| example_style(e) }
207
- root.xpath("//definition/verbal-definition").each do |e|
208
- definition_style(e)
209
- end
210
- root.xpath("//note").each { |e| note_style(e) }
211
- root.xpath("//fn").each { |e| footnote_style(e) }
212
- root.xpath(ASSETS_TO_STYLE).each { |e| style(e, extract_text(e)) }
213
- norm_bibitem_style(root)
214
- super
215
- end
216
-
217
205
  def subclause_validate(root)
218
206
  root.xpath("//clause/clause/clause/clause/clause/clause/clause/clause")
219
207
  .each do |c|
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.1.2".freeze
3
+ VERSION = "2.1.3".freeze
4
4
  end
5
5
  end
@@ -576,17 +576,11 @@ RSpec.describe IsoDoc do
576
576
  <ext>
577
577
  <doctype>standard</doctype>
578
578
  <subdoctype>vocabulary</subdoctype>
579
- <editorialgroup identifier='ISO/ / / '>
579
+ <editorialgroup identifier='ISO'>
580
580
  <agency>ISO</agency>
581
- <technical-committee/>
582
- <subcommittee/>
583
- <workgroup/>
584
581
  </editorialgroup>
585
- <approvalgroup identifier='ISO/ / / '>
582
+ <approvalgroup identifier='ISO'>
586
583
  <agency>ISO</agency>
587
- <technical-committee/>
588
- <subcommittee/>
589
- <workgroup/>
590
584
  </approvalgroup>
591
585
  <stagename>International standard</stagename>
592
586
  </ext>
@@ -673,6 +673,66 @@ RSpec.describe IsoDoc do
673
673
  .to be_equivalent_to xmlpp(word)
674
674
  end
675
675
 
676
+ it "deals with lists and paragraphs" do
677
+ input = <<~INPUT
678
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
679
+ <bibdata>
680
+ <status><stage>50</stage></status>
681
+ </bibdata>
682
+ <sections>
683
+ <clause id="A">
684
+ <p id="_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828">ISO and IEC maintain terminological databases for use in
685
+ standardization at the following addresses:</p>
686
+
687
+ <ul id="_6f8dbb84-61d9-f774-264e-b7e249cf44d1">
688
+ <li> <p id="_9f56356a-3a58-64c4-e59e-a23ca3da7e88">ISO Online browsing platform: available at
689
+ <link target="https://www.iso.org/obp"/></p></li>
690
+ <li> <p id="_5dc6886f-a99c-e420-a29d-2aa6ca9f376e">IEC Electropedia: available at
691
+ <link target="https://www.electropedia.org"/>
692
+ </p> </li> </ul>
693
+ </clause>
694
+ </sections>
695
+ </iso-standard>
696
+ INPUT
697
+ word = <<~OUTPUT
698
+ <div class='WordSection3'>
699
+ <p class='zzSTDTitle'/>
700
+ <div>
701
+ <a name='A' id='A'/>
702
+ <h1>1</h1>
703
+ <p class='MsoBodyText'>
704
+ <a name='_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828' id='_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828'/>
705
+ ISO and IEC maintain terminological databases for use in standardization
706
+ at the following addresses:
707
+ </p>
708
+ <p class='ListContinue1'>
709
+
710
+ <span style='mso-tab-count:1'> </span>
711
+ ISO Online browsing platform: available at
712
+ <a href='https://www.iso.org/obp'>https://www.iso.org/obp</a>
713
+ </p>
714
+ <p class='ListContinue1'>
715
+
716
+ <span style='mso-tab-count:1'> </span>
717
+ IEC Electropedia: available at
718
+ <a href='https://www.electropedia.org'>https://www.electropedia.org</a>
719
+ </p>
720
+ </div>
721
+ </div>
722
+ OUTPUT
723
+ FileUtils.rm_f "test.doc"
724
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
725
+ .convert("test", input, true)
726
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
727
+ expect(File.exist?("test.doc")).to be true
728
+ output = File.read("test.doc", encoding: "UTF-8")
729
+ .sub(/^.*<html/m, "<html")
730
+ .sub(/<\/html>.*$/m, "</html>")
731
+ expect(xmlpp(Nokogiri::XML(output)
732
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml))
733
+ .to be_equivalent_to xmlpp(word)
734
+ end
735
+
676
736
  it "deals with ordered list start" do
677
737
  input = <<~INPUT
678
738
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -352,15 +352,9 @@ RSpec.describe Metanorma::ISO do
352
352
  <doctype>amendment</doctype>
353
353
  <editorialgroup>
354
354
  <agency>ISO</agency>
355
- <technical-committee/>
356
- <subcommittee/>
357
- <workgroup/>
358
355
  </editorialgroup>
359
356
  <approvalgroup>
360
357
  <agency>ISO</agency>
361
- <technical-committee/>
362
- <subcommittee/>
363
- <workgroup/>
364
358
  </approvalgroup>
365
359
  <structuredidentifier>
366
360
  <project-number amendment="1" part="1">17301</project-number>
@@ -431,15 +425,9 @@ RSpec.describe Metanorma::ISO do
431
425
  <doctype>amendment</doctype>
432
426
  <editorialgroup>
433
427
  <agency>ISO</agency>
434
- <technical-committee/>
435
- <subcommittee/>
436
- <workgroup/>
437
428
  </editorialgroup>
438
429
  <approvalgroup>
439
430
  <agency>ISO</agency>
440
- <technical-committee/>
441
- <subcommittee/>
442
- <workgroup/>
443
431
  </approvalgroup>
444
432
  <structuredidentifier>
445
433
  <project-number amendment="1" part="1">17301</project-number>
@@ -507,17 +495,11 @@ RSpec.describe Metanorma::ISO do
507
495
  </copyright>
508
496
  <ext>
509
497
  <doctype>amendment</doctype>
510
- <editorialgroup>
498
+ <editorialgroup>
511
499
  <agency>ISO</agency>
512
- <technical-committee/>
513
- <subcommittee/>
514
- <workgroup/>
515
500
  </editorialgroup>
516
501
  <approvalgroup>
517
502
  <agency>ISO</agency>
518
- <technical-committee/>
519
- <subcommittee/>
520
- <workgroup/>
521
503
  </approvalgroup>
522
504
  <structuredidentifier>
523
505
  <project-number amendment="1" part="1">17301</project-number>
@@ -586,17 +568,11 @@ RSpec.describe Metanorma::ISO do
586
568
  </copyright>
587
569
  <ext>
588
570
  <doctype>technical-corrigendum</doctype>
589
- <editorialgroup>
571
+ <editorialgroup>
590
572
  <agency>ISO</agency>
591
- <technical-committee/>
592
- <subcommittee/>
593
- <workgroup/>
594
573
  </editorialgroup>
595
574
  <approvalgroup>
596
575
  <agency>ISO</agency>
597
- <technical-committee/>
598
- <subcommittee/>
599
- <workgroup/>
600
576
  </approvalgroup>
601
577
  <structuredidentifier>
602
578
  <project-number corrigendum="3" part="1">17301</project-number>
@@ -665,17 +641,11 @@ RSpec.describe Metanorma::ISO do
665
641
  </copyright>
666
642
  <ext>
667
643
  <doctype>technical-corrigendum</doctype>
668
- <editorialgroup>
644
+ <editorialgroup>
669
645
  <agency>ISO</agency>
670
- <technical-committee/>
671
- <subcommittee/>
672
- <workgroup/>
673
646
  </editorialgroup>
674
647
  <approvalgroup>
675
648
  <agency>ISO</agency>
676
- <technical-committee/>
677
- <subcommittee/>
678
- <workgroup/>
679
649
  </approvalgroup>
680
650
  <structuredidentifier>
681
651
  <project-number part='1' corrigendum='3'>17301</project-number>
@@ -743,17 +713,11 @@ RSpec.describe Metanorma::ISO do
743
713
  </copyright>
744
714
  <ext>
745
715
  <doctype>technical-corrigendum</doctype>
746
- <editorialgroup>
716
+ <editorialgroup>
747
717
  <agency>ISO</agency>
748
- <technical-committee/>
749
- <subcommittee/>
750
- <workgroup/>
751
718
  </editorialgroup>
752
719
  <approvalgroup>
753
720
  <agency>ISO</agency>
754
- <technical-committee/>
755
- <subcommittee/>
756
- <workgroup/>
757
721
  </approvalgroup>
758
722
  <structuredidentifier>
759
723
  <project-number corrigendum="3" part="1">17301</project-number>