metanorma-bipm 2.0.4 → 2.0.7

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/>
@@ -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"/>
@@ -3061,8 +3159,27 @@
3061
3159
  <xsl:sort select="@displayorder" data-type="number"/>
3062
3160
  <xsl:apply-templates select="."/>
3063
3161
  </xsl:for-each>
3064
- </xsl:template><xsl:template match="text()">
3065
- <xsl:value-of select="."/>
3162
+ </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
3163
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3164
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3165
+ <xsl:call-template name="replace_fo_inline">
3166
+ <xsl:with-param name="text" select="$text"/>
3167
+ </xsl:call-template>
3168
+ </xsl:template><xsl:template name="replace_fo_inline">
3169
+ <xsl:param name="text"/>
3170
+ <xsl:choose>
3171
+ <xsl:when test="contains($text, $tag_open)">
3172
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
3173
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3174
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3175
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3176
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3177
+ <xsl:call-template name="replace_fo_inline">
3178
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3179
+ </xsl:call-template>
3180
+ </xsl:when>
3181
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
3182
+ </xsl:choose>
3066
3183
  </xsl:template><xsl:template match="*[local-name()='br']">
3067
3184
  <xsl:value-of select="$linebreak"/>
3068
3185
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -3890,37 +4007,7 @@
3890
4007
 
3891
4008
  <!-- list of footnotes to calculate actual footnotes number -->
3892
4009
  <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>
4010
+ <xsl:call-template name="get_fn_list"/>
3924
4011
  </xsl:variable>
3925
4012
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3926
4013
 
@@ -3981,6 +4068,38 @@
3981
4068
  <xsl:copy-of select="$footnote_inline"/>
3982
4069
  </xsl:otherwise>
3983
4070
  </xsl:choose>
4071
+ </xsl:template><xsl:template name="get_fn_list">
4072
+ <xsl:choose>
4073
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4074
+ <fn gen_id="{generate-id(.)}">
4075
+ <xsl:copy-of select="@*"/>
4076
+ <xsl:copy-of select="node()"/>
4077
+ </fn>
4078
+ </xsl:when>
4079
+ <xsl:otherwise>
4080
+ <!-- itetation for:
4081
+ footnotes in bibdata/title
4082
+ footnotes in bibliography
4083
+ footnotes in document's body (except table's head/body/foot and figure text)
4084
+ -->
4085
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4086
+ <fn gen_id="{generate-id(.)}">
4087
+ <xsl:copy-of select="@*"/>
4088
+ <xsl:copy-of select="node()"/>
4089
+ </fn>
4090
+ </xsl:for-each>
4091
+ <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']/*">
4092
+ <xsl:sort select="@displayorder" data-type="number"/>
4093
+ <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])]">
4094
+ <!-- copy unique fn -->
4095
+ <fn gen_id="{generate-id(.)}">
4096
+ <xsl:copy-of select="@*"/>
4097
+ <xsl:copy-of select="node()"/>
4098
+ </fn>
4099
+ </xsl:for-each>
4100
+ </xsl:for-each>
4101
+ </xsl:otherwise>
4102
+ </xsl:choose>
3984
4103
  </xsl:template><xsl:template name="table_fn_display">
3985
4104
  <xsl:variable name="references">
3986
4105
 
@@ -4157,7 +4276,7 @@
4157
4276
  </fo:inline>
4158
4277
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
4159
4278
  <fo:inline><xsl:value-of select="."/></fo:inline>
4160
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
4279
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
4161
4280
  <fo:inline>
4162
4281
  <xsl:apply-templates/>
4163
4282
  </fo:inline>
@@ -5859,13 +5978,14 @@
5859
5978
  <xsl:apply-templates mode="bookmarks"/>
5860
5979
  </xsl:template><xsl:template name="addBookmarks">
5861
5980
  <xsl:param name="contents"/>
5862
- <xsl:if test="xalan:nodeset($contents)//item">
5981
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5982
+ <xsl:if test="$contents_nodes//item">
5863
5983
  <fo:bookmark-tree>
5864
5984
  <xsl:choose>
