metanorma-iso 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: 933e6aa82c5ca8cef1a5ead9829cb1b754fd96a4ca96e9949bd3159bb314ae63
4
- data.tar.gz: f39b54e13cbcd0f15c31808a8d3a94bafbb6d9834e0e6bd7cb73851643b590e7
3
+ metadata.gz: 63f76b4a2d9cc268099b20ca2fa32965d1baa2573dbd696170412ba717ae726b
4
+ data.tar.gz: 4d7c46a0cedf41d5466030d6e4e5ea8956cdce2081d4d24be581eafae3a71c4d
5
5
  SHA512:
6
- metadata.gz: 8f46dc0381b71de56114fa2749729ee78a9a7c3f02d5a11d9c8ac97cead706d7e96a4ebeda77fc4f05843c44585f9c014447c954e519b34ba4337cf00c6af2f3
7
- data.tar.gz: 4564b27b84fe80c5e15c817f3bb8d33daffb0e0fb0fa590983da1abf11c5fc8e97eff593a3ab3191c589c28f1c34fd5cd26818070d202dfc2f4f1ab96ad14ff8
6
+ metadata.gz: 1651fd7ed1c7216292a542dd4a1e5be937807afe1728675633287e507100b0c9979fd58afb682e6ba271d0021313ef1e92f04dc8a14f6d9ad2778fc6cd7eed2a
7
+ data.tar.gz: 5c195c5207ca60ea89789d9ba82723788f01e85ac9e576d03d27c2449a2fe6ee1bf2fd479809a7813865821e1107b257cc64cdf0f7bb6e59603696602bc30b28
@@ -0,0 +1,39 @@
1
+ stage_dict:
2
+ "00": Preliminary work item
3
+ "10": New work item proposal
4
+ "20": Working draft
5
+ "30": Committee draft
6
+ "40":
7
+ international-standard: Draft International Standard
8
+ technical-specification: Draft Technical Specification
9
+ technical-report: Draft Technical Report
10
+ publicly-available-specification: Draft Publicly Available Specification
11
+ international-workshop-agreement: Draft International Workshop Agreement
12
+ guide: Draft Guide
13
+ amendment: Draft Amendment
14
+ technical-corrigendum: Draft Technical Corrigendum
15
+ directive: Draft Directive
16
+ "50":
17
+ international-standard: Final Draft International Standard
18
+ technical-specification: Final Draft Technical Specification
19
+ technical-report: Final Draft Technical Report
20
+ publicly-available-specification: Final Draft Publicly Available Specification
21
+ international-workshop-agreement: Final Draft International Workshop Agreement
22
+ guide: Final Draft Guide
23
+ amendment: Final Draft Amendment
24
+ technical-corrigendum: Final Draft Technical Corrigendum
25
+ directive: Final Draft Directive
26
+ "60":
27
+ international-standard: International Standard
28
+ technical-specification: Technical Specification
29
+ technical-report: Technical Report
30
+ publicly-available-specification: Publicly Available Specification
31
+ international-workshop-agreement: International Workshop Agreement
32
+ guide: Guide
33
+ amendment: Amendment
34
+ technical-corrigendum: Technical Corrigendum
35
+ directive: Directive
36
+ "90": Review
37
+ "95": Withdrawal
38
+
39
+
@@ -2,13 +2,18 @@ module IsoDoc
2
2
  module Iso
3
3
  class I18n < IsoDoc::I18n
4
4
  def load_file(fname)
5
- YAML.load_file(File.join(File.dirname(__FILE__), fname))
5
+ YAML.load_file(File.join(File.dirname(__FILE__), fname)) ||
6
+ {}
6
7
  end
7
8
 
9
+ # all gems inheriting from ISO need to be represented here,
10
+ # even if the file is empty
11
+ # e.g. JA for metanorma-jis
8
12
  def load_yaml1(lang, script)
9
13
  y = if lang == "en" then load_file("i18n-en.yaml")
10
14
  elsif lang == "fr" then load_file("i18n-fr.yaml")
11
15
  elsif lang == "ru" then load_file("i18n-ru.yaml")
16
+ elsif lang == "ja" then load_file("i18n-ja.yaml")
12
17
  elsif lang == "zh" && script == "Hans"
13
18
  load_file("i18n-zh-Hans.yaml")
14
19
  else load_file("i18n-en.yaml")
@@ -2824,6 +2824,7 @@
2824
2824
  <xsl:variable name="table-border_">
2825
2825
 
2826
2826
  1pt solid black
2827
+
2827
2828
  </xsl:variable>
2828
2829
  <xsl:variable name="table-border" select="normalize-space($table-border_)"/>
2829
2830
 
@@ -3112,6 +3113,7 @@
3112
3113
  <xsl:attribute-set name="term-name-style">
3113
3114
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
3114
3115
  <xsl:attribute name="font-weight">bold</xsl:attribute>
3116
+
3115
3117
  </xsl:attribute-set>
3116
3118
 
3117
3119
  <xsl:attribute-set name="figure-block-style">
@@ -4069,7 +4071,7 @@
4069
4071
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
4070
4072
  </xsl:when>
4071
4073
  <xsl:otherwise>
4072
- <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
4074
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'dl') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer, note and dl which render separaterely -->
4073
4075
  </xsl:otherwise>
4074
4076
  </xsl:choose>
4075
4077
 
@@ -4605,7 +4607,7 @@
4605
4607
  <xsl:param name="colwidths"/>
4606
4608
  <xsl:param name="colgroup"/>
4607
4609
 
4608
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4610
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4609
4611
 
4610
4612
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
4611
4613
 
@@ -4673,6 +4675,7 @@
4673
4675
 
4674
4676
  <!-- except gb and bsi -->
4675
4677
 
4678
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
4676
4679
  <xsl:apply-templates select="../*[local-name()='note']"/>
4677
4680
 
4678
4681
  <xsl:variable name="isDisplayRowSeparator">
@@ -4842,7 +4845,7 @@
4842
4845
  <!-- ===================== -->
4843
4846
  <!-- Table's row processing -->
4844
4847
  <!-- ===================== -->
4845
- <!-- row in table header (thead) -->
4848
+ <!-- row in table header (thead) thead/tr -->
4846
4849
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4847
4850
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4848
4851
 
@@ -4887,7 +4890,7 @@
4887
4890
  </xsl:choose>
4888
4891
  </xsl:template>
4889
4892
 
4890
- <!-- row in table footer (tfoot) -->
4893
+ <!-- row in table footer (tfoot), tfoot/tr -->
4891
4894
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
4892
4895
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
4893
4896
 
@@ -5390,6 +5393,8 @@
5390
5393
  <!-- <dl><xsl:copy-of select="."/></dl> -->
5391
5394
  <fo:block-container>
5392
5395
 
