metanorma-m3aawg 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,15 @@
16
16
  <item level="1" id="Foreword" display="true">Foreword</item>
17
17
  <item id="term-script" display="false">3.2</item>
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
+
24
+ <xsl:call-template name="processTablesFigures_Contents"/>
23
25
  </contents>
24
26
  </xsl:variable>
27
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
25
28
 
26
29
  <xsl:template match="/">
27
30
  <xsl:call-template name="namespaceCheck"/>
@@ -200,7 +203,7 @@
200
203
  <xsl:if test="$debug = 'true'">
201
204
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
202
205
  DEBUG
203
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
206
+ contents=<xsl:copy-of select="$contents"/>
204
207
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
205
208
  </xsl:if>
206
209
 
@@ -213,7 +216,7 @@
213
216
  </xsl:variable>
214
217
  <fo:block font-size="12pt" font-weight="bold" text-decoration="underline" margin-bottom="4pt" role="H1"><xsl:value-of select="$title-toc"/></fo:block>
215
218
  <fo:block font-size="10pt" role="TOC">
216
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
219
+ <xsl:for-each select="$contents//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
217
220
  <xsl:choose>
218
221
  <xsl:when test="@section = ''">
219
222
  <fo:table table-layout="fixed" width="100%">
@@ -290,10 +293,30 @@
290
293
  </xsl:otherwise>
291
294
 
292
295
  </xsl:choose>
296
+
297
+ </xsl:for-each>
293
298
 
299
+ <!-- List of Tables -->
300
+ <xsl:if test="$contents//tables/table">
301
+ <xsl:call-template name="insertListOf_Title">
302
+ <xsl:with-param name="title" select="$title-list-tables"/>
303
+ </xsl:call-template>
304
+ <xsl:for-each select="$contents//tables/table">
305
+ <xsl:call-template name="insertListOf_Item"/>
306
+ </xsl:for-each>
307
+ </xsl:if>
294
308
 
309
+ <!-- List of Figures -->
310
+ <xsl:if test="$contents//figures/figure">
311
+ <xsl:call-template name="insertListOf_Title">
312
+ <xsl:with-param name="title" select="$title-list-figures"/>
313
+ </xsl:call-template>
314
+ <xsl:for-each select="$contents//figures/figure">
315
+ <xsl:call-template name="insertListOf_Item"/>
316
+ </xsl:for-each>
317
+ </xsl:if>
295
318
 
296
- </xsl:for-each>
319
+
297
320
  </fo:block>
298
321
  </fo:block-container>
299
322
 
@@ -318,6 +341,49 @@
318
341
  </fo:root>
319
342
  </xsl:template>
320
343
 
344
+ <xsl:template name="insertListOf_Title">
345
+ <xsl:param name="title"/>
346
+ <fo:table table-layout="fixed" width="100%">
347
+ <fo:table-column column-width="180mm"/>
348
+ <fo:table-body>
349
+ <fo:table-row height="6mm">
350
+ <fo:table-cell>
351
+ <fo:block role="TOCI" font-weight="bold">
352
+ <xsl:value-of select="$title"/>
353
+ </fo:block>
354
+ </fo:table-cell>
355
+ </fo:table-row>
356
+ </fo:table-body>
357
+ </fo:table>
358
+ </xsl:template>
359
+
360
+ <xsl:template name="insertListOf_Item">
361
+ <fo:table table-layout="fixed" width="100%">
362
+ <fo:table-column column-width="5mm"/>
363
+ <fo:table-column column-width="175mm"/>
364
+ <fo:table-body>
365
+ <fo:table-row height="6mm">
366
+ <fo:table-cell>
367
+ <fo:block> </fo:block>
368
+ </fo:table-cell>
369
+ <fo:table-cell>
370
+ <fo:block text-align-last="justify" role="TOCI" font-weight="bold">
371
+ <fo:basic-link internal-destination="{@id}">
372
+ <xsl:call-template name="setAltText">
373
+ <xsl:with-param name="value" select="@alt-text"/>
374
+ </xsl:call-template>
375
+ <xsl:apply-templates select="." mode="contents"/><xsl:text> </xsl:text>
376
+ <fo:inline keep-together.within-line="always">
377
+ <fo:leader font-weight="normal" leader-pattern="dots"/>
378
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
379
+ </fo:inline>
380
+ </fo:basic-link>
381
+ </fo:block>
382
+ </fo:table-cell>
383
+ </fo:table-row>
384
+ </fo:table-body>
385
+ </fo:table>
386
+ </xsl:template>
321
387
 
322
388
  <xsl:template match="m3d:boilerplate//m3d:p" priority="2">
323
389
  <fo:block font-size="11pt" margin-bottom="12pt">
@@ -620,6 +686,10 @@
620
686
  <xsl:text>Édition </xsl:text>
621
687
  </title-edition>
622
688
 
689
+ <title-edition lang="ru">
690
+ <xsl:text>Издание </xsl:text>
691
+ </title-edition>
692
+
623
693
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
624
694
  <title-toc lang="en">
625
695
 
@@ -636,7 +706,7 @@
636
706
  <xsl:text>Contents</xsl:text>
637
707
 
638
708
  </title-toc>
639
-
709
+
640
710
  <title-descriptors lang="en">Descriptors</title-descriptors>
641
711
 
642
712
  <title-part lang="en">
@@ -648,7 +718,11 @@
648
718
 
649
719
 
650
720
 
651
- </title-part>
721
+ </title-part>
722
+ <title-part lang="ru">
723
+
724
+
725
+ </title-part>
652
726
  <title-part lang="zh">第 # 部分:</title-part>
653
727
 
