metanorma-bipm 2.0.4 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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/>
@@ -3885,7 +3960,7 @@
3885
3960
  <xsl:text>Contents</xsl:text>
3886
3961
 
3887
3962
  </title-toc>
3888
-
3963
+
3889
3964
  <title-descriptors lang="en">Descriptors</title-descriptors>
3890
3965
 
3891
3966
  <title-part lang="en">
@@ -3925,7 +4000,31 @@
3925
4000
  <title-continued lang="en">(continued)</title-continued>
3926
4001
  <title-continued lang="fr">(continué)</title-continued>
3927
4002
 
3928
- </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">
3929
4028
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
3930
4029
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
3931
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">
@@ -5158,6 +5257,30 @@
5158
5257
  <xsl:sort select="@displayorder" data-type="number"/>
5159
5258
  <xsl:apply-templates select="." mode="contents"/>
5160
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>
5161
5284
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
5162
5285
  <xsl:for-each select="/*/*[local-name()='preface']/*">
5163
5286
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -5179,8 +5302,27 @@
5179
5302
  <xsl:sort select="@displayorder" data-type="number"/>
5180
5303
  <xsl:apply-templates select="."/>
5181
5304
  </xsl:for-each>
5182
- </xsl:template><xsl:template match="text()">
5183
- <xsl:value-of select="."/>
5305
+ </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
5306
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5307
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
5308
+ <xsl:call-template name="replace_fo_inline">
5309
+ <xsl:with-param name="text" select="$text"/>
5310
+ </xsl:call-template>
5311
+ </xsl:template><xsl:template name="replace_fo_inline">
5312
+ <xsl:param name="text"/>
5313
+ <xsl:choose>
5314
+ <xsl:when test="contains($text, $tag_open)">
5315
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
5316
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
5317
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5318
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5319
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
5320
+ <xsl:call-template name="replace_fo_inline">
5321
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
5322
+ </xsl:call-template>
5323
+ </xsl:when>
5324
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
5325
+ </xsl:choose>
5184
5326
  </xsl:template><xsl:template match="*[local-name()='br']">
5185
5327
  <xsl:value-of select="$linebreak"/>
5186
5328
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -6023,37 +6165,7 @@
6023
6165
 
6024
6166
  <!-- list of footnotes to calculate actual footnotes number -->
6025
6167
  <xsl:variable name="p_fn_">
6026
- <xsl:choose>
6027
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
6028
- <fn gen_id="{generate-id(.)}">
6029
- <xsl:copy-of select="@*"/>
6030
- <xsl:copy-of select="node()"/>
6031
- </fn>
6032
- </xsl:when>
6033
- <xsl:otherwise>
6034
- <!-- itetation for:
6035
- footnotes in bibdata/title
6036
- footnotes in bibliography
6037
- footnotes in document's body (except table's head/body/foot and figure text)
6038
- -->
6039
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
6040
- <fn gen_id="{generate-id(.)}">
6041
- <xsl:copy-of select="@*"/>
6042
- <xsl:copy-of select="node()"/>
6043
- </fn>
6044
- </xsl:for-each>
6045
- <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']/*">
6046
- <xsl:sort select="@displayorder" data-type="number"/>
6047
- <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])]">
6048
- <!-- copy unique fn -->
6049
- <fn gen_id="{generate-id(.)}">
6050
- <xsl:copy-of select="@*"/>
6051
- <xsl:copy-of select="node()"/>
6052
- </fn>
6053
- </xsl:for-each>
6054
- </xsl:for-each>
6055
- </xsl:otherwise>
6056
- </xsl:choose>
6168
+ <xsl:call-template name="get_fn_list"/>
6057
6169
  </xsl:variable>
6058
6170
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6059
6171
 
@@ -6114,6 +6226,38 @@
6114
6226
  <xsl:copy-of select="$footnote_inline"/>
6115
6227
  </xsl:otherwise>
6116
6228
  </xsl:choose>
