metanorma-csa 2.0.3 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,12 +16,14 @@
16
16
 
17
17
  <xsl:variable name="color-header-document">rgb(79, 201, 204)</xsl:variable>
18
18
 
19
- <xsl:variable name="contents">
19
+ <xsl:variable name="contents_">
20
20
  <contents>
21
21
  <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
22
22
  <xsl:call-template name="processMainSectionsDefault_Contents"/>
23
+ <xsl:call-template name="processTablesFigures_Contents"/>
23
24
  </contents>
24
25
  </xsl:variable>
26
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
25
27
 
26
28
  <xsl:template match="/">
27
29
  <xsl:call-template name="namespaceCheck"/>
@@ -104,7 +106,7 @@
104
106
  <xsl:if test="$debug = 'true'">
105
107
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
106
108
  DEBUG
107
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
109
+ contents=<xsl:copy-of select="$contents"/>
108
110
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
109
111
  </xsl:if>
110
112
 
@@ -193,7 +195,7 @@
193
195
  <fo:block font-size="26pt" color="black" margin-top="2pt" margin-bottom="30pt" role="H1"><xsl:value-of select="$title-toc"/></fo:block>
194
196
 
195
197
  <fo:block margin-left="-3mm" role="TOC">
196
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']">
198
+ <xsl:for-each select="$contents//item[@display = 'true']">
197
199
  <fo:block role="TOCI">
198
200
  <fo:list-block>
199
201
  <xsl:attribute name="provisional-distance-between-starts">
@@ -222,6 +224,27 @@
222
224
  </fo:list-block>
223
225
  </fo:block>
224
226
  </xsl:for-each>
227
+
228
+ <!-- List of Tables -->
229
+ <xsl:if test="$contents//tables/table">
230
+ <xsl:call-template name="insertListOf_Title">
231
+ <xsl:with-param name="title" select="$title-list-tables"/>
232
+ </xsl:call-template>
233
+ <xsl:for-each select="$contents//tables/table">
234
+ <xsl:call-template name="insertListOf_Item"/>
235
+ </xsl:for-each>
236
+ </xsl:if>
237
+
238
+ <!-- List of Figures -->
239
+ <xsl:if test="$contents//figures/figure">
240
+ <xsl:call-template name="insertListOf_Title">
241
+ <xsl:with-param name="title" select="$title-list-figures"/>
242
+ </xsl:call-template>
243
+ <xsl:for-each select="$contents//figures/figure">
244
+ <xsl:call-template name="insertListOf_Item"/>
245
+ </xsl:for-each>
246
+ </xsl:if>
247
+
225
248
  </fo:block>
226
249
  </fo:block-container>
227
250
 
@@ -240,6 +263,51 @@
240
263
  </fo:root>
241
264
  </xsl:template>
242
265
 
266
+ <xsl:template name="insertListOf_Title">
267
+ <xsl:param name="title"/>
268
+ <fo:block role="TOCI" keep-with-next="always">
269
+ <fo:list-block provisional-distance-between-starts="3mm">
270
+ <fo:list-item>
271
+ <fo:list-item-label end-indent="label-end()">
272
+ <fo:block font-size="1pt"> </fo:block>
273
+ </fo:list-item-label>
274
+ <fo:list-item-body start-indent="body-start()">
275
+ <fo:block>
276
+ <xsl:value-of select="$title"/>
277
+ </fo:block>
278
+ </fo:list-item-body>
279
+ </fo:list-item>
280
+ </fo:list-block>
281
+ </fo:block>
282
+ </xsl:template>
283
+
284
+ <xsl:template name="insertListOf_Item">
285
+ <fo:block role="TOCI">
286
+ <fo:list-block provisional-distance-between-starts="10mm">
287
+ <fo:list-item>
288
+ <fo:list-item-label end-indent="label-end()">
289
+ <fo:block font-size="1pt"> </fo:block>
290
+ </fo:list-item-label>
291
+ <fo:list-item-body start-indent="body-start()">
292
+ <fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
293
+ <fo:basic-link internal-destination="{@id}">
294
+ <xsl:call-template name="setAltText">
295
+ <xsl:with-param name="value" select="@alt-text"/>
296
+ </xsl:call-template>
297
+ <xsl:apply-templates select="." mode="contents"/>
298
+ <fo:inline keep-together.within-line="always">
299
+ <fo:leader leader-pattern="dots"/>
300
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
301
+ </fo:inline>
302
+ </fo:basic-link>
303
+ </fo:block>
304
+ </fo:list-item-body>
305
+ </fo:list-item>
306
+ </fo:list-block>
307
+ </fo:block>
308
+ </xsl:template>
309
+
310
+
243
311
  <xsl:template match="node()">
244
312
  <xsl:apply-templates/>
245
313
  </xsl:template>
@@ -523,6 +591,10 @@
523
591
  <xsl:text>Édition </xsl:text>
524
592
  </title-edition>
525
593
 
594
+ <title-edition lang="ru">
595
+ <xsl:text>Издание </xsl:text>
596
+ </title-edition>
597
+
526
598
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
527
599
  <title-toc lang="en">
528
600
 
@@ -539,7 +611,7 @@
539
611
  <xsl:text>Contents</xsl:text>
540
612
 
541
613
  </title-toc>
542
-
614
+
543
615
  <title-descriptors lang="en">Descriptors</title-descriptors>
544
616
 
545
617
  <title-part lang="en">
@@ -551,7 +623,11 @@
551
623
 
552
624
 
553
625
 
554
- </title-part>
626
+ </title-part>
627
+ <title-part lang="ru">
628
+
629
+
630
+ </title-part>
555
631
  <title-part lang="zh">第 # 部分:</title-part>