654
728
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -664,10 +738,35 @@
664
738
 
665
739
  <title-summary lang="en">Summary</title-summary>
666
740
 
741
+ <title-continued lang="ru">(продолжение)</title-continued>
667
742
  <title-continued lang="en">(continued)</title-continued>
668
743
  <title-continued lang="fr">(continué)</title-continued>
669
744
 
670
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
745
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
746
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
747
+ <xsl:value-of select="$toc_table_title"/>
748
+ <xsl:if test="normalize-space($toc_table_title) = ''">
749
+ <xsl:call-template name="getTitle">
750
+ <xsl:with-param name="name" select="'title-list-tables'"/>
751
+ </xsl:call-template>
752
+ </xsl:if>
753
+ </xsl:variable><xsl:variable name="title-list-figures">
754
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
755
+ <xsl:value-of select="$toc_figure_title"/>
756
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
757
+ <xsl:call-template name="getTitle">
758
+ <xsl:with-param name="name" select="'title-list-figures'"/>
759
+ </xsl:call-template>
760
+ </xsl:if>
761
+ </xsl:variable><xsl:variable name="title-list-recommendations">
762
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
763
+ <xsl:value-of select="$toc_requirement_title"/>
764
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
765
+ <xsl:call-template name="getTitle">
766
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
767
+ </xsl:call-template>
768
+ </xsl:if>
769
+ </xsl:variable><xsl:variable name="bibdata">
671
770
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
672
771
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
673
772
  </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">
@@ -1389,13 +1488,19 @@
1389
1488
  </xsl:attribute-set><xsl:variable name="color-added-text">
1390
1489
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1391
1490
  </xsl:variable><xsl:attribute-set name="add-style">
1392
- <xsl:attribute name="color">red</xsl:attribute>
1393
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
1394
- <!-- <xsl:attribute name="color">black</xsl:attribute>
1395
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1396
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
1397
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1398
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1491
+
1492
+ <xsl:attribute name="color">red</xsl:attribute>
1493
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1494
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1495
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1496
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1497
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1498
+
1499
+ </xsl:attribute-set><xsl:variable name="add-style">
1500
+ <add-style xsl:use-attribute-sets="add-style"/>
1501
+ </xsl:variable><xsl:template name="append_add-style">
1502
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1503
+ </xsl:template><xsl:variable name="color-deleted-text">
1399
1504
  <xsl:text>red</xsl:text>
1400
1505
  </xsl:variable><xsl:attribute-set name="del-style">
1401
1506
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -1817,14 +1922,42 @@
1817
1922
 
1818
1923
 
1819
1924
  </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">
1925
+ <xsl:variable name="nodes_preface_">
1926
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
1927
+ <node id="{@id}"/>
1928
+ </xsl:for-each>
1929
+ </xsl:variable>
1930
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
1931
+
1820
1932
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1821
1933
  <xsl:sort select="@displayorder" data-type="number"/>
1934
+
1935
+ <!-- process Section's title -->
1936
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
1937
+ <xsl:if test="$preceding-sibling_id != ''">
1938
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
1939
+ </xsl:if>
1940
+
1822
1941
  <xsl:apply-templates select="." mode="contents"/>
1823
1942
  </xsl:for-each>
1824
1943
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
1825
1944
 
1945
+ <xsl:variable name="nodes_sections_">
1946
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
1947
+ <node id="{@id}"/>
1948
+ </xsl:for-each>
1949
+ </xsl:variable>
1950
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
1951
+
1826
1952
  <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']]">
1827
1953
  <xsl:sort select="@displayorder" data-type="number"/>
1954
+
1955
+ <!-- process Section's title -->
1956
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
1957
+ <xsl:if test="$preceding-sibling_id != ''">
1958
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
1959
+ </xsl:if>
1960
+
1828
1961
  <xsl:apply-templates select="." mode="contents"/>
1829
1962
  </xsl:for-each>
1830
1963
 
@@ -1837,6 +1970,30 @@
1837
1970
  <xsl:sort select="@displayorder" data-type="number"/>
1838
1971
  <xsl:apply-templates select="." mode="contents"/>
1839
1972
  </xsl:for-each>
1973
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
1974
+ <xsl:param name="always"/>
1975
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1976
+ <xsl:call-template name="processTables_Contents"/>
1977
+ </xsl:if>
1978
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1979
+ <xsl:call-template name="processFigures_Contents"/>
1980
+ </xsl:if>
1981
+ </xsl:template><xsl:template name="processTables_Contents">
1982
+ <tables>
1983
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
1984
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
1985
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1986
+ </table>
1987
+ </xsl:for-each>
1988
+ </tables>
1989
+ </xsl:template><xsl:template name="processFigures_Contents">
1990
+ <figures>
1991
+ <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) != '']">
1992
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
1993
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1994
+ </figure>
1995
+ </xsl:for-each>
1996
+ </figures>
1840
1997
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1841
1998
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1842
1999
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -1969,7 +2126,7 @@
1969
2126
  </xsl:call-template>
1970
2127
  </xsl:if>
1971
2128
  </xsl:variable>
1972
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2129
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
1973
2130
 
1974
2131
 
1975
2132
  <xsl:variable name="margin-side">
@@ -2235,7 +2392,7 @@
2235
2392
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2236
2393
  <!-- 2009 thinspace -->
2237
2394
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2238
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2395
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2239
2396
  </xsl:call-template>
2240
2397
  </xsl:variable>
2241
2398
  <xsl:variable name="max_length">
@@ -2621,37 +2778,7 @@
2621
2778
 
2622
2779
  <!-- list of footnotes to calculate actual footnotes number -->
2623
2780
  <xsl:variable name="p_fn_">
