metanorma-iec 2.0.3 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -74,7 +74,7 @@
74
74
  <item level="1" id="Foreword" display="true">Foreword</item>
75
75
  <item id="term-script" display="false">3.2</item>
76
76
  -->
77
- <xsl:variable name="contents">
77
+ <xsl:variable name="contents_">
78
78
 
79
79
  <xsl:for-each select="//iec:iec-standard">
80
80
  <xsl:variable name="lang" select="*[local-name()='bibdata']/*[local-name()='language'][@current = 'true']"/>
@@ -92,22 +92,16 @@
92
92
  </xsl:for-each>
93
93
 
94
94
  </xsl:variable>
95
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
95
96
 
96
97
  <xsl:template name="generateContents">
97
98
  <contents>
98
99
  <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
99
100
  <xsl:call-template name="processMainSectionsDefault_Contents"/>
100
101
  <xsl:apply-templates select="//iec:indexsect" mode="contents"/>
101
- <xsl:for-each select="//*[local-name() = 'figure'][@id and *[local-name() = 'name']]">
102
- <figure id="{@id}">
103
- <title><xsl:value-of select="*[local-name() = 'name']/text()"/></title>
104
- </figure>
105
- </xsl:for-each>
106
- <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name']]">
107
- <table id="{@id}">
108
- <title><xsl:value-of select="*[local-name() = 'name']/text()"/></title>
109
- </table>
110
- </xsl:for-each>
102
+ <xsl:call-template name="processTablesFigures_Contents">
103
+ <xsl:with-param name="always">true</xsl:with-param>
104
+ </xsl:call-template>
111
105
  </contents>
112
106
  </xsl:template>
113
107
 
@@ -816,7 +810,7 @@
816
810
  <xsl:if test="$debug = 'true'">
817
811
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
818
812
  DEBUG
819
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
813
+ contents=<xsl:copy-of select="$contents"/>
820
814
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
821
815
  </xsl:if>
822
816
 
@@ -845,7 +839,7 @@
845
839
  <fo:flow flow-name="xsl-region-body">
846
840
 
847
841
  <xsl:call-template name="insertTOCpages">
848
- <xsl:with-param name="contents" select="xalan:nodeset($contents)/doc[@id = $docid]"/>
842
+ <xsl:with-param name="contents" select="$contents/doc[@id = $docid]"/>
849
843
  </xsl:call-template>
850
844
 
851
845
  <xsl:call-template name="insertPrefacepages">
@@ -1192,39 +1186,36 @@
1192
1186
  </fo:block>
1193
1187
  </xsl:for-each>
1194
1188
 
1195
- <xsl:if test="//iec:figure[@id and iec:name]">
1196
- <fo:block margin-bottom="5pt"> </fo:block>
1197
- <xsl:for-each select="//iec:figure[@id and iec:name]">
1198
- <fo:block text-align-last="justify" margin-bottom="5pt" margin-left="8mm" text-indent="-8mm" role="TOCI">
1199
- <fo:basic-link internal-destination="{@id}" fox:alt-text="Figure {@id}">
1200
- <xsl:apply-templates select="iec:name" mode="contents"/>
1201
- <fo:inline keep-together.within-line="always">
1202
- <fo:leader leader-pattern="dots"/>
1203
- <fo:page-number-citation ref-id="{@id}"/>
1204
- </fo:inline>
1205
- </fo:basic-link>
1206
- </fo:block>
1189
+ <xsl:if test="$contents//figures/figure">
1190
+ <fo:block margin-bottom="5pt"> </fo:block>
1191
+ <xsl:for-each select="$contents//figures/figure">
1192
+ <xsl:call-template name="insertListOf_Item"/>
1207
1193
  </xsl:for-each>
1208
1194
  </xsl:if>
1209
1195
 
1210
- <xsl:if test="//iec:table[@id and iec:name]">
1211
- <fo:block margin-bottom="5pt"> </fo:block>
1212
- <xsl:for-each select="//iec:table[@id and iec:name]">
1213
- <fo:block text-align-last="justify" margin-bottom="5pt" margin-left="8mm" text-indent="-8mm" role="TOCI">
1214
- <fo:basic-link internal-destination="{@id}" fox:alt-text="Table {@id}">
1215
- <xsl:apply-templates select="iec:name" mode="contents"/>
1216
- <fo:inline keep-together.within-line="always">
1217
- <fo:leader leader-pattern="dots"/>
1218
- <fo:page-number-citation ref-id="{@id}"/>
1219
- </fo:inline>
1220
- </fo:basic-link>
1221
- </fo:block>
1196
+ <xsl:if test="$contents//tables/table">
1197
+ <fo:block margin-bottom="5pt"> </fo:block>
1198
+ <xsl:for-each select="$contents//tables/table">
1199
+ <xsl:call-template name="insertListOf_Item"/>
1222
1200
  </xsl:for-each>
1223
1201
  </xsl:if>
1202
+
1224
1203
  </fo:block>
1225
1204
  </fo:block-container>
1226
1205
  </xsl:template>
1227
1206
 
1207
+ <xsl:template name="insertListOf_Item">
1208
+ <fo:block text-align-last="justify" margin-bottom="5pt" margin-left="8mm" text-indent="-8mm" role="TOCI">
1209
+ <fo:basic-link internal-destination="{@id}" fox:alt-text="{local-name()} {@id}">
1210
+ <xsl:apply-templates select="." mode="contents"/>
1211
+ <fo:inline keep-together.within-line="always">
1212
+ <fo:leader leader-pattern="dots"/>
1213
+ <fo:page-number-citation ref-id="{@id}"/>
1214
+ </fo:inline>
1215
+ </fo:basic-link>
1216
+ </fo:block>
1217
+ </xsl:template>
1218
+
1228
1219
  <xsl:template name="insertPrefacepages">
1229
1220
  <xsl:param name="lang" select="$lang"/>
1230
1221
  <fo:block break-after="page"/>
