metanorma-iho 0.5.4 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,12 +20,15 @@
20
20
  <item level="1" id="Foreword" display="true">Foreword</item>
21
21
  <item id="term-script" display="false">3.2</item>
22
22
  -->
23
- <xsl:variable name="contents">
23
+ <xsl:variable name="contents_">
24
24
  <contents>
25
25
  <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
26
- <xsl:call-template name="processMainSectionsDefault_Contents"/>
26
+ <xsl:call-template name="processMainSectionsDefault_Contents"/>
27
+
28
+ <xsl:call-template name="processTablesFigures_Contents"/>
27
29
  </contents>
28
30
  </xsl:variable>
31
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
29
32
 
30
33
  <xsl:template match="/">
31
34
 
@@ -212,11 +215,11 @@
212
215
  <xsl:if test="$debug = 'true'">
213
216
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
214
217
  DEBUG
215
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
218
+ contents=<xsl:copy-of select="$contents"/>
216
219
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
217
220
  </xsl:if>
218
221
 
219
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
222
+ <xsl:for-each select="$contents//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
220
223
  <fo:block role="TOCI">
221
224
  <xsl:if test="@level = 1">
222
225
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -256,6 +259,27 @@
256
259
  </fo:block>
257
260
 
258
261
  </xsl:for-each>
262
+
263
+ <!-- List of Tables -->
264
+ <xsl:if test="$contents//tables/table">
265
+ <xsl:call-template name="insertListOf_Title">
266
+ <xsl:with-param name="title" select="$title-list-tables"/>
267
+ </xsl:call-template>
268
+ <xsl:for-each select="$contents//tables/table">
269
+ <xsl:call-template name="insertListOf_Item"/>
270
+ </xsl:for-each>
271
+ </xsl:if>
272
+
273
+ <!-- List of Figures -->
274
+ <xsl:if test="$contents//figures/figure">
275
+ <xsl:call-template name="insertListOf_Title">
276
+ <xsl:with-param name="title" select="$title-list-figures"/>
277
+ </xsl:call-template>
278
+ <xsl:for-each select="$contents//figures/figure">
279
+ <xsl:call-template name="insertListOf_Item"/>
280
+ </xsl:for-each>
281
+ </xsl:if>
282
+
259
283
  </fo:block>
260
284
  </fo:block-container>
261
285
  </fo:block-container>
@@ -345,6 +369,28 @@
345
369
 
346
370
  </xsl:template>
347
371
 
372
+ <xsl:template name="insertListOf_Title">
373
+ <xsl:param name="title"/>
374
+ <fo:block role="TOCI" font-weight="bold" margin-top="6pt" keep-with-next="always">
375
+ <xsl:value-of select="$title"/>
376
+ </fo:block>
377
+ </xsl:template>
378
+
379
+ <xsl:template name="insertListOf_Item">
380
+ <fo:block role="TOCI" text-align-last="justify" margin-left="12mm" text-indent="-12mm">
381
+ <fo:basic-link internal-destination="{@id}">
382
+ <xsl:call-template name="setAltText">
383
+ <xsl:with-param name="value" select="@alt-text"/>
384
+ </xsl:call-template>
385
+ <xsl:apply-templates select="." mode="contents"/>
386
+ <fo:inline keep-together.within-line="always">
387
+ <fo:leader font-size="9pt" font-weight="normal" leader-pattern="dots"/>
388
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
389
+ </fo:inline>
390
+ </fo:basic-link>
391
+ </fo:block>
392
+ </xsl:template>
393
+
348
394
  <!-- ============================= -->
349
395
  <!-- CONTENTS -->
350
396
  <!-- ============================= -->
@@ -769,7 +815,7 @@
769
815
  <xsl:text>Contents</xsl:text>
770
816
 
771
817
  </title-toc>
772
-
818
+
773
819
  <title-descriptors lang="en">Descriptors</title-descriptors>
774
820
 
775
821
  <title-part lang="en">
