metanorma-bipm 2.0.4 → 2.0.5

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/>
@@ -3841,7 +3916,7 @@
3841
3916
  </xsl:template>
3842
3917
 
3843
3918
 
3844
- <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">
3919
+ <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">
3845
3920
  <xsl:call-template name="getLang"/>
3846
3921
  </xsl:variable><xsl:variable name="pageWidth_">
3847
3922
  210
@@ -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"/>
@@ -6023,37 +6146,7 @@
6023
6146
 
6024
6147
  <!-- list of footnotes to calculate actual footnotes number -->
6025
6148
  <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>
6149
+ <xsl:call-template name="get_fn_list"/>
6057
6150
  </xsl:variable>
6058
6151
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6059
6152
 
@@ -6114,6 +6207,38 @@
6114
6207
  <xsl:copy-of select="$footnote_inline"/>
6115
6208
  </xsl:otherwise>
6116
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>
6117
6242
  </xsl:template><xsl:template name="table_fn_display">
6118
6243
  <xsl:variable name="references">
6119
6244
 
@@ -6293,7 +6418,7 @@
6293
6418
  </fo:inline>
6294
6419
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
6295
6420
  <fo:inline><xsl:value-of select="."/></fo:inline>
6296
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
6421
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
6297
6422
  <fo:inline>
6298
6423
  <xsl:apply-templates/>
6299
6424
  </fo:inline>
@@ -8026,13 +8151,14 @@
8026
8151
  <xsl:apply-templates mode="bookmarks"/>
8027
8152
  </xsl:template><xsl:template name="addBookmarks">
8028
8153
  <xsl:param name="contents"/>
8029
- <xsl:if test="xalan:nodeset($contents)//item">
8154
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
8155
+ <xsl:if test="$contents_nodes//item">
8030
8156
  <fo:bookmark-tree>
8031
8157
  <xsl:choose>
8032
- <xsl:when test="xalan:nodeset($contents)/doc">
8158
+ <xsl:when test="$contents_nodes/doc">
8033
8159
  <xsl:choose>
8034
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
8035
- <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">
8036
8162
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
8037
8163
  <xsl:if test="@bundle = 'true'">
8038
8164
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -8083,7 +8209,7 @@
8083
8209
  </xsl:for-each>
8084
8210
  </xsl:when>
8085
8211
  <xsl:otherwise>
8086
- <xsl:for-each select="xalan:nodeset($contents)/doc">
8212
+ <xsl:for-each select="$contents_nodes/doc">
8087
8213
 
8088
8214
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
8089
8215
 
@@ -8101,25 +8227,36 @@
8101
8227
  </xsl:choose>
8102
8228
  </xsl:when>
8103
8229
  <xsl:otherwise>
8104
- <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
+
8105
8241
  </xsl:otherwise>
8106
8242
  </xsl:choose>
8107
8243
 
8244
+
8108
8245
 
8109
8246
 
8110
8247
 
8111
8248
 
8112
-
8113
-
8249
+
8114
8250
 
8115
8251
  </fo:bookmark-tree>
8116
8252
  </xsl:if>
8117
8253
  </xsl:template><xsl:template name="insertFigureBookmarks">
8118
8254
  <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">
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">
8121
8258
  <fo:bookmark-title>Figures</fo:bookmark-title>
8122
- <xsl:for-each select="xalan:nodeset($contents)/figure">
8259
+ <xsl:for-each select="$contents_nodes/figure">
8123
8260
  <fo:bookmark internal-destination="{@id}">
8124
8261
  <fo:bookmark-title>
8125
8262
  <xsl:value-of select="normalize-space(title)"/>
@@ -8128,18 +8265,40 @@
8128
8265
  </xsl:for-each>
8129
8266
  </fo:bookmark>
8130
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
+
8131
8289
  </xsl:template><xsl:template name="insertTableBookmarks">
8132
8290
  <xsl:param name="contents"/>