@@ -1957,6 +1948,10 @@
1957
1948
  <xsl:text>Édition </xsl:text>
1958
1949
  </title-edition>
1959
1950
 
1951
+ <title-edition lang="ru">
1952
+ <xsl:text>Издание </xsl:text>
1953
+ </title-edition>
1954
+
1960
1955
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1961
1956
  <title-toc lang="en">
1962
1957
 
@@ -1971,7 +1966,7 @@
1971
1966
  <xsl:text>Contents</xsl:text>
1972
1967
 
1973
1968
  </title-toc>
1974
-
1969
+
1975
1970
  <title-descriptors lang="en">Descriptors</title-descriptors>
1976
1971
 
1977
1972
  <title-part lang="en">
@@ -1987,7 +1982,13 @@
1987
1982
  <xsl:text>Partie #: </xsl:text>
1988
1983
 
1989
1984
 
1990
- </title-part>
1985
+ </title-part>
1986
+ <title-part lang="ru">
1987
+
1988
+
1989
+ <xsl:text>Часть #: </xsl:text>
1990
+
1991
+ </title-part>
1991
1992
  <title-part lang="zh">第 # 部分:</title-part>
1992
1993
 
1993
1994
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -2003,10 +2004,35 @@
2003
2004
 
2004
2005
  <title-summary lang="en">Summary</title-summary>
2005
2006
 
2007
+ <title-continued lang="ru">(продолжение)</title-continued>
2006
2008
  <title-continued lang="en">(continued)</title-continued>
2007
2009
  <title-continued lang="fr">(continué)</title-continued>
2008
2010
 
2009
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
2011
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
2012
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
2013
+ <xsl:value-of select="$toc_table_title"/>
2014
+ <xsl:if test="normalize-space($toc_table_title) = ''">
2015
+ <xsl:call-template name="getTitle">
2016
+ <xsl:with-param name="name" select="'title-list-tables'"/>
2017
+ </xsl:call-template>
2018
+ </xsl:if>
2019
+ </xsl:variable><xsl:variable name="title-list-figures">
2020
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
2021
+ <xsl:value-of select="$toc_figure_title"/>
2022
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
2023
+ <xsl:call-template name="getTitle">
2024
+ <xsl:with-param name="name" select="'title-list-figures'"/>
2025
+ </xsl:call-template>
2026
+ </xsl:if>
2027
+ </xsl:variable><xsl:variable name="title-list-recommendations">
2028
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
2029
+ <xsl:value-of select="$toc_requirement_title"/>
2030
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
2031
+ <xsl:call-template name="getTitle">
2032
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
2033
+ </xsl:call-template>
2034
+ </xsl:if>
2035
+ </xsl:variable><xsl:variable name="bibdata">
2010
2036
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
2011
2037
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
2012
2038
  </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">
@@ -2775,13 +2801,19 @@
2775
2801
  </xsl:attribute-set><xsl:variable name="color-added-text">
2776
2802
  <xsl:text>rgb(0, 255, 0)</xsl:text>
2777
2803
  </xsl:variable><xsl:attribute-set name="add-style">
2778
- <xsl:attribute name="color">red</xsl:attribute>
2779
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
2780
- <!-- <xsl:attribute name="color">black</xsl:attribute>
2781
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2782
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
2783
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2784
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
2804
+
2805
+ <xsl:attribute name="color">red</xsl:attribute>
2806
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
2807
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
2808
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2809
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
2810
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2811
+
2812
+ </xsl:attribute-set><xsl:variable name="add-style">
2813
+ <add-style xsl:use-attribute-sets="add-style"/>
2814
+ </xsl:variable><xsl:template name="append_add-style">
2815
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
2816
+ </xsl:template><xsl:variable name="color-deleted-text">
2785
2817
  <xsl:text>red</xsl:text>
2786
2818
  </xsl:variable><xsl:attribute-set name="del-style">
2787
2819
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -3218,14 +3250,42 @@
3218
3250
 
3219
3251
 
3220
3252
  </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">
3253
+ <xsl:variable name="nodes_preface_">
3254
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
3255
+ <node id="{@id}"/>
3256
+ </xsl:for-each>
3257
+ </xsl:variable>
3258
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
3259
+
3221
3260
  <xsl:for-each select="/*/*[local-name()='preface']/*">
3222
3261
  <xsl:sort select="@displayorder" data-type="number"/>
3262
+
3263
+ <!-- process Section's title -->
3264
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
3265
+ <xsl:if test="$preceding-sibling_id != ''">
3266
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
3267
+ </xsl:if>
3268
+
3223
3269
  <xsl:apply-templates select="." mode="contents"/>
3224
3270
  </xsl:for-each>
3225
3271
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
3226
3272
 
3273
+ <xsl:variable name="nodes_sections_">
3274
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
3275
+ <node id="{@id}"/>
3276
+ </xsl:for-each>
3277
+ </xsl:variable>
3278
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
3279
+
3227
3280
  <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']]">
3228
3281
  <xsl:sort select="@displayorder" data-type="number"/>
3282
+
3283
+ <!-- process Section's title -->
3284
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
3285
+ <xsl:if test="$preceding-sibling_id != ''">
3286
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
3287
+ </xsl:if>
3288
+
3229
3289
  <xsl:apply-templates select="." mode="contents"/>
3230
3290
  </xsl:for-each>
3231
3291
 
@@ -3238,6 +3298,30 @@
3238
3298
  <xsl:sort select="@displayorder" data-type="number"/>
3239
3299
  <xsl:apply-templates select="." mode="contents"/>
3240
3300
  </xsl:for-each>
3301
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
3302
+ <xsl:param name="always"/>
3303
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3304
+ <xsl:call-template name="processTables_Contents"/>
3305
+ </xsl:if>
3306
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3307
+ <xsl:call-template name="processFigures_Contents"/>
3308
+ </xsl:if>
3309
+ </xsl:template><xsl:template name="processTables_Contents">
3310
+ <tables>
3311
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
3312
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
3313
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3314
+ </table>
3315
+ </xsl:for-each>
3316
+ </tables>
3317
+ </xsl:template><xsl:template name="processFigures_Contents">
3318
+ <figures>
3319
+ <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) != '']">
3320
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
3321
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3322
+ </figure>
3323
+ </xsl:for-each>
3324
+ </figures>
3241
3325
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3242
3326
  <xsl:for-each select="/*/*[local-name()='preface']/*">
