metanorma-iso 1.9.4 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ubuntu.yml +41 -0
  3. data/Gemfile +3 -4
  4. data/Makefile +44 -0
  5. data/Rakefile +1 -1
  6. data/bin/rspec +1 -2
  7. data/lib/asciidoctor/iso/basicdoc.rng +32 -5
  8. data/lib/asciidoctor/iso/biblio.rng +2 -0
  9. data/lib/asciidoctor/iso/cleanup.rb +7 -6
  10. data/lib/asciidoctor/iso/front.rb +9 -1
  11. data/lib/asciidoctor/iso/isodoc.rng +430 -76
  12. data/lib/asciidoctor/iso/isostandard-amd.rng +1 -1
  13. data/lib/asciidoctor/iso/isostandard.rng +9 -23
  14. data/lib/asciidoctor/iso/reqt.rng +24 -3
  15. data/lib/asciidoctor/iso/validate.rb +7 -7
  16. data/lib/asciidoctor/iso/validate_section.rb +1 -1
  17. data/lib/isodoc/iso/html/isodoc.css +1 -2
  18. data/lib/isodoc/iso/html/isodoc.scss +1 -1
  19. data/lib/isodoc/iso/html/wordstyle.css +16 -4
  20. data/lib/isodoc/iso/html/wordstyle.scss +16 -4
  21. data/lib/isodoc/iso/i18n.rb +10 -9
  22. data/lib/isodoc/iso/iso.amendment.xsl +200 -20
  23. data/lib/isodoc/iso/iso.international-standard.xsl +200 -20
  24. data/lib/isodoc/iso/presentation_xml_convert.rb +9 -10
  25. data/lib/isodoc/iso/sections.rb +2 -0
  26. data/lib/isodoc/iso/word_cleanup.rb +94 -0
  27. data/lib/isodoc/iso/word_convert.rb +12 -89
  28. data/lib/metanorma/iso/version.rb +1 -1
  29. data/metanorma-iso.gemspec +4 -3
  30. data/spec/asciidoctor/base_spec.rb +685 -178
  31. data/spec/asciidoctor/blank_spec.rb +38 -0
  32. data/spec/asciidoctor/blocks_spec.rb +22 -47
  33. data/spec/asciidoctor/cleanup_spec.rb +34 -20
  34. data/spec/asciidoctor/inline_spec.rb +10 -2
  35. data/spec/asciidoctor/refs_spec.rb +87 -4
  36. data/spec/asciidoctor/section_spec.rb +3 -3
  37. data/spec/isodoc/i18n_spec.rb +29 -15
  38. data/spec/isodoc/inline_spec.rb +56 -26
  39. data/spec/isodoc/section_spec.rb +1 -1
  40. data/spec/isodoc/table_spec.rb +6 -8
  41. data/spec/isodoc/terms_spec.rb +11 -11
  42. data/spec/isodoc/xref_spec.rb +1397 -1376
  43. data/spec/metanorma/processor_spec.rb +4 -1
  44. data/spec/spec_helper.rb +14 -1
  45. data/spec/vcr_cassettes/docrels.yml +783 -0
  46. data/spec/vcr_cassettes/sortrefs.yml +599 -0
  47. metadata +38 -19
@@ -1798,7 +1798,7 @@
1798
1798
  </xsl:variable>
1799
1799
  <fo:block line-height="1.1" role="H{$levelTerm}">
1800
1800
  <fo:block font-weight="bold" keep-with-next="always">
1801
- <xsl:apply-templates select="ancestor::iso:term/iso:name" mode="presentation"/>
1801
+ <xsl:apply-templates select="ancestor::iso:term[1]/iso:name" mode="presentation"/>
1802
1802
  </fo:block>
1803
1803
  <fo:block font-weight="bold" keep-with-next="always">
1804
1804
  <xsl:apply-templates/>
@@ -2260,6 +2260,8 @@
2260
2260
 
2261
2261
  <title-list-figures lang="en">List of Figures</title-list-figures>
2262
2262
 
2263
+ <title-table-figures lang="en">Table of Figures</title-table-figures>
2264
+
2263
2265
  <title-list-recommendations lang="en">List of Recommendations</title-list-recommendations>
2264
2266
 
2265
2267
  <title-acknowledgements lang="en">Acknowledgements</title-acknowledgements>