2624
- <xsl:choose>
2625
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2626
- <fn gen_id="{generate-id(.)}">
2627
- <xsl:copy-of select="@*"/>
2628
- <xsl:copy-of select="node()"/>
2629
- </fn>
2630
- </xsl:when>
2631
- <xsl:otherwise>
2632
- <!-- itetation for:
2633
- footnotes in bibdata/title
2634
- footnotes in bibliography
2635
- footnotes in document's body (except table's head/body/foot and figure text)
2636
- -->
2637
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2638
- <fn gen_id="{generate-id(.)}">
2639
- <xsl:copy-of select="@*"/>
2640
- <xsl:copy-of select="node()"/>
2641
- </fn>
2642
- </xsl:for-each>
2643
- <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']/*">
2644
- <xsl:sort select="@displayorder" data-type="number"/>
2645
- <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])]">
2646
- <!-- copy unique fn -->
2647
- <fn gen_id="{generate-id(.)}">
2648
- <xsl:copy-of select="@*"/>
2649
- <xsl:copy-of select="node()"/>
2650
- </fn>
2651
- </xsl:for-each>
2652
- </xsl:for-each>
2653
- </xsl:otherwise>
2654
- </xsl:choose>
2781
+ <xsl:call-template name="get_fn_list"/>
2655
2782
  </xsl:variable>
2656
2783
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2657
2784
 
@@ -2712,6 +2839,38 @@
2712
2839
  <xsl:copy-of select="$footnote_inline"/>
2713
2840
  </xsl:otherwise>
2714
2841
  </xsl:choose>
2842
+ </xsl:template><xsl:template name="get_fn_list">
2843
+ <xsl:choose>
2844
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2845
+ <fn gen_id="{generate-id(.)}">
2846
+ <xsl:copy-of select="@*"/>
2847
+ <xsl:copy-of select="node()"/>
2848
+ </fn>
2849
+ </xsl:when>
2850
+ <xsl:otherwise>
2851
+ <!-- itetation for:
2852
+ footnotes in bibdata/title
2853
+ footnotes in bibliography
2854
+ footnotes in document's body (except table's head/body/foot and figure text)
2855
+ -->
2856
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2857
+ <fn gen_id="{generate-id(.)}">
2858
+ <xsl:copy-of select="@*"/>
2859
+ <xsl:copy-of select="node()"/>
2860
+ </fn>
2861
+ </xsl:for-each>
2862
+ <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']/*">
2863
+ <xsl:sort select="@displayorder" data-type="number"/>
2864
+ <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])]">
2865
+ <!-- copy unique fn -->
2866
+ <fn gen_id="{generate-id(.)}">
2867
+ <xsl:copy-of select="@*"/>
2868
+ <xsl:copy-of select="node()"/>
2869
+ </fn>
2870
+ </xsl:for-each>
2871
+ </xsl:for-each>
2872
+ </xsl:otherwise>
2873
+ </xsl:choose>
2715
2874
  </xsl:template><xsl:template name="table_fn_display">
2716
2875
  <xsl:variable name="references">
2717
2876
 
@@ -2883,7 +3042,7 @@
2883
3042
  </fo:inline>
2884
3043
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
2885
3044
  <fo:inline><xsl:value-of select="."/></fo:inline>
2886
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3045
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
2887
3046
  <fo:inline>
2888
3047
  <xsl:apply-templates/>
2889
3048
  </fo:inline>
@@ -3864,6 +4023,9 @@
3864
4023
  </fo:inline>
3865
4024
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
3866
4025
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4026
+ <xsl:if test="parent::*[local-name() = 'add']">
4027
+ <xsl:call-template name="append_add-style"/>
4028
+ </xsl:if>
3867
4029
  <xsl:apply-templates/>
3868
4030
  </fo:basic-link>
3869
4031
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -3961,6 +4123,13 @@
3961
4123
 
3962
4124
 
3963
4125
 
4126
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4127
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4128
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4129
+ <xsl:call-template name="append_add-style"/>
4130
+ </xsl:if>
4131
+
4132
+
3964
4133
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
3965
4134
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
3966
4135
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -3999,6 +4168,12 @@
3999
4168
 
4000
4169
 
4001
4170
 
4171
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4172
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4173
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4174
+ <xsl:call-template name="append_add-style"/>
4175
+ </xsl:if>
4176
+
4002
4177
  <xsl:apply-templates select="*[local-name() = 'name']"/>
4003
4178
 
4004
4179
  </fo:inline>
@@ -4050,6 +4225,7 @@
4050
4225
  </fo:block>
4051
4226
  </xsl:template><xsl:template match="*[local-name() = 'term']">
4052
4227
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4228
+
4053
4229
 
4054
4230
 
4055
4231
  <fo:block keep-with-next="always" margin-top="10pt" margin-bottom="8pt" line-height="1.1">
@@ -4490,7 +4666,11 @@
4490
4666
  <xsl:value-of select="."/>
4491
4667
  </xsl:template><xsl:template match="node()" mode="contents">
4492
4668
  <xsl:apply-templates mode="contents"/>
4493
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4669
+ </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">
4670
+ <xsl:call-template name="contents_section-title"/>
4671
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4672
+ <xsl:call-template name="contents_section-title"/>
4673
+ </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">
4494
4674
  <xsl:variable name="level">
4495
4675
  <xsl:call-template name="getLevel">
4496
4676
  <xsl:with-param name="depth" select="@depth"/>
@@ -4559,13 +4739,14 @@
4559
4739
  <xsl:apply-templates mode="bookmarks"/>
4560
4740
  </xsl:template><xsl:template name="addBookmarks">
4561
4741
  <xsl:param name="contents"/>
