metanorma-ribose 2.0.3 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@
20
20
  </xsl:variable>
21
21
 
22
22
 
23
- <xsl:variable name="contents">
23
+ <xsl:variable name="contents_">
24
24
  <contents>
25
25
 
26
26
  <xsl:apply-templates select="/rsd:rsd-standard/rsd:preface/rsd:abstract" mode="contents"/>
@@ -32,9 +32,10 @@
32
32
 
33
33
  <xsl:call-template name="processMainSectionsDefault_Contents"/>
34
34
 
35
+ <xsl:call-template name="processTablesFigures_Contents"/>
35
36
  </contents>
36
37
  </xsl:variable>
37
-
38
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
38
39
 
39
40
  <xsl:variable name="docnumber_version">
40
41
  <xsl:value-of select="/rsd:rsd-standard/rsd:bibdata/rsd:docidentifier[@type = 'rsd' or @type = 'Ribose']"/>
@@ -399,7 +400,7 @@
399
400
  <fo:page-sequence master-reference="document" force-page-count="no-force"> <!-- master-reference="toc" -->
400
401
  <xsl:call-template name="insertHeaderFooter"/>
401
402
  <fo:flow flow-name="xsl-region-body">
402
- <xsl:if test="xalan:nodeset($contents)//item[@display = 'true']">
403
+ <xsl:if test="$contents//item[@display = 'true']">
403
404
  <fo:block role="TOC">
404
405
  <!-- <fo:block-container absolute-position="fixed" left="13mm" top="15mm"> -->
405
406
  <fo:block font-size="27pt" font-weight="bold" color="black" margin-left="-15mm" margin-bottom="13mm" role="H1">
@@ -411,7 +412,7 @@
411
412
 
412
413
  <fo:block-container margin-left="32mm" margin-right="-17mm">
413
414
  <fo:block-container margin-left="0mm" margin-right="0mm">
414
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']">
415
+ <xsl:for-each select="$contents//item[@display = 'true']">
415
416
  <fo:block font-size="13pt" role="TOCI">
416
417
  <xsl:if test="@level = 1">
417
418
  <xsl:if test="preceding-sibling::item[@display = 'true' and @level = 1]">
@@ -434,13 +435,34 @@
434
435
  <xsl:apply-templates select="title"/>
435
436
  <xsl:text>  </xsl:text>
436
437
  <fo:inline>
437
- <fo:leader leader-pattern="rule" rule-thickness="0.2mm"/>
438
- <fo:inline padding-left="2mm"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
439
- </fo:inline>
438
+ <fo:leader leader-pattern="rule" rule-thickness="0.2mm"/>
439
+ <fo:inline padding-left="2mm"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
440
+ </fo:inline>
440
441
  </fo:basic-link>
441
442
  </fo:block>
442
443
  </fo:block>
443
444
  </xsl:for-each>
445
+
446
+ <!-- List of Tables -->
447
+ <xsl:if test="$contents//tables/table">
448
+ <xsl:call-template name="insertListOf_Title">
449
+ <xsl:with-param name="title" select="$title-list-tables"/>
450
+ </xsl:call-template>
451
+ <xsl:for-each select="$contents//tables/table">
452
+ <xsl:call-template name="insertListOf_Item"/>
453
+ </xsl:for-each>
454
+ </xsl:if>
455
+
456
+ <!-- List of Figures -->
457
+ <xsl:if test="$contents//figures/figure">
458
+ <xsl:call-template name="insertListOf_Title">
459
+ <xsl:with-param name="title" select="$title-list-figures"/>
460
+ </xsl:call-template>
461
+ <xsl:for-each select="$contents//figures/figure">
462
+ <xsl:call-template name="insertListOf_Item"/>
463
+ </xsl:for-each>
464
+ </xsl:if>
465
+
444
466
  </fo:block-container>
445
467
  </fo:block-container>
446
468
  </fo:block>
@@ -485,6 +507,30 @@
485
507
  </fo:root>
486
508
  </xsl:template>
487
509
 
510
+ <xsl:template name="insertListOf_Title">
511
+ <xsl:param name="title"/>
512
+ <fo:block font-size="13pt" font-weight="bold" color="black" margin-top="12pt" margin-bottom="12pt" keep-with-next="always">
513
+ <xsl:value-of select="$title"/>
514
+ </fo:block>
515
+ </xsl:template>
516
+
517
+ <xsl:template name="insertListOf_Item">
518
+ <fo:block font-size="13pt" role="TOCI" margin-left="16.5mm" space-before="4pt" space-after="5pt">
519
+ <fo:block text-align-last="justify">
520
+ <fo:basic-link internal-destination="{@id}">
521
+ <xsl:call-template name="setAltText">
522
+ <xsl:with-param name="value" select="@alt-text"/>
523
+ </xsl:call-template>
524
+ <xsl:apply-templates select="." mode="contents"/>
525
+ <xsl:text>  </xsl:text>
526
+ <fo:inline>
527
+ <fo:leader leader-pattern="rule" rule-thickness="0.2mm"/>
528
+ <fo:inline padding-left="2mm"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
529
+ </fo:inline>
530
+ </fo:basic-link>
531
+ </fo:block>
532
+ </fo:block>
533
+ </xsl:template>
488
534
 
489
535
  <xsl:template match="rsd:title" mode="cover_page">
490
536
  <xsl:apply-templates/>
@@ -1189,6 +1235,10 @@
1189
1235
  <xsl:text>Édition </xsl:text>
1190
1236
  </title-edition>
1191
1237
 
1238
+ <title-edition lang="ru">
1239
+ <xsl:text>Издание </xsl:text>
1240
+ </title-edition>
1241
+
1192
1242
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1193
1243
  <title-toc lang="en">
1194
1244
 
