metanorma-itu 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,7 +36,7 @@
36
36
  <item level="1" id="Foreword" display="true">Foreword</item>
37
37
  <item id="term-script" display="false">3.2</item>
38
38
  -->
39
- <xsl:variable name="contents">
39
+ <xsl:variable name="contents_">
40
40
  <contents>
41
41
  <!-- <xsl:apply-templates select="/itu:itu-standard/itu:preface/node()" mode="contents"/> -->
42
42
  <xsl:apply-templates select="/itu:itu-standard/itu:sections/itu:clause[@type='scope']" mode="contents"/> <!-- @id = 'scope' -->
@@ -53,8 +53,12 @@
53
53
 
54
54
  <xsl:apply-templates select="//itu:table" mode="contents"/>
55
55
 
56
+ <xsl:call-template name="processTablesFigures_Contents">
57
+ <xsl:with-param name="always" select="$doctype = 'technical-report' or $doctype = 'technical-paper'"/>
58
+ </xsl:call-template>
56
59
  </contents>
57
60
  </xsl:variable>
61
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
58
62
 
59
63
  <xsl:variable name="doctypeTitle">
60
64
  <xsl:choose>
@@ -973,11 +977,11 @@
973
977
  <xsl:if test="$debug = 'true'">
974
978
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
975
979
  DEBUG
976
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
980
+ contents=<xsl:copy-of select="$contents"/>
977
981
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
978
982
  </xsl:if>
979
983
 
980
- <xsl:if test="xalan:nodeset($contents)//item[@display = 'true'] and $doctype != 'resolution' and $doctype != 'service-publication'">
984
+ <xsl:if test="$contents//item[@display = 'true'] and $doctype != 'resolution' and $doctype != 'service-publication'">
981
985
  <fo:block break-after="page"/>
982
986
  <fo:block-container>
983
987
  <fo:block role="TOC">
@@ -992,7 +996,7 @@
992
996
  </xsl:call-template>
993
997
  </fo:block>
994
998
 
995
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']">
999
+ <xsl:for-each select="$contents//item[@display = 'true']">
996
1000
  <fo:block role="TOCI">
997
1001
  <xsl:if test="@level = 1">
998
1002
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -1045,72 +1049,42 @@
1045
1049
  </fo:block>
1046
1050
  </xsl:for-each>
1047
1051
 
1048
-
1049
- <xsl:if test="$doctype = 'technical-report' or $doctype = 'technical-paper'">
1050
- <xsl:if test="//itu:table[@id and itu:name]">
1051
- <xsl:variable name="title-list-tables">
1052
- <xsl:call-template name="getTitle">
1053
- <xsl:with-param name="name" select="'title-list-tables'"/>
1054
- </xsl:call-template>
1055
- </xsl:variable>
1056
-
1057
- <fo:block space-before="36pt" text-align="center" font-weight="bold" keep-with-next="always">
1058
- <xsl:value-of select="$title-list-tables"/>
1059
- </fo:block>
1052
+
1053
+ <!-- List of Tables -->
1054
+ <xsl:if test="$contents//tables/table">
1055
+ <xsl:call-template name="insertListOf_Title">
1056
+ <xsl:with-param name="title" select="$title-list-tables"/>
1057
+ </xsl:call-template>
1060
1058
  <fo:block margin-top="6pt" text-align="end" font-weight="bold" keep-with-next="always">
1061
1059
  <xsl:call-template name="getLocalizedString">
1062
1060
  <xsl:with-param name="key">Page.sg</xsl:with-param>
1063
1061
  </xsl:call-template>
1064
1062
  </fo:block>
1065
-
1066
1063
  <fo:block-container>