5865
- <xsl:when test="xalan:nodeset($contents)/doc">
5985
+ <xsl:when test="$contents_nodes/doc">
5866
5986
  <xsl:choose>
5867
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5868
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5987
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
5988
+ <xsl:for-each select="$contents_nodes/doc">
5869
5989
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5870
5990
  <xsl:if test="@bundle = 'true'">
5871
5991
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -5916,7 +6036,7 @@
5916
6036
  </xsl:for-each>
5917
6037
  </xsl:when>
5918
6038
  <xsl:otherwise>
5919
- <xsl:for-each select="xalan:nodeset($contents)/doc">
6039
+ <xsl:for-each select="$contents_nodes/doc">
5920
6040
 
5921
6041
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5922
6042
 
@@ -5934,25 +6054,36 @@
5934
6054
  </xsl:choose>
5935
6055
  </xsl:when>
5936
6056
  <xsl:otherwise>
5937
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
6057
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
6058
+
6059
+ <xsl:call-template name="insertFigureBookmarks">
6060
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6061
+ </xsl:call-template>
6062
+
6063
+ <xsl:call-template name="insertTableBookmarks">
6064
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
6065
+ <xsl:with-param name="lang" select="@lang"/>
6066
+ </xsl:call-template>
6067
+
5938
6068
  </xsl:otherwise>
5939
6069
  </xsl:choose>
5940
6070
 
6071
+
5941
6072
 
5942
6073
 
5943
6074
 
5944
6075
 
5945
-
5946
-
6076
+
5947
6077
 
5948
6078
  </fo:bookmark-tree>
5949
6079
  </xsl:if>
5950
6080
  </xsl:template><xsl:template name="insertFigureBookmarks">
5951
6081
  <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">
6082
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6083
+ <xsl:if test="$contents_nodes/figure">
6084
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
5954
6085
  <fo:bookmark-title>Figures</fo:bookmark-title>
5955
- <xsl:for-each select="xalan:nodeset($contents)/figure">
6086
+ <xsl:for-each select="$contents_nodes/figure">
5956
6087
  <fo:bookmark internal-destination="{@id}">
5957
6088
  <fo:bookmark-title>
5958
6089
  <xsl:value-of select="normalize-space(title)"/>
@@ -5961,18 +6092,40 @@
5961
6092
  </xsl:for-each>
5962
6093
  </fo:bookmark>
5963
6094
  </xsl:if>
6095
+
6096
+
6097
+ <xsl:if test="$contents_nodes//figures/figure">
6098
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6099
+
6100
+
6101
+
6102
+ <xsl:variable name="bookmark-title">
6103
+
6104
+ <xsl:value-of select="$title-list-figures"/>
6105
+
6106
+ </xsl:variable>
6107
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
6108
+ <xsl:for-each select="$contents_nodes//figures/figure">
6109
+ <fo:bookmark internal-destination="{@id}">
6110
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6111
+ </fo:bookmark>
6112
+ </xsl:for-each>
6113
+ </fo:bookmark>
6114
+ </xsl:if>
6115
+
5964
6116
  </xsl:template><xsl:template name="insertTableBookmarks">
5965
6117
  <xsl:param name="contents"/>
5966
6118
  <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">
6119
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
6120
+ <xsl:if test="$contents_nodes/table">
6121
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
5969
6122
  <fo:bookmark-title>
5970
6123
  <xsl:choose>
5971
6124
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
5972
6125
  <xsl:otherwise>Tables</xsl:otherwise>
5973
6126
  </xsl:choose>
5974
6127
  </fo:bookmark-title>
5975
- <xsl:for-each select="xalan:nodeset($contents)/table">
6128
+ <xsl:for-each select="$contents_nodes/table">
5976
6129
  <fo:bookmark internal-destination="{@id}">
5977
6130
  <fo:bookmark-title>
5978
6131
  <xsl:value-of select="normalize-space(title)"/>
@@ -5981,6 +6134,29 @@
5981
6134
  </xsl:for-each>
5982
6135
  </fo:bookmark>
5983
6136
  </xsl:if>
