metanorma-un 0.8.3 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,13 +11,15 @@
11
11
 
12
12
  <xsl:variable name="debug">false</xsl:variable>
13
13
 
14
- <xsl:variable name="contents">
14
+ <xsl:variable name="contents_">
15
15
  <contents>
16
16
  <xsl:apply-templates select="/un:un-standard/un:sections/*" mode="contents"/>
17
17
  <xsl:apply-templates select="/un:un-standard/un:annex" mode="contents"/>
18
18
  <xsl:apply-templates select="/un:un-standard/un:bibliography/un:references" mode="contents"/>
19
+ <xsl:call-template name="processTablesFigures_Contents"/>
19
20
  </contents>
20
21
  </xsl:variable>
22
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
21
23
 
22
24
 
23
25
  <xsl:variable name="title" select="/un:un-standard/un:bibdata/un:title[@language = 'en' and @type = 'main']"/>
@@ -198,7 +200,7 @@
198
200
  </xsl:variable>
199
201
  <fo:block font-size="9pt" text-align="right" font-style="italic" margin-bottom="6pt"><xsl:value-of select="$title-page"/></fo:block>
200
202
  <fo:block role="TOC">
201
- <xsl:for-each select="xalan:nodeset($contents)//item[not (@type = 'annex' or @parent = 'annex') and @display = 'true']">
203
+ <xsl:for-each select="$contents//item[not (@type = 'annex' or @parent = 'annex') and @display = 'true']">
202
204
 
203
205
  <fo:block role="TOCI">
204
206
 
@@ -236,9 +238,9 @@
236
238
 
237
239
  </xsl:for-each>
238
240
 
239
- <xsl:if test="xalan:nodeset($contents)//item[@type = 'annex' and @display = 'true']">
240
- <fo:block text-align="center" margin-top="12pt" margin-bottom="12pt">ANNEXES</fo:block>
241
- <xsl:for-each select="xalan:nodeset($contents)//item[@type = 'annex' and @display = 'true']">
241
+ <xsl:if test="$contents//item[@type = 'annex' and @display = 'true']">
242
+ <fo:block text-align="center" margin-top="12pt" margin-bottom="12pt" keep-with-next="always">ANNEXES</fo:block>
243
+ <xsl:for-each select="$contents//item[@type = 'annex' and @display = 'true']">
242
244
  <fo:block role="TOCI">
243
245
  <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
244
246
  <fo:basic-link internal-destination="{@id}" fox:alt-text="{@section}">
@@ -268,6 +270,26 @@
268
270
  </xsl:for-each>
269
271
  </xsl:if>
270
272
 
273
+ <!-- List of Tables -->
274
+ <xsl:if test="$contents//tables/table">
275
+ <xsl:call-template name="insertListOf_Title">
276
+ <xsl:with-param name="title" select="$title-list-tables"/>
277
+ </xsl:call-template>
278
+ <xsl:for-each select="$contents//tables/table">
279
+ <xsl:call-template name="insertListOf_Item"/>
280
+ </xsl:for-each>
281
+ </xsl:if>
282
+
283
+ <!-- List of Figures -->
284
+ <xsl:if test="$contents//figures/figure">
285
+ <xsl:call-template name="insertListOf_Title">
286
+ <xsl:with-param name="title" select="$title-list-figures"/>
287
+ </xsl:call-template>
288
+ <xsl:for-each select="$contents//figures/figure">
289
+ <xsl:call-template name="insertListOf_Item"/>
290
+ </xsl:for-each>
291
+ </xsl:if>
292
+
271
293
  </fo:block>
272
294
  </fo:flow>
273
295
  </fo:page-sequence>
@@ -289,7 +311,7 @@
289
311
  <xsl:if test="$debug = 'true'">
290
312
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
291
313
  DEBUG
292
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
314
+ contents=<xsl:copy-of select="$contents"/>
293
315
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
294
316
  </xsl:if>
295
317
 
@@ -327,6 +349,30 @@
327
349
  </fo:page-sequence>
328
350
  </fo:root>
329
351
  </xsl:template>
352
+
353
+ <xsl:template name="insertListOf_Title">
354
+ <xsl:param name="title"/>
355
+ <fo:block text-align="center" margin-top="12pt" margin-bottom="12pt" keep-with-next="always">
356
+ <xsl:value-of select="$title"/>
357
+ </fo:block>
358
+ </xsl:template>
359
+
360
+ <xsl:template name="insertListOf_Item">
361
+ <fo:block role="TOCI">
362
+ <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
363
+ <fo:basic-link internal-destination="{@id}">
364
+ <xsl:call-template name="setAltText">
365
+ <xsl:with-param name="value" select="@alt-text"/>
366
+ </xsl:call-template>
367
+ <xsl:apply-templates select="." mode="contents"/>
368
+ <fo:inline keep-together.within-line="always">
369
+ <fo:leader leader-pattern="dots"/>
370
+ <fo:page-number-citation ref-id="{@id}"/>
371
+ </fo:inline>
372
+ </fo:basic-link>
373
+ </fo:block>
374
+ </fo:block>
375
+ </xsl:template>
330
376
 
331
377
  <!-- ============================= -->
332
378
  <!-- CONTENTS -->
@@ -876,6 +922,10 @@
876
922
  <xsl:text>Édition </xsl:text>
877
923
  </title-edition>
878
924
 
925
+ <title-edition lang="ru">
926
+ <xsl:text>Издание </xsl:text>
927
+ </title-edition>
928
+
879
929
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
880
930
  <title-toc lang="en">
881
931
 
@@ -892,7 +942,7 @@
892
942
  <xsl:text>Contents</xsl:text>
893
943
 
894
944
  </title-toc>
895
-
945
+
896
946
  <title-descriptors lang="en">Descriptors</title-descriptors>