@@ -2558,6 +2560,11 @@
2558
2560
 
2559
2561
 
2560
2562
 
2563
+ </xsl:attribute-set><xsl:attribute-set name="table-note-name-style">
2564
+
2565
+
2566
+
2567
+
2561
2568
  </xsl:attribute-set><xsl:attribute-set name="note-p-style">
2562
2569
 
2563
2570
 
@@ -2731,13 +2738,20 @@
2731
2738
 
2732
2739
  </xsl:attribute-set><xsl:attribute-set name="list-style">
2733
2740
 
2734
- </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
2741
+ </xsl:attribute-set><xsl:attribute-set name="toc-style">
2742
+ <xsl:attribute name="line-height">135%</xsl:attribute>
2743
+ </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="OLD_processPrefaceSectionsDefault_Contents">
2735
2744
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
2736
2745
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
2737
2746
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
2738
2747
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']" mode="contents"/>
2739
2748
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']" mode="contents"/>
2740
- </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2749
+ </xsl:template><xsl:template name="processPrefaceSectionsDefault_Contents">
2750
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2751
+ <xsl:sort select="@displayorder" data-type="number"/>
2752
+ <xsl:apply-templates select="." mode="contents"/>
2753
+ </xsl:for-each>
2754
+ </xsl:template><xsl:template name="OLD_processMainSectionsDefault_Contents">
2741
2755
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
2742
2756
 
2743
2757
  <!-- Normative references -->
@@ -2750,13 +2764,33 @@
2750
2764
  <!-- Bibliography -->
2751
2765
  <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]" mode="contents"/>
2752
2766
 
2753
- </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2767
+ </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2768
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2769
+ <xsl:sort select="@displayorder" data-type="number"/>
2770
+ <xsl:apply-templates select="." mode="contents"/>
2771
+ </xsl:for-each>
2772
+
2773
+ <xsl:for-each select="/*/*[local-name()='annex']">
2774
+ <xsl:sort select="@displayorder" data-type="number"/>
2775
+ <xsl:apply-templates select="." mode="contents"/>
2776
+ </xsl:for-each>
2777
+
2778
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2779
+ <xsl:sort select="@displayorder" data-type="number"/>
2780
+ <xsl:apply-templates select="." mode="contents"/>
2781
+ </xsl:for-each>
2782
+ </xsl:template><xsl:template name="OLD_processPrefaceSectionsDefault">
2754
2783
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
2755
2784
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
2756
2785
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']"/>
2757
2786
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']"/>
2758
2787
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']"/>
2759
- </xsl:template><xsl:template name="processMainSectionsDefault">
2788
+ </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2789
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2790
+ <xsl:sort select="@displayorder" data-type="number"/>
2791
+ <xsl:apply-templates select="."/>
2792
+ </xsl:for-each>
2793
+ </xsl:template><xsl:template name="OLD_processMainSectionsDefault">
2760
2794
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']"/>
2761
2795
 
2762
2796
  <!-- Normative references -->
@@ -2768,6 +2802,22 @@
2768
2802
  <xsl:apply-templates select="/*/*[local-name()='annex']"/>
2769
2803
  <!-- Bibliography -->
2770
2804
  <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]"/>
2805
+ </xsl:template><xsl:template name="processMainSectionsDefault">
2806
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2807
+ <xsl:sort select="@displayorder" data-type="number"/>
2808
+ <xsl:apply-templates select="."/>
2809
+
2810
+ </xsl:for-each>
2811
+
2812
+ <xsl:for-each select="/*/*[local-name()='annex']">
2813
+ <xsl:sort select="@displayorder" data-type="number"/>
2814
+ <xsl:apply-templates select="."/>
2815
+ </xsl:for-each>
2816
+
2817
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2818
+ <xsl:sort select="@displayorder" data-type="number"/>
2819
+ <xsl:apply-templates select="."/>
2820
+ </xsl:for-each>
2771
2821
  </xsl:template><xsl:template match="text()">
2772
2822
  <xsl:value-of select="."/>
2773
2823
  </xsl:template><xsl:template match="*[local-name()='br']">
@@ -3714,9 +3764,8 @@
3714
3764
 
3715
3765
  <!-- Table's note name (NOTE, for example) -->
3716
3766
 