5396
+ <xsl:call-template name="setBlockSpanAll"/>
5397
+
5393
5398
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
5394
5399
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
5395
5400
  </xsl:if>
@@ -7548,13 +7553,17 @@
7548
7553
  </xsl:template>
7549
7554
 
7550
7555
  <xsl:template match="*[local-name() = 'callout']">
7551
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
7556
+ <xsl:choose>
7557
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
7558
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
7559
+ </xsl:choose>
7552
7560
  </xsl:template>
7553
7561
 
7554
7562
  <xsl:template match="*[local-name() = 'annotation']">
7555
7563
  <xsl:variable name="annotation-id" select="@id"/>
7556
7564
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
7557
7565
  <fo:block id="{$annotation-id}" white-space="nowrap">
7566
+
7558
7567
  <fo:inline>
7559
7568
  <xsl:apply-templates>
7560
7569
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -7659,6 +7668,10 @@
7659
7668
  <!-- ====== -->
7660
7669
  <!-- ====== -->
7661
7670
 
7671
+ <xsl:template name="setBlockSpanAll">
7672
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
7673
+ </xsl:template>
7674
+
7662
7675
  <!-- ====== -->
7663
7676
  <!-- note -->
7664
7677
  <!-- termnote -->
@@ -7668,6 +7681,8 @@
7668
7681
 
7669
7682
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
7670
7683
 
7684
+ <xsl:call-template name="setBlockSpanAll"/>
7685
+
7671
7686
  <xsl:if test="$doctype = 'amendment' and parent::*[local-name() = 'quote']">
7672
7687
  <xsl:attribute name="font-size">inherit</xsl:attribute>
7673
7688
  </xsl:if>
@@ -7722,6 +7737,8 @@
7722
7737
  <xsl:template match="*[local-name() = 'termnote']">
7723
7738
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
7724
7739
 
7740
+ <xsl:call-template name="setBlockSpanAll"/>
7741
+
7725
7742
  <xsl:if test="$doctype = 'amendment' and parent::*[local-name() = 'quote']">
7726
7743
  <xsl:attribute name="font-size">inherit</xsl:attribute>
7727
7744
  </xsl:if>
@@ -9639,6 +9656,9 @@
9639
9656
  <!-- ====== -->
9640
9657
  <xsl:template match="*[local-name() = 'termexample']">
9641
9658
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
9659
+
9660
+ <xsl:call-template name="setBlockSpanAll"/>
9661
+
9642
9662
  <xsl:apply-templates select="*[local-name()='name']"/>
9643
9663
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
9644
9664
  </fo:block>
@@ -9690,6 +9710,8 @@
9690
9710
 
9691
9711
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
9692
9712
 
9713
+ <xsl:call-template name="setBlockSpanAll"/>
9714
+
9693
9715
  <xsl:variable name="fo_element">
9694
9716
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
9695
9717
  inline
@@ -9717,6 +9739,35 @@
9717
9739
  </fo:block-container>
9718
9740
  </xsl:when> <!-- end block -->
9719
9741
 
9742
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
9743
+
9744
+ <xsl:variable name="provisional_distance_between_starts">
9745
+ 7
9746
+ </xsl:variable>
9747
+ <xsl:variable name="indent">
9748
+ 0
9749
+ </xsl:variable>
9750
+
9751
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
9752
+ <fo:list-item>
9753
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
9754
+ <fo:block>
9755
+ <xsl:apply-templates select="*[local-name()='name']">
9756
+ <xsl:with-param name="fo_element">block</xsl:with-param>
9757
+ </xsl:apply-templates>
9758
+ </fo:block>
9759
+ </fo:list-item-label>
9760
+ <fo:list-item-body start-indent="body-start()">
9761
+ <fo:block>
9762
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9763
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9764
+ </xsl:apply-templates>
9765
+ </fo:block>
9766
+ </fo:list-item-body>
9767
+ </fo:list-item>
9768
+ </fo:list-block>
9769
+ </xsl:when> <!-- end list -->
9770
+
9720
9771
  <xsl:otherwise> <!-- inline -->
9721
9772
 
9722
9773
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -9797,6 +9848,11 @@
9797
9848
  </fo:block>
9798
9849
  </fo:block-container>
9799
9850
  </xsl:when>
9851
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
9852
+ <fo:block xsl:use-attribute-sets="example-p-style">
9853
+ <xsl:apply-templates/>
9854
+ </fo:block>
9855
+ </xsl:when>
9800
9856
  <xsl:otherwise>
9801
9857
  <fo:inline xsl:use-attribute-sets="example-p-style">
9802
9858
  <xsl:apply-templates/>
@@ -9914,6 +9970,9 @@
9914
9970
  <!-- ====== -->
9915
9971
  <xsl:template match="*[local-name() = 'quote']">
9916
9972
  <fo:block-container margin-left="0mm">
9973
+
9974
+ <xsl:call-template name="setBlockSpanAll"/>
9975
+
9917
9976
  <xsl:if test="parent::*[local-name() = 'note']">
9918
9977
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
9919
9978
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -10206,6 +10265,8 @@
10206
10265
  <fo:block>
10207
10266
  <xsl:call-template name="setId"/>
10208
10267
 
10268
+ <xsl:call-template name="setBlockSpanAll"/>
10269
+
10209
10270
  <xsl:apply-templates/>
10210
10271
  </fo:block>
10211
10272
  </xsl:template>
@@ -10220,6 +10281,8 @@
10220
10281
  <fo:block break-after="page"/>
10221
10282
  <fo:block id="{@id}">
10222
10283
 
10284
+ <xsl:call-template name="setBlockSpanAll"/>
10285
+
10223
10286
  </fo:block>
10224
10287
  <xsl:apply-templates/>
10225
10288
  </xsl:template>
@@ -11173,6 +11236,8 @@
11173
11236
 
11174
11237
  <fo:block xsl:use-attribute-sets="admonition-style">
11175
11238
 
11239
+ <xsl:call-template name="setBlockSpanAll"/>
11240
+
11176
11241
  <xsl:if test="@type = 'editorial'">
11177
11242
  <xsl:attribute name="color">green</xsl:attribute>
11178
11243
  <xsl:attribute name="font-weight">normal</xsl:attribute>
@@ -11355,6 +11420,16 @@
11355
11420
  <xsl:apply-templates mode="update_xml_step1"/>
11356
11421
  </xsl:copy>
11357
11422
  </xsl:template>
11423
+
11424
+ <!-- remove semantic xml -->
11425
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
11426
+
11427
+ <!-- remove image/emf -->
11428
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
11429
+
11430
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
11431
+ <xsl:copy-of select="."/>
11432
+ </xsl:template>
11358
11433
  <!-- =========================================================================== -->
11359
11434
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
11360
11435
  <!-- =========================================================================== -->
