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.
@@ -28,7 +28,7 @@
28
28
 
29
29
  <xsl:variable name="root-element" select="local-name(/*)"/>
30
30
 
31
- <xsl:variable name="contents">
31
+ <xsl:variable name="contents_">
32
32
  <xsl:choose>
33
33
  <xsl:when test="$root-element = 'metanorma-collection'">
34
34
  <xsl:choose>
@@ -80,6 +80,7 @@
80
80
  </xsl:otherwise>
81
81
  </xsl:choose>
82
82
  </xsl:variable>
83
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
83
84
 
84
85
  <xsl:variable name="indexes">
85
86
  <xsl:choose>
@@ -180,6 +181,8 @@
180
181
  <!-- Index -->
181
182
  <xsl:apply-templates select="//bipm:indexsect" mode="contents"/>
182
183
 
184
+ <xsl:call-template name="processTablesFigures_Contents"/>
185
+
183
186
  </contents>
184
187
  </xsl:template>
185
188
 
@@ -923,7 +926,7 @@
923
926
  <xsl:if test="$debug = 'true'">
924
927
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
925
928
  DEBUG
926
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
929
+ contents=<xsl:copy-of select="$contents"/>
927
930
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
928
931
  </xsl:if>
929
932
 
@@ -1078,12 +1081,12 @@
1078
1081
  <fo:block role="TOC">
1079
1082
  <!-- <xsl:copy-of select="$contents"/> -->
1080
1083
 
1081
- <xsl:if test="xalan:nodeset($contents)/doc[@id = $docid]//item[@display='true']">
1084
+ <xsl:if test="$contents/doc[@id = $docid]//item[@display='true']">
1082
1085
  <fo:table table-layout="fixed" width="100%">
1083
1086
  <fo:table-column column-width="127mm"/>
1084
1087
  <fo:table-column column-width="12mm"/>
1085
1088
  <fo:table-body>
1086
- <xsl:for-each select="xalan:nodeset($contents)/doc[@id = $docid]//item[@display='true' and not(@type = 'annex') and not(@type = 'index') and not(@parent = 'annex')]">
1089
+ <xsl:for-each select="$contents/doc[@id = $docid]//item[@display='true' and not(@type = 'annex') and not(@type = 'index') and not(@parent = 'annex')]">
1087
1090
  <xsl:call-template name="insertContentItem"/>
1088
1091
  </xsl:for-each>
1089
1092
  <xsl:if test="$doctype ='brochure'">
@@ -1094,12 +1097,33 @@
1094
1097
  </fo:table-cell>
1095
1098
  </fo:table-row>
1096
1099
  </xsl:if>
1097
- <xsl:for-each select="xalan:nodeset($contents)/doc[@id = $docid]//item[@display='true' and (@type = 'annex')]"> <!-- or (@level = 2 and @parent = 'annex') -->
1100
+ <xsl:for-each select="$contents/doc[@id = $docid]//item[@display='true' and (@type = 'annex')]"> <!-- or (@level = 2 and @parent = 'annex') -->
1098
1101
  <xsl:call-template name="insertContentItem"/>
1099
1102
  </xsl:for-each>
1100
- <xsl:for-each select="xalan:nodeset($contents)/doc[@id = $docid]//item[@display='true' and (@type = 'index')]">
1103
+ <xsl:for-each select="$contents/doc[@id = $docid]//item[@display='true' and (@type = 'index')]">
1101
1104
  <xsl:call-template name="insertContentItem"/>
1102
1105
  </xsl:for-each>
1106
+
1107
+ <!-- List of Tables -->
1108
+ <xsl:if test="$contents/doc[@id = $docid]//tables/table">
1109
+ <xsl:call-template name="insertListOf_Title">
1110
+ <xsl:with-param name="title" select="$title-list-tables"/>
1111
+ </xsl:call-template>
1112
+ <xsl:for-each select="$contents/doc[@id = $docid]//tables/table">
1113
+ <xsl:call-template name="insertListOf_Item"/>
1114
+ </xsl:for-each>
1115
+ </xsl:if>
1116
+
1117
+ <!-- List of Figures -->
1118
+ <xsl:if test="$contents/doc[@id = $docid]//figures/figure">
1119
+ <xsl:call-template name="insertListOf_Title">
1120
+ <xsl:with-param name="title" select="$title-list-figures"/>
1121
+ </xsl:call-template>
1122
+ <xsl:for-each select="$contents/doc[@id = $docid]//figures/figure">
1123
+ <xsl:call-template name="insertListOf_Item"/>
1124
+ </xsl:for-each>
1125
+ </xsl:if>
1126
+
1103
1127
  </fo:table-body>
1104
1128
  </fo:table>
1105
1129
  </xsl:if>
@@ -1861,6 +1885,57 @@
1861
1885
  </fo:table-row>
1862
1886
  </xsl:template>
1863
1887
 
1888
+ <xsl:template name="insertListOf_Title">
1889
+ <xsl:param name="title"/>
1890
+ <fo:table-row keep-with-next="always">
1891
+ <fo:table-cell font-family="Arial" font-weight="bold" font-size="10pt" padding-top="14pt" padding-bottom="6pt">
1892
+ <fo:block role="TOCI">
1893
+ <xsl:value-of select="$title"/>
1894
+ </fo:block>
1895
+ </fo:table-cell>
1896
+ <fo:table-cell>
1897
+ <fo:block/>
1898
+ </fo:table-cell>
1899
+ </fo:table-row>
1900
+ </xsl:template>
1901
+
1902
+ <xsl:template name="insertListOf_Item">
1903
+ <fo:table-row>
1904
+ <fo:table-cell>
1905
+ <fo:block role="TOCI" font-size="10.5pt" margin-left="8mm">
1906
+ <fo:list-block provisional-distance-between-starts="8mm">
1907
+ <fo:list-item>
1908
+ <fo:list-item-label end-indent="label-end()">
1909
+ <fo:block/>
1910
+ </fo:list-item-label>
1911
+ <fo:list-item-body start-indent="body-start()">
1912
+ <fo:block>
1913
+ <fo:basic-link internal-destination="{@id}">
1914
+ <xsl:call-template name="setAltText">
1915
+ <xsl:with-param name="value" select="@alt-text"/>
1916
+ </xsl:call-template>
1917
+ <fo:inline>
1918
+ <xsl:apply-templates select="." mode="contents"/>
1919
+ </fo:inline>
1920
+ </fo:basic-link>
1921
+ </fo:block>
1922
+ </fo:list-item-body>
1923
+ </fo:list-item>
1924
+ </fo:list-block>
1925
+ </fo:block>
1926
+ </fo:table-cell>
1927
+ <fo:table-cell text-align="right" font-family="Arial" font-weight="bold" font-size="10pt">
1928
+ <fo:block>
1929
+ <fo:basic-link internal-destination="{@id}">
1930
+ <xsl:call-template name="setAltText">
1931
+ <xsl:with-param name="value" select="@alt-text"/>
1932
+ </xsl:call-template>
1933
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
1934
+ </fo:basic-link>
1935
+ </fo:block>
1936
+ </fo:table-cell>
1937
+ </fo:table-row>
1938
+ </xsl:template>
1864
1939
 