556
632
 
557
633
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -567,10 +643,35 @@
567
643
 
568
644
  <title-summary lang="en">Summary</title-summary>
569
645
 
646
+ <title-continued lang="ru">(продолжение)</title-continued>
570
647
  <title-continued lang="en">(continued)</title-continued>
571
648
  <title-continued lang="fr">(continué)</title-continued>
572
649
 
573
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
650
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
651
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
652
+ <xsl:value-of select="$toc_table_title"/>
653
+ <xsl:if test="normalize-space($toc_table_title) = ''">
654
+ <xsl:call-template name="getTitle">
655
+ <xsl:with-param name="name" select="'title-list-tables'"/>
656
+ </xsl:call-template>
657
+ </xsl:if>
658
+ </xsl:variable><xsl:variable name="title-list-figures">
659
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
660
+ <xsl:value-of select="$toc_figure_title"/>
661
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
662
+ <xsl:call-template name="getTitle">
663
+ <xsl:with-param name="name" select="'title-list-figures'"/>
664
+ </xsl:call-template>
665
+ </xsl:if>
666
+ </xsl:variable><xsl:variable name="title-list-recommendations">
667
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
668
+ <xsl:value-of select="$toc_requirement_title"/>
669
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
670
+ <xsl:call-template name="getTitle">
671
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
672
+ </xsl:call-template>
673
+ </xsl:if>
674
+ </xsl:variable><xsl:variable name="bibdata">
574
675
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
575
676
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
576
677
  </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">
@@ -1299,13 +1400,19 @@
1299
1400
  </xsl:attribute-set><xsl:variable name="color-added-text">
1300
1401
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1301
1402
  </xsl:variable><xsl:attribute-set name="add-style">
1302
- <xsl:attribute name="color">red</xsl:attribute>
1303
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
1304
- <!-- <xsl:attribute name="color">black</xsl:attribute>
1305
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1306
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
1307
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1308
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1403
+
1404
+ <xsl:attribute name="color">red</xsl:attribute>
1405
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1406
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1407
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1408
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1409
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1410
+
1411
+ </xsl:attribute-set><xsl:variable name="add-style">
1412
+ <add-style xsl:use-attribute-sets="add-style"/>
1413
+ </xsl:variable><xsl:template name="append_add-style">
1414
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1415
+ </xsl:template><xsl:variable name="color-deleted-text">
1309
1416
  <xsl:text>red</xsl:text>
1310
1417
  </xsl:variable><xsl:attribute-set name="del-style">
1311
1418
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -1746,14 +1853,42 @@
1746
1853
 
1747
1854
 
1748
1855
  </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">
1856
+ <xsl:variable name="nodes_preface_">
1857
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
1858
+ <node id="{@id}"/>
1859
+ </xsl:for-each>
1860
+ </xsl:variable>
1861
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
1862
+
1749
1863
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1750
1864
  <xsl:sort select="@displayorder" data-type="number"/>
1865
+
1866
+ <!-- process Section's title -->
1867
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
1868
+ <xsl:if test="$preceding-sibling_id != ''">
1869
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
1870
+ </xsl:if>
1871
+
1751
1872
  <xsl:apply-templates select="." mode="contents"/>
1752
1873
  </xsl:for-each>
1753
1874
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
1754
1875
 
1876
+ <xsl:variable name="nodes_sections_">
1877
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
1878
+ <node id="{@id}"/>
1879
+ </xsl:for-each>
1880
+ </xsl:variable>
1881
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
1882
+
1755
1883
  <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']]">
1756
1884
  <xsl:sort select="@displayorder" data-type="number"/>
1885
+
1886
+ <!-- process Section's title -->
1887
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
1888
+ <xsl:if test="$preceding-sibling_id != ''">
1889
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
1890
+ </xsl:if>
1891
+
1757
1892
  <xsl:apply-templates select="." mode="contents"/>
1758
1893
  </xsl:for-each>
1759
1894
 
@@ -1766,6 +1901,30 @@
1766
1901
  <xsl:sort select="@displayorder" data-type="number"/>
1767
1902
  <xsl:apply-templates select="." mode="contents"/>
1768
1903
  </xsl:for-each>
1904
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
1905
+ <xsl:param name="always"/>
1906
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1907
+ <xsl:call-template name="processTables_Contents"/>
1908
+ </xsl:if>
1909
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1910
+ <xsl:call-template name="processFigures_Contents"/>
1911
+ </xsl:if>
1912
+ </xsl:template><xsl:template name="processTables_Contents">
1913
+ <tables>
1914
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
1915
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
1916
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1917
+ </table>
1918
+ </xsl:for-each>
1919
+ </tables>
1920
+ </xsl:template><xsl:template name="processFigures_Contents">
1921
+ <figures>
1922
+ <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) != '']">
1923
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
1924
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1925
+ </figure>
1926
+ </xsl:for-each>
1927
+ </figures>
1769
1928
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1770
1929
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1771
1930
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -1890,7 +2049,7 @@
1890
2049
  </xsl:call-template>
1891
2050
  </xsl:if>
1892
2051
  </xsl:variable>
1893
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2052
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
1894
2053
 
1895
2054
 
1896
2055
  <xsl:variable name="margin-side">
@@ -2156,7 +2315,7 @@
2156
2315
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2157
2316
  <!-- 2009 thinspace -->
2158
2317
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2159
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2318
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2160
2319
  </xsl:call-template>
2161
2320
  </xsl:variable>
2162
2321
  <xsl:variable name="max_length">
@@ -2542,37 +2701,7 @@
2542
2701
 
2543
2702
  <!-- list of footnotes to calculate actual footnotes number -->
2544
2703
  <xsl:variable name="p_fn_">
