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.
@@ -91,7 +91,7 @@
91
91
  <item level="1" id="Foreword" display="true">Foreword</item>
92
92
  <item id="term-script" display="false">3.2</item>
93
93
  -->
94
- <xsl:variable name="contents">
94
+ <xsl:variable name="contents_">
95
95
 
96
96
  <xsl:for-each select="//*[contains(local-name(), '-standard')]">
97
97
  <xsl:variable name="lang" select="*[local-name()='bibdata']/*[local-name()='language'][@current = 'true']"/>
@@ -109,11 +109,14 @@
109
109
  <!-- Index -->
110
110
  <!-- <xsl:apply-templates select="//jcgm:clause[@type = 'index']" mode="contents"/> -->
111
111
  <xsl:apply-templates select="//jcgm:indexsect" mode="contents"/>
112
+
113
+ <xsl:call-template name="processTablesFigures_Contents"/>
112
114
  </contents>
113
115
  </doc>
114
116
  </xsl:for-each>
115
117
  </xsl:for-each>
116
118
  </xsl:variable>
119
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
117
120
 
118
121
 
119
122
  <xsl:variable name="indexes">
@@ -365,7 +368,7 @@
365
368
  <xsl:if test="$debug = 'true'">
366
369
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
367
370
  DEBUG
368
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
371
+ contents=<xsl:copy-of select="$contents"/>
369
372
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
370
373
  </xsl:if>
371
374
 
@@ -375,7 +378,7 @@
375
378
  </xsl:call-template>
376
379
  </xsl:variable>
377
380
 
378
- <xsl:for-each select="xalan:nodeset($contents)/doc[@id=$docid]//item[@display = 'true']"> <!-- and not (@type = 'annex') and not (@type = 'references') -->
381
+ <xsl:for-each select="$contents/doc[@id=$docid]//item[@display = 'true']"> <!-- and not (@type = 'annex') and not (@type = 'references') -->
379
382
  <xsl:if test="@type = 'annex' and not(preceding-sibling::item[@display = 'true' and @type = 'annex'])">
380
383
  <fo:block font-size="12pt" space-before="16pt" font-weight="bold" role="TOCI">
381
384
  <xsl:value-of select="$annexes_title"/>
@@ -383,6 +386,27 @@
383
386
  </xsl:if>
384
387
  <xsl:call-template name="print_JCGN_toc_item"/>
385
388
  </xsl:for-each>
389
+
390
+ <!-- List of Tables -->
391
+ <xsl:if test="$contents//tables/table">
392
+ <xsl:call-template name="insertListOf_Title">
393
+ <xsl:with-param name="title" select="$title-list-tables"/>
394
+ </xsl:call-template>
395
+ <xsl:for-each select="$contents//tables/table">
396
+ <xsl:call-template name="insertListOf_Item"/>
397
+ </xsl:for-each>
398
+ </xsl:if>
399
+
400
+ <!-- List of Figures -->
401
+ <xsl:if test="$contents//figures/figure">
402
+ <xsl:call-template name="insertListOf_Title">
403
+ <xsl:with-param name="title" select="$title-list-figures"/>
404
+ </xsl:call-template>
405
+ <xsl:for-each select="$contents//figures/figure">
406
+ <xsl:call-template name="insertListOf_Item"/>
407
+ </xsl:for-each>
408
+ </xsl:if>
409
+
386
410
  </fo:block>
387
411
  </fo:block-container>
388
412
 
@@ -529,6 +553,32 @@
529
553
  </fo:root>
530
554
  </xsl:template>
531
555
 
