metanorma-bipm 2.0.3 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -91,7 +91,7 @@
91
91
  <item level="1" id="Foreword" display="true">Foreword</item>
92
92
  <item id="term-script" display="false">3.2</item>
93
93
  -->
94
- <xsl:variable name="contents">
94
+ <xsl:variable name="contents_">
95
95
 
96
96
  <xsl:for-each select="//*[contains(local-name(), '-standard')]">
97
97
  <xsl:variable name="lang" select="*[local-name()='bibdata']/*[local-name()='language'][@current = 'true']"/>
@@ -109,11 +109,14 @@
109
109
  <!-- Index -->
110
110
  <!-- <xsl:apply-templates select="//jcgm:clause[@type = 'index']" mode="contents"/> -->
111
111
  <xsl:apply-templates select="//jcgm:indexsect" mode="contents"/>
112
+
113
+ <xsl:call-template name="processTablesFigures_Contents"/>
112
114
  </contents>
113
115
  </doc>
114
116
  </xsl:for-each>
115
117
  </xsl:for-each>
116
118
  </xsl:variable>
119
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
117
120
 
118
121
 
119
122
  <xsl:variable name="indexes">
@@ -365,7 +368,7 @@
365
368
  <xsl:if test="$debug = 'true'">
366
369
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
367
370
  DEBUG
368
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
371
+ contents=<xsl:copy-of select="$contents"/>
369
372
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
370
373
  </xsl:if>
371
374
 
@@ -375,7 +378,7 @@
375
378
  </xsl:call-template>
376
379
  </xsl:variable>
377
380
 
378
- <xsl:for-each select="xalan:nodeset($contents)/doc[@id=$docid]//item[@display = 'true']"> <!-- and not (@type = 'annex') and not (@type = 'references') -->
381
+ <xsl:for-each select="$contents/doc[@id=$docid]//item[@display = 'true']"> <!-- and not (@type = 'annex') and not (@type = 'references') -->
379
382
  <xsl:if test="@type = 'annex' and not(preceding-sibling::item[@display = 'true' and @type = 'annex'])">
380
383
  <fo:block font-size="12pt" space-before="16pt" font-weight="bold" role="TOCI">
381
384
  <xsl:value-of select="$annexes_title"/>
@@ -383,6 +386,27 @@
383
386
  </xsl:if>
384
387
  <xsl:call-template name="print_JCGN_toc_item"/>
385
388
  </xsl:for-each>
389
+
390
+ <!-- List of Tables -->
391
+ <xsl:if test="$contents//tables/table">
392
+ <xsl:call-template name="insertListOf_Title">
393
+ <xsl:with-param name="title" select="$title-list-tables"/>
394
+ </xsl:call-template>
395
+ <xsl:for-each select="$contents//tables/table">
396
+ <xsl:call-template name="insertListOf_Item"/>
397
+ </xsl:for-each>
398
+ </xsl:if>
399
+
400
+ <!-- List of Figures -->
401
+ <xsl:if test="$contents//figures/figure">
402
+ <xsl:call-template name="insertListOf_Title">
403
+ <xsl:with-param name="title" select="$title-list-figures"/>
404
+ </xsl:call-template>
405
+ <xsl:for-each select="$contents//figures/figure">
406
+ <xsl:call-template name="insertListOf_Item"/>
407
+ </xsl:for-each>
408
+ </xsl:if>
409
+
386
410
  </fo:block>
387
411
  </fo:block-container>
388
412
 
@@ -529,6 +553,32 @@
529
553
  </fo:root>
530
554
  </xsl:template>
531
555
 
556
+ <xsl:template name="insertListOf_Title">
557
+ <xsl:param name="title"/>
558
+ <fo:block font-weight="bold" margin-top="12pt" keep-with-next="always">
559
+ <xsl:value-of select="$title"/>
560
+ </fo:block>
561
+ </xsl:template>
562
+
563
+ <xsl:template name="insertListOf_Item">
564
+ <fo:block margin-left="5mm" role="TOCI">
565
+ <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
566
+ <fo:basic-link internal-destination="{@id}">
567
+ <xsl:call-template name="setAltText">
568
+ <xsl:with-param name="value" select="@alt-text"/>
569
+ </xsl:call-template>
570
+ <fo:inline>
571
+ <xsl:apply-templates select="." mode="contents"/>
572
+ </fo:inline>
573
+ <xsl:text> </xsl:text>
574
+ <fo:inline keep-together.within-line="always" font-weight="normal">
575
+ <fo:leader font-size="9pt" leader-pattern="dots"/>
576
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
577
+ </fo:inline>
578
+ </fo:basic-link>
579
+ </fo:block>
580
+ </fo:block>
581
+ </xsl:template>
532
582
 
533
583
  <xsl:template match="node()">
534
584
  <xsl:apply-templates/>
@@ -1736,6 +1786,10 @@
1736
1786
  <xsl:text>Édition </xsl:text>
1737
1787
  </title-edition>
1738
1788
 
1789
+ <title-edition lang="ru">
1790
+ <xsl:text>Издание </xsl:text>
1791
+ </title-edition>
1792
+
1739
1793
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1740
1794
  <title-toc lang="en">
1741
1795
 
@@ -1750,7 +1804,7 @@
1750
1804
  <xsl:text>Contents</xsl:text>
1751
1805
 
1752
1806
  </title-toc>
1753
-
1807
+
1754
1808
  <title-descriptors lang="en">Descriptors</title-descriptors>
1755
1809
 
1756
1810
  <title-part lang="en">
@@ -1762,7 +1816,11 @@
1762
1816
 
1763
1817
 
1764
1818
 
1765
- </title-part>
1819
+ </title-part>
1820
+ <title-part lang="ru">
1821
+
1822
+
1823
+ </title-part>
1766
1824
  <title-part lang="zh">第 # 部分:</title-part>
1767
1825
 
1768
1826
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -1778,10 +1836,35 @@
1778
1836
 