2545
- <xsl:choose>
2546
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2547
- <fn gen_id="{generate-id(.)}">
2548
- <xsl:copy-of select="@*"/>
2549
- <xsl:copy-of select="node()"/>
2550
- </fn>
2551
- </xsl:when>
2552
- <xsl:otherwise>
2553
- <!-- itetation for:
2554
- footnotes in bibdata/title
2555
- footnotes in bibliography
2556
- footnotes in document's body (except table's head/body/foot and figure text)
2557
- -->
2558
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2559
- <fn gen_id="{generate-id(.)}">
2560
- <xsl:copy-of select="@*"/>
2561
- <xsl:copy-of select="node()"/>
2562
- </fn>
2563
- </xsl:for-each>
2564
- <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']/*">
2565
- <xsl:sort select="@displayorder" data-type="number"/>
2566
- <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])]">
2567
- <!-- copy unique fn -->
2568
- <fn gen_id="{generate-id(.)}">
2569
- <xsl:copy-of select="@*"/>
2570
- <xsl:copy-of select="node()"/>
2571
- </fn>
2572
- </xsl:for-each>
2573
- </xsl:for-each>
2574
- </xsl:otherwise>
2575
- </xsl:choose>
2704
+ <xsl:call-template name="get_fn_list"/>
2576
2705
  </xsl:variable>
2577
2706
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2578
2707
 
@@ -2633,6 +2762,38 @@
2633
2762
  <xsl:copy-of select="$footnote_inline"/>
2634
2763
  </xsl:otherwise>
2635
2764
  </xsl:choose>
2765
+ </xsl:template><xsl:template name="get_fn_list">
2766
+ <xsl:choose>
2767
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2768
+ <fn gen_id="{generate-id(.)}">
2769
+ <xsl:copy-of select="@*"/>
2770
+ <xsl:copy-of select="node()"/>
2771
+ </fn>
2772
+ </xsl:when>
2773
+ <xsl:otherwise>
2774
+ <!-- itetation for:
2775
+ footnotes in bibdata/title
2776
+ footnotes in bibliography
2777
+ footnotes in document's body (except table's head/body/foot and figure text)
2778
+ -->
2779
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2780
+ <fn gen_id="{generate-id(.)}">
2781
+ <xsl:copy-of select="@*"/>
2782
+ <xsl:copy-of select="node()"/>
2783
+ </fn>
2784
+ </xsl:for-each>
2785
+ <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']/*">
2786
+ <xsl:sort select="@displayorder" data-type="number"/>
2787
+ <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])]">
2788
+ <!-- copy unique fn -->
2789
+ <fn gen_id="{generate-id(.)}">
2790
+ <xsl:copy-of select="@*"/>
2791
+ <xsl:copy-of select="node()"/>
2792
+ </fn>
2793
+ </xsl:for-each>
2794
+ </xsl:for-each>
2795
+ </xsl:otherwise>
2796
+ </xsl:choose>
2636
2797
  </xsl:template><xsl:template name="table_fn_display">
2637
2798
  <xsl:variable name="references">
2638
2799
 
@@ -2804,7 +2965,7 @@
2804
2965
  </fo:inline>
2805
2966
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
2806
2967
  <fo:inline><xsl:value-of select="."/></fo:inline>
2807
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
2968
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
2808
2969
  <fo:inline>
2809
2970
  <xsl:apply-templates/>
2810
2971
  </fo:inline>
@@ -3780,6 +3941,9 @@
3780
3941
  </fo:inline>
3781
3942
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
3782
3943
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
3944
+ <xsl:if test="parent::*[local-name() = 'add']">
3945
+ <xsl:call-template name="append_add-style"/>
3946
+ </xsl:if>
3783
3947
  <xsl:apply-templates/>
3784
3948
  </fo:basic-link>
3785
3949
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -3881,6 +4045,13 @@
3881
4045
 
3882
4046
 
3883
4047
 
4048
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4049
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4050
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4051
+ <xsl:call-template name="append_add-style"/>
4052
+ </xsl:if>
4053
+
4054
+
3884
4055
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
3885
4056
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
3886
4057
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -3919,6 +4090,12 @@
3919
4090
 
3920
4091
 
3921
4092
 
4093
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4094
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4095
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4096
+ <xsl:call-template name="append_add-style"/>
4097
+ </xsl:if>
4098
+
3922
4099
  <xsl:apply-templates select="*[local-name() = 'name']"/>
3923
4100
 
3924
4101
  </fo:inline>
@@ -3968,6 +4145,7 @@
3968
4145
  </fo:block>
3969
4146
  </xsl:template><xsl:template match="*[local-name() = 'term']">
3970
4147
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4148
+
3971
4149
 
3972
4150
 
3973
4151
 
@@ -4404,7 +4582,11 @@
4404
4582
  <xsl:value-of select="."/>
4405
4583
  </xsl:template><xsl:template match="node()" mode="contents">
4406
4584
  <xsl:apply-templates mode="contents"/>
4407
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4585
+ </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">
4586
+ <xsl:call-template name="contents_section-title"/>
4587
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4588
+ <xsl:call-template name="contents_section-title"/>
4589
+ </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">
4408
4590
  <xsl:variable name="level">
4409
4591
  <xsl:call-template name="getLevel">
4410
4592
  <xsl:with-param name="depth" select="@depth"/>
@@ -4473,13 +4655,14 @@
4473
4655
  <xsl:apply-templates mode="bookmarks"/>
4474
4656
  </xsl:template><xsl:template name="addBookmarks">
4475
4657
  <xsl:param name="contents"/>