4562
- <xsl:if test="xalan:nodeset($contents)//item">
4742
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4743
+ <xsl:if test="$contents_nodes//item">
4563
4744
  <fo:bookmark-tree>
4564
4745
  <xsl:choose>
4565
- <xsl:when test="xalan:nodeset($contents)/doc">
4746
+ <xsl:when test="$contents_nodes/doc">
4566
4747
  <xsl:choose>
4567
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4568
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4748
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4749
+ <xsl:for-each select="$contents_nodes/doc">
4569
4750
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4570
4751
  <xsl:if test="@bundle = 'true'">
4571
4752
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4616,7 +4797,7 @@
4616
4797
  </xsl:for-each>
4617
4798
  </xsl:when>
4618
4799
  <xsl:otherwise>
4619
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4800
+ <xsl:for-each select="$contents_nodes/doc">
4620
4801
 
4621
4802
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4622
4803
 
@@ -4634,25 +4815,36 @@
4634
4815
  </xsl:choose>
4635
4816
  </xsl:when>
4636
4817
  <xsl:otherwise>
4637
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4818
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4819
+
4820
+ <xsl:call-template name="insertFigureBookmarks">
4821
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4822
+ </xsl:call-template>
4823
+
4824
+ <xsl:call-template name="insertTableBookmarks">
4825
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4826
+ <xsl:with-param name="lang" select="@lang"/>
4827
+ </xsl:call-template>
4828
+
4638
4829
  </xsl:otherwise>
4639
4830
  </xsl:choose>
4640
4831
 
4832
+
4641
4833
 
4642
4834
 
4643
4835
 
4644
4836
 
4645
-
4646
-
4837
+
4647
4838
 
4648
4839
  </fo:bookmark-tree>
4649
4840
  </xsl:if>
4650
4841
  </xsl:template><xsl:template name="insertFigureBookmarks">
4651
4842
  <xsl:param name="contents"/>
4652
- <xsl:if test="xalan:nodeset($contents)/figure">
4653
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
4843
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4844
+ <xsl:if test="$contents_nodes/figure">
4845
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4654
4846
  <fo:bookmark-title>Figures</fo:bookmark-title>
4655
- <xsl:for-each select="xalan:nodeset($contents)/figure">
4847
+ <xsl:for-each select="$contents_nodes/figure">
4656
4848
  <fo:bookmark internal-destination="{@id}">
4657
4849
  <fo:bookmark-title>
4658
4850
  <xsl:value-of select="normalize-space(title)"/>
@@ -4661,18 +4853,40 @@
4661
4853
  </xsl:for-each>
4662
4854
  </fo:bookmark>
4663
4855
  </xsl:if>
4856
+
4857
+
4858
+ <xsl:if test="$contents_nodes//figures/figure">
4859
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4860
+
4861
+
4862
+
4863
+ <xsl:variable name="bookmark-title">
4864
+
4865
+ <xsl:value-of select="$title-list-figures"/>
4866
+
4867
+ </xsl:variable>
4868
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
4869
+ <xsl:for-each select="$contents_nodes//figures/figure">
4870
+ <fo:bookmark internal-destination="{@id}">
4871
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4872
+ </fo:bookmark>
4873
+ </xsl:for-each>
4874
+ </fo:bookmark>
4875
+ </xsl:if>
4876
+
4664
4877
  </xsl:template><xsl:template name="insertTableBookmarks">
4665
4878
  <xsl:param name="contents"/>
4666
4879
  <xsl:param name="lang"/>
4667
- <xsl:if test="xalan:nodeset($contents)/table">
4668
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
4880
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4881
+ <xsl:if test="$contents_nodes/table">
4882
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4669
4883
  <fo:bookmark-title>
4670
4884
  <xsl:choose>
4671
4885
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4672
4886
  <xsl:otherwise>Tables</xsl:otherwise>
4673
4887
  </xsl:choose>
4674
4888
  </fo:bookmark-title>
4675
- <xsl:for-each select="xalan:nodeset($contents)/table">
4889
+ <xsl:for-each select="$contents_nodes/table">
4676
4890
  <fo:bookmark internal-destination="{@id}">
4677
4891
  <fo:bookmark-title>
4678
4892
  <xsl:value-of select="normalize-space(title)"/>
@@ -4681,6 +4895,29 @@
4681
4895
  </xsl:for-each>
4682
4896
  </fo:bookmark>
4683
4897
  </xsl:if>
4898
+
4899
+
4900
+ <xsl:if test="$contents_nodes//tables/table">
4901
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4902
+
4903
+
4904
+
4905
+ <xsl:variable name="bookmark-title">
4906
+
4907
+ <xsl:value-of select="$title-list-tables"/>
4908
+
4909
+ </xsl:variable>
4910
+
4911
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
4912
+
4913
+ <xsl:for-each select="$contents_nodes//tables/table">
4914
+ <fo:bookmark internal-destination="{@id}">
4915
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4916
+ </fo:bookmark>
4917
+ </xsl:for-each>
4918
+ </fo:bookmark>
4919
+ </xsl:if>
4920
+
4684
4921
  </xsl:template><xsl:template name="getLangVersion">
4685
4922
  <xsl:param name="lang"/>
4686
4923
  <xsl:param name="doctype" select="''"/>
@@ -4905,7 +5142,51 @@
4905
5142
  <xsl:with-param name="text" select="$text_step1"/>
4906
5143
  </xsl:call-template>
4907
5144
  </xsl:variable>