@@ -805,7 +851,31 @@
805
851
  <title-continued lang="en">(continued)</title-continued>
806
852
  <title-continued lang="fr">(continué)</title-continued>
807
853
 
808
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
854
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
855
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
856
+ <xsl:value-of select="$toc_table_title"/>
857
+ <xsl:if test="normalize-space($toc_table_title) = ''">
858
+ <xsl:call-template name="getTitle">
859
+ <xsl:with-param name="name" select="'title-list-tables'"/>
860
+ </xsl:call-template>
861
+ </xsl:if>
862
+ </xsl:variable><xsl:variable name="title-list-figures">
863
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
864
+ <xsl:value-of select="$toc_figure_title"/>
865
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
866
+ <xsl:call-template name="getTitle">
867
+ <xsl:with-param name="name" select="'title-list-figures'"/>
868
+ </xsl:call-template>
869
+ </xsl:if>
870
+ </xsl:variable><xsl:variable name="title-list-recommendations">
871
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
872
+ <xsl:value-of select="$toc_requirement_title"/>
873
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
874
+ <xsl:call-template name="getTitle">
875
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
876
+ </xsl:call-template>
877
+ </xsl:if>
878
+ </xsl:variable><xsl:variable name="bibdata">
809
879
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
810
880
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
811
881
  </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">
@@ -2042,6 +2112,30 @@
2042
2112
  <xsl:sort select="@displayorder" data-type="number"/>
2043
2113
  <xsl:apply-templates select="." mode="contents"/>
2044
2114
  </xsl:for-each>
2115
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2116
+ <xsl:param name="always"/>
2117
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2118
+ <xsl:call-template name="processTables_Contents"/>
2119
+ </xsl:if>
2120
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2121
+ <xsl:call-template name="processFigures_Contents"/>
2122
+ </xsl:if>
2123
+ </xsl:template><xsl:template name="processTables_Contents">
2124
+ <tables>
2125
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2126
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2127
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2128
+ </table>
2129
+ </xsl:for-each>
2130
+ </tables>
2131
+ </xsl:template><xsl:template name="processFigures_Contents">
2132
+ <figures>
2133
+ <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) != '']">
2134
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2135
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2136
+ </figure>
2137
+ </xsl:for-each>
2138
+ </figures>
2045
2139
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2046
2140
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2047
2141
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2063,8 +2157,27 @@
2063
2157
  <xsl:sort select="@displayorder" data-type="number"/>
2064
2158
  <xsl:apply-templates select="."/>
2065
2159
  </xsl:for-each>
2066
- </xsl:template><xsl:template match="text()">
2067
- <xsl:value-of select="."/>
2160
+ </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">
2161
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2162
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2163
+ <xsl:call-template name="replace_fo_inline">
2164
+ <xsl:with-param name="text" select="$text"/>
2165
+ </xsl:call-template>
2166
+ </xsl:template><xsl:template name="replace_fo_inline">
2167
+ <xsl:param name="text"/>
2168
+ <xsl:choose>
2169
+ <xsl:when test="contains($text, $tag_open)">
2170
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
2171
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2172
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2173
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2174
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2175
+ <xsl:call-template name="replace_fo_inline">
2176
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2177
+ </xsl:call-template>
2178
+ </xsl:when>
2179
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
2180
+ </xsl:choose>
2068
2181
  </xsl:template><xsl:template match="*[local-name()='br']">
2069
2182
  <xsl:value-of select="$linebreak"/>
2070
2183
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -2814,37 +2927,7 @@
2814
2927
 
2815
2928
  <!-- list of footnotes to calculate actual footnotes number -->
2816
2929
  <xsl:variable name="p_fn_">