897
947
 
898
948
  <title-part lang="en">
@@ -904,7 +954,11 @@
904
954
 
905
955
 
906
956
 
907
- </title-part>
957
+ </title-part>
958
+ <title-part lang="ru">
959
+
960
+
961
+ </title-part>
908
962
  <title-part lang="zh">第 # 部分:</title-part>
909
963
 
910
964
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -920,10 +974,35 @@
920
974
 
921
975
  <title-summary lang="en">Summary</title-summary>
922
976
 
977
+ <title-continued lang="ru">(продолжение)</title-continued>
923
978
  <title-continued lang="en">(continued)</title-continued>
924
979
  <title-continued lang="fr">(continué)</title-continued>
925
980
 
926
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
981
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
982
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
983
+ <xsl:value-of select="$toc_table_title"/>
984
+ <xsl:if test="normalize-space($toc_table_title) = ''">
985
+ <xsl:call-template name="getTitle">
986
+ <xsl:with-param name="name" select="'title-list-tables'"/>
987
+ </xsl:call-template>
988
+ </xsl:if>
989
+ </xsl:variable><xsl:variable name="title-list-figures">
990
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
991
+ <xsl:value-of select="$toc_figure_title"/>
992
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
993
+ <xsl:call-template name="getTitle">
994
+ <xsl:with-param name="name" select="'title-list-figures'"/>
995
+ </xsl:call-template>
996
+ </xsl:if>
997
+ </xsl:variable><xsl:variable name="title-list-recommendations">
998
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
999
+ <xsl:value-of select="$toc_requirement_title"/>
1000
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
1001
+ <xsl:call-template name="getTitle">
1002
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
1003
+ </xsl:call-template>
1004
+ </xsl:if>
1005
+ </xsl:variable><xsl:variable name="bibdata">
927
1006
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
928
1007
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
929
1008
  </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">
@@ -1631,13 +1710,19 @@
1631
1710
  </xsl:attribute-set><xsl:variable name="color-added-text">
1632
1711
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1633
1712
  </xsl:variable><xsl:attribute-set name="add-style">
1634
- <xsl:attribute name="color">red</xsl:attribute>
1635
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
1636
- <!-- <xsl:attribute name="color">black</xsl:attribute>
1637
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1638
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
1639
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1640
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1713
+
1714
+ <xsl:attribute name="color">red</xsl:attribute>
1715
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1716
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1717
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1718
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1719
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1720
+
1721
+ </xsl:attribute-set><xsl:variable name="add-style">
1722
+ <add-style xsl:use-attribute-sets="add-style"/>
1723
+ </xsl:variable><xsl:template name="append_add-style">
1724
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1725
+ </xsl:template><xsl:variable name="color-deleted-text">
1641
1726
  <xsl:text>red</xsl:text>
1642
1727
  </xsl:variable><xsl:attribute-set name="del-style">
1643
1728
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -2069,14 +2154,42 @@
2069
2154
 
2070
2155
 
2071
2156
  </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
2157
+ <xsl:variable name="nodes_preface_">
2158
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2159
+ <node id="{@id}"/>
2160
+ </xsl:for-each>
2161
+ </xsl:variable>
2162
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2163
+
2072
2164
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2073
2165
  <xsl:sort select="@displayorder" data-type="number"/>
2166
+
2167
+ <!-- process Section's title -->
2168
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2169
+ <xsl:if test="$preceding-sibling_id != ''">
2170
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2171
+ </xsl:if>
2172
+
2074
2173
  <xsl:apply-templates select="." mode="contents"/>
2075
2174
  </xsl:for-each>
2076
2175
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2077
2176
 
2177
+ <xsl:variable name="nodes_sections_">
2178
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
2179
+ <node id="{@id}"/>
2180
+ </xsl:for-each>
2181
+ </xsl:variable>
2182
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
2183
+
2078
2184
  <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]">
2079
2185
  <xsl:sort select="@displayorder" data-type="number"/>
2186
+
2187
+ <!-- process Section's title -->
2188
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2189
+ <xsl:if test="$preceding-sibling_id != ''">
2190
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2191
+ </xsl:if>
2192
+
2080
2193
  <xsl:apply-templates select="." mode="contents"/>
2081
2194
  </xsl:for-each>
2082
2195
 
@@ -2089,6 +2202,30 @@
2089
2202
  <xsl:sort select="@displayorder" data-type="number"/>
2090
2203
  <xsl:apply-templates select="." mode="contents"/>
2091
2204
  </xsl:for-each>
2205
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2206
+ <xsl:param name="always"/>
2207
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2208
+ <xsl:call-template name="processTables_Contents"/>
2209
+ </xsl:if>
2210
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2211
+ <xsl:call-template name="processFigures_Contents"/>
2212
+ </xsl:if>
2213
+ </xsl:template><xsl:template name="processTables_Contents">
2214
+ <tables>
2215
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2216
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2217
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2218
+ </table>
2219
+ </xsl:for-each>
2220
+ </tables>
2221
+ </xsl:template><xsl:template name="processFigures_Contents">
2222
+ <figures>
2223
+ <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) != '']">
2224
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2225
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2226
+ </figure>
2227
+ </xsl:for-each>
2228
+ </figures>
2092
2229
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2093
2230
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2094
2231
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2215,7 +2352,7 @@
2215
2352
  </xsl:call-template>
2216
2353
  </xsl:if>
2217
2354
  </xsl:variable>
2218
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2355
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2219
2356
 
2220
2357
 
2221
2358
  <xsl:variable name="margin-side">
@@ -2492,7 +2629,7 @@
2492
2629
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2493
2630
  <!-- 2009 thinspace -->
2494
2631
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2495
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2632
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2496
2633
  </xsl:call-template>
