metanorma-iec 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,8 +64,13 @@ RSpec.describe IsoDoc do
64
64
  </body>
65
65
  </html>
66
66
  OUTPUT
67
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
68
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
67
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
68
+ .convert("test", input, true)
69
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
70
+ .to be_equivalent_to xmlpp(presxml)
71
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
72
+ .convert("test", presxml, true)))
73
+ .to be_equivalent_to xmlpp(html)
69
74
  end
70
75
 
71
76
  it "processes bibliographies under IEV" do
@@ -227,8 +232,13 @@ RSpec.describe IsoDoc do
227
232
  </body>
228
233
  </html>
229
234
  OUTPUT
230
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
231
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
235
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
236
+ .convert("test", input, true)
237
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
238
+ .to be_equivalent_to xmlpp(presxml)
239
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
240
+ .convert("test", presxml, true)))
241
+ .to be_equivalent_to xmlpp(html)
232
242
  end
233
243
 
234
244
  it "processes IEV terms" do
@@ -241,8 +251,8 @@ RSpec.describe IsoDoc do
241
251
  <sections>
242
252
  <clause id="_terms_and_definitions" obligation="normative"><title>Terms and definitions</title>
243
253
  <terms id="_general" obligation="normative"><title>General</title>
244
- <term id="paddy1"><preferred>paddy</preferred>
245
- <definition><verbaldefinition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbaldefinition></definition>
254
+ <term id="paddy1"><preferred><expression><name>paddy</name></expression></preferred>
255
+ <definition><verbal-definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbal-definition></definition>
246
256
  <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
247
257
  <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
248
258
  <ul>
@@ -260,11 +270,12 @@ RSpec.describe IsoDoc do
260
270
  <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
261
271
  </modification>
262
272
  </termsource></term>
263
- <term id="paddy"><preferred>paddy</preferred><admitted>paddy rice</admitted>
264
- <admitted>rough rice</admitted>
265
- <deprecates>cargo rice</deprecates>
273
+ <term id="paddy"><preferred><expression><name>paddy</name></expression></preferred>
274
+ <admitted><expression><name>paddy rice</name></expression></admitted>
275
+ <admitted><expression><name>rough rice</name></expression></admitted>
276
+ <deprecates><expression><name>cargo rice</name></expression></deprecates>
266
277
  <domain>rice</domain>
267
- <definition><verbaldefinition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbaldefinition></definition>
278
+ <definition><verbal-definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbal-definition></definition>
268
279
  <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
269
280
  <ul>
270
281
  <li>A</li>
@@ -287,6 +298,7 @@ RSpec.describe IsoDoc do
287
298
  INPUT
288
299
 
289
300
  presxml = <<~INPUT
301
+ <?xml version='1.0'?>
290
302
  <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
291
303
  <bibdata type='standard'>
292
304
  <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
@@ -297,7 +309,7 @@ RSpec.describe IsoDoc do
297
309
  <terms id="_general" obligation="normative"><title>192-01 General</title>
298
310
  <term id="paddy1">
299
311
  <name>192-01-01</name>
300
- <preferred>paddy</preferred>
312
+ <preferred><strong>paddy</strong></preferred>
301
313
  <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
302
314
  <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
303
315
  <name>EXAMPLE 1</name>
@@ -320,11 +332,10 @@ RSpec.describe IsoDoc do
320
332
  </termsource></term>
321
333
  <term id="paddy">
322
334
  <name>192-01-02</name>
323
- <preferred>paddy</preferred><admitted>paddy rice</admitted>
335
+ <preferred><strong>paddy</strong></preferred><admitted>paddy rice</admitted>
324
336
  <admitted>rough rice</admitted>
325
337
  <deprecates>cargo rice</deprecates>
326
- <domain>rice</domain>
327
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
338
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">&#x3c;rice&#x3e; rice retaining its husk after threshing</p></definition>
328
339
  <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
329
340
  <name>EXAMPLE</name>
330
341
  <ul>
@@ -364,7 +375,7 @@ RSpec.describe IsoDoc do
364
375
  <b>192-01 General</b>
365
376
  </p>
366
377
  <p class='TermNum' id='paddy1'>192-01-01</p>
367
- <p class='Terms' style='text-align:left;'>paddy</p>
378
+ <p class='Terms' style='text-align:left;'><b>paddy</b></p>
368
379
  <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
369
380
  <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f892' class='example'>