@@ -11455,6 +11530,10 @@
11455
11530
  </xsl:call-template>
11456
11531
  </xsl:template>
11457
11532
 
11533
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step2">
11534
+ <xsl:copy-of select="."/>
11535
+ </xsl:template>
11536
+
11458
11537
  <!-- =========================================================================== -->
11459
11538
  <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
11460
11539
  <!-- =========================================================================== -->
@@ -11476,7 +11555,7 @@
11476
11555
 
11477
11556
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
11478
11557
 
11479
- <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
11558
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
11480
11559
 
11481
11560
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
11482
11561
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -11558,6 +11637,10 @@
11558
11637
 
11559
11638
  </xsl:template>
11560
11639
 
11640
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
11641
+ <xsl:copy-of select="."/>
11642
+ </xsl:template>
11643
+
11561
11644
  <xsl:template name="replace_text_tags">
11562
11645
  <xsl:param name="tag_open"/>
11563
11646
  <xsl:param name="tag_close"/>
@@ -11584,6 +11667,194 @@
11584
11667
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
11585
11668
  <!-- ===================================== -->
11586
11669
 
11670
+ <!-- ===================================== -->
11671
+ <!-- ===================================== -->
11672
+ <!-- Make linear XML (need for landscape orientation) -->
11673
+ <!-- ===================================== -->
11674
+ <!-- ===================================== -->
11675
+ <xsl:template match="@*|node()" mode="linear_xml">
11676
+ <xsl:copy>
11677
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
11678
+ </xsl:copy>
11679
+ </xsl:template>
11680
+
11681
+ <xsl:template match="processing-instruction()" mode="linear_xml">
11682
+ <xsl:copy-of select="."/>
11683
+ </xsl:template>
11684
+
11685
+ <!-- From:
11686
+ <clause>
11687
+ <title>...</title>
11688
+ <p>...</p>
11689
+ </clause>
11690
+ To:
11691
+ <clause/>
11692
+ <title>...</title>
11693
+ <p>...</p>
11694
+ -->
11695
+ <xsl:template match="*[local-name() = 'foreword'] | *[local-name() = 'foreword']//*[local-name() = 'clause'] | *[local-name() = 'preface']//*[local-name() = 'clause'][not(@type = 'corrigenda') and not(@type = 'policy') and not(@type = 'related-refs')] | *[local-name() = 'introduction'] | *[local-name() = 'introduction']//*[local-name() = 'clause'] | *[local-name() = 'sections']//*[local-name() = 'clause'] | *[local-name() = 'annex'] | *[local-name() = 'annex']//*[local-name() = 'clause'] | *[local-name() = 'references'][not(@hidden = 'true')] | *[local-name() = 'bibliography']/*[local-name() = 'clause'] | *[local-name() = 'colophon'] | *[local-name() = 'colophon']//*[local-name() = 'clause'] | *[local-name()='sections']//*[local-name()='terms'] | *[local-name()='sections']//*[local-name()='definitions'] | *[local-name()='annex']//*[local-name()='definitions']" mode="linear_xml" name="clause_linear">
11696
+
11697
+ <xsl:copy>
11698
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11699
+
11700
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11701
+
11702
+ <xsl:if test="local-name() = 'foreword' or local-name() = 'introduction' or local-name(..) = 'preface' or local-name(..) = 'sections' or (local-name() = 'references' and parent::*[local-name() = 'bibliography']) or (local-name() = 'clause' and parent::*[local-name() = 'bibliography']) or local-name() = 'annex' or local-name(..) = 'annex' or local-name(..) = 'colophon'">
11703
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11704
+ </xsl:if>
11705
+ </xsl:copy>
11706
+
11707
+ <xsl:apply-templates mode="linear_xml"/>
11708
+ </xsl:template>
11709
+
11710
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
11711
+ <xsl:copy>
11712
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11713
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11714
+ <xsl:variable name="level">
11715
+ <xsl:call-template name="getLevel"/>
11716
+ </xsl:variable>
11717
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
11718
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
11719
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
11720
+ </xsl:copy>
11721
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
11722
+ </xsl:template>
11723
+
11724
+ <xsl:template match="*[local-name() = 'introduction']//*[local-name() = 'title'] | *[local-name() = 'foreword']//*[local-name() = 'title'] | *[local-name() = 'sections']//*[local-name() = 'title'] | *[local-name() = 'annex']//*[local-name() = 'title'] | *[local-name() = 'bibliography']/*[local-name() = 'clause']/*[local-name() = 'title'] | *[local-name() = 'references']/*[local-name() = 'title'] | *[local-name() = 'colophon']//*[local-name() = 'title']" mode="linear_xml" priority="2">
11725
+ <xsl:copy>
11726
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11727
+
11728
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11729
+
11730
+ <xsl:variable name="level">
11731
+ <xsl:call-template name="getLevel"/>
11732
+ </xsl:variable>
11733
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
11734
+
11735
+ <xsl:if test="parent::*[local-name() = 'annex']">
11736
+ <xsl:attribute name="depth">1</xsl:attribute>
11737
+ </xsl:if>
11738
+
11739
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
11740
+ <xsl:copy-of select="../@inline-header"/>
11741
+ </xsl:if>
11742
+
11743
+ <xsl:attribute name="ancestor">
11744
+ <xsl:choose>
11745
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
11746
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
11747
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
11748
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
11749
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
11750
+ </xsl:choose>
11751
+ </xsl:attribute>
11752
+
11753
+ <xsl:apply-templates mode="linear_xml"/>
11754
+ </xsl:copy>
11755
+ </xsl:template>
11756
+
11757
+ <!-- add @to = figure, table, clause -->
11758
+ <!-- add @depth = from -->
11759
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
11760
+ <xsl:copy>
11761
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11762
+ <xsl:variable name="target" select="@target"/>
11763
+ <xsl:attribute name="to">
11764
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
11765
+ </xsl:attribute>
11766
+ <xsl:attribute name="depth">
11767
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
11768
+ </xsl:attribute>
11769
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11770
+ </xsl:copy>
11771
+ </xsl:template>
11772
+
11773
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
11774
+ <xsl:choose>
11775
+ <xsl:when test="contains(., $non_breaking_hyphen)">
11776
+ <xsl:call-template name="replaceChar">
11777
+ <xsl:with-param name="text" select="."/>
11778
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
11779
+ <xsl:with-param name="by" select="'-'"/>
11780
+ </xsl:call-template>
11781
+ </xsl:when>
11782
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
11783
+ </xsl:choose>
11784
+ </xsl:template>
11785
+
11786
+ <xsl:template name="replaceChar">
11787
+ <xsl:param name="text"/>
11788
+ <xsl:param name="replace"/>
11789
+ <xsl:param name="by"/>
11790
+ <xsl:choose>
11791
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
11792
+ <xsl:value-of select="$text"/>
11793
+ </xsl:when>
11794
+ <xsl:when test="contains($text, $replace)">
11795
+ <xsl:value-of select="substring-before($text,$replace)"/>
11796
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
11797
+ <xsl:call-template name="replaceChar">
11798
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
11799
+ <xsl:with-param name="replace" select="$replace"/>
11800
+ <xsl:with-param name="by" select="$by"/>
11801
+ </xsl:call-template>
11802
+ </xsl:when>
11803
+ <xsl:otherwise>
11804
+ <xsl:value-of select="$text"/>
11805
+ </xsl:otherwise>
11806
+ </xsl:choose>
11807
+ </xsl:template>
11808
+
11809
+ <xsl:template match="*[local-name() = 'inlineChar']">
11810
+ <fo:inline><xsl:value-of select="."/></fo:inline>
11811
+ </xsl:template>
11812
+
11813
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
11814
+ <!--
11815
+ <fn reference="1">
11816
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
11817
+ </fn>
11818
+ -->
11819
+ <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" mode="linear_xml" name="linear_xml_fn">
11820
+ <xsl:variable name="p_fn_">
11821
+ <xsl:call-template name="get_fn_list"/>
11822
+ </xsl:variable>
11823
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
11824
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
11825
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
11826
+ <xsl:variable name="reference" select="@reference"/>
11827
+ <!-- fn sequence number in document -->
11828
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
11829
+
11830
+ <xsl:copy>
11831
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11832
+ <!-- put actual reference number -->
11833
+ <xsl:attribute name="current_fn_number">
11834
+ <xsl:value-of select="$current_fn_number"/>
11835
+ </xsl:attribute>
11836
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
11837
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
11838
+ </xsl:attribute>
11839
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11840
+ </xsl:copy>
11841
+ </xsl:template>
11842
+
11843
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
11844
+ <xsl:copy>
11845
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11846
+ <xsl:if test="@depth = '1'">
11847
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11848
+ </xsl:if>
11849
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11850
+ </xsl:copy>
11851
+ </xsl:template>
11852
+ <!-- ===================================== -->
11853
+ <!-- ===================================== -->
11854
+ <!-- END: Make linear XML (need for landscape orientation) -->
11855
+ <!-- ===================================== -->
11856
+ <!-- ===================================== -->
11857
+
11587
11858
  <!-- for correct rendering combining chars -->