@@ -1203,7 +1253,7 @@
1203
1253
  <xsl:text>Contents</xsl:text>
1204
1254
 
1205
1255
  </title-toc>
1206
-
1256
+
1207
1257
  <title-descriptors lang="en">Descriptors</title-descriptors>
1208
1258
 
1209
1259
  <title-part lang="en">
@@ -1215,7 +1265,11 @@
1215
1265
 
1216
1266
 
1217
1267
 
1218
- </title-part>
1268
+ </title-part>
1269
+ <title-part lang="ru">
1270
+
1271
+
1272
+ </title-part>
1219
1273
  <title-part lang="zh">第 # 部分:</title-part>
1220
1274
 
1221
1275
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -1231,10 +1285,35 @@
1231
1285
 
1232
1286
  <title-summary lang="en">Summary</title-summary>
1233
1287
 
1288
+ <title-continued lang="ru">(продолжение)</title-continued>
1234
1289
  <title-continued lang="en">(continued)</title-continued>
1235
1290
  <title-continued lang="fr">(continué)</title-continued>
1236
1291
 
1237
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
1292
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
1293
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
1294
+ <xsl:value-of select="$toc_table_title"/>
1295
+ <xsl:if test="normalize-space($toc_table_title) = ''">
1296
+ <xsl:call-template name="getTitle">
1297
+ <xsl:with-param name="name" select="'title-list-tables'"/>
1298
+ </xsl:call-template>
1299
+ </xsl:if>
1300
+ </xsl:variable><xsl:variable name="title-list-figures">
1301
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
1302
+ <xsl:value-of select="$toc_figure_title"/>
1303
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
1304
+ <xsl:call-template name="getTitle">
1305
+ <xsl:with-param name="name" select="'title-list-figures'"/>
1306
+ </xsl:call-template>
1307
+ </xsl:if>
1308
+ </xsl:variable><xsl:variable name="title-list-recommendations">
1309
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
1310
+ <xsl:value-of select="$toc_requirement_title"/>
1311
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
1312
+ <xsl:call-template name="getTitle">
1313
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
1314
+ </xsl:call-template>
1315
+ </xsl:if>
1316
+ </xsl:variable><xsl:variable name="bibdata">
1238
1317
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1239
1318
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1240
1319
  </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">
@@ -2036,13 +2115,19 @@
2036
2115
  </xsl:attribute-set><xsl:variable name="color-added-text">
2037
2116
  <xsl:text>rgb(0, 255, 0)</xsl:text>
2038
2117
  </xsl:variable><xsl:attribute-set name="add-style">
2039
- <xsl:attribute name="color">red</xsl:attribute>
2040
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
2041
- <!-- <xsl:attribute name="color">black</xsl:attribute>
2042
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2043
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
2044
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2045
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
2118
+
2119
+ <xsl:attribute name="color">red</xsl:attribute>
2120
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
2121
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
2122
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2123
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
2124
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2125
+
2126
+ </xsl:attribute-set><xsl:variable name="add-style">
2127
+ <add-style xsl:use-attribute-sets="add-style"/>
2128
+ </xsl:variable><xsl:template name="append_add-style">
2129
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
2130
+ </xsl:template><xsl:variable name="color-deleted-text">
2046
2131
  <xsl:text>red</xsl:text>
2047
2132
  </xsl:variable><xsl:attribute-set name="del-style">
2048
2133
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -2488,14 +2573,42 @@
2488
2573
 
2489
2574
 
2490
2575
  </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">
2576
+ <xsl:variable name="nodes_preface_">
2577
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2578
+ <node id="{@id}"/>
2579
+ </xsl:for-each>
2580
+ </xsl:variable>
2581
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2582
+
2491
2583
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2492
2584
  <xsl:sort select="@displayorder" data-type="number"/>
2585
+
2586
+ <!-- process Section's title -->
2587
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2588
+ <xsl:if test="$preceding-sibling_id != ''">
2589
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2590
+ </xsl:if>
2591
+
2493
2592
  <xsl:apply-templates select="." mode="contents"/>
2494
2593
  </xsl:for-each>
2495
2594
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2496
2595
 
2596
+ <xsl:variable name="nodes_sections_">
2597
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
2598
+ <node id="{@id}"/>
2599
+ </xsl:for-each>
2600
+ </xsl:variable>
2601
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
2602
+
2497
2603
  <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']]">
2498
2604
  <xsl:sort select="@displayorder" data-type="number"/>
2605
+
2606
+ <!-- process Section's title -->
2607
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2608
+ <xsl:if test="$preceding-sibling_id != ''">
2609
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2610
+ </xsl:if>
2611
+
2499
2612
  <xsl:apply-templates select="." mode="contents"/>
2500
2613
  </xsl:for-each>
2501
2614
 
@@ -2508,6 +2621,30 @@
2508
2621
  <xsl:sort select="@displayorder" data-type="number"/>
2509
2622
  <xsl:apply-templates select="." mode="contents"/>
2510
2623
  </xsl:for-each>
2624
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2625
+ <xsl:param name="always"/>
2626
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2627
+ <xsl:call-template name="processTables_Contents"/>
2628
+ </xsl:if>
2629
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2630
+ <xsl:call-template name="processFigures_Contents"/>
2631
+ </xsl:if>
2632
+ </xsl:template><xsl:template name="processTables_Contents">
2633
+ <tables>
2634
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2635
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2636
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2637
+ </table>
2638
+ </xsl:for-each>
2639
+ </tables>
2640
+ </xsl:template><xsl:template name="processFigures_Contents">
2641
+ <figures>
2642
+ <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) != '']">
2643
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2644
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2645
+ </figure>
2646
+ </xsl:for-each>
2647
+ </figures>
2511
2648
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2512
2649
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2513
2650
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2637,7 +2774,7 @@
2637
2774
  </xsl:call-template>