1779
1837
  <title-summary lang="en">Summary</title-summary>
1780
1838
 
1839
+ <title-continued lang="ru">(продолжение)</title-continued>
1781
1840
  <title-continued lang="en">(continued)</title-continued>
1782
1841
  <title-continued lang="fr">(continué)</title-continued>
1783
1842
 
1784
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
1843
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
1844
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
1845
+ <xsl:value-of select="$toc_table_title"/>
1846
+ <xsl:if test="normalize-space($toc_table_title) = ''">
1847
+ <xsl:call-template name="getTitle">
1848
+ <xsl:with-param name="name" select="'title-list-tables'"/>
1849
+ </xsl:call-template>
1850
+ </xsl:if>
1851
+ </xsl:variable><xsl:variable name="title-list-figures">
1852
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
1853
+ <xsl:value-of select="$toc_figure_title"/>
1854
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
1855
+ <xsl:call-template name="getTitle">
1856
+ <xsl:with-param name="name" select="'title-list-figures'"/>
1857
+ </xsl:call-template>
1858
+ </xsl:if>
1859
+ </xsl:variable><xsl:variable name="title-list-recommendations">
1860
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
1861
+ <xsl:value-of select="$toc_requirement_title"/>
1862
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
1863
+ <xsl:call-template name="getTitle">
1864
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
1865
+ </xsl:call-template>
1866
+ </xsl:if>
1867
+ </xsl:variable><xsl:variable name="bibdata">
1785
1868
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1786
1869
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1787
1870
  </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
@@ -2546,13 +2629,19 @@
2546
2629
  </xsl:attribute-set><xsl:variable name="color-added-text">
2547
2630
  <xsl:text>rgb(0, 255, 0)</xsl:text>
2548
2631
  </xsl:variable><xsl:attribute-set name="add-style">
2549
- <xsl:attribute name="color">red</xsl:attribute>
2550
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
2551
- <!-- <xsl:attribute name="color">black</xsl:attribute>
2552
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2553
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
2554
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2555
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
2632
+
2633
+ <xsl:attribute name="color">red</xsl:attribute>
2634
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
2635
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
2636
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2637
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
2638
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2639
+
2640
+ </xsl:attribute-set><xsl:variable name="add-style">
2641
+ <add-style xsl:use-attribute-sets="add-style"/>
2642
+ </xsl:variable><xsl:template name="append_add-style">
2643
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
2644
+ </xsl:template><xsl:variable name="color-deleted-text">
2556
2645
  <xsl:text>red</xsl:text>
2557
2646
  </xsl:variable><xsl:attribute-set name="del-style">
2558
2647
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -2977,14 +3066,42 @@
2977
3066
  <xsl:attribute name="margin-left">25mm</xsl:attribute>
2978
3067
 
2979
3068
  </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:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
3069
+ <xsl:variable name="nodes_preface_">
3070
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
3071
+ <node id="{@id}"/>
3072
+ </xsl:for-each>
3073
+ </xsl:variable>
3074
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
3075
+
2980
3076
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2981
3077
  <xsl:sort select="@displayorder" data-type="number"/>
3078
+
3079
+ <!-- process Section's title -->
3080
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
3081
+ <xsl:if test="$preceding-sibling_id != ''">
3082
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
3083
+ </xsl:if>
3084
+
2982
3085
  <xsl:apply-templates select="." mode="contents"/>
2983
3086
  </xsl:for-each>
2984
3087
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2985
3088
 
3089
+ <xsl:variable name="nodes_sections_">
3090
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
3091
+ <node id="{@id}"/>
3092
+ </xsl:for-each>
3093
+ </xsl:variable>
3094
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
3095
+
2986
3096
  <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]">
2987
3097
  <xsl:sort select="@displayorder" data-type="number"/>
3098
+
3099
+ <!-- process Section's title -->
3100
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
3101
+ <xsl:if test="$preceding-sibling_id != ''">
3102
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
3103
+ </xsl:if>
3104
+
2988
3105
  <xsl:apply-templates select="." mode="contents"/>
2989
3106
  </xsl:for-each>
2990
3107
 
@@ -2997,6 +3114,30 @@
2997
3114
  <xsl:sort select="@displayorder" data-type="number"/>
2998
3115
  <xsl:apply-templates select="." mode="contents"/>
2999
3116
  </xsl:for-each>
3117
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
3118
+ <xsl:param name="always"/>
3119
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3120
+ <xsl:call-template name="processTables_Contents"/>
3121
+ </xsl:if>
3122
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3123
+ <xsl:call-template name="processFigures_Contents"/>
3124
+ </xsl:if>
3125
+ </xsl:template><xsl:template name="processTables_Contents">
3126
+ <tables>
3127
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
3128
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
3129
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3130
+ </table>
3131
+ </xsl:for-each>
3132
+ </tables>
3133
+ </xsl:template><xsl:template name="processFigures_Contents">
3134
+ <figures>
3135
+ <xsl:for-each select="//*[local-name() = 'figure'][@id and *[local-name() = 'name'] and not(@unnumbered = 'true') and normalize-space(@id) != ''] | //*[@id and starts-with(*[local-name() = 'name'], 'Figure ') and normalize-space(@id) != '']">
3136
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
3137
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3138
+ </figure>
3139
+ </xsl:for-each>
3140
+ </figures>
3000
3141
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3001
3142
  <xsl:for-each select="/*/*[local-name()='preface']/*">
3002
3143
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -3119,7 +3260,7 @@
3119
3260
  </xsl:call-template>
3120
3261
  </xsl:if>
3121
3262
  </xsl:variable>
3122
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3263
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3123
3264
 
3124
3265
 
3125
3266
  <xsl:variable name="margin-side">
@@ -3385,7 +3526,7 @@
3385
3526
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3386
3527
  <!-- 2009 thinspace -->
3387
3528
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
3388
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
3529
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3389
3530
  </xsl:call-template>
3390
3531
  </xsl:variable>