2497
2634
  </xsl:variable>
2498
2635
  <xsl:variable name="max_length">
@@ -2902,37 +3039,7 @@
2902
3039
 
2903
3040
  <!-- list of footnotes to calculate actual footnotes number -->
2904
3041
  <xsl:variable name="p_fn_">
2905
- <xsl:choose>
2906
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2907
- <fn gen_id="{generate-id(.)}">
2908
- <xsl:copy-of select="@*"/>
2909
- <xsl:copy-of select="node()"/>
2910
- </fn>
2911
- </xsl:when>
2912
- <xsl:otherwise>
2913
- <!-- itetation for:
2914
- footnotes in bibdata/title
2915
- footnotes in bibliography
2916
- footnotes in document's body (except table's head/body/foot and figure text)
2917
- -->
2918
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2919
- <fn gen_id="{generate-id(.)}">
2920
- <xsl:copy-of select="@*"/>
2921
- <xsl:copy-of select="node()"/>
2922
- </fn>
2923
- </xsl:for-each>
2924
- <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']/*">
2925
- <xsl:sort select="@displayorder" data-type="number"/>
2926
- <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])]">
2927
- <!-- copy unique fn -->
2928
- <fn gen_id="{generate-id(.)}">
2929
- <xsl:copy-of select="@*"/>
2930
- <xsl:copy-of select="node()"/>
2931
- </fn>
2932
- </xsl:for-each>
2933
- </xsl:for-each>
2934
- </xsl:otherwise>
2935
- </xsl:choose>
3042
+ <xsl:call-template name="get_fn_list"/>
2936
3043
  </xsl:variable>
2937
3044
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2938
3045
 
@@ -2993,6 +3100,38 @@
2993
3100
  <xsl:copy-of select="$footnote_inline"/>
2994
3101
  </xsl:otherwise>
2995
3102
  </xsl:choose>
3103
+ </xsl:template><xsl:template name="get_fn_list">
3104
+ <xsl:choose>
3105
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3106
+ <fn gen_id="{generate-id(.)}">
3107
+ <xsl:copy-of select="@*"/>
3108
+ <xsl:copy-of select="node()"/>
3109
+ </fn>
3110
+ </xsl:when>
3111
+ <xsl:otherwise>
3112
+ <!-- itetation for:
3113
+ footnotes in bibdata/title
3114
+ footnotes in bibliography
3115
+ footnotes in document's body (except table's head/body/foot and figure text)
3116
+ -->
3117
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3118
+ <fn gen_id="{generate-id(.)}">
3119
+ <xsl:copy-of select="@*"/>
3120
+ <xsl:copy-of select="node()"/>
3121
+ </fn>
3122
+ </xsl:for-each>
3123
+ <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']/*">
3124
+ <xsl:sort select="@displayorder" data-type="number"/>
3125
+ <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])]">
3126
+ <!-- copy unique fn -->
3127
+ <fn gen_id="{generate-id(.)}">
3128
+ <xsl:copy-of select="@*"/>
3129
+ <xsl:copy-of select="node()"/>
3130
+ </fn>
3131
+ </xsl:for-each>
3132
+ </xsl:for-each>
3133
+ </xsl:otherwise>
3134
+ </xsl:choose>
2996
3135
  </xsl:template><xsl:template name="table_fn_display">
2997
3136
  <xsl:variable name="references">
2998
3137
 
@@ -3164,7 +3303,7 @@
3164
3303
  </fo:inline>
3165
3304
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3166
3305
  <fo:inline><xsl:value-of select="."/></fo:inline>
3167
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3306
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3168
3307
  <fo:inline>
3169
3308
  <xsl:apply-templates/>
3170
3309
  </fo:inline>
@@ -4140,6 +4279,9 @@
4140
4279
  </fo:inline>
4141
4280
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
4142
4281
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4282
+ <xsl:if test="parent::*[local-name() = 'add']">
4283
+ <xsl:call-template name="append_add-style"/>
4284
+ </xsl:if>
4143
4285
  <xsl:apply-templates/>
4144
4286
  </fo:basic-link>
4145
4287
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -4255,6 +4397,13 @@
4255
4397
 
4256
4398
 
4257
4399
 
4400
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4401
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4402
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4403
+ <xsl:call-template name="append_add-style"/>
4404
+ </xsl:if>
4405
+
4406
+
4258
4407
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
4259
4408
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
4260
4409
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -4293,6 +4442,12 @@
4293
4442
 
4294
4443
 
4295
4444
 
4445
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4446
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4447
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4448
+ <xsl:call-template name="append_add-style"/>
4449
+ </xsl:if>
4450
+
4296
4451
  <xsl:apply-templates select="*[local-name() = 'name']"/>
4297
4452
 
4298
4453
  </fo:inline>
@@ -4346,6 +4501,7 @@
4346
4501
  </fo:block>
4347
4502
  </xsl:template><xsl:template match="*[local-name() = 'term']">
4348
4503
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4504
+
4349
4505
 
4350
4506
 
4351
4507
 
@@ -4787,7 +4943,11 @@
4787
4943
  <xsl:value-of select="."/>
4788
4944
  </xsl:template><xsl:template match="node()" mode="contents">
4789
4945
  <xsl:apply-templates mode="contents"/>
4790
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4946
+ </xsl:template><xsl:template match="*[local-name() = 'preface' or local-name() = 'sections']/*[local-name() = 'p'][@type = 'section-title' and not(@displayorder)]" priority="3" mode="contents"/><xsl:template match="*[local-name() = 'p'][@type = 'section-title' and not(@displayorder)]" mode="contents_no_displayorder">
4947
+ <xsl:call-template name="contents_section-title"/>
4948
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4949
+ <xsl:call-template name="contents_section-title"/>
4950
+ </xsl:template><xsl:template match="*[local-name() = 'clause']/*[local-name() = 'p'][@type = 'section-title' and (@depth != ../*[local-name() = 'title']/@depth or ../*[local-name() = 'title']/@depth = 1)]" priority="3" mode="contents"/><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" name="contents_section-title" mode="contents">
4791
4951
  <xsl:variable name="level">