8133
8291
  <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">
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">
8136
8295
  <fo:bookmark-title>
8137
8296
  <xsl:choose>
8138
8297
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
8139
8298
  <xsl:otherwise>Tables</xsl:otherwise>
8140
8299
  </xsl:choose>
8141
8300
  </fo:bookmark-title>
8142
- <xsl:for-each select="xalan:nodeset($contents)/table">
8301
+ <xsl:for-each select="$contents_nodes/table">
8143
8302
  <fo:bookmark internal-destination="{@id}">
8144
8303
  <fo:bookmark-title>
8145
8304
  <xsl:value-of select="normalize-space(title)"/>
@@ -8148,6 +8307,29 @@
8148
8307
  </xsl:for-each>
8149
8308
  </fo:bookmark>
8150
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
+
8151
8333
  </xsl:template><xsl:template name="getLangVersion">
8152
8334
  <xsl:param name="lang"/>
8153
8335
  <xsl:param name="doctype" select="''"/>
@@ -8818,6 +9000,8 @@
8818
9000
  </xsl:otherwise>
8819
9001
  </xsl:choose> -->
8820
9002
  </fo:block>
9003
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
9004
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
8821
9005
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
8822
9006
  <xsl:if test="normalize-space() != ''">
8823
9007
  <xsl:value-of select="."/>
@@ -8892,26 +9076,11 @@
8892
9076
  </xsl:template><xsl:template match="*[local-name() = 'author']">
8893
9077
  <xsl:text>— </xsl:text>
8894
9078
  <xsl:apply-templates/>
8895
- </xsl:template><xsl:variable name="bibitem_hidden_">
8896
- <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
8897
- <xsl:copy-of select="."/>
8898
- </xsl:for-each>
8899
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
8900
- <xsl:copy-of select="."/>
8901
- </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
-
9079
+ </xsl:template><xsl:template match="*[local-name() = 'eref']">
9080
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
9081
+ <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
8913
9082
  <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 -->
9083
+ <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) -->
8915
9084
  <fo:inline xsl:use-attribute-sets="eref-style">
8916
9085
  <xsl:if test="@type = 'footnote'">
8917
9086
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -8925,8 +9094,8 @@
8925
9094
  <xsl:variable name="text" select="normalize-space()"/>
8926
9095
 
8927
9096
 
8928
-
8929
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
9097
+
9098
+ <fo:basic-link fox:alt-text="{@citeas}">
8930
9099
  <xsl:if test="normalize-space(@citeas) = ''">
8931
9100
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
8932
9101
  </xsl:if>
@@ -8945,14 +9114,21 @@
8945
9114
 
8946
9115
  </xsl:if>
8947
9116
 
8948
-
9117
+ <xsl:choose>
9118
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
9119
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
9120
+ </xsl:when>
9121
+ <xsl:otherwise>
9122
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
9123
+ </xsl:otherwise>
9124
+ </xsl:choose>
8949
9125
 
8950
9126
  <xsl:apply-templates/>
8951
9127
  </fo:basic-link>
8952
-
9128
+
8953
9129
  </fo:inline>
8954
9130
  </xsl:when>
8955
- <xsl:otherwise>
9131
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
8956
9132
  <fo:inline><xsl:apply-templates/></fo:inline>
8957
9133
  </xsl:otherwise>
8958
9134
  </xsl:choose>
@@ -9687,6 +9863,24 @@
9687
9863
  <xsl:apply-templates/>
9688
9864
  </fo:inline>
9689
9865
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
9866
+
9867
+ <!-- list of footnotes to calculate actual footnotes number -->
9868
+ <xsl:variable name="p_fn_">
9869
+ <xsl:call-template name="get_fn_list"/>
9870
+ </xsl:variable>
9871
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
9872
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
9873
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
9874
+ <!-- fn sequence number in document -->
9875
+ <xsl:variable name="current_fn_number">
9876
+ <xsl:choose>
9877
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
9878
+ <xsl:otherwise>
9879
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
9880
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
9881
+ </xsl:otherwise>
9882
+ </xsl:choose>
9883
+ </xsl:variable>
9690
9884
  <fo:footnote>