3391
3532
  <xsl:variable name="max_length">
@@ -3847,37 +3988,7 @@
3847
3988
 
3848
3989
  <!-- list of footnotes to calculate actual footnotes number -->
3849
3990
  <xsl:variable name="p_fn_">
3850
- <xsl:choose>
3851
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3852
- <fn gen_id="{generate-id(.)}">
3853
- <xsl:copy-of select="@*"/>
3854
- <xsl:copy-of select="node()"/>
3855
- </fn>
3856
- </xsl:when>
3857
- <xsl:otherwise>
3858
- <!-- itetation for:
3859
- footnotes in bibdata/title
3860
- footnotes in bibliography
3861
- footnotes in document's body (except table's head/body/foot and figure text)
3862
- -->
3863
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3864
- <fn gen_id="{generate-id(.)}">
3865
- <xsl:copy-of select="@*"/>
3866
- <xsl:copy-of select="node()"/>
3867
- </fn>
3868
- </xsl:for-each>
3869
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
3870
- <xsl:sort select="@displayorder" data-type="number"/>
3871
- <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
3872
- <!-- copy unique fn -->
3873
- <fn gen_id="{generate-id(.)}">
3874
- <xsl:copy-of select="@*"/>
3875
- <xsl:copy-of select="node()"/>
3876
- </fn>
3877
- </xsl:for-each>
3878
- </xsl:for-each>
3879
- </xsl:otherwise>
3880
- </xsl:choose>
3991
+ <xsl:call-template name="get_fn_list"/>
3881
3992
  </xsl:variable>
3882
3993
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3883
3994
 
@@ -3938,6 +4049,38 @@
3938
4049
  <xsl:copy-of select="$footnote_inline"/>
3939
4050
  </xsl:otherwise>
3940
4051
  </xsl:choose>
4052
+ </xsl:template><xsl:template name="get_fn_list">
4053
+ <xsl:choose>
4054
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4055
+ <fn gen_id="{generate-id(.)}">
4056
+ <xsl:copy-of select="@*"/>
4057
+ <xsl:copy-of select="node()"/>
4058
+ </fn>
4059
+ </xsl:when>
4060
+ <xsl:otherwise>
4061
+ <!-- itetation for:
4062
+ footnotes in bibdata/title
4063
+ footnotes in bibliography
4064
+ footnotes in document's body (except table's head/body/foot and figure text)
4065
+ -->
4066
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4067
+ <fn gen_id="{generate-id(.)}">
4068
+ <xsl:copy-of select="@*"/>
4069
+ <xsl:copy-of select="node()"/>
4070
+ </fn>
4071
+ </xsl:for-each>
4072
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
4073
+ <xsl:sort select="@displayorder" data-type="number"/>
4074
+ <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4075
+ <!-- copy unique fn -->
4076
+ <fn gen_id="{generate-id(.)}">
4077
+ <xsl:copy-of select="@*"/>
4078
+ <xsl:copy-of select="node()"/>
4079
+ </fn>
4080
+ </xsl:for-each>
4081
+ </xsl:for-each>
4082
+ </xsl:otherwise>
4083
+ </xsl:choose>
3941
4084
  </xsl:template><xsl:template name="table_fn_display">
3942
4085
  <xsl:variable name="references">
3943
4086
 
@@ -4114,7 +4257,7 @@
4114
4257
  </fo:inline>
4115
4258
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
4116
4259
  <fo:inline><xsl:value-of select="."/></fo:inline>
4117
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
4260
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
4118
4261
  <fo:inline>
4119
4262
  <xsl:apply-templates/>
4120
4263
  </fo:inline>
@@ -5104,6 +5247,9 @@
5104
5247
  </fo:inline>
5105
5248
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
5106
5249
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5250
+ <xsl:if test="parent::*[local-name() = 'add']">
5251
+ <xsl:call-template name="append_add-style"/>
5252
+ </xsl:if>
5107
5253
  <xsl:apply-templates/>
5108
5254
  </fo:basic-link>
5109
5255
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -5201,6 +5347,13 @@
5201
5347
 
5202
5348
 
5203
5349
 
5350
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5351
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
5352
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
5353
+ <xsl:call-template name="append_add-style"/>
5354
+ </xsl:if>
5355
+
5356
+
5204
5357
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
5205
5358
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
5206
5359
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -5239,6 +5392,12 @@
5239
5392
 
5240
5393
 
5241
5394
 
5395
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5396
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
5397
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
5398
+ <xsl:call-template name="append_add-style"/>
5399
+ </xsl:if>
5400
+
5242
5401
  <xsl:apply-templates select="*[local-name() = 'name']"/>
5243
5402
 
5244
5403
  </fo:inline>
@@ -5290,6 +5449,7 @@
5290
5449
  </fo:block>
5291
5450
  </xsl:template><xsl:template match="*[local-name() = 'term']">
5292
5451
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
5452
+
5293
5453
 
5294
5454
 
5295
5455
 
@@ -5726,7 +5886,11 @@
5726
5886
  <xsl:value-of select="."/>
5727
5887
  </xsl:template><xsl:template match="node()" mode="contents">
5728
5888
  <xsl:apply-templates mode="contents"/>
5729
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
5889
+ </xsl:template><xsl:template match="*[local-name() = 'preface' or local-name() = 'sections']/*[local-name() = 'p'][@type = 'section-title' and not(@displayorder)]" priority="3" mode="contents"/><xsl:template match="*[local-name() = 'p'][@type = 'section-title' and not(@displayorder)]" mode="contents_no_displayorder">
5890
+ <xsl:call-template name="contents_section-title"/>
5891
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
5892
+ <xsl:call-template name="contents_section-title"/>
5893
+ </xsl:template><xsl:template match="*[local-name() = 'clause']/*[local-name() = 'p'][@type = 'section-title' and (@depth != ../*[local-name() = 'title']/@depth or ../*[local-name() = 'title']/@depth = 1)]" priority="3" mode="contents"/><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" name="contents_section-title" mode="contents">
5730
5894
  <xsl:variable name="level">