4476
- <xsl:if test="xalan:nodeset($contents)//item">
4658
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4659
+ <xsl:if test="$contents_nodes//item">
4477
4660
  <fo:bookmark-tree>
4478
4661
  <xsl:choose>
4479
- <xsl:when test="xalan:nodeset($contents)/doc">
4662
+ <xsl:when test="$contents_nodes/doc">
4480
4663
  <xsl:choose>
4481
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4482
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4664
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4665
+ <xsl:for-each select="$contents_nodes/doc">
4483
4666
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4484
4667
  <xsl:if test="@bundle = 'true'">
4485
4668
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4530,7 +4713,7 @@
4530
4713
  </xsl:for-each>
4531
4714
  </xsl:when>
4532
4715
  <xsl:otherwise>
4533
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4716
+ <xsl:for-each select="$contents_nodes/doc">
4534
4717
 
4535
4718
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4536
4719
 
@@ -4548,25 +4731,36 @@
4548
4731
  </xsl:choose>
4549
4732
  </xsl:when>
4550
4733
  <xsl:otherwise>
4551
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4734
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4735
+
4736
+ <xsl:call-template name="insertFigureBookmarks">
4737
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4738
+ </xsl:call-template>
4739
+
4740
+ <xsl:call-template name="insertTableBookmarks">
4741
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4742
+ <xsl:with-param name="lang" select="@lang"/>
4743
+ </xsl:call-template>
4744
+
4552
4745
  </xsl:otherwise>
4553
4746
  </xsl:choose>
4554
4747
 
4748
+
4555
4749
 
4556
4750
 
4557
4751
 
4558
4752
 
4559
-
4560
-
4753
+
4561
4754
 
4562
4755
  </fo:bookmark-tree>
4563
4756
  </xsl:if>
4564
4757
  </xsl:template><xsl:template name="insertFigureBookmarks">
4565
4758
  <xsl:param name="contents"/>
4566
- <xsl:if test="xalan:nodeset($contents)/figure">
4567
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
4759
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4760
+ <xsl:if test="$contents_nodes/figure">
4761
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4568
4762
  <fo:bookmark-title>Figures</fo:bookmark-title>
4569
- <xsl:for-each select="xalan:nodeset($contents)/figure">
4763
+ <xsl:for-each select="$contents_nodes/figure">
4570
4764
  <fo:bookmark internal-destination="{@id}">
4571
4765
  <fo:bookmark-title>
4572
4766
  <xsl:value-of select="normalize-space(title)"/>
@@ -4575,18 +4769,40 @@
4575
4769
  </xsl:for-each>
4576
4770
  </fo:bookmark>
4577
4771
  </xsl:if>
4772
+
4773
+
4774
+ <xsl:if test="$contents_nodes//figures/figure">
4775
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4776
+
4777
+
4778
+
4779
+ <xsl:variable name="bookmark-title">
4780
+
4781
+ <xsl:value-of select="$title-list-figures"/>
4782
+
4783
+ </xsl:variable>
4784
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
4785
+ <xsl:for-each select="$contents_nodes//figures/figure">
4786
+ <fo:bookmark internal-destination="{@id}">
4787
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4788
+ </fo:bookmark>
4789
+ </xsl:for-each>
4790
+ </fo:bookmark>
4791
+ </xsl:if>
4792
+
4578
4793
  </xsl:template><xsl:template name="insertTableBookmarks">
4579
4794
  <xsl:param name="contents"/>
4580
4795
  <xsl:param name="lang"/>
4581
- <xsl:if test="xalan:nodeset($contents)/table">
4582
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
4796
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4797
+ <xsl:if test="$contents_nodes/table">
4798
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4583
4799
  <fo:bookmark-title>
4584
4800
  <xsl:choose>
4585
4801
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4586
4802
  <xsl:otherwise>Tables</xsl:otherwise>
4587
4803
  </xsl:choose>
4588
4804
  </fo:bookmark-title>
4589
- <xsl:for-each select="xalan:nodeset($contents)/table">
4805
+ <xsl:for-each select="$contents_nodes/table">
4590
4806
  <fo:bookmark internal-destination="{@id}">
4591
4807
  <fo:bookmark-title>
4592
4808
  <xsl:value-of select="normalize-space(title)"/>
@@ -4595,6 +4811,29 @@
4595
4811
  </xsl:for-each>
4596
4812
  </fo:bookmark>
4597
4813
  </xsl:if>
4814
+
4815
+
4816
+ <xsl:if test="$contents_nodes//tables/table">
4817
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4818
+
4819
+
4820
+
4821
+ <xsl:variable name="bookmark-title">
4822
+
4823
+ <xsl:value-of select="$title-list-tables"/>
4824
+
4825
+ </xsl:variable>
4826
+
4827
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
4828
+
4829
+ <xsl:for-each select="$contents_nodes//tables/table">
4830
+ <fo:bookmark internal-destination="{@id}">
4831
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4832
+ </fo:bookmark>
4833
+ </xsl:for-each>
4834
+ </fo:bookmark>
4835
+ </xsl:if>
4836
+
4598
4837
  </xsl:template><xsl:template name="getLangVersion">
4599
4838
  <xsl:param name="lang"/>
4600
4839
  <xsl:param name="doctype" select="''"/>
@@ -4819,7 +5058,51 @@
4819
5058
  <xsl:with-param name="text" select="$text_step1"/>
4820
5059
  </xsl:call-template>
4821
5060
  </xsl:variable>