2817
- <xsl:choose>
2818
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2819
- <fn gen_id="{generate-id(.)}">
2820
- <xsl:copy-of select="@*"/>
2821
- <xsl:copy-of select="node()"/>
2822
- </fn>
2823
- </xsl:when>
2824
- <xsl:otherwise>
2825
- <!-- itetation for:
2826
- footnotes in bibdata/title
2827
- footnotes in bibliography
2828
- footnotes in document's body (except table's head/body/foot and figure text)
2829
- -->
2830
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2831
- <fn gen_id="{generate-id(.)}">
2832
- <xsl:copy-of select="@*"/>
2833
- <xsl:copy-of select="node()"/>
2834
- </fn>
2835
- </xsl:for-each>
2836
- <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']/*">
2837
- <xsl:sort select="@displayorder" data-type="number"/>
2838
- <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])]">
2839
- <!-- copy unique fn -->
2840
- <fn gen_id="{generate-id(.)}">
2841
- <xsl:copy-of select="@*"/>
2842
- <xsl:copy-of select="node()"/>
2843
- </fn>
2844
- </xsl:for-each>
2845
- </xsl:for-each>
2846
- </xsl:otherwise>
2847
- </xsl:choose>
2930
+ <xsl:call-template name="get_fn_list"/>
2848
2931
  </xsl:variable>
2849
2932
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2850
2933
 
@@ -2905,6 +2988,38 @@
2905
2988
  <xsl:copy-of select="$footnote_inline"/>
2906
2989
  </xsl:otherwise>
2907
2990
  </xsl:choose>
2991
+ </xsl:template><xsl:template name="get_fn_list">
2992
+ <xsl:choose>
2993
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2994
+ <fn gen_id="{generate-id(.)}">
2995
+ <xsl:copy-of select="@*"/>
2996
+ <xsl:copy-of select="node()"/>
2997
+ </fn>
2998
+ </xsl:when>
2999
+ <xsl:otherwise>
3000
+ <!-- itetation for:
3001
+ footnotes in bibdata/title
3002
+ footnotes in bibliography
3003
+ footnotes in document's body (except table's head/body/foot and figure text)
3004
+ -->
3005
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3006
+ <fn gen_id="{generate-id(.)}">
3007
+ <xsl:copy-of select="@*"/>
3008
+ <xsl:copy-of select="node()"/>
3009
+ </fn>
3010
+ </xsl:for-each>
3011
+ <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']/*">
3012
+ <xsl:sort select="@displayorder" data-type="number"/>
3013
+ <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])]">
3014
+ <!-- copy unique fn -->
3015
+ <fn gen_id="{generate-id(.)}">
3016
+ <xsl:copy-of select="@*"/>
3017
+ <xsl:copy-of select="node()"/>
3018
+ </fn>
3019
+ </xsl:for-each>
3020
+ </xsl:for-each>
3021
+ </xsl:otherwise>
3022
+ </xsl:choose>
2908
3023
  </xsl:template><xsl:template name="table_fn_display">
2909
3024
  <xsl:variable name="references">
2910
3025
 
@@ -3076,7 +3191,7 @@
3076
3191
  </fo:inline>
3077
3192
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3078
3193
  <fo:inline><xsl:value-of select="."/></fo:inline>
3079
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3194
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3080
3195
  <fo:inline>
3081
3196
  <xsl:apply-templates/>
3082
3197
  </fo:inline>
@@ -4770,13 +4885,14 @@
4770
4885
  <xsl:apply-templates mode="bookmarks"/>
4771
4886
  </xsl:template><xsl:template name="addBookmarks">
4772
4887
  <xsl:param name="contents"/>
4773
- <xsl:if test="xalan:nodeset($contents)//item">
4888
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4889
+ <xsl:if test="$contents_nodes//item">
4774
4890
  <fo:bookmark-tree>
4775
4891
  <xsl:choose>
4776
- <xsl:when test="xalan:nodeset($contents)/doc">
4892
+ <xsl:when test="$contents_nodes/doc">
4777
4893
  <xsl:choose>
4778
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4779
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4894
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4895
+ <xsl:for-each select="$contents_nodes/doc">
4780
4896
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4781
4897
  <xsl:if test="@bundle = 'true'">