4908
- <xsl:value-of select="$text_step2"/>
5145
+
5146
+ <!-- <xsl:value-of select="$text_step2"/> -->
5147
+
5148
+ <!-- add zero-width space after space -->
5149
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5150
+
5151
+ <!-- split text by zero-width space -->
5152
+ <xsl:variable name="text_step4">
5153
+ <xsl:call-template name="split">
5154
+ <xsl:with-param name="pText" select="$text_step3"/>
5155
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5156
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5157
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5158
+ </xsl:call-template>
5159
+ </xsl:variable>
5160
+
5161
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5162
+ <xsl:choose>
5163
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5164
+ <xsl:call-template name="interspers">
5165
+ <xsl:with-param name="str" select="."/>
5166
+ </xsl:call-template>
5167
+ </xsl:when>
5168
+ <xsl:otherwise>
5169
+ <xsl:value-of select="."/>
5170
+ </xsl:otherwise>
5171
+ </xsl:choose>
5172
+ </xsl:for-each>
5173
+
5174
+ </xsl:template><xsl:template name="interspers">
5175
+ <xsl:param name="str"/>
5176
+ <xsl:param name="char" select="$zero_width_space"/>
5177
+ <xsl:if test="$str != ''">
5178
+ <xsl:value-of select="substring($str, 1, 1)"/>
5179
+
5180
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5181
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5182
+ <xsl:value-of select="$char"/>
5183
+ </xsl:if>
5184
+
5185
+ <xsl:call-template name="interspers">
5186
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5187
+ <xsl:with-param name="char" select="$char"/>
5188
+ </xsl:call-template>
5189
+ </xsl:if>
4909
5190
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
4910
5191
  <xsl:apply-templates mode="syntax_highlight"/>
4911
5192
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5337,6 +5618,8 @@
5337
5618
  </xsl:otherwise>
5338
5619
  </xsl:choose> -->
5339
5620
  </fo:block>
5621
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5622
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5340
5623
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5341
5624
  <xsl:if test="normalize-space() != ''">
5342
5625
  <xsl:value-of select="."/>
@@ -5411,26 +5694,24 @@
5411
5694
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5412
5695
  <xsl:text>— </xsl:text>
5413
5696
  <xsl:apply-templates/>
5414
- </xsl:template><xsl:variable name="bibitem_hidden_">
5697
+ </xsl:template><xsl:variable name="bibitems_">
5698
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5699
+ <xsl:copy-of select="."/>
5700
+ </xsl:for-each>
5701
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5415
5702
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5416
5703
  <xsl:copy-of select="."/>
5417
5704
  </xsl:for-each>
5418
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5705
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5419
5706
  <xsl:copy-of select="."/>
5420
5707
  </xsl:for-each>
5421
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5422
-
5423
- <xsl:variable name="bibitemid">
5424
- <xsl:choose>
5425
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5426
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5427
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5428
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5429
- </xsl:choose>
5430
- </xsl:variable>
5431
-
5708
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5709
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5710
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5711
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5432
5712
  <xsl:choose>
5433
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5713
+ <!-- <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) -->
5714
+ <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) -->
5434
5715
  <fo:inline xsl:use-attribute-sets="eref-style">
5435
5716
  <xsl:if test="@type = 'footnote'">
5436
5717
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5446,8 +5727,8 @@
5446
5727
  <xsl:variable name="text" select="normalize-space()"/>
5447
5728
 
5448
5729
 
5449
-
5450
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5730
+
5731
+ <fo:basic-link fox:alt-text="{@citeas}">
5451
5732
  <xsl:if test="normalize-space(@citeas) = ''">
5452
5733
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5453
5734
  </xsl:if>
@@ -5457,14 +5738,21 @@
5457
5738
 
5458
5739
  </xsl:if>
5459
5740
 
5460
-
5741
+ <xsl:choose>
5742
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5743
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5744
+ </xsl:when>
5745
+ <xsl:otherwise>
5746
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5747
+ </xsl:otherwise>
5748
+ </xsl:choose>
5461
5749
 
5462
5750
  <xsl:apply-templates/>
5463
5751
  </fo:basic-link>
5464
-
5752
+
5465
5753
  </fo:inline>
5466
5754
  </xsl:when>
5467
- <xsl:otherwise>
5755
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5468
5756
  <fo:inline><xsl:apply-templates/></fo:inline>
5469
5757
  </xsl:otherwise>
5470
5758
  </xsl:choose>
@@ -5807,7 +6095,7 @@
5807
6095
 
5808
6096
 
5809
6097
 
5810
-
6098
+
5811
6099
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
5812
6100
  </fo:list-block>
5813
6101
  <!-- <xsl:for-each select="./iho:note">
@@ -5825,6 +6113,11 @@
5825
6113
 
5826
6114
 
5827
6115
 
6116
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6117
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6118
+ <xsl:call-template name="append_add-style"/>
6119
+ </xsl:if>
6120
+
5828
6121
  <xsl:call-template name="getListItemFormat"/>
5829
6122
  </fo:block>
5830
6123
  </fo:list-item-label>
@@ -6201,23 +6494,45 @@
6201
6494
  <xsl:apply-templates/>
6202
6495
  </fo:inline>
6203
6496
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6497
+
6498
+ <!-- list of footnotes to calculate actual footnotes number -->
6499
+ <xsl:variable name="p_fn_">
6500
+ <xsl:call-template name="get_fn_list"/>
6501
+ </xsl:variable>
6502
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6503
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6504
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6505
+ <!-- fn sequence number in document -->
6506
+ <xsl:variable name="current_fn_number">
6507
+ <xsl:choose>
6508
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6509
+ <xsl:otherwise>
6510
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6511
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6512
+ </xsl:otherwise>
6513
+ </xsl:choose>
6514
+ </xsl:variable>
6204
6515
  <fo:footnote>