9691
9885
  <xsl:variable name="number">
9692
9886
 
@@ -9695,22 +9889,26 @@
9695
9889
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
9696
9890
  </xsl:when>
9697
9891
  <xsl:otherwise>
9698
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
9892
+ <xsl:value-of select="$current_fn_number"/>
9699
9893
  </xsl:otherwise>
9700
9894
  </xsl:choose>
9701
9895
 
9702
9896
  </xsl:variable>
9897
+
9898
+ <xsl:variable name="current_fn_number_text">
9899
+ <xsl:value-of select="$number"/>
9900
+
9901
+ </xsl:variable>
9902
+
9703
9903
  <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
-
9904
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
9905
+ <xsl:value-of select="$current_fn_number_text"/>
9707
9906
  </fo:basic-link>
9708
9907
  </fo:inline>
9709
9908
  <fo:footnote-body>
9710
9909
  <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
-
9910
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
9911
+ <xsl:value-of select="$current_fn_number_text"/>
9714
9912
  </fo:inline>
9715
9913
  <xsl:apply-templates/>
9716
9914
  </fo:block>
@@ -9956,6 +10154,78 @@
9956
10154
  <xsl:apply-templates/>
9957
10155
  </fo:block>
9958
10156
 
10157
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
10158
+ <xsl:copy>
10159
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
10160
+ </xsl:copy>
10161
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
10162
+ <xsl:copy>
10163
+ <xsl:copy-of select="@*"/>
10164
+
10165
+ <xsl:variable name="nodes_preface_">
10166
+ <xsl:for-each select="*">
10167
+ <node id="{@id}"/>
10168
+ </xsl:for-each>
10169
+ </xsl:variable>
10170
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
10171
+
10172
+ <xsl:for-each select="*">
10173
+ <xsl:sort select="@displayorder" data-type="number"/>
10174
+
10175
+ <!-- process Section's title -->
10176
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
10177
+ <xsl:if test="$preceding-sibling_id != ''">
10178
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
10179
+ </xsl:if>
10180
+
10181
+ <xsl:choose>
10182
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
10183
+ <xsl:otherwise>
10184
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10185
+ </xsl:otherwise>
10186
+ </xsl:choose>
10187
+
10188
+ </xsl:for-each>
10189
+ </xsl:copy>
10190
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
10191
+ <xsl:copy>
10192
+ <xsl:copy-of select="@*"/>
10193
+
10194
+ <xsl:variable name="nodes_sections_">
10195
+ <xsl:for-each select="*">
10196
+ <node id="{@id}"/>
10197
+ </xsl:for-each>
10198
+ </xsl:variable>
10199
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
10200
+
10201
+ <!-- move section 'Normative references' inside 'sections' -->
10202
+ <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']]">
10203
+ <xsl:sort select="@displayorder" data-type="number"/>
10204
+
10205
+ <!-- process Section's title -->
10206
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
10207
+ <xsl:if test="$preceding-sibling_id != ''">
10208
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
10209
+ </xsl:if>
10210
+
10211
+ <xsl:choose>
10212
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
10213
+ <xsl:otherwise>
10214
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10215
+ </xsl:otherwise>
10216
+ </xsl:choose>
10217
+
10218
+ </xsl:for-each>
10219
+ </xsl:copy>
10220
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
10221
+ <xsl:copy>
10222
+ <xsl:copy-of select="@*"/>
10223
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
10224
+ <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
10225
+ <xsl:sort select="@displayorder" data-type="number"/>
10226
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
10227
+ </xsl:for-each>
10228
+ </xsl:copy>
9959
10229
  </xsl:template><xsl:template name="convertDate">
9960
10230
  <xsl:param name="date"/>
9961
10231
  <xsl:param name="format" select="'short'"/>