4822
- <xsl:value-of select="$text_step2"/>
5061
+
5062
+ <!-- <xsl:value-of select="$text_step2"/> -->
5063
+
5064
+ <!-- add zero-width space after space -->
5065
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5066
+
5067
+ <!-- split text by zero-width space -->
5068
+ <xsl:variable name="text_step4">
5069
+ <xsl:call-template name="split">
5070
+ <xsl:with-param name="pText" select="$text_step3"/>
5071
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5072
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5073
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5074
+ </xsl:call-template>
5075
+ </xsl:variable>
5076
+
5077
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5078
+ <xsl:choose>
5079
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5080
+ <xsl:call-template name="interspers">
5081
+ <xsl:with-param name="str" select="."/>
5082
+ </xsl:call-template>
5083
+ </xsl:when>
5084
+ <xsl:otherwise>
5085
+ <xsl:value-of select="."/>
5086
+ </xsl:otherwise>
5087
+ </xsl:choose>
5088
+ </xsl:for-each>
5089
+
5090
+ </xsl:template><xsl:template name="interspers">
5091
+ <xsl:param name="str"/>
5092
+ <xsl:param name="char" select="$zero_width_space"/>
5093
+ <xsl:if test="$str != ''">
5094
+ <xsl:value-of select="substring($str, 1, 1)"/>
5095
+
5096
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5097
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5098
+ <xsl:value-of select="$char"/>
5099
+ </xsl:if>
5100
+
5101
+ <xsl:call-template name="interspers">
5102
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5103
+ <xsl:with-param name="char" select="$char"/>
5104
+ </xsl:call-template>
5105
+ </xsl:if>
4823
5106
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
4824
5107
  <xsl:apply-templates mode="syntax_highlight"/>
4825
5108
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5251,6 +5534,8 @@
5251
5534
  </xsl:otherwise>
5252
5535
  </xsl:choose> -->
5253
5536
  </fo:block>
5537
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5538
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5254
5539
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5255
5540
  <xsl:if test="normalize-space() != ''">
5256
5541
  <xsl:value-of select="."/>
@@ -5325,26 +5610,24 @@
5325
5610
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5326
5611
  <xsl:text>— </xsl:text>
5327
5612
  <xsl:apply-templates/>
5328
- </xsl:template><xsl:variable name="bibitem_hidden_">
5613
+ </xsl:template><xsl:variable name="bibitems_">
5614
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5615
+ <xsl:copy-of select="."/>
5616
+ </xsl:for-each>
5617
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5329
5618
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5330
5619
  <xsl:copy-of select="."/>
5331
5620
  </xsl:for-each>
5332
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5621
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5333
5622
  <xsl:copy-of select="."/>
5334
5623
  </xsl:for-each>
5335
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5336
-
5337
- <xsl:variable name="bibitemid">
5338
- <xsl:choose>
5339
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5340
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5341
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5342
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5343
- </xsl:choose>
5344
- </xsl:variable>
5345
-
5624
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5625
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5626
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5627
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5346
5628
  <xsl:choose>
5347
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5629
+ <!-- <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) -->
5630
+ <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) -->
5348
5631
  <fo:inline xsl:use-attribute-sets="eref-style">
5349
5632
  <xsl:if test="@type = 'footnote'">
5350
5633
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5358,8 +5641,8 @@
5358
5641
  <xsl:variable name="text" select="normalize-space()"/>
5359
5642
 
5360
5643
 
5361
-
5362
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5644
+
5645
+ <fo:basic-link fox:alt-text="{@citeas}">
5363
5646
  <xsl:if test="normalize-space(@citeas) = ''">
5364
5647
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5365
5648
  </xsl:if>
@@ -5369,14 +5652,21 @@
5369
5652
 
5370
5653
  </xsl:if>
5371
5654
 
5372
-
5655
+ <xsl:choose>
5656
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5657
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5658
+ </xsl:when>
5659
+ <xsl:otherwise>
5660
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5661
+ </xsl:otherwise>
5662
+ </xsl:choose>
5373
5663
 
5374
5664
  <xsl:apply-templates/>
5375
5665
  </fo:basic-link>
5376
-
5666
+
5377
5667
  </fo:inline>
5378
5668
  </xsl:when>
5379
- <xsl:otherwise>
5669
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5380
5670
  <fo:inline><xsl:apply-templates/></fo:inline>
5381
5671
  </xsl:otherwise>
5382
5672
  </xsl:choose>
@@ -5712,7 +6002,7 @@
5712
6002
 
5713
6003
 
5714
6004
 
5715
-
6005
+
5716
6006
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
5717
6007
  </fo:list-block>
5718
6008
  <!-- <xsl:for-each select="./iho:note">
@@ -5730,6 +6020,11 @@
5730
6020
 
5731
6021
 
5732
6022
 
6023
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6024
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6025
+ <xsl:call-template name="append_add-style"/>
6026
+ </xsl:if>
6027
+
5733
6028
  <xsl:call-template name="getListItemFormat"/>
5734
6029
  </fo:block>
5735
6030
  </fo:list-item-label>
@@ -6147,6 +6442,24 @@
6147
6442
  <xsl:apply-templates/>
6148
6443
  </fo:inline>
6149
6444
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6445
+
6446
+ <!-- list of footnotes to calculate actual footnotes number -->
6447
+ <xsl:variable name="p_fn_">
6448
+ <xsl:call-template name="get_fn_list"/>
6449
+ </xsl:variable>
6450
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6451
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6452
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6453
+ <!-- fn sequence number in document -->
6454
+ <xsl:variable name="current_fn_number">
6455
+ <xsl:choose>
6456
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6457
+ <xsl:otherwise>
6458
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6459
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6460
+ </xsl:otherwise>
6461
+ </xsl:choose>
6462
+ </xsl:variable>
6150
6463
  <fo:footnote>
6151
6464
  <xsl:variable name="number">
6152
6465
 
@@ -6155,22 +6468,26 @@
6155
6468
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6156
6469
  </xsl:when>