1865
1940
  <xsl:template match="node()">
1866
1941
  <xsl:apply-templates/>
@@ -3867,6 +3942,10 @@
3867
3942
  <xsl:text>Édition </xsl:text>
3868
3943
  </title-edition>
3869
3944
 
3945
+ <title-edition lang="ru">
3946
+ <xsl:text>Издание </xsl:text>
3947
+ </title-edition>
3948
+
3870
3949
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
3871
3950
  <title-toc lang="en">
3872
3951
 
@@ -3881,7 +3960,7 @@
3881
3960
  <xsl:text>Contents</xsl:text>
3882
3961
 
3883
3962
  </title-toc>
3884
-
3963
+
3885
3964
  <title-descriptors lang="en">Descriptors</title-descriptors>
3886
3965
 
3887
3966
  <title-part lang="en">
@@ -3897,7 +3976,11 @@
3897
3976
 
3898
3977
  <xsl:text>Partie #</xsl:text>
3899
3978
 
3900
- </title-part>
3979
+ </title-part>
3980
+ <title-part lang="ru">
3981
+
3982
+
3983
+ </title-part>
3901
3984
  <title-part lang="zh">第 # 部分:</title-part>
3902
3985
 
3903
3986
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -3913,10 +3996,35 @@
3913
3996
 
3914
3997
  <title-summary lang="en">Summary</title-summary>
3915
3998
 
3999
+ <title-continued lang="ru">(продолжение)</title-continued>
3916
4000
  <title-continued lang="en">(continued)</title-continued>
3917
4001
  <title-continued lang="fr">(continué)</title-continued>
3918
4002
 
3919
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
4003
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
4004
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
4005
+ <xsl:value-of select="$toc_table_title"/>
4006
+ <xsl:if test="normalize-space($toc_table_title) = ''">
4007
+ <xsl:call-template name="getTitle">
4008
+ <xsl:with-param name="name" select="'title-list-tables'"/>
4009
+ </xsl:call-template>
4010
+ </xsl:if>
4011
+ </xsl:variable><xsl:variable name="title-list-figures">
4012
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
4013
+ <xsl:value-of select="$toc_figure_title"/>
4014
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
4015
+ <xsl:call-template name="getTitle">
4016
+ <xsl:with-param name="name" select="'title-list-figures'"/>
4017
+ </xsl:call-template>
4018
+ </xsl:if>
4019
+ </xsl:variable><xsl:variable name="title-list-recommendations">
4020
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
4021
+ <xsl:value-of select="$toc_requirement_title"/>
4022
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
4023
+ <xsl:call-template name="getTitle">
4024
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
4025
+ </xsl:call-template>
4026
+ </xsl:if>
4027
+ </xsl:variable><xsl:variable name="bibdata">
3920
4028
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
3921
4029
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
3922
4030
  </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">
@@ -4643,13 +4751,19 @@
4643
4751
  </xsl:attribute-set><xsl:variable name="color-added-text">
4644
4752
  <xsl:text>rgb(0, 255, 0)</xsl:text>
4645
4753
  </xsl:variable><xsl:attribute-set name="add-style">
4646
- <xsl:attribute name="color">red</xsl:attribute>
4647
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
4648
- <!-- <xsl:attribute name="color">black</xsl:attribute>
4649
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
4650
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
4651
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
4652
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
4754
+
4755
+ <xsl:attribute name="color">red</xsl:attribute>
4756
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
4757
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
4758
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
4759
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
4760
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
4761
+
4762
+ </xsl:attribute-set><xsl:variable name="add-style">
4763
+ <add-style xsl:use-attribute-sets="add-style"/>
4764
+ </xsl:variable><xsl:template name="append_add-style">
4765
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
4766
+ </xsl:template><xsl:variable name="color-deleted-text">
4653
4767
  <xsl:text>red</xsl:text>
4654
4768
  </xsl:variable><xsl:attribute-set name="del-style">
4655
4769
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -5095,14 +5209,42 @@
5095
5209
 
5096
5210
 
5097
5211
  </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">
5212
+ <xsl:variable name="nodes_preface_">
5213
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
5214
+ <node id="{@id}"/>
5215
+ </xsl:for-each>
5216
+ </xsl:variable>
5217
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
5218
+
5098
5219
  <xsl:for-each select="/*/*[local-name()='preface']/*">
5099
5220
  <xsl:sort select="@displayorder" data-type="number"/>
5221
+
5222
+ <!-- process Section's title -->
5223
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
5224
+ <xsl:if test="$preceding-sibling_id != ''">
5225
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
5226
+ </xsl:if>
5227
+
5100
5228
  <xsl:apply-templates select="." mode="contents"/>
5101
5229
  </xsl:for-each>
5102
5230
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
5103
5231
 
5232
+ <xsl:variable name="nodes_sections_">
5233
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
5234
+ <node id="{@id}"/>
5235
+ </xsl:for-each>
5236
+ </xsl:variable>
5237
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
5238
+
5104
5239
  <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']]">
5105
5240
  <xsl:sort select="@displayorder" data-type="number"/>