3717
- <fo:inline padding-right="2mm">
3767
+ <fo:inline padding-right="2mm" xsl:use-attribute-sets="table-note-name-style">
3718
3768
 
3719
-
3720
3769
 
3721
3770
 
3722
3771
 
@@ -4246,6 +4295,7 @@
4246
4295
  <fo:table-cell>
4247
4296
 
4248
4297
  <fo:block margin-top="6pt">
4298
+ <xsl:copy-of select="@id"/>
4249
4299
 
4250
4300
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
4251
4301
 
@@ -4351,6 +4401,8 @@
4351
4401
  <xsl:if test="$font-size != ''">
4352
4402
  <xsl:attribute name="font-size">
4353
4403
  <xsl:choose>
4404
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4405
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4354
4406
  <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4355
4407
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4356
4408
  </xsl:choose>
@@ -5090,14 +5142,20 @@
5090
5142
  </xsl:template><xsl:template match="*[local-name() = 'termnote']/*[local-name() = 'p']">
5091
5143
  <fo:inline><xsl:apply-templates/></fo:inline>
5092
5144
  </xsl:template><xsl:template match="*[local-name() = 'terms']">
5145
+ <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
5093
5146
  <fo:block id="{@id}">
5094
5147
  <xsl:apply-templates/>
5095
5148
  </fo:block>
5096
5149
  </xsl:template><xsl:template match="*[local-name() = 'term']">
5150
+ <!-- <xsl:message>'term' <xsl:number/> processing, name=<xsl:value-of select="iso:name"/>, preferred=<xsl:value-of select="iso:preferred"/>...</xsl:message> -->
5097
5151
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
5098
5152
 
5099
5153
 
5100
-
5154
+ <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'term'])">
5155
+
5156
+ <xsl:attribute name="space-before">12pt</xsl:attribute>
5157
+
5158
+ </xsl:if>
5101
5159
  <xsl:apply-templates/>
5102
5160
  </fo:block>
5103
5161
  </xsl:template><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']" mode="presentation">
@@ -5159,6 +5217,7 @@
5159
5217
  <xsl:otherwise>
5160
5218
  <fo:block xsl:use-attribute-sets="image-style">
5161
5219
 
5220
+
5162
5221
  <xsl:variable name="src">
5163
5222
  <xsl:call-template name="image_src"/>
5164
5223
  </xsl:variable>
@@ -5406,6 +5465,13 @@
5406
5465
  </xsl:attribute>
5407
5466
  <xsl:apply-templates mode="svg_update"/>
5408
5467
  </xsl:copy>
5468
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
5469
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
5470
+ <xsl:for-each select="*[local-name() = 'svg']">
5471
+ <xsl:call-template name="image_svg">
5472
+ <xsl:with-param name="name" select="$name"/>
5473
+ </xsl:call-template>
5474
+ </xsl:for-each>
5409
5475
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
5410
5476
  <xsl:variable name="svg_content" select="document(@src)"/>
5411
5477
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -5510,7 +5576,7 @@
5510
5576
  </fo:basic-link>
5511
5577
  </fo:block>
5512
5578
  </fo:block-container>
5513
- </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
5579
+ </xsl:template><xsl:template match="*[local-name() = 'emf']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
5514
5580
  <xsl:apply-templates mode="contents"/>
5515
5581
  <xsl:text> </xsl:text>
5516
5582
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="bookmarks">
@@ -5518,7 +5584,7 @@
5518
5584
  <xsl:text> </xsl:text>
5519
5585
  </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="contents" priority="2">
5520
5586
  <xsl:value-of select="."/>
5521
- </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="bookmarks" priority="2">
5587
+ </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']//text()" mode="bookmarks" priority="2">
5522
5588
  <xsl:value-of select="."/>
5523
5589
  </xsl:template><xsl:template match="node()" mode="contents">
5524
5590
  <xsl:apply-templates mode="contents"/>
@@ -5616,6 +5682,8 @@
5616
5682
 
5617
5683
 
5618
5684
 
5685
+
5686
+
5619
5687
  </fo:bookmark-tree>
5620
5688
  </xsl:if>
5621
5689
  </xsl:template><xsl:template name="insertFigureBookmarks">
@@ -5809,12 +5877,16 @@
5809
5877
  <xsl:if test="$font-size != ''">