1067
- <xsl:for-each select="//itu:table[@id and itu:name]">
1068
- <fo:block text-align-last="justify" margin-top="6pt" role="TOCI">
1069
- <fo:basic-link internal-destination="{@id}" fox:alt-text="{itu:name}">
1070
- <xsl:apply-templates select="itu:name" mode="contents"/>
1071
- <fo:inline keep-together.within-line="always">
1072
- <fo:leader leader-pattern="dots"/>
1073
- <fo:page-number-citation ref-id="{@id}"/>
1074
- </fo:inline>
1075
- </fo:basic-link>
1076
- </fo:block>
1064
+ <xsl:for-each select="$contents//tables/table">
1065
+ <xsl:call-template name="insertListOf_Item"/>
1077
1066
  </xsl:for-each>
1078
- </fo:block-container>
1067
+ </fo:block-container>
1079
1068
  </xsl:if>
1080
-
1081
- <xsl:if test="//itu:figure[@id and itu:name]">
1082
- <xsl:variable name="title-list-figures">
1083
- <xsl:call-template name="getTitle">
1084
- <xsl:with-param name="name" select="'title-list-figures'"/>
1085
- </xsl:call-template>
1086
- </xsl:variable>
1087
-
1088
-
1089
- <fo:block space-before="36pt" text-align="center" font-weight="bold" keep-with-next="always">
1090
- <xsl:value-of select="$title-list-figures"/>
1091
- </fo:block>
1069
+
1070
+ <!-- List of Figures -->
1071
+ <xsl:if test="$contents//figures/figure">
1072
+ <xsl:call-template name="insertListOf_Title">
1073
+ <xsl:with-param name="title" select="$title-list-figures"/>
1074
+ </xsl:call-template>
1092
1075
  <fo:block margin-top="6pt" text-align="end" font-weight="bold" keep-with-next="always">
1093
1076
  <xsl:call-template name="getLocalizedString">
1094
1077
  <xsl:with-param name="key">Page.sg</xsl:with-param>
1095
1078
  </xsl:call-template>
1096
1079
  </fo:block>
1097
-
1098
1080
  <fo:block-container>
1099
- <xsl:for-each select="//itu:figure[@id and itu:name]">
1100
- <fo:block text-align-last="justify" margin-top="6pt" role="TOCI">
1101
- <fo:basic-link internal-destination="{@id}" fox:alt-text="{itu:name}">
1102
- <xsl:apply-templates select="itu:name" mode="contents"/>
1103
- <fo:inline keep-together.within-line="always">
1104
- <fo:leader leader-pattern="dots"/>
1105
- <fo:page-number-citation ref-id="{@id}"/>
1106
- </fo:inline>
1107
- </fo:basic-link>
1108
- </fo:block>
1081
+ <xsl:for-each select="$contents//figures/figure">
1082
+ <xsl:call-template name="insertListOf_Item"/>
1109
1083
  </xsl:for-each>
1110
- </fo:block-container>
1084
+ </fo:block-container>
1111
1085
  </xsl:if>
1112
- </xsl:if>
1113
- </fo:block>
1086
+
1087
+ </fo:block>
1114
1088
  </fo:block-container>
1115
1089
  </xsl:if>
1116
1090
 
@@ -1208,6 +1182,28 @@
1208
1182
  </fo:root>
1209
1183
  </xsl:template>
1210
1184
 
1185
+ <xsl:template name="insertListOf_Title">
1186
+ <xsl:param name="title"/>
1187
+ <fo:block space-before="36pt" text-align="center" font-weight="bold" keep-with-next="always">
1188
+ <xsl:value-of select="$title"/>
1189
+ </fo:block>
1190
+ </xsl:template>
1191
+
1192
+ <xsl:template name="insertListOf_Item">
1193
+ <fo:block text-align-last="justify" margin-top="6pt" role="TOCI">
1194
+ <fo:basic-link internal-destination="{@id}">
1195
+ <xsl:call-template name="setAltText">
1196
+ <xsl:with-param name="value" select="@alt-text"/>
1197
+ </xsl:call-template>
1198
+ <xsl:apply-templates select="." mode="contents"/>
1199
+ <fo:inline keep-together.within-line="always">
1200
+ <fo:leader leader-pattern="dots"/>
1201
+ <fo:page-number-citation ref-id="{@id}"/>
1202
+ </fo:inline>
1203
+ </fo:basic-link>
1204
+ </fo:block>
1205
+ </xsl:template>
1206
+
1211
1207
  <xsl:template match="node()">