5731
5895
  <xsl:call-template name="getLevel">
5732
5896
  <xsl:with-param name="depth" select="@depth"/>
@@ -5795,13 +5959,14 @@
5795
5959
  <xsl:apply-templates mode="bookmarks"/>
5796
5960
  </xsl:template><xsl:template name="addBookmarks">
5797
5961
  <xsl:param name="contents"/>
5798
- <xsl:if test="xalan:nodeset($contents)//item">
5962
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5963
+ <xsl:if test="$contents_nodes//item">
5799
5964
  <fo:bookmark-tree>
5800
5965
  <xsl:choose>
5801
- <xsl:when test="xalan:nodeset($contents)/doc">
5966
+ <xsl:when test="$contents_nodes/doc">
5802
5967
  <xsl:choose>
5803
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5804
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5968
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
5969
+ <xsl:for-each select="$contents_nodes/doc">
5805
5970
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5806
5971
  <xsl:if test="@bundle = 'true'">
5807
5972
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -5852,7 +6017,7 @@
5852
6017
  </xsl:for-each>
5853
6018
  </xsl:when>
5854
6019
  <xsl:otherwise>
5855
- <xsl:for-each select="xalan:nodeset($contents)/doc">
6020
+ <xsl:for-each select="$contents_nodes/doc">
5856
6021
 
5857
6022
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5858
6023
 
@@ -5870,25 +6035,36 @@
5870
6035
  </xsl:choose>
5871
6036
  </xsl:when>
5872
6037
  <xsl:otherwise>
5873
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
6038
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
6039
+
6040
+ <xsl:call-template name="insertFigureBookmarks">
6041
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6042
+ </xsl:call-template>
6043
+
6044
+ <xsl:call-template name="insertTableBookmarks">
6045
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6046
+ <xsl:with-param name="lang" select="@lang"/>
6047
+ </xsl:call-template>
6048
+
5874
6049
  </xsl:otherwise>
5875
6050
  </xsl:choose>
5876
6051
 
6052
+
5877
6053
 
5878
6054
 
5879
6055
 
5880
6056
 
5881
-
5882
-
6057
+
5883
6058
 
5884
6059
  </fo:bookmark-tree>
5885
6060
  </xsl:if>
5886
6061
  </xsl:template><xsl:template name="insertFigureBookmarks">
5887
6062
  <xsl:param name="contents"/>
5888
- <xsl:if test="xalan:nodeset($contents)/figure">
5889
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
6063
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6064
+ <xsl:if test="$contents_nodes/figure">
6065
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
5890
6066
  <fo:bookmark-title>Figures</fo:bookmark-title>
5891
- <xsl:for-each select="xalan:nodeset($contents)/figure">
6067
+ <xsl:for-each select="$contents_nodes/figure">
5892
6068
  <fo:bookmark internal-destination="{@id}">
5893
6069
  <fo:bookmark-title>
5894
6070
  <xsl:value-of select="normalize-space(title)"/>
@@ -5897,18 +6073,40 @@
5897
6073
  </xsl:for-each>
5898
6074
  </fo:bookmark>
5899
6075
  </xsl:if>
6076
+
6077
+
6078
+ <xsl:if test="$contents_nodes//figures/figure">
6079
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6080
+
6081
+
6082
+
6083
+ <xsl:variable name="bookmark-title">
6084
+
6085
+ <xsl:value-of select="$title-list-figures"/>
6086
+
6087
+ </xsl:variable>
6088
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
6089
+ <xsl:for-each select="$contents_nodes//figures/figure">
6090
+ <fo:bookmark internal-destination="{@id}">
6091
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6092
+ </fo:bookmark>
6093
+ </xsl:for-each>
6094
+ </fo:bookmark>
6095
+ </xsl:if>
6096
+
5900
6097
  </xsl:template><xsl:template name="insertTableBookmarks">
5901
6098
  <xsl:param name="contents"/>
5902
6099
  <xsl:param name="lang"/>
5903
- <xsl:if test="xalan:nodeset($contents)/table">
5904
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
6100
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6101
+ <xsl:if test="$contents_nodes/table">
6102
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
5905
6103
  <fo:bookmark-title>
5906
6104
  <xsl:choose>
5907
6105
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
5908
6106
  <xsl:otherwise>Tables</xsl:otherwise>
5909
6107
  </xsl:choose>
5910
6108
  </fo:bookmark-title>
5911
- <xsl:for-each select="xalan:nodeset($contents)/table">
6109
+ <xsl:for-each select="$contents_nodes/table">
5912
6110
  <fo:bookmark internal-destination="{@id}">
5913
6111
  <fo:bookmark-title>
5914
6112
  <xsl:value-of select="normalize-space(title)"/>
@@ -5917,6 +6115,29 @@
5917
6115
  </xsl:for-each>
5918
6116
  </fo:bookmark>
5919
6117
  </xsl:if>
6118
+
6119
+
6120
+ <xsl:if test="$contents_nodes//tables/table">
6121
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6122
+
6123
+
6124
+
6125
+ <xsl:variable name="bookmark-title">
6126
+
6127
+ <xsl:value-of select="$title-list-tables"/>
6128
+
6129
+ </xsl:variable>
6130
+
6131
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
6132
+
6133
+ <xsl:for-each select="$contents_nodes//tables/table">
6134
+ <fo:bookmark internal-destination="{@id}">
6135
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6136
+ </fo:bookmark>
6137
+ </xsl:for-each>
6138
+ </fo:bookmark>
6139
+ </xsl:if>
6140
+
5920
6141
  </xsl:template><xsl:template name="getLangVersion">
5921
6142
  <xsl:param name="lang"/>
5922
6143
  <xsl:param name="doctype" select="''"/>
@@ -6141,7 +6362,51 @@
6141
6362
  <xsl:with-param name="text" select="$text_step1"/>
6142
6363
  </xsl:call-template>