11588
11859
  <xsl:template match="*[local-name() = 'lang_none']">
11589
11860
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -2824,6 +2824,7 @@
2824
2824
  <xsl:variable name="table-border_">
2825
2825
 
2826
2826
  1pt solid black
2827
+
2827
2828
  </xsl:variable>
2828
2829
  <xsl:variable name="table-border" select="normalize-space($table-border_)"/>
2829
2830
 
@@ -3112,6 +3113,7 @@
3112
3113
  <xsl:attribute-set name="term-name-style">
3113
3114
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
3114
3115
  <xsl:attribute name="font-weight">bold</xsl:attribute>
3116
+
3115
3117
  </xsl:attribute-set>
3116
3118
 
3117
3119
  <xsl:attribute-set name="figure-block-style">
@@ -4069,7 +4071,7 @@
4069
4071
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
4070
4072
  </xsl:when>
4071
4073
  <xsl:otherwise>
4072
- <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
4074
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'dl') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer, note and dl which render separaterely -->
4073
4075
  </xsl:otherwise>
4074
4076
  </xsl:choose>
4075
4077
 
@@ -4605,7 +4607,7 @@
4605
4607
  <xsl:param name="colwidths"/>
4606
4608
  <xsl:param name="colgroup"/>
4607
4609
 
4608
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4610
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4609
4611
 
4610
4612
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
4611
4613
 
@@ -4673,6 +4675,7 @@
4673
4675
 
4674
4676
  <!-- except gb and bsi -->
4675
4677
 
4678
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
4676
4679
  <xsl:apply-templates select="../*[local-name()='note']"/>
4677
4680
 
4678
4681
  <xsl:variable name="isDisplayRowSeparator">
@@ -4842,7 +4845,7 @@
4842
4845
  <!-- ===================== -->
4843
4846
  <!-- Table's row processing -->
4844
4847
  <!-- ===================== -->
4845
- <!-- row in table header (thead) -->
4848
+ <!-- row in table header (thead) thead/tr -->
4846
4849
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4847
4850
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4848
4851
 
@@ -4887,7 +4890,7 @@
4887
4890
  </xsl:choose>
4888
4891
  </xsl:template>
4889
4892
 
4890
- <!-- row in table footer (tfoot) -->
4893
+ <!-- row in table footer (tfoot), tfoot/tr -->
4891
4894
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
4892
4895
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
4893
4896
 
@@ -5390,6 +5393,8 @@
5390
5393
  <!-- <dl><xsl:copy-of select="."/></dl> -->
5391
5394
  <fo:block-container>
5392
5395
 
5396
+ <xsl:call-template name="setBlockSpanAll"/>
5397
+
5393
5398
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
5394
5399
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
5395
5400
  </xsl:if>
@@ -7548,13 +7553,17 @@
7548
7553
  </xsl:template>
7549
7554
 
7550
7555
  <xsl:template match="*[local-name() = 'callout']">
7551
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
7556
+ <xsl:choose>
7557
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
7558
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
7559
+ </xsl:choose>
7552
7560
  </xsl:template>
7553
7561
 
7554
7562
  <xsl:template match="*[local-name() = 'annotation']">
7555
7563
  <xsl:variable name="annotation-id" select="@id"/>
7556
7564
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
7557
7565
  <fo:block id="{$annotation-id}" white-space="nowrap">
7566
+
7558
7567
  <fo:inline>
7559
7568
  <xsl:apply-templates>
7560
7569
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -7659,6 +7668,10 @@
7659
7668
  <!-- ====== -->
7660
7669
  <!-- ====== -->
7661
7670
 
7671
+ <xsl:template name="setBlockSpanAll">
7672
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
7673
+ </xsl:template>
7674
+
7662
7675
  <!-- ====== -->
7663
7676
  <!-- note -->
7664
7677
  <!-- termnote -->
@@ -7668,6 +7681,8 @@
7668
7681
 
7669
7682
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
7670
7683
 
7684
+ <xsl:call-template name="setBlockSpanAll"/>
7685
+
7671
7686
  <xsl:if test="$doctype = 'amendment' and parent::*[local-name() = 'quote']">
7672
7687
  <xsl:attribute name="font-size">inherit</xsl:attribute>
7673
7688
  </xsl:if>
@@ -7722,6 +7737,8 @@
7722
7737
  <xsl:template match="*[local-name() = 'termnote']">
7723
7738
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
7724
7739
 