6229
+ </xsl:template><xsl:template name="get_fn_list">
6230
+ <xsl:choose>
6231
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
6232
+ <fn gen_id="{generate-id(.)}">
6233
+ <xsl:copy-of select="@*"/>
6234
+ <xsl:copy-of select="node()"/>
6235
+ </fn>
6236
+ </xsl:when>
6237
+ <xsl:otherwise>
6238
+ <!-- itetation for:
6239
+ footnotes in bibdata/title
6240
+ footnotes in bibliography
6241
+ footnotes in document's body (except table's head/body/foot and figure text)
6242
+ -->
6243
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
6244
+ <fn gen_id="{generate-id(.)}">
6245
+ <xsl:copy-of select="@*"/>
6246
+ <xsl:copy-of select="node()"/>
6247
+ </fn>
6248
+ </xsl:for-each>
6249
+ <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']/*">
6250
+ <xsl:sort select="@displayorder" data-type="number"/>
6251
+ <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])]">
6252
+ <!-- copy unique fn -->
6253
+ <fn gen_id="{generate-id(.)}">
6254
+ <xsl:copy-of select="@*"/>
6255
+ <xsl:copy-of select="node()"/>
6256
+ </fn>
6257
+ </xsl:for-each>
6258
+ </xsl:for-each>
6259
+ </xsl:otherwise>
6260
+ </xsl:choose>
6117
6261
  </xsl:template><xsl:template name="table_fn_display">
6118
6262
  <xsl:variable name="references">
6119
6263
 
@@ -6293,7 +6437,7 @@
6293
6437
  </fo:inline>
6294
6438
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
6295
6439
  <fo:inline><xsl:value-of select="."/></fo:inline>
6296
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
6440
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
6297
6441
  <fo:inline>
6298
6442
  <xsl:apply-templates/>
6299
6443
  </fo:inline>
@@ -8026,13 +8170,14 @@
8026
8170
  <xsl:apply-templates mode="bookmarks"/>
8027
8171
  </xsl:template><xsl:template name="addBookmarks">
8028
8172
  <xsl:param name="contents"/>
8029
- <xsl:if test="xalan:nodeset($contents)//item">
8173
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
8174
+ <xsl:if test="$contents_nodes//item">
8030
8175
  <fo:bookmark-tree>
8031
8176
  <xsl:choose>
8032
- <xsl:when test="xalan:nodeset($contents)/doc">
8177
+ <xsl:when test="$contents_nodes/doc">
8033
8178
  <xsl:choose>
8034
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
8035
- <xsl:for-each select="xalan:nodeset($contents)/doc">
8179
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
8180
+ <xsl:for-each select="$contents_nodes/doc">
8036
8181
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
8037
8182
  <xsl:if test="@bundle = 'true'">
8038
8183
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -8083,7 +8228,7 @@
8083
8228
  </xsl:for-each>
8084
8229
  </xsl:when>
8085
8230
  <xsl:otherwise>
8086
- <xsl:for-each select="xalan:nodeset($contents)/doc">
8231
+ <xsl:for-each select="$contents_nodes/doc">
8087
8232
 
8088
8233
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
8089
8234
 
@@ -8101,25 +8246,36 @@
8101
8246
  </xsl:choose>
8102
8247
  </xsl:when>
8103
8248
  <xsl:otherwise>
8104
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
8249
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
8250
+
8251
+ <xsl:call-template name="insertFigureBookmarks">
8252
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
8253
+ </xsl:call-template>
8254
+
8255
+ <xsl:call-template name="insertTableBookmarks">
8256
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
8257
+ <xsl:with-param name="lang" select="@lang"/>
8258
+ </xsl:call-template>
8259
+
8105
8260
  </xsl:otherwise>
8106
8261
  </xsl:choose>
8107
8262
 
8263
+
8108
8264
 
8109
8265
 
8110
8266
 
8111
8267
 
8112
-
8113
-
8268
+
8114
8269
 
8115
8270
  </fo:bookmark-tree>
8116
8271
  </xsl:if>
8117
8272
  </xsl:template><xsl:template name="insertFigureBookmarks">
8118
8273
  <xsl:param name="contents"/>
8119
- <xsl:if test="xalan:nodeset($contents)/figure">
8120
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
8274
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
8275
+ <xsl:if test="$contents_nodes/figure">
8276
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
8121
8277
  <fo:bookmark-title>Figures</fo:bookmark-title>
8122
- <xsl:for-each select="xalan:nodeset($contents)/figure">
8278
+ <xsl:for-each select="$contents_nodes/figure">
8123
8279
  <fo:bookmark internal-destination="{@id}">
8124
8280
  <fo:bookmark-title>
8125
8281
  <xsl:value-of select="normalize-space(title)"/>
@@ -8128,18 +8284,40 @@
8128
8284
  </xsl:for-each>
8129
8285
  </fo:bookmark>
8130
8286
  </xsl:if>
8287
+
8288
+
8289
+ <xsl:if test="$contents_nodes//figures/figure">
8290
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
8291
+
8292
+
8293
+
8294
+ <xsl:variable name="bookmark-title">
8295
+
8296
+ <xsl:value-of select="$title-list-figures"/>
8297
+
8298
+ </xsl:variable>
8299
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
8300
+ <xsl:for-each select="$contents_nodes//figures/figure">
8301
+ <fo:bookmark internal-destination="{@id}">
8302
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
8303
+ </fo:bookmark>
8304
+ </xsl:for-each>
8305
+ </fo:bookmark>
8306
+ </xsl:if>
8307
+
8131
8308
  </xsl:template><xsl:template name="insertTableBookmarks">