6143
6364
  </xsl:variable>
6144
- <xsl:value-of select="$text_step2"/>
6365
+
6366
+ <!-- <xsl:value-of select="$text_step2"/> -->
6367
+
6368
+ <!-- add zero-width space after space -->
6369
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
6370
+
6371
+ <!-- split text by zero-width space -->
6372
+ <xsl:variable name="text_step4">
6373
+ <xsl:call-template name="split">
6374
+ <xsl:with-param name="pText" select="$text_step3"/>
6375
+ <xsl:with-param name="sep" select="$zero_width_space"/>
6376
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
6377
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
6378
+ </xsl:call-template>
6379
+ </xsl:variable>
6380
+
6381
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
6382
+ <xsl:choose>
6383
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6384
+ <xsl:call-template name="interspers">
6385
+ <xsl:with-param name="str" select="."/>
6386
+ </xsl:call-template>
6387
+ </xsl:when>
6388
+ <xsl:otherwise>
6389
+ <xsl:value-of select="."/>
6390
+ </xsl:otherwise>
6391
+ </xsl:choose>
6392
+ </xsl:for-each>
6393
+
6394
+ </xsl:template><xsl:template name="interspers">
6395
+ <xsl:param name="str"/>
6396
+ <xsl:param name="char" select="$zero_width_space"/>
6397
+ <xsl:if test="$str != ''">
6398
+ <xsl:value-of select="substring($str, 1, 1)"/>
6399
+
6400
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
6401
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
6402
+ <xsl:value-of select="$char"/>
6403
+ </xsl:if>
6404
+
6405
+ <xsl:call-template name="interspers">
6406
+ <xsl:with-param name="str" select="substring($str, 2)"/>
6407
+ <xsl:with-param name="char" select="$char"/>
6408
+ </xsl:call-template>
6409
+ </xsl:if>
6145
6410
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6146
6411
  <xsl:apply-templates mode="syntax_highlight"/>
6147
6412
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6522,7 +6787,7 @@
6522
6787
  <xsl:variable name="element">
6523
6788
 
6524
6789
  <xsl:choose>
6525
- <xsl:when test="$num = 1">inline</xsl:when>
6790
+ <xsl:when test="$num = 1 and not(contains($fo_element, 'block'))">inline</xsl:when>
6526
6791
  <xsl:otherwise>block</xsl:otherwise>
6527
6792
  </xsl:choose>
6528
6793
 
@@ -6578,6 +6843,8 @@
6578
6843
  </xsl:otherwise>
6579
6844
  </xsl:choose> -->
6580
6845
  </fo:block>
6846
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6847
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6581
6848
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6582
6849
  <xsl:if test="normalize-space() != ''">
6583
6850
  <xsl:value-of select="."/>
@@ -6662,26 +6929,24 @@
6662
6929
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6663
6930
  <xsl:text>— </xsl:text>
6664
6931
  <xsl:apply-templates/>
6665
- </xsl:template><xsl:variable name="bibitem_hidden_">
6932
+ </xsl:template><xsl:variable name="bibitems_">
6933
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
6934
+ <xsl:copy-of select="."/>
6935
+ </xsl:for-each>
6936
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
6666
6937
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6667
6938
  <xsl:copy-of select="."/>
6668
6939
  </xsl:for-each>
6669
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6940
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
6670
6941
  <xsl:copy-of select="."/>
6671
6942
  </xsl:for-each>
6672
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6673
-
6674
- <xsl:variable name="bibitemid">
6675
- <xsl:choose>
6676
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6677
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6678
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6679
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6680
- </xsl:choose>
6681
- </xsl:variable>
6682
-
6943
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6944
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6945
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
6946
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
6683
6947
  <xsl:choose>
6684
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
6948
+ <!-- <xsl:when test="$external-destination != '' or not(key('bibitems_hidden', $current_bibitemid))"> --> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
6949
+ <xsl:when test="$external-destination != '' or not($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid])"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
6685
6950
  <fo:inline xsl:use-attribute-sets="eref-style">
6686
6951
  <xsl:if test="@type = 'footnote'">
6687
6952
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6695,8 +6960,8 @@
6695
6960
  <xsl:variable name="text" select="normalize-space()"/>
6696
6961
 
6697
6962
 
6698
-
6699
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6963
+
6964
+ <fo:basic-link fox:alt-text="{@citeas}">
6700
6965
  <xsl:if test="normalize-space(@citeas) = ''">
6701
6966
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6702
6967
  </xsl:if>
@@ -6706,14 +6971,21 @@
6706
6971
 
6707
6972
  </xsl:if>
6708
6973
 
6709
-
6974
+ <xsl:choose>
6975
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6976
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6977
+ </xsl:when>
6978
+ <xsl:otherwise>
6979
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6980
+ </xsl:otherwise>
6981
+ </xsl:choose>
6710
6982
 
6711
6983
  <xsl:apply-templates/>
6712
6984
  </fo:basic-link>
6713
-
6985
+
6714
6986
  </fo:inline>
6715
6987
  </xsl:when>
6716
- <xsl:otherwise>
6988
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6717
6989
  <fo:inline><xsl:apply-templates/></fo:inline>
6718
6990
  </xsl:otherwise>
6719
6991
  </xsl:choose>
@@ -7053,7 +7325,7 @@
7053
7325
 
7054
7326
 
7055
7327
 
7056
-
7328
+
7057
7329
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7058
7330
  </fo:list-block>
7059
7331
  <!-- <xsl:for-each select="./iho:note">
@@ -7071,6 +7343,11 @@
7071
7343
 
7072
7344
 
7073
7345
 
7346
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7347
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
7348
+ <xsl:call-template name="append_add-style"/>
7349
+ </xsl:if>
7350
+
7074
7351
  <xsl:call-template name="getListItemFormat"/>
7075
7352
  </fo:block>
7076
7353
  </fo:list-item-label>
@@ -7445,27 +7722,47 @@
7445
7722
  <xsl:apply-templates/>