4782
4898
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4827,7 +4943,7 @@
4827
4943
  </xsl:for-each>
4828
4944
  </xsl:when>
4829
4945
  <xsl:otherwise>
4830
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4946
+ <xsl:for-each select="$contents_nodes/doc">
4831
4947
 
4832
4948
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4833
4949
 
@@ -4845,25 +4961,36 @@
4845
4961
  </xsl:choose>
4846
4962
  </xsl:when>
4847
4963
  <xsl:otherwise>
4848
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4964
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4965
+
4966
+ <xsl:call-template name="insertFigureBookmarks">
4967
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4968
+ </xsl:call-template>
4969
+
4970
+ <xsl:call-template name="insertTableBookmarks">
4971
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4972
+ <xsl:with-param name="lang" select="@lang"/>
4973
+ </xsl:call-template>
4974
+
4849
4975
  </xsl:otherwise>
4850
4976
  </xsl:choose>
4851
4977
 
4978
+
4852
4979
 
4853
4980
 
4854
4981
 
4855
4982
 
4856
-
4857
-
4983
+
4858
4984
 
4859
4985
  </fo:bookmark-tree>
4860
4986
  </xsl:if>
4861
4987
  </xsl:template><xsl:template name="insertFigureBookmarks">
4862
4988
  <xsl:param name="contents"/>
4863
- <xsl:if test="xalan:nodeset($contents)/figure">
4864
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
4989
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4990
+ <xsl:if test="$contents_nodes/figure">
4991
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4865
4992
  <fo:bookmark-title>Figures</fo:bookmark-title>
4866
- <xsl:for-each select="xalan:nodeset($contents)/figure">
4993
+ <xsl:for-each select="$contents_nodes/figure">
4867
4994
  <fo:bookmark internal-destination="{@id}">
4868
4995
  <fo:bookmark-title>
4869
4996
  <xsl:value-of select="normalize-space(title)"/>
@@ -4872,18 +4999,40 @@
4872
4999
  </xsl:for-each>
4873
5000
  </fo:bookmark>
4874
5001
  </xsl:if>
5002
+
5003
+
5004
+ <xsl:if test="$contents_nodes//figures/figure">
5005
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5006
+
5007
+
5008
+
5009
+ <xsl:variable name="bookmark-title">
5010
+
5011
+ <xsl:value-of select="$title-list-figures"/>
5012
+
5013
+ </xsl:variable>
5014
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
5015
+ <xsl:for-each select="$contents_nodes//figures/figure">
5016
+ <fo:bookmark internal-destination="{@id}">
5017
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5018
+ </fo:bookmark>
5019
+ </xsl:for-each>
5020
+ </fo:bookmark>
5021
+ </xsl:if>
5022
+
4875
5023
  </xsl:template><xsl:template name="insertTableBookmarks">
4876
5024
  <xsl:param name="contents"/>
4877
5025
  <xsl:param name="lang"/>
4878
- <xsl:if test="xalan:nodeset($contents)/table">
4879
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5026
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5027
+ <xsl:if test="$contents_nodes/table">
5028
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4880
5029
  <fo:bookmark-title>
4881
5030
  <xsl:choose>
4882
5031
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4883
5032
  <xsl:otherwise>Tables</xsl:otherwise>
4884
5033
  </xsl:choose>
4885
5034
  </fo:bookmark-title>
4886
- <xsl:for-each select="xalan:nodeset($contents)/table">
5035
+ <xsl:for-each select="$contents_nodes/table">
4887
5036
  <fo:bookmark internal-destination="{@id}">
4888
5037
  <fo:bookmark-title>
4889
5038
  <xsl:value-of select="normalize-space(title)"/>
@@ -4892,6 +5041,29 @@
4892
5041
  </xsl:for-each>
4893
5042
  </fo:bookmark>
4894
5043
  </xsl:if>