2638
2775
  </xsl:if>
2639
2776
  </xsl:variable>
2640
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2777
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2641
2778
 
2642
2779
 
2643
2780
  <xsl:variable name="margin-side">
@@ -2897,7 +3034,7 @@
2897
3034
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2898
3035
  <!-- 2009 thinspace -->
2899
3036
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2900
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
3037
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2901
3038
  </xsl:call-template>
2902
3039
  </xsl:variable>
2903
3040
  <xsl:variable name="max_length">
@@ -3288,37 +3425,7 @@
3288
3425
 
3289
3426
  <!-- list of footnotes to calculate actual footnotes number -->
3290
3427
  <xsl:variable name="p_fn_">
3291
- <xsl:choose>
3292
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3293
- <fn gen_id="{generate-id(.)}">
3294
- <xsl:copy-of select="@*"/>
3295
- <xsl:copy-of select="node()"/>
3296
- </fn>
3297
- </xsl:when>
3298
- <xsl:otherwise>
3299
- <!-- itetation for:
3300
- footnotes in bibdata/title
3301
- footnotes in bibliography
3302
- footnotes in document's body (except table's head/body/foot and figure text)
3303
- -->
3304
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3305
- <fn gen_id="{generate-id(.)}">
3306
- <xsl:copy-of select="@*"/>
3307
- <xsl:copy-of select="node()"/>
3308
- </fn>
3309
- </xsl:for-each>
3310
- <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']/*">
3311
- <xsl:sort select="@displayorder" data-type="number"/>
3312
- <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])]">
3313
- <!-- copy unique fn -->
3314
- <fn gen_id="{generate-id(.)}">
3315
- <xsl:copy-of select="@*"/>
3316
- <xsl:copy-of select="node()"/>
3317
- </fn>
3318
- </xsl:for-each>
3319
- </xsl:for-each>
3320
- </xsl:otherwise>
3321
- </xsl:choose>
3428
+ <xsl:call-template name="get_fn_list"/>
3322
3429
  </xsl:variable>
3323
3430
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3324
3431
 
@@ -3379,6 +3486,38 @@
3379
3486
  <xsl:copy-of select="$footnote_inline"/>
3380
3487
  </xsl:otherwise>
3381
3488
  </xsl:choose>
3489
+ </xsl:template><xsl:template name="get_fn_list">
3490
+ <xsl:choose>
3491
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3492
+ <fn gen_id="{generate-id(.)}">
3493
+ <xsl:copy-of select="@*"/>
3494
+ <xsl:copy-of select="node()"/>
3495
+ </fn>
3496
+ </xsl:when>
3497
+ <xsl:otherwise>
3498
+ <!-- itetation for:
3499
+ footnotes in bibdata/title
3500
+ footnotes in bibliography
3501
+ footnotes in document's body (except table's head/body/foot and figure text)
3502
+ -->
3503
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3504
+ <fn gen_id="{generate-id(.)}">
3505
+ <xsl:copy-of select="@*"/>
3506
+ <xsl:copy-of select="node()"/>
3507
+ </fn>
3508
+ </xsl:for-each>
3509
+ <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']/*">
3510
+ <xsl:sort select="@displayorder" data-type="number"/>
3511
+ <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])]">
3512
+ <!-- copy unique fn -->
3513
+ <fn gen_id="{generate-id(.)}">
3514
+ <xsl:copy-of select="@*"/>
3515
+ <xsl:copy-of select="node()"/>
3516
+ </fn>
3517
+ </xsl:for-each>
3518
+ </xsl:for-each>
3519
+ </xsl:otherwise>
3520
+ </xsl:choose>
3382
3521
  </xsl:template><xsl:template name="table_fn_display">
3383
3522
  <xsl:variable name="references">
3384
3523
 
@@ -3550,7 +3689,7 @@
3550
3689
  </fo:inline>
3551
3690
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3552
3691
  <fo:inline><xsl:value-of select="."/></fo:inline>
3553
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3692
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3554
3693
  <fo:inline>
3555
3694
  <xsl:apply-templates/>
3556
3695
  </fo:inline>
@@ -4545,6 +4684,9 @@
4545
4684
  </fo:inline>
4546
4685
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
4547
4686
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4687
+ <xsl:if test="parent::*[local-name() = 'add']">
4688
+ <xsl:call-template name="append_add-style"/>
4689
+ </xsl:if>
4548
4690
  <xsl:apply-templates/>
4549
4691
  </fo:basic-link>
4550
4692
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -4647,6 +4789,13 @@
4647
4789
 
4648
4790
 
4649
4791
 
4792
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4793
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4794
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4795
+ <xsl:call-template name="append_add-style"/>
4796
+ </xsl:if>
4797
+
4798
+
4650
4799
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
4651
4800
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
4652
4801
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -4685,6 +4834,12 @@
4685
4834
 
4686
4835
 
4687
4836
 
4837
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4838
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4839
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4840
+ <xsl:call-template name="append_add-style"/>
4841
+ </xsl:if>
4842
+
4688
4843
  <xsl:apply-templates select="*[local-name() = 'name']"/>
4689
4844
 
4690
4845
  </fo:inline>
@@ -4738,6 +4893,7 @@
4738
4893
  </fo:block>
4739
4894
  </xsl:template><xsl:template match="*[local-name() = 'term']">
4740
4895
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4896
+
4741
4897
 
4742
4898
 
4743
4899
 
@@ -5174,7 +5330,11 @@
5174
5330
  <xsl:value-of select="."/>
5175
5331
  </xsl:template><xsl:template match="node()" mode="contents">
5176
5332
  <xsl:apply-templates mode="contents"/>
5177
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
5333
+ </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">
5334
+ <xsl:call-template name="contents_section-title"/>
5335
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
5336
+ <xsl:call-template name="contents_section-title"/>
5337
+ </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">
5178
5338
  <xsl:variable name="level">