1212
1208
  <xsl:apply-templates/>
1213
1209
  </xsl:template>
@@ -2064,7 +2060,7 @@
2064
2060
  </xsl:if>
2065
2061
  </xsl:template>
2066
2062
 
2067
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
2063
+ <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:key name="bibitems" match="*[local-name() = 'bibitem']" use="@id"/><xsl:key name="bibitems_hidden" match="*[local-name() = 'bibitem'][@hidden='true'] | *[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']" use="@id"/><xsl:variable name="lang">
2068
2064
  <xsl:call-template name="getLang"/>
2069
2065
  </xsl:variable><xsl:variable name="pageWidth_">
2070
2066
  210
@@ -2108,7 +2104,7 @@
2108
2104
  <xsl:text>Contents</xsl:text>
2109
2105
 
2110
2106
  </title-toc>
2111
-
2107
+
2112
2108
  <title-descriptors lang="en">Descriptors</title-descriptors>
2113
2109
 
2114
2110
  <title-part lang="en">
@@ -2144,7 +2140,31 @@
2144
2140
  <title-continued lang="en">(continued)</title-continued>
2145
2141
  <title-continued lang="fr">(continué)</title-continued>
2146
2142
 
2147
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
2143
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
2144
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
2145
+ <xsl:value-of select="$toc_table_title"/>
2146
+ <xsl:if test="normalize-space($toc_table_title) = ''">
2147
+ <xsl:call-template name="getTitle">
2148
+ <xsl:with-param name="name" select="'title-list-tables'"/>
2149
+ </xsl:call-template>
2150
+ </xsl:if>
2151
+ </xsl:variable><xsl:variable name="title-list-figures">
2152
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
2153
+ <xsl:value-of select="$toc_figure_title"/>
2154
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
2155
+ <xsl:call-template name="getTitle">
2156
+ <xsl:with-param name="name" select="'title-list-figures'"/>
2157
+ </xsl:call-template>
2158
+ </xsl:if>
2159
+ </xsl:variable><xsl:variable name="title-list-recommendations">
2160
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
2161
+ <xsl:value-of select="$toc_requirement_title"/>
2162
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
2163
+ <xsl:call-template name="getTitle">
2164
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
2165
+ </xsl:call-template>
2166
+ </xsl:if>
2167
+ </xsl:variable><xsl:variable name="bibdata">
2148
2168
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
2149
2169
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
2150
2170
  </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">
@@ -3358,6 +3378,30 @@
3358
3378
  <xsl:sort select="@displayorder" data-type="number"/>
3359
3379
  <xsl:apply-templates select="." mode="contents"/>
3360
3380
  </xsl:for-each>
3381
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
3382
+ <xsl:param name="always"/>
3383
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3384
+ <xsl:call-template name="processTables_Contents"/>
3385
+ </xsl:if>
3386
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3387
+ <xsl:call-template name="processFigures_Contents"/>
3388
+ </xsl:if>
3389
+ </xsl:template><xsl:template name="processTables_Contents">
3390
+ <tables>
3391
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
3392
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
3393
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3394
+ </table>
3395
+ </xsl:for-each>
3396
+ </tables>
3397
+ </xsl:template><xsl:template name="processFigures_Contents">
3398
+ <figures>
3399
+ <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) != '']">
3400
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
3401
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3402
+ </figure>
3403
+ </xsl:for-each>
3404
+ </figures>
3361
3405
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3362
3406
  <xsl:for-each select="/*/*[local-name()='preface']/*">
3363
3407
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -4197,37 +4241,7 @@
4197
4241
 
4198
4242
  <!-- list of footnotes to calculate actual footnotes number -->
4199
4243
  <xsl:variable name="p_fn_">