7446
7723
  </fo:inline>
7447
7724
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7725
+
7726
+ <!-- list of footnotes to calculate actual footnotes number -->
7727
+ <xsl:variable name="p_fn_">
7728
+ <xsl:call-template name="get_fn_list"/>
7729
+ </xsl:variable>
7730
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7731
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7732
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7733
+ <!-- fn sequence number in document -->
7734
+ <xsl:variable name="current_fn_number">
7735
+ <xsl:choose>
7736
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7737
+ <xsl:otherwise>
7738
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7739
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7740
+ </xsl:otherwise>
7741
+ </xsl:choose>
7742
+ </xsl:variable>
7448
7743
  <fo:footnote>
7449
7744
  <xsl:variable name="number">
7450
7745
 
7451
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7746
+ <xsl:value-of select="$current_fn_number"/>
7452
7747
 
7453
7748
  </xsl:variable>
7454
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7455
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
7456
- <xsl:value-of select="$number"/>
7457
-
7749
+
7750
+ <xsl:variable name="current_fn_number_text">
7751
+ <xsl:value-of select="$number"/>
7752
+
7458
7753
  <xsl:text>)</xsl:text>
7459
7754
 
7755
+ </xsl:variable>
7756
+
7757
+ <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7758
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7759
+ <xsl:value-of select="$current_fn_number_text"/>
7460
7760
  </fo:basic-link>
7461
7761
  </fo:inline>
7462
7762
  <fo:footnote-body>
7463
7763
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
7464
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7465
- <xsl:value-of select="$number"/>
7466
-
7467
- <xsl:text>)</xsl:text>
7468
-
7764
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7765
+ <xsl:value-of select="$current_fn_number_text"/>
7469
7766
  </fo:inline>
7470
7767
  <xsl:apply-templates/>
7471
7768
  </fo:block>
@@ -7705,6 +8002,78 @@
7705
8002
  <xsl:apply-templates/>
7706
8003
  </fo:block>
7707
8004
 
8005
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
8006
+ <xsl:copy>
8007
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
8008
+ </xsl:copy>
8009
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
8010
+ <xsl:copy>
8011
+ <xsl:copy-of select="@*"/>
8012
+
8013
+ <xsl:variable name="nodes_preface_">
8014
+ <xsl:for-each select="*">
8015
+ <node id="{@id}"/>
8016
+ </xsl:for-each>
8017
+ </xsl:variable>
8018
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
8019
+
8020
+ <xsl:for-each select="*">
8021
+ <xsl:sort select="@displayorder" data-type="number"/>
8022
+
8023
+ <!-- process Section's title -->
8024
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8025
+ <xsl:if test="$preceding-sibling_id != ''">
8026
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8027
+ </xsl:if>
8028
+
8029
+ <xsl:choose>
8030
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8031
+ <xsl:otherwise>
8032
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8033
+ </xsl:otherwise>
8034
+ </xsl:choose>
8035
+
8036
+ </xsl:for-each>
8037
+ </xsl:copy>
8038
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
8039
+ <xsl:copy>
8040
+ <xsl:copy-of select="@*"/>
8041
+
8042
+ <xsl:variable name="nodes_sections_">
8043
+ <xsl:for-each select="*">
8044
+ <node id="{@id}"/>
8045
+ </xsl:for-each>
8046
+ </xsl:variable>
8047
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
8048
+
8049
+ <!-- move section 'Normative references' inside 'sections' -->
8050
+ <xsl:for-each select="* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]">
8051
+ <xsl:sort select="@displayorder" data-type="number"/>
8052
+
8053
+ <!-- process Section's title -->
8054
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8055
+ <xsl:if test="$preceding-sibling_id != ''">
8056
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8057
+ </xsl:if>
8058
+
8059
+ <xsl:choose>
8060
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8061
+ <xsl:otherwise>
8062
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8063
+ </xsl:otherwise>
8064
+ </xsl:choose>
8065
+
8066
+ </xsl:for-each>
8067
+ </xsl:copy>
8068
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
8069
+ <xsl:copy>
8070
+ <xsl:copy-of select="@*"/>
8071
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
8072
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
8073
+ <xsl:sort select="@displayorder" data-type="number"/>
8074
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8075
+ </xsl:for-each>
8076
+ </xsl:copy>
7708
8077
  </xsl:template><xsl:template name="convertDate">
7709
8078
  <xsl:param name="date"/>
7710
8079
  <xsl:param name="format" select="'short'"/>
@@ -7946,22 +8315,25 @@
7946
8315
  <xsl:param name="pText" select="."/>
7947
8316
  <xsl:param name="sep" select="','"/>
7948
8317
  <xsl:param name="normalize-space" select="'true'"/>
8318
+ <xsl:param name="keep_sep" select="'false'"/>
7949
8319
  <xsl:if test="string-length($pText) &gt;0">
7950
- <item>
7951
- <xsl:choose>
7952
- <xsl:when test="$normalize-space = 'true'">
7953
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7954
- </xsl:when>
7955
- <xsl:otherwise>
7956
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7957
- </xsl:otherwise>
7958
- </xsl:choose>
7959
- </item>
7960
- <xsl:call-template name="split">
7961
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7962
- <xsl:with-param name="sep" select="$sep"/>
7963
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
7964
- </xsl:call-template>
8320
+ <item>
8321
+ <xsl:choose>
8322
+ <xsl:when test="$normalize-space = 'true'">
8323
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8324
+ </xsl:when>
8325
+ <xsl:otherwise>
8326
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8327
+ </xsl:otherwise>
8328
+ </xsl:choose>
8329
+ </item>
8330
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
8331
+ <xsl:call-template name="split">
8332
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8333
+ <xsl:with-param name="sep" select="$sep"/>
8334
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
8335
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
8336
+ </xsl:call-template>
7965
8337
  </xsl:if>
7966
8338
  </xsl:template><xsl:template name="getDocumentId">