5241
+
5242
+ <!-- process Section's title -->
5243
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
5244
+ <xsl:if test="$preceding-sibling_id != ''">
5245
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
5246
+ </xsl:if>
5247
+
5106
5248
  <xsl:apply-templates select="." mode="contents"/>
5107
5249
  </xsl:for-each>
5108
5250
 
@@ -5115,6 +5257,30 @@
5115
5257
  <xsl:sort select="@displayorder" data-type="number"/>
5116
5258
  <xsl:apply-templates select="." mode="contents"/>
5117
5259
  </xsl:for-each>
5260
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
5261
+ <xsl:param name="always"/>
5262
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
5263
+ <xsl:call-template name="processTables_Contents"/>
5264
+ </xsl:if>
5265
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
5266
+ <xsl:call-template name="processFigures_Contents"/>
5267
+ </xsl:if>
5268
+ </xsl:template><xsl:template name="processTables_Contents">
5269
+ <tables>
5270
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
5271
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
5272
+ <xsl:copy-of select="*[local-name() = 'name']"/>
5273
+ </table>
5274
+ </xsl:for-each>
5275
+ </tables>
5276
+ </xsl:template><xsl:template name="processFigures_Contents">
5277
+ <figures>
5278
+ <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) != '']">
5279
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
5280
+ <xsl:copy-of select="*[local-name() = 'name']"/>
5281
+ </figure>
5282
+ </xsl:for-each>
5283
+ </figures>
5118
5284
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
5119
5285
  <xsl:for-each select="/*/*[local-name()='preface']/*">
5120
5286
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -5251,7 +5417,7 @@
5251
5417
  </xsl:call-template>
5252
5418
  </xsl:if>
5253
5419
  </xsl:variable>
5254
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
5420
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
5255
5421
 
5256
5422
 
5257
5423
  <xsl:variable name="margin-side">
@@ -5533,7 +5699,7 @@
5533
5699
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
5534
5700
  <!-- 2009 thinspace -->
5535
5701
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
5536
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
5702
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
5537
5703
  </xsl:call-template>
5538
5704
  </xsl:variable>
5539
5705
  <xsl:variable name="max_length">
@@ -5980,37 +6146,7 @@
5980
6146
 
5981
6147
  <!-- list of footnotes to calculate actual footnotes number -->
5982
6148
  <xsl:variable name="p_fn_">
5983
- <xsl:choose>
5984
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
5985
- <fn gen_id="{generate-id(.)}">
5986
- <xsl:copy-of select="@*"/>
5987
- <xsl:copy-of select="node()"/>
5988
- </fn>
5989
- </xsl:when>
5990
- <xsl:otherwise>
5991
- <!-- itetation for:
5992
- footnotes in bibdata/title
5993
- footnotes in bibliography
5994
- footnotes in document's body (except table's head/body/foot and figure text)
5995
- -->
5996
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
5997
- <fn gen_id="{generate-id(.)}">
5998
- <xsl:copy-of select="@*"/>
5999
- <xsl:copy-of select="node()"/>
6000
- </fn>
6001
- </xsl:for-each>
6002
- <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']/*">
6003
- <xsl:sort select="@displayorder" data-type="number"/>
6004
- <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])]">
6005
- <!-- copy unique fn -->
6006
- <fn gen_id="{generate-id(.)}">
6007
- <xsl:copy-of select="@*"/>
6008
- <xsl:copy-of select="node()"/>
6009
- </fn>
6010
- </xsl:for-each>
6011
- </xsl:for-each>
6012
- </xsl:otherwise>
6013
- </xsl:choose>
6149
+ <xsl:call-template name="get_fn_list"/>
6014
6150
  </xsl:variable>
6015
6151
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6016
6152
 
@@ -6071,6 +6207,38 @@
6071
6207
  <xsl:copy-of select="$footnote_inline"/>
6072
6208
  </xsl:otherwise>
6073
6209
  </xsl:choose>
6210
+ </xsl:template><xsl:template name="get_fn_list">
6211
+ <xsl:choose>
6212
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
6213
+ <fn gen_id="{generate-id(.)}">
6214
+ <xsl:copy-of select="@*"/>
6215
+ <xsl:copy-of select="node()"/>
6216
+ </fn>
6217
+ </xsl:when>
6218
+ <xsl:otherwise>
6219
+ <!-- itetation for:
6220
+ footnotes in bibdata/title
6221
+ footnotes in bibliography
6222
+ footnotes in document's body (except table's head/body/foot and figure text)
6223
+ -->
6224
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
6225
+ <fn gen_id="{generate-id(.)}">
6226
+ <xsl:copy-of select="@*"/>
6227
+ <xsl:copy-of select="node()"/>
6228
+ </fn>
6229
+ </xsl:for-each>
6230
+ <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']/*">
6231
+ <xsl:sort select="@displayorder" data-type="number"/>
6232
+ <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])]">
6233
+ <!-- copy unique fn -->
6234
+ <fn gen_id="{generate-id(.)}">
6235
+ <xsl:copy-of select="@*"/>
6236
+ <xsl:copy-of select="node()"/>
6237
+ </fn>
6238
+ </xsl:for-each>
6239
+ </xsl:for-each>
6240
+ </xsl:otherwise>
6241
+ </xsl:choose>
6074
6242
  </xsl:template><xsl:template name="table_fn_display">
6075
6243
  <xsl:variable name="references">
6076
6244
 
@@ -6250,7 +6418,7 @@
6250
6418
  </fo:inline>
6251
6419
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
6252
6420
  <fo:inline><xsl:value-of select="."/></fo:inline>
6253
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
6421
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
6254
6422
  <fo:inline>
6255
6423
  <xsl:apply-templates/>
6256
6424
  </fo:inline>
@@ -7253,6 +7421,9 @@
7253
7421
  </fo:inline>
7254
7422
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
7255
7423
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
7424
+ <xsl:if test="parent::*[local-name() = 'add']">
7425
+ <xsl:call-template name="append_add-style"/>
7426
+ </xsl:if>
7256
7427
  <xsl:apply-templates/>
7257
7428
  </fo:basic-link>
7258
7429
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -7362,6 +7533,13 @@
7362
7533
 
