metanorma-mpfa 0.8.3 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,7 @@
32
32
  <item level="1" id="Foreword" display="true">Foreword</item>
33
33
  <item id="term-script" display="false">3.2</item>
34
34
  -->
35
- <xsl:variable name="contents">
35
+ <xsl:variable name="contents_">
36
36
  <contents>
37
37
  <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:preface/*[not(local-name() = 'terms')]" mode="contents"/>
38
38
  <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:preface/mpfd:terms" mode="contents"/>
@@ -41,11 +41,12 @@
41
41
 
42
42
  <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:annex" mode="contents"/>
43
43
 
44
- <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:bibliography" mode="contents"/>
44
+ <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:bibliography" mode="contents"/>
45
45
 
46
+ <xsl:call-template name="processTablesFigures_Contents"/>
46
47
  </contents>
47
48
  </xsl:variable>
48
-
49
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
49
50
 
50
51
  <xsl:template match="/">
51
52
  <xsl:call-template name="namespaceCheck"/>
@@ -159,7 +160,7 @@
159
160
  <xsl:if test="$debug = 'true'">
160
161
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
161
162
  DEBUG
162
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
163
+ contents=<xsl:copy-of select="$contents"/>
163
164
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
164
165
  </xsl:if>
165
166
  <!-- Table of content -->
@@ -171,7 +172,7 @@
171
172
  </xsl:variable>
172
173
  <fo:block font-size="14pt" margin-bottom="15.5pt" role="H1"><xsl:value-of select="$title-toc"/></fo:block>
173
174
  <fo:block line-height="115%" role="TOC">
174
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']">
175
+ <xsl:for-each select="$contents//item[@display = 'true']">
175
176
  <fo:block role="TOCI">
176
177
  <xsl:if test="@level = 1">
177
178
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -191,21 +192,43 @@
191
192
  </xsl:if>
192
193
  </fo:block>
193
194
  </fo:list-item-label>
194
- <fo:list-item-body start-indent="body-start()">
195
- <fo:block text-align-last="justify">
196
- <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
197
- <xsl:apply-templates select="title"/>
198
- <fo:inline keep-together.within-line="always">
199
- <fo:leader leader-pattern="dots"/>
200
- <fo:page-number-citation ref-id="{@id}"/>
201
- </fo:inline>
202
- </fo:basic-link>
203
- </fo:block>
204
- </fo:list-item-body>
195
+ <fo:list-item-body start-indent="body-start()">
196
+ <fo:block text-align-last="justify">
197
+ <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
198
+ <xsl:apply-templates select="title"/>
199
+ <fo:inline keep-together.within-line="always">
200
+ <fo:leader leader-pattern="dots"/>
201
+ <fo:page-number-citation ref-id="{@id}"/>
202
+ </fo:inline>
203
+ </fo:basic-link>
204
+ </fo:block>
205
+ </fo:list-item-body>
205
206
  </fo:list-item>
206
207
  </fo:list-block>
207
208
  </fo:block>
208
209
  </xsl:for-each>
210
+
211
+
212
+ <!-- List of Tables -->
213
+ <xsl:if test="$contents//tables/table">
214
+ <xsl:call-template name="insertListOf_Title">
215
+ <xsl:with-param name="title" select="$title-list-tables"/>
216
+ </xsl:call-template>
217
+ <xsl:for-each select="$contents//tables/table">
218
+ <xsl:call-template name="insertListOf_Item"/>
219
+ </xsl:for-each>
220
+ </xsl:if>
221
+
222
+ <!-- List of Figures -->
223
+ <xsl:if test="$contents//figures/figure">
224
+ <xsl:call-template name="insertListOf_Title">
225
+ <xsl:with-param name="title" select="$title-list-figures"/>
226
+ </xsl:call-template>
227
+ <xsl:for-each select="$contents//figures/figure">
228
+ <xsl:call-template name="insertListOf_Item"/>
229
+ </xsl:for-each>
230
+ </xsl:if>
231
+
209
232
  </fo:block>
210
233
  </fo:block-container>
211
234
  <xsl:if test="/mpfd:mpfd-standard/mpfd:preface/*">
@@ -246,6 +269,28 @@
246
269
  </fo:root>
247
270
  </xsl:template>
248
271
 
272
+ <xsl:template name="insertListOf_Title">
273
+ <xsl:param name="title"/>
274
+ <fo:block margin-top="6pt" keep-with-next="always">
275
+ <xsl:value-of select="$title"/>
276
+ </fo:block>
277
+ </xsl:template>
278
+
279
+ <xsl:template name="insertListOf_Item">
280
+ <fo:block role="TOCI" text-align-last="justify">
281
+ <fo:basic-link internal-destination="{@id}">
282
+ <xsl:call-template name="setAltText">
283
+ <xsl:with-param name="value" select="@alt-text"/>
284
+ </xsl:call-template>
285
+ <xsl:apply-templates select="." mode="contents"/>
286
+ <fo:inline keep-together.within-line="always">
287
+ <fo:leader leader-pattern="dots"/>
288
+ <fo:page-number-citation ref-id="{@id}"/>
289
+ </fo:inline>
290
+ </fo:basic-link>
291
+ </fo:block>
292
+ </xsl:template>
293
+
249
294
  <xsl:template match="node()">
250
295
  <xsl:apply-templates/>
251
296
  </xsl:template>
@@ -551,6 +596,10 @@
551
596
  <xsl:text>Édition </xsl:text>
552
597
  </title-edition>
553
598
 
599
+ <title-edition lang="ru">
600
+ <xsl:text>Издание </xsl:text>
601
+ </title-edition>
602
+
554
603
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
555
604
  <title-toc lang="en">
556
605
 
@@ -567,7 +616,7 @@
567
616
  <xsl:text>Contents</xsl:text>
568
617
 
569
618
  </title-toc>
570
-
619
+
571
620
  <title-descriptors lang="en">Descriptors</title-descriptors>
572
621
 
573
622
  <title-part lang="en">
@@ -579,7 +628,11 @@
579
628
 
580
629
 
581
630
 
582
- </title-part>
631
+ </title-part>
632
+ <title-part lang="ru">
633
+
634
+
635
+ </title-part>
583
636
  <title-part lang="zh">第 # 部分:</title-part>
584
637
 
585
638
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -595,10 +648,35 @@
595
648
 
596
649
  <title-summary lang="en">Summary</title-summary>
597
650
 
651
+ <title-continued lang="ru">(продолжение)</title-continued>
598
652
  <title-continued lang="en">(continued)</title-continued>
599
653
  <title-continued lang="fr">(continué)</title-continued>
600
654
 
601
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
655
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
656
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
657
+ <xsl:value-of select="$toc_table_title"/>
658
+ <xsl:if test="normalize-space($toc_table_title) = ''">
659
+ <xsl:call-template name="getTitle">
660
+ <xsl:with-param name="name" select="'title-list-tables'"/>
661
+ </xsl:call-template>
662
+ </xsl:if>
663
+ </xsl:variable><xsl:variable name="title-list-figures">
664
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
665
+ <xsl:value-of select="$toc_figure_title"/>
666
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
667
+ <xsl:call-template name="getTitle">
668
+ <xsl:with-param name="name" select="'title-list-figures'"/>
669
+ </xsl:call-template>
670
+ </xsl:if>
671
+ </xsl:variable><xsl:variable name="title-list-recommendations">
672
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
673
+ <xsl:value-of select="$toc_requirement_title"/>
674
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
675
+ <xsl:call-template name="getTitle">
676
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
677
+ </xsl:call-template>
678
+ </xsl:if>
679
+ </xsl:variable><xsl:variable name="bibdata">
602
680
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
603
681
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
604
682
  </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">
@@ -1295,13 +1373,19 @@
1295
1373
  </xsl:attribute-set><xsl:variable name="color-added-text">
1296
1374
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1297
1375
  </xsl:variable><xsl:attribute-set name="add-style">
1298
- <xsl:attribute name="color">red</xsl:attribute>
1299
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
1300
- <!-- <xsl:attribute name="color">black</xsl:attribute>
1301
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1302
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
1303
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1304
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1376
+
1377
+ <xsl:attribute name="color">red</xsl:attribute>
1378
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1379
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1380
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1381
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1382
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1383
+
1384
+ </xsl:attribute-set><xsl:variable name="add-style">
1385
+ <add-style xsl:use-attribute-sets="add-style"/>
1386
+ </xsl:variable><xsl:template name="append_add-style">
1387
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1388
+ </xsl:template><xsl:variable name="color-deleted-text">
1305
1389
  <xsl:text>red</xsl:text>
1306
1390
  </xsl:variable><xsl:attribute-set name="del-style">
1307
1391
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -1721,14 +1805,42 @@
1721
1805
 
1722
1806
 
1723
1807
  </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">
1808
+ <xsl:variable name="nodes_preface_">
1809
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
1810
+ <node id="{@id}"/>
1811
+ </xsl:for-each>
1812
+ </xsl:variable>
1813
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
1814
+
1724
1815
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1725
1816
  <xsl:sort select="@displayorder" data-type="number"/>
1817
+
1818
+ <!-- process Section's title -->
1819
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
1820
+ <xsl:if test="$preceding-sibling_id != ''">
1821
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
1822
+ </xsl:if>
1823
+
1726
1824
  <xsl:apply-templates select="." mode="contents"/>
1727
1825
  </xsl:for-each>
1728
1826
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
1729
1827
 
1828
+ <xsl:variable name="nodes_sections_">
1829
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
1830
+ <node id="{@id}"/>
1831
+ </xsl:for-each>
1832
+ </xsl:variable>
1833
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
1834
+
1730
1835
  <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']]">
1731
1836
  <xsl:sort select="@displayorder" data-type="number"/>
1837
+
1838
+ <!-- process Section's title -->
1839
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
1840
+ <xsl:if test="$preceding-sibling_id != ''">
1841
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
1842
+ </xsl:if>
1843
+
1732
1844
  <xsl:apply-templates select="." mode="contents"/>
1733
1845
  </xsl:for-each>
1734
1846
 
@@ -1741,6 +1853,30 @@
1741
1853
  <xsl:sort select="@displayorder" data-type="number"/>
1742
1854
  <xsl:apply-templates select="." mode="contents"/>
1743
1855
  </xsl:for-each>
1856
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
1857
+ <xsl:param name="always"/>
1858
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1859
+ <xsl:call-template name="processTables_Contents"/>
1860
+ </xsl:if>
1861
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1862
+ <xsl:call-template name="processFigures_Contents"/>
1863
+ </xsl:if>
1864
+ </xsl:template><xsl:template name="processTables_Contents">
1865
+ <tables>
1866
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
1867
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
1868
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1869
+ </table>
1870
+ </xsl:for-each>
1871
+ </tables>
1872
+ </xsl:template><xsl:template name="processFigures_Contents">
1873
+ <figures>
1874
+ <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) != '']">
1875
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
1876
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1877
+ </figure>
1878
+ </xsl:for-each>
1879
+ </figures>
1744
1880
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1745
1881
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1746
1882
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -1867,7 +2003,7 @@
1867
2003
  </xsl:call-template>
1868
2004
  </xsl:if>
1869
2005
  </xsl:variable>
1870
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2006
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
1871
2007
 
1872
2008
 
1873
2009
  <xsl:variable name="margin-side">
@@ -2127,7 +2263,7 @@
2127
2263
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2128
2264
  <!-- 2009 thinspace -->
2129
2265
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2130
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2266
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2131
2267
  </xsl:call-template>
2132
2268
  </xsl:variable>
2133
2269
  <xsl:variable name="max_length">
@@ -2513,37 +2649,7 @@
2513
2649
 
2514
2650
  <!-- list of footnotes to calculate actual footnotes number -->
2515
2651
  <xsl:variable name="p_fn_">
2516
- <xsl:choose>
2517
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2518
- <fn gen_id="{generate-id(.)}">
2519
- <xsl:copy-of select="@*"/>
2520
- <xsl:copy-of select="node()"/>
2521
- </fn>
2522
- </xsl:when>
2523
- <xsl:otherwise>
2524
- <!-- itetation for:
2525
- footnotes in bibdata/title
2526
- footnotes in bibliography
2527
- footnotes in document's body (except table's head/body/foot and figure text)
2528
- -->
2529
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2530
- <fn gen_id="{generate-id(.)}">
2531
- <xsl:copy-of select="@*"/>
2532
- <xsl:copy-of select="node()"/>
2533
- </fn>
2534
- </xsl:for-each>
2535
- <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']/*">
2536
- <xsl:sort select="@displayorder" data-type="number"/>
2537
- <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])]">
2538
- <!-- copy unique fn -->
2539
- <fn gen_id="{generate-id(.)}">
2540
- <xsl:copy-of select="@*"/>
2541
- <xsl:copy-of select="node()"/>
2542
- </fn>
2543
- </xsl:for-each>
2544
- </xsl:for-each>
2545
- </xsl:otherwise>
2546
- </xsl:choose>
2652
+ <xsl:call-template name="get_fn_list"/>
2547
2653
  </xsl:variable>
2548
2654
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2549
2655
 
@@ -2604,6 +2710,38 @@
2604
2710
  <xsl:copy-of select="$footnote_inline"/>
2605
2711
  </xsl:otherwise>
2606
2712
  </xsl:choose>
2713
+ </xsl:template><xsl:template name="get_fn_list">
2714
+ <xsl:choose>
2715
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2716
+ <fn gen_id="{generate-id(.)}">
2717
+ <xsl:copy-of select="@*"/>
2718
+ <xsl:copy-of select="node()"/>
2719
+ </fn>
2720
+ </xsl:when>
2721
+ <xsl:otherwise>
2722
+ <!-- itetation for:
2723
+ footnotes in bibdata/title
2724
+ footnotes in bibliography
2725
+ footnotes in document's body (except table's head/body/foot and figure text)
2726
+ -->
2727
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2728
+ <fn gen_id="{generate-id(.)}">
2729
+ <xsl:copy-of select="@*"/>
2730
+ <xsl:copy-of select="node()"/>
2731
+ </fn>
2732
+ </xsl:for-each>
2733
+ <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']/*">
2734
+ <xsl:sort select="@displayorder" data-type="number"/>
2735
+ <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])]">
2736
+ <!-- copy unique fn -->
2737
+ <fn gen_id="{generate-id(.)}">
2738
+ <xsl:copy-of select="@*"/>
2739
+ <xsl:copy-of select="node()"/>
2740
+ </fn>
2741
+ </xsl:for-each>
2742
+ </xsl:for-each>
2743
+ </xsl:otherwise>
2744
+ </xsl:choose>
2607
2745
  </xsl:template><xsl:template name="table_fn_display">
2608
2746
  <xsl:variable name="references">
2609
2747
 
@@ -2775,7 +2913,7 @@
2775
2913
  </fo:inline>
2776
2914
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
2777
2915
  <fo:inline><xsl:value-of select="."/></fo:inline>
2778
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
2916
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
2779
2917
  <fo:inline>
2780
2918
  <xsl:apply-templates/>
2781
2919
  </fo:inline>
@@ -3751,6 +3889,9 @@
3751
3889
  </fo:inline>
3752
3890
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
3753
3891
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
3892
+ <xsl:if test="parent::*[local-name() = 'add']">
3893
+ <xsl:call-template name="append_add-style"/>
3894
+ </xsl:if>
3754
3895
  <xsl:apply-templates/>
3755
3896
  </fo:basic-link>
3756
3897
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -3848,6 +3989,13 @@
3848
3989
 
3849
3990
 
3850
3991
 
3992
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
3993
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
3994
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
3995
+ <xsl:call-template name="append_add-style"/>
3996
+ </xsl:if>
3997
+
3998
+
3851
3999
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
3852
4000
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
3853
4001
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -3886,6 +4034,12 @@
3886
4034
 
3887
4035
 
3888
4036
 
4037
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4038
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4039
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4040
+ <xsl:call-template name="append_add-style"/>
4041
+ </xsl:if>
4042
+
3889
4043
  <xsl:apply-templates select="*[local-name() = 'name']"/>
3890
4044
 
3891
4045
  </fo:inline>
@@ -3935,6 +4089,7 @@
3935
4089
  </fo:block>
3936
4090
  </xsl:template><xsl:template match="*[local-name() = 'term']">
3937
4091
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4092
+
3938
4093
 
3939
4094
 
3940
4095
 
@@ -4371,7 +4526,11 @@
4371
4526
  <xsl:value-of select="."/>
4372
4527
  </xsl:template><xsl:template match="node()" mode="contents">
4373
4528
  <xsl:apply-templates mode="contents"/>
4374
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4529
+ </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">
4530
+ <xsl:call-template name="contents_section-title"/>
4531
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4532
+ <xsl:call-template name="contents_section-title"/>
4533
+ </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">
4375
4534
  <xsl:variable name="level">
4376
4535
  <xsl:call-template name="getLevel">
4377
4536
  <xsl:with-param name="depth" select="@depth"/>
@@ -4440,13 +4599,14 @@
4440
4599
  <xsl:apply-templates mode="bookmarks"/>
4441
4600
  </xsl:template><xsl:template name="addBookmarks">
4442
4601
  <xsl:param name="contents"/>
4443
- <xsl:if test="xalan:nodeset($contents)//item">
4602
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4603
+ <xsl:if test="$contents_nodes//item">
4444
4604
  <fo:bookmark-tree>
4445
4605
  <xsl:choose>
4446
- <xsl:when test="xalan:nodeset($contents)/doc">
4606
+ <xsl:when test="$contents_nodes/doc">
4447
4607
  <xsl:choose>
4448
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4449
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4608
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4609
+ <xsl:for-each select="$contents_nodes/doc">
4450
4610
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4451
4611
  <xsl:if test="@bundle = 'true'">
4452
4612
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4497,7 +4657,7 @@
4497
4657
  </xsl:for-each>
4498
4658
  </xsl:when>
4499
4659
  <xsl:otherwise>
4500
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4660
+ <xsl:for-each select="$contents_nodes/doc">
4501
4661
 
4502
4662
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4503
4663
 
@@ -4515,25 +4675,36 @@
4515
4675
  </xsl:choose>
4516
4676
  </xsl:when>
4517
4677
  <xsl:otherwise>
4518
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4678
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4679
+
4680
+ <xsl:call-template name="insertFigureBookmarks">
4681
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4682
+ </xsl:call-template>
4683
+
4684
+ <xsl:call-template name="insertTableBookmarks">
4685
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4686
+ <xsl:with-param name="lang" select="@lang"/>
4687
+ </xsl:call-template>
4688
+
4519
4689
  </xsl:otherwise>
4520
4690
  </xsl:choose>
4521
4691
 
4692
+
4522
4693
 
4523
4694
 
4524
4695
 
4525
4696
 
4526
-
4527
-
4697
+
4528
4698
 
4529
4699
  </fo:bookmark-tree>
4530
4700
  </xsl:if>
4531
4701
  </xsl:template><xsl:template name="insertFigureBookmarks">
4532
4702
  <xsl:param name="contents"/>
4533
- <xsl:if test="xalan:nodeset($contents)/figure">
4534
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
4703
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4704
+ <xsl:if test="$contents_nodes/figure">
4705
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4535
4706
  <fo:bookmark-title>Figures</fo:bookmark-title>
4536
- <xsl:for-each select="xalan:nodeset($contents)/figure">
4707
+ <xsl:for-each select="$contents_nodes/figure">
4537
4708
  <fo:bookmark internal-destination="{@id}">
4538
4709
  <fo:bookmark-title>
4539
4710
  <xsl:value-of select="normalize-space(title)"/>
@@ -4542,18 +4713,40 @@
4542
4713
  </xsl:for-each>
4543
4714
  </fo:bookmark>
4544
4715
  </xsl:if>
4716
+
4717
+
4718
+ <xsl:if test="$contents_nodes//figures/figure">
4719
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4720
+
4721
+
4722
+
4723
+ <xsl:variable name="bookmark-title">
4724
+
4725
+ <xsl:value-of select="$title-list-figures"/>
4726
+
4727
+ </xsl:variable>
4728
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
4729
+ <xsl:for-each select="$contents_nodes//figures/figure">
4730
+ <fo:bookmark internal-destination="{@id}">
4731
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4732
+ </fo:bookmark>
4733
+ </xsl:for-each>
4734
+ </fo:bookmark>
4735
+ </xsl:if>
4736
+
4545
4737
  </xsl:template><xsl:template name="insertTableBookmarks">
4546
4738
  <xsl:param name="contents"/>
4547
4739
  <xsl:param name="lang"/>
4548
- <xsl:if test="xalan:nodeset($contents)/table">
4549
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
4740
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4741
+ <xsl:if test="$contents_nodes/table">
4742
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4550
4743
  <fo:bookmark-title>
4551
4744
  <xsl:choose>
4552
4745
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4553
4746
  <xsl:otherwise>Tables</xsl:otherwise>
4554
4747
  </xsl:choose>
4555
4748
  </fo:bookmark-title>
4556
- <xsl:for-each select="xalan:nodeset($contents)/table">
4749
+ <xsl:for-each select="$contents_nodes/table">
4557
4750
  <fo:bookmark internal-destination="{@id}">
4558
4751
  <fo:bookmark-title>
4559
4752
  <xsl:value-of select="normalize-space(title)"/>
@@ -4562,6 +4755,29 @@
4562
4755
  </xsl:for-each>
4563
4756
  </fo:bookmark>
4564
4757
  </xsl:if>
4758
+
4759
+
4760
+ <xsl:if test="$contents_nodes//tables/table">
4761
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4762
+
4763
+
4764
+
4765
+ <xsl:variable name="bookmark-title">
4766
+
4767
+ <xsl:value-of select="$title-list-tables"/>
4768
+
4769
+ </xsl:variable>
4770
+
4771
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
4772
+
4773
+ <xsl:for-each select="$contents_nodes//tables/table">
4774
+ <fo:bookmark internal-destination="{@id}">
4775
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4776
+ </fo:bookmark>
4777
+ </xsl:for-each>
4778
+ </fo:bookmark>
4779
+ </xsl:if>
4780
+
4565
4781
  </xsl:template><xsl:template name="getLangVersion">
4566
4782
  <xsl:param name="lang"/>
4567
4783
  <xsl:param name="doctype" select="''"/>
@@ -4786,7 +5002,51 @@
4786
5002
  <xsl:with-param name="text" select="$text_step1"/>
4787
5003
  </xsl:call-template>
4788
5004
  </xsl:variable>
4789
- <xsl:value-of select="$text_step2"/>
5005
+
5006
+ <!-- <xsl:value-of select="$text_step2"/> -->
5007
+
5008
+ <!-- add zero-width space after space -->
5009
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5010
+
5011
+ <!-- split text by zero-width space -->
5012
+ <xsl:variable name="text_step4">
5013
+ <xsl:call-template name="split">
5014
+ <xsl:with-param name="pText" select="$text_step3"/>
5015
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5016
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5017
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5018
+ </xsl:call-template>
5019
+ </xsl:variable>
5020
+
5021
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5022
+ <xsl:choose>
5023
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5024
+ <xsl:call-template name="interspers">
5025
+ <xsl:with-param name="str" select="."/>
5026
+ </xsl:call-template>
5027
+ </xsl:when>
5028
+ <xsl:otherwise>
5029
+ <xsl:value-of select="."/>
5030
+ </xsl:otherwise>
5031
+ </xsl:choose>
5032
+ </xsl:for-each>
5033
+
5034
+ </xsl:template><xsl:template name="interspers">
5035
+ <xsl:param name="str"/>
5036
+ <xsl:param name="char" select="$zero_width_space"/>
5037
+ <xsl:if test="$str != ''">
5038
+ <xsl:value-of select="substring($str, 1, 1)"/>
5039
+
5040
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5041
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5042
+ <xsl:value-of select="$char"/>
5043
+ </xsl:if>
5044
+
5045
+ <xsl:call-template name="interspers">
5046
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5047
+ <xsl:with-param name="char" select="$char"/>
5048
+ </xsl:call-template>
5049
+ </xsl:if>
4790
5050
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
4791
5051
  <xsl:apply-templates mode="syntax_highlight"/>
4792
5052
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5218,6 +5478,8 @@
5218
5478
  </xsl:otherwise>
5219
5479
  </xsl:choose> -->
5220
5480
  </fo:block>
5481
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5482
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5221
5483
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5222
5484
  <xsl:if test="normalize-space() != ''">
5223
5485
  <xsl:value-of select="."/>
@@ -5292,26 +5554,24 @@
5292
5554
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5293
5555
  <xsl:text>— </xsl:text>
5294
5556
  <xsl:apply-templates/>
5295
- </xsl:template><xsl:variable name="bibitem_hidden_">
5557
+ </xsl:template><xsl:variable name="bibitems_">
5558
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5559
+ <xsl:copy-of select="."/>
5560
+ </xsl:for-each>
5561
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5296
5562
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5297
5563
  <xsl:copy-of select="."/>
5298
5564
  </xsl:for-each>
5299
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5565
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5300
5566
  <xsl:copy-of select="."/>
5301
5567
  </xsl:for-each>
5302
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5303
-
5304
- <xsl:variable name="bibitemid">
5305
- <xsl:choose>
5306
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5307
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5308
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5309
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5310
- </xsl:choose>
5311
- </xsl:variable>
5312
-
5568
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5569
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5570
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5571
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5313
5572
  <xsl:choose>
5314
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5573
+ <!-- <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) -->
5574
+ <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) -->
5315
5575
  <fo:inline xsl:use-attribute-sets="eref-style">
5316
5576
  <xsl:if test="@type = 'footnote'">
5317
5577
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5325,8 +5585,8 @@
5325
5585
  <xsl:variable name="text" select="normalize-space()"/>
5326
5586
 
5327
5587
 
5328
-
5329
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5588
+
5589
+ <fo:basic-link fox:alt-text="{@citeas}">
5330
5590
  <xsl:if test="normalize-space(@citeas) = ''">
5331
5591
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5332
5592
  </xsl:if>
@@ -5339,14 +5599,21 @@
5339
5599
 
5340
5600
  </xsl:if>
5341
5601
 
5342
-
5602
+ <xsl:choose>
5603
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5604
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5605
+ </xsl:when>
5606
+ <xsl:otherwise>
5607
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5608
+ </xsl:otherwise>
5609
+ </xsl:choose>
5343
5610
 
5344
5611
  <xsl:apply-templates/>
5345
5612
  </fo:basic-link>
5346
-
5613
+
5347
5614
  </fo:inline>
5348
5615
  </xsl:when>
5349
- <xsl:otherwise>
5616
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5350
5617
  <fo:inline><xsl:apply-templates/></fo:inline>
5351
5618
  </xsl:otherwise>
5352
5619
  </xsl:choose>
@@ -5674,7 +5941,7 @@
5674
5941
 
5675
5942
 
5676
5943
 
5677
-
5944
+
5678
5945
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
5679
5946
  </fo:list-block>
5680
5947
  <!-- <xsl:for-each select="./iho:note">
@@ -5692,6 +5959,11 @@
5692
5959
 
5693
5960
 
5694
5961
 
5962
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5963
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
5964
+ <xsl:call-template name="append_add-style"/>
5965
+ </xsl:if>
5966
+
5695
5967
  <xsl:call-template name="getListItemFormat"/>
5696
5968
  </fo:block>
5697
5969
  </fo:list-item-label>
@@ -6061,23 +6333,45 @@
6061
6333
  <xsl:apply-templates/>
6062
6334
  </fo:inline>
6063
6335
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6336
+
6337
+ <!-- list of footnotes to calculate actual footnotes number -->
6338
+ <xsl:variable name="p_fn_">
6339
+ <xsl:call-template name="get_fn_list"/>
6340
+ </xsl:variable>
6341
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6342
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6343
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6344
+ <!-- fn sequence number in document -->
6345
+ <xsl:variable name="current_fn_number">
6346
+ <xsl:choose>
6347
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6348
+ <xsl:otherwise>
6349
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6350
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6351
+ </xsl:otherwise>
6352
+ </xsl:choose>
6353
+ </xsl:variable>
6064
6354
  <fo:footnote>
6065
6355
  <xsl:variable name="number">
6066
6356
 
6067
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6357
+ <xsl:value-of select="$current_fn_number"/>
6068
6358
 
6069
6359
  </xsl:variable>
6360
+
6361
+ <xsl:variable name="current_fn_number_text">
6362
+ <xsl:value-of select="$number"/>
6363
+
6364
+ </xsl:variable>
6365
+
6070
6366
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6071
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6072
- <xsl:value-of select="$number"/>
6073
-
6367
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6368
+ <xsl:value-of select="$current_fn_number_text"/>
6074
6369
  </fo:basic-link>
6075
6370
  </fo:inline>
6076
6371
  <fo:footnote-body>
6077
6372
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6078
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6079
- <xsl:value-of select="$number"/>
6080
-
6373
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6374
+ <xsl:value-of select="$current_fn_number_text"/>
6081
6375
  </fo:inline>
6082
6376
  <xsl:apply-templates/>
6083
6377
  </fo:block>
@@ -6318,6 +6612,78 @@
6318
6612
  <!-- processing for admonition/p found in the template for 'p' -->
6319
6613
  <xsl:call-template name="paragraph"/>
6320
6614
 
6615
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6616
+ <xsl:copy>
6617
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6618
+ </xsl:copy>
6619
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6620
+ <xsl:copy>
6621
+ <xsl:copy-of select="@*"/>
6622
+
6623
+ <xsl:variable name="nodes_preface_">
6624
+ <xsl:for-each select="*">
6625
+ <node id="{@id}"/>
6626
+ </xsl:for-each>
6627
+ </xsl:variable>
6628
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6629
+
6630
+ <xsl:for-each select="*">
6631
+ <xsl:sort select="@displayorder" data-type="number"/>
6632
+
6633
+ <!-- process Section's title -->
6634
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6635
+ <xsl:if test="$preceding-sibling_id != ''">
6636
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6637
+ </xsl:if>
6638
+
6639
+ <xsl:choose>
6640
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6641
+ <xsl:otherwise>
6642
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6643
+ </xsl:otherwise>
6644
+ </xsl:choose>
6645
+
6646
+ </xsl:for-each>
6647
+ </xsl:copy>
6648
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
6649
+ <xsl:copy>
6650
+ <xsl:copy-of select="@*"/>
6651
+
6652
+ <xsl:variable name="nodes_sections_">
6653
+ <xsl:for-each select="*">
6654
+ <node id="{@id}"/>
6655
+ </xsl:for-each>
6656
+ </xsl:variable>
6657
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
6658
+
6659
+ <!-- move section 'Normative references' inside 'sections' -->
6660
+ <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']]">
6661
+ <xsl:sort select="@displayorder" data-type="number"/>
6662
+
6663
+ <!-- process Section's title -->
6664
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6665
+ <xsl:if test="$preceding-sibling_id != ''">
6666
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6667
+ </xsl:if>
6668
+
6669
+ <xsl:choose>
6670
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6671
+ <xsl:otherwise>
6672
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6673
+ </xsl:otherwise>
6674
+ </xsl:choose>
6675
+
6676
+ </xsl:for-each>
6677
+ </xsl:copy>
6678
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
6679
+ <xsl:copy>
6680
+ <xsl:copy-of select="@*"/>
6681
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
6682
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
6683
+ <xsl:sort select="@displayorder" data-type="number"/>
6684
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6685
+ </xsl:for-each>
6686
+ </xsl:copy>
6321
6687
  </xsl:template><xsl:template name="convertDate">
6322
6688
  <xsl:param name="date"/>
6323
6689
  <xsl:param name="format" select="'short'"/>
@@ -6562,22 +6928,25 @@
6562
6928
  <xsl:param name="pText" select="."/>
6563
6929
  <xsl:param name="sep" select="','"/>
6564
6930
  <xsl:param name="normalize-space" select="'true'"/>
6931
+ <xsl:param name="keep_sep" select="'false'"/>
6565
6932
  <xsl:if test="string-length($pText) &gt;0">
6566
- <item>
6567
- <xsl:choose>
6568
- <xsl:when test="$normalize-space = 'true'">
6569
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6570
- </xsl:when>
6571
- <xsl:otherwise>
6572
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6573
- </xsl:otherwise>
6574
- </xsl:choose>
6575
- </item>
6576
- <xsl:call-template name="split">
6577
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6578
- <xsl:with-param name="sep" select="$sep"/>
6579
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
6580
- </xsl:call-template>
6933
+ <item>
6934
+ <xsl:choose>
6935
+ <xsl:when test="$normalize-space = 'true'">
6936
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6937
+ </xsl:when>
6938
+ <xsl:otherwise>
6939
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6940
+ </xsl:otherwise>
6941
+ </xsl:choose>
6942
+ </item>
6943
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
6944
+ <xsl:call-template name="split">
6945
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6946
+ <xsl:with-param name="sep" select="$sep"/>
6947
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
6948
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
6949
+ </xsl:call-template>
6581
6950
  </xsl:if>
6582
6951
  </xsl:template><xsl:template name="getDocumentId">
6583
6952
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -6768,53 +7137,153 @@
6768
7137
  <xsl:param name="first"/>
6769
7138
  <xsl:if test="$number != ''">
6770
7139
  <xsl:variable name="words">
6771
- <words>
6772
- <word cardinal="1">One-</word>
6773
- <word ordinal="1">First </word>
6774
- <word cardinal="2">Two-</word>
6775
- <word ordinal="2">Second </word>
6776
- <word cardinal="3">Three-</word>
6777
- <word ordinal="3">Third </word>
6778
- <word cardinal="4">Four-</word>
6779
- <word ordinal="4">Fourth </word>
6780
- <word cardinal="5">Five-</word>
6781
- <word ordinal="5">Fifth </word>
6782
- <word cardinal="6">Six-</word>
6783
- <word ordinal="6">Sixth </word>
6784
- <word cardinal="7">Seven-</word>
6785
- <word ordinal="7">Seventh </word>
6786
- <word cardinal="8">Eight-</word>
6787
- <word ordinal="8">Eighth </word>
6788
- <word cardinal="9">Nine-</word>
6789
- <word ordinal="9">Ninth </word>
6790
- <word ordinal="10">Tenth </word>
6791
- <word ordinal="11">Eleventh </word>
6792
- <word ordinal="12">Twelfth </word>
6793
- <word ordinal="13">Thirteenth </word>
6794
- <word ordinal="14">Fourteenth </word>
6795
- <word ordinal="15">Fifteenth </word>
6796
- <word ordinal="16">Sixteenth </word>
6797
- <word ordinal="17">Seventeenth </word>
6798
- <word ordinal="18">Eighteenth </word>
6799
- <word ordinal="19">Nineteenth </word>
6800
- <word cardinal="20">Twenty-</word>
6801
- <word ordinal="20">Twentieth </word>
6802
- <word cardinal="30">Thirty-</word>
6803
- <word ordinal="30">Thirtieth </word>
6804
- <word cardinal="40">Forty-</word>
6805
- <word ordinal="40">Fortieth </word>
6806
- <word cardinal="50">Fifty-</word>
6807
- <word ordinal="50">Fiftieth </word>
6808
- <word cardinal="60">Sixty-</word>
6809
- <word ordinal="60">Sixtieth </word>
6810
- <word cardinal="70">Seventy-</word>
6811
- <word ordinal="70">Seventieth </word>
6812
- <word cardinal="80">Eighty-</word>
6813
- <word ordinal="80">Eightieth </word>
6814
- <word cardinal="90">Ninety-</word>
6815
- <word ordinal="90">Ninetieth </word>
6816
- <word cardinal="100">Hundred-</word>
6817
- <word ordinal="100">Hundredth </word>
7140
+ <words>
7141
+ <xsl:choose>
7142
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7143
+ <word cardinal="1">Une-</word>
7144
+ <word ordinal="1">Première </word>
7145
+ <word cardinal="2">Deux-</word>
7146
+ <word ordinal="2">Seconde </word>
7147
+ <word cardinal="3">Trois-</word>
7148
+ <word ordinal="3">Tierce </word>
7149
+ <word cardinal="4">Quatre-</word>
7150
+ <word ordinal="4">Quatrième </word>
7151
+ <word cardinal="5">Cinq-</word>
7152
+ <word ordinal="5">Cinquième </word>
7153
+ <word cardinal="6">Six-</word>
7154
+ <word ordinal="6">Sixième </word>
7155
+ <word cardinal="7">Sept-</word>
7156
+ <word ordinal="7">Septième </word>
7157
+ <word cardinal="8">Huit-</word>
7158
+ <word ordinal="8">Huitième </word>
7159
+ <word cardinal="9">Neuf-</word>
7160
+ <word ordinal="9">Neuvième </word>
7161
+ <word ordinal="10">Dixième </word>
7162
+ <word ordinal="11">Onzième </word>
7163
+ <word ordinal="12">Douzième </word>
7164
+ <word ordinal="13">Treizième </word>
7165
+ <word ordinal="14">Quatorzième </word>
7166
+ <word ordinal="15">Quinzième </word>
7167
+ <word ordinal="16">Seizième </word>
7168
+ <word ordinal="17">Dix-septième </word>
7169
+ <word ordinal="18">Dix-huitième </word>
7170
+ <word ordinal="19">Dix-neuvième </word>
7171
+ <word cardinal="20">Vingt-</word>
7172
+ <word ordinal="20">Vingtième </word>
7173
+ <word cardinal="30">Trente-</word>
7174
+ <word ordinal="30">Trentième </word>
7175
+ <word cardinal="40">Quarante-</word>
7176
+ <word ordinal="40">Quarantième </word>
7177
+ <word cardinal="50">Cinquante-</word>
7178
+ <word ordinal="50">Cinquantième </word>
7179
+ <word cardinal="60">Soixante-</word>
7180
+ <word ordinal="60">Soixantième </word>
7181
+ <word cardinal="70">Septante-</word>
7182
+ <word ordinal="70">Septantième </word>
7183
+ <word cardinal="80">Huitante-</word>
7184
+ <word ordinal="80">Huitantième </word>
7185
+ <word cardinal="90">Nonante-</word>
7186
+ <word ordinal="90">Nonantième </word>
7187
+ <word cardinal="100">Cent-</word>
7188
+ <word ordinal="100">Centième </word>
7189
+ </xsl:when>
7190
+ <xsl:when test="$lang = 'ru'">
7191
+ <word cardinal="1">Одна-</word>
7192
+ <word ordinal="1">Первое </word>
7193
+ <word cardinal="2">Две-</word>
7194
+ <word ordinal="2">Второе </word>
7195
+ <word cardinal="3">Три-</word>
7196
+ <word ordinal="3">Третье </word>
7197
+ <word cardinal="4">Четыре-</word>
7198
+ <word ordinal="4">Четвертое </word>
7199
+ <word cardinal="5">Пять-</word>
7200
+ <word ordinal="5">Пятое </word>
7201
+ <word cardinal="6">Шесть-</word>
7202
+ <word ordinal="6">Шестое </word>
7203
+ <word cardinal="7">Семь-</word>
7204
+ <word ordinal="7">Седьмое </word>
7205
+ <word cardinal="8">Восемь-</word>
7206
+ <word ordinal="8">Восьмое </word>
7207
+ <word cardinal="9">Девять-</word>
7208
+ <word ordinal="9">Девятое </word>
7209
+ <word ordinal="10">Десятое </word>
7210
+ <word ordinal="11">Одиннадцатое </word>
7211
+ <word ordinal="12">Двенадцатое </word>
7212
+ <word ordinal="13">Тринадцатое </word>
7213
+ <word ordinal="14">Четырнадцатое </word>
7214
+ <word ordinal="15">Пятнадцатое </word>
7215
+ <word ordinal="16">Шестнадцатое </word>
7216
+ <word ordinal="17">Семнадцатое </word>
7217
+ <word ordinal="18">Восемнадцатое </word>
7218
+ <word ordinal="19">Девятнадцатое </word>
7219
+ <word cardinal="20">Двадцать-</word>
7220
+ <word ordinal="20">Двадцатое </word>
7221
+ <word cardinal="30">Тридцать-</word>
7222
+ <word ordinal="30">Тридцатое </word>
7223
+ <word cardinal="40">Сорок-</word>
7224
+ <word ordinal="40">Сороковое </word>
7225
+ <word cardinal="50">Пятьдесят-</word>
7226
+ <word ordinal="50">Пятидесятое </word>
7227
+ <word cardinal="60">Шестьдесят-</word>
7228
+ <word ordinal="60">Шестидесятое </word>
7229
+ <word cardinal="70">Семьдесят-</word>
7230
+ <word ordinal="70">Семидесятое </word>
7231
+ <word cardinal="80">Восемьдесят-</word>
7232
+ <word ordinal="80">Восьмидесятое </word>
7233
+ <word cardinal="90">Девяносто-</word>
7234
+ <word ordinal="90">Девяностое </word>
7235
+ <word cardinal="100">Сто-</word>
7236
+ <word ordinal="100">Сотое </word>
7237
+ </xsl:when>
7238
+ <xsl:otherwise> <!-- default english -->
7239
+ <word cardinal="1">One-</word>
7240
+ <word ordinal="1">First </word>
7241
+ <word cardinal="2">Two-</word>
7242
+ <word ordinal="2">Second </word>
7243
+ <word cardinal="3">Three-</word>
7244
+ <word ordinal="3">Third </word>
7245
+ <word cardinal="4">Four-</word>
7246
+ <word ordinal="4">Fourth </word>
7247
+ <word cardinal="5">Five-</word>
7248
+ <word ordinal="5">Fifth </word>
7249
+ <word cardinal="6">Six-</word>
7250
+ <word ordinal="6">Sixth </word>
7251
+ <word cardinal="7">Seven-</word>
7252
+ <word ordinal="7">Seventh </word>
7253
+ <word cardinal="8">Eight-</word>
7254
+ <word ordinal="8">Eighth </word>
7255
+ <word cardinal="9">Nine-</word>
7256
+ <word ordinal="9">Ninth </word>
7257
+ <word ordinal="10">Tenth </word>
7258
+ <word ordinal="11">Eleventh </word>
7259
+ <word ordinal="12">Twelfth </word>
7260
+ <word ordinal="13">Thirteenth </word>
7261
+ <word ordinal="14">Fourteenth </word>
7262
+ <word ordinal="15">Fifteenth </word>
7263
+ <word ordinal="16">Sixteenth </word>
7264
+ <word ordinal="17">Seventeenth </word>
7265
+ <word ordinal="18">Eighteenth </word>
7266
+ <word ordinal="19">Nineteenth </word>
7267
+ <word cardinal="20">Twenty-</word>
7268
+ <word ordinal="20">Twentieth </word>
7269
+ <word cardinal="30">Thirty-</word>
7270
+ <word ordinal="30">Thirtieth </word>
7271
+ <word cardinal="40">Forty-</word>
7272
+ <word ordinal="40">Fortieth </word>
7273
+ <word cardinal="50">Fifty-</word>
7274
+ <word ordinal="50">Fiftieth </word>
7275
+ <word cardinal="60">Sixty-</word>
7276
+ <word ordinal="60">Sixtieth </word>
7277
+ <word cardinal="70">Seventy-</word>
7278
+ <word ordinal="70">Seventieth </word>
7279
+ <word cardinal="80">Eighty-</word>
7280
+ <word ordinal="80">Eightieth </word>
7281
+ <word cardinal="90">Ninety-</word>
7282
+ <word ordinal="90">Ninetieth </word>
7283
+ <word cardinal="100">Hundred-</word>
7284
+ <word ordinal="100">Hundredth </word>
7285
+ </xsl:otherwise>
7286
+ </xsl:choose>
6818
7287
  </words>
6819
7288
  </xsl:variable>
6820
7289
 
@@ -6888,4 +7357,18 @@
6888
7357
  <xsl:otherwise>_</xsl:otherwise>
6889
7358
  </xsl:choose>
6890
7359
  </xsl:attribute>
7360
+ </xsl:template><xsl:template name="substring-after-last">
7361
+ <xsl:param name="value"/>
7362
+ <xsl:param name="delimiter"/>
7363
+ <xsl:choose>
7364
+ <xsl:when test="contains($value, $delimiter)">
7365
+ <xsl:call-template name="substring-after-last">
7366
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7367
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7368
+ </xsl:call-template>
7369
+ </xsl:when>
7370
+ <xsl:otherwise>
7371
+ <xsl:value-of select="$value"/>
7372
+ </xsl:otherwise>
7373
+ </xsl:choose>
6891
7374
  </xsl:template></xsl:stylesheet>