5179
5339
  <xsl:call-template name="getLevel">
5180
5340
  <xsl:with-param name="depth" select="@depth"/>
@@ -5243,13 +5403,14 @@
5243
5403
  <xsl:apply-templates mode="bookmarks"/>
5244
5404
  </xsl:template><xsl:template name="addBookmarks">
5245
5405
  <xsl:param name="contents"/>
5246
- <xsl:if test="xalan:nodeset($contents)//item">
5406
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5407
+ <xsl:if test="$contents_nodes//item">
5247
5408
  <fo:bookmark-tree>
5248
5409
  <xsl:choose>
5249
- <xsl:when test="xalan:nodeset($contents)/doc">
5410
+ <xsl:when test="$contents_nodes/doc">
5250
5411
  <xsl:choose>
5251
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5252
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5412
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
5413
+ <xsl:for-each select="$contents_nodes/doc">
5253
5414
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5254
5415
  <xsl:if test="@bundle = 'true'">
5255
5416
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -5300,7 +5461,7 @@
5300
5461
  </xsl:for-each>
5301
5462
  </xsl:when>
5302
5463
  <xsl:otherwise>
5303
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5464
+ <xsl:for-each select="$contents_nodes/doc">
5304
5465
 
5305
5466
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5306
5467
 
@@ -5318,25 +5479,36 @@
5318
5479
  </xsl:choose>
5319
5480
  </xsl:when>
5320
5481
  <xsl:otherwise>
5321
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
5482
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
5483
+
5484
+ <xsl:call-template name="insertFigureBookmarks">
5485
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5486
+ </xsl:call-template>
5487
+
5488
+ <xsl:call-template name="insertTableBookmarks">
5489
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5490
+ <xsl:with-param name="lang" select="@lang"/>
5491
+ </xsl:call-template>
5492
+
5322
5493
  </xsl:otherwise>
5323
5494
  </xsl:choose>
5324
5495
 
5496
+
5325
5497
 
5326
5498
 
5327
5499
 
5328
5500
 
5329
-
5330
-
5501
+
5331
5502
 
5332
5503
  </fo:bookmark-tree>
5333
5504
  </xsl:if>
5334
5505
  </xsl:template><xsl:template name="insertFigureBookmarks">
5335
5506
  <xsl:param name="contents"/>
5336
- <xsl:if test="xalan:nodeset($contents)/figure">
5337
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
5507
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5508
+ <xsl:if test="$contents_nodes/figure">
5509
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
5338
5510
  <fo:bookmark-title>Figures</fo:bookmark-title>
5339
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5511
+ <xsl:for-each select="$contents_nodes/figure">
5340
5512
  <fo:bookmark internal-destination="{@id}">
5341
5513
  <fo:bookmark-title>
5342
5514
  <xsl:value-of select="normalize-space(title)"/>
@@ -5345,18 +5517,40 @@
5345
5517
  </xsl:for-each>
5346
5518
  </fo:bookmark>
5347
5519
  </xsl:if>
5520
+
5521
+
5522
+ <xsl:if test="$contents_nodes//figures/figure">
5523
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5524
+
5525
+
5526
+
5527
+ <xsl:variable name="bookmark-title">
5528
+
5529
+ <xsl:value-of select="$title-list-figures"/>
5530
+
5531
+ </xsl:variable>
5532
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
5533
+ <xsl:for-each select="$contents_nodes//figures/figure">
5534
+ <fo:bookmark internal-destination="{@id}">
5535
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5536
+ </fo:bookmark>
5537
+ </xsl:for-each>
5538
+ </fo:bookmark>
5539
+ </xsl:if>
5540
+
5348
5541
  </xsl:template><xsl:template name="insertTableBookmarks">
5349
5542
  <xsl:param name="contents"/>
5350
5543
  <xsl:param name="lang"/>
5351
- <xsl:if test="xalan:nodeset($contents)/table">
5352
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5544
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5545
+ <xsl:if test="$contents_nodes/table">
5546
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
5353
5547
  <fo:bookmark-title>
5354
5548
  <xsl:choose>
5355
5549
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
5356
5550
  <xsl:otherwise>Tables</xsl:otherwise>
5357
5551
  </xsl:choose>
5358
5552
  </fo:bookmark-title>
5359
- <xsl:for-each select="xalan:nodeset($contents)/table">
5553
+ <xsl:for-each select="$contents_nodes/table">
5360
5554
  <fo:bookmark internal-destination="{@id}">
5361
5555
  <fo:bookmark-title>
5362
5556
  <xsl:value-of select="normalize-space(title)"/>
@@ -5365,6 +5559,29 @@
5365
5559
  </xsl:for-each>
5366
5560
  </fo:bookmark>
5367
5561
  </xsl:if>
5562
+
5563
+
5564
+ <xsl:if test="$contents_nodes//tables/table">
5565
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5566
+
5567
+
5568
+
5569
+ <xsl:variable name="bookmark-title">
5570
+
5571
+ <xsl:value-of select="$title-list-tables"/>
5572
+
5573
+ </xsl:variable>
5574
+
5575
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
5576
+
5577
+ <xsl:for-each select="$contents_nodes//tables/table">
5578
+ <fo:bookmark internal-destination="{@id}">
5579
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5580
+ </fo:bookmark>
5581
+ </xsl:for-each>
5582
+ </fo:bookmark>
5583
+ </xsl:if>
5584
+
5368
5585
  </xsl:template><xsl:template name="getLangVersion">
5369
5586
  <xsl:param name="lang"/>
5370
5587
  <xsl:param name="doctype" select="''"/>
@@ -5607,7 +5824,51 @@
5607
5824
  <xsl:with-param name="text" select="$text_step1"/>