4200
- <xsl:choose>
4201
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4202
- <fn gen_id="{generate-id(.)}">
4203
- <xsl:copy-of select="@*"/>
4204
- <xsl:copy-of select="node()"/>
4205
- </fn>
4206
- </xsl:when>
4207
- <xsl:otherwise>
4208
- <!-- itetation for:
4209
- footnotes in bibdata/title
4210
- footnotes in bibliography
4211
- footnotes in document's body (except table's head/body/foot and figure text)
4212
- -->
4213
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4214
- <fn gen_id="{generate-id(.)}">
4215
- <xsl:copy-of select="@*"/>
4216
- <xsl:copy-of select="node()"/>
4217
- </fn>
4218
- </xsl:for-each>
4219
- <xsl:for-each 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']/*">
4220
- <xsl:sort select="@displayorder" data-type="number"/>
4221
- <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])]">
4222
- <!-- copy unique fn -->
4223
- <fn gen_id="{generate-id(.)}">
4224
- <xsl:copy-of select="@*"/>
4225
- <xsl:copy-of select="node()"/>
4226
- </fn>
4227
- </xsl:for-each>
4228
- </xsl:for-each>
4229
- </xsl:otherwise>
4230
- </xsl:choose>
4244
+ <xsl:call-template name="get_fn_list"/>
4231
4245
  </xsl:variable>
4232
4246
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
4233
4247
 
@@ -4292,6 +4306,38 @@
4292
4306
  <xsl:copy-of select="$footnote_inline"/>
4293
4307
  </xsl:otherwise>
4294
4308
  </xsl:choose>
4309
+ </xsl:template><xsl:template name="get_fn_list">
4310
+ <xsl:choose>
4311
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4312
+ <fn gen_id="{generate-id(.)}">
4313
+ <xsl:copy-of select="@*"/>
4314
+ <xsl:copy-of select="node()"/>
4315
+ </fn>
4316
+ </xsl:when>
4317
+ <xsl:otherwise>
4318
+ <!-- itetation for:
4319
+ footnotes in bibdata/title
4320
+ footnotes in bibliography
4321
+ footnotes in document's body (except table's head/body/foot and figure text)
4322
+ -->
4323
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4324
+ <fn gen_id="{generate-id(.)}">
4325
+ <xsl:copy-of select="@*"/>
4326
+ <xsl:copy-of select="node()"/>
4327
+ </fn>
4328
+ </xsl:for-each>
4329
+ <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']/*">
4330
+ <xsl:sort select="@displayorder" data-type="number"/>
4331
+ <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])]">
4332
+ <!-- copy unique fn -->
4333
+ <fn gen_id="{generate-id(.)}">
4334
+ <xsl:copy-of select="@*"/>
4335
+ <xsl:copy-of select="node()"/>
4336
+ </fn>
4337
+ </xsl:for-each>
4338
+ </xsl:for-each>
4339
+ </xsl:otherwise>
4340
+ </xsl:choose>
4295
4341
  </xsl:template><xsl:template name="table_fn_display">
4296
4342
  <xsl:variable name="references">
4297
4343
 
@@ -4469,7 +4515,7 @@
4469
4515
  </fo:inline>
4470
4516
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
4471
4517
  <fo:inline><xsl:value-of select="."/></fo:inline>
4472
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
4518
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
4473
4519
  <fo:inline>
4474
4520
  <xsl:apply-templates/>
4475
4521
  </fo:inline>
@@ -6179,13 +6225,14 @@
6179
6225
  <xsl:apply-templates mode="bookmarks"/>
6180
6226
  </xsl:template><xsl:template name="addBookmarks">
6181
6227
  <xsl:param name="contents"/>
6182
- <xsl:if test="xalan:nodeset($contents)//item">
6228
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6229
+ <xsl:if test="$contents_nodes//item">
6183
6230
  <fo:bookmark-tree>
6184
6231
  <xsl:choose>
6185
- <xsl:when test="xalan:nodeset($contents)/doc">
6232
+ <xsl:when test="$contents_nodes/doc">
6186
6233
  <xsl:choose>