5810
5878
  <xsl:attribute name="font-size">
5811
5879
  <xsl:choose>
5880
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
5881
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
5812
5882
  <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5813
5883
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
5814
5884
  </xsl:choose>
5815
5885
  </xsl:attribute>
5816
5886
  </xsl:if>
5817
5887
 
5888
+
5889
+
5818
5890
  <xsl:apply-templates/>
5819
5891
  </fo:block>
5820
5892
 
@@ -6057,7 +6129,8 @@
6057
6129
  </fo:block>
6058
6130
  </fo:table-cell>
6059
6131
  </xsl:template><xsl:template match="*[local-name() = 'p'][@class='RecommendationTitle' or @class = 'RecommendationTestTitle']" priority="2">
6060
- <fo:block font-size="11pt" color="rgb(237, 193, 35)"> <!-- font-weight="bold" margin-bottom="4pt" text-align="center" -->
6132
+ <fo:block font-size="11pt">
6133
+
6061
6134
  <xsl:apply-templates/>
6062
6135
  </fo:block>
6063
6136
  </xsl:template><xsl:template match="*[local-name() = 'p2'][ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']]">
@@ -6167,6 +6240,7 @@
6167
6240
  </xsl:choose>
6168
6241
  </xsl:template><xsl:template match="*[local-name() = 'termsource']" name="termsource">
6169
6242
  <fo:block xsl:use-attribute-sets="termsource-style">
6243
+
6170
6244
  <!-- Example: [SOURCE: ISO 5127:2017, 3.1.6.02] -->
6171
6245
  <xsl:variable name="termsource_text">
6172
6246
  <xsl:apply-templates/>
@@ -6177,13 +6251,15 @@
6177
6251
  <!-- <xsl:apply-templates /> -->
6178
6252
  <xsl:copy-of select="$termsource_text"/>
6179
6253
  </xsl:when>
6180
- <xsl:otherwise>
6254
+ <xsl:otherwise>
6255
+
6181
6256
 
6182
6257
  <xsl:text>[</xsl:text>
6183
6258
 
6184
6259
  <!-- <xsl:apply-templates /> -->
6185
6260
  <xsl:copy-of select="$termsource_text"/>
6186
6261
 
6262
+
6187
6263
  <xsl:text>]</xsl:text>
6188
6264
 
6189
6265
  </xsl:otherwise>
@@ -6195,19 +6271,21 @@
6195
6271
  </xsl:if>
6196
6272
  </xsl:template><xsl:variable name="localized.source">
6197
6273
  <xsl:call-template name="getLocalizedString">
6198
- <xsl:with-param name="key">source</xsl:with-param>
6199
- </xsl:call-template>
6274
+ <xsl:with-param name="key">source</xsl:with-param>
6275
+ </xsl:call-template>
6200
6276
  </xsl:variable><xsl:template match="*[local-name() = 'origin']">
6201
6277
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6202
6278
  <xsl:if test="normalize-space(@citeas) = ''">
6203
6279
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6204
6280
  </xsl:if>
6205
6281
 
6282
+
6206
6283
  <fo:inline>
6207
6284
 
6208
6285
 
6209
6286
 
6210
6287
 
6288
+
6211
6289
  <xsl:value-of select="$localized.source"/>
6212
6290
  <xsl:text>: </xsl:text>
6213
6291
 
@@ -6219,6 +6297,7 @@
6219
6297
  <fo:inline xsl:use-attribute-sets="origin-style">
6220
6298
  <xsl:apply-templates/>
6221
6299
  </fo:inline>
6300
+
6222
6301
  </fo:basic-link>
6223
6302
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
6224
6303
  <fo:inline><xsl:apply-templates/></fo:inline>
@@ -6262,12 +6341,20 @@
6262
6341
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6263
6342
  <xsl:text>— </xsl:text>
6264
6343
  <xsl:apply-templates/>
6265
- </xsl:template><xsl:template match="*[local-name() = 'eref']">
6344
+ </xsl:template><xsl:variable name="bibitem_hidden_">
6345
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6346
+ <xsl:copy-of select="."/>
6347
+ </xsl:for-each>
6348
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6349
+ <xsl:copy-of select="."/>
6350
+ </xsl:for-each>
6351
+ </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6266
6352
 