6157
6470
  <xsl:otherwise>
6158
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6471
+ <xsl:value-of select="$current_fn_number"/>
6159
6472
  </xsl:otherwise>
6160
6473
  </xsl:choose>
6161
6474
 
6162
6475
  </xsl:variable>
6476
+
6477
+ <xsl:variable name="current_fn_number_text">
6478
+ <xsl:value-of select="$number"/>
6479
+
6480
+ </xsl:variable>
6481
+
6163
6482
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6164
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6165
- <xsl:value-of select="$number"/>
6166
-
6483
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6484
+ <xsl:value-of select="$current_fn_number_text"/>
6167
6485
  </fo:basic-link>
6168
6486
  </fo:inline>
6169
6487
  <fo:footnote-body>
6170
6488
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6171
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6172
- <xsl:value-of select="$number"/>
6173
-
6489
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6490
+ <xsl:value-of select="$current_fn_number_text"/>
6174
6491
  </fo:inline>
6175
6492
  <xsl:apply-templates/>
6176
6493
  </fo:block>
@@ -6410,6 +6727,78 @@
6410
6727
  <!-- processing for admonition/p found in the template for 'p' -->
6411
6728
  <xsl:call-template name="paragraph"/>
6412
6729
 
6730
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6731
+ <xsl:copy>
6732
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6733
+ </xsl:copy>
6734
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6735
+ <xsl:copy>
6736
+ <xsl:copy-of select="@*"/>
6737
+
6738
+ <xsl:variable name="nodes_preface_">
6739
+ <xsl:for-each select="*">
6740
+ <node id="{@id}"/>
6741
+ </xsl:for-each>
6742
+ </xsl:variable>
6743
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6744
+
6745
+ <xsl:for-each select="*">
6746
+ <xsl:sort select="@displayorder" data-type="number"/>
6747
+
6748
+ <!-- process Section's title -->
6749
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6750
+ <xsl:if test="$preceding-sibling_id != ''">
6751
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6752
+ </xsl:if>
6753
+
6754
+ <xsl:choose>
6755
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6756
+ <xsl:otherwise>
6757
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6758
+ </xsl:otherwise>
6759
+ </xsl:choose>
6760
+
6761
+ </xsl:for-each>
6762
+ </xsl:copy>
6763
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
6764
+ <xsl:copy>
6765
+ <xsl:copy-of select="@*"/>
6766
+
6767
+ <xsl:variable name="nodes_sections_">
6768
+ <xsl:for-each select="*">
6769
+ <node id="{@id}"/>
6770
+ </xsl:for-each>
6771
+ </xsl:variable>
6772
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
6773
+
6774
+ <!-- move section 'Normative references' inside 'sections' -->
6775
+ <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']]">
6776
+ <xsl:sort select="@displayorder" data-type="number"/>
6777
+
6778
+ <!-- process Section's title -->
6779
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6780
+ <xsl:if test="$preceding-sibling_id != ''">
6781
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6782
+ </xsl:if>
6783
+
6784
+ <xsl:choose>
6785
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6786
+ <xsl:otherwise>
6787
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6788
+ </xsl:otherwise>
6789
+ </xsl:choose>
6790
+
6791
+ </xsl:for-each>
6792
+ </xsl:copy>
6793
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
6794
+ <xsl:copy>
6795
+ <xsl:copy-of select="@*"/>
6796
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
6797
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
6798
+ <xsl:sort select="@displayorder" data-type="number"/>
6799
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6800
+ </xsl:for-each>
6801
+ </xsl:copy>
6413
6802
  </xsl:template><xsl:template name="convertDate">
6414
6803
  <xsl:param name="date"/>
6415
6804
  <xsl:param name="format" select="'short'"/>
@@ -6654,22 +7043,25 @@
6654
7043
  <xsl:param name="pText" select="."/>
6655
7044
  <xsl:param name="sep" select="','"/>
6656
7045
  <xsl:param name="normalize-space" select="'true'"/>
7046
+ <xsl:param name="keep_sep" select="'false'"/>
6657
7047
  <xsl:if test="string-length($pText) &gt;0">
6658
- <item>
6659
- <xsl:choose>
6660
- <xsl:when test="$normalize-space = 'true'">
6661
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6662
- </xsl:when>
6663
- <xsl:otherwise>
6664
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6665
- </xsl:otherwise>
6666
- </xsl:choose>
6667
- </item>
6668
- <xsl:call-template name="split">
6669
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6670
- <xsl:with-param name="sep" select="$sep"/>
6671
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
6672
- </xsl:call-template>
7048
+ <item>
7049
+ <xsl:choose>
7050
+ <xsl:when test="$normalize-space = 'true'">
7051
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7052
+ </xsl:when>
7053
+ <xsl:otherwise>
7054
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7055
+ </xsl:otherwise>
7056
+ </xsl:choose>
7057
+ </item>
7058
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7059
+ <xsl:call-template name="split">
7060
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7061
+ <xsl:with-param name="sep" select="$sep"/>
7062
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7063
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7064
+ </xsl:call-template>
6673
7065
  </xsl:if>
6674
7066
  </xsl:template><xsl:template name="getDocumentId">
6675
7067
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -6860,53 +7252,153 @@
6860
7252
  <xsl:param name="first"/>
6861
7253
  <xsl:if test="$number != ''">
6862
7254
  <xsl:variable name="words">