556
+ <xsl:template name="insertListOf_Title">
557
+ <xsl:param name="title"/>
558
+ <fo:block font-weight="bold" margin-top="12pt" keep-with-next="always">
559
+ <xsl:value-of select="$title"/>
560
+ </fo:block>
561
+ </xsl:template>
562
+
563
+ <xsl:template name="insertListOf_Item">
564
+ <fo:block margin-left="5mm" role="TOCI">
565
+ <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
566
+ <fo:basic-link internal-destination="{@id}">
567
+ <xsl:call-template name="setAltText">
568
+ <xsl:with-param name="value" select="@alt-text"/>
569
+ </xsl:call-template>
570
+ <fo:inline>
571
+ <xsl:apply-templates select="." mode="contents"/>
572
+ </fo:inline>
573
+ <xsl:text> </xsl:text>
574
+ <fo:inline keep-together.within-line="always" font-weight="normal">
575
+ <fo:leader font-size="9pt" leader-pattern="dots"/>
576
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
577
+ </fo:inline>
578
+ </fo:basic-link>
579
+ </fo:block>
580
+ </fo:block>
581
+ </xsl:template>
532
582
 
533
583
  <xsl:template match="node()">
534
584
  <xsl:apply-templates/>
@@ -1710,7 +1760,7 @@
1710
1760
  </fo:block-container>
1711
1761
  </xsl:template>
1712
1762
 
1713
- <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">
1763
+ <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">
1714
1764
  <xsl:call-template name="getLang"/>
1715
1765
  </xsl:variable><xsl:variable name="pageWidth_">
1716
1766
  210
@@ -1754,7 +1804,7 @@
1754
1804
  <xsl:text>Contents</xsl:text>
1755
1805
 
1756
1806
  </title-toc>
1757
-
1807
+
1758
1808
  <title-descriptors lang="en">Descriptors</title-descriptors>
1759
1809
 
1760
1810
  <title-part lang="en">
@@ -1790,7 +1840,31 @@
1790
1840
  <title-continued lang="en">(continued)</title-continued>
1791
1841
  <title-continued lang="fr">(continué)</title-continued>
1792
1842
 
1793
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
1843
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
1844
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
1845
+ <xsl:value-of select="$toc_table_title"/>
1846
+ <xsl:if test="normalize-space($toc_table_title) = ''">
1847
+ <xsl:call-template name="getTitle">
1848
+ <xsl:with-param name="name" select="'title-list-tables'"/>
1849
+ </xsl:call-template>
1850
+ </xsl:if>
1851
+ </xsl:variable><xsl:variable name="title-list-figures">
1852
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
1853
+ <xsl:value-of select="$toc_figure_title"/>
1854
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
1855
+ <xsl:call-template name="getTitle">
1856
+ <xsl:with-param name="name" select="'title-list-figures'"/>
1857
+ </xsl:call-template>
1858
+ </xsl:if>
1859
+ </xsl:variable><xsl:variable name="title-list-recommendations">
1860
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
1861
+ <xsl:value-of select="$toc_requirement_title"/>
1862
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
1863
+ <xsl:call-template name="getTitle">
1864
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
1865
+ </xsl:call-template>
1866
+ </xsl:if>
1867
+ </xsl:variable><xsl:variable name="bibdata">
1794
1868
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1795
1869
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1796
1870
  </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">
@@ -3040,6 +3114,30 @@
3040
3114
  <xsl:sort select="@displayorder" data-type="number"/>
3041
3115
  <xsl:apply-templates select="." mode="contents"/>
3042
3116
  </xsl:for-each>
3117
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
3118
+ <xsl:param name="always"/>
3119
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3120
+ <xsl:call-template name="processTables_Contents"/>
3121
+ </xsl:if>
3122
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
3123
+ <xsl:call-template name="processFigures_Contents"/>
3124
+ </xsl:if>
3125
+ </xsl:template><xsl:template name="processTables_Contents">
3126
+ <tables>
3127
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
3128
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
3129
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3130
+ </table>
3131
+ </xsl:for-each>
3132
+ </tables>
3133
+ </xsl:template><xsl:template name="processFigures_Contents">
3134
+ <figures>
3135
+ <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) != '']">
3136
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
3137
+ <xsl:copy-of select="*[local-name() = 'name']"/>
3138
+ </figure>
3139
+ </xsl:for-each>
3140
+ </figures>
3043
3141
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3044
3142
  <xsl:for-each select="/*/*[local-name()='preface']/*">
3045
3143
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -3890,37 +3988,7 @@
3890
3988
 