370
381
  <p>
@@ -391,11 +402,11 @@ RSpec.describe IsoDoc do
391
402
  Note 1 to entry is not included here [/TERMREF]
392
403
  </p>
393
404
  <p class='TermNum' id='paddy'>192-01-02</p>
394
- <p class='Terms' style='text-align:left;'>paddy, &lt;rice&gt;</p>
395
- <p class='AltTerms' style='text-align:left;'>paddy rice, &lt;rice&gt;</p>
396
- <p class='AltTerms' style='text-align:left;'>rough rice, &lt;rice&gt;</p>
397
- <p class='DeprecatedTerms' style='text-align:left;'>DEPRECATED: cargo rice, &lt;rice&gt;</p>
398
- <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
405
+ <p class='Terms' style='text-align:left;'><b>paddy</b></p>
406
+ <p class='AltTerms' style='text-align:left;'>paddy rice</p>
407
+ <p class='AltTerms' style='text-align:left;'>rough rice</p>
408
+ <p class='DeprecatedTerms' style='text-align:left;'>DEPRECATED: cargo rice</p>
409
+ <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>&lt;rice&gt; rice retaining its husk after threshing</p>
399
410
  <div id='_bd57bbf1-f948-4bae-b0ce-73c00431f893' class='example'>
400
411
  <p>
401
412
  <span class='example_label'>EXAMPLE</span>
@@ -435,8 +446,13 @@ RSpec.describe IsoDoc do
435
446
  </body>
436
447
  </html>
437
448
  OUTPUT
438
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
439
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
449
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
450
+ .convert("test", input, true)
451
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
452
+ .to be_equivalent_to xmlpp(presxml)
453
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
454
+ .convert("test", presxml, true)))
455
+ .to be_equivalent_to xmlpp(html)
440
456
  end
441
457
 
442
458
  it "populates Word template with terms reference labels" do
@@ -451,8 +467,8 @@ RSpec.describe IsoDoc do
451
467
  <sections>
452
468
  <clause id="_terms_and_definitions" obligation="normative" displayorder="1"><title>Terms and definitions</title>
453
469
  <terms id="_general" obligation="normative"><title>General</title>
454
- <term id="paddy1"><preferred>paddy</preferred>
455
- <definition><verbaldefinition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbaldefinition></definition>
470
+ <term id="paddy1"><preferred><expression><name>paddy</name></expression></preferred>
471
+ <definition><verbal-definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbal-definition></definition>
456
472
  <termsource status="modified">
457
473
  <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
458
474
  <modification>
@@ -477,7 +493,7 @@ RSpec.describe IsoDoc do
477
493
  <title>192-01 General</title>
478
494
  <term id='paddy1'>
479
495
  <name>192-01-01</name>
480
- <preferred>paddy</preferred>
496
+ <preferred><strong>paddy</strong></preferred>
481
497
  <definition>
482
498
  <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
483
499
  </definition>
@@ -501,9 +517,13 @@ RSpec.describe IsoDoc do
501
517
  </sections>
502
518
  </iso-standard>
503
519
  OUTPUT
504
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
520
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
521
+ .convert("test", input, true)
522
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
523
+ .to be_equivalent_to xmlpp(presxml)
505
524
  IsoDoc::Iec::WordConvert.new({}).convert("test", presxml, false)
506
- word = File.read("test.doc").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
525
+ word = File.read("test.doc")
526
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
507
527
  .sub(%r{<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>.*$}m, "")
508
528
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
509
529
  <div class='WordSection3'>
@@ -530,7 +550,7 @@ RSpec.describe IsoDoc do
530
550
  <a name='paddy1' id='paddy1'/>
531
551
  192-01-01
532
552
  </p>
533
- <p class='Terms' style='text-align:left;'>paddy</p>
553
+ <p class='Terms' style='text-align:left;'><b>paddy</b></p>
534
554
  <p class='MsoNormal'>
535
555
  <a name='_eb29b35e-123e-4d1c-b50b-2714d41e747f' id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'/>
536
556
  rice retaining its husk after threshing
@@ -546,4 +566,92 @@ RSpec.describe IsoDoc do
546
566
  </div>
547
567
  OUTPUT
548
568
  end