4792
4952
  <xsl:call-template name="getLevel">
4793
4953
  <xsl:with-param name="depth" select="@depth"/>
@@ -4856,13 +5016,14 @@
4856
5016
  <xsl:apply-templates mode="bookmarks"/>
4857
5017
  </xsl:template><xsl:template name="addBookmarks">
4858
5018
  <xsl:param name="contents"/>
4859
- <xsl:if test="xalan:nodeset($contents)//item">
5019
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5020
+ <xsl:if test="$contents_nodes//item">
4860
5021
  <fo:bookmark-tree>
4861
5022
  <xsl:choose>
4862
- <xsl:when test="xalan:nodeset($contents)/doc">
5023
+ <xsl:when test="$contents_nodes/doc">
4863
5024
  <xsl:choose>
4864
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4865
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5025
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
5026
+ <xsl:for-each select="$contents_nodes/doc">
4866
5027
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4867
5028
  <xsl:if test="@bundle = 'true'">
4868
5029
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4913,7 +5074,7 @@
4913
5074
  </xsl:for-each>
4914
5075
  </xsl:when>
4915
5076
  <xsl:otherwise>
4916
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5077
+ <xsl:for-each select="$contents_nodes/doc">
4917
5078
 
4918
5079
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4919
5080
 
@@ -4931,25 +5092,36 @@
4931
5092
  </xsl:choose>
4932
5093
  </xsl:when>
4933
5094
  <xsl:otherwise>
4934
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
5095
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
5096
+
5097
+ <xsl:call-template name="insertFigureBookmarks">
5098
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5099
+ </xsl:call-template>
5100
+
5101
+ <xsl:call-template name="insertTableBookmarks">
5102
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5103
+ <xsl:with-param name="lang" select="@lang"/>
5104
+ </xsl:call-template>
5105
+
4935
5106
  </xsl:otherwise>
4936
5107
  </xsl:choose>
4937
5108
 
5109
+
4938
5110
 
4939
5111
 
4940
5112
 
4941
5113
 
4942
-
4943
-
5114
+
4944
5115
 
4945
5116
  </fo:bookmark-tree>
4946
5117
  </xsl:if>
4947
5118
  </xsl:template><xsl:template name="insertFigureBookmarks">
4948
5119
  <xsl:param name="contents"/>
4949
- <xsl:if test="xalan:nodeset($contents)/figure">
4950
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
5120
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5121
+ <xsl:if test="$contents_nodes/figure">
5122
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4951
5123
  <fo:bookmark-title>Figures</fo:bookmark-title>
4952
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5124
+ <xsl:for-each select="$contents_nodes/figure">
4953
5125
  <fo:bookmark internal-destination="{@id}">
4954
5126
  <fo:bookmark-title>
4955
5127
  <xsl:value-of select="normalize-space(title)"/>
@@ -4958,18 +5130,40 @@
4958
5130
  </xsl:for-each>
4959
5131
  </fo:bookmark>
4960
5132
  </xsl:if>
5133
+
5134
+
5135
+ <xsl:if test="$contents_nodes//figures/figure">
5136
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5137
+
5138
+
5139
+
5140
+ <xsl:variable name="bookmark-title">
5141
+
5142
+ <xsl:value-of select="$title-list-figures"/>
5143
+
5144
+ </xsl:variable>
5145
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
5146
+ <xsl:for-each select="$contents_nodes//figures/figure">
5147
+ <fo:bookmark internal-destination="{@id}">
5148
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5149
+ </fo:bookmark>
5150
+ </xsl:for-each>
5151
+ </fo:bookmark>
5152
+ </xsl:if>
5153
+
4961
5154
  </xsl:template><xsl:template name="insertTableBookmarks">
4962
5155
  <xsl:param name="contents"/>
4963
5156
  <xsl:param name="lang"/>
4964
- <xsl:if test="xalan:nodeset($contents)/table">
4965
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5157
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5158
+ <xsl:if test="$contents_nodes/table">
5159
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4966
5160
  <fo:bookmark-title>
4967
5161
  <xsl:choose>
4968
5162
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4969
5163
  <xsl:otherwise>Tables</xsl:otherwise>
4970
5164
  </xsl:choose>
4971
5165
  </fo:bookmark-title>
4972
- <xsl:for-each select="xalan:nodeset($contents)/table">
5166
+ <xsl:for-each select="$contents_nodes/table">
4973
5167
  <fo:bookmark internal-destination="{@id}">
4974
5168
  <fo:bookmark-title>
4975
5169
  <xsl:value-of select="normalize-space(title)"/>
@@ -4978,6 +5172,29 @@
4978
5172
  </xsl:for-each>
4979
5173
  </fo:bookmark>
4980
5174
  </xsl:if>
5175
+
5176
+
5177
+ <xsl:if test="$contents_nodes//tables/table">
5178
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5179
+
5180
+
5181
+
5182
+ <xsl:variable name="bookmark-title">
5183
+
5184
+ <xsl:value-of select="$title-list-tables"/>
5185
+
5186
+ </xsl:variable>
5187
+
5188
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
5189
+
5190
+ <xsl:for-each select="$contents_nodes//tables/table">
5191
+ <fo:bookmark internal-destination="{@id}">
5192
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5193
+ </fo:bookmark>
5194
+ </xsl:for-each>
5195
+ </fo:bookmark>
5196
+ </xsl:if>
5197
+
4981
5198
  </xsl:template><xsl:template name="getLangVersion">