3891
3989
  <!-- list of footnotes to calculate actual footnotes number -->
3892
3990
  <xsl:variable name="p_fn_">
3893
- <xsl:choose>
3894
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3895
- <fn gen_id="{generate-id(.)}">
3896
- <xsl:copy-of select="@*"/>
3897
- <xsl:copy-of select="node()"/>
3898
- </fn>
3899
- </xsl:when>
3900
- <xsl:otherwise>
3901
- <!-- itetation for:
3902
- footnotes in bibdata/title
3903
- footnotes in bibliography
3904
- footnotes in document's body (except table's head/body/foot and figure text)
3905
- -->
3906
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3907
- <fn gen_id="{generate-id(.)}">
3908
- <xsl:copy-of select="@*"/>
3909
- <xsl:copy-of select="node()"/>
3910
- </fn>
3911
- </xsl:for-each>
3912
- <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']/*">
3913
- <xsl:sort select="@displayorder" data-type="number"/>
3914
- <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])]">
3915
- <!-- copy unique fn -->
3916
- <fn gen_id="{generate-id(.)}">
3917
- <xsl:copy-of select="@*"/>
3918
- <xsl:copy-of select="node()"/>
3919
- </fn>
3920
- </xsl:for-each>
3921
- </xsl:for-each>
3922
- </xsl:otherwise>
3923
- </xsl:choose>
3991
+ <xsl:call-template name="get_fn_list"/>
3924
3992
  </xsl:variable>
3925
3993
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3926
3994
 
@@ -3981,6 +4049,38 @@
3981
4049
  <xsl:copy-of select="$footnote_inline"/>
3982
4050
  </xsl:otherwise>
3983
4051
  </xsl:choose>
4052
+ </xsl:template><xsl:template name="get_fn_list">
4053
+ <xsl:choose>
4054
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4055
+ <fn gen_id="{generate-id(.)}">
4056
+ <xsl:copy-of select="@*"/>
4057
+ <xsl:copy-of select="node()"/>
4058
+ </fn>
4059
+ </xsl:when>
4060
+ <xsl:otherwise>
4061
+ <!-- itetation for:
4062
+ footnotes in bibdata/title
4063
+ footnotes in bibliography
4064
+ footnotes in document's body (except table's head/body/foot and figure text)
4065
+ -->
4066
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4067
+ <fn gen_id="{generate-id(.)}">
4068
+ <xsl:copy-of select="@*"/>
4069
+ <xsl:copy-of select="node()"/>
4070
+ </fn>
4071
+ </xsl:for-each>
4072
+ <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']/*">
4073
+ <xsl:sort select="@displayorder" data-type="number"/>
4074
+ <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])]">
4075
+ <!-- copy unique fn -->
4076
+ <fn gen_id="{generate-id(.)}">
4077
+ <xsl:copy-of select="@*"/>
4078
+ <xsl:copy-of select="node()"/>
4079
+ </fn>
4080
+ </xsl:for-each>
4081
+ </xsl:for-each>
4082
+ </xsl:otherwise>
4083
+ </xsl:choose>
3984
4084
  </xsl:template><xsl:template name="table_fn_display">
3985
4085
  <xsl:variable name="references">
3986
4086
 
@@ -4157,7 +4257,7 @@
4157
4257
  </fo:inline>
4158
4258
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
4159
4259
  <fo:inline><xsl:value-of select="."/></fo:inline>
4160
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
4260
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
4161
4261
  <fo:inline>
4162
4262
  <xsl:apply-templates/>
4163
4263
  </fo:inline>
@@ -5859,13 +5959,14 @@
5859
5959
  <xsl:apply-templates mode="bookmarks"/>
5860
5960
  </xsl:template><xsl:template name="addBookmarks">
5861
5961
  <xsl:param name="contents"/>
5862
- <xsl:if test="xalan:nodeset($contents)//item">
5962
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5963
+ <xsl:if test="$contents_nodes//item">
5863
5964
  <fo:bookmark-tree>
5864
5965
  <xsl:choose>