6863
- <words>
6864
- <word cardinal="1">One-</word>
6865
- <word ordinal="1">First </word>
6866
- <word cardinal="2">Two-</word>
6867
- <word ordinal="2">Second </word>
6868
- <word cardinal="3">Three-</word>
6869
- <word ordinal="3">Third </word>
6870
- <word cardinal="4">Four-</word>
6871
- <word ordinal="4">Fourth </word>
6872
- <word cardinal="5">Five-</word>
6873
- <word ordinal="5">Fifth </word>
6874
- <word cardinal="6">Six-</word>
6875
- <word ordinal="6">Sixth </word>
6876
- <word cardinal="7">Seven-</word>
6877
- <word ordinal="7">Seventh </word>
6878
- <word cardinal="8">Eight-</word>
6879
- <word ordinal="8">Eighth </word>
6880
- <word cardinal="9">Nine-</word>
6881
- <word ordinal="9">Ninth </word>
6882
- <word ordinal="10">Tenth </word>
6883
- <word ordinal="11">Eleventh </word>
6884
- <word ordinal="12">Twelfth </word>
6885
- <word ordinal="13">Thirteenth </word>
6886
- <word ordinal="14">Fourteenth </word>
6887
- <word ordinal="15">Fifteenth </word>
6888
- <word ordinal="16">Sixteenth </word>
6889
- <word ordinal="17">Seventeenth </word>
6890
- <word ordinal="18">Eighteenth </word>
6891
- <word ordinal="19">Nineteenth </word>
6892
- <word cardinal="20">Twenty-</word>
6893
- <word ordinal="20">Twentieth </word>
6894
- <word cardinal="30">Thirty-</word>
6895
- <word ordinal="30">Thirtieth </word>
6896
- <word cardinal="40">Forty-</word>
6897
- <word ordinal="40">Fortieth </word>
6898
- <word cardinal="50">Fifty-</word>
6899
- <word ordinal="50">Fiftieth </word>
6900
- <word cardinal="60">Sixty-</word>
6901
- <word ordinal="60">Sixtieth </word>
6902
- <word cardinal="70">Seventy-</word>
6903
- <word ordinal="70">Seventieth </word>
6904
- <word cardinal="80">Eighty-</word>
6905
- <word ordinal="80">Eightieth </word>
6906
- <word cardinal="90">Ninety-</word>
6907
- <word ordinal="90">Ninetieth </word>
6908
- <word cardinal="100">Hundred-</word>
6909
- <word ordinal="100">Hundredth </word>
7255
+ <words>
7256
+ <xsl:choose>
7257
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7258
+ <word cardinal="1">Une-</word>
7259
+ <word ordinal="1">Première </word>
7260
+ <word cardinal="2">Deux-</word>
7261
+ <word ordinal="2">Seconde </word>
7262
+ <word cardinal="3">Trois-</word>
7263
+ <word ordinal="3">Tierce </word>
7264
+ <word cardinal="4">Quatre-</word>
7265
+ <word ordinal="4">Quatrième </word>
7266
+ <word cardinal="5">Cinq-</word>
7267
+ <word ordinal="5">Cinquième </word>
7268
+ <word cardinal="6">Six-</word>
7269
+ <word ordinal="6">Sixième </word>
7270
+ <word cardinal="7">Sept-</word>
7271
+ <word ordinal="7">Septième </word>
7272
+ <word cardinal="8">Huit-</word>
7273
+ <word ordinal="8">Huitième </word>
7274
+ <word cardinal="9">Neuf-</word>
7275
+ <word ordinal="9">Neuvième </word>
7276
+ <word ordinal="10">Dixième </word>
7277
+ <word ordinal="11">Onzième </word>
7278
+ <word ordinal="12">Douzième </word>
7279
+ <word ordinal="13">Treizième </word>
7280
+ <word ordinal="14">Quatorzième </word>
7281
+ <word ordinal="15">Quinzième </word>
7282
+ <word ordinal="16">Seizième </word>
7283
+ <word ordinal="17">Dix-septième </word>
7284
+ <word ordinal="18">Dix-huitième </word>
7285
+ <word ordinal="19">Dix-neuvième </word>
7286
+ <word cardinal="20">Vingt-</word>
7287
+ <word ordinal="20">Vingtième </word>
7288
+ <word cardinal="30">Trente-</word>
7289
+ <word ordinal="30">Trentième </word>
7290
+ <word cardinal="40">Quarante-</word>
7291
+ <word ordinal="40">Quarantième </word>
7292
+ <word cardinal="50">Cinquante-</word>
7293
+ <word ordinal="50">Cinquantième </word>
7294
+ <word cardinal="60">Soixante-</word>
7295
+ <word ordinal="60">Soixantième </word>
7296
+ <word cardinal="70">Septante-</word>
7297
+ <word ordinal="70">Septantième </word>
7298
+ <word cardinal="80">Huitante-</word>
7299
+ <word ordinal="80">Huitantième </word>
7300
+ <word cardinal="90">Nonante-</word>
7301
+ <word ordinal="90">Nonantième </word>
7302
+ <word cardinal="100">Cent-</word>
7303
+ <word ordinal="100">Centième </word>
7304
+ </xsl:when>
7305
+ <xsl:when test="$lang = 'ru'">
7306
+ <word cardinal="1">Одна-</word>
7307
+ <word ordinal="1">Первое </word>
7308
+ <word cardinal="2">Две-</word>
7309
+ <word ordinal="2">Второе </word>
7310
+ <word cardinal="3">Три-</word>
7311
+ <word ordinal="3">Третье </word>
7312
+ <word cardinal="4">Четыре-</word>
7313
+ <word ordinal="4">Четвертое </word>
7314
+ <word cardinal="5">Пять-</word>
7315
+ <word ordinal="5">Пятое </word>
7316
+ <word cardinal="6">Шесть-</word>
7317
+ <word ordinal="6">Шестое </word>
7318
+ <word cardinal="7">Семь-</word>
7319
+ <word ordinal="7">Седьмое </word>
7320
+ <word cardinal="8">Восемь-</word>
7321
+ <word ordinal="8">Восьмое </word>
7322
+ <word cardinal="9">Девять-</word>
7323
+ <word ordinal="9">Девятое </word>
7324
+ <word ordinal="10">Десятое </word>
7325
+ <word ordinal="11">Одиннадцатое </word>
7326
+ <word ordinal="12">Двенадцатое </word>
7327
+ <word ordinal="13">Тринадцатое </word>
7328
+ <word ordinal="14">Четырнадцатое </word>
7329
+ <word ordinal="15">Пятнадцатое </word>
7330
+ <word ordinal="16">Шестнадцатое </word>
7331
+ <word ordinal="17">Семнадцатое </word>
7332
+ <word ordinal="18">Восемнадцатое </word>
7333
+ <word ordinal="19">Девятнадцатое </word>
7334
+ <word cardinal="20">Двадцать-</word>
7335
+ <word ordinal="20">Двадцатое </word>
7336
+ <word cardinal="30">Тридцать-</word>
7337
+ <word ordinal="30">Тридцатое </word>
7338
+ <word cardinal="40">Сорок-</word>
7339
+ <word ordinal="40">Сороковое </word>
7340
+ <word cardinal="50">Пятьдесят-</word>
7341
+ <word ordinal="50">Пятидесятое </word>
7342
+ <word cardinal="60">Шестьдесят-</word>
7343
+ <word ordinal="60">Шестидесятое </word>
7344
+ <word cardinal="70">Семьдесят-</word>
7345
+ <word ordinal="70">Семидесятое </word>
7346
+ <word cardinal="80">Восемьдесят-</word>
7347
+ <word ordinal="80">Восьмидесятое </word>
7348
+ <word cardinal="90">Девяносто-</word>
7349
+ <word ordinal="90">Девяностое </word>
7350
+ <word cardinal="100">Сто-</word>
7351
+ <word ordinal="100">Сотое </word>
7352
+ </xsl:when>
7353
+ <xsl:otherwise> <!-- default english -->
7354
+ <word cardinal="1">One-</word>
7355
+ <word ordinal="1">First </word>
7356
+ <word cardinal="2">Two-</word>
7357
+ <word ordinal="2">Second </word>
7358
+ <word cardinal="3">Three-</word>
7359
+ <word ordinal="3">Third </word>
7360
+ <word cardinal="4">Four-</word>
7361
+ <word ordinal="4">Fourth </word>
7362
+ <word cardinal="5">Five-</word>
7363
+ <word ordinal="5">Fifth </word>
7364
+ <word cardinal="6">Six-</word>
7365
+ <word ordinal="6">Sixth </word>
7366
+ <word cardinal="7">Seven-</word>
7367
+ <word ordinal="7">Seventh </word>
7368
+ <word cardinal="8">Eight-</word>
7369
+ <word ordinal="8">Eighth </word>
7370
+ <word cardinal="9">Nine-</word>
7371
+ <word ordinal="9">Ninth </word>
7372
+ <word ordinal="10">Tenth </word>
7373
+ <word ordinal="11">Eleventh </word>
7374
+ <word ordinal="12">Twelfth </word>
7375
+ <word ordinal="13">Thirteenth </word>
7376
+ <word ordinal="14">Fourteenth </word>
7377
+ <word ordinal="15">Fifteenth </word>
7378
+ <word ordinal="16">Sixteenth </word>
7379
+ <word ordinal="17">Seventeenth </word>
7380
+ <word ordinal="18">Eighteenth </word>
7381
+ <word ordinal="19">Nineteenth </word>
7382
+ <word cardinal="20">Twenty-</word>
7383
+ <word ordinal="20">Twentieth </word>
7384
+ <word cardinal="30">Thirty-</word>
7385
+ <word ordinal="30">Thirtieth </word>
7386
+ <word cardinal="40">Forty-</word>
7387
+ <word ordinal="40">Fortieth </word>
7388
+ <word cardinal="50">Fifty-</word>
7389
+ <word ordinal="50">Fiftieth </word>
7390
+ <word cardinal="60">Sixty-</word>
7391
+ <word ordinal="60">Sixtieth </word>
7392
+ <word cardinal="70">Seventy-</word>
7393
+ <word ordinal="70">Seventieth </word>
7394
+ <word cardinal="80">Eighty-</word>
7395
+ <word ordinal="80">Eightieth </word>
7396
+ <word cardinal="90">Ninety-</word>
7397
+ <word ordinal="90">Ninetieth </word>
7398
+ <word cardinal="100">Hundred-</word>
7399
+ <word ordinal="100">Hundredth </word>
7400
+ </xsl:otherwise>
7401
+ </xsl:choose>
6910
7402
  </words>
6911
7403
  </xsl:variable>
6912
7404
 
@@ -6980,4 +7472,18 @@
6980
7472
  <xsl:otherwise>_</xsl:otherwise>
6981
7473
  </xsl:choose>
6982
7474
  </xsl:attribute>
7475
+ </xsl:template><xsl:template name="substring-after-last">
7476
+ <xsl:param name="value"/>
7477
+ <xsl:param name="delimiter"/>
7478
+ <xsl:choose>
7479
+ <xsl:when test="contains($value, $delimiter)">
7480
+ <xsl:call-template name="substring-after-last">
7481
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7482
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7483
+ </xsl:call-template>
7484
+ </xsl:when>
7485
+ <xsl:otherwise>
7486
+ <xsl:value-of select="$value"/>
7487
+ </xsl:otherwise>
7488
+ </xsl:choose>
6983
7489
  </xsl:template></xsl:stylesheet>