6205
6516
  <xsl:variable name="number">
6206
6517
 
6207
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6518
+ <xsl:value-of select="$current_fn_number"/>
6208
6519
 
6209
6520
  </xsl:variable>
6521
+
6522
+ <xsl:variable name="current_fn_number_text">
6523
+ <xsl:value-of select="$number"/>
6524
+
6525
+ </xsl:variable>
6526
+
6210
6527
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6211
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6212
- <xsl:value-of select="$number"/>
6213
-
6528
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6529
+ <xsl:value-of select="$current_fn_number_text"/>
6214
6530
  </fo:basic-link>
6215
6531
  </fo:inline>
6216
6532
  <fo:footnote-body>
6217
6533
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6218
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6219
- <xsl:value-of select="$number"/>
6220
-
6534
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6535
+ <xsl:value-of select="$current_fn_number_text"/>
6221
6536
  </fo:inline>
6222
6537
  <xsl:apply-templates/>
6223
6538
  </fo:block>
@@ -6458,6 +6773,78 @@
6458
6773
  <!-- processing for admonition/p found in the template for 'p' -->
6459
6774
  <xsl:call-template name="paragraph"/>
6460
6775
 
6776
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6777
+ <xsl:copy>
6778
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6779
+ </xsl:copy>
6780
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6781
+ <xsl:copy>
6782
+ <xsl:copy-of select="@*"/>
6783
+
6784
+ <xsl:variable name="nodes_preface_">
6785
+ <xsl:for-each select="*">
6786
+ <node id="{@id}"/>
6787
+ </xsl:for-each>
6788
+ </xsl:variable>
6789
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6790
+
6791
+ <xsl:for-each select="*">
6792
+ <xsl:sort select="@displayorder" data-type="number"/>
6793
+
6794
+ <!-- process Section's title -->
6795
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6796
+ <xsl:if test="$preceding-sibling_id != ''">
6797
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6798
+ </xsl:if>
6799
+
6800
+ <xsl:choose>
6801
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6802
+ <xsl:otherwise>
6803
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6804
+ </xsl:otherwise>
6805
+ </xsl:choose>
6806
+
6807
+ </xsl:for-each>
6808
+ </xsl:copy>
6809
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
6810
+ <xsl:copy>
6811
+ <xsl:copy-of select="@*"/>
6812
+
6813
+ <xsl:variable name="nodes_sections_">
6814
+ <xsl:for-each select="*">
6815
+ <node id="{@id}"/>
6816
+ </xsl:for-each>
6817
+ </xsl:variable>
6818
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
6819
+
6820
+ <!-- move section 'Normative references' inside 'sections' -->
6821
+ <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']]">
6822
+ <xsl:sort select="@displayorder" data-type="number"/>
6823
+
6824
+ <!-- process Section's title -->
6825
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6826
+ <xsl:if test="$preceding-sibling_id != ''">
6827
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6828
+ </xsl:if>
6829
+
6830
+ <xsl:choose>
6831
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6832
+ <xsl:otherwise>
6833
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6834
+ </xsl:otherwise>
6835
+ </xsl:choose>
6836
+
6837
+ </xsl:for-each>
6838
+ </xsl:copy>
6839
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
6840
+ <xsl:copy>
6841
+ <xsl:copy-of select="@*"/>
6842
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
6843
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
6844
+ <xsl:sort select="@displayorder" data-type="number"/>
6845
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6846
+ </xsl:for-each>
6847
+ </xsl:copy>
6461
6848
  </xsl:template><xsl:template name="convertDate">
6462
6849
  <xsl:param name="date"/>
6463
6850
  <xsl:param name="format" select="'short'"/>
@@ -6702,22 +7089,25 @@
6702
7089
  <xsl:param name="pText" select="."/>
6703
7090
  <xsl:param name="sep" select="','"/>
6704
7091
  <xsl:param name="normalize-space" select="'true'"/>
7092
+ <xsl:param name="keep_sep" select="'false'"/>
6705
7093
  <xsl:if test="string-length($pText) &gt;0">
6706
- <item>
6707
- <xsl:choose>
6708
- <xsl:when test="$normalize-space = 'true'">
6709
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6710
- </xsl:when>
6711
- <xsl:otherwise>
6712
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6713
- </xsl:otherwise>
6714
- </xsl:choose>
6715
- </item>
6716
- <xsl:call-template name="split">
6717
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6718
- <xsl:with-param name="sep" select="$sep"/>
6719
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
6720
- </xsl:call-template>
7094
+ <item>
7095
+ <xsl:choose>
7096
+ <xsl:when test="$normalize-space = 'true'">
7097
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7098
+ </xsl:when>
7099
+ <xsl:otherwise>
7100
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7101
+ </xsl:otherwise>
7102
+ </xsl:choose>
7103
+ </item>
7104
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7105
+ <xsl:call-template name="split">
7106
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7107
+ <xsl:with-param name="sep" select="$sep"/>
7108
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7109
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7110
+ </xsl:call-template>
6721
7111
  </xsl:if>
6722
7112
  </xsl:template><xsl:template name="getDocumentId">
6723
7113
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -6908,53 +7298,153 @@
6908
7298
  <xsl:param name="first"/>
6909
7299
  <xsl:if test="$number != ''">
6910
7300
  <xsl:variable name="words">