6137
+
6138
+
6139
+ <xsl:if test="$contents_nodes//tables/table">
6140
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
6141
+
6142
+
6143
+
6144
+ <xsl:variable name="bookmark-title">
6145
+
6146
+ <xsl:value-of select="$title-list-tables"/>
6147
+
6148
+ </xsl:variable>
6149
+
6150
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
6151
+
6152
+ <xsl:for-each select="$contents_nodes//tables/table">
6153
+ <fo:bookmark internal-destination="{@id}">
6154
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
6155
+ </fo:bookmark>
6156
+ </xsl:for-each>
6157
+ </fo:bookmark>
6158
+ </xsl:if>
6159
+
5984
6160
  </xsl:template><xsl:template name="getLangVersion">
5985
6161
  <xsl:param name="lang"/>
5986
6162
  <xsl:param name="doctype" select="''"/>
@@ -6205,7 +6381,51 @@
6205
6381
  <xsl:with-param name="text" select="$text_step1"/>
6206
6382
  </xsl:call-template>
6207
6383
  </xsl:variable>
6208
- <xsl:value-of select="$text_step2"/>
6384
+
6385
+ <!-- <xsl:value-of select="$text_step2"/> -->
6386
+
6387
+ <!-- add zero-width space after space -->
6388
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
6389
+
6390
+ <!-- split text by zero-width space -->
6391
+ <xsl:variable name="text_step4">
6392
+ <xsl:call-template name="split">
6393
+ <xsl:with-param name="pText" select="$text_step3"/>
6394
+ <xsl:with-param name="sep" select="$zero_width_space"/>
6395
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
6396
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
6397
+ </xsl:call-template>
6398
+ </xsl:variable>
6399
+
6400
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
6401
+ <xsl:choose>
6402
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6403
+ <xsl:call-template name="interspers">
6404
+ <xsl:with-param name="str" select="."/>
6405
+ </xsl:call-template>
6406
+ </xsl:when>
6407
+ <xsl:otherwise>
6408
+ <xsl:value-of select="."/>
6409
+ </xsl:otherwise>
6410
+ </xsl:choose>
6411
+ </xsl:for-each>
6412
+
6413
+ </xsl:template><xsl:template name="interspers">
6414
+ <xsl:param name="str"/>
6415
+ <xsl:param name="char" select="$zero_width_space"/>
6416
+ <xsl:if test="$str != ''">
6417
+ <xsl:value-of select="substring($str, 1, 1)"/>
6418
+
6419
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
6420
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
6421
+ <xsl:value-of select="$char"/>
6422
+ </xsl:if>
6423
+
6424
+ <xsl:call-template name="interspers">
6425
+ <xsl:with-param name="str" select="substring($str, 2)"/>
6426
+ <xsl:with-param name="char" select="$char"/>
6427
+ </xsl:call-template>
6428
+ </xsl:if>
6209
6429
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6210
6430
  <xsl:apply-templates mode="syntax_highlight"/>
6211
6431
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6586,7 +6806,7 @@
6586
6806
  <xsl:variable name="element">
6587
6807
 
6588
6808
  <xsl:choose>
6589
- <xsl:when test="$num = 1">inline</xsl:when>
6809
+ <xsl:when test="$num = 1 and not(contains($fo_element, 'block'))">inline</xsl:when>
6590
6810
  <xsl:otherwise>block</xsl:otherwise>
6591
6811
  </xsl:choose>
6592
6812
 
@@ -6642,6 +6862,8 @@
6642
6862
  </xsl:otherwise>
6643
6863
  </xsl:choose> -->
6644
6864
  </fo:block>
6865
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6866
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6645
6867
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6646
6868
  <xsl:if test="normalize-space() != ''">
6647
6869
  <xsl:value-of select="."/>
@@ -6676,7 +6898,8 @@
6676
6898
  <fo:inline><xsl:apply-templates/></fo:inline>
6677
6899
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
6678
6900
  <xsl:if test="normalize-space() != ''">
6679
- <xsl:value-of select="."/>
6901
+ <!-- <xsl:value-of select="."/> -->
6902
+ <xsl:call-template name="text"/>
6680
6903
  </xsl:if>