5608
5825
  </xsl:call-template>
5609
5826
  </xsl:variable>
5610
- <xsl:value-of select="$text_step2"/>
5827
+
5828
+ <!-- <xsl:value-of select="$text_step2"/> -->
5829
+
5830
+ <!-- add zero-width space after space -->
5831
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5832
+
5833
+ <!-- split text by zero-width space -->
5834
+ <xsl:variable name="text_step4">
5835
+ <xsl:call-template name="split">
5836
+ <xsl:with-param name="pText" select="$text_step3"/>
5837
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5838
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5839
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5840
+ </xsl:call-template>
5841
+ </xsl:variable>
5842
+
5843
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5844
+ <xsl:choose>
5845
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5846
+ <xsl:call-template name="interspers">
5847
+ <xsl:with-param name="str" select="."/>
5848
+ </xsl:call-template>
5849
+ </xsl:when>
5850
+ <xsl:otherwise>
5851
+ <xsl:value-of select="."/>
5852
+ </xsl:otherwise>
5853
+ </xsl:choose>
5854
+ </xsl:for-each>
5855
+
5856
+ </xsl:template><xsl:template name="interspers">
5857
+ <xsl:param name="str"/>
5858
+ <xsl:param name="char" select="$zero_width_space"/>
5859
+ <xsl:if test="$str != ''">
5860
+ <xsl:value-of select="substring($str, 1, 1)"/>
5861
+
5862
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5863
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5864
+ <xsl:value-of select="$char"/>
5865
+ </xsl:if>
5866
+
5867
+ <xsl:call-template name="interspers">
5868
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5869
+ <xsl:with-param name="char" select="$char"/>
5870
+ </xsl:call-template>
5871
+ </xsl:if>
5611
5872
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5612
5873
  <xsl:apply-templates mode="syntax_highlight"/>
5613
5874
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6049,6 +6310,8 @@
6049
6310
  </xsl:otherwise>
6050
6311
  </xsl:choose> -->
6051
6312
  </fo:block>
6313
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6314
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6052
6315
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6053
6316
  <xsl:if test="normalize-space() != ''">
6054
6317
  <xsl:value-of select="."/>
@@ -6123,26 +6386,24 @@
6123
6386
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6124
6387
  <xsl:text>— </xsl:text>
6125
6388
  <xsl:apply-templates/>
6126
- </xsl:template><xsl:variable name="bibitem_hidden_">
6389
+ </xsl:template><xsl:variable name="bibitems_">
6390
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
6391
+ <xsl:copy-of select="."/>
6392
+ </xsl:for-each>
6393
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
6127
6394
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6128
6395
  <xsl:copy-of select="."/>
6129
6396
  </xsl:for-each>
6130
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6397
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
6131
6398
  <xsl:copy-of select="."/>
6132
6399
  </xsl:for-each>
6133
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6134
-
6135
- <xsl:variable name="bibitemid">
6136
- <xsl:choose>
6137
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6138
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6139
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6140
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6141
- </xsl:choose>
6142
- </xsl:variable>
6143
-
6400
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6401
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6402
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
6403
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
6144
6404
  <xsl:choose>
6145
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
6405
+ <!-- <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) -->
6406
+ <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) -->
6146
6407
  <fo:inline xsl:use-attribute-sets="eref-style">
6147
6408
  <xsl:if test="@type = 'footnote'">
6148
6409
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6156,8 +6417,8 @@
6156
6417
  <xsl:variable name="text" select="normalize-space()"/>
6157
6418
 
6158
6419
 
6159
-
6160
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6420
+
6421
+ <fo:basic-link fox:alt-text="{@citeas}">
6161
6422
  <xsl:if test="normalize-space(@citeas) = ''">
6162
6423
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6163
6424
  </xsl:if>
@@ -6167,14 +6428,21 @@
6167
6428
 
6168
6429
  </xsl:if>
6169
6430
 
6170
-
6431
+ <xsl:choose>
6432
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6433
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6434
+ </xsl:when>
6435
+ <xsl:otherwise>
6436
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6437
+ </xsl:otherwise>
6438
+ </xsl:choose>
6171
6439
 
6172
6440
  <xsl:apply-templates/>
6173
6441
  </fo:basic-link>
6174
-
6442
+
6175
6443
  </fo:inline>
6176
6444
  </xsl:when>
6177
- <xsl:otherwise>
6445
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6178
6446
  <fo:inline><xsl:apply-templates/></fo:inline>
6179
6447
  </xsl:otherwise>
6180
6448
  </xsl:choose>
@@ -6505,7 +6773,7 @@
6505
6773
 
6506
6774
 
6507
6775
 
6508
-
6776
+
6509
6777
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6510
6778
  </fo:list-block>
6511
6779
  <!-- <xsl:for-each select="./iho:note">
@@ -6523,6 +6791,11 @@
6523
6791
 
6524
6792
 
6525
6793
 
6794
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6795
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6796
+ <xsl:call-template name="append_add-style"/>
6797
+ </xsl:if>
6798
+
6526
6799
  <xsl:call-template name="getListItemFormat"/>
6527
6800
  </fo:block>
6528
6801
  </fo:list-item-label>
@@ -6911,6 +7184,24 @@
6911
7184
  <xsl:apply-templates/>
6912
7185
  </fo:inline>
6913
7186
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7187
+
7188
+ <!-- list of footnotes to calculate actual footnotes number -->
7189
+ <xsl:variable name="p_fn_">
7190
+ <xsl:call-template name="get_fn_list"/>
7191
+ </xsl:variable>
7192
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7193
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7194
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7195
+ <!-- fn sequence number in document -->
7196
+ <xsl:variable name="current_fn_number">
7197
+ <xsl:choose>
7198
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7199
+ <xsl:otherwise>
7200
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7201
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7202
+ </xsl:otherwise>
7203
+ </xsl:choose>
7204
+ </xsl:variable>
6914
7205
  <fo:footnote>