4982
5199
  <xsl:param name="lang"/>
4983
5200
  <xsl:param name="doctype" select="''"/>
@@ -5202,7 +5419,51 @@
5202
5419
  <xsl:with-param name="text" select="$text_step1"/>
5203
5420
  </xsl:call-template>
5204
5421
  </xsl:variable>
5205
- <xsl:value-of select="$text_step2"/>
5422
+
5423
+ <!-- <xsl:value-of select="$text_step2"/> -->
5424
+
5425
+ <!-- add zero-width space after space -->
5426
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5427
+
5428
+ <!-- split text by zero-width space -->
5429
+ <xsl:variable name="text_step4">
5430
+ <xsl:call-template name="split">
5431
+ <xsl:with-param name="pText" select="$text_step3"/>
5432
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5433
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5434
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5435
+ </xsl:call-template>
5436
+ </xsl:variable>
5437
+
5438
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5439
+ <xsl:choose>
5440
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5441
+ <xsl:call-template name="interspers">
5442
+ <xsl:with-param name="str" select="."/>
5443
+ </xsl:call-template>
5444
+ </xsl:when>
5445
+ <xsl:otherwise>
5446
+ <xsl:value-of select="."/>
5447
+ </xsl:otherwise>
5448
+ </xsl:choose>
5449
+ </xsl:for-each>
5450
+
5451
+ </xsl:template><xsl:template name="interspers">
5452
+ <xsl:param name="str"/>
5453
+ <xsl:param name="char" select="$zero_width_space"/>
5454
+ <xsl:if test="$str != ''">
5455
+ <xsl:value-of select="substring($str, 1, 1)"/>
5456
+
5457
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5458
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5459
+ <xsl:value-of select="$char"/>
5460
+ </xsl:if>
5461
+
5462
+ <xsl:call-template name="interspers">
5463
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5464
+ <xsl:with-param name="char" select="$char"/>
5465
+ </xsl:call-template>
5466
+ </xsl:if>
5206
5467
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5207
5468
  <xsl:apply-templates mode="syntax_highlight"/>
5208
5469
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5638,6 +5899,8 @@
5638
5899
  </xsl:otherwise>
5639
5900
  </xsl:choose> -->
5640
5901
  </fo:block>
5902
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5903
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5641
5904
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5642
5905
  <xsl:if test="normalize-space() != ''">
5643
5906
  <xsl:value-of select="."/>
@@ -5712,26 +5975,24 @@
5712
5975
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5713
5976
  <xsl:text>— </xsl:text>
5714
5977
  <xsl:apply-templates/>
5715
- </xsl:template><xsl:variable name="bibitem_hidden_">
5978
+ </xsl:template><xsl:variable name="bibitems_">
5979
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5980
+ <xsl:copy-of select="."/>
5981
+ </xsl:for-each>
5982
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5716
5983
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5717
5984
  <xsl:copy-of select="."/>
5718
5985
  </xsl:for-each>
5719
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5986
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5720
5987
  <xsl:copy-of select="."/>
5721
5988
  </xsl:for-each>
5722
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5723
-
5724
- <xsl:variable name="bibitemid">
5725
- <xsl:choose>
5726
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5727
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5728
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5729
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5730
- </xsl:choose>
5731
- </xsl:variable>
5732
-
5989
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5990
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5991
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5992
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5733
5993
  <xsl:choose>
5734
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5994
+ <!-- <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) -->
5995
+ <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) -->
5735
5996
  <fo:inline xsl:use-attribute-sets="eref-style">
5736
5997
  <xsl:if test="@type = 'footnote'">
5737
5998
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5745,8 +6006,8 @@
5745
6006
  <xsl:variable name="text" select="normalize-space()"/>
5746
6007
 
5747
6008
 
5748
-
5749
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6009
+
6010
+ <fo:basic-link fox:alt-text="{@citeas}">
5750
6011
  <xsl:if test="normalize-space(@citeas) = ''">
5751
6012
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5752
6013
  </xsl:if>
@@ -5756,14 +6017,21 @@
5756
6017
 
5757
6018
  </xsl:if>
5758
6019
 
5759
-
6020
+ <xsl:choose>
6021
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6022
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6023
+ </xsl:when>
6024
+ <xsl:otherwise>
6025
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6026
+ </xsl:otherwise>
6027
+ </xsl:choose>
5760
6028
 
5761
6029
  <xsl:apply-templates/>
5762
6030
  </fo:basic-link>
5763
-
6031
+
5764
6032
  </fo:inline>
5765
6033
  </xsl:when>
5766
- <xsl:otherwise>
6034
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5767
6035
  <fo:inline><xsl:apply-templates/></fo:inline>
5768
6036
  </xsl:otherwise>
5769
6037
  </xsl:choose>
@@ -6104,7 +6372,7 @@
6104
6372
 
6105
6373
 
6106
6374
 
6107
-
6375
+
6108
6376
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6109
6377
  </fo:list-block>
6110
6378
  <!-- <xsl:for-each select="./iho:note">
@@ -6122,6 +6390,11 @@
6122
6390
 
6123
6391
 
6124
6392
 
6393
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6394
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6395
+ <xsl:call-template name="append_add-style"/>
6396
+ </xsl:if>
6397
+
6125
6398
  <xsl:call-template name="getListItemFormat"/>
6126
6399
  </fo:block>
6127
6400
  </fo:list-item-label>
@@ -6459,23 +6732,45 @@
6459
6732
  <xsl:apply-templates/>
6460
6733
  </fo:inline>