7967
8339
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -8152,53 +8524,153 @@
8152
8524
  <xsl:param name="first"/>
8153
8525
  <xsl:if test="$number != ''">
8154
8526
  <xsl:variable name="words">
8155
- <words>
8156
- <word cardinal="1">One-</word>
8157
- <word ordinal="1">First </word>
8158
- <word cardinal="2">Two-</word>
8159
- <word ordinal="2">Second </word>
8160
- <word cardinal="3">Three-</word>
8161
- <word ordinal="3">Third </word>
8162
- <word cardinal="4">Four-</word>
8163
- <word ordinal="4">Fourth </word>
8164
- <word cardinal="5">Five-</word>
8165
- <word ordinal="5">Fifth </word>
8166
- <word cardinal="6">Six-</word>
8167
- <word ordinal="6">Sixth </word>
8168
- <word cardinal="7">Seven-</word>
8169
- <word ordinal="7">Seventh </word>
8170
- <word cardinal="8">Eight-</word>
8171
- <word ordinal="8">Eighth </word>
8172
- <word cardinal="9">Nine-</word>
8173
- <word ordinal="9">Ninth </word>
8174
- <word ordinal="10">Tenth </word>
8175
- <word ordinal="11">Eleventh </word>
8176
- <word ordinal="12">Twelfth </word>
8177
- <word ordinal="13">Thirteenth </word>
8178
- <word ordinal="14">Fourteenth </word>
8179
- <word ordinal="15">Fifteenth </word>
8180
- <word ordinal="16">Sixteenth </word>
8181
- <word ordinal="17">Seventeenth </word>
8182
- <word ordinal="18">Eighteenth </word>
8183
- <word ordinal="19">Nineteenth </word>
8184
- <word cardinal="20">Twenty-</word>
8185
- <word ordinal="20">Twentieth </word>
8186
- <word cardinal="30">Thirty-</word>
8187
- <word ordinal="30">Thirtieth </word>
8188
- <word cardinal="40">Forty-</word>
8189
- <word ordinal="40">Fortieth </word>
8190
- <word cardinal="50">Fifty-</word>
8191
- <word ordinal="50">Fiftieth </word>
8192
- <word cardinal="60">Sixty-</word>
8193
- <word ordinal="60">Sixtieth </word>
8194
- <word cardinal="70">Seventy-</word>
8195
- <word ordinal="70">Seventieth </word>
8196
- <word cardinal="80">Eighty-</word>
8197
- <word ordinal="80">Eightieth </word>
8198
- <word cardinal="90">Ninety-</word>
8199
- <word ordinal="90">Ninetieth </word>
8200
- <word cardinal="100">Hundred-</word>
8201
- <word ordinal="100">Hundredth </word>
8527
+ <words>
8528
+ <xsl:choose>
8529
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
8530
+ <word cardinal="1">Une-</word>
8531
+ <word ordinal="1">Première </word>
8532
+ <word cardinal="2">Deux-</word>
8533
+ <word ordinal="2">Seconde </word>
8534
+ <word cardinal="3">Trois-</word>
8535
+ <word ordinal="3">Tierce </word>
8536
+ <word cardinal="4">Quatre-</word>
8537
+ <word ordinal="4">Quatrième </word>
8538
+ <word cardinal="5">Cinq-</word>
8539
+ <word ordinal="5">Cinquième </word>
8540
+ <word cardinal="6">Six-</word>
8541
+ <word ordinal="6">Sixième </word>
8542
+ <word cardinal="7">Sept-</word>
8543
+ <word ordinal="7">Septième </word>
8544
+ <word cardinal="8">Huit-</word>
8545
+ <word ordinal="8">Huitième </word>
8546
+ <word cardinal="9">Neuf-</word>
8547
+ <word ordinal="9">Neuvième </word>
8548
+ <word ordinal="10">Dixième </word>
8549
+ <word ordinal="11">Onzième </word>
8550
+ <word ordinal="12">Douzième </word>
8551
+ <word ordinal="13">Treizième </word>
8552
+ <word ordinal="14">Quatorzième </word>
8553
+ <word ordinal="15">Quinzième </word>
8554
+ <word ordinal="16">Seizième </word>
8555
+ <word ordinal="17">Dix-septième </word>
8556
+ <word ordinal="18">Dix-huitième </word>
8557
+ <word ordinal="19">Dix-neuvième </word>
8558
+ <word cardinal="20">Vingt-</word>
8559
+ <word ordinal="20">Vingtième </word>
8560
+ <word cardinal="30">Trente-</word>
8561
+ <word ordinal="30">Trentième </word>
8562
+ <word cardinal="40">Quarante-</word>
8563
+ <word ordinal="40">Quarantième </word>
8564
+ <word cardinal="50">Cinquante-</word>
8565
+ <word ordinal="50">Cinquantième </word>
8566
+ <word cardinal="60">Soixante-</word>
8567
+ <word ordinal="60">Soixantième </word>
8568
+ <word cardinal="70">Septante-</word>
8569
+ <word ordinal="70">Septantième </word>
8570
+ <word cardinal="80">Huitante-</word>
8571
+ <word ordinal="80">Huitantième </word>
8572
+ <word cardinal="90">Nonante-</word>
8573
+ <word ordinal="90">Nonantième </word>
8574
+ <word cardinal="100">Cent-</word>
8575
+ <word ordinal="100">Centième </word>
8576
+ </xsl:when>
8577
+ <xsl:when test="$lang = 'ru'">
8578
+ <word cardinal="1">Одна-</word>
8579
+ <word ordinal="1">Первое </word>
8580
+ <word cardinal="2">Две-</word>
8581
+ <word ordinal="2">Второе </word>
8582
+ <word cardinal="3">Три-</word>
8583
+ <word ordinal="3">Третье </word>
8584
+ <word cardinal="4">Четыре-</word>
8585
+ <word ordinal="4">Четвертое </word>
8586
+ <word cardinal="5">Пять-</word>
8587
+ <word ordinal="5">Пятое </word>
8588
+ <word cardinal="6">Шесть-</word>
8589
+ <word ordinal="6">Шестое </word>
8590
+ <word cardinal="7">Семь-</word>
8591
+ <word ordinal="7">Седьмое </word>
8592
+ <word cardinal="8">Восемь-</word>
8593
+ <word ordinal="8">Восьмое </word>
8594
+ <word cardinal="9">Девять-</word>
8595
+ <word ordinal="9">Девятое </word>
8596
+ <word ordinal="10">Десятое </word>
8597
+ <word ordinal="11">Одиннадцатое </word>
8598
+ <word ordinal="12">Двенадцатое </word>
8599
+ <word ordinal="13">Тринадцатое </word>
8600
+ <word ordinal="14">Четырнадцатое </word>
8601
+ <word ordinal="15">Пятнадцатое </word>
8602
+ <word ordinal="16">Шестнадцатое </word>
8603
+ <word ordinal="17">Семнадцатое </word>
8604
+ <word ordinal="18">Восемнадцатое </word>
8605
+ <word ordinal="19">Девятнадцатое </word>
8606
+ <word cardinal="20">Двадцать-</word>
8607
+ <word ordinal="20">Двадцатое </word>
8608
+ <word cardinal="30">Тридцать-</word>
8609
+ <word ordinal="30">Тридцатое </word>
8610
+ <word cardinal="40">Сорок-</word>
8611
+ <word ordinal="40">Сороковое </word>
8612
+ <word cardinal="50">Пятьдесят-</word>
8613
+ <word ordinal="50">Пятидесятое </word>
8614
+ <word cardinal="60">Шестьдесят-</word>
8615
+ <word ordinal="60">Шестидесятое </word>
8616
+ <word cardinal="70">Семьдесят-</word>
8617
+ <word ordinal="70">Семидесятое </word>
8618
+ <word cardinal="80">Восемьдесят-</word>
8619
+ <word ordinal="80">Восьмидесятое </word>
8620
+ <word cardinal="90">Девяносто-</word>
8621
+ <word ordinal="90">Девяностое </word>
8622
+ <word cardinal="100">Сто-</word>
8623
+ <word ordinal="100">Сотое </word>
8624
+ </xsl:when>
8625
+ <xsl:otherwise> <!-- default english -->
8626
+ <word cardinal="1">One-</word>
8627
+ <word ordinal="1">First </word>
8628
+ <word cardinal="2">Two-</word>
8629
+ <word ordinal="2">Second </word>
8630
+ <word cardinal="3">Three-</word>
8631
+ <word ordinal="3">Third </word>
8632
+ <word cardinal="4">Four-</word>
8633
+ <word ordinal="4">Fourth </word>
8634
+ <word cardinal="5">Five-</word>
8635
+ <word ordinal="5">Fifth </word>
8636
+ <word cardinal="6">Six-</word>
8637
+ <word ordinal="6">Sixth </word>
8638
+ <word cardinal="7">Seven-</word>
8639
+ <word ordinal="7">Seventh </word>
8640
+ <word cardinal="8">Eight-</word>
8641
+ <word ordinal="8">Eighth </word>
8642
+ <word cardinal="9">Nine-</word>
8643
+ <word ordinal="9">Ninth </word>
8644
+ <word ordinal="10">Tenth </word>
8645
+ <word ordinal="11">Eleventh </word>
8646
+ <word ordinal="12">Twelfth </word>
8647
+ <word ordinal="13">Thirteenth </word>
8648
+ <word ordinal="14">Fourteenth </word>
8649
+ <word ordinal="15">Fifteenth </word>
8650
+ <word ordinal="16">Sixteenth </word>
8651
+ <word ordinal="17">Seventeenth </word>
8652
+ <word ordinal="18">Eighteenth </word>
8653
+ <word ordinal="19">Nineteenth </word>
8654
+ <word cardinal="20">Twenty-</word>
8655
+ <word ordinal="20">Twentieth </word>
8656
+ <word cardinal="30">Thirty-</word>
8657
+ <word ordinal="30">Thirtieth </word>
8658
+ <word cardinal="40">Forty-</word>
8659
+ <word ordinal="40">Fortieth </word>
8660
+ <word cardinal="50">Fifty-</word>
8661
+ <word ordinal="50">Fiftieth </word>
8662
+ <word cardinal="60">Sixty-</word>
8663
+ <word ordinal="60">Sixtieth </word>
8664
+ <word cardinal="70">Seventy-</word>
8665
+ <word ordinal="70">Seventieth </word>
8666
+ <word cardinal="80">Eighty-</word>
8667
+ <word ordinal="80">Eightieth </word>
8668
+ <word cardinal="90">Ninety-</word>
8669
+ <word ordinal="90">Ninetieth </word>
8670
+ <word cardinal="100">Hundred-</word>
8671
+ <word ordinal="100">Hundredth </word>
8672
+ </xsl:otherwise>
8673
+ </xsl:choose>
8202
8674
  </words>
8203
8675
  </xsl:variable>
8204
8676
 
@@ -8272,4 +8744,18 @@
8272
8744
  <xsl:otherwise>_</xsl:otherwise>
8273
8745
  </xsl:choose>
8274
8746
  </xsl:attribute>
8747
+ </xsl:template><xsl:template name="substring-after-last">
8748
+ <xsl:param name="value"/>
8749
+ <xsl:param name="delimiter"/>
8750
+ <xsl:choose>
8751
+ <xsl:when test="contains($value, $delimiter)">
8752
+ <xsl:call-template name="substring-after-last">
8753
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
8754
+ <xsl:with-param name="delimiter" select="$delimiter"/>
8755
+ </xsl:call-template>
8756
+ </xsl:when>
8757
+ <xsl:otherwise>
8758
+ <xsl:value-of select="$value"/>
8759
+ </xsl:otherwise>
8760
+ </xsl:choose>
8275
8761
  </xsl:template></xsl:stylesheet>