6911
- <words>
6912
- <word cardinal="1">One-</word>
6913
- <word ordinal="1">First </word>
6914
- <word cardinal="2">Two-</word>
6915
- <word ordinal="2">Second </word>
6916
- <word cardinal="3">Three-</word>
6917
- <word ordinal="3">Third </word>
6918
- <word cardinal="4">Four-</word>
6919
- <word ordinal="4">Fourth </word>
6920
- <word cardinal="5">Five-</word>
6921
- <word ordinal="5">Fifth </word>
6922
- <word cardinal="6">Six-</word>
6923
- <word ordinal="6">Sixth </word>
6924
- <word cardinal="7">Seven-</word>
6925
- <word ordinal="7">Seventh </word>
6926
- <word cardinal="8">Eight-</word>
6927
- <word ordinal="8">Eighth </word>
6928
- <word cardinal="9">Nine-</word>
6929
- <word ordinal="9">Ninth </word>
6930
- <word ordinal="10">Tenth </word>
6931
- <word ordinal="11">Eleventh </word>
6932
- <word ordinal="12">Twelfth </word>
6933
- <word ordinal="13">Thirteenth </word>
6934
- <word ordinal="14">Fourteenth </word>
6935
- <word ordinal="15">Fifteenth </word>
6936
- <word ordinal="16">Sixteenth </word>
6937
- <word ordinal="17">Seventeenth </word>
6938
- <word ordinal="18">Eighteenth </word>
6939
- <word ordinal="19">Nineteenth </word>
6940
- <word cardinal="20">Twenty-</word>
6941
- <word ordinal="20">Twentieth </word>
6942
- <word cardinal="30">Thirty-</word>
6943
- <word ordinal="30">Thirtieth </word>
6944
- <word cardinal="40">Forty-</word>
6945
- <word ordinal="40">Fortieth </word>
6946
- <word cardinal="50">Fifty-</word>
6947
- <word ordinal="50">Fiftieth </word>
6948
- <word cardinal="60">Sixty-</word>
6949
- <word ordinal="60">Sixtieth </word>
6950
- <word cardinal="70">Seventy-</word>
6951
- <word ordinal="70">Seventieth </word>
6952
- <word cardinal="80">Eighty-</word>
6953
- <word ordinal="80">Eightieth </word>
6954
- <word cardinal="90">Ninety-</word>
6955
- <word ordinal="90">Ninetieth </word>
6956
- <word cardinal="100">Hundred-</word>
6957
- <word ordinal="100">Hundredth </word>
7301
+ <words>
7302
+ <xsl:choose>
7303
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7304
+ <word cardinal="1">Une-</word>
7305
+ <word ordinal="1">Première </word>
7306
+ <word cardinal="2">Deux-</word>
7307
+ <word ordinal="2">Seconde </word>
7308
+ <word cardinal="3">Trois-</word>
7309
+ <word ordinal="3">Tierce </word>
7310
+ <word cardinal="4">Quatre-</word>
7311
+ <word ordinal="4">Quatrième </word>
7312
+ <word cardinal="5">Cinq-</word>
7313
+ <word ordinal="5">Cinquième </word>
7314
+ <word cardinal="6">Six-</word>
7315
+ <word ordinal="6">Sixième </word>
7316
+ <word cardinal="7">Sept-</word>
7317
+ <word ordinal="7">Septième </word>
7318
+ <word cardinal="8">Huit-</word>
7319
+ <word ordinal="8">Huitième </word>
7320
+ <word cardinal="9">Neuf-</word>
7321
+ <word ordinal="9">Neuvième </word>
7322
+ <word ordinal="10">Dixième </word>
7323
+ <word ordinal="11">Onzième </word>
7324
+ <word ordinal="12">Douzième </word>
7325
+ <word ordinal="13">Treizième </word>
7326
+ <word ordinal="14">Quatorzième </word>
7327
+ <word ordinal="15">Quinzième </word>
7328
+ <word ordinal="16">Seizième </word>
7329
+ <word ordinal="17">Dix-septième </word>
7330
+ <word ordinal="18">Dix-huitième </word>
7331
+ <word ordinal="19">Dix-neuvième </word>
7332
+ <word cardinal="20">Vingt-</word>
7333
+ <word ordinal="20">Vingtième </word>
7334
+ <word cardinal="30">Trente-</word>
7335
+ <word ordinal="30">Trentième </word>
7336
+ <word cardinal="40">Quarante-</word>
7337
+ <word ordinal="40">Quarantième </word>
7338
+ <word cardinal="50">Cinquante-</word>
7339
+ <word ordinal="50">Cinquantième </word>
7340
+ <word cardinal="60">Soixante-</word>
7341
+ <word ordinal="60">Soixantième </word>
7342
+ <word cardinal="70">Septante-</word>
7343
+ <word ordinal="70">Septantième </word>
7344
+ <word cardinal="80">Huitante-</word>
7345
+ <word ordinal="80">Huitantième </word>
7346
+ <word cardinal="90">Nonante-</word>
7347
+ <word ordinal="90">Nonantième </word>
7348
+ <word cardinal="100">Cent-</word>
7349
+ <word ordinal="100">Centième </word>
7350
+ </xsl:when>
7351
+ <xsl:when test="$lang = 'ru'">
7352
+ <word cardinal="1">Одна-</word>
7353
+ <word ordinal="1">Первое </word>
7354
+ <word cardinal="2">Две-</word>
7355
+ <word ordinal="2">Второе </word>
7356
+ <word cardinal="3">Три-</word>
7357
+ <word ordinal="3">Третье </word>
7358
+ <word cardinal="4">Четыре-</word>
7359
+ <word ordinal="4">Четвертое </word>
7360
+ <word cardinal="5">Пять-</word>
7361
+ <word ordinal="5">Пятое </word>
7362
+ <word cardinal="6">Шесть-</word>
7363
+ <word ordinal="6">Шестое </word>
7364
+ <word cardinal="7">Семь-</word>
7365
+ <word ordinal="7">Седьмое </word>
7366
+ <word cardinal="8">Восемь-</word>
7367
+ <word ordinal="8">Восьмое </word>
7368
+ <word cardinal="9">Девять-</word>
7369
+ <word ordinal="9">Девятое </word>
7370
+ <word ordinal="10">Десятое </word>
7371
+ <word ordinal="11">Одиннадцатое </word>
7372
+ <word ordinal="12">Двенадцатое </word>
7373
+ <word ordinal="13">Тринадцатое </word>
7374
+ <word ordinal="14">Четырнадцатое </word>
7375
+ <word ordinal="15">Пятнадцатое </word>
7376
+ <word ordinal="16">Шестнадцатое </word>
7377
+ <word ordinal="17">Семнадцатое </word>
7378
+ <word ordinal="18">Восемнадцатое </word>
7379
+ <word ordinal="19">Девятнадцатое </word>
7380
+ <word cardinal="20">Двадцать-</word>
7381
+ <word ordinal="20">Двадцатое </word>
7382
+ <word cardinal="30">Тридцать-</word>
7383
+ <word ordinal="30">Тридцатое </word>
7384
+ <word cardinal="40">Сорок-</word>
7385
+ <word ordinal="40">Сороковое </word>
7386
+ <word cardinal="50">Пятьдесят-</word>
7387
+ <word ordinal="50">Пятидесятое </word>
7388
+ <word cardinal="60">Шестьдесят-</word>
7389
+ <word ordinal="60">Шестидесятое </word>
7390
+ <word cardinal="70">Семьдесят-</word>
7391
+ <word ordinal="70">Семидесятое </word>
7392
+ <word cardinal="80">Восемьдесят-</word>
7393
+ <word ordinal="80">Восьмидесятое </word>
7394
+ <word cardinal="90">Девяносто-</word>
7395
+ <word ordinal="90">Девяностое </word>
7396
+ <word cardinal="100">Сто-</word>
7397
+ <word ordinal="100">Сотое </word>
7398
+ </xsl:when>
7399
+ <xsl:otherwise> <!-- default english -->
7400
+ <word cardinal="1">One-</word>
7401
+ <word ordinal="1">First </word>
7402
+ <word cardinal="2">Two-</word>
7403
+ <word ordinal="2">Second </word>
7404
+ <word cardinal="3">Three-</word>
7405
+ <word ordinal="3">Third </word>
7406
+ <word cardinal="4">Four-</word>
7407
+ <word ordinal="4">Fourth </word>
7408
+ <word cardinal="5">Five-</word>
7409
+ <word ordinal="5">Fifth </word>
7410
+ <word cardinal="6">Six-</word>
7411
+ <word ordinal="6">Sixth </word>
7412
+ <word cardinal="7">Seven-</word>
7413
+ <word ordinal="7">Seventh </word>
7414
+ <word cardinal="8">Eight-</word>
7415
+ <word ordinal="8">Eighth </word>
7416
+ <word cardinal="9">Nine-</word>
7417
+ <word ordinal="9">Ninth </word>
7418
+ <word ordinal="10">Tenth </word>
7419
+ <word ordinal="11">Eleventh </word>
7420
+ <word ordinal="12">Twelfth </word>
7421
+ <word ordinal="13">Thirteenth </word>
7422
+ <word ordinal="14">Fourteenth </word>
7423
+ <word ordinal="15">Fifteenth </word>
7424
+ <word ordinal="16">Sixteenth </word>
7425
+ <word ordinal="17">Seventeenth </word>
7426
+ <word ordinal="18">Eighteenth </word>
7427
+ <word ordinal="19">Nineteenth </word>
7428
+ <word cardinal="20">Twenty-</word>
7429
+ <word ordinal="20">Twentieth </word>
7430
+ <word cardinal="30">Thirty-</word>
7431
+ <word ordinal="30">Thirtieth </word>
7432
+ <word cardinal="40">Forty-</word>
7433
+ <word ordinal="40">Fortieth </word>
7434
+ <word cardinal="50">Fifty-</word>
7435
+ <word ordinal="50">Fiftieth </word>
7436
+ <word cardinal="60">Sixty-</word>
7437
+ <word ordinal="60">Sixtieth </word>
7438
+ <word cardinal="70">Seventy-</word>
7439
+ <word ordinal="70">Seventieth </word>
7440
+ <word cardinal="80">Eighty-</word>
7441
+ <word ordinal="80">Eightieth </word>
7442
+ <word cardinal="90">Ninety-</word>
7443
+ <word ordinal="90">Ninetieth </word>
7444
+ <word cardinal="100">Hundred-</word>
7445
+ <word ordinal="100">Hundredth </word>
7446
+ </xsl:otherwise>
7447
+ </xsl:choose>
6958
7448
  </words>
6959
7449
  </xsl:variable>
6960
7450
 
@@ -7028,4 +7518,18 @@
7028
7518
  <xsl:otherwise>_</xsl:otherwise>
7029
7519
  </xsl:choose>
7030
7520
  </xsl:attribute>
7521
+ </xsl:template><xsl:template name="substring-after-last">
7522
+ <xsl:param name="value"/>
7523
+ <xsl:param name="delimiter"/>
7524
+ <xsl:choose>
7525
+ <xsl:when test="contains($value, $delimiter)">
7526
+ <xsl:call-template name="substring-after-last">
7527
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7528
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7529
+ </xsl:call-template>
7530
+ </xsl:when>
7531
+ <xsl:otherwise>
7532
+ <xsl:value-of select="$value"/>
7533
+ </xsl:otherwise>
7534
+ </xsl:choose>
7031
7535
  </xsl:template></xsl:stylesheet>