3243
3327
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -3367,7 +3451,7 @@
3367
3451
  </xsl:call-template>
3368
3452
  </xsl:if>
3369
3453
  </xsl:variable>
3370
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3454
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3371
3455
 
3372
3456
 
3373
3457
  <xsl:variable name="margin-side">
@@ -3637,7 +3721,7 @@
3637
3721
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3638
3722
  <!-- 2009 thinspace -->
3639
3723
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
3640
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
3724
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3641
3725
  </xsl:call-template>
3642
3726
  </xsl:variable>
3643
3727
  <xsl:variable name="max_length">
@@ -4042,37 +4126,7 @@
4042
4126
 
4043
4127
  <!-- list of footnotes to calculate actual footnotes number -->
4044
4128
  <xsl:variable name="p_fn_">
4045
- <xsl:choose>
4046
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4047
- <fn gen_id="{generate-id(.)}">
4048
- <xsl:copy-of select="@*"/>
4049
- <xsl:copy-of select="node()"/>
4050
- </fn>
4051
- </xsl:when>
4052
- <xsl:otherwise>
4053
- <!-- itetation for:
4054
- footnotes in bibdata/title
4055
- footnotes in bibliography
4056
- footnotes in document's body (except table's head/body/foot and figure text)
4057
- -->
4058
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4059
- <fn gen_id="{generate-id(.)}">
4060
- <xsl:copy-of select="@*"/>
4061
- <xsl:copy-of select="node()"/>
4062
- </fn>
4063
- </xsl:for-each>
4064
- <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']/*">
4065
- <xsl:sort select="@displayorder" data-type="number"/>
4066
- <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])]">
4067
- <!-- copy unique fn -->
4068
- <fn gen_id="{generate-id(.)}">
4069
- <xsl:copy-of select="@*"/>
4070
- <xsl:copy-of select="node()"/>
4071
- </fn>
4072
- </xsl:for-each>
4073
- </xsl:for-each>
4074
- </xsl:otherwise>
4075
- </xsl:choose>
4129
+ <xsl:call-template name="get_fn_list"/>
4076
4130
  </xsl:variable>
4077
4131
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
4078
4132
 
@@ -4133,6 +4187,38 @@
4133
4187
  <xsl:copy-of select="$footnote_inline"/>
4134
4188
  </xsl:otherwise>
4135
4189
  </xsl:choose>
4190
+ </xsl:template><xsl:template name="get_fn_list">
4191
+ <xsl:choose>
4192
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4193
+ <fn gen_id="{generate-id(.)}">
4194
+ <xsl:copy-of select="@*"/>
4195
+ <xsl:copy-of select="node()"/>
4196
+ </fn>
4197
+ </xsl:when>
4198
+ <xsl:otherwise>
4199
+ <!-- itetation for:
4200
+ footnotes in bibdata/title
4201
+ footnotes in bibliography
4202
+ footnotes in document's body (except table's head/body/foot and figure text)
4203
+ -->
4204
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4205
+ <fn gen_id="{generate-id(.)}">
4206
+ <xsl:copy-of select="@*"/>
4207
+ <xsl:copy-of select="node()"/>
4208
+ </fn>
4209
+ </xsl:for-each>
4210
+ <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']/*">
4211
+ <xsl:sort select="@displayorder" data-type="number"/>
4212
+ <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])]">
4213
+ <!-- copy unique fn -->
4214
+ <fn gen_id="{generate-id(.)}">
4215
+ <xsl:copy-of select="@*"/>
4216
+ <xsl:copy-of select="node()"/>
4217
+ </fn>
4218
+ </xsl:for-each>
4219
+ </xsl:for-each>
4220
+ </xsl:otherwise>
4221
+ </xsl:choose>
4136
4222
  </xsl:template><xsl:template name="table_fn_display">
4137
4223
  <xsl:variable name="references">
4138
4224
 
@@ -4309,7 +4395,7 @@
4309
4395
  </fo:inline>
4310
4396
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
4311
4397
  <fo:inline><xsl:value-of select="."/></fo:inline>
4312
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
4398
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
4313
4399
  <fo:inline>
4314
4400
  <xsl:apply-templates/>
4315
4401
  </fo:inline>
@@ -5305,6 +5391,9 @@
5305
5391
  </fo:inline>
5306
5392
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
5307
5393
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5394
+ <xsl:if test="parent::*[local-name() = 'add']">
5395
+ <xsl:call-template name="append_add-style"/>
5396
+ </xsl:if>
5308
5397
  <xsl:apply-templates/>
5309
5398
  </fo:basic-link>
5310
5399
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -5402,6 +5491,13 @@
5402
5491
 
5403
5492
 
5404
5493
 
5494
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5495
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
5496
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
5497
+ <xsl:call-template name="append_add-style"/>
5498
+ </xsl:if>
5499
+
5500
+
5405
5501
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
5406
5502
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
5407
5503
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -5440,6 +5536,12 @@
5440
5536
 
5441
5537
 
5442
5538
 
5539
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5540
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
5541
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
5542
+ <xsl:call-template name="append_add-style"/>
5543
+ </xsl:if>
5544
+
5443
5545
  <xsl:apply-templates select="*[local-name() = 'name']"/>
5444
5546
 
5445
5547
  </fo:inline>
@@ -5491,6 +5593,7 @@
5491
5593
  </fo:block>
5492
5594
  </xsl:template><xsl:template match="*[local-name() = 'term']">
5493
5595
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
5596
+
5494
5597
 
5495
5598
 
5496
5599
 
@@ -5927,7 +6030,11 @@
5927
6030
  <xsl:value-of select="."/>