5044
+
5045
+
5046
+ <xsl:if test="$contents_nodes//tables/table">
5047
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5048
+
5049
+
5050
+
5051
+ <xsl:variable name="bookmark-title">
5052
+
5053
+ <xsl:value-of select="$title-list-tables"/>
5054
+
5055
+ </xsl:variable>
5056
+
5057
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
5058
+
5059
+ <xsl:for-each select="$contents_nodes//tables/table">
5060
+ <fo:bookmark internal-destination="{@id}">
5061
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5062
+ </fo:bookmark>
5063
+ </xsl:for-each>
5064
+ </fo:bookmark>
5065
+ </xsl:if>
5066
+
4895
5067
  </xsl:template><xsl:template name="getLangVersion">
4896
5068
  <xsl:param name="lang"/>
4897
5069
  <xsl:param name="doctype" select="''"/>
@@ -5116,7 +5288,51 @@
5116
5288
  <xsl:with-param name="text" select="$text_step1"/>
5117
5289
  </xsl:call-template>
5118
5290
  </xsl:variable>
5119
- <xsl:value-of select="$text_step2"/>
5291
+
5292
+ <!-- <xsl:value-of select="$text_step2"/> -->
5293
+
5294
+ <!-- add zero-width space after space -->
5295
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5296
+
5297
+ <!-- split text by zero-width space -->
5298
+ <xsl:variable name="text_step4">
5299
+ <xsl:call-template name="split">
5300
+ <xsl:with-param name="pText" select="$text_step3"/>
5301
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5302
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5303
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5304
+ </xsl:call-template>
5305
+ </xsl:variable>
5306
+
5307
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5308
+ <xsl:choose>
5309
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5310
+ <xsl:call-template name="interspers">
5311
+ <xsl:with-param name="str" select="."/>
5312
+ </xsl:call-template>
5313
+ </xsl:when>
5314
+ <xsl:otherwise>
5315
+ <xsl:value-of select="."/>
5316
+ </xsl:otherwise>
5317
+ </xsl:choose>
5318
+ </xsl:for-each>
5319
+
5320
+ </xsl:template><xsl:template name="interspers">
5321
+ <xsl:param name="str"/>
5322
+ <xsl:param name="char" select="$zero_width_space"/>
5323
+ <xsl:if test="$str != ''">
5324
+ <xsl:value-of select="substring($str, 1, 1)"/>
5325
+
5326
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5327
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5328
+ <xsl:value-of select="$char"/>
5329
+ </xsl:if>
5330
+
5331
+ <xsl:call-template name="interspers">
5332
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5333
+ <xsl:with-param name="char" select="$char"/>
5334
+ </xsl:call-template>
5335
+ </xsl:if>
5120
5336
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5121
5337
  <xsl:apply-templates mode="syntax_highlight"/>
5122
5338
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5548,6 +5764,8 @@
5548
5764
  </xsl:otherwise>
5549
5765
  </xsl:choose> -->
5550
5766
  </fo:block>
5767
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5768
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5551
5769
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5552
5770
  <xsl:if test="normalize-space() != ''">
5553
5771
  <xsl:value-of select="."/>
@@ -5582,7 +5800,8 @@
5582
5800
  <fo:inline><xsl:apply-templates/></fo:inline>
5583
5801
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
5584
5802
  <xsl:if test="normalize-space() != ''">
5585
- <xsl:value-of select="."/>
5803
+ <!-- <xsl:value-of select="."/> -->
5804
+ <xsl:call-template name="text"/>
5586
5805
  </xsl:if>
5587
5806
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
5588
5807
  <fo:block-container margin-left="0mm">
@@ -5622,26 +5841,24 @@
5622
5841
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5623
5842
  <xsl:text>— </xsl:text>
5624
5843
  <xsl:apply-templates/>
5625
- </xsl:template><xsl:variable name="bibitem_hidden_">
5844
+ </xsl:template><xsl:variable name="bibitems_">
5845
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5846
+ <xsl:copy-of select="."/>
5847
+ </xsl:for-each>
5848
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5626
5849
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5627
5850
  <xsl:copy-of select="."/>