6187
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
6188
- <xsl:for-each select="xalan:nodeset($contents)/doc">
6234
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
6235
+ <xsl:for-each select="$contents_nodes/doc">
6189
6236
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6190
6237
  <xsl:if test="@bundle = 'true'">
6191
6238
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -6236,7 +6283,7 @@
6236
6283
  </xsl:for-each>
6237
6284
  </xsl:when>
6238
6285
  <xsl:otherwise>
6239
- <xsl:for-each select="xalan:nodeset($contents)/doc">
6286
+ <xsl:for-each select="$contents_nodes/doc">
6240
6287
 
6241
6288
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
6242
6289
 
@@ -6254,25 +6301,36 @@
6254
6301
  </xsl:choose>
6255
6302
  </xsl:when>
6256
6303
  <xsl:otherwise>
6257
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
6304
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
6305
+
6306
+ <xsl:call-template name="insertFigureBookmarks">
6307
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6308
+ </xsl:call-template>
6309
+
6310
+ <xsl:call-template name="insertTableBookmarks">
6311
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6312
+ <xsl:with-param name="lang" select="@lang"/>
6313
+ </xsl:call-template>
6314
+
6258
6315
  </xsl:otherwise>
6259
6316
  </xsl:choose>
6260
6317
 
6318
+
6261
6319
 
6262
6320
 
6263
6321
 
6264
6322
 
6265
-
6266
-
6323
+
6267
6324
 
6268
6325
  </fo:bookmark-tree>
6269
6326
  </xsl:if>
6270
6327
  </xsl:template><xsl:template name="insertFigureBookmarks">
6271
6328
  <xsl:param name="contents"/>
6272
- <xsl:if test="xalan:nodeset($contents)/figure">
6273
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
6329
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6330
+ <xsl:if test="$contents_nodes/figure">
6331
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
6274
6332
  <fo:bookmark-title>Figures</fo:bookmark-title>
6275
- <xsl:for-each select="xalan:nodeset($contents)/figure">
6333
+ <xsl:for-each select="$contents_nodes/figure">
6276
6334
  <fo:bookmark internal-destination="{@id}">
6277
6335
  <fo:bookmark-title>
6278
6336
  <xsl:value-of select="normalize-space(title)"/>
@@ -6281,18 +6339,40 @@
6281
6339
  </xsl:for-each>
6282
6340
  </fo:bookmark>
6283
6341
  </xsl:if>
6342
+
6343
+
6344
+ <xsl:if test="$contents_nodes//figures/figure">
6345
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6346
+
6347
+
6348
+
6349
+ <xsl:variable name="bookmark-title">
6350
+
6351
+ <xsl:value-of select="$title-list-figures"/>
6352
+
6353
+ </xsl:variable>
6354
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
6355
+ <xsl:for-each select="$contents_nodes//figures/figure">
6356
+ <fo:bookmark internal-destination="{@id}">
6357
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6358
+ </fo:bookmark>
6359
+ </xsl:for-each>
6360
+ </fo:bookmark>
6361
+ </xsl:if>
6362
+
6284
6363
  </xsl:template><xsl:template name="insertTableBookmarks">
6285
6364
  <xsl:param name="contents"/>
6286
6365
  <xsl:param name="lang"/>
6287
- <xsl:if test="xalan:nodeset($contents)/table">
6288
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
6366
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6367
+ <xsl:if test="$contents_nodes/table">
6368
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
6289
6369
  <fo:bookmark-title>
6290
6370
  <xsl:choose>
6291
6371
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
6292
6372
  <xsl:otherwise>Tables</xsl:otherwise>
6293
6373
  </xsl:choose>
6294
6374
  </fo:bookmark-title>
6295
- <xsl:for-each select="xalan:nodeset($contents)/table">
6375
+ <xsl:for-each select="$contents_nodes/table">
6296
6376
  <fo:bookmark internal-destination="{@id}">
6297
6377
  <fo:bookmark-title>
6298
6378
  <xsl:value-of select="normalize-space(title)"/>