5865
- <xsl:when test="xalan:nodeset($contents)/doc">
5966
+ <xsl:when test="$contents_nodes/doc">
5866
5967
  <xsl:choose>
5867
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5868
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5968
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
5969
+ <xsl:for-each select="$contents_nodes/doc">
5869
5970
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5870
5971
  <xsl:if test="@bundle = 'true'">
5871
5972
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -5916,7 +6017,7 @@
5916
6017
  </xsl:for-each>
5917
6018
  </xsl:when>
5918
6019
  <xsl:otherwise>
5919
- <xsl:for-each select="xalan:nodeset($contents)/doc">
6020
+ <xsl:for-each select="$contents_nodes/doc">
5920
6021
 
5921
6022
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5922
6023
 
@@ -5934,25 +6035,36 @@
5934
6035
  </xsl:choose>
5935
6036
  </xsl:when>
5936
6037
  <xsl:otherwise>
5937
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
6038
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
6039
+
6040
+ <xsl:call-template name="insertFigureBookmarks">
6041
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6042
+ </xsl:call-template>
6043
+
6044
+ <xsl:call-template name="insertTableBookmarks">
6045
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6046
+ <xsl:with-param name="lang" select="@lang"/>
6047
+ </xsl:call-template>
6048
+
5938
6049
  </xsl:otherwise>
5939
6050
  </xsl:choose>
5940
6051
 
6052
+
5941
6053
 
5942
6054
 
5943
6055
 
5944
6056
 
5945
-
5946
-
6057
+
5947
6058
 
5948
6059
  </fo:bookmark-tree>
5949
6060
  </xsl:if>
5950
6061
  </xsl:template><xsl:template name="insertFigureBookmarks">
5951
6062
  <xsl:param name="contents"/>
5952
- <xsl:if test="xalan:nodeset($contents)/figure">
5953
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
6063
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6064
+ <xsl:if test="$contents_nodes/figure">
6065
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
5954
6066
  <fo:bookmark-title>Figures</fo:bookmark-title>
5955
- <xsl:for-each select="xalan:nodeset($contents)/figure">
6067
+ <xsl:for-each select="$contents_nodes/figure">
5956
6068
  <fo:bookmark internal-destination="{@id}">
5957
6069
  <fo:bookmark-title>
5958
6070
  <xsl:value-of select="normalize-space(title)"/>
@@ -5961,18 +6073,40 @@
5961
6073
  </xsl:for-each>
5962
6074
  </fo:bookmark>
5963
6075
  </xsl:if>
6076
+
6077
+
6078
+ <xsl:if test="$contents_nodes//figures/figure">
6079
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6080
+
6081
+
6082
+
6083
+ <xsl:variable name="bookmark-title">
6084
+
6085
+ <xsl:value-of select="$title-list-figures"/>
6086
+
6087
+ </xsl:variable>
6088
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
6089
+ <xsl:for-each select="$contents_nodes//figures/figure">
6090
+ <fo:bookmark internal-destination="{@id}">
6091
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6092
+ </fo:bookmark>
6093
+ </xsl:for-each>
6094
+ </fo:bookmark>
6095
+ </xsl:if>
6096
+
5964
6097
  </xsl:template><xsl:template name="insertTableBookmarks">
5965
6098
  <xsl:param name="contents"/>
5966
6099
  <xsl:param name="lang"/>
5967
- <xsl:if test="xalan:nodeset($contents)/table">
5968
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
6100
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6101
+ <xsl:if test="$contents_nodes/table">
6102
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
5969
6103
  <fo:bookmark-title>
5970
6104
  <xsl:choose>
5971
6105
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
5972
6106
  <xsl:otherwise>Tables</xsl:otherwise>
5973
6107
  </xsl:choose>
5974
6108
  </fo:bookmark-title>
5975
- <xsl:for-each select="xalan:nodeset($contents)/table">
6109
+ <xsl:for-each select="$contents_nodes/table">
5976
6110
  <fo:bookmark internal-destination="{@id}">
5977
6111
  <fo:bookmark-title>
5978
6112
  <xsl:value-of select="normalize-space(title)"/>