5628
5851
  </xsl:for-each>
5629
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5852
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5630
5853
  <xsl:copy-of select="."/>
5631
5854
  </xsl:for-each>
5632
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5633
-
5634
- <xsl:variable name="bibitemid">
5635
- <xsl:choose>
5636
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5637
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5638
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5639
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5640
- </xsl:choose>
5641
- </xsl:variable>
5642
-
5855
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5856
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5857
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5858
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5643
5859
  <xsl:choose>
5644
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5860
+ <!-- <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) -->
5861
+ <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) -->
5645
5862
  <fo:inline xsl:use-attribute-sets="eref-style">
5646
5863
  <xsl:if test="@type = 'footnote'">
5647
5864
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5655,8 +5872,8 @@
5655
5872
  <xsl:variable name="text" select="normalize-space()"/>
5656
5873
 
5657
5874
 
5658
-
5659
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5875
+
5876
+ <fo:basic-link fox:alt-text="{@citeas}">
5660
5877
  <xsl:if test="normalize-space(@citeas) = ''">
5661
5878
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5662
5879
  </xsl:if>
@@ -5669,14 +5886,21 @@
5669
5886
 
5670
5887
  </xsl:if>
5671
5888
 
5672
-
5889
+ <xsl:choose>
5890
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5891
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5892
+ </xsl:when>
5893
+ <xsl:otherwise>
5894
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5895
+ </xsl:otherwise>
5896
+ </xsl:choose>
5673
5897
 
5674
5898
  <xsl:apply-templates/>
5675
5899
  </fo:basic-link>
5676
-
5900
+
5677
5901
  </fo:inline>
5678
5902
  </xsl:when>
5679
- <xsl:otherwise>
5903
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5680
5904
  <fo:inline><xsl:apply-templates/></fo:inline>
5681
5905
  </xsl:otherwise>
5682
5906
  </xsl:choose>
@@ -6469,27 +6693,47 @@
6469
6693
  <xsl:apply-templates/>
6470
6694
  </fo:inline>
6471
6695
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6696
+
6697
+ <!-- list of footnotes to calculate actual footnotes number -->
6698
+ <xsl:variable name="p_fn_">
6699
+ <xsl:call-template name="get_fn_list"/>
6700
+ </xsl:variable>
6701
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6702
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6703
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6704
+ <!-- fn sequence number in document -->
6705
+ <xsl:variable name="current_fn_number">
6706
+ <xsl:choose>
6707
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6708
+ <xsl:otherwise>
6709
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6710
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6711
+ </xsl:otherwise>
6712
+ </xsl:choose>
6713
+ </xsl:variable>
6472
6714
  <fo:footnote>
6473
6715
  <xsl:variable name="number">
6474
6716
 
6475
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6717
+ <xsl:value-of select="$current_fn_number"/>
6476
6718
 
6477
6719
  </xsl:variable>
6478
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6479
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6480
- <xsl:value-of select="$number"/>
6481
-
6720
+
6721
+ <xsl:variable name="current_fn_number_text">
6722
+ <xsl:value-of select="$number"/>
6723
+
6482
6724
  <xsl:text>)</xsl:text>
6483
6725
 
6726
+ </xsl:variable>
6727
+
6728
+ <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6729
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6730
+ <xsl:value-of select="$current_fn_number_text"/>
6484
6731
  </fo:basic-link>
6485
6732
  </fo:inline>
6486
6733
  <fo:footnote-body>
6487
6734
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6488
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6489
- <xsl:value-of select="$number"/>
6490
-
6491
- <xsl:text>)</xsl:text>
6492
-
6735
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6736
+ <xsl:value-of select="$current_fn_number_text"/>
6493
6737
  </fo:inline>
6494
6738
  <xsl:apply-templates/>
6495
6739
  </fo:block>
@@ -6730,6 +6974,78 @@
6730
6974
  <!-- processing for admonition/p found in the template for 'p' -->
6731
6975
  <xsl:call-template name="paragraph"/>