6915
7206
  <xsl:variable name="number">
6916
7207
 
@@ -6919,22 +7210,26 @@
6919
7210
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6920
7211
  </xsl:when>
6921
7212
  <xsl:otherwise>
6922
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7213
+ <xsl:value-of select="$current_fn_number"/>
6923
7214
  </xsl:otherwise>
6924
7215
  </xsl:choose>
6925
7216
 
6926
7217
  </xsl:variable>
7218
+
7219
+ <xsl:variable name="current_fn_number_text">
7220
+ <xsl:value-of select="$number"/>
7221
+
7222
+ </xsl:variable>
7223
+
6927
7224
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6928
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6929
- <xsl:value-of select="$number"/>
6930
-
7225
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7226
+ <xsl:value-of select="$current_fn_number_text"/>
6931
7227
  </fo:basic-link>
6932
7228
  </fo:inline>
6933
7229
  <fo:footnote-body>
6934
7230
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6935
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6936
- <xsl:value-of select="$number"/>
6937
-
7231
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7232
+ <xsl:value-of select="$current_fn_number_text"/>
6938
7233
  </fo:inline>
6939
7234
  <xsl:apply-templates/>
6940
7235
  </fo:block>
@@ -7180,6 +7475,78 @@
7180
7475
  <xsl:apply-templates/>
7181
7476
  </fo:block>
7182
7477
 
7478
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7479
+ <xsl:copy>
7480
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7481
+ </xsl:copy>
7482
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7483
+ <xsl:copy>
7484
+ <xsl:copy-of select="@*"/>
7485
+
7486
+ <xsl:variable name="nodes_preface_">
7487
+ <xsl:for-each select="*">
7488
+ <node id="{@id}"/>
7489
+ </xsl:for-each>
7490
+ </xsl:variable>
7491
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7492
+
7493
+ <xsl:for-each select="*">
7494
+ <xsl:sort select="@displayorder" data-type="number"/>
7495
+
7496
+ <!-- process Section's title -->
7497
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7498
+ <xsl:if test="$preceding-sibling_id != ''">
7499
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7500
+ </xsl:if>
7501
+
7502
+ <xsl:choose>
7503
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7504
+ <xsl:otherwise>
7505
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7506
+ </xsl:otherwise>
7507
+ </xsl:choose>
7508
+
7509
+ </xsl:for-each>
7510
+ </xsl:copy>
7511
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7512
+ <xsl:copy>
7513
+ <xsl:copy-of select="@*"/>
7514
+
7515
+ <xsl:variable name="nodes_sections_">
7516
+ <xsl:for-each select="*">
7517
+ <node id="{@id}"/>
7518
+ </xsl:for-each>
7519
+ </xsl:variable>
7520
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7521
+
7522
+ <!-- move section 'Normative references' inside 'sections' -->
7523
+ <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']]">
7524
+ <xsl:sort select="@displayorder" data-type="number"/>
7525
+
7526
+ <!-- process Section's title -->
7527
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7528
+ <xsl:if test="$preceding-sibling_id != ''">
7529
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7530
+ </xsl:if>
7531
+
7532
+ <xsl:choose>
7533
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7534
+ <xsl:otherwise>
7535
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7536
+ </xsl:otherwise>
7537
+ </xsl:choose>
7538
+
7539
+ </xsl:for-each>
7540
+ </xsl:copy>
7541
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7542
+ <xsl:copy>
7543
+ <xsl:copy-of select="@*"/>
7544
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7545
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7546
+ <xsl:sort select="@displayorder" data-type="number"/>
7547
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7548
+ </xsl:for-each>
7549
+ </xsl:copy>
7183
7550
  </xsl:template><xsl:template name="convertDate">
7184
7551
  <xsl:param name="date"/>
7185
7552
  <xsl:param name="format" select="'short'"/>
@@ -7424,22 +7791,25 @@
7424
7791
  <xsl:param name="pText" select="."/>
7425
7792
  <xsl:param name="sep" select="','"/>
7426
7793
  <xsl:param name="normalize-space" select="'true'"/>
7794
+ <xsl:param name="keep_sep" select="'false'"/>
7427
7795
  <xsl:if test="string-length($pText) &gt;0">
7428
- <item>
7429
- <xsl:choose>
7430
- <xsl:when test="$normalize-space = 'true'">
7431
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7432
- </xsl:when>
7433
- <xsl:otherwise>
7434
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7435
- </xsl:otherwise>
7436
- </xsl:choose>
7437
- </item>
7438
- <xsl:call-template name="split">
7439
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7440
- <xsl:with-param name="sep" select="$sep"/>
7441
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
7442
- </xsl:call-template>
7796
+ <item>
7797
+ <xsl:choose>
7798
+ <xsl:when test="$normalize-space = 'true'">
7799
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7800
+ </xsl:when>
7801
+ <xsl:otherwise>
7802
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7803
+ </xsl:otherwise>
7804
+ </xsl:choose>
7805
+ </item>
7806
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7807
+ <xsl:call-template name="split">
7808
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7809
+ <xsl:with-param name="sep" select="$sep"/>
7810
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7811
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7812
+ </xsl:call-template>
7443
7813
  </xsl:if>
7444
7814
  </xsl:template><xsl:template name="getDocumentId">
7445
7815
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -7630,53 +8000,153 @@
7630
8000
  <xsl:param name="first"/>
7631
8001
  <xsl:if test="$number != ''">
7632
8002
  <xsl:variable name="words">