7363
7534
 
7364
7535
 
7536
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7537
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
7538
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
7539
+ <xsl:call-template name="append_add-style"/>
7540
+ </xsl:if>
7541
+
7542
+
7365
7543
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
7366
7544
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
7367
7545
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -7400,6 +7578,12 @@
7400
7578
 
7401
7579
 
7402
7580
 
7581
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7582
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
7583
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
7584
+ <xsl:call-template name="append_add-style"/>
7585
+ </xsl:if>
7586
+
7403
7587
  <xsl:apply-templates select="*[local-name() = 'name']"/>
7404
7588
 
7405
7589
  </fo:inline>
@@ -7453,6 +7637,7 @@
7453
7637
  </fo:block>
7454
7638
  </xsl:template><xsl:template match="*[local-name() = 'term']">
7455
7639
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
7640
+
7456
7641
 
7457
7642
 
7458
7643
 
@@ -7893,7 +8078,11 @@
7893
8078
  <xsl:value-of select="."/>
7894
8079
  </xsl:template><xsl:template match="node()" mode="contents">
7895
8080
  <xsl:apply-templates mode="contents"/>
7896
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
8081
+ </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">
8082
+ <xsl:call-template name="contents_section-title"/>
8083
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
8084
+ <xsl:call-template name="contents_section-title"/>
8085
+ </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">
7897
8086
  <xsl:variable name="level">
7898
8087
  <xsl:call-template name="getLevel">
7899
8088
  <xsl:with-param name="depth" select="@depth"/>
@@ -7962,13 +8151,14 @@
7962
8151
  <xsl:apply-templates mode="bookmarks"/>
7963
8152
  </xsl:template><xsl:template name="addBookmarks">
7964
8153
  <xsl:param name="contents"/>
7965
- <xsl:if test="xalan:nodeset($contents)//item">
8154
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
8155
+ <xsl:if test="$contents_nodes//item">
7966
8156
  <fo:bookmark-tree>
7967
8157
  <xsl:choose>
7968
- <xsl:when test="xalan:nodeset($contents)/doc">
8158
+ <xsl:when test="$contents_nodes/doc">
7969
8159
  <xsl:choose>
7970
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
7971
- <xsl:for-each select="xalan:nodeset($contents)/doc">
8160
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
8161
+ <xsl:for-each select="$contents_nodes/doc">
7972
8162
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
7973
8163
  <xsl:if test="@bundle = 'true'">
7974
8164
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -8019,7 +8209,7 @@
8019
8209
  </xsl:for-each>
8020
8210
  </xsl:when>
8021
8211
  <xsl:otherwise>
8022
- <xsl:for-each select="xalan:nodeset($contents)/doc">
8212
+ <xsl:for-each select="$contents_nodes/doc">
8023
8213
 
8024
8214
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
8025
8215
 
@@ -8037,25 +8227,36 @@
8037
8227
  </xsl:choose>
8038
8228
  </xsl:when>
8039
8229
  <xsl:otherwise>
8040
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
8230
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
8231
+
8232
+ <xsl:call-template name="insertFigureBookmarks">
8233
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
8234
+ </xsl:call-template>
8235
+
8236
+ <xsl:call-template name="insertTableBookmarks">
8237
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
8238
+ <xsl:with-param name="lang" select="@lang"/>
8239
+ </xsl:call-template>
8240
+
8041
8241
  </xsl:otherwise>
8042
8242
  </xsl:choose>
8043
8243
 
8244
+
8044
8245
 
8045
8246
 
8046
8247
 
8047
8248
 
8048
-
8049
-
8249
+
8050
8250
 
8051
8251
  </fo:bookmark-tree>
8052
8252
  </xsl:if>
8053
8253
  </xsl:template><xsl:template name="insertFigureBookmarks">
8054
8254
  <xsl:param name="contents"/>
8055
- <xsl:if test="xalan:nodeset($contents)/figure">
8056
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
8255
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
8256
+ <xsl:if test="$contents_nodes/figure">
8257
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
8057
8258
  <fo:bookmark-title>Figures</fo:bookmark-title>
8058
- <xsl:for-each select="xalan:nodeset($contents)/figure">
8259
+ <xsl:for-each select="$contents_nodes/figure">
8059
8260
  <fo:bookmark internal-destination="{@id}">
8060
8261
  <fo:bookmark-title>
8061
8262
  <xsl:value-of select="normalize-space(title)"/>
@@ -8064,18 +8265,40 @@
8064
8265
  </xsl:for-each>
8065
8266
  </fo:bookmark>
8066
8267
  </xsl:if>
8268
+
8269
+
8270
+ <xsl:if test="$contents_nodes//figures/figure">
8271
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
8272
+
8273
+
8274
+
8275
+ <xsl:variable name="bookmark-title">
8276
+
8277
+ <xsl:value-of select="$title-list-figures"/>
8278
+
8279
+ </xsl:variable>
8280
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
8281
+ <xsl:for-each select="$contents_nodes//figures/figure">
8282
+ <fo:bookmark internal-destination="{@id}">
8283
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
8284
+ </fo:bookmark>
8285
+ </xsl:for-each>
8286
+ </fo:bookmark>
8287
+ </xsl:if>
8288
+
8067
8289
  </xsl:template><xsl:template name="insertTableBookmarks">
8068
8290
  <xsl:param name="contents"/>
8069
8291
  <xsl:param name="lang"/>
8070
- <xsl:if test="xalan:nodeset($contents)/table">
8071
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
8292
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
8293
+ <xsl:if test="$contents_nodes/table">
8294
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
8072
8295
  <fo:bookmark-title>
8073
8296
  <xsl:choose>
8074
8297
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
8075
8298
  <xsl:otherwise>Tables</xsl:otherwise>
8076
8299
  </xsl:choose>
8077
8300
  </fo:bookmark-title>
8078
- <xsl:for-each select="xalan:nodeset($contents)/table">
8301
+ <xsl:for-each select="$contents_nodes/table">
8079
8302
  <fo:bookmark internal-destination="{@id}">
8080
8303
  <fo:bookmark-title>
8081
8304
  <xsl:value-of select="normalize-space(title)"/>