6732
6976
 
6977
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6978
+ <xsl:copy>
6979
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6980
+ </xsl:copy>
6981
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6982
+ <xsl:copy>
6983
+ <xsl:copy-of select="@*"/>
6984
+
6985
+ <xsl:variable name="nodes_preface_">
6986
+ <xsl:for-each select="*">
6987
+ <node id="{@id}"/>
6988
+ </xsl:for-each>
6989
+ </xsl:variable>
6990
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6991
+
6992
+ <xsl:for-each select="*">
6993
+ <xsl:sort select="@displayorder" data-type="number"/>
6994
+
6995
+ <!-- process Section's title -->
6996
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6997
+ <xsl:if test="$preceding-sibling_id != ''">
6998
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6999
+ </xsl:if>
7000
+
7001
+ <xsl:choose>
7002
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7003
+ <xsl:otherwise>
7004
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7005
+ </xsl:otherwise>
7006
+ </xsl:choose>
7007
+
7008
+ </xsl:for-each>
7009
+ </xsl:copy>
7010
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7011
+ <xsl:copy>
7012
+ <xsl:copy-of select="@*"/>
7013
+
7014
+ <xsl:variable name="nodes_sections_">
7015
+ <xsl:for-each select="*">
7016
+ <node id="{@id}"/>
7017
+ </xsl:for-each>
7018
+ </xsl:variable>
7019
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7020
+
7021
+ <!-- move section 'Normative references' inside 'sections' -->
7022
+ <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']]">
7023
+ <xsl:sort select="@displayorder" data-type="number"/>
7024
+
7025
+ <!-- process Section's title -->
7026
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7027
+ <xsl:if test="$preceding-sibling_id != ''">
7028
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7029
+ </xsl:if>
7030
+
7031
+ <xsl:choose>
7032
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7033
+ <xsl:otherwise>
7034
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7035
+ </xsl:otherwise>
7036
+ </xsl:choose>
7037
+
7038
+ </xsl:for-each>
7039
+ </xsl:copy>
7040
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7041
+ <xsl:copy>
7042
+ <xsl:copy-of select="@*"/>
7043
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7044
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7045
+ <xsl:sort select="@displayorder" data-type="number"/>
7046
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7047
+ </xsl:for-each>
7048
+ </xsl:copy>
6733
7049
  </xsl:template><xsl:template name="convertDate">
6734
7050
  <xsl:param name="date"/>
6735
7051
  <xsl:param name="format" select="'short'"/>
@@ -6974,22 +7290,25 @@
6974
7290
  <xsl:param name="pText" select="."/>
6975
7291
  <xsl:param name="sep" select="','"/>
6976
7292
  <xsl:param name="normalize-space" select="'true'"/>
7293
+ <xsl:param name="keep_sep" select="'false'"/>
6977
7294
  <xsl:if test="string-length($pText) &gt;0">
6978
- <item>
6979
- <xsl:choose>
6980
- <xsl:when test="$normalize-space = 'true'">
6981
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6982
- </xsl:when>
6983
- <xsl:otherwise>
6984
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6985
- </xsl:otherwise>
6986
- </xsl:choose>
6987
- </item>
6988
- <xsl:call-template name="split">
6989
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6990
- <xsl:with-param name="sep" select="$sep"/>
6991
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
6992
- </xsl:call-template>
7295
+ <item>
7296
+ <xsl:choose>
7297
+ <xsl:when test="$normalize-space = 'true'">
7298
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7299
+ </xsl:when>
7300
+ <xsl:otherwise>
7301
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7302
+ </xsl:otherwise>
7303
+ </xsl:choose>
7304
+ </item>
7305
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7306
+ <xsl:call-template name="split">
7307
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7308
+ <xsl:with-param name="sep" select="$sep"/>
7309
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7310
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7311
+ </xsl:call-template>
6993
7312
  </xsl:if>
6994
7313
  </xsl:template><xsl:template name="getDocumentId">
6995
7314
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>