7633
- <words>
7634
- <word cardinal="1">One-</word>
7635
- <word ordinal="1">First </word>
7636
- <word cardinal="2">Two-</word>
7637
- <word ordinal="2">Second </word>
7638
- <word cardinal="3">Three-</word>
7639
- <word ordinal="3">Third </word>
7640
- <word cardinal="4">Four-</word>
7641
- <word ordinal="4">Fourth </word>
7642
- <word cardinal="5">Five-</word>
7643
- <word ordinal="5">Fifth </word>
7644
- <word cardinal="6">Six-</word>
7645
- <word ordinal="6">Sixth </word>
7646
- <word cardinal="7">Seven-</word>
7647
- <word ordinal="7">Seventh </word>
7648
- <word cardinal="8">Eight-</word>
7649
- <word ordinal="8">Eighth </word>
7650
- <word cardinal="9">Nine-</word>
7651
- <word ordinal="9">Ninth </word>
7652
- <word ordinal="10">Tenth </word>
7653
- <word ordinal="11">Eleventh </word>
7654
- <word ordinal="12">Twelfth </word>
7655
- <word ordinal="13">Thirteenth </word>
7656
- <word ordinal="14">Fourteenth </word>
7657
- <word ordinal="15">Fifteenth </word>
7658
- <word ordinal="16">Sixteenth </word>
7659
- <word ordinal="17">Seventeenth </word>
7660
- <word ordinal="18">Eighteenth </word>
7661
- <word ordinal="19">Nineteenth </word>
7662
- <word cardinal="20">Twenty-</word>
7663
- <word ordinal="20">Twentieth </word>
7664
- <word cardinal="30">Thirty-</word>
7665
- <word ordinal="30">Thirtieth </word>
7666
- <word cardinal="40">Forty-</word>
7667
- <word ordinal="40">Fortieth </word>
7668
- <word cardinal="50">Fifty-</word>
7669
- <word ordinal="50">Fiftieth </word>
7670
- <word cardinal="60">Sixty-</word>
7671
- <word ordinal="60">Sixtieth </word>
7672
- <word cardinal="70">Seventy-</word>
7673
- <word ordinal="70">Seventieth </word>
7674
- <word cardinal="80">Eighty-</word>
7675
- <word ordinal="80">Eightieth </word>
7676
- <word cardinal="90">Ninety-</word>
7677
- <word ordinal="90">Ninetieth </word>
7678
- <word cardinal="100">Hundred-</word>
7679
- <word ordinal="100">Hundredth </word>
8003
+ <words>
8004
+ <xsl:choose>
8005
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
8006
+ <word cardinal="1">Une-</word>
8007
+ <word ordinal="1">Première </word>
8008
+ <word cardinal="2">Deux-</word>
8009
+ <word ordinal="2">Seconde </word>
8010
+ <word cardinal="3">Trois-</word>
8011
+ <word ordinal="3">Tierce </word>
8012
+ <word cardinal="4">Quatre-</word>
8013
+ <word ordinal="4">Quatrième </word>
8014
+ <word cardinal="5">Cinq-</word>
8015
+ <word ordinal="5">Cinquième </word>
8016
+ <word cardinal="6">Six-</word>
8017
+ <word ordinal="6">Sixième </word>
8018
+ <word cardinal="7">Sept-</word>
8019
+ <word ordinal="7">Septième </word>
8020
+ <word cardinal="8">Huit-</word>
8021
+ <word ordinal="8">Huitième </word>
8022
+ <word cardinal="9">Neuf-</word>
8023
+ <word ordinal="9">Neuvième </word>
8024
+ <word ordinal="10">Dixième </word>
8025
+ <word ordinal="11">Onzième </word>
8026
+ <word ordinal="12">Douzième </word>
8027
+ <word ordinal="13">Treizième </word>
8028
+ <word ordinal="14">Quatorzième </word>
8029
+ <word ordinal="15">Quinzième </word>
8030
+ <word ordinal="16">Seizième </word>
8031
+ <word ordinal="17">Dix-septième </word>
8032
+ <word ordinal="18">Dix-huitième </word>
8033
+ <word ordinal="19">Dix-neuvième </word>
8034
+ <word cardinal="20">Vingt-</word>
8035
+ <word ordinal="20">Vingtième </word>
8036
+ <word cardinal="30">Trente-</word>
8037
+ <word ordinal="30">Trentième </word>
8038
+ <word cardinal="40">Quarante-</word>
8039
+ <word ordinal="40">Quarantième </word>
8040
+ <word cardinal="50">Cinquante-</word>
8041
+ <word ordinal="50">Cinquantième </word>
8042
+ <word cardinal="60">Soixante-</word>
8043
+ <word ordinal="60">Soixantième </word>
8044
+ <word cardinal="70">Septante-</word>
8045
+ <word ordinal="70">Septantième </word>
8046
+ <word cardinal="80">Huitante-</word>
8047
+ <word ordinal="80">Huitantième </word>
8048
+ <word cardinal="90">Nonante-</word>
8049
+ <word ordinal="90">Nonantième </word>
8050
+ <word cardinal="100">Cent-</word>
8051
+ <word ordinal="100">Centième </word>
8052
+ </xsl:when>
8053
+ <xsl:when test="$lang = 'ru'">
8054
+ <word cardinal="1">Одна-</word>
8055
+ <word ordinal="1">Первое </word>
8056
+ <word cardinal="2">Две-</word>
8057
+ <word ordinal="2">Второе </word>
8058
+ <word cardinal="3">Три-</word>
8059
+ <word ordinal="3">Третье </word>
8060
+ <word cardinal="4">Четыре-</word>
8061
+ <word ordinal="4">Четвертое </word>
8062
+ <word cardinal="5">Пять-</word>
8063
+ <word ordinal="5">Пятое </word>
8064
+ <word cardinal="6">Шесть-</word>
8065
+ <word ordinal="6">Шестое </word>
8066
+ <word cardinal="7">Семь-</word>
8067
+ <word ordinal="7">Седьмое </word>
8068
+ <word cardinal="8">Восемь-</word>
8069
+ <word ordinal="8">Восьмое </word>
8070
+ <word cardinal="9">Девять-</word>
8071
+ <word ordinal="9">Девятое </word>
8072
+ <word ordinal="10">Десятое </word>
8073
+ <word ordinal="11">Одиннадцатое </word>
8074
+ <word ordinal="12">Двенадцатое </word>
8075
+ <word ordinal="13">Тринадцатое </word>
8076
+ <word ordinal="14">Четырнадцатое </word>
8077
+ <word ordinal="15">Пятнадцатое </word>
8078
+ <word ordinal="16">Шестнадцатое </word>
8079
+ <word ordinal="17">Семнадцатое </word>
8080
+ <word ordinal="18">Восемнадцатое </word>
8081
+ <word ordinal="19">Девятнадцатое </word>
8082
+ <word cardinal="20">Двадцать-</word>
8083
+ <word ordinal="20">Двадцатое </word>
8084
+ <word cardinal="30">Тридцать-</word>
8085
+ <word ordinal="30">Тридцатое </word>
8086
+ <word cardinal="40">Сорок-</word>
8087
+ <word ordinal="40">Сороковое </word>
8088
+ <word cardinal="50">Пятьдесят-</word>
8089
+ <word ordinal="50">Пятидесятое </word>
8090
+ <word cardinal="60">Шестьдесят-</word>
8091
+ <word ordinal="60">Шестидесятое </word>
8092
+ <word cardinal="70">Семьдесят-</word>
8093
+ <word ordinal="70">Семидесятое </word>
8094
+ <word cardinal="80">Восемьдесят-</word>
8095
+ <word ordinal="80">Восьмидесятое </word>
8096
+ <word cardinal="90">Девяносто-</word>
8097
+ <word ordinal="90">Девяностое </word>
8098
+ <word cardinal="100">Сто-</word>
8099
+ <word ordinal="100">Сотое </word>
8100
+ </xsl:when>
8101
+ <xsl:otherwise> <!-- default english -->
8102
+ <word cardinal="1">One-</word>
8103
+ <word ordinal="1">First </word>
8104
+ <word cardinal="2">Two-</word>
8105
+ <word ordinal="2">Second </word>
8106
+ <word cardinal="3">Three-</word>
8107
+ <word ordinal="3">Third </word>
8108
+ <word cardinal="4">Four-</word>
8109
+ <word ordinal="4">Fourth </word>
8110
+ <word cardinal="5">Five-</word>
8111
+ <word ordinal="5">Fifth </word>
8112
+ <word cardinal="6">Six-</word>
8113
+ <word ordinal="6">Sixth </word>
8114
+ <word cardinal="7">Seven-</word>
8115
+ <word ordinal="7">Seventh </word>
8116
+ <word cardinal="8">Eight-</word>
8117
+ <word ordinal="8">Eighth </word>
8118
+ <word cardinal="9">Nine-</word>
8119
+ <word ordinal="9">Ninth </word>
8120
+ <word ordinal="10">Tenth </word>
8121
+ <word ordinal="11">Eleventh </word>
8122
+ <word ordinal="12">Twelfth </word>
8123
+ <word ordinal="13">Thirteenth </word>
8124
+ <word ordinal="14">Fourteenth </word>
8125
+ <word ordinal="15">Fifteenth </word>
8126
+ <word ordinal="16">Sixteenth </word>
8127
+ <word ordinal="17">Seventeenth </word>
8128
+ <word ordinal="18">Eighteenth </word>
8129
+ <word ordinal="19">Nineteenth </word>
8130
+ <word cardinal="20">Twenty-</word>
8131
+ <word ordinal="20">Twentieth </word>
8132
+ <word cardinal="30">Thirty-</word>
8133
+ <word ordinal="30">Thirtieth </word>
8134
+ <word cardinal="40">Forty-</word>
8135
+ <word ordinal="40">Fortieth </word>
8136
+ <word cardinal="50">Fifty-</word>
8137
+ <word ordinal="50">Fiftieth </word>
8138
+ <word cardinal="60">Sixty-</word>
8139
+ <word ordinal="60">Sixtieth </word>
8140
+ <word cardinal="70">Seventy-</word>
8141
+ <word ordinal="70">Seventieth </word>
8142
+ <word cardinal="80">Eighty-</word>
8143
+ <word ordinal="80">Eightieth </word>
8144
+ <word cardinal="90">Ninety-</word>
8145
+ <word ordinal="90">Ninetieth </word>
8146
+ <word cardinal="100">Hundred-</word>
8147
+ <word ordinal="100">Hundredth </word>
8148
+ </xsl:otherwise>
8149
+ </xsl:choose>
7680
8150
  </words>
7681
8151
  </xsl:variable>
7682
8152
 
@@ -7750,4 +8220,18 @@
7750
8220
  <xsl:otherwise>_</xsl:otherwise>
7751
8221
  </xsl:choose>
7752
8222
  </xsl:attribute>
8223
+ </xsl:template><xsl:template name="substring-after-last">
8224
+ <xsl:param name="value"/>
8225
+ <xsl:param name="delimiter"/>
8226
+ <xsl:choose>
8227
+ <xsl:when test="contains($value, $delimiter)">
8228
+ <xsl:call-template name="substring-after-last">
8229
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
8230
+ <xsl:with-param name="delimiter" select="$delimiter"/>
8231
+ </xsl:call-template>
8232
+ </xsl:when>
8233
+ <xsl:otherwise>
8234
+ <xsl:value-of select="$value"/>
8235
+ </xsl:otherwise>
8236
+ </xsl:choose>
7753
8237
  </xsl:template></xsl:stylesheet>