8132
8309
  <xsl:param name="contents"/>
8133
8310
  <xsl:param name="lang"/>
8134
- <xsl:if test="xalan:nodeset($contents)/table">
8135
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
8311
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
8312
+ <xsl:if test="$contents_nodes/table">
8313
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
8136
8314
  <fo:bookmark-title>
8137
8315
  <xsl:choose>
8138
8316
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
8139
8317
  <xsl:otherwise>Tables</xsl:otherwise>
8140
8318
  </xsl:choose>
8141
8319
  </fo:bookmark-title>
8142
- <xsl:for-each select="xalan:nodeset($contents)/table">
8320
+ <xsl:for-each select="$contents_nodes/table">
8143
8321
  <fo:bookmark internal-destination="{@id}">
8144
8322
  <fo:bookmark-title>
8145
8323
  <xsl:value-of select="normalize-space(title)"/>
@@ -8148,6 +8326,29 @@
8148
8326
  </xsl:for-each>
8149
8327
  </fo:bookmark>
8150
8328
  </xsl:if>
8329
+
8330
+
8331
+ <xsl:if test="$contents_nodes//tables/table">
8332
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
8333
+
8334
+
8335
+
8336
+ <xsl:variable name="bookmark-title">
8337
+
8338
+ <xsl:value-of select="$title-list-tables"/>
8339
+
8340
+ </xsl:variable>
8341
+
8342
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
8343
+
8344
+ <xsl:for-each select="$contents_nodes//tables/table">
8345
+ <fo:bookmark internal-destination="{@id}">
8346
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
8347
+ </fo:bookmark>
8348
+ </xsl:for-each>
8349
+ </fo:bookmark>
8350
+ </xsl:if>
8351
+
8151
8352
  </xsl:template><xsl:template name="getLangVersion">
8152
8353
  <xsl:param name="lang"/>
8153
8354
  <xsl:param name="doctype" select="''"/>
@@ -8386,7 +8587,51 @@
8386
8587
  <xsl:with-param name="text" select="$text_step1"/>
8387
8588
  </xsl:call-template>
8388
8589
  </xsl:variable>
8389
- <xsl:value-of select="$text_step2"/>
8590
+
8591
+ <!-- <xsl:value-of select="$text_step2"/> -->
8592
+
8593
+ <!-- add zero-width space after space -->
8594
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
8595
+
8596
+ <!-- split text by zero-width space -->
8597
+ <xsl:variable name="text_step4">
8598
+ <xsl:call-template name="split">
8599
+ <xsl:with-param name="pText" select="$text_step3"/>
8600
+ <xsl:with-param name="sep" select="$zero_width_space"/>
8601
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
8602
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
8603
+ </xsl:call-template>
8604
+ </xsl:variable>
8605
+
8606
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
8607
+ <xsl:choose>
8608
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
8609
+ <xsl:call-template name="interspers">
8610
+ <xsl:with-param name="str" select="."/>
8611
+ </xsl:call-template>
8612
+ </xsl:when>
8613
+ <xsl:otherwise>
8614
+ <xsl:value-of select="."/>
8615
+ </xsl:otherwise>
8616
+ </xsl:choose>
8617
+ </xsl:for-each>
8618
+
8619
+ </xsl:template><xsl:template name="interspers">
8620
+ <xsl:param name="str"/>
8621
+ <xsl:param name="char" select="$zero_width_space"/>
8622
+ <xsl:if test="$str != ''">
8623
+ <xsl:value-of select="substring($str, 1, 1)"/>
8624
+
8625
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
8626
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
8627
+ <xsl:value-of select="$char"/>
8628
+ </xsl:if>
8629
+
8630
+ <xsl:call-template name="interspers">
8631
+ <xsl:with-param name="str" select="substring($str, 2)"/>
8632
+ <xsl:with-param name="char" select="$char"/>
8633
+ </xsl:call-template>
8634
+ </xsl:if>
8390
8635
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
8391
8636
  <xsl:apply-templates mode="syntax_highlight"/>
8392
8637
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -8818,6 +9063,8 @@
8818
9063
  </xsl:otherwise>
8819
9064
  </xsl:choose> -->
8820
9065
  </fo:block>
9066
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
9067
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
8821
9068
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
8822
9069
  <xsl:if test="normalize-space() != ''">