5928
6031
  </xsl:template><xsl:template match="node()" mode="contents">
5929
6032
  <xsl:apply-templates mode="contents"/>
5930
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
6033
+ </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">
6034
+ <xsl:call-template name="contents_section-title"/>
6035
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
6036
+ <xsl:call-template name="contents_section-title"/>
6037
+ </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">
5931
6038
  <xsl:variable name="level">
5932
6039
  <xsl:call-template name="getLevel">
5933
6040
  <xsl:with-param name="depth" select="@depth"/>
@@ -5996,13 +6103,14 @@
5996
6103
  <xsl:apply-templates mode="bookmarks"/>
5997
6104
  </xsl:template><xsl:template name="addBookmarks">
5998
6105
  <xsl:param name="contents"/>
5999
- <xsl:if test="xalan:nodeset($contents)//item">
6106
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6107
+ <xsl:if test="$contents_nodes//item">
6000
6108
  <fo:bookmark-tree>
6001
6109
  <xsl:choose>
6002
- <xsl:when test="xalan:nodeset($contents)/doc">
6110
+ <xsl:when test="$contents_nodes/doc">
6003
6111
  <xsl:choose>
6004
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
6005
- <xsl:for-each select="xalan:nodeset($contents)/doc">
6112
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
6113
+ <xsl:for-each select="$contents_nodes/doc">
6006
6114
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6007
6115
  <xsl:if test="@bundle = 'true'">
6008
6116
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -6053,7 +6161,7 @@
6053
6161
  </xsl:for-each>
6054
6162
  </xsl:when>
6055
6163
  <xsl:otherwise>
6056
- <xsl:for-each select="xalan:nodeset($contents)/doc">
6164
+ <xsl:for-each select="$contents_nodes/doc">
6057
6165
 
6058
6166
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
6059
6167
 
@@ -6071,25 +6179,36 @@
6071
6179
  </xsl:choose>
6072
6180
  </xsl:when>
6073
6181
  <xsl:otherwise>
6074
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
6182
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
6183
+
6184
+ <xsl:call-template name="insertFigureBookmarks">
6185
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6186
+ </xsl:call-template>
6187
+
6188
+ <xsl:call-template name="insertTableBookmarks">
6189
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6190
+ <xsl:with-param name="lang" select="@lang"/>
6191
+ </xsl:call-template>
6192
+
6075
6193
  </xsl:otherwise>
6076
6194
  </xsl:choose>
6077
6195
 
6196
+
6078
6197
 
6079
6198
 
6080
6199
 
6081
6200
 
6082
-
6083
-
6201
+
6084
6202
 
6085
6203
  </fo:bookmark-tree>
6086
6204
  </xsl:if>
6087
6205
  </xsl:template><xsl:template name="insertFigureBookmarks">
6088
6206
  <xsl:param name="contents"/>
6089
- <xsl:if test="xalan:nodeset($contents)/figure">
6090
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
6207
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6208
+ <xsl:if test="$contents_nodes/figure">
6209
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
6091
6210
  <fo:bookmark-title>Figures</fo:bookmark-title>
6092
- <xsl:for-each select="xalan:nodeset($contents)/figure">
6211
+ <xsl:for-each select="$contents_nodes/figure">
6093
6212
  <fo:bookmark internal-destination="{@id}">
6094
6213
  <fo:bookmark-title>
6095
6214
  <xsl:value-of select="normalize-space(title)"/>
@@ -6098,18 +6217,42 @@
6098
6217
  </xsl:for-each>
6099
6218
  </fo:bookmark>
6100
6219
  </xsl:if>
6220
+
6221
+
6222
+ <xsl:if test="$contents_nodes//figures/figure">
6223
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6224
+
6225
+
6226
+ <xsl:attribute name="internal-destination">
6227
+ <xsl:value-of select="$contents_nodes//figures/figure[1]/@id"/>
6228
+ </xsl:attribute>
6229
+
6230
+
6231
+ <xsl:variable name="bookmark-title">
6232
+ Figures
6233
+ </xsl:variable>
6234
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
6235
+ <xsl:for-each select="$contents_nodes//figures/figure">
6236
+ <fo:bookmark internal-destination="{@id}">
6237
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6238
+ </fo:bookmark>
6239
+ </xsl:for-each>
6240
+ </fo:bookmark>
6241
+ </xsl:if>
6242
+
6101
6243
  </xsl:template><xsl:template name="insertTableBookmarks">
6102
6244
  <xsl:param name="contents"/>
6103
6245
  <xsl:param name="lang"/>
6104
- <xsl:if test="xalan:nodeset($contents)/table">
6105
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
6246
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6247
+ <xsl:if test="$contents_nodes/table">
6248
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
6106
6249
  <fo:bookmark-title>
6107
6250
  <xsl:choose>
6108
6251
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
6109
6252
  <xsl:otherwise>Tables</xsl:otherwise>
6110
6253
  </xsl:choose>
6111
6254
  </fo:bookmark-title>
6112
- <xsl:for-each select="xalan:nodeset($contents)/table">
6255
+ <xsl:for-each select="$contents_nodes/table">
6113
6256
  <fo:bookmark internal-destination="{@id}">
6114
6257
  <fo:bookmark-title>
6115
6258
  <xsl:value-of select="normalize-space(title)"/>
@@ -6118,6 +6261,36 @@
6118
6261
  </xsl:for-each>
6119
6262
  </fo:bookmark>
6120
6263
  </xsl:if>