@@ -6301,6 +6381,29 @@
6301
6381
  </xsl:for-each>
6302
6382
  </fo:bookmark>
6303
6383
  </xsl:if>
6384
+
6385
+
6386
+ <xsl:if test="$contents_nodes//tables/table">
6387
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6388
+
6389
+
6390
+
6391
+ <xsl:variable name="bookmark-title">
6392
+
6393
+ <xsl:value-of select="$title-list-tables"/>
6394
+
6395
+ </xsl:variable>
6396
+
6397
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
6398
+
6399
+ <xsl:for-each select="$contents_nodes//tables/table">
6400
+ <fo:bookmark internal-destination="{@id}">
6401
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6402
+ </fo:bookmark>
6403
+ </xsl:for-each>
6404
+ </fo:bookmark>
6405
+ </xsl:if>
6406
+
6304
6407
  </xsl:template><xsl:template name="getLangVersion">
6305
6408
  <xsl:param name="lang"/>
6306
6409
  <xsl:param name="doctype" select="''"/>
@@ -6957,6 +7060,8 @@
6957
7060
  </xsl:otherwise>
6958
7061
  </xsl:choose> -->
6959
7062
  </fo:block>
7063
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
7064
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6960
7065
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6961
7066
  <xsl:if test="normalize-space() != ''">
6962
7067
  <xsl:value-of select="."/>
@@ -7031,26 +7136,11 @@
7031
7136
  </xsl:template><xsl:template match="*[local-name() = 'author']">
7032
7137
  <xsl:text>— </xsl:text>
7033
7138
  <xsl:apply-templates/>
7034
- </xsl:template><xsl:variable name="bibitem_hidden_">
7035
- <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
7036
- <xsl:copy-of select="."/>
7037
- </xsl:for-each>
7038
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
7039
- <xsl:copy-of select="."/>
7040
- </xsl:for-each>
7041
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
7042
-
7043
- <xsl:variable name="bibitemid">
7044
- <xsl:choose>
7045
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
7046
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
7047
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
7048
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
7049
- </xsl:choose>
7050
- </xsl:variable>
7051
-
7139
+ </xsl:template><xsl:template match="*[local-name() = 'eref']">
7140
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
7141
+ <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
7052
7142
  <xsl:choose>
7053
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
7143
+ <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) -->
7054
7144
  <fo:inline xsl:use-attribute-sets="eref-style">
7055
7145
  <xsl:if test="@type = 'footnote'">
7056
7146
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -7064,8 +7154,8 @@
7064
7154
  <xsl:variable name="text" select="normalize-space()"/>
7065
7155
 
7066
7156
 
7067
-
7068
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
7157
+
7158
+ <fo:basic-link fox:alt-text="{@citeas}">
7069
7159
  <xsl:if test="normalize-space(@citeas) = ''">
7070
7160
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
7071
7161
  </xsl:if>
@@ -7075,14 +7165,21 @@
7075
7165
 
7076
7166
  </xsl:if>
7077
7167
 
7078
-
7168
+ <xsl:choose>
7169
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
7170
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
7171
+ </xsl:when>
7172
+ <xsl:otherwise>
7173
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
7174
+ </xsl:otherwise>
7175
+ </xsl:choose>
7079
7176
 
7080
7177
  <xsl:apply-templates/>
7081
7178
  </fo:basic-link>
7082
-
7179
+
7083
7180
  </fo:inline>
7084
7181
  </xsl:when>
7085
- <xsl:otherwise>
7182
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7086
7183
  <fo:inline><xsl:apply-templates/></fo:inline>
7087
7184
  </xsl:otherwise>
7088
7185
  </xsl:choose>
@@ -7843,23 +7940,45 @@
7843
7940
  <xsl:apply-templates/>
7844
7941
  </fo:inline>