7740
+ <xsl:call-template name="setBlockSpanAll"/>
7741
+
7725
7742
  <xsl:if test="$doctype = 'amendment' and parent::*[local-name() = 'quote']">
7726
7743
  <xsl:attribute name="font-size">inherit</xsl:attribute>
7727
7744
  </xsl:if>
@@ -9639,6 +9656,9 @@
9639
9656
  <!-- ====== -->
9640
9657
  <xsl:template match="*[local-name() = 'termexample']">
9641
9658
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
9659
+
9660
+ <xsl:call-template name="setBlockSpanAll"/>
9661
+
9642
9662
  <xsl:apply-templates select="*[local-name()='name']"/>
9643
9663
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
9644
9664
  </fo:block>
@@ -9690,6 +9710,8 @@
9690
9710
 
9691
9711
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
9692
9712
 
9713
+ <xsl:call-template name="setBlockSpanAll"/>
9714
+
9693
9715
  <xsl:variable name="fo_element">
9694
9716
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
9695
9717
  inline
@@ -9717,6 +9739,35 @@
9717
9739
  </fo:block-container>
9718
9740
  </xsl:when> <!-- end block -->
9719
9741
 
9742
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
9743
+
9744
+ <xsl:variable name="provisional_distance_between_starts">
9745
+ 7
9746
+ </xsl:variable>
9747
+ <xsl:variable name="indent">
9748
+ 0
9749
+ </xsl:variable>
9750
+
9751
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
9752
+ <fo:list-item>
9753
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
9754
+ <fo:block>
9755
+ <xsl:apply-templates select="*[local-name()='name']">
9756
+ <xsl:with-param name="fo_element">block</xsl:with-param>
9757
+ </xsl:apply-templates>
9758
+ </fo:block>
9759
+ </fo:list-item-label>
9760
+ <fo:list-item-body start-indent="body-start()">
9761
+ <fo:block>
9762
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9763
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9764
+ </xsl:apply-templates>
9765
+ </fo:block>
9766
+ </fo:list-item-body>
9767
+ </fo:list-item>
9768
+ </fo:list-block>
9769
+ </xsl:when> <!-- end list -->
9770
+
9720
9771
  <xsl:otherwise> <!-- inline -->
9721
9772
 
9722
9773
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -9797,6 +9848,11 @@
9797
9848
  </fo:block>
9798
9849
  </fo:block-container>
9799
9850
  </xsl:when>
9851
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
9852
+ <fo:block xsl:use-attribute-sets="example-p-style">
9853
+ <xsl:apply-templates/>
9854
+ </fo:block>
9855
+ </xsl:when>
9800
9856
  <xsl:otherwise>
9801
9857
  <fo:inline xsl:use-attribute-sets="example-p-style">
9802
9858
  <xsl:apply-templates/>
@@ -9914,6 +9970,9 @@
9914
9970
  <!-- ====== -->
9915
9971
  <xsl:template match="*[local-name() = 'quote']">
9916
9972
  <fo:block-container margin-left="0mm">
9973
+
9974
+ <xsl:call-template name="setBlockSpanAll"/>
9975
+
9917
9976
  <xsl:if test="parent::*[local-name() = 'note']">
9918
9977
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
9919
9978
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -10206,6 +10265,8 @@
10206
10265
  <fo:block>
10207
10266
  <xsl:call-template name="setId"/>
10208
10267
 
10268
+ <xsl:call-template name="setBlockSpanAll"/>
10269
+
10209
10270
  <xsl:apply-templates/>
10210
10271
  </fo:block>
10211
10272
  </xsl:template>
@@ -10220,6 +10281,8 @@
10220
10281
  <fo:block break-after="page"/>
10221
10282
  <fo:block id="{@id}">
10222
10283
 
10284
+ <xsl:call-template name="setBlockSpanAll"/>
10285
+
10223
10286
  </fo:block>
10224
10287
  <xsl:apply-templates/>
10225
10288
  </xsl:template>
@@ -11173,6 +11236,8 @@
11173
11236
 
11174
11237
  <fo:block xsl:use-attribute-sets="admonition-style">
11175
11238
 
11239
+ <xsl:call-template name="setBlockSpanAll"/>
11240
+
11176
11241
  <xsl:if test="@type = 'editorial'">
11177
11242
  <xsl:attribute name="color">green</xsl:attribute>
11178
11243
  <xsl:attribute name="font-weight">normal</xsl:attribute>
@@ -11355,6 +11420,16 @@
11355
11420
  <xsl:apply-templates mode="update_xml_step1"/>
11356
11421
  </xsl:copy>
11357
11422
  </xsl:template>
11423
+
11424
+ <!-- remove semantic xml -->
11425
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
11426
+
11427
+ <!-- remove image/emf -->
11428
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
11429
+
11430
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
11431
+ <xsl:copy-of select="."/>
11432
+ </xsl:template>
11358
11433
  <!-- =========================================================================== -->
11359
11434
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
11360
11435
  <!-- =========================================================================== -->
@@ -11455,6 +11530,10 @@
11455
11530
  </xsl:call-template>
11456
11531
  </xsl:template>
11457
11532
 
11533
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step2">
11534
+ <xsl:copy-of select="."/>
11535
+ </xsl:template>
11536
+
11458
11537
  <!-- =========================================================================== -->
11459
11538
  <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
11460
11539
  <!-- =========================================================================== -->
@@ -11476,7 +11555,7 @@
11476
11555
 
11477
11556
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
11478
11557
 
11479
- <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
11558
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
11480
11559
 
11481
11560
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
11482
11561
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -11558,6 +11637,10 @@
11558
11637
 
11559
11638
  </xsl:template>
11560
11639
 
11640
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
11641
+ <xsl:copy-of select="."/>
11642
+ </xsl:template>
11643
+
11561
11644
  <xsl:template name="replace_text_tags">
11562
11645
  <xsl:param name="tag_open"/>
11563
11646
  <xsl:param name="tag_close"/>
@@ -11584,6 +11667,194 @@
11584
11667
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
11585
11668
  <!-- ===================================== -->
11586
11669
 