6264
+
6265
+
6266
+ <xsl:if test="$contents_nodes//tables/table">
6267
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6268
+
6269
+
6270
+ <xsl:attribute name="internal-destination">
6271
+ <xsl:value-of select="$contents_nodes//tables/table[1]/@id"/>
6272
+ </xsl:attribute>
6273
+
6274
+
6275
+ <xsl:variable name="bookmark-title">
6276
+
6277
+ <xsl:choose>
6278
+ <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
6279
+ <xsl:otherwise>Tables</xsl:otherwise>
6280
+ </xsl:choose>
6281
+
6282
+ </xsl:variable>
6283
+
6284
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
6285
+
6286
+ <xsl:for-each select="$contents_nodes//tables/table">
6287
+ <fo:bookmark internal-destination="{@id}">
6288
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6289
+ </fo:bookmark>
6290
+ </xsl:for-each>
6291
+ </fo:bookmark>
6292
+ </xsl:if>
6293
+
6121
6294
  </xsl:template><xsl:template name="getLangVersion">
6122
6295
  <xsl:param name="lang"/>
6123
6296
  <xsl:param name="doctype" select="''"/>
@@ -6342,7 +6515,51 @@
6342
6515
  <xsl:with-param name="text" select="$text_step1"/>
6343
6516
  </xsl:call-template>
6344
6517
  </xsl:variable>
6345
- <xsl:value-of select="$text_step2"/>
6518
+
6519
+ <!-- <xsl:value-of select="$text_step2"/> -->
6520
+
6521
+ <!-- add zero-width space after space -->
6522
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
6523
+
6524
+ <!-- split text by zero-width space -->
6525
+ <xsl:variable name="text_step4">
6526
+ <xsl:call-template name="split">
6527
+ <xsl:with-param name="pText" select="$text_step3"/>
6528
+ <xsl:with-param name="sep" select="$zero_width_space"/>
6529
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
6530
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
6531
+ </xsl:call-template>
6532
+ </xsl:variable>
6533
+
6534
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
6535
+ <xsl:choose>
6536
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6537
+ <xsl:call-template name="interspers">
6538
+ <xsl:with-param name="str" select="."/>
6539
+ </xsl:call-template>
6540
+ </xsl:when>
6541
+ <xsl:otherwise>
6542
+ <xsl:value-of select="."/>
6543
+ </xsl:otherwise>
6544
+ </xsl:choose>
6545
+ </xsl:for-each>
6546
+
6547
+ </xsl:template><xsl:template name="interspers">
6548
+ <xsl:param name="str"/>
6549
+ <xsl:param name="char" select="$zero_width_space"/>
6550
+ <xsl:if test="$str != ''">
6551
+ <xsl:value-of select="substring($str, 1, 1)"/>
6552
+
6553
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
6554
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
6555
+ <xsl:value-of select="$char"/>
6556
+ </xsl:if>
6557
+
6558
+ <xsl:call-template name="interspers">
6559
+ <xsl:with-param name="str" select="substring($str, 2)"/>
6560
+ <xsl:with-param name="char" select="$char"/>
6561
+ </xsl:call-template>
6562
+ </xsl:if>
6346
6563
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6347
6564
  <xsl:apply-templates mode="syntax_highlight"/>
6348
6565
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6780,6 +6997,8 @@
6780
6997
  </xsl:otherwise>
6781
6998
  </xsl:choose> -->
6782
6999
  </fo:block>
7000
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
7001
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6783
7002
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6784
7003
  <xsl:if test="normalize-space() != ''">
6785
7004
  <xsl:value-of select="."/>
@@ -6854,26 +7073,24 @@
6854
7073
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6855
7074
  <xsl:text>— </xsl:text>
6856
7075
  <xsl:apply-templates/>
6857
- </xsl:template><xsl:variable name="bibitem_hidden_">
7076
+ </xsl:template><xsl:variable name="bibitems_">
7077
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
7078
+ <xsl:copy-of select="."/>
7079
+ </xsl:for-each>
7080
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
6858
7081
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6859
7082
  <xsl:copy-of select="."/>
6860
7083
  </xsl:for-each>
6861
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
7084
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
6862
7085
  <xsl:copy-of select="."/>
6863
7086
  </xsl:for-each>
6864
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6865
-
6866
- <xsl:variable name="bibitemid">
6867
- <xsl:choose>
6868
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6869
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6870
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6871
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6872
- </xsl:choose>
6873
- </xsl:variable>
6874
-
7087
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
7088
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
7089
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
7090
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
6875
7091
  <xsl:choose>
6876
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
7092
+ <!-- <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) -->
7093
+ <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) -->
6877
7094
  <fo:inline xsl:use-attribute-sets="eref-style">
6878
7095
  <xsl:if test="@type = 'footnote'">
6879
7096
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6887,8 +7104,8 @@
6887
7104
  <xsl:variable name="text" select="normalize-space()"/>
6888
7105
 
6889
7106
 
6890
-
6891
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
7107
+
7108
+ <fo:basic-link fox:alt-text="{@citeas}">
6892
7109
  <xsl:if test="normalize-space(@citeas) = ''">
6893
7110
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6894
7111
  </xsl:if>
@@ -6898,14 +7115,21 @@
6898
7115
 
6899
7116
  </xsl:if>
6900
7117
 
6901
-
7118
+ <xsl:choose>
7119
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
7120
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
7121
+ </xsl:when>
7122
+ <xsl:otherwise>
7123
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
7124
+ </xsl:otherwise>
7125
+ </xsl:choose>
6902
7126
 
6903
7127
  <xsl:apply-templates/>
6904
7128
  </fo:basic-link>
6905
-
7129
+
6906
7130
  </fo:inline>
6907
7131
  </xsl:when>
6908
- <xsl:otherwise>
7132
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6909
7133
  <fo:inline><xsl:apply-templates/></fo:inline>
6910
7134
  </xsl:otherwise>
6911
7135
  </xsl:choose>
@@ -7249,7 +7473,7 @@
7249
7473
 
7250
7474
 
7251
7475
 
7252
-
7476
+
7253
7477
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7254
7478
  </fo:list-block>
7255
7479
  <!-- <xsl:for-each select="./iho:note">
@@ -7267,6 +7491,11 @@
7267
7491
 
7268
7492
 
7269
7493
 
7494
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7495
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
7496
+ <xsl:call-template name="append_add-style"/>
7497
+ </xsl:if>
7498
+
7270
7499
  <xsl:call-template name="getListItemFormat"/>