@@ -8084,6 +8307,29 @@
8084
8307
  </xsl:for-each>
8085
8308
  </fo:bookmark>
8086
8309
  </xsl:if>
8310
+
8311
+
8312
+ <xsl:if test="$contents_nodes//tables/table">
8313
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
8314
+
8315
+
8316
+
8317
+ <xsl:variable name="bookmark-title">
8318
+
8319
+ <xsl:value-of select="$title-list-tables"/>
8320
+
8321
+ </xsl:variable>
8322
+
8323
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
8324
+
8325
+ <xsl:for-each select="$contents_nodes//tables/table">
8326
+ <fo:bookmark internal-destination="{@id}">
8327
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
8328
+ </fo:bookmark>
8329
+ </xsl:for-each>
8330
+ </fo:bookmark>
8331
+ </xsl:if>
8332
+
8087
8333
  </xsl:template><xsl:template name="getLangVersion">
8088
8334
  <xsl:param name="lang"/>
8089
8335
  <xsl:param name="doctype" select="''"/>
@@ -8322,7 +8568,51 @@
8322
8568
  <xsl:with-param name="text" select="$text_step1"/>
8323
8569
  </xsl:call-template>
8324
8570
  </xsl:variable>
8325
- <xsl:value-of select="$text_step2"/>
8571
+
8572
+ <!-- <xsl:value-of select="$text_step2"/> -->
8573
+
8574
+ <!-- add zero-width space after space -->
8575
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
8576
+
8577
+ <!-- split text by zero-width space -->
8578
+ <xsl:variable name="text_step4">
8579
+ <xsl:call-template name="split">
8580
+ <xsl:with-param name="pText" select="$text_step3"/>
8581
+ <xsl:with-param name="sep" select="$zero_width_space"/>
8582
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
8583
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
8584
+ </xsl:call-template>
8585
+ </xsl:variable>
8586
+
8587
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
8588
+ <xsl:choose>
8589
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
8590
+ <xsl:call-template name="interspers">
8591
+ <xsl:with-param name="str" select="."/>
8592
+ </xsl:call-template>
8593
+ </xsl:when>
8594
+ <xsl:otherwise>
8595
+ <xsl:value-of select="."/>
8596
+ </xsl:otherwise>
8597
+ </xsl:choose>
8598
+ </xsl:for-each>
8599
+
8600
+ </xsl:template><xsl:template name="interspers">
8601
+ <xsl:param name="str"/>
8602
+ <xsl:param name="char" select="$zero_width_space"/>
8603
+ <xsl:if test="$str != ''">
8604
+ <xsl:value-of select="substring($str, 1, 1)"/>
8605
+
8606
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
8607
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
8608
+ <xsl:value-of select="$char"/>
8609
+ </xsl:if>
8610
+
8611
+ <xsl:call-template name="interspers">
8612
+ <xsl:with-param name="str" select="substring($str, 2)"/>
8613
+ <xsl:with-param name="char" select="$char"/>
8614
+ </xsl:call-template>
8615
+ </xsl:if>
8326
8616
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
8327
8617
  <xsl:apply-templates mode="syntax_highlight"/>
8328
8618
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -8754,6 +9044,8 @@
8754
9044
  </xsl:otherwise>
8755
9045
  </xsl:choose> -->
8756
9046
  </fo:block>
9047
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
9048
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
8757
9049
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
8758
9050
  <xsl:if test="normalize-space() != ''">
8759
9051
  <xsl:value-of select="."/>
@@ -8828,26 +9120,24 @@
8828
9120
  </xsl:template><xsl:template match="*[local-name() = 'author']">
8829
9121
  <xsl:text>— </xsl:text>
8830
9122
  <xsl:apply-templates/>
8831
- </xsl:template><xsl:variable name="bibitem_hidden_">
9123
+ </xsl:template><xsl:variable name="bibitems_">
9124
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
9125
+ <xsl:copy-of select="."/>
9126
+ </xsl:for-each>
9127
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
8832
9128
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
8833
9129
  <xsl:copy-of select="."/>
8834
9130
  </xsl:for-each>
8835
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
9131
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
8836
9132
  <xsl:copy-of select="."/>
8837
9133
  </xsl:for-each>
8838
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
8839
-
8840
- <xsl:variable name="bibitemid">
8841
- <xsl:choose>
8842
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
8843
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
8844
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
8845
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
8846
- </xsl:choose>
8847
- </xsl:variable>
8848
-
9134
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
9135
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
9136
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
9137
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
8849
9138
  <xsl:choose>
8850
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
9139
+ <!-- <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) -->
9140
+ <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) -->
8851
9141
  <fo:inline xsl:use-attribute-sets="eref-style">
8852
9142
  <xsl:if test="@type = 'footnote'">
8853
9143
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -8861,8 +9151,8 @@
8861
9151
  <xsl:variable name="text" select="normalize-space()"/>
8862
9152
 
8863
9153
 
8864
-
8865
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
9154
+
9155
+ <fo:basic-link fox:alt-text="{@citeas}">
8866
9156
  <xsl:if test="normalize-space(@citeas) = ''">
8867
9157
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
8868
9158
  </xsl:if>
@@ -8881,14 +9171,21 @@
8881
9171
 
8882
9172
  </xsl:if>
8883
9173
 
8884
-
9174
+ <xsl:choose>
9175
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
9176
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
9177
+ </xsl:when>
9178
+ <xsl:otherwise>
9179
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
9180
+ </xsl:otherwise>
9181
+ </xsl:choose>
8885
9182
 
8886
9183
  <xsl:apply-templates/>
8887
9184
  </fo:basic-link>
8888
-
9185
+
8889
9186
  </fo:inline>
8890
9187
  </xsl:when>
8891
- <xsl:otherwise>
9188
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
8892
9189
  <fo:inline><xsl:apply-templates/></fo:inline>
8893
9190
  </xsl:otherwise>
8894
9191
  </xsl:choose>
@@ -9223,7 +9520,7 @@
9223
9520
 
9224
9521
 
9225
9522
 
9226
-
9523
+
9227
9524
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
9228
9525
  </fo:list-block>