@@ -5981,6 +6115,29 @@
5981
6115
  </xsl:for-each>
5982
6116
  </fo:bookmark>
5983
6117
  </xsl:if>
6118
+
6119
+
6120
+ <xsl:if test="$contents_nodes//tables/table">
6121
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6122
+
6123
+
6124
+
6125
+ <xsl:variable name="bookmark-title">
6126
+
6127
+ <xsl:value-of select="$title-list-tables"/>
6128
+
6129
+ </xsl:variable>
6130
+
6131
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
6132
+
6133
+ <xsl:for-each select="$contents_nodes//tables/table">
6134
+ <fo:bookmark internal-destination="{@id}">
6135
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6136
+ </fo:bookmark>
6137
+ </xsl:for-each>
6138
+ </fo:bookmark>
6139
+ </xsl:if>
6140
+
5984
6141
  </xsl:template><xsl:template name="getLangVersion">
5985
6142
  <xsl:param name="lang"/>
5986
6143
  <xsl:param name="doctype" select="''"/>
@@ -6642,6 +6799,8 @@
6642
6799
  </xsl:otherwise>
6643
6800
  </xsl:choose> -->
6644
6801
  </fo:block>
6802
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6803
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6645
6804
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6646
6805
  <xsl:if test="normalize-space() != ''">
6647
6806
  <xsl:value-of select="."/>
@@ -6726,26 +6885,11 @@
6726
6885
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6727
6886
  <xsl:text>— </xsl:text>
6728
6887
  <xsl:apply-templates/>
6729
- </xsl:template><xsl:variable name="bibitem_hidden_">
6730
- <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6731
- <xsl:copy-of select="."/>
6732
- </xsl:for-each>
6733
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6734
- <xsl:copy-of select="."/>
6735
- </xsl:for-each>
6736
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6737
-
6738
- <xsl:variable name="bibitemid">
6739
- <xsl:choose>
6740
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6741
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6742
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6743
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6744
- </xsl:choose>
6745
- </xsl:variable>
6746
-
6888
+ </xsl:template><xsl:template match="*[local-name() = 'eref']">
6889
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6890
+ <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
6747
6891
  <xsl:choose>
6748
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
6892
+ <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) -->
6749
6893
  <fo:inline xsl:use-attribute-sets="eref-style">
6750
6894
  <xsl:if test="@type = 'footnote'">
6751
6895
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6759,8 +6903,8 @@
6759
6903
  <xsl:variable name="text" select="normalize-space()"/>
6760
6904
 
6761
6905
 
6762
-
6763
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6906
+
6907
+ <fo:basic-link fox:alt-text="{@citeas}">
6764
6908
  <xsl:if test="normalize-space(@citeas) = ''">
6765
6909
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6766
6910
  </xsl:if>
@@ -6770,14 +6914,21 @@
6770
6914
 
6771
6915
  </xsl:if>
6772
6916
 
6773
-
6917
+ <xsl:choose>
6918
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6919
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6920
+ </xsl:when>
6921
+ <xsl:otherwise>
6922
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6923
+ </xsl:otherwise>
6924
+ </xsl:choose>
6774
6925
 
6775
6926
  <xsl:apply-templates/>
6776
6927
  </fo:basic-link>
6777
-
6928
+
6778
6929
  </fo:inline>
6779
6930
  </xsl:when>
6780
- <xsl:otherwise>
6931
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6781
6932
  <fo:inline><xsl:apply-templates/></fo:inline>
6782
6933
  </xsl:otherwise>
6783
6934
  </xsl:choose>
@@ -7514,27 +7665,47 @@
7514
7665
  <xsl:apply-templates/>
7515
7666
  </fo:inline>
7516
7667
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7668
+
7669
+ <!-- list of footnotes to calculate actual footnotes number -->
7670
+ <xsl:variable name="p_fn_">
7671
+ <xsl:call-template name="get_fn_list"/>
7672
+ </xsl:variable>
7673
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7674
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7675
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7676
+ <!-- fn sequence number in document -->
7677
+ <xsl:variable name="current_fn_number">
7678
+ <xsl:choose>
7679
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7680
+ <xsl:otherwise>
7681
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7682
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7683
+ </xsl:otherwise>
7684
+ </xsl:choose>
7685
+ </xsl:variable>
7517
7686
  <fo:footnote>