6461
6734
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6735
+
6736
+ <!-- list of footnotes to calculate actual footnotes number -->
6737
+ <xsl:variable name="p_fn_">
6738
+ <xsl:call-template name="get_fn_list"/>
6739
+ </xsl:variable>
6740
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6741
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6742
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6743
+ <!-- fn sequence number in document -->
6744
+ <xsl:variable name="current_fn_number">
6745
+ <xsl:choose>
6746
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6747
+ <xsl:otherwise>
6748
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6749
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6750
+ </xsl:otherwise>
6751
+ </xsl:choose>
6752
+ </xsl:variable>
6462
6753
  <fo:footnote>
6463
6754
  <xsl:variable name="number">
6464
6755
 
6465
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6756
+ <xsl:value-of select="$current_fn_number"/>
6466
6757
 
6467
6758
  </xsl:variable>
6759
+
6760
+ <xsl:variable name="current_fn_number_text">
6761
+ <xsl:value-of select="$number"/>
6762
+
6763
+ </xsl:variable>
6764
+
6468
6765
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6469
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6470
- <xsl:value-of select="$number"/>
6471
-
6766
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6767
+ <xsl:value-of select="$current_fn_number_text"/>
6472
6768
  </fo:basic-link>
6473
6769
  </fo:inline>
6474
6770
  <fo:footnote-body>
6475
6771
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6476
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6477
- <xsl:value-of select="$number"/>
6478
-
6772
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6773
+ <xsl:value-of select="$current_fn_number_text"/>
6479
6774
  </fo:inline>
6480
6775
  <xsl:apply-templates/>
6481
6776
  </fo:block>
@@ -6728,6 +7023,78 @@
6728
7023
  <xsl:apply-templates/>
6729
7024
  </fo:block>
6730
7025
 
7026
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7027
+ <xsl:copy>
7028
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7029
+ </xsl:copy>
7030
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7031
+ <xsl:copy>
7032
+ <xsl:copy-of select="@*"/>
7033
+
7034
+ <xsl:variable name="nodes_preface_">
7035
+ <xsl:for-each select="*">
7036
+ <node id="{@id}"/>
7037
+ </xsl:for-each>
7038
+ </xsl:variable>
7039
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7040
+
7041
+ <xsl:for-each select="*">
7042
+ <xsl:sort select="@displayorder" data-type="number"/>
7043
+
7044
+ <!-- process Section's title -->
7045
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7046
+ <xsl:if test="$preceding-sibling_id != ''">
7047
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7048
+ </xsl:if>
7049
+
7050
+ <xsl:choose>
7051
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7052
+ <xsl:otherwise>
7053
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7054
+ </xsl:otherwise>
7055
+ </xsl:choose>
7056
+
7057
+ </xsl:for-each>
7058
+ </xsl:copy>
7059
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7060
+ <xsl:copy>
7061
+ <xsl:copy-of select="@*"/>
7062
+
7063
+ <xsl:variable name="nodes_sections_">
7064
+ <xsl:for-each select="*">
7065
+ <node id="{@id}"/>
7066
+ </xsl:for-each>
7067
+ </xsl:variable>
7068
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7069
+
7070
+ <!-- move section 'Normative references' inside 'sections' -->
7071
+ <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']]">
7072
+ <xsl:sort select="@displayorder" data-type="number"/>
7073
+
7074
+ <!-- process Section's title -->
7075
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7076
+ <xsl:if test="$preceding-sibling_id != ''">
7077
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7078
+ </xsl:if>
7079
+
7080
+ <xsl:choose>
7081
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7082
+ <xsl:otherwise>
7083
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7084
+ </xsl:otherwise>
7085
+ </xsl:choose>
7086
+
7087
+ </xsl:for-each>
7088
+ </xsl:copy>
7089
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7090
+ <xsl:copy>
7091
+ <xsl:copy-of select="@*"/>
7092
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7093
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7094
+ <xsl:sort select="@displayorder" data-type="number"/>
7095
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7096
+ </xsl:for-each>
7097
+ </xsl:copy>
6731
7098
  </xsl:template><xsl:template name="convertDate">
6732
7099
  <xsl:param name="date"/>
6733
7100
  <xsl:param name="format" select="'short'"/>
@@ -6972,22 +7339,25 @@
6972
7339
  <xsl:param name="pText" select="."/>
6973
7340
  <xsl:param name="sep" select="','"/>
6974
7341
  <xsl:param name="normalize-space" select="'true'"/>
7342
+ <xsl:param name="keep_sep" select="'false'"/>
6975
7343
  <xsl:if test="string-length($pText) &gt;0">
6976
- <item>
6977
- <xsl:choose>
6978
- <xsl:when test="$normalize-space = 'true'">
6979
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6980
- </xsl:when>
6981
- <xsl:otherwise>
6982
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6983
- </xsl:otherwise>
6984
- </xsl:choose>
6985
- </item>
6986
- <xsl:call-template name="split">
6987
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6988
- <xsl:with-param name="sep" select="$sep"/>
6989
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
6990
- </xsl:call-template>
7344
+ <item>
7345
+ <xsl:choose>
7346
+ <xsl:when test="$normalize-space = 'true'">
7347
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7348
+ </xsl:when>
7349
+ <xsl:otherwise>
7350
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7351
+ </xsl:otherwise>
7352
+ </xsl:choose>
7353
+ </item>
7354
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7355
+ <xsl:call-template name="split">
7356
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7357
+ <xsl:with-param name="sep" select="$sep"/>
7358
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7359
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7360
+ </xsl:call-template>
6991
7361
  </xsl:if>
6992
7362
  </xsl:template><xsl:template name="getDocumentId">
6993
7363
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -7178,53 +7548,153 @@
7178
7548
  <xsl:param name="first"/>
7179
7549
  <xsl:if test="$number != ''">
7180
7550
  <xsl:variable name="words">