7271
7500
  </fo:block>
7272
7501
  </fo:list-item-label>
@@ -7641,23 +7870,45 @@
7641
7870
  <xsl:apply-templates/>
7642
7871
  </fo:inline>
7643
7872
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7873
+
7874
+ <!-- list of footnotes to calculate actual footnotes number -->
7875
+ <xsl:variable name="p_fn_">
7876
+ <xsl:call-template name="get_fn_list"/>
7877
+ </xsl:variable>
7878
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7879
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7880
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7881
+ <!-- fn sequence number in document -->
7882
+ <xsl:variable name="current_fn_number">
7883
+ <xsl:choose>
7884
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7885
+ <xsl:otherwise>
7886
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7887
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7888
+ </xsl:otherwise>
7889
+ </xsl:choose>
7890
+ </xsl:variable>
7644
7891
  <fo:footnote>
7645
7892
  <xsl:variable name="number">
7646
7893
 
7647
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7894
+ <xsl:value-of select="$current_fn_number"/>
7648
7895
 
7649
7896
  </xsl:variable>
7897
+
7898
+ <xsl:variable name="current_fn_number_text">
7899
+ <xsl:value-of select="$number"/>
7900
+
7901
+ </xsl:variable>
7902
+
7650
7903
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7651
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
7652
- <xsl:value-of select="$number"/>
7653
-
7904
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7905
+ <xsl:value-of select="$current_fn_number_text"/>
7654
7906
  </fo:basic-link>
7655
7907
  </fo:inline>
7656
7908
  <fo:footnote-body>
7657
7909
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
7658
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7659
- <xsl:value-of select="$number"/>
7660
-
7910
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7911
+ <xsl:value-of select="$current_fn_number_text"/>
7661
7912
  </fo:inline>
7662
7913
  <xsl:apply-templates/>
7663
7914
  </fo:block>
@@ -7899,6 +8150,78 @@
7899
8150
  <!-- processing for admonition/p found in the template for 'p' -->
7900
8151
  <xsl:call-template name="paragraph"/>
7901
8152
 
8153
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
8154
+ <xsl:copy>
8155
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
8156
+ </xsl:copy>
8157
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
8158
+ <xsl:copy>
8159
+ <xsl:copy-of select="@*"/>
8160
+
8161
+ <xsl:variable name="nodes_preface_">
8162
+ <xsl:for-each select="*">
8163
+ <node id="{@id}"/>
8164
+ </xsl:for-each>
8165
+ </xsl:variable>
8166
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
8167
+
8168
+ <xsl:for-each select="*">
8169
+ <xsl:sort select="@displayorder" data-type="number"/>
8170
+
8171
+ <!-- process Section's title -->
8172
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8173
+ <xsl:if test="$preceding-sibling_id != ''">
8174
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8175
+ </xsl:if>
8176
+
8177
+ <xsl:choose>
8178
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8179
+ <xsl:otherwise>
8180
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8181
+ </xsl:otherwise>
8182
+ </xsl:choose>
8183
+
8184
+ </xsl:for-each>
8185
+ </xsl:copy>
8186
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
8187
+ <xsl:copy>
8188
+ <xsl:copy-of select="@*"/>
8189
+
8190
+ <xsl:variable name="nodes_sections_">
8191
+ <xsl:for-each select="*">
8192
+ <node id="{@id}"/>
8193
+ </xsl:for-each>
8194
+ </xsl:variable>
8195
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
8196
+
8197
+ <!-- move section 'Normative references' inside 'sections' -->
8198
+ <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']]">
8199
+ <xsl:sort select="@displayorder" data-type="number"/>
8200
+
8201
+ <!-- process Section's title -->
8202
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8203
+ <xsl:if test="$preceding-sibling_id != ''">
8204
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8205
+ </xsl:if>
8206
+
8207
+ <xsl:choose>
8208
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8209
+ <xsl:otherwise>
8210
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8211
+ </xsl:otherwise>
8212
+ </xsl:choose>
8213
+
8214
+ </xsl:for-each>
8215
+ </xsl:copy>
8216
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
8217
+ <xsl:copy>
8218
+ <xsl:copy-of select="@*"/>
8219
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
8220
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
8221
+ <xsl:sort select="@displayorder" data-type="number"/>
8222
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8223
+ </xsl:for-each>
8224
+ </xsl:copy>
7902
8225
  </xsl:template><xsl:template name="convertDate">
7903
8226
  <xsl:param name="date"/>
7904
8227
  <xsl:param name="format" select="'short'"/>
@@ -8143,22 +8466,25 @@
8143
8466
  <xsl:param name="pText" select="."/>
8144
8467
  <xsl:param name="sep" select="','"/>
8145
8468
  <xsl:param name="normalize-space" select="'true'"/>
8469
+ <xsl:param name="keep_sep" select="'false'"/>
8146
8470
  <xsl:if test="string-length($pText) &gt;0">
8147
- <item>
8148
- <xsl:choose>
8149
- <xsl:when test="$normalize-space = 'true'">
8150
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8151
- </xsl:when>
8152
- <xsl:otherwise>
8153
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8154
- </xsl:otherwise>
8155
- </xsl:choose>
8156
- </item>
8157
- <xsl:call-template name="split">
8158
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8159
- <xsl:with-param name="sep" select="$sep"/>
8160
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
8161
- </xsl:call-template>
8471
+ <item>
8472
+ <xsl:choose>
8473
+ <xsl:when test="$normalize-space = 'true'">
8474
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8475
+ </xsl:when>
8476
+ <xsl:otherwise>
8477
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8478
+ </xsl:otherwise>
8479
+ </xsl:choose>
8480
+ </item>
8481
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
8482
+ <xsl:call-template name="split">
8483
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8484
+ <xsl:with-param name="sep" select="$sep"/>
8485
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
8486
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
8487
+ </xsl:call-template>
8162
8488
  </xsl:if>
8163
8489
  </xsl:template><xsl:template name="getDocumentId">