8823
9070
  <xsl:value-of select="."/>
@@ -8852,7 +9099,8 @@
8852
9099
  <fo:inline><xsl:apply-templates/></fo:inline>
8853
9100
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
8854
9101
  <xsl:if test="normalize-space() != ''">
8855
- <xsl:value-of select="."/>
9102
+ <!-- <xsl:value-of select="."/> -->
9103
+ <xsl:call-template name="text"/>
8856
9104
  </xsl:if>
8857
9105
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
8858
9106
  <fo:block-container margin-left="0mm">
@@ -8892,26 +9140,24 @@
8892
9140
  </xsl:template><xsl:template match="*[local-name() = 'author']">
8893
9141
  <xsl:text>— </xsl:text>
8894
9142
  <xsl:apply-templates/>
8895
- </xsl:template><xsl:variable name="bibitem_hidden_">
9143
+ </xsl:template><xsl:variable name="bibitems_">
9144
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
9145
+ <xsl:copy-of select="."/>
9146
+ </xsl:for-each>
9147
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
8896
9148
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
8897
9149
  <xsl:copy-of select="."/>
8898
9150
  </xsl:for-each>
8899
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
9151
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
8900
9152
  <xsl:copy-of select="."/>
8901
9153
  </xsl:for-each>
8902
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
8903
-
8904
- <xsl:variable name="bibitemid">
8905
- <xsl:choose>
8906
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
8907
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
8908
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
8909
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
8910
- </xsl:choose>
8911
- </xsl:variable>
8912
-
9154
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
9155
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
9156
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
9157
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
8913
9158
  <xsl:choose>
8914
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
9159
+ <!-- <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) -->
9160
+ <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) -->
8915
9161
  <fo:inline xsl:use-attribute-sets="eref-style">
8916
9162
  <xsl:if test="@type = 'footnote'">
8917
9163
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -8925,8 +9171,8 @@
8925
9171
  <xsl:variable name="text" select="normalize-space()"/>
8926
9172
 
8927
9173
 
8928
-
8929
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
9174
+
9175
+ <fo:basic-link fox:alt-text="{@citeas}">
8930
9176
  <xsl:if test="normalize-space(@citeas) = ''">
8931
9177
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
8932
9178
  </xsl:if>
@@ -8945,14 +9191,21 @@
8945
9191
 
8946
9192
  </xsl:if>
8947
9193
 
8948
-
9194
+ <xsl:choose>
9195
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
9196
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
9197
+ </xsl:when>
9198
+ <xsl:otherwise>
9199
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
9200
+ </xsl:otherwise>
9201
+ </xsl:choose>
8949
9202
 
8950
9203
  <xsl:apply-templates/>
8951
9204
  </fo:basic-link>
8952
-
9205
+
8953
9206
  </fo:inline>
8954
9207
  </xsl:when>
8955
- <xsl:otherwise>
9208
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
8956
9209
  <fo:inline><xsl:apply-templates/></fo:inline>
8957
9210
  </xsl:otherwise>
8958
9211
  </xsl:choose>
@@ -9687,6 +9940,24 @@
9687
9940
  <xsl:apply-templates/>
9688
9941
  </fo:inline>
9689
9942
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
9943
+
9944
+ <!-- list of footnotes to calculate actual footnotes number -->
9945
+ <xsl:variable name="p_fn_">
9946
+ <xsl:call-template name="get_fn_list"/>
9947
+ </xsl:variable>
9948
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
9949
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
9950
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
9951
+ <!-- fn sequence number in document -->
9952
+ <xsl:variable name="current_fn_number">
9953
+ <xsl:choose>
9954
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
9955
+ <xsl:otherwise>
9956
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
9957
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
9958
+ </xsl:otherwise>
9959
+ </xsl:choose>
9960
+ </xsl:variable>
9690
9961
  <fo:footnote>
9691
9962
  <xsl:variable name="number">
9692
9963
 
@@ -9695,22 +9966,26 @@
9695
9966
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
9696
9967
  </xsl:when>
9697
9968
  <xsl:otherwise>
9698
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
9969
+ <xsl:value-of select="$current_fn_number"/>
9699
9970
  </xsl:otherwise>
9700
9971
  </xsl:choose>
9701
9972
 
9702
9973
  </xsl:variable>
9974
+
9975
+ <xsl:variable name="current_fn_number_text">
9976
+ <xsl:value-of select="$number"/>
9977
+
9978
+ </xsl:variable>
9979
+
9703
9980
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
9704
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
9705
- <xsl:value-of select="$number"/>
9706
-
9981
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
9982
+ <xsl:value-of select="$current_fn_number_text"/>
9707
9983
  </fo:basic-link>