9229
9526
  <!-- <xsl:for-each select="./iho:note">
@@ -9241,6 +9538,11 @@
9241
9538
 
9242
9539
 
9243
9540
 
9541
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
9542
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
9543
+ <xsl:call-template name="append_add-style"/>
9544
+ </xsl:if>
9545
+
9244
9546
  <xsl:call-template name="getListItemFormat"/>
9245
9547
  </fo:block>
9246
9548
  </fo:list-item-label>
@@ -9618,6 +9920,24 @@
9618
9920
  <xsl:apply-templates/>
9619
9921
  </fo:inline>
9620
9922
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
9923
+
9924
+ <!-- list of footnotes to calculate actual footnotes number -->
9925
+ <xsl:variable name="p_fn_">
9926
+ <xsl:call-template name="get_fn_list"/>
9927
+ </xsl:variable>
9928
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
9929
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
9930
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
9931
+ <!-- fn sequence number in document -->
9932
+ <xsl:variable name="current_fn_number">
9933
+ <xsl:choose>
9934
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
9935
+ <xsl:otherwise>
9936
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
9937
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
9938
+ </xsl:otherwise>
9939
+ </xsl:choose>
9940
+ </xsl:variable>
9621
9941
  <fo:footnote>
9622
9942
  <xsl:variable name="number">
9623
9943
 
@@ -9626,22 +9946,26 @@
9626
9946
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
9627
9947
  </xsl:when>
9628
9948
  <xsl:otherwise>
9629
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
9949
+ <xsl:value-of select="$current_fn_number"/>
9630
9950
  </xsl:otherwise>
9631
9951
  </xsl:choose>
9632
9952
 
9633
9953
  </xsl:variable>
9954
+
9955
+ <xsl:variable name="current_fn_number_text">
9956
+ <xsl:value-of select="$number"/>
9957
+
9958
+ </xsl:variable>
9959
+
9634
9960
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
9635
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
9636
- <xsl:value-of select="$number"/>
9637
-
9961
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
9962
+ <xsl:value-of select="$current_fn_number_text"/>
9638
9963
  </fo:basic-link>
9639
9964
  </fo:inline>
9640
9965
  <fo:footnote-body>
9641
9966
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
9642
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
9643
- <xsl:value-of select="$number"/>
9644
-
9967
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
9968
+ <xsl:value-of select="$current_fn_number_text"/>
9645
9969
  </fo:inline>
9646
9970
  <xsl:apply-templates/>
9647
9971
  </fo:block>
@@ -9887,6 +10211,78 @@
9887
10211
  <xsl:apply-templates/>
9888
10212
  </fo:block>
9889
10213
 
10214
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
10215
+ <xsl:copy>
10216
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
10217
+ </xsl:copy>
10218
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
10219
+ <xsl:copy>
10220
+ <xsl:copy-of select="@*"/>
10221
+
10222
+ <xsl:variable name="nodes_preface_">
10223
+ <xsl:for-each select="*">
10224
+ <node id="{@id}"/>
10225
+ </xsl:for-each>
10226
+ </xsl:variable>
10227
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
10228
+
10229
+ <xsl:for-each select="*">
10230
+ <xsl:sort select="@displayorder" data-type="number"/>
10231
+
10232
+ <!-- process Section's title -->
10233
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
10234
+ <xsl:if test="$preceding-sibling_id != ''">
10235
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
10236
+ </xsl:if>
10237
+
10238
+ <xsl:choose>
10239
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
10240
+ <xsl:otherwise>
10241
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10242
+ </xsl:otherwise>
10243
+ </xsl:choose>
10244
+
10245
+ </xsl:for-each>
10246
+ </xsl:copy>
10247
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
10248
+ <xsl:copy>
10249
+ <xsl:copy-of select="@*"/>
10250
+
10251
+ <xsl:variable name="nodes_sections_">
10252
+ <xsl:for-each select="*">
10253
+ <node id="{@id}"/>
10254
+ </xsl:for-each>
10255
+ </xsl:variable>
10256
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
10257
+
10258
+ <!-- move section 'Normative references' inside 'sections' -->
10259
+ <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']]">
10260
+ <xsl:sort select="@displayorder" data-type="number"/>
10261
+
10262
+ <!-- process Section's title -->
10263
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
10264
+ <xsl:if test="$preceding-sibling_id != ''">
10265
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
10266
+ </xsl:if>
10267
+
10268
+ <xsl:choose>
10269
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
10270
+ <xsl:otherwise>
10271
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10272
+ </xsl:otherwise>
10273
+ </xsl:choose>
10274
+
10275
+ </xsl:for-each>
10276
+ </xsl:copy>
10277
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
10278
+ <xsl:copy>
10279
+ <xsl:copy-of select="@*"/>
10280
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
10281
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
10282
+ <xsl:sort select="@displayorder" data-type="number"/>
10283
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10284
+ </xsl:for-each>
10285
+ </xsl:copy>
9890
10286
  </xsl:template><xsl:template name="convertDate">
9891
10287
  <xsl:param name="date"/>
9892
10288
  <xsl:param name="format" select="'short'"/>
@@ -10131,22 +10527,25 @@
10131
10527
  <xsl:param name="pText" select="."/>
10132
10528
  <xsl:param name="sep" select="','"/>
10133
10529
  <xsl:param name="normalize-space" select="'true'"/>
10530
+ <xsl:param name="keep_sep" select="'false'"/>
10134
10531
  <xsl:if test="string-length($pText) &gt;0">
10135
- <item>
10136
- <xsl:choose>
10137
- <xsl:when test="$normalize-space = 'true'">
10138
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10139
- </xsl:when>
10140
- <xsl:otherwise>
10141
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10142
- </xsl:otherwise>
10143
- </xsl:choose>
10144
- </item>
10145
- <xsl:call-template name="split">
10146
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10147
- <xsl:with-param name="sep" select="$sep"/>
10148
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
10149
- </xsl:call-template>
10532
+ <item>
10533
+ <xsl:choose>
10534
+ <xsl:when test="$normalize-space = 'true'">
10535
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10536
+ </xsl:when>
10537
+ <xsl:otherwise>
10538
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10539
+ </xsl:otherwise>
10540
+ </xsl:choose>
10541
+ </item>
10542
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
10543
+ <xsl:call-template name="split">
10544
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10545
+ <xsl:with-param name="sep" select="$sep"/>
10546
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
10547
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
10548
+ </xsl:call-template>
10150
10549
  </xsl:if>