11670
+ <!-- ===================================== -->
11671
+ <!-- ===================================== -->
11672
+ <!-- Make linear XML (need for landscape orientation) -->
11673
+ <!-- ===================================== -->
11674
+ <!-- ===================================== -->
11675
+ <xsl:template match="@*|node()" mode="linear_xml">
11676
+ <xsl:copy>
11677
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
11678
+ </xsl:copy>
11679
+ </xsl:template>
11680
+
11681
+ <xsl:template match="processing-instruction()" mode="linear_xml">
11682
+ <xsl:copy-of select="."/>
11683
+ </xsl:template>
11684
+
11685
+ <!-- From:
11686
+ <clause>
11687
+ <title>...</title>
11688
+ <p>...</p>
11689
+ </clause>
11690
+ To:
11691
+ <clause/>
11692
+ <title>...</title>
11693
+ <p>...</p>
11694
+ -->
11695
+ <xsl:template match="*[local-name() = 'foreword'] | *[local-name() = 'foreword']//*[local-name() = 'clause'] | *[local-name() = 'preface']//*[local-name() = 'clause'][not(@type = 'corrigenda') and not(@type = 'policy') and not(@type = 'related-refs')] | *[local-name() = 'introduction'] | *[local-name() = 'introduction']//*[local-name() = 'clause'] | *[local-name() = 'sections']//*[local-name() = 'clause'] | *[local-name() = 'annex'] | *[local-name() = 'annex']//*[local-name() = 'clause'] | *[local-name() = 'references'][not(@hidden = 'true')] | *[local-name() = 'bibliography']/*[local-name() = 'clause'] | *[local-name() = 'colophon'] | *[local-name() = 'colophon']//*[local-name() = 'clause'] | *[local-name()='sections']//*[local-name()='terms'] | *[local-name()='sections']//*[local-name()='definitions'] | *[local-name()='annex']//*[local-name()='definitions']" mode="linear_xml" name="clause_linear">
11696
+
11697
+ <xsl:copy>
11698
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11699
+
11700
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11701
+
11702
+ <xsl:if test="local-name() = 'foreword' or local-name() = 'introduction' or local-name(..) = 'preface' or local-name(..) = 'sections' or (local-name() = 'references' and parent::*[local-name() = 'bibliography']) or (local-name() = 'clause' and parent::*[local-name() = 'bibliography']) or local-name() = 'annex' or local-name(..) = 'annex' or local-name(..) = 'colophon'">
11703
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11704
+ </xsl:if>
11705
+ </xsl:copy>
11706
+
11707
+ <xsl:apply-templates mode="linear_xml"/>
11708
+ </xsl:template>
11709
+
11710
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
11711
+ <xsl:copy>
11712
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11713
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11714
+ <xsl:variable name="level">
11715
+ <xsl:call-template name="getLevel"/>
11716
+ </xsl:variable>
11717
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
11718
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
11719
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
11720
+ </xsl:copy>
11721
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
11722
+ </xsl:template>
11723
+
11724
+ <xsl:template match="*[local-name() = 'introduction']//*[local-name() = 'title'] | *[local-name() = 'foreword']//*[local-name() = 'title'] | *[local-name() = 'sections']//*[local-name() = 'title'] | *[local-name() = 'annex']//*[local-name() = 'title'] | *[local-name() = 'bibliography']/*[local-name() = 'clause']/*[local-name() = 'title'] | *[local-name() = 'references']/*[local-name() = 'title'] | *[local-name() = 'colophon']//*[local-name() = 'title']" mode="linear_xml" priority="2">
11725
+ <xsl:copy>
11726
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11727
+
11728
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11729
+
11730
+ <xsl:variable name="level">
11731
+ <xsl:call-template name="getLevel"/>
11732
+ </xsl:variable>
11733
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
11734
+
11735
+ <xsl:if test="parent::*[local-name() = 'annex']">
11736
+ <xsl:attribute name="depth">1</xsl:attribute>
11737
+ </xsl:if>
11738
+
11739
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
11740
+ <xsl:copy-of select="../@inline-header"/>
11741
+ </xsl:if>
11742
+
11743
+ <xsl:attribute name="ancestor">
11744
+ <xsl:choose>
11745
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
11746
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
11747
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
11748
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
11749
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
11750
+ </xsl:choose>
11751
+ </xsl:attribute>
11752
+
11753
+ <xsl:apply-templates mode="linear_xml"/>
11754
+ </xsl:copy>
11755
+ </xsl:template>
11756
+
11757
+ <!-- add @to = figure, table, clause -->
11758
+ <!-- add @depth = from -->
11759
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
11760
+ <xsl:copy>
11761
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11762
+ <xsl:variable name="target" select="@target"/>
11763
+ <xsl:attribute name="to">
11764
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
11765
+ </xsl:attribute>
11766
+ <xsl:attribute name="depth">
11767
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
11768
+ </xsl:attribute>
11769
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11770
+ </xsl:copy>
11771
+ </xsl:template>
11772
+
11773
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
11774
+ <xsl:choose>
11775
+ <xsl:when test="contains(., $non_breaking_hyphen)">
11776
+ <xsl:call-template name="replaceChar">
11777
+ <xsl:with-param name="text" select="."/>
11778
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
11779
+ <xsl:with-param name="by" select="'-'"/>
11780
+ </xsl:call-template>
11781
+ </xsl:when>
11782
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
11783
+ </xsl:choose>
11784
+ </xsl:template>
11785
+
11786
+ <xsl:template name="replaceChar">
11787
+ <xsl:param name="text"/>
11788
+ <xsl:param name="replace"/>
11789
+ <xsl:param name="by"/>
11790
+ <xsl:choose>
11791
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
11792
+ <xsl:value-of select="$text"/>
11793
+ </xsl:when>
11794
+ <xsl:when test="contains($text, $replace)">
11795
+ <xsl:value-of select="substring-before($text,$replace)"/>
11796
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
11797
+ <xsl:call-template name="replaceChar">
11798
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
11799
+ <xsl:with-param name="replace" select="$replace"/>
11800
+ <xsl:with-param name="by" select="$by"/>
11801
+ </xsl:call-template>
11802
+ </xsl:when>
11803
+ <xsl:otherwise>
11804
+ <xsl:value-of select="$text"/>
11805
+ </xsl:otherwise>
11806
+ </xsl:choose>
11807
+ </xsl:template>
11808
+
11809
+ <xsl:template match="*[local-name() = 'inlineChar']">
11810
+ <fo:inline><xsl:value-of select="."/></fo:inline>
11811
+ </xsl:template>
11812
+
11813
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
11814
+ <!--
11815
+ <fn reference="1">
11816
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
11817
+ </fn>
11818
+ -->
11819
+ <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" mode="linear_xml" name="linear_xml_fn">
11820
+ <xsl:variable name="p_fn_">
11821
+ <xsl:call-template name="get_fn_list"/>
11822
+ </xsl:variable>
11823
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
11824
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
11825
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
11826
+ <xsl:variable name="reference" select="@reference"/>
11827
+ <!-- fn sequence number in document -->
11828
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
11829
+
11830
+ <xsl:copy>
11831
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11832
+ <!-- put actual reference number -->
11833
+ <xsl:attribute name="current_fn_number">
11834
+ <xsl:value-of select="$current_fn_number"/>
11835
+ </xsl:attribute>
11836
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
11837
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
11838
+ </xsl:attribute>
11839
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11840
+ </xsl:copy>
11841
+ </xsl:template>
11842
+
11843
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
11844
+ <xsl:copy>
11845
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11846
+ <xsl:if test="@depth = '1'">
11847
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11848
+ </xsl:if>
11849
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11850
+ </xsl:copy>
11851
+ </xsl:template>
11852
+ <!-- ===================================== -->
11853
+ <!-- ===================================== -->
11854
+ <!-- END: Make linear XML (need for landscape orientation) -->
11855
+ <!-- ===================================== -->
11856
+ <!-- ===================================== -->
11857
+
11587
11858
  <!-- for correct rendering combining chars -->