6267
6353
  <xsl:variable name="bibitemid">
6268
6354
  <xsl:choose>
6269
- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"/>
6270
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6355
+ <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6356
+ <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6357
+ <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6271
6358
  <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6272
6359
  </xsl:choose>
6273
6360
  </xsl:variable>
@@ -6285,6 +6372,9 @@
6285
6372
 
6286
6373
  </xsl:if>
6287
6374
 
6375
+ <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
6376
+ <xsl:variable name="text" select="normalize-space()"/>
6377
+
6288
6378
 
6289
6379
 
6290
6380
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
@@ -6297,7 +6387,9 @@
6297
6387
 
6298
6388
 
6299
6389
  </xsl:if>
6300
-
6390
+
6391
+
6392
+
6301
6393
  <xsl:apply-templates/>
6302
6394
  </fo:basic-link>
6303
6395
 
@@ -6351,10 +6443,10 @@
6351
6443
  </xsl:choose>
6352
6444
  </xsl:variable>
6353
6445
 
6354
- <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/>
6446
+ <!-- <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/> -->
6355
6447
 
6356
6448
  <xsl:choose>
6357
- <xsl:when test="$language = 'zh'">
6449
+ <xsl:when test="$lang = 'zh'">
6358
6450
  <fo:inline><xsl:value-of select="$tab_zh"/></fo:inline>
6359
6451
  </xsl:when>
6360
6452
  <xsl:when test="../../@inline-header = 'true'">
@@ -6830,9 +6922,97 @@
6830
6922
  <fo:block-container border="1pt solid black" width="50%">
6831
6923
  <fo:block> </fo:block>
6832
6924
  </fo:block-container>