10151
10550
  </xsl:template><xsl:template name="getDocumentId">
10152
10551
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -10337,53 +10736,153 @@
10337
10736
  <xsl:param name="first"/>
10338
10737
  <xsl:if test="$number != ''">
10339
10738
  <xsl:variable name="words">
10340
- <words>
10341
- <word cardinal="1">One-</word>
10342
- <word ordinal="1">First </word>
10343
- <word cardinal="2">Two-</word>
10344
- <word ordinal="2">Second </word>
10345
- <word cardinal="3">Three-</word>
10346
- <word ordinal="3">Third </word>
10347
- <word cardinal="4">Four-</word>
10348
- <word ordinal="4">Fourth </word>
10349
- <word cardinal="5">Five-</word>
10350
- <word ordinal="5">Fifth </word>
10351
- <word cardinal="6">Six-</word>
10352
- <word ordinal="6">Sixth </word>
10353
- <word cardinal="7">Seven-</word>
10354
- <word ordinal="7">Seventh </word>
10355
- <word cardinal="8">Eight-</word>
10356
- <word ordinal="8">Eighth </word>
10357
- <word cardinal="9">Nine-</word>
10358
- <word ordinal="9">Ninth </word>
10359
- <word ordinal="10">Tenth </word>
10360
- <word ordinal="11">Eleventh </word>
10361
- <word ordinal="12">Twelfth </word>
10362
- <word ordinal="13">Thirteenth </word>
10363
- <word ordinal="14">Fourteenth </word>
10364
- <word ordinal="15">Fifteenth </word>
10365
- <word ordinal="16">Sixteenth </word>
10366
- <word ordinal="17">Seventeenth </word>
10367
- <word ordinal="18">Eighteenth </word>
10368
- <word ordinal="19">Nineteenth </word>
10369
- <word cardinal="20">Twenty-</word>
10370
- <word ordinal="20">Twentieth </word>
10371
- <word cardinal="30">Thirty-</word>
10372
- <word ordinal="30">Thirtieth </word>
10373
- <word cardinal="40">Forty-</word>
10374
- <word ordinal="40">Fortieth </word>
10375
- <word cardinal="50">Fifty-</word>
10376
- <word ordinal="50">Fiftieth </word>
10377
- <word cardinal="60">Sixty-</word>
10378
- <word ordinal="60">Sixtieth </word>
10379
- <word cardinal="70">Seventy-</word>
10380
- <word ordinal="70">Seventieth </word>
10381
- <word cardinal="80">Eighty-</word>
10382
- <word ordinal="80">Eightieth </word>
10383
- <word cardinal="90">Ninety-</word>
10384
- <word ordinal="90">Ninetieth </word>
10385
- <word cardinal="100">Hundred-</word>
10386
- <word ordinal="100">Hundredth </word>
10739
+ <words>
10740
+ <xsl:choose>
10741
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
10742
+ <word cardinal="1">Une-</word>
10743
+ <word ordinal="1">Première </word>
10744
+ <word cardinal="2">Deux-</word>
10745
+ <word ordinal="2">Seconde </word>
10746
+ <word cardinal="3">Trois-</word>
10747
+ <word ordinal="3">Tierce </word>
10748
+ <word cardinal="4">Quatre-</word>
10749
+ <word ordinal="4">Quatrième </word>
10750
+ <word cardinal="5">Cinq-</word>
10751
+ <word ordinal="5">Cinquième </word>
10752
+ <word cardinal="6">Six-</word>
10753
+ <word ordinal="6">Sixième </word>
10754
+ <word cardinal="7">Sept-</word>
10755
+ <word ordinal="7">Septième </word>
10756
+ <word cardinal="8">Huit-</word>
10757
+ <word ordinal="8">Huitième </word>
10758
+ <word cardinal="9">Neuf-</word>
10759
+ <word ordinal="9">Neuvième </word>
10760
+ <word ordinal="10">Dixième </word>
10761
+ <word ordinal="11">Onzième </word>
10762
+ <word ordinal="12">Douzième </word>
10763
+ <word ordinal="13">Treizième </word>
10764
+ <word ordinal="14">Quatorzième </word>
10765
+ <word ordinal="15">Quinzième </word>
10766
+ <word ordinal="16">Seizième </word>
10767
+ <word ordinal="17">Dix-septième </word>
10768
+ <word ordinal="18">Dix-huitième </word>
10769
+ <word ordinal="19">Dix-neuvième </word>
10770
+ <word cardinal="20">Vingt-</word>
10771
+ <word ordinal="20">Vingtième </word>
10772
+ <word cardinal="30">Trente-</word>
10773
+ <word ordinal="30">Trentième </word>
10774
+ <word cardinal="40">Quarante-</word>
10775
+ <word ordinal="40">Quarantième </word>
10776
+ <word cardinal="50">Cinquante-</word>
10777
+ <word ordinal="50">Cinquantième </word>
10778
+ <word cardinal="60">Soixante-</word>
10779
+ <word ordinal="60">Soixantième </word>
10780
+ <word cardinal="70">Septante-</word>
10781
+ <word ordinal="70">Septantième </word>
10782
+ <word cardinal="80">Huitante-</word>
10783
+ <word ordinal="80">Huitantième </word>
10784
+ <word cardinal="90">Nonante-</word>
10785
+ <word ordinal="90">Nonantième </word>
10786
+ <word cardinal="100">Cent-</word>
10787
+ <word ordinal="100">Centième </word>
10788
+ </xsl:when>
10789
+ <xsl:when test="$lang = 'ru'">
10790
+ <word cardinal="1">Одна-</word>
10791
+ <word ordinal="1">Первое </word>
10792
+ <word cardinal="2">Две-</word>
10793
+ <word ordinal="2">Второе </word>
10794
+ <word cardinal="3">Три-</word>
10795
+ <word ordinal="3">Третье </word>
10796
+ <word cardinal="4">Четыре-</word>
10797
+ <word ordinal="4">Четвертое </word>
10798
+ <word cardinal="5">Пять-</word>
10799
+ <word ordinal="5">Пятое </word>
10800
+ <word cardinal="6">Шесть-</word>
10801
+ <word ordinal="6">Шестое </word>
10802
+ <word cardinal="7">Семь-</word>
10803
+ <word ordinal="7">Седьмое </word>
10804
+ <word cardinal="8">Восемь-</word>
10805
+ <word ordinal="8">Восьмое </word>
10806
+ <word cardinal="9">Девять-</word>
10807
+ <word ordinal="9">Девятое </word>
10808
+ <word ordinal="10">Десятое </word>
10809
+ <word ordinal="11">Одиннадцатое </word>
10810
+ <word ordinal="12">Двенадцатое </word>
10811
+ <word ordinal="13">Тринадцатое </word>
10812
+ <word ordinal="14">Четырнадцатое </word>
10813
+ <word ordinal="15">Пятнадцатое </word>
10814
+ <word ordinal="16">Шестнадцатое </word>
10815
+ <word ordinal="17">Семнадцатое </word>
10816
+ <word ordinal="18">Восемнадцатое </word>
10817
+ <word ordinal="19">Девятнадцатое </word>
10818
+ <word cardinal="20">Двадцать-</word>
10819
+ <word ordinal="20">Двадцатое </word>
10820
+ <word cardinal="30">Тридцать-</word>
10821
+ <word ordinal="30">Тридцатое </word>
10822
+ <word cardinal="40">Сорок-</word>
10823
+ <word ordinal="40">Сороковое </word>
10824
+ <word cardinal="50">Пятьдесят-</word>
10825
+ <word ordinal="50">Пятидесятое </word>
10826
+ <word cardinal="60">Шестьдесят-</word>
10827
+ <word ordinal="60">Шестидесятое </word>
10828
+ <word cardinal="70">Семьдесят-</word>
10829
+ <word ordinal="70">Семидесятое </word>
10830
+ <word cardinal="80">Восемьдесят-</word>
10831
+ <word ordinal="80">Восьмидесятое </word>
10832
+ <word cardinal="90">Девяносто-</word>
10833
+ <word ordinal="90">Девяностое </word>
10834
+ <word cardinal="100">Сто-</word>
10835
+ <word ordinal="100">Сотое </word>
10836
+ </xsl:when>
10837
+ <xsl:otherwise> <!-- default english -->
10838
+ <word cardinal="1">One-</word>
10839
+ <word ordinal="1">First </word>
10840
+ <word cardinal="2">Two-</word>
10841
+ <word ordinal="2">Second </word>
10842
+ <word cardinal="3">Three-</word>
10843
+ <word ordinal="3">Third </word>
10844
+ <word cardinal="4">Four-</word>
10845
+ <word ordinal="4">Fourth </word>
10846
+ <word cardinal="5">Five-</word>
10847
+ <word ordinal="5">Fifth </word>
10848
+ <word cardinal="6">Six-</word>
10849
+ <word ordinal="6">Sixth </word>
10850
+ <word cardinal="7">Seven-</word>
10851
+ <word ordinal="7">Seventh </word>
10852
+ <word cardinal="8">Eight-</word>
10853
+ <word ordinal="8">Eighth </word>
10854
+ <word cardinal="9">Nine-</word>
10855
+ <word ordinal="9">Ninth </word>
10856
+ <word ordinal="10">Tenth </word>
10857
+ <word ordinal="11">Eleventh </word>
10858
+ <word ordinal="12">Twelfth </word>
10859
+ <word ordinal="13">Thirteenth </word>
10860
+ <word ordinal="14">Fourteenth </word>
10861
+ <word ordinal="15">Fifteenth </word>
10862
+ <word ordinal="16">Sixteenth </word>
10863
+ <word ordinal="17">Seventeenth </word>
10864
+ <word ordinal="18">Eighteenth </word>
10865
+ <word ordinal="19">Nineteenth </word>
10866
+ <word cardinal="20">Twenty-</word>
10867
+ <word ordinal="20">Twentieth </word>
10868
+ <word cardinal="30">Thirty-</word>
10869
+ <word ordinal="30">Thirtieth </word>
10870
+ <word cardinal="40">Forty-</word>
10871
+ <word ordinal="40">Fortieth </word>
10872
+ <word cardinal="50">Fifty-</word>
10873
+ <word ordinal="50">Fiftieth </word>
10874
+ <word cardinal="60">Sixty-</word>
10875
+ <word ordinal="60">Sixtieth </word>
10876
+ <word cardinal="70">Seventy-</word>
10877
+ <word ordinal="70">Seventieth </word>
10878
+ <word cardinal="80">Eighty-</word>
10879
+ <word ordinal="80">Eightieth </word>
10880
+ <word cardinal="90">Ninety-</word>
10881
+ <word ordinal="90">Ninetieth </word>
10882
+ <word cardinal="100">Hundred-</word>
10883
+ <word ordinal="100">Hundredth </word>
10884
+ </xsl:otherwise>
10885
+ </xsl:choose>
10387
10886
  </words>
10388
10887
  </xsl:variable>
10389
10888
 
@@ -10457,4 +10956,18 @@
10457
10956
  <xsl:otherwise>_</xsl:otherwise>
10458
10957
  </xsl:choose>
10459
10958
  </xsl:attribute>
10959
+ </xsl:template><xsl:template name="substring-after-last">
10960
+ <xsl:param name="value"/>
10961
+ <xsl:param name="delimiter"/>
10962
+ <xsl:choose>
10963
+ <xsl:when test="contains($value, $delimiter)">
10964
+ <xsl:call-template name="substring-after-last">
10965
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
10966
+ <xsl:with-param name="delimiter" select="$delimiter"/>
10967
+ </xsl:call-template>
10968
+ </xsl:when>
10969
+ <xsl:otherwise>
10970
+ <xsl:value-of select="$value"/>
10971
+ </xsl:otherwise>
10972
+ </xsl:choose>
10460
10973
  </xsl:template></xsl:stylesheet>