7518
7687
  <xsl:variable name="number">
7519
7688
 
7520
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7689
+ <xsl:value-of select="$current_fn_number"/>
7521
7690
 
7522
7691
  </xsl:variable>
7523
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7524
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
7525
- <xsl:value-of select="$number"/>
7526
-
7692
+
7693
+ <xsl:variable name="current_fn_number_text">
7694
+ <xsl:value-of select="$number"/>
7695
+
7527
7696
  <xsl:text>)</xsl:text>
7528
7697
 
7698
+ </xsl:variable>
7699
+
7700
+ <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7701
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7702
+ <xsl:value-of select="$current_fn_number_text"/>
7529
7703
  </fo:basic-link>
7530
7704
  </fo:inline>
7531
7705
  <fo:footnote-body>
7532
7706
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
7533
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7534
- <xsl:value-of select="$number"/>
7535
-
7536
- <xsl:text>)</xsl:text>
7537
-
7707
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7708
+ <xsl:value-of select="$current_fn_number_text"/>
7538
7709
  </fo:inline>
7539
7710
  <xsl:apply-templates/>
7540
7711
  </fo:block>
@@ -7774,6 +7945,78 @@
7774
7945
  <xsl:apply-templates/>
7775
7946
  </fo:block>
7776
7947
 
7948
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7949
+ <xsl:copy>
7950
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7951
+ </xsl:copy>
7952
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7953
+ <xsl:copy>
7954
+ <xsl:copy-of select="@*"/>
7955
+
7956
+ <xsl:variable name="nodes_preface_">
7957
+ <xsl:for-each select="*">
7958
+ <node id="{@id}"/>
7959
+ </xsl:for-each>
7960
+ </xsl:variable>
7961
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7962
+
7963
+ <xsl:for-each select="*">
7964
+ <xsl:sort select="@displayorder" data-type="number"/>
7965
+
7966
+ <!-- process Section's title -->
7967
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7968
+ <xsl:if test="$preceding-sibling_id != ''">
7969
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7970
+ </xsl:if>
7971
+
7972
+ <xsl:choose>
7973
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7974
+ <xsl:otherwise>
7975
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7976
+ </xsl:otherwise>
7977
+ </xsl:choose>
7978
+
7979
+ </xsl:for-each>
7980
+ </xsl:copy>
7981
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7982
+ <xsl:copy>
7983
+ <xsl:copy-of select="@*"/>
7984
+
7985
+ <xsl:variable name="nodes_sections_">
7986
+ <xsl:for-each select="*">
7987
+ <node id="{@id}"/>
7988
+ </xsl:for-each>
7989
+ </xsl:variable>
7990
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7991
+
7992
+ <!-- move section 'Normative references' inside 'sections' -->
7993
+ <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']]">
7994
+ <xsl:sort select="@displayorder" data-type="number"/>
7995
+
7996
+ <!-- process Section's title -->
7997
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7998
+ <xsl:if test="$preceding-sibling_id != ''">
7999
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8000
+ </xsl:if>
8001
+
8002
+ <xsl:choose>
8003
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8004
+ <xsl:otherwise>
8005
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8006
+ </xsl:otherwise>
8007
+ </xsl:choose>
8008
+
8009
+ </xsl:for-each>
8010
+ </xsl:copy>
8011
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
8012
+ <xsl:copy>
8013
+ <xsl:copy-of select="@*"/>
8014
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
8015
+ <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
8016
+ <xsl:sort select="@displayorder" data-type="number"/>
8017
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8018
+ </xsl:for-each>
8019
+ </xsl:copy>
7777
8020
  </xsl:template><xsl:template name="convertDate">
7778
8021
  <xsl:param name="date"/>
7779
8022
  <xsl:param name="format" select="'short'"/>