6925
+ </xsl:template><xsl:template match="*[local-name() = 'toc']">
6926
+ <xsl:param name="colwidths"/>
6927
+ <xsl:variable name="colwidths_">
6928
+ <xsl:choose>
6929
+ <xsl:when test="not($colwidths)">
6930
+ <xsl:variable name="toc_table_simple">
6931
+ <tbody>
6932
+ <xsl:apply-templates mode="toc_table_width"/>
6933
+ </tbody>
6934
+ </xsl:variable>
6935
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($toc_table_simple)/*/tr[1]/td)"/>
6936
+ <xsl:call-template name="calculate-column-widths">
6937
+ <xsl:with-param name="cols-count" select="$cols-count"/>
6938
+ <xsl:with-param name="table" select="$toc_table_simple"/>
6939
+ </xsl:call-template>
6940
+ </xsl:when>
6941
+ <xsl:otherwise>
6942
+ <xsl:copy-of select="$colwidths"/>
6943
+ </xsl:otherwise>
6944
+ </xsl:choose>
6945
+ </xsl:variable>
6946
+ <fo:block role="TOCI" space-after="16pt">
6947
+ <fo:table width="100%" table-layout="fixed">
6948
+ <xsl:for-each select="xalan:nodeset($colwidths_)/column">
6949
+ <fo:table-column column-width="proportional-column-width({.})"/>
6950
+ </xsl:for-each>
6951
+ <fo:table-body>
6952
+ <xsl:apply-templates/>
6953
+ </fo:table-body>
6954
+ </fo:table>
6955
+ </fo:block>
6956
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']">
6957
+ <fo:table-row min-height="5mm">
6958
+ <xsl:apply-templates/>
6959
+ </fo:table-row>
6960
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']/*[local-name() = 'p']">
6961
+ <xsl:apply-templates/>
6962
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'xref']" priority="3">
6963
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
6964
+ <xsl:variable name="target" select="@target"/>
6965
+ <xsl:for-each select="*[local-name() = 'tab']">
6966
+ <xsl:variable name="current_id" select="generate-id()"/>
6967
+ <fo:table-cell>
6968
+ <fo:block>
6969
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
6970
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
6971
+ <xsl:choose>
6972
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
6973
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
6974
+ </xsl:choose>
6975
+ </xsl:for-each>
6976
+ </fo:basic-link>
6977
+ </fo:block>
6978
+ </fo:table-cell>
6979
+ </xsl:for-each>
6980
+ <!-- last column - for page numbers -->
6981
+ <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
6982
+ <fo:block>
6983
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
6984
+ <fo:page-number-citation ref-id="{$target}"/>
6985
+ </fo:basic-link>
6986
+ </fo:block>
6987
+ </fo:table-cell>
6988
+ </xsl:template><xsl:template match="*" mode="toc_table_width">
6989
+ <xsl:apply-templates mode="toc_table_width"/>
6990
+ </xsl:template><xsl:template match="*[local-name() = 'clause'][@type = 'toc']/*[local-name() = 'title']" mode="toc_table_width"/><xsl:template match="*[local-name() = 'clause'][not(@type = 'toc')]/*[local-name() = 'title']" mode="toc_table_width"/><xsl:template match="*[local-name() = 'li']" mode="toc_table_width">
6991
+ <tr>
6992
+ <xsl:apply-templates mode="toc_table_width"/>
6993
+ </tr>
6994
+ </xsl:template><xsl:template match="*[local-name() = 'xref']" mode="toc_table_width">
6995
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
6996
+ <xsl:for-each select="*[local-name() = 'tab']">
6997
+ <xsl:variable name="current_id" select="generate-id()"/>
6998
+ <td>
6999
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
7000
+ <xsl:copy-of select="."/>
7001
+ </xsl:for-each>
7002
+ </td>
7003
+ </xsl:for-each>
7004
+ <td>333</td> <!-- page number, just for fill -->
6833
7005
  </xsl:template><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
6834
7006
  <fo:inline padding-right="5mm"> </fo:inline>
6835
7007
  <fo:inline><xsl:apply-templates/></fo:inline>
7008
+ </xsl:template><xsl:template match="*[local-name() = 'blacksquare']" name="blacksquare">
7009
+ <fo:inline padding-right="2.5mm" baseline-shift="5%">
7010
+ <fo:instream-foreign-object content-height="2mm" content-width="2mm" fox:alt-text="Quad">
7011
+ <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 2 2">
7012
+ <rect x="0" y="0" width="2" height="2" fill="black"/>
7013
+ </svg>
7014
+ </fo:instream-foreign-object>
7015
+ </fo:inline>
6836
7016
  </xsl:template><xsl:template name="convertDate">
6837
7017
  <xsl:param name="date"/>
6838
7018
  <xsl:param name="format" select="'short'"/>
@@ -45,13 +45,15 @@ module IsoDoc
45
45
  prefix_name(node, "&nbsp;&mdash; ", lbl, "name")
46
46
  end
47
47
 
48
+ def eref_delim(delim, type)
49
+ if delim == ";" then ";"
50
+ else type == "list" ? "" : delim
51
+ end
52
+ end
53
+
48
54
  def eref_localities1_zh(target, type, from, upto, node, delim)
49
55
  subsection = from&.text&.match(/\./)
50
- ret = if delim == ";"
51
- ";"
52
- else
53
- type == "list" ? "" : delim
54
- end
56
+ ret = eref_delim(delim, type)
55
57
  ret += " 第#{from.text}" if from
56
58
  ret += "&ndash;#{upto.text}" if upto
57
59
  loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize)
@@ -70,10 +72,7 @@ module IsoDoc
70
72
  lang == "zh" and
71
73
  return l10n(eref_localities1_zh(target, type, from, upto, node,
72
74
  delim))
73
- ret = if delim == ";" then ";"
74
- else
75
- type == "list" ? "" : delim
76
- end
75
+ ret = eref_delim(delim, type)
77
76
  ret += eref_locality_populate(type, node) unless subsection &&
78
77
  type == "clause" || type == "list" ||
79
78
  target.match(/^IEV$|^IEC 60050-/)
@@ -114,7 +113,7 @@ module IsoDoc
114
113
  end
115
114
 
116
115
  def concept(docxml)
117
- docxml.xpath(ns("//terms//concept")).each_with_object({}) do |f, m|
116
+ docxml.xpath(ns("//term//concept")).each_with_object({}) do |f, m|
118
117
  concept_term(f, m)
119
118
  end
120
119
  docxml.xpath(ns("//concept")).each do |node|
@@ -49,12 +49,14 @@ module IsoDoc
49
49
 
50
50
  def foreword(isoxml, out)
51
51
  f = isoxml.at(ns("//foreword")) || return
52
+ @foreword = true
52
53
  page_break(out)
53
54
  out.div **attr_code(id: f["id"]) do |s|
54
55
  clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
55
56
  { class: "ForewordTitle" })
56
57
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
57
58
  end
59
+ @foreword = false
58
60
  end
59
61
  end
60
62
  end
@@ -0,0 +1,94 @@
1
+ module IsoDoc
2
+ module Iso
3
+ class WordConvert < IsoDoc::WordConvert
4
+ def figure_cleanup(xml)
5
+ super
6
+ xml.xpath("//div[@class = 'figure']//table[@class = 'dl']").each do |t|
7
+ t["class"] = "figdl"
8
+ d = t.add_previous_sibling("<div class='figdl' "\
9
+ "style='page-break-after:avoid;'/>")
10
+ t.parent = d.first
11
+ end
12
+ end
13
+
14
+ # force Annex h2 down to be p.h2Annex, so it is not picked up by ToC
15
+ def word_annex_cleanup1(docxml, lvl)
16
+ docxml.xpath("//h#{lvl}[ancestor::*[@class = 'Section3']]").each do |h2|
17
+ h2.name = "p"
18
+ h2["class"] = "h#{lvl}Annex"
19
+ end
20
+ end
21
+
22
+ def word_annex_cleanup(docxml)
23
+ (2..6).each { |i| word_annex_cleanup1(docxml, i) }
24
+ end
25
+
26
+ def word_annex_cleanup_h1(docxml)
27
+ docxml.xpath("//h1[@class = 'Annex']").each do |h|
28
+ h.name = "p"
29
+ h["class"] = "ANNEX"
30
+ end
31
+ %w(BiblioTitle ForewordTitle IntroTitle).each do |s|
32
+ docxml.xpath("//*[@class = '#{s}']").each do |h|
33
+ h.name = "p"
34
+ end
35
+ end
36
+ end
37
+
38
+ def style_cleanup(docxml)
39
+ word_annex_cleanup_h1(docxml)
40
+ style_cleanup1(docxml)
41
+ end
42
+
43
+ def style_cleanup1(docxml)
44
+ docxml.xpath("//*[@class = 'example']").each do |p|
45
+ p["class"] = "Example"
46
+ end
47
+ end
48
+
49
+ def authority_hdr_cleanup(docxml)
50
+ docxml&.xpath("//div[@class = 'boilerplate-license']")&.each do |d|
51
+ d.xpath(".//h1").each do |p|
52
+ p.name = "p"
53
+ p["class"] = "zzWarningHdr"
54
+ end
55
+ end
56
+ docxml&.xpath("//div[@class = 'boilerplate-copyright']")&.each do |d|
57
+ d.xpath(".//h1").each do |p|
58
+ p.name = "p"
59
+ p["class"] = "zzCopyrightHdr"
60
+ end
61
+ end
62
+ end
63
+
64
+ def authority_cleanup(docxml)
65
+ insert = docxml.at("//div[@id = 'boilerplate-license-destination']")
66
+ auth = docxml&.at("//div[@class = 'boilerplate-license']")&.remove
67
+ auth&.xpath(".//p[not(@class)]")&.each { |p| p["class"] = "zzWarning" }
68
+ auth and insert.children = auth
69
+ insert = docxml.at("//div[@id = 'boilerplate-copyright-destination']")
70
+ auth = docxml&.at("//div[@class = 'boilerplate-copyright']")&.remove
71
+ auth&.xpath(".//p[not(@class)]")&.each do |p|
72
+ p["class"] = "zzCopyright"
73
+ end
74
+ auth&.xpath(".//p[@id = 'boilerplate-message']")&.each do |p|
75
+ p["class"] = "zzCopyright1"
76
+ end
77
+ auth&.xpath(".//p[@id = 'boilerplate-address']")&.each do |p|
78
+ p["class"] = "zzAddress"
79
+ end
80
+ auth&.xpath(".//p[@id = 'boilerplate-place']")&.each do |p|
81
+ p["class"] = "zzCopyright1"
82
+ end
83
+ auth and insert.children = auth
84
+ end
85
+
86
+ def word_cleanup(docxml)
87
+ authority_hdr_cleanup(docxml)
88
+ super
89
+ style_cleanup(docxml)
90
+ docxml
91
+ end
92
+ end
93
+ end
94
+ end