6681
6904
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
6682
6905
  <fo:block-container margin-left="0mm">
@@ -6726,26 +6949,24 @@
6726
6949
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6727
6950
  <xsl:text>— </xsl:text>
6728
6951
  <xsl:apply-templates/>
6729
- </xsl:template><xsl:variable name="bibitem_hidden_">
6952
+ </xsl:template><xsl:variable name="bibitems_">
6953
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
6954
+ <xsl:copy-of select="."/>
6955
+ </xsl:for-each>
6956
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
6730
6957
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6731
6958
  <xsl:copy-of select="."/>
6732
6959
  </xsl:for-each>
6733
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6960
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
6734
6961
  <xsl:copy-of select="."/>
6735
6962
  </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
-
6963
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6964
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6965
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
6966
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
6747
6967
  <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 -->
6968
+ <!-- <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) -->
6969
+ <xsl:when test="$external-destination != '' or not($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid])"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link (internal to the bibitem or external) -->
6749
6970
  <fo:inline xsl:use-attribute-sets="eref-style">
6750
6971
  <xsl:if test="@type = 'footnote'">
6751
6972
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6759,8 +6980,8 @@
6759
6980
  <xsl:variable name="text" select="normalize-space()"/>
6760
6981
 
6761
6982
 
6762
-
6763
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6983
+
6984
+ <fo:basic-link fox:alt-text="{@citeas}">
6764
6985
  <xsl:if test="normalize-space(@citeas) = ''">
6765
6986
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6766
6987
  </xsl:if>
@@ -6770,14 +6991,21 @@
6770
6991
 
6771
6992
  </xsl:if>
6772
6993
 
6773
-
6994
+ <xsl:choose>
6995
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6996
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6997
+ </xsl:when>
6998
+ <xsl:otherwise>
6999
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
7000
+ </xsl:otherwise>
7001
+ </xsl:choose>
6774
7002
 
6775
7003
  <xsl:apply-templates/>
6776
7004
  </fo:basic-link>
6777
-
7005
+
6778
7006
  </fo:inline>
6779
7007
  </xsl:when>
6780
- <xsl:otherwise>
7008
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6781
7009
  <fo:inline><xsl:apply-templates/></fo:inline>
6782
7010
  </xsl:otherwise>
6783
7011
  </xsl:choose>
@@ -7514,27 +7742,47 @@
7514
7742
  <xsl:apply-templates/>
7515
7743
  </fo:inline>
7516
7744
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7745
+
7746
+ <!-- list of footnotes to calculate actual footnotes number -->
7747
+ <xsl:variable name="p_fn_">
7748
+ <xsl:call-template name="get_fn_list"/>
7749
+ </xsl:variable>
7750
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7751
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7752
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7753
+ <!-- fn sequence number in document -->
7754
+ <xsl:variable name="current_fn_number">
7755
+ <xsl:choose>
7756
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7757
+ <xsl:otherwise>
7758
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7759
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7760
+ </xsl:otherwise>
7761
+ </xsl:choose>
7762
+ </xsl:variable>
7517
7763
  <fo:footnote>
7518
7764
  <xsl:variable name="number">
7519
7765
 
7520
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7766
+ <xsl:value-of select="$current_fn_number"/>
7521
7767
 
7522
7768
  </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
-
7769
+
7770
+ <xsl:variable name="current_fn_number_text">
7771
+ <xsl:value-of select="$number"/>
7772
+
7527
7773
  <xsl:text>)</xsl:text>
7528
7774
 
7775
+ </xsl:variable>
7776
+
7777
+ <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7778
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7779
+ <xsl:value-of select="$current_fn_number_text"/>
7529
7780
  </fo:basic-link>
7530
7781
  </fo:inline>
7531
7782
  <fo:footnote-body>
7532
7783
  <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
-
7784
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7785
+ <xsl:value-of select="$current_fn_number_text"/>
7538
7786
  </fo:inline>
7539
7787
  <xsl:apply-templates/>
7540
7788
  </fo:block>