9708
9984
  </fo:inline>
9709
9985
  <fo:footnote-body>
9710
9986
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
9711
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
9712
- <xsl:value-of select="$number"/>
9713
-
9987
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
9988
+ <xsl:value-of select="$current_fn_number_text"/>
9714
9989
  </fo:inline>
9715
9990
  <xsl:apply-templates/>
9716
9991
  </fo:block>
@@ -9956,6 +10231,78 @@
9956
10231
  <xsl:apply-templates/>
9957
10232
  </fo:block>
9958
10233
 
10234
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
10235
+ <xsl:copy>
10236
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
10237
+ </xsl:copy>
10238
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
10239
+ <xsl:copy>
10240
+ <xsl:copy-of select="@*"/>
10241
+
10242
+ <xsl:variable name="nodes_preface_">
10243
+ <xsl:for-each select="*">
10244
+ <node id="{@id}"/>
10245
+ </xsl:for-each>
10246
+ </xsl:variable>
10247
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
10248
+
10249
+ <xsl:for-each select="*">
10250
+ <xsl:sort select="@displayorder" data-type="number"/>
10251
+
10252
+ <!-- process Section's title -->
10253
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
10254
+ <xsl:if test="$preceding-sibling_id != ''">
10255
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
10256
+ </xsl:if>
10257
+
10258
+ <xsl:choose>
10259
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
10260
+ <xsl:otherwise>
10261
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10262
+ </xsl:otherwise>
10263
+ </xsl:choose>
10264
+
10265
+ </xsl:for-each>
10266
+ </xsl:copy>
10267
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
10268
+ <xsl:copy>
10269
+ <xsl:copy-of select="@*"/>
10270
+
10271
+ <xsl:variable name="nodes_sections_">
10272
+ <xsl:for-each select="*">
10273
+ <node id="{@id}"/>
10274
+ </xsl:for-each>
10275
+ </xsl:variable>
10276
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
10277
+
10278
+ <!-- move section 'Normative references' inside 'sections' -->
10279
+ <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']]">
10280
+ <xsl:sort select="@displayorder" data-type="number"/>
10281
+
10282
+ <!-- process Section's title -->
10283
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
10284
+ <xsl:if test="$preceding-sibling_id != ''">
10285
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
10286
+ </xsl:if>
10287
+
10288
+ <xsl:choose>
10289
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
10290
+ <xsl:otherwise>
10291
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10292
+ </xsl:otherwise>
10293
+ </xsl:choose>
10294
+
10295
+ </xsl:for-each>
10296
+ </xsl:copy>
10297
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
10298
+ <xsl:copy>
10299
+ <xsl:copy-of select="@*"/>
10300
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
10301
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
10302
+ <xsl:sort select="@displayorder" data-type="number"/>
10303
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10304
+ </xsl:for-each>
10305
+ </xsl:copy>
9959
10306
  </xsl:template><xsl:template name="convertDate">
9960
10307
  <xsl:param name="date"/>
9961
10308
  <xsl:param name="format" select="'short'"/>
@@ -10200,22 +10547,25 @@
10200
10547
  <xsl:param name="pText" select="."/>
10201
10548
  <xsl:param name="sep" select="','"/>
10202
10549
  <xsl:param name="normalize-space" select="'true'"/>
10550
+ <xsl:param name="keep_sep" select="'false'"/>
10203
10551
  <xsl:if test="string-length($pText) &gt;0">
10204
- <item>
10205
- <xsl:choose>
10206
- <xsl:when test="$normalize-space = 'true'">
10207
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10208
- </xsl:when>
10209
- <xsl:otherwise>
10210
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10211
- </xsl:otherwise>
10212
- </xsl:choose>
10213
- </item>
10214
- <xsl:call-template name="split">
10215
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10216
- <xsl:with-param name="sep" select="$sep"/>
10217
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
10218
- </xsl:call-template>
10552
+ <item>
10553
+ <xsl:choose>
10554
+ <xsl:when test="$normalize-space = 'true'">
10555
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
10556
+ </xsl:when>
10557
+ <xsl:otherwise>
10558
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
10559
+ </xsl:otherwise>
10560
+ </xsl:choose>
10561
+ </item>
10562
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
10563
+ <xsl:call-template name="split">
10564
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
10565
+ <xsl:with-param name="sep" select="$sep"/>
10566
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
10567
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
10568
+ </xsl:call-template>
10219
10569
  </xsl:if>
10220
10570
  </xsl:template><xsl:template name="getDocumentId">
10221
10571
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>