7181
- <words>
7182
- <word cardinal="1">One-</word>
7183
- <word ordinal="1">First </word>
7184
- <word cardinal="2">Two-</word>
7185
- <word ordinal="2">Second </word>
7186
- <word cardinal="3">Three-</word>
7187
- <word ordinal="3">Third </word>
7188
- <word cardinal="4">Four-</word>
7189
- <word ordinal="4">Fourth </word>
7190
- <word cardinal="5">Five-</word>
7191
- <word ordinal="5">Fifth </word>
7192
- <word cardinal="6">Six-</word>
7193
- <word ordinal="6">Sixth </word>
7194
- <word cardinal="7">Seven-</word>
7195
- <word ordinal="7">Seventh </word>
7196
- <word cardinal="8">Eight-</word>
7197
- <word ordinal="8">Eighth </word>
7198
- <word cardinal="9">Nine-</word>
7199
- <word ordinal="9">Ninth </word>
7200
- <word ordinal="10">Tenth </word>
7201
- <word ordinal="11">Eleventh </word>
7202
- <word ordinal="12">Twelfth </word>
7203
- <word ordinal="13">Thirteenth </word>
7204
- <word ordinal="14">Fourteenth </word>
7205
- <word ordinal="15">Fifteenth </word>
7206
- <word ordinal="16">Sixteenth </word>
7207
- <word ordinal="17">Seventeenth </word>
7208
- <word ordinal="18">Eighteenth </word>
7209
- <word ordinal="19">Nineteenth </word>
7210
- <word cardinal="20">Twenty-</word>
7211
- <word ordinal="20">Twentieth </word>
7212
- <word cardinal="30">Thirty-</word>
7213
- <word ordinal="30">Thirtieth </word>
7214
- <word cardinal="40">Forty-</word>
7215
- <word ordinal="40">Fortieth </word>
7216
- <word cardinal="50">Fifty-</word>
7217
- <word ordinal="50">Fiftieth </word>
7218
- <word cardinal="60">Sixty-</word>
7219
- <word ordinal="60">Sixtieth </word>
7220
- <word cardinal="70">Seventy-</word>
7221
- <word ordinal="70">Seventieth </word>
7222
- <word cardinal="80">Eighty-</word>
7223
- <word ordinal="80">Eightieth </word>
7224
- <word cardinal="90">Ninety-</word>
7225
- <word ordinal="90">Ninetieth </word>
7226
- <word cardinal="100">Hundred-</word>
7227
- <word ordinal="100">Hundredth </word>
7551
+ <words>
7552
+ <xsl:choose>
7553
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7554
+ <word cardinal="1">Une-</word>
7555
+ <word ordinal="1">Première </word>
7556
+ <word cardinal="2">Deux-</word>
7557
+ <word ordinal="2">Seconde </word>
7558
+ <word cardinal="3">Trois-</word>
7559
+ <word ordinal="3">Tierce </word>
7560
+ <word cardinal="4">Quatre-</word>
7561
+ <word ordinal="4">Quatrième </word>
7562
+ <word cardinal="5">Cinq-</word>
7563
+ <word ordinal="5">Cinquième </word>
7564
+ <word cardinal="6">Six-</word>
7565
+ <word ordinal="6">Sixième </word>
7566
+ <word cardinal="7">Sept-</word>
7567
+ <word ordinal="7">Septième </word>
7568
+ <word cardinal="8">Huit-</word>
7569
+ <word ordinal="8">Huitième </word>
7570
+ <word cardinal="9">Neuf-</word>
7571
+ <word ordinal="9">Neuvième </word>
7572
+ <word ordinal="10">Dixième </word>
7573
+ <word ordinal="11">Onzième </word>
7574
+ <word ordinal="12">Douzième </word>
7575
+ <word ordinal="13">Treizième </word>
7576
+ <word ordinal="14">Quatorzième </word>
7577
+ <word ordinal="15">Quinzième </word>
7578
+ <word ordinal="16">Seizième </word>
7579
+ <word ordinal="17">Dix-septième </word>
7580
+ <word ordinal="18">Dix-huitième </word>
7581
+ <word ordinal="19">Dix-neuvième </word>
7582
+ <word cardinal="20">Vingt-</word>
7583
+ <word ordinal="20">Vingtième </word>
7584
+ <word cardinal="30">Trente-</word>
7585
+ <word ordinal="30">Trentième </word>
7586
+ <word cardinal="40">Quarante-</word>
7587
+ <word ordinal="40">Quarantième </word>
7588
+ <word cardinal="50">Cinquante-</word>
7589
+ <word ordinal="50">Cinquantième </word>
7590
+ <word cardinal="60">Soixante-</word>
7591
+ <word ordinal="60">Soixantième </word>
7592
+ <word cardinal="70">Septante-</word>
7593
+ <word ordinal="70">Septantième </word>
7594
+ <word cardinal="80">Huitante-</word>
7595
+ <word ordinal="80">Huitantième </word>
7596
+ <word cardinal="90">Nonante-</word>
7597
+ <word ordinal="90">Nonantième </word>
7598
+ <word cardinal="100">Cent-</word>
7599
+ <word ordinal="100">Centième </word>
7600
+ </xsl:when>
7601
+ <xsl:when test="$lang = 'ru'">
7602
+ <word cardinal="1">Одна-</word>
7603
+ <word ordinal="1">Первое </word>
7604
+ <word cardinal="2">Две-</word>
7605
+ <word ordinal="2">Второе </word>
7606
+ <word cardinal="3">Три-</word>
7607
+ <word ordinal="3">Третье </word>
7608
+ <word cardinal="4">Четыре-</word>
7609
+ <word ordinal="4">Четвертое </word>
7610
+ <word cardinal="5">Пять-</word>
7611
+ <word ordinal="5">Пятое </word>
7612
+ <word cardinal="6">Шесть-</word>
7613
+ <word ordinal="6">Шестое </word>
7614
+ <word cardinal="7">Семь-</word>
7615
+ <word ordinal="7">Седьмое </word>
7616
+ <word cardinal="8">Восемь-</word>
7617
+ <word ordinal="8">Восьмое </word>
7618
+ <word cardinal="9">Девять-</word>
7619
+ <word ordinal="9">Девятое </word>
7620
+ <word ordinal="10">Десятое </word>
7621
+ <word ordinal="11">Одиннадцатое </word>
7622
+ <word ordinal="12">Двенадцатое </word>
7623
+ <word ordinal="13">Тринадцатое </word>
7624
+ <word ordinal="14">Четырнадцатое </word>
7625
+ <word ordinal="15">Пятнадцатое </word>
7626
+ <word ordinal="16">Шестнадцатое </word>
7627
+ <word ordinal="17">Семнадцатое </word>
7628
+ <word ordinal="18">Восемнадцатое </word>
7629
+ <word ordinal="19">Девятнадцатое </word>
7630
+ <word cardinal="20">Двадцать-</word>
7631
+ <word ordinal="20">Двадцатое </word>
7632
+ <word cardinal="30">Тридцать-</word>
7633
+ <word ordinal="30">Тридцатое </word>
7634
+ <word cardinal="40">Сорок-</word>
7635
+ <word ordinal="40">Сороковое </word>
7636
+ <word cardinal="50">Пятьдесят-</word>
7637
+ <word ordinal="50">Пятидесятое </word>
7638
+ <word cardinal="60">Шестьдесят-</word>
7639
+ <word ordinal="60">Шестидесятое </word>
7640
+ <word cardinal="70">Семьдесят-</word>
7641
+ <word ordinal="70">Семидесятое </word>
7642
+ <word cardinal="80">Восемьдесят-</word>
7643
+ <word ordinal="80">Восьмидесятое </word>
7644
+ <word cardinal="90">Девяносто-</word>
7645
+ <word ordinal="90">Девяностое </word>
7646
+ <word cardinal="100">Сто-</word>
7647
+ <word ordinal="100">Сотое </word>
7648
+ </xsl:when>
7649
+ <xsl:otherwise> <!-- default english -->
7650
+ <word cardinal="1">One-</word>
7651
+ <word ordinal="1">First </word>
7652
+ <word cardinal="2">Two-</word>
7653
+ <word ordinal="2">Second </word>
7654
+ <word cardinal="3">Three-</word>
7655
+ <word ordinal="3">Third </word>
7656
+ <word cardinal="4">Four-</word>
7657
+ <word ordinal="4">Fourth </word>
7658
+ <word cardinal="5">Five-</word>
7659
+ <word ordinal="5">Fifth </word>
7660
+ <word cardinal="6">Six-</word>
7661
+ <word ordinal="6">Sixth </word>
7662
+ <word cardinal="7">Seven-</word>
7663
+ <word ordinal="7">Seventh </word>
7664
+ <word cardinal="8">Eight-</word>
7665
+ <word ordinal="8">Eighth </word>
7666
+ <word cardinal="9">Nine-</word>
7667
+ <word ordinal="9">Ninth </word>
7668
+ <word ordinal="10">Tenth </word>
7669
+ <word ordinal="11">Eleventh </word>
7670
+ <word ordinal="12">Twelfth </word>
7671
+ <word ordinal="13">Thirteenth </word>
7672
+ <word ordinal="14">Fourteenth </word>
7673
+ <word ordinal="15">Fifteenth </word>
7674
+ <word ordinal="16">Sixteenth </word>
7675
+ <word ordinal="17">Seventeenth </word>
7676
+ <word ordinal="18">Eighteenth </word>
7677
+ <word ordinal="19">Nineteenth </word>
7678
+ <word cardinal="20">Twenty-</word>
7679
+ <word ordinal="20">Twentieth </word>
7680
+ <word cardinal="30">Thirty-</word>
7681
+ <word ordinal="30">Thirtieth </word>
7682
+ <word cardinal="40">Forty-</word>
7683
+ <word ordinal="40">Fortieth </word>
7684
+ <word cardinal="50">Fifty-</word>
7685
+ <word ordinal="50">Fiftieth </word>
7686
+ <word cardinal="60">Sixty-</word>
7687
+ <word ordinal="60">Sixtieth </word>
7688
+ <word cardinal="70">Seventy-</word>
7689
+ <word ordinal="70">Seventieth </word>
7690
+ <word cardinal="80">Eighty-</word>
7691
+ <word ordinal="80">Eightieth </word>
7692
+ <word cardinal="90">Ninety-</word>
7693
+ <word ordinal="90">Ninetieth </word>
7694
+ <word cardinal="100">Hundred-</word>
7695
+ <word ordinal="100">Hundredth </word>
7696
+ </xsl:otherwise>
7697
+ </xsl:choose>
7228
7698
  </words>
7229
7699
  </xsl:variable>
7230
7700
 
@@ -7298,4 +7768,18 @@
7298
7768
  <xsl:otherwise>_</xsl:otherwise>
7299
7769
  </xsl:choose>
7300
7770
  </xsl:attribute>
7771
+ </xsl:template><xsl:template name="substring-after-last">
7772
+ <xsl:param name="value"/>
7773
+ <xsl:param name="delimiter"/>
7774
+ <xsl:choose>
7775
+ <xsl:when test="contains($value, $delimiter)">
7776
+ <xsl:call-template name="substring-after-last">
7777
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7778
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7779
+ </xsl:call-template>
7780
+ </xsl:when>
7781
+ <xsl:otherwise>
7782
+ <xsl:value-of select="$value"/>
7783
+ </xsl:otherwise>
7784
+ </xsl:choose>
7301
7785
  </xsl:template></xsl:stylesheet>