@@ -7774,6 +8022,78 @@
7774
8022
  <xsl:apply-templates/>
7775
8023
  </fo:block>
7776
8024
 
8025
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
8026
+ <xsl:copy>
8027
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
8028
+ </xsl:copy>
8029
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
8030
+ <xsl:copy>
8031
+ <xsl:copy-of select="@*"/>
8032
+
8033
+ <xsl:variable name="nodes_preface_">
8034
+ <xsl:for-each select="*">
8035
+ <node id="{@id}"/>
8036
+ </xsl:for-each>
8037
+ </xsl:variable>
8038
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
8039
+
8040
+ <xsl:for-each select="*">
8041
+ <xsl:sort select="@displayorder" data-type="number"/>
8042
+
8043
+ <!-- process Section's title -->
8044
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8045
+ <xsl:if test="$preceding-sibling_id != ''">
8046
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8047
+ </xsl:if>
8048
+
8049
+ <xsl:choose>
8050
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8051
+ <xsl:otherwise>
8052
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8053
+ </xsl:otherwise>
8054
+ </xsl:choose>
8055
+
8056
+ </xsl:for-each>
8057
+ </xsl:copy>
8058
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
8059
+ <xsl:copy>
8060
+ <xsl:copy-of select="@*"/>
8061
+
8062
+ <xsl:variable name="nodes_sections_">
8063
+ <xsl:for-each select="*">
8064
+ <node id="{@id}"/>
8065
+ </xsl:for-each>
8066
+ </xsl:variable>
8067
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
8068
+
8069
+ <!-- move section 'Normative references' inside 'sections' -->
8070
+ <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']]">
8071
+ <xsl:sort select="@displayorder" data-type="number"/>
8072
+
8073
+ <!-- process Section's title -->
8074
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
8075
+ <xsl:if test="$preceding-sibling_id != ''">
8076
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
8077
+ </xsl:if>
8078
+
8079
+ <xsl:choose>
8080
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
8081
+ <xsl:otherwise>
8082
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8083
+ </xsl:otherwise>
8084
+ </xsl:choose>
8085
+
8086
+ </xsl:for-each>
8087
+ </xsl:copy>
8088
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
8089
+ <xsl:copy>
8090
+ <xsl:copy-of select="@*"/>
8091
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
8092
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
8093
+ <xsl:sort select="@displayorder" data-type="number"/>
8094
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
8095
+ </xsl:for-each>
8096
+ </xsl:copy>
7777
8097
  </xsl:template><xsl:template name="convertDate">
7778
8098
  <xsl:param name="date"/>
7779
8099
  <xsl:param name="format" select="'short'"/>
@@ -8015,22 +8335,25 @@
8015
8335
  <xsl:param name="pText" select="."/>
8016
8336
  <xsl:param name="sep" select="','"/>
8017
8337
  <xsl:param name="normalize-space" select="'true'"/>
8338
+ <xsl:param name="keep_sep" select="'false'"/>
8018
8339
  <xsl:if test="string-length($pText) &gt;0">
8019
- <item>
8020
- <xsl:choose>
8021
- <xsl:when test="$normalize-space = 'true'">
8022
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8023
- </xsl:when>
8024
- <xsl:otherwise>
8025
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8026
- </xsl:otherwise>
8027
- </xsl:choose>
8028
- </item>
8029
- <xsl:call-template name="split">
8030
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8031
- <xsl:with-param name="sep" select="$sep"/>
8032
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
8033
- </xsl:call-template>
8340
+ <item>
8341
+ <xsl:choose>
8342
+ <xsl:when test="$normalize-space = 'true'">
8343
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8344
+ </xsl:when>
8345
+ <xsl:otherwise>
8346
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8347
+ </xsl:otherwise>
8348
+ </xsl:choose>
8349
+ </item>
8350
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
8351
+ <xsl:call-template name="split">
8352
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8353
+ <xsl:with-param name="sep" select="$sep"/>
8354
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
8355
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
8356
+ </xsl:call-template>
8034
8357
  </xsl:if>
8035
8358
  </xsl:template><xsl:template name="getDocumentId">
8036
8359
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>