11588
11859
  <xsl:template match="*[local-name() = 'lang_none']">
11589
11860
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -84,15 +84,15 @@ module IsoDoc
84
84
  p = titlenums[:part]
85
85
  titlenums[:part] && titlenums[:subpart] and
86
86
  p = "#{titlenums[:part]}&#x2013;#{titlenums[:subpart]}"
87
- "#{PART_LABEL[lang.to_sym]}&#xa0;#{p}"
87
+ "#{self.class::PART_LABEL[lang.to_sym]}&#xa0;#{p}"
88
88
  end
89
89
 
90
90
  def amd_prefix(titlenums, lang)
91
- "#{AMD_LABEL[lang.to_sym]}&#xa0;#{titlenums[:amd]}"
91
+ "#{self.class::AMD_LABEL[lang.to_sym]}&#xa0;#{titlenums[:amd]}"
92
92
  end
93
93
 
94
94
  def corr_prefix(titlenums, lang)
95
- "#{CORR_LABEL[lang.to_sym]}&#xa0;#{titlenums[:corr]}"
95
+ "#{self.class::CORR_LABEL[lang.to_sym]}&#xa0;#{titlenums[:corr]}"
96
96
  end
97
97
 
98
98
  def compose_title(tparts, tnums, lang)
@@ -86,7 +86,7 @@ module IsoDoc
86
86
  }.freeze
87
87
 
88
88
  def new_styles(docxml)
89
- STYLESMAP.each do |k, v|
89
+ self.class::STYLESMAP.each do |k, v|
90
90
  docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
91
91
  end
92
92
  docxml.xpath("//div[@class = 'Section3']//p[@class = 'Tabletitle']")
@@ -106,10 +106,11 @@ module Metanorma
106
106
  xmldoc.xpath("//term").each do |t|
107
107
  para = t.at("./definition/verbal-definition") || return
108
108
  term = t.at("./preferred//name").text
109
- termdef_warn(para.text, /\A(the|a)\b/i, t, term,
110
- "term definition starts with article")
111
- termdef_warn(para.text, /\.\Z/i, t, term,
112
- "term definition ends with period")
109
+ @lang == "en" and termdef_warn(para.text, /\A(the|a)\b/i, t, term,
110
+ "term definition starts with article")
111
+ %(Cyrl Latn).include?(@script) and
112
+ termdef_warn(para.text, /\.\Z/i, t, term,
113
+ "term definition ends with period")
113
114
  end
114
115
  end
115
116
 
@@ -56,7 +56,8 @@ module Metanorma
56
56
  def list_punctuation1(list, prectext)
57
57
  prectext ||= ""
58
58
  entries = list.xpath(".//li")
59
- case prectext.strip.chars.last
59
+ %w(Cyrl Latn Grek).include?(@script) or return
60
+ case prectext.strip[-1]
60
61
  when ":", "" then list_after_colon_punctuation(list, entries)
61
62
  when "." then entries.each { |li| list_full_sentence(li) }