569
+
570
+ it "convert termbase references to the current document to xrefs" do
571
+ input = <<~INPUT
572
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
573
+ <bibdata type='standard'>
574
+ <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
575
+ <docnumber>60050</docnumber>
576
+ <ext>
577
+ <doctype>international-standard</doctype>
578
+ <horizontal>false</horizontal>
579
+ <structuredidentifier>
580
+ <project-number part="192">IEC 60050</project-number>
581
+ </structuredidentifier>
582
+ <stagename>International standard</stagename>
583
+ </ext>
584
+ </bibdata>
585
+ <sections>
586
+ <clause id="_terms_and_definitions" obligation="normative" displayorder="1"><title>Terms and definitions</title>
587
+ <terms id="_general" obligation="normative"><title>General</title>
588
+ <term id="term-durability"><preferred><expression><name>durability</name></expression><field-of-application>of an item</field-of-application></preferred>
589
+ <definition><verbaldefinition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></verbaldefinition></definition>
590
+ <termnote id="_5f49cfad-e57e-5029-78cf-5b7e3e10a3b3">
591
+ <p id="_8c830e60-8f09-73a2-6393-2a27d9c5b1ce">Dependability includes availability (<concept><refterm>192-01-02</refterm><renderterm>192-01-02</renderterm><termref base="IEV" target="192-01-02"/></concept>, <concept><refterm>191-01-02</refterm><renderterm>191-01-02</renderterm><termref base="IEV" target="191-01-02"/></concept>)</p>
592
+ </termnote>
593
+ </term>
594
+ <term id="term-sub-item"><preferred><expression><name>sub item</name></expression></preferred><definition><verbal-definition><p id="_6952e988-8803-159d-a32e-57147fbf3d86">part of the subject being considered</p></verbal-definition></definition>
595
+ </term>
596
+ </terms>
597
+ </clause>
598
+ </sections>
599
+ </iso-standard>
600
+ INPUT
601
+ presxml = <<~PRESXML
602
+ <?xml version='1.0'?>
603
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
604
+ <bibdata type='standard'>
605
+ <docidentifier type='ISO'>IEC 60050-192 ED 1</docidentifier>
606
+ <docnumber>60050</docnumber>
607
+ <ext>
608
+ <doctype language=''>international-standard</doctype>
609
+ <doctype language='fr'>Norme international</doctype>
610
+ <doctype language='en'>International Standard</doctype>
611
+ <horizontal language=''>false</horizontal>
612
+ <structuredidentifier>
613
+ <project-number part='192'>IEC 60050</project-number>
614
+ </structuredidentifier>
615
+ <stagename>International standard</stagename>
616
+ </ext>
617
+ </bibdata>
618
+ <sections>
619
+ <clause id='_terms_and_definitions' obligation='normative' displayorder='1'>
620
+ <title depth='1'>1<tab/>Terms and definitions</title>
621
+ <terms id='_general' obligation='normative'>
622
+ <title>192-01 General</title>
623
+ <term id='term-durability'>
624
+ <name>192-01-01</name>
625
+ <preferred><strong>durability, &#x3c;of an item&#x3e;</strong></preferred>
626
+ <definition>
627
+ <verbaldefinition>
628
+ <p id='_eb29b35e-123e-4d1c-b50b-2714d41e747f'>rice retaining its husk after threshing</p>
629
+ </verbaldefinition>
630
+ </definition>
631
+ <termnote id='_5f49cfad-e57e-5029-78cf-5b7e3e10a3b3'>
632
+ <name>Note 1 to entry</name>
633
+ <p id='_8c830e60-8f09-73a2-6393-2a27d9c5b1ce'>Dependability includes availability (<em>192-01-02</em>
634
+ (<xref target='term-sub-item'>192-01-02</xref>),
635
+ <em>191-01-02</em>
636
+ [term defined in
637
+ <termref base='IEV' target='191-01-02'/>])</p>
638
+ </termnote>
639
+ </term>
640
+ <term id='term-sub-item'>
641
+ <name>192-01-02</name>
642
+ <preferred><strong>sub item</strong></preferred>
643
+ <definition>
644
+ <p id='_6952e988-8803-159d-a32e-57147fbf3d86'>part of the subject being considered</p>
645
+ </definition>
646
+ </term>
647
+ </terms>
648
+ </clause>
649
+ </sections>
650
+ </iso-standard>
651
+ PRESXML
652
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
653
+ .convert("test", input, true)
654
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
655
+ .to be_equivalent_to xmlpp(presxml)
656
+ end
549
657
  end