7845
7942
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7943
+
7944
+ <!-- list of footnotes to calculate actual footnotes number -->
7945
+ <xsl:variable name="p_fn_">
7946
+ <xsl:call-template name="get_fn_list"/>
7947
+ </xsl:variable>
7948
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7949
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7950
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7951
+ <!-- fn sequence number in document -->
7952
+ <xsl:variable name="current_fn_number">
7953
+ <xsl:choose>
7954
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7955
+ <xsl:otherwise>
7956
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7957
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7958
+ </xsl:otherwise>
7959
+ </xsl:choose>
7960
+ </xsl:variable>
7846
7961
  <fo:footnote>
7847
7962
  <xsl:variable name="number">
7848
7963
 
7849
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7964
+ <xsl:value-of select="$current_fn_number"/>
7850
7965
 
7851
7966
  </xsl:variable>
7967
+
7968
+ <xsl:variable name="current_fn_number_text">
7969
+ <xsl:value-of select="$number"/>
7970
+
7971
+ </xsl:variable>
7972
+
7852
7973
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7853
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
7854
- <xsl:value-of select="$number"/>
7855
-
7974
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7975
+ <xsl:value-of select="$current_fn_number_text"/>
7856
7976
  </fo:basic-link>
7857
7977
  </fo:inline>
7858
7978
  <fo:footnote-body>
7859
7979
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
7860
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7861
- <xsl:value-of select="$number"/>
7862
-
7980
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7981
+ <xsl:value-of select="$current_fn_number_text"/>
7863
7982
  </fo:inline>
7864
7983
  <xsl:apply-templates/>
7865
7984
  </fo:block>
@@ -8105,6 +8224,78 @@
8105
8224
  <xsl:apply-templates/>
8106
8225
  </fo:block>
8107
8226
 
8227
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
8228
+ <xsl:copy>
8229
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
8230
+ </xsl:copy>
8231
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
8232
+ <xsl:copy>
8233
+ <xsl:copy-of select="@*"/>
8234
+
8235
+ <xsl:variable name="nodes_preface_">
8236
+ <xsl:for-each select="*">
8237
+ <node id="{@id}"/>
8238
+ </xsl:for-each>
8239
+ </xsl:variable>
8240
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
8241
+
8242
+ <xsl:for-each select="*">
8243
+ <xsl:sort select="@displayorder" data-type="number"/>
8244
+
8245
+ <!-- process Section's title -->
8246
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8247
+ <xsl:if test="$preceding-sibling_id != ''">
8248
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8249
+ </xsl:if>
8250
+
8251
+ <xsl:choose>
8252
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8253
+ <xsl:otherwise>
8254
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8255
+ </xsl:otherwise>
8256
+ </xsl:choose>
8257
+
8258
+ </xsl:for-each>
8259
+ </xsl:copy>
8260
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
8261
+ <xsl:copy>
8262
+ <xsl:copy-of select="@*"/>
8263
+
8264
+ <xsl:variable name="nodes_sections_">
8265
+ <xsl:for-each select="*">
8266
+ <node id="{@id}"/>
8267
+ </xsl:for-each>
8268
+ </xsl:variable>
8269
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
8270
+
8271
+ <!-- move section 'Normative references' inside 'sections' -->
8272
+ <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']]">
8273
+ <xsl:sort select="@displayorder" data-type="number"/>
8274
+
8275
+ <!-- process Section's title -->
8276
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8277
+ <xsl:if test="$preceding-sibling_id != ''">
8278
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8279
+ </xsl:if>
8280
+
8281
+ <xsl:choose>
8282
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8283
+ <xsl:otherwise>
8284
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8285
+ </xsl:otherwise>
8286
+ </xsl:choose>
8287
+
8288
+ </xsl:for-each>
8289
+ </xsl:copy>
8290
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
8291
+ <xsl:copy>
8292
+ <xsl:copy-of select="@*"/>
8293
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
8294
+ <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
8295
+ <xsl:sort select="@displayorder" data-type="number"/>
8296
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8297
+ </xsl:for-each>
8298
+ </xsl:copy>
8108
8299
  </xsl:template><xsl:template name="convertDate">
8109
8300
  <xsl:param name="date"/>
8110
8301
  <xsl:param name="format" select="'short'"/>