8164
8490
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -8349,53 +8675,153 @@
8349
8675
  <xsl:param name="first"/>
8350
8676
  <xsl:if test="$number != ''">
8351
8677
  <xsl:variable name="words">
8352
- <words>
8353
- <word cardinal="1">One-</word>
8354
- <word ordinal="1">First </word>
8355
- <word cardinal="2">Two-</word>
8356
- <word ordinal="2">Second </word>
8357
- <word cardinal="3">Three-</word>
8358
- <word ordinal="3">Third </word>
8359
- <word cardinal="4">Four-</word>
8360
- <word ordinal="4">Fourth </word>
8361
- <word cardinal="5">Five-</word>
8362
- <word ordinal="5">Fifth </word>
8363
- <word cardinal="6">Six-</word>
8364
- <word ordinal="6">Sixth </word>
8365
- <word cardinal="7">Seven-</word>
8366
- <word ordinal="7">Seventh </word>
8367
- <word cardinal="8">Eight-</word>
8368
- <word ordinal="8">Eighth </word>
8369
- <word cardinal="9">Nine-</word>
8370
- <word ordinal="9">Ninth </word>
8371
- <word ordinal="10">Tenth </word>
8372
- <word ordinal="11">Eleventh </word>
8373
- <word ordinal="12">Twelfth </word>
8374
- <word ordinal="13">Thirteenth </word>
8375
- <word ordinal="14">Fourteenth </word>
8376
- <word ordinal="15">Fifteenth </word>
8377
- <word ordinal="16">Sixteenth </word>
8378
- <word ordinal="17">Seventeenth </word>
8379
- <word ordinal="18">Eighteenth </word>
8380
- <word ordinal="19">Nineteenth </word>
8381
- <word cardinal="20">Twenty-</word>
8382
- <word ordinal="20">Twentieth </word>
8383
- <word cardinal="30">Thirty-</word>
8384
- <word ordinal="30">Thirtieth </word>
8385
- <word cardinal="40">Forty-</word>
8386
- <word ordinal="40">Fortieth </word>
8387
- <word cardinal="50">Fifty-</word>
8388
- <word ordinal="50">Fiftieth </word>
8389
- <word cardinal="60">Sixty-</word>
8390
- <word ordinal="60">Sixtieth </word>
8391
- <word cardinal="70">Seventy-</word>
8392
- <word ordinal="70">Seventieth </word>
8393
- <word cardinal="80">Eighty-</word>
8394
- <word ordinal="80">Eightieth </word>
8395
- <word cardinal="90">Ninety-</word>
8396
- <word ordinal="90">Ninetieth </word>
8397
- <word cardinal="100">Hundred-</word>
8398
- <word ordinal="100">Hundredth </word>
8678
+ <words>
8679
+ <xsl:choose>
8680
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
8681
+ <word cardinal="1">Une-</word>
8682
+ <word ordinal="1">Première </word>
8683
+ <word cardinal="2">Deux-</word>
8684
+ <word ordinal="2">Seconde </word>
8685
+ <word cardinal="3">Trois-</word>
8686
+ <word ordinal="3">Tierce </word>
8687
+ <word cardinal="4">Quatre-</word>
8688
+ <word ordinal="4">Quatrième </word>
8689
+ <word cardinal="5">Cinq-</word>
8690
+ <word ordinal="5">Cinquième </word>
8691
+ <word cardinal="6">Six-</word>
8692
+ <word ordinal="6">Sixième </word>
8693
+ <word cardinal="7">Sept-</word>
8694
+ <word ordinal="7">Septième </word>
8695
+ <word cardinal="8">Huit-</word>
8696
+ <word ordinal="8">Huitième </word>
8697
+ <word cardinal="9">Neuf-</word>
8698
+ <word ordinal="9">Neuvième </word>
8699
+ <word ordinal="10">Dixième </word>
8700
+ <word ordinal="11">Onzième </word>
8701
+ <word ordinal="12">Douzième </word>
8702
+ <word ordinal="13">Treizième </word>
8703
+ <word ordinal="14">Quatorzième </word>
8704
+ <word ordinal="15">Quinzième </word>
8705
+ <word ordinal="16">Seizième </word>
8706
+ <word ordinal="17">Dix-septième </word>
8707
+ <word ordinal="18">Dix-huitième </word>
8708
+ <word ordinal="19">Dix-neuvième </word>
8709
+ <word cardinal="20">Vingt-</word>
8710
+ <word ordinal="20">Vingtième </word>
8711
+ <word cardinal="30">Trente-</word>
8712
+ <word ordinal="30">Trentième </word>
8713
+ <word cardinal="40">Quarante-</word>
8714
+ <word ordinal="40">Quarantième </word>
8715
+ <word cardinal="50">Cinquante-</word>
8716
+ <word ordinal="50">Cinquantième </word>
8717
+ <word cardinal="60">Soixante-</word>
8718
+ <word ordinal="60">Soixantième </word>
8719
+ <word cardinal="70">Septante-</word>
8720
+ <word ordinal="70">Septantième </word>
8721
+ <word cardinal="80">Huitante-</word>
8722
+ <word ordinal="80">Huitantième </word>
8723
+ <word cardinal="90">Nonante-</word>
8724
+ <word ordinal="90">Nonantième </word>
8725
+ <word cardinal="100">Cent-</word>
8726
+ <word ordinal="100">Centième </word>
8727
+ </xsl:when>
8728
+ <xsl:when test="$lang = 'ru'">
8729
+ <word cardinal="1">Одна-</word>
8730
+ <word ordinal="1">Первое </word>
8731
+ <word cardinal="2">Две-</word>
8732
+ <word ordinal="2">Второе </word>
8733
+ <word cardinal="3">Три-</word>
8734
+ <word ordinal="3">Третье </word>
8735
+ <word cardinal="4">Четыре-</word>
8736
+ <word ordinal="4">Четвертое </word>
8737
+ <word cardinal="5">Пять-</word>
8738
+ <word ordinal="5">Пятое </word>
8739
+ <word cardinal="6">Шесть-</word>
8740
+ <word ordinal="6">Шестое </word>
8741
+ <word cardinal="7">Семь-</word>
8742
+ <word ordinal="7">Седьмое </word>
8743
+ <word cardinal="8">Восемь-</word>
8744
+ <word ordinal="8">Восьмое </word>
8745
+ <word cardinal="9">Девять-</word>
8746
+ <word ordinal="9">Девятое </word>
8747
+ <word ordinal="10">Десятое </word>
8748
+ <word ordinal="11">Одиннадцатое </word>
8749
+ <word ordinal="12">Двенадцатое </word>
8750
+ <word ordinal="13">Тринадцатое </word>
8751
+ <word ordinal="14">Четырнадцатое </word>
8752
+ <word ordinal="15">Пятнадцатое </word>
8753
+ <word ordinal="16">Шестнадцатое </word>
8754
+ <word ordinal="17">Семнадцатое </word>
8755
+ <word ordinal="18">Восемнадцатое </word>
8756
+ <word ordinal="19">Девятнадцатое </word>
8757
+ <word cardinal="20">Двадцать-</word>
8758
+ <word ordinal="20">Двадцатое </word>
8759
+ <word cardinal="30">Тридцать-</word>
8760
+ <word ordinal="30">Тридцатое </word>
8761
+ <word cardinal="40">Сорок-</word>
8762
+ <word ordinal="40">Сороковое </word>
8763
+ <word cardinal="50">Пятьдесят-</word>
8764
+ <word ordinal="50">Пятидесятое </word>
8765
+ <word cardinal="60">Шестьдесят-</word>
8766
+ <word ordinal="60">Шестидесятое </word>
8767
+ <word cardinal="70">Семьдесят-</word>
8768
+ <word ordinal="70">Семидесятое </word>
8769
+ <word cardinal="80">Восемьдесят-</word>
8770
+ <word ordinal="80">Восьмидесятое </word>
8771
+ <word cardinal="90">Девяносто-</word>
8772
+ <word ordinal="90">Девяностое </word>
8773
+ <word cardinal="100">Сто-</word>
8774
+ <word ordinal="100">Сотое </word>
8775
+ </xsl:when>
8776
+ <xsl:otherwise> <!-- default english -->
8777
+ <word cardinal="1">One-</word>
8778
+ <word ordinal="1">First </word>
8779
+ <word cardinal="2">Two-</word>
8780
+ <word ordinal="2">Second </word>
8781
+ <word cardinal="3">Three-</word>
8782
+ <word ordinal="3">Third </word>
8783
+ <word cardinal="4">Four-</word>
8784
+ <word ordinal="4">Fourth </word>
8785
+ <word cardinal="5">Five-</word>
8786
+ <word ordinal="5">Fifth </word>
8787
+ <word cardinal="6">Six-</word>
8788
+ <word ordinal="6">Sixth </word>
8789
+ <word cardinal="7">Seven-</word>
8790
+ <word ordinal="7">Seventh </word>
8791
+ <word cardinal="8">Eight-</word>
8792
+ <word ordinal="8">Eighth </word>
8793
+ <word cardinal="9">Nine-</word>
8794
+ <word ordinal="9">Ninth </word>
8795
+ <word ordinal="10">Tenth </word>
8796
+ <word ordinal="11">Eleventh </word>
8797
+ <word ordinal="12">Twelfth </word>
8798
+ <word ordinal="13">Thirteenth </word>
8799
+ <word ordinal="14">Fourteenth </word>
8800
+ <word ordinal="15">Fifteenth </word>
8801
+ <word ordinal="16">Sixteenth </word>
8802
+ <word ordinal="17">Seventeenth </word>
8803
+ <word ordinal="18">Eighteenth </word>
8804
+ <word ordinal="19">Nineteenth </word>
8805
+ <word cardinal="20">Twenty-</word>
8806
+ <word ordinal="20">Twentieth </word>
8807
+ <word cardinal="30">Thirty-</word>
8808
+ <word ordinal="30">Thirtieth </word>
8809
+ <word cardinal="40">Forty-</word>
8810
+ <word ordinal="40">Fortieth </word>
8811
+ <word cardinal="50">Fifty-</word>
8812
+ <word ordinal="50">Fiftieth </word>
8813
+ <word cardinal="60">Sixty-</word>
8814
+ <word ordinal="60">Sixtieth </word>
8815
+ <word cardinal="70">Seventy-</word>
8816
+ <word ordinal="70">Seventieth </word>
8817
+ <word cardinal="80">Eighty-</word>
8818
+ <word ordinal="80">Eightieth </word>
8819
+ <word cardinal="90">Ninety-</word>
8820
+ <word ordinal="90">Ninetieth </word>
8821
+ <word cardinal="100">Hundred-</word>
8822
+ <word ordinal="100">Hundredth </word>
8823
+ </xsl:otherwise>
8824
+ </xsl:choose>
8399
8825
  </words>
8400
8826
  </xsl:variable>
8401
8827
 
@@ -8469,4 +8895,18 @@
8469
8895
  <xsl:otherwise>_</xsl:otherwise>
8470
8896
  </xsl:choose>
8471
8897
  </xsl:attribute>
8898
+ </xsl:template><xsl:template name="substring-after-last">
8899
+ <xsl:param name="value"/>
8900
+ <xsl:param name="delimiter"/>
8901
+ <xsl:choose>
8902
+ <xsl:when test="contains($value, $delimiter)">
8903
+ <xsl:call-template name="substring-after-last">
8904
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
8905
+ <xsl:with-param name="delimiter" select="$delimiter"/>
8906
+ </xsl:call-template>
8907
+ </xsl:when>
8908
+ <xsl:otherwise>
8909
+ <xsl:value-of select="$value"/>
8910
+ </xsl:otherwise>
8911
+ </xsl:choose>
8472
8912
  </xsl:template></xsl:stylesheet>