62
63
  else style_warning(list, "All lists must be preceded by "\
@@ -98,6 +99,7 @@ module Metanorma
98
99
  end
99
100
 
100
101
  def list_full_sentence(elem)
102
+ %w(Cyrl Latn Grek).include?(@script) or return
101
103
  text = elem.text.strip
102
104
  starts_uppercase?(text) or
103
105
  style_warning(elem, "List entry of separate sentences must start "\
@@ -99,6 +99,7 @@ module Metanorma
99
99
  end
100
100
 
101
101
  def style_no_guidance(node, text, docpart)
102
+ @lang == "en" or return
102
103
  r = requirement_check(text)
103
104
  style_warning(node, "#{docpart} may contain requirement", r) if r
104
105
  r = permission_check(text)
@@ -32,9 +32,9 @@ module Metanorma
32
32
  @log.add("Style", f, "normative references contains subclauses")
33
33
  end
34
34
 
35
- ONE_SYMBOLS_WARNING = "Only one Symbols and Abbreviated "\
35
+ ONE_SYMBOLS_WARNING = "Only one Symbols and Abbreviated " \
36
36
  "Terms section in the standard".freeze
37
- NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can "\
37
+ NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can " \
38
38
  "only contain a definition list".freeze
39
39
 
40
40
  def symbols_validate(root)
@@ -46,7 +46,7 @@ module Metanorma
46
46
  @log.add("Style", f.first, NON_DL_SYMBOLS_WARNING)
47
47
  @vocab and f.each do |f1|
48
48
  f1.at("./ancestor::annex") or
49
- @log.add("Style", f1, "In vocabulary documents, Symbols and "\
49
+ @log.add("Style", f1, "In vocabulary documents, Symbols and " \
50
50
  "Abbreviated Terms are only permitted in annexes")
51
51
  end
52
52
  end
@@ -80,15 +80,15 @@ module Metanorma
80
80
  val: ["./self::introduction", "./self::clause[@type = 'scope']"] },
81
81
  { msg: "Prefatory material must be followed by (clause) Scope",
82
82
  val: ["./self::clause[@type = 'scope']"] },
83
- { msg: "Normative References must be followed by "\
83
+ { msg: "Normative References must be followed by " \
84
84
  "Terms and Definitions",
85
85
  val: ["./self::terms | .//terms"] },
86
86
  ].freeze
87
87
 
88
88
  SECTIONS_XPATH =
89
- "//foreword | //introduction | //sections/terms | .//annex | "\
90
- "//sections/definitions | //sections/clause | "\
91
- "//references[not(parent::clause)] | "\
89
+ "//foreword | //introduction | //sections/terms | .//annex | " \
90
+ "//sections/definitions | //sections/clause | " \
91
+ "//references[not(parent::clause)] | " \
92
92
  "//clause[descendant::references][not(parent::clause)]".freeze
93
93
 
94
94
  def sections_sequence_validate(root)
@@ -119,7 +119,7 @@ module Metanorma
119
119
  @log.add("Style", elem, "Document must contain at least one clause")
120
120
  end
121
121
  elem&.at("./self::clause") ||
122
- @log.add("Style", elem, "Document must contain clause after "\
122
+ @log.add("Style", elem, "Document must contain clause after " \
123
123
  "Terms and Definitions")
124
124
  elem&.at("./self::clause[@type = 'scope']") &&
125
125
  @log.add("Style", elem,
@@ -151,12 +151,12 @@ module Metanorma
151
151
  while elem&.name == "annex"
152
152
  elem = names.shift
153
153
  if elem.nil?
154
- @log.add("Style", nil, "Document must include (references) "\
154
+ @log.add("Style", nil, "Document must include (references) " \
155
155
  "Normative References")
156
156
  end
157
157
  end
158
158
  elem&.at("./self::references[@normative = 'true']") ||
159
- @log.add("Style", nil, "Document must include (references) "\
159
+ @log.add("Style", nil, "Document must include (references) " \
160
160
  "Normative References")
161
161
  elem = names&.shift
162
162
  elem&.at("./self::references[@normative = 'false']") ||
@@ -227,13 +227,13 @@ module Metanorma
227
227
  if terms.size == 1
228
228
  ((t = terms.first.at("./title")) && (t&.text == @i18n.termsdef)) or
229
229
  @log.add("Style", terms.first,
230
- "Single terms clause in vocabulary document "\
230
+ "Single terms clause in vocabulary document " \
231
231
  "should have normal Terms and definitions heading")
232
232
  elsif terms.size > 1
233
233
  terms.each do |x|
234
234
  ((t = x.at("./title")) && /^#{@i18n.termsrelated}/.match?(t&.text)) or
235
235
  @log.add("Style", x,
236
- "Multiple terms clauses in vocabulary document "\
236
+ "Multiple terms clauses in vocabulary document " \
237
237
  "should have 'Terms related to' heading")
238
238
  end
239
239
  end
@@ -110,8 +110,8 @@ module Metanorma
110
110
  )
111
111
  style_regex(/\b(?<num>[0-9]+\.[0-9]+)/i,
112
112
  "possible decimal point", node, text)
113
- style_regex(/\b(?<num>billions?)\b/i,
114
- "ambiguous number", node, text)
113
+ @lang == "en" and style_regex(/\b(?<num>billions?)\b/i,
114
+ "ambiguous number", node, text)
115
115
  style_regex(/(^|\s)(?<num>-[0-9][0-9,.]*)/i,
116
116
  "hyphen instead of minus sign U+2212", node, text)
117
117
  end
@@ -135,8 +135,8 @@ module Metanorma
135
135
  end
136
136
 
137
137
  # leaving out as problematic: N J K C S T H h d B o E
138
- SI_UNIT = "(m|cm|mm|km|μm|nm|g|kg|mgmol|cd|rad|sr|Hz|Hz|MHz|Pa|hPa|kJ|"\
139
- "V|kV|W|MW|kW|F|μF|Ω|Wb|°C|lm|lx|Bq|Gy|Sv|kat|l|t|eV|u|Np|Bd|"\
138
+ SI_UNIT = "(m|cm|mm|km|μm|nm|g|kg|mgmol|cd|rad|sr|Hz|Hz|MHz|Pa|hPa|kJ|" \
139
+ "V|kV|W|MW|kW|F|μF|Ω|Wb|°C|lm|lx|Bq|Gy|Sv|kat|l|t|eV|u|Np|Bd|" \
140
140
  "bit|kB|MB|Hart|nat|Sh|var)".freeze
141
141
 
142
142
  # ISO/IEC DIR 2, 9.3
@@ -165,8 +165,8 @@ module Metanorma
165
165
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-and
166
166
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-andor
167
167
  def style_punct(node, text)
168
- style_regex(/\b(?<num>and\/?or)\b/i,
169
- "Use 'either x or y, or both'", node, text)
168
+ @lang == "en" and style_regex(/\b(?<num>and\/?or)\b/i,
169
+ "Use 'either x or y, or both'", node, text)
170
170
  style_regex(/\s(?<num>&)\s/i,
171
171
  "Avoid ampersand in ordinary text'", node, text)
172
172
  end
@@ -180,8 +180,8 @@ module Metanorma
180
180
  end
181
181
 
182
182
  ASSETS_TO_STYLE =
183
- "//termsource | //formula | //termnote | "\
184
- "//p[not(ancestor::boilerplate)] | //li[not(p)] | //dt | "\
183
+ "//termsource | //formula | //termnote | " \
184
+ "//p[not(ancestor::boilerplate)] | //li[not(p)] | //dt | " \
185
185
  "//dd[not(p)] | //td[not(p)] | //th[not(p)]".freeze
186
186
 
187
187
  def asset_style(root)
@@ -42,8 +42,8 @@ module Metanorma
42
42
  def title_subpart_validate(root)
43
43
  docid = root.at("//bibdata/docidentifier[@type = 'ISO']")
44
44
  subpart = /-\d+-\d+/.match docid
45
- iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
46
- "organization[abbreviation = 'IEC' or "\
45
+ iec = root.at("//bibdata/contributor[role/@type = 'publisher']/" \
46
+ "organization[abbreviation = 'IEC' or " \
47
47
  "name = 'International Electrotechnical Commission']")
48
48
  subpart && !iec and
49
49
  @log.add("Style", docid, "Subpart defined on non-IEC document!")
@@ -51,6 +51,7 @@ module Metanorma
51
51
 
52
52
  # ISO/IEC DIR 2, 11.5.2
53
53
  def title_names_type_validate(root)
54
+ @lang == "en" or return
54
55
  doctypes = /International\sStandard | Technical\sSpecification |
55
56
  Publicly\sAvailable\sSpecification | Technical\sReport | Guide /xi
56
57
  title_main_en = title_lang_part(root, "main", "en")
@@ -93,8 +94,8 @@ module Metanorma
93
94
 
94
95
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-full
95
96
  def title_no_full_stop_validate(root)
96
- root.xpath("//preface//title | //sections//title | //annex//title | "\
97
- "//references/title | //preface//name | //sections//name | "\
97
+ root.xpath("//preface//title | //sections//title | //annex//title | " \
98
+ "//references/title | //preface//name | //sections//name | " \
98
99
  "//annex//name").each do |t|
99
100
  style_regex(/\A(?<num>.+\.\Z)/i,
100
101
  "No full stop at end of title or caption",
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.4.0".freeze
3
+ VERSION = "2.4.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
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: 2023-03-13 00:00:00.000000000 Z
11
+ date: 2023-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -340,6 +340,7 @@ files:
340
340
  - lib/isodoc/iso/html_convert.rb
341
341
  - lib/isodoc/iso/i18n-en.yaml
342
342
  - lib/isodoc/iso/i18n-fr.yaml
343
+ - lib/isodoc/iso/i18n-ja.yaml
343
344
  - lib/isodoc/iso/i18n-ru.yaml
344
345
  - lib/isodoc/iso/i18n-zh-Hans.yaml
345
346
  - lib/isodoc/iso/i18n.rb