metanorma-iho 0.5.3 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,12 +20,15 @@
20
20
  <item level="1" id="Foreword" display="true">Foreword</item>
21
21
  <item id="term-script" display="false">3.2</item>
22
22
  -->
23
- <xsl:variable name="contents">
23
+ <xsl:variable name="contents_">
24
24
  <contents>
25
25
  <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
26
- <xsl:call-template name="processMainSectionsDefault_Contents"/>
26
+ <xsl:call-template name="processMainSectionsDefault_Contents"/>
27
+
28
+ <xsl:call-template name="processTablesFigures_Contents"/>
27
29
  </contents>
28
30
  </xsl:variable>
31
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
29
32
 
30
33
  <xsl:template match="/">
31
34
 
@@ -212,11 +215,11 @@
212
215
  <xsl:if test="$debug = 'true'">
213
216
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
214
217
  DEBUG
215
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
218
+ contents=<xsl:copy-of select="$contents"/>
216
219
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
217
220
  </xsl:if>
218
221
 
219
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
222
+ <xsl:for-each select="$contents//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
220
223
  <fo:block role="TOCI">
221
224
  <xsl:if test="@level = 1">
222
225
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -256,6 +259,27 @@
256
259
  </fo:block>
257
260
 
258
261
  </xsl:for-each>
262
+
263
+ <!-- List of Tables -->
264
+ <xsl:if test="$contents//tables/table">
265
+ <xsl:call-template name="insertListOf_Title">
266
+ <xsl:with-param name="title" select="$title-list-tables"/>
267
+ </xsl:call-template>
268
+ <xsl:for-each select="$contents//tables/table">
269
+ <xsl:call-template name="insertListOf_Item"/>
270
+ </xsl:for-each>
271
+ </xsl:if>
272
+
273
+ <!-- List of Figures -->
274
+ <xsl:if test="$contents//figures/figure">
275
+ <xsl:call-template name="insertListOf_Title">
276
+ <xsl:with-param name="title" select="$title-list-figures"/>
277
+ </xsl:call-template>
278
+ <xsl:for-each select="$contents//figures/figure">
279
+ <xsl:call-template name="insertListOf_Item"/>
280
+ </xsl:for-each>
281
+ </xsl:if>
282
+
259
283
  </fo:block>
260
284
  </fo:block-container>
261
285
  </fo:block-container>
@@ -345,6 +369,28 @@
345
369
 
346
370
  </xsl:template>
347
371
 
372
+ <xsl:template name="insertListOf_Title">
373
+ <xsl:param name="title"/>
374
+ <fo:block role="TOCI" font-weight="bold" margin-top="6pt" keep-with-next="always">
375
+ <xsl:value-of select="$title"/>
376
+ </fo:block>
377
+ </xsl:template>
378
+
379
+ <xsl:template name="insertListOf_Item">
380
+ <fo:block role="TOCI" text-align-last="justify" margin-left="12mm" text-indent="-12mm">
381
+ <fo:basic-link internal-destination="{@id}">
382
+ <xsl:call-template name="setAltText">
383
+ <xsl:with-param name="value" select="@alt-text"/>
384
+ </xsl:call-template>
385
+ <xsl:apply-templates select="." mode="contents"/>
386
+ <fo:inline keep-together.within-line="always">
387
+ <fo:leader font-size="9pt" font-weight="normal" leader-pattern="dots"/>
388
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
389
+ </fo:inline>
390
+ </fo:basic-link>
391
+ </fo:block>
392
+ </xsl:template>
393
+
348
394
  <!-- ============================= -->
349
395
  <!-- CONTENTS -->
350
396
  <!-- ============================= -->
@@ -749,6 +795,10 @@
749
795
  <xsl:text>Édition </xsl:text>
750
796
  </title-edition>
751
797
 
798
+ <title-edition lang="ru">
799
+ <xsl:text>Издание </xsl:text>
800
+ </title-edition>
801
+
752
802
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
753
803
  <title-toc lang="en">
754
804
 
@@ -765,7 +815,7 @@
765
815
  <xsl:text>Contents</xsl:text>
766
816
 
767
817
  </title-toc>
768
-
818
+
769
819
  <title-descriptors lang="en">Descriptors</title-descriptors>
770
820
 
771
821
  <title-part lang="en">
@@ -777,7 +827,11 @@
777
827
 
778
828
 
779
829
 
780
- </title-part>
830
+ </title-part>
831
+ <title-part lang="ru">
832
+
833
+
834
+ </title-part>
781
835
  <title-part lang="zh">第 # 部分:</title-part>
782
836
 
783
837
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -793,10 +847,35 @@
793
847
 
794
848
  <title-summary lang="en">Summary</title-summary>
795
849
 
850
+ <title-continued lang="ru">(продолжение)</title-continued>
796
851
  <title-continued lang="en">(continued)</title-continued>
797
852
  <title-continued lang="fr">(continué)</title-continued>
798
853
 
799
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
854
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
855
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
856
+ <xsl:value-of select="$toc_table_title"/>
857
+ <xsl:if test="normalize-space($toc_table_title) = ''">
858
+ <xsl:call-template name="getTitle">
859
+ <xsl:with-param name="name" select="'title-list-tables'"/>
860
+ </xsl:call-template>
861
+ </xsl:if>
862
+ </xsl:variable><xsl:variable name="title-list-figures">
863
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
864
+ <xsl:value-of select="$toc_figure_title"/>
865
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
866
+ <xsl:call-template name="getTitle">
867
+ <xsl:with-param name="name" select="'title-list-figures'"/>
868
+ </xsl:call-template>
869
+ </xsl:if>
870
+ </xsl:variable><xsl:variable name="title-list-recommendations">
871
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
872
+ <xsl:value-of select="$toc_requirement_title"/>
873
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
874
+ <xsl:call-template name="getTitle">
875
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
876
+ </xsl:call-template>
877
+ </xsl:if>
878
+ </xsl:variable><xsl:variable name="bibdata">
800
879
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
801
880
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
802
881
  </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">
@@ -1539,13 +1618,19 @@
1539
1618
  </xsl:attribute-set><xsl:variable name="color-added-text">
1540
1619
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1541
1620
  </xsl:variable><xsl:attribute-set name="add-style">
1542
- <xsl:attribute name="color">red</xsl:attribute>
1543
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
1544
- <!-- <xsl:attribute name="color">black</xsl:attribute>
1545
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1546
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
1547
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1548
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1621
+
1622
+ <xsl:attribute name="color">red</xsl:attribute>
1623
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1624
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1625
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1626
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1627
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1628
+
1629
+ </xsl:attribute-set><xsl:variable name="add-style">
1630
+ <add-style xsl:use-attribute-sets="add-style"/>
1631
+ </xsl:variable><xsl:template name="append_add-style">
1632
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1633
+ </xsl:template><xsl:variable name="color-deleted-text">
1549
1634
  <xsl:text>red</xsl:text>
1550
1635
  </xsl:variable><xsl:attribute-set name="del-style">
1551
1636
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -1979,14 +2064,42 @@
1979
2064
 
1980
2065
 
1981
2066
  </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">
2067
+ <xsl:variable name="nodes_preface_">
2068
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2069
+ <node id="{@id}"/>
2070
+ </xsl:for-each>
2071
+ </xsl:variable>
2072
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2073
+
1982
2074
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1983
2075
  <xsl:sort select="@displayorder" data-type="number"/>
2076
+
2077
+ <!-- process Section's title -->
2078
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2079
+ <xsl:if test="$preceding-sibling_id != ''">
2080
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2081
+ </xsl:if>
2082
+
1984
2083
  <xsl:apply-templates select="." mode="contents"/>
1985
2084
  </xsl:for-each>
1986
2085
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
1987
2086
 
2087
+ <xsl:variable name="nodes_sections_">
2088
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
2089
+ <node id="{@id}"/>
2090
+ </xsl:for-each>
2091
+ </xsl:variable>
2092
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
2093
+
1988
2094
  <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']]">
1989
2095
  <xsl:sort select="@displayorder" data-type="number"/>
2096
+
2097
+ <!-- process Section's title -->
2098
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2099
+ <xsl:if test="$preceding-sibling_id != ''">
2100
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2101
+ </xsl:if>
2102
+
1990
2103
  <xsl:apply-templates select="." mode="contents"/>
1991
2104
  </xsl:for-each>
1992
2105
 
@@ -1999,6 +2112,30 @@
1999
2112
  <xsl:sort select="@displayorder" data-type="number"/>
2000
2113
  <xsl:apply-templates select="." mode="contents"/>
2001
2114
  </xsl:for-each>
2115
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2116
+ <xsl:param name="always"/>
2117
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2118
+ <xsl:call-template name="processTables_Contents"/>
2119
+ </xsl:if>
2120
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2121
+ <xsl:call-template name="processFigures_Contents"/>
2122
+ </xsl:if>
2123
+ </xsl:template><xsl:template name="processTables_Contents">
2124
+ <tables>
2125
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2126
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2127
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2128
+ </table>
2129
+ </xsl:for-each>
2130
+ </tables>
2131
+ </xsl:template><xsl:template name="processFigures_Contents">
2132
+ <figures>
2133
+ <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) != '']">
2134
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2135
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2136
+ </figure>
2137
+ </xsl:for-each>
2138
+ </figures>
2002
2139
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2003
2140
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2004
2141
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2125,7 +2262,7 @@
2125
2262
  </xsl:call-template>
2126
2263
  </xsl:if>
2127
2264
  </xsl:variable>
2128
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2265
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2129
2266
 
2130
2267
 
2131
2268
  <xsl:variable name="margin-side">
@@ -2385,7 +2522,7 @@
2385
2522
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2386
2523
  <!-- 2009 thinspace -->
2387
2524
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2388
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2525
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2389
2526
  </xsl:call-template>
2390
2527
  </xsl:variable>
2391
2528
  <xsl:variable name="max_length">
@@ -2771,37 +2908,7 @@
2771
2908
 
2772
2909
  <!-- list of footnotes to calculate actual footnotes number -->
2773
2910
  <xsl:variable name="p_fn_">
2774
- <xsl:choose>
2775
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2776
- <fn gen_id="{generate-id(.)}">
2777
- <xsl:copy-of select="@*"/>
2778
- <xsl:copy-of select="node()"/>
2779
- </fn>
2780
- </xsl:when>
2781
- <xsl:otherwise>
2782
- <!-- itetation for:
2783
- footnotes in bibdata/title
2784
- footnotes in bibliography
2785
- footnotes in document's body (except table's head/body/foot and figure text)
2786
- -->
2787
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2788
- <fn gen_id="{generate-id(.)}">
2789
- <xsl:copy-of select="@*"/>
2790
- <xsl:copy-of select="node()"/>
2791
- </fn>
2792
- </xsl:for-each>
2793
- <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']/*">
2794
- <xsl:sort select="@displayorder" data-type="number"/>
2795
- <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])]">
2796
- <!-- copy unique fn -->
2797
- <fn gen_id="{generate-id(.)}">
2798
- <xsl:copy-of select="@*"/>
2799
- <xsl:copy-of select="node()"/>
2800
- </fn>
2801
- </xsl:for-each>
2802
- </xsl:for-each>
2803
- </xsl:otherwise>
2804
- </xsl:choose>
2911
+ <xsl:call-template name="get_fn_list"/>
2805
2912
  </xsl:variable>
2806
2913
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2807
2914
 
@@ -2862,6 +2969,38 @@
2862
2969
  <xsl:copy-of select="$footnote_inline"/>
2863
2970
  </xsl:otherwise>
2864
2971
  </xsl:choose>
2972
+ </xsl:template><xsl:template name="get_fn_list">
2973
+ <xsl:choose>
2974
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2975
+ <fn gen_id="{generate-id(.)}">
2976
+ <xsl:copy-of select="@*"/>
2977
+ <xsl:copy-of select="node()"/>
2978
+ </fn>
2979
+ </xsl:when>
2980
+ <xsl:otherwise>
2981
+ <!-- itetation for:
2982
+ footnotes in bibdata/title
2983
+ footnotes in bibliography
2984
+ footnotes in document's body (except table's head/body/foot and figure text)
2985
+ -->
2986
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2987
+ <fn gen_id="{generate-id(.)}">
2988
+ <xsl:copy-of select="@*"/>
2989
+ <xsl:copy-of select="node()"/>
2990
+ </fn>
2991
+ </xsl:for-each>
2992
+ <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']/*">
2993
+ <xsl:sort select="@displayorder" data-type="number"/>
2994
+ <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])]">
2995
+ <!-- copy unique fn -->
2996
+ <fn gen_id="{generate-id(.)}">
2997
+ <xsl:copy-of select="@*"/>
2998
+ <xsl:copy-of select="node()"/>
2999
+ </fn>
3000
+ </xsl:for-each>
3001
+ </xsl:for-each>
3002
+ </xsl:otherwise>
3003
+ </xsl:choose>
2865
3004
  </xsl:template><xsl:template name="table_fn_display">
2866
3005
  <xsl:variable name="references">
2867
3006
 
@@ -3033,7 +3172,7 @@
3033
3172
  </fo:inline>
3034
3173
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3035
3174
  <fo:inline><xsl:value-of select="."/></fo:inline>
3036
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3175
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3037
3176
  <fo:inline>
3038
3177
  <xsl:apply-templates/>
3039
3178
  </fo:inline>
@@ -4013,6 +4152,9 @@
4013
4152
  </fo:inline>
4014
4153
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
4015
4154
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4155
+ <xsl:if test="parent::*[local-name() = 'add']">
4156
+ <xsl:call-template name="append_add-style"/>
4157
+ </xsl:if>
4016
4158
  <xsl:apply-templates/>
4017
4159
  </fo:basic-link>
4018
4160
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -4114,6 +4256,13 @@
4114
4256
 
4115
4257
 
4116
4258
 
4259
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4260
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4261
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4262
+ <xsl:call-template name="append_add-style"/>
4263
+ </xsl:if>
4264
+
4265
+
4117
4266
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
4118
4267
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
4119
4268
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -4152,6 +4301,12 @@
4152
4301
 
4153
4302
 
4154
4303
 
4304
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4305
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4306
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4307
+ <xsl:call-template name="append_add-style"/>
4308
+ </xsl:if>
4309
+
4155
4310
  <xsl:apply-templates select="*[local-name() = 'name']"/>
4156
4311
 
4157
4312
  </fo:inline>
@@ -4201,6 +4356,7 @@
4201
4356
  </fo:block>
4202
4357
  </xsl:template><xsl:template match="*[local-name() = 'term']">
4203
4358
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4359
+
4204
4360
 
4205
4361
 
4206
4362
 
@@ -4637,7 +4793,11 @@
4637
4793
  <xsl:value-of select="."/>
4638
4794
  </xsl:template><xsl:template match="node()" mode="contents">
4639
4795
  <xsl:apply-templates mode="contents"/>
4640
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4796
+ </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">
4797
+ <xsl:call-template name="contents_section-title"/>
4798
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4799
+ <xsl:call-template name="contents_section-title"/>
4800
+ </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">
4641
4801
  <xsl:variable name="level">
4642
4802
  <xsl:call-template name="getLevel">
4643
4803
  <xsl:with-param name="depth" select="@depth"/>
@@ -4706,13 +4866,14 @@
4706
4866
  <xsl:apply-templates mode="bookmarks"/>
4707
4867
  </xsl:template><xsl:template name="addBookmarks">
4708
4868
  <xsl:param name="contents"/>
4709
- <xsl:if test="xalan:nodeset($contents)//item">
4869
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4870
+ <xsl:if test="$contents_nodes//item">
4710
4871
  <fo:bookmark-tree>
4711
4872
  <xsl:choose>
4712
- <xsl:when test="xalan:nodeset($contents)/doc">
4873
+ <xsl:when test="$contents_nodes/doc">
4713
4874
  <xsl:choose>
4714
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4715
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4875
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4876
+ <xsl:for-each select="$contents_nodes/doc">
4716
4877
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4717
4878
  <xsl:if test="@bundle = 'true'">
4718
4879
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4763,7 +4924,7 @@
4763
4924
  </xsl:for-each>
4764
4925
  </xsl:when>
4765
4926
  <xsl:otherwise>
4766
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4927
+ <xsl:for-each select="$contents_nodes/doc">
4767
4928
 
4768
4929
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4769
4930
 
@@ -4781,25 +4942,36 @@
4781
4942
  </xsl:choose>
4782
4943
  </xsl:when>
4783
4944
  <xsl:otherwise>
4784
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4945
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4946
+
4947
+ <xsl:call-template name="insertFigureBookmarks">
4948
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4949
+ </xsl:call-template>
4950
+
4951
+ <xsl:call-template name="insertTableBookmarks">
4952
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4953
+ <xsl:with-param name="lang" select="@lang"/>
4954
+ </xsl:call-template>
4955
+
4785
4956
  </xsl:otherwise>
4786
4957
  </xsl:choose>
4787
4958
 
4959
+
4788
4960
 
4789
4961
 
4790
4962
 
4791
4963
 
4792
-
4793
-
4964
+
4794
4965
 
4795
4966
  </fo:bookmark-tree>
4796
4967
  </xsl:if>
4797
4968
  </xsl:template><xsl:template name="insertFigureBookmarks">
4798
4969
  <xsl:param name="contents"/>
4799
- <xsl:if test="xalan:nodeset($contents)/figure">
4800
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
4970
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4971
+ <xsl:if test="$contents_nodes/figure">
4972
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4801
4973
  <fo:bookmark-title>Figures</fo:bookmark-title>
4802
- <xsl:for-each select="xalan:nodeset($contents)/figure">
4974
+ <xsl:for-each select="$contents_nodes/figure">
4803
4975
  <fo:bookmark internal-destination="{@id}">
4804
4976
  <fo:bookmark-title>
4805
4977
  <xsl:value-of select="normalize-space(title)"/>
@@ -4808,18 +4980,40 @@
4808
4980
  </xsl:for-each>
4809
4981
  </fo:bookmark>
4810
4982
  </xsl:if>
4983
+
4984
+
4985
+ <xsl:if test="$contents_nodes//figures/figure">
4986
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4987
+
4988
+
4989
+
4990
+ <xsl:variable name="bookmark-title">
4991
+
4992
+ <xsl:value-of select="$title-list-figures"/>
4993
+
4994
+ </xsl:variable>
4995
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
4996
+ <xsl:for-each select="$contents_nodes//figures/figure">
4997
+ <fo:bookmark internal-destination="{@id}">
4998
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4999
+ </fo:bookmark>
5000
+ </xsl:for-each>
5001
+ </fo:bookmark>
5002
+ </xsl:if>
5003
+
4811
5004
  </xsl:template><xsl:template name="insertTableBookmarks">
4812
5005
  <xsl:param name="contents"/>
4813
5006
  <xsl:param name="lang"/>
4814
- <xsl:if test="xalan:nodeset($contents)/table">
4815
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5007
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5008
+ <xsl:if test="$contents_nodes/table">
5009
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4816
5010
  <fo:bookmark-title>
4817
5011
  <xsl:choose>
4818
5012
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4819
5013
  <xsl:otherwise>Tables</xsl:otherwise>
4820
5014
  </xsl:choose>
4821
5015
  </fo:bookmark-title>
4822
- <xsl:for-each select="xalan:nodeset($contents)/table">
5016
+ <xsl:for-each select="$contents_nodes/table">
4823
5017
  <fo:bookmark internal-destination="{@id}">
4824
5018
  <fo:bookmark-title>
4825
5019
  <xsl:value-of select="normalize-space(title)"/>
@@ -4828,6 +5022,29 @@
4828
5022
  </xsl:for-each>
4829
5023
  </fo:bookmark>
4830
5024
  </xsl:if>
5025
+
5026
+
5027
+ <xsl:if test="$contents_nodes//tables/table">
5028
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5029
+
5030
+
5031
+
5032
+ <xsl:variable name="bookmark-title">
5033
+
5034
+ <xsl:value-of select="$title-list-tables"/>
5035
+
5036
+ </xsl:variable>
5037
+
5038
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
5039
+
5040
+ <xsl:for-each select="$contents_nodes//tables/table">
5041
+ <fo:bookmark internal-destination="{@id}">
5042
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5043
+ </fo:bookmark>
5044
+ </xsl:for-each>
5045
+ </fo:bookmark>
5046
+ </xsl:if>
5047
+
4831
5048
  </xsl:template><xsl:template name="getLangVersion">
4832
5049
  <xsl:param name="lang"/>
4833
5050
  <xsl:param name="doctype" select="''"/>
@@ -5052,7 +5269,51 @@
5052
5269
  <xsl:with-param name="text" select="$text_step1"/>
5053
5270
  </xsl:call-template>
5054
5271
  </xsl:variable>
5055
- <xsl:value-of select="$text_step2"/>
5272
+
5273
+ <!-- <xsl:value-of select="$text_step2"/> -->
5274
+
5275
+ <!-- add zero-width space after space -->
5276
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5277
+
5278
+ <!-- split text by zero-width space -->
5279
+ <xsl:variable name="text_step4">
5280
+ <xsl:call-template name="split">
5281
+ <xsl:with-param name="pText" select="$text_step3"/>
5282
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5283
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5284
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5285
+ </xsl:call-template>
5286
+ </xsl:variable>
5287
+
5288
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5289
+ <xsl:choose>
5290
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5291
+ <xsl:call-template name="interspers">
5292
+ <xsl:with-param name="str" select="."/>
5293
+ </xsl:call-template>
5294
+ </xsl:when>
5295
+ <xsl:otherwise>
5296
+ <xsl:value-of select="."/>
5297
+ </xsl:otherwise>
5298
+ </xsl:choose>
5299
+ </xsl:for-each>
5300
+
5301
+ </xsl:template><xsl:template name="interspers">
5302
+ <xsl:param name="str"/>
5303
+ <xsl:param name="char" select="$zero_width_space"/>
5304
+ <xsl:if test="$str != ''">
5305
+ <xsl:value-of select="substring($str, 1, 1)"/>
5306
+
5307
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5308
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5309
+ <xsl:value-of select="$char"/>
5310
+ </xsl:if>
5311
+
5312
+ <xsl:call-template name="interspers">
5313
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5314
+ <xsl:with-param name="char" select="$char"/>
5315
+ </xsl:call-template>
5316
+ </xsl:if>
5056
5317
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5057
5318
  <xsl:apply-templates mode="syntax_highlight"/>
5058
5319
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5484,6 +5745,8 @@
5484
5745
  </xsl:otherwise>
5485
5746
  </xsl:choose> -->
5486
5747
  </fo:block>
5748
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5749
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5487
5750
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5488
5751
  <xsl:if test="normalize-space() != ''">
5489
5752
  <xsl:value-of select="."/>
@@ -5558,26 +5821,24 @@
5558
5821
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5559
5822
  <xsl:text>— </xsl:text>
5560
5823
  <xsl:apply-templates/>
5561
- </xsl:template><xsl:variable name="bibitem_hidden_">
5824
+ </xsl:template><xsl:variable name="bibitems_">
5825
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5826
+ <xsl:copy-of select="."/>
5827
+ </xsl:for-each>
5828
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5562
5829
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5563
5830
  <xsl:copy-of select="."/>
5564
5831
  </xsl:for-each>
5565
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5832
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5566
5833
  <xsl:copy-of select="."/>
5567
5834
  </xsl:for-each>
5568
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5569
-
5570
- <xsl:variable name="bibitemid">
5571
- <xsl:choose>
5572
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5573
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5574
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5575
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5576
- </xsl:choose>
5577
- </xsl:variable>
5578
-
5835
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5836
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5837
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5838
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5579
5839
  <xsl:choose>
5580
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5840
+ <!-- <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) -->
5841
+ <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) -->
5581
5842
  <fo:inline xsl:use-attribute-sets="eref-style">
5582
5843
  <xsl:if test="@type = 'footnote'">
5583
5844
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5591,8 +5852,8 @@
5591
5852
  <xsl:variable name="text" select="normalize-space()"/>
5592
5853
 
5593
5854
 
5594
-
5595
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5855
+
5856
+ <fo:basic-link fox:alt-text="{@citeas}">
5596
5857
  <xsl:if test="normalize-space(@citeas) = ''">
5597
5858
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5598
5859
  </xsl:if>
@@ -5605,14 +5866,21 @@
5605
5866
 
5606
5867
  </xsl:if>
5607
5868
 
5608
-
5869
+ <xsl:choose>
5870
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5871
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5872
+ </xsl:when>
5873
+ <xsl:otherwise>
5874
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5875
+ </xsl:otherwise>
5876
+ </xsl:choose>
5609
5877
 
5610
5878
  <xsl:apply-templates/>
5611
5879
  </fo:basic-link>
5612
-
5880
+
5613
5881
  </fo:inline>
5614
5882
  </xsl:when>
5615
- <xsl:otherwise>
5883
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5616
5884
  <fo:inline><xsl:apply-templates/></fo:inline>
5617
5885
  </xsl:otherwise>
5618
5886
  </xsl:choose>
@@ -5942,7 +6210,7 @@
5942
6210
 
5943
6211
 
5944
6212
 
5945
-
6213
+
5946
6214
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
5947
6215
  </fo:list-block>
5948
6216
  <!-- <xsl:for-each select="./iho:note">
@@ -5960,6 +6228,11 @@
5960
6228
 
5961
6229
 
5962
6230
 
6231
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6232
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6233
+ <xsl:call-template name="append_add-style"/>
6234
+ </xsl:if>
6235
+
5963
6236
  <xsl:call-template name="getListItemFormat"/>
5964
6237
  </fo:block>
5965
6238
  </fo:list-item-label>
@@ -6400,27 +6673,47 @@
6400
6673
  <xsl:apply-templates/>
6401
6674
  </fo:inline>
6402
6675
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6676
+
6677
+ <!-- list of footnotes to calculate actual footnotes number -->
6678
+ <xsl:variable name="p_fn_">
6679
+ <xsl:call-template name="get_fn_list"/>
6680
+ </xsl:variable>
6681
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6682
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6683
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6684
+ <!-- fn sequence number in document -->
6685
+ <xsl:variable name="current_fn_number">
6686
+ <xsl:choose>
6687
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6688
+ <xsl:otherwise>
6689
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6690
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6691
+ </xsl:otherwise>
6692
+ </xsl:choose>
6693
+ </xsl:variable>
6403
6694
  <fo:footnote>
6404
6695
  <xsl:variable name="number">
6405
6696
 
6406
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6697
+ <xsl:value-of select="$current_fn_number"/>
6407
6698
 
6408
6699
  </xsl:variable>
6409
- <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6410
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6411
- <xsl:value-of select="$number"/>
6412
-
6700
+
6701
+ <xsl:variable name="current_fn_number_text">
6702
+ <xsl:value-of select="$number"/>
6703
+
6413
6704
  <xsl:text>)</xsl:text>
6414
6705
 
6706
+ </xsl:variable>
6707
+
6708
+ <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6709
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6710
+ <xsl:value-of select="$current_fn_number_text"/>
6415
6711
  </fo:basic-link>
6416
6712
  </fo:inline>
6417
6713
  <fo:footnote-body>
6418
6714
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6419
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6420
- <xsl:value-of select="$number"/>
6421
-
6422
- <xsl:text>)</xsl:text>
6423
-
6715
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6716
+ <xsl:value-of select="$current_fn_number_text"/>
6424
6717
  </fo:inline>
6425
6718
  <xsl:apply-templates/>
6426
6719
  </fo:block>
@@ -6661,6 +6954,78 @@
6661
6954
  <!-- processing for admonition/p found in the template for 'p' -->
6662
6955
  <xsl:call-template name="paragraph"/>
6663
6956
 
6957
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6958
+ <xsl:copy>
6959
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6960
+ </xsl:copy>
6961
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6962
+ <xsl:copy>
6963
+ <xsl:copy-of select="@*"/>
6964
+
6965
+ <xsl:variable name="nodes_preface_">
6966
+ <xsl:for-each select="*">
6967
+ <node id="{@id}"/>
6968
+ </xsl:for-each>
6969
+ </xsl:variable>
6970
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6971
+
6972
+ <xsl:for-each select="*">
6973
+ <xsl:sort select="@displayorder" data-type="number"/>
6974
+
6975
+ <!-- process Section's title -->
6976
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6977
+ <xsl:if test="$preceding-sibling_id != ''">
6978
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6979
+ </xsl:if>
6980
+
6981
+ <xsl:choose>
6982
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6983
+ <xsl:otherwise>
6984
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6985
+ </xsl:otherwise>
6986
+ </xsl:choose>
6987
+
6988
+ </xsl:for-each>
6989
+ </xsl:copy>
6990
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
6991
+ <xsl:copy>
6992
+ <xsl:copy-of select="@*"/>
6993
+
6994
+ <xsl:variable name="nodes_sections_">
6995
+ <xsl:for-each select="*">
6996
+ <node id="{@id}"/>
6997
+ </xsl:for-each>
6998
+ </xsl:variable>
6999
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7000
+
7001
+ <!-- move section 'Normative references' inside 'sections' -->
7002
+ <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']]">
7003
+ <xsl:sort select="@displayorder" data-type="number"/>
7004
+
7005
+ <!-- process Section's title -->
7006
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7007
+ <xsl:if test="$preceding-sibling_id != ''">
7008
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7009
+ </xsl:if>
7010
+
7011
+ <xsl:choose>
7012
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7013
+ <xsl:otherwise>
7014
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7015
+ </xsl:otherwise>
7016
+ </xsl:choose>
7017
+
7018
+ </xsl:for-each>
7019
+ </xsl:copy>
7020
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7021
+ <xsl:copy>
7022
+ <xsl:copy-of select="@*"/>
7023
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7024
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7025
+ <xsl:sort select="@displayorder" data-type="number"/>
7026
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7027
+ </xsl:for-each>
7028
+ </xsl:copy>
6664
7029
  </xsl:template><xsl:template name="convertDate">
6665
7030
  <xsl:param name="date"/>
6666
7031
  <xsl:param name="format" select="'short'"/>
@@ -6905,22 +7270,25 @@
6905
7270
  <xsl:param name="pText" select="."/>
6906
7271
  <xsl:param name="sep" select="','"/>
6907
7272
  <xsl:param name="normalize-space" select="'true'"/>
7273
+ <xsl:param name="keep_sep" select="'false'"/>
6908
7274
  <xsl:if test="string-length($pText) &gt;0">
6909
- <item>
6910
- <xsl:choose>
6911
- <xsl:when test="$normalize-space = 'true'">
6912
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6913
- </xsl:when>
6914
- <xsl:otherwise>
6915
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6916
- </xsl:otherwise>
6917
- </xsl:choose>
6918
- </item>
6919
- <xsl:call-template name="split">
6920
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6921
- <xsl:with-param name="sep" select="$sep"/>
6922
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
6923
- </xsl:call-template>
7275
+ <item>
7276
+ <xsl:choose>
7277
+ <xsl:when test="$normalize-space = 'true'">
7278
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7279
+ </xsl:when>
7280
+ <xsl:otherwise>
7281
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7282
+ </xsl:otherwise>
7283
+ </xsl:choose>
7284
+ </item>
7285
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7286
+ <xsl:call-template name="split">
7287
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7288
+ <xsl:with-param name="sep" select="$sep"/>
7289
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7290
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7291
+ </xsl:call-template>
6924
7292
  </xsl:if>
6925
7293
  </xsl:template><xsl:template name="getDocumentId">
6926
7294
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -7111,53 +7479,153 @@
7111
7479
  <xsl:param name="first"/>
7112
7480
  <xsl:if test="$number != ''">
7113
7481
  <xsl:variable name="words">
7114
- <words>
7115
- <word cardinal="1">One-</word>
7116
- <word ordinal="1">First </word>
7117
- <word cardinal="2">Two-</word>
7118
- <word ordinal="2">Second </word>
7119
- <word cardinal="3">Three-</word>
7120
- <word ordinal="3">Third </word>
7121
- <word cardinal="4">Four-</word>
7122
- <word ordinal="4">Fourth </word>
7123
- <word cardinal="5">Five-</word>
7124
- <word ordinal="5">Fifth </word>
7125
- <word cardinal="6">Six-</word>
7126
- <word ordinal="6">Sixth </word>
7127
- <word cardinal="7">Seven-</word>
7128
- <word ordinal="7">Seventh </word>
7129
- <word cardinal="8">Eight-</word>
7130
- <word ordinal="8">Eighth </word>
7131
- <word cardinal="9">Nine-</word>
7132
- <word ordinal="9">Ninth </word>
7133
- <word ordinal="10">Tenth </word>
7134
- <word ordinal="11">Eleventh </word>
7135
- <word ordinal="12">Twelfth </word>
7136
- <word ordinal="13">Thirteenth </word>
7137
- <word ordinal="14">Fourteenth </word>
7138
- <word ordinal="15">Fifteenth </word>
7139
- <word ordinal="16">Sixteenth </word>
7140
- <word ordinal="17">Seventeenth </word>
7141
- <word ordinal="18">Eighteenth </word>
7142
- <word ordinal="19">Nineteenth </word>
7143
- <word cardinal="20">Twenty-</word>
7144
- <word ordinal="20">Twentieth </word>
7145
- <word cardinal="30">Thirty-</word>
7146
- <word ordinal="30">Thirtieth </word>
7147
- <word cardinal="40">Forty-</word>
7148
- <word ordinal="40">Fortieth </word>
7149
- <word cardinal="50">Fifty-</word>
7150
- <word ordinal="50">Fiftieth </word>
7151
- <word cardinal="60">Sixty-</word>
7152
- <word ordinal="60">Sixtieth </word>
7153
- <word cardinal="70">Seventy-</word>
7154
- <word ordinal="70">Seventieth </word>
7155
- <word cardinal="80">Eighty-</word>
7156
- <word ordinal="80">Eightieth </word>
7157
- <word cardinal="90">Ninety-</word>
7158
- <word ordinal="90">Ninetieth </word>
7159
- <word cardinal="100">Hundred-</word>
7160
- <word ordinal="100">Hundredth </word>
7482
+ <words>
7483
+ <xsl:choose>
7484
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7485
+ <word cardinal="1">Une-</word>
7486
+ <word ordinal="1">Première </word>
7487
+ <word cardinal="2">Deux-</word>
7488
+ <word ordinal="2">Seconde </word>
7489
+ <word cardinal="3">Trois-</word>
7490
+ <word ordinal="3">Tierce </word>
7491
+ <word cardinal="4">Quatre-</word>
7492
+ <word ordinal="4">Quatrième </word>
7493
+ <word cardinal="5">Cinq-</word>
7494
+ <word ordinal="5">Cinquième </word>
7495
+ <word cardinal="6">Six-</word>
7496
+ <word ordinal="6">Sixième </word>
7497
+ <word cardinal="7">Sept-</word>
7498
+ <word ordinal="7">Septième </word>
7499
+ <word cardinal="8">Huit-</word>
7500
+ <word ordinal="8">Huitième </word>
7501
+ <word cardinal="9">Neuf-</word>
7502
+ <word ordinal="9">Neuvième </word>
7503
+ <word ordinal="10">Dixième </word>
7504
+ <word ordinal="11">Onzième </word>
7505
+ <word ordinal="12">Douzième </word>
7506
+ <word ordinal="13">Treizième </word>
7507
+ <word ordinal="14">Quatorzième </word>
7508
+ <word ordinal="15">Quinzième </word>
7509
+ <word ordinal="16">Seizième </word>
7510
+ <word ordinal="17">Dix-septième </word>
7511
+ <word ordinal="18">Dix-huitième </word>
7512
+ <word ordinal="19">Dix-neuvième </word>
7513
+ <word cardinal="20">Vingt-</word>
7514
+ <word ordinal="20">Vingtième </word>
7515
+ <word cardinal="30">Trente-</word>
7516
+ <word ordinal="30">Trentième </word>
7517
+ <word cardinal="40">Quarante-</word>
7518
+ <word ordinal="40">Quarantième </word>
7519
+ <word cardinal="50">Cinquante-</word>
7520
+ <word ordinal="50">Cinquantième </word>
7521
+ <word cardinal="60">Soixante-</word>
7522
+ <word ordinal="60">Soixantième </word>
7523
+ <word cardinal="70">Septante-</word>
7524
+ <word ordinal="70">Septantième </word>
7525
+ <word cardinal="80">Huitante-</word>
7526
+ <word ordinal="80">Huitantième </word>
7527
+ <word cardinal="90">Nonante-</word>
7528
+ <word ordinal="90">Nonantième </word>
7529
+ <word cardinal="100">Cent-</word>
7530
+ <word ordinal="100">Centième </word>
7531
+ </xsl:when>
7532
+ <xsl:when test="$lang = 'ru'">
7533
+ <word cardinal="1">Одна-</word>
7534
+ <word ordinal="1">Первое </word>
7535
+ <word cardinal="2">Две-</word>
7536
+ <word ordinal="2">Второе </word>
7537
+ <word cardinal="3">Три-</word>
7538
+ <word ordinal="3">Третье </word>
7539
+ <word cardinal="4">Четыре-</word>
7540
+ <word ordinal="4">Четвертое </word>
7541
+ <word cardinal="5">Пять-</word>
7542
+ <word ordinal="5">Пятое </word>
7543
+ <word cardinal="6">Шесть-</word>
7544
+ <word ordinal="6">Шестое </word>
7545
+ <word cardinal="7">Семь-</word>
7546
+ <word ordinal="7">Седьмое </word>
7547
+ <word cardinal="8">Восемь-</word>
7548
+ <word ordinal="8">Восьмое </word>
7549
+ <word cardinal="9">Девять-</word>
7550
+ <word ordinal="9">Девятое </word>
7551
+ <word ordinal="10">Десятое </word>
7552
+ <word ordinal="11">Одиннадцатое </word>
7553
+ <word ordinal="12">Двенадцатое </word>
7554
+ <word ordinal="13">Тринадцатое </word>
7555
+ <word ordinal="14">Четырнадцатое </word>
7556
+ <word ordinal="15">Пятнадцатое </word>
7557
+ <word ordinal="16">Шестнадцатое </word>
7558
+ <word ordinal="17">Семнадцатое </word>
7559
+ <word ordinal="18">Восемнадцатое </word>
7560
+ <word ordinal="19">Девятнадцатое </word>
7561
+ <word cardinal="20">Двадцать-</word>
7562
+ <word ordinal="20">Двадцатое </word>
7563
+ <word cardinal="30">Тридцать-</word>
7564
+ <word ordinal="30">Тридцатое </word>
7565
+ <word cardinal="40">Сорок-</word>
7566
+ <word ordinal="40">Сороковое </word>
7567
+ <word cardinal="50">Пятьдесят-</word>
7568
+ <word ordinal="50">Пятидесятое </word>
7569
+ <word cardinal="60">Шестьдесят-</word>
7570
+ <word ordinal="60">Шестидесятое </word>
7571
+ <word cardinal="70">Семьдесят-</word>
7572
+ <word ordinal="70">Семидесятое </word>
7573
+ <word cardinal="80">Восемьдесят-</word>
7574
+ <word ordinal="80">Восьмидесятое </word>
7575
+ <word cardinal="90">Девяносто-</word>
7576
+ <word ordinal="90">Девяностое </word>
7577
+ <word cardinal="100">Сто-</word>
7578
+ <word ordinal="100">Сотое </word>
7579
+ </xsl:when>
7580
+ <xsl:otherwise> <!-- default english -->
7581
+ <word cardinal="1">One-</word>
7582
+ <word ordinal="1">First </word>
7583
+ <word cardinal="2">Two-</word>
7584
+ <word ordinal="2">Second </word>
7585
+ <word cardinal="3">Three-</word>
7586
+ <word ordinal="3">Third </word>
7587
+ <word cardinal="4">Four-</word>
7588
+ <word ordinal="4">Fourth </word>
7589
+ <word cardinal="5">Five-</word>
7590
+ <word ordinal="5">Fifth </word>
7591
+ <word cardinal="6">Six-</word>
7592
+ <word ordinal="6">Sixth </word>
7593
+ <word cardinal="7">Seven-</word>
7594
+ <word ordinal="7">Seventh </word>
7595
+ <word cardinal="8">Eight-</word>
7596
+ <word ordinal="8">Eighth </word>
7597
+ <word cardinal="9">Nine-</word>
7598
+ <word ordinal="9">Ninth </word>
7599
+ <word ordinal="10">Tenth </word>
7600
+ <word ordinal="11">Eleventh </word>
7601
+ <word ordinal="12">Twelfth </word>
7602
+ <word ordinal="13">Thirteenth </word>
7603
+ <word ordinal="14">Fourteenth </word>
7604
+ <word ordinal="15">Fifteenth </word>
7605
+ <word ordinal="16">Sixteenth </word>
7606
+ <word ordinal="17">Seventeenth </word>
7607
+ <word ordinal="18">Eighteenth </word>
7608
+ <word ordinal="19">Nineteenth </word>
7609
+ <word cardinal="20">Twenty-</word>
7610
+ <word ordinal="20">Twentieth </word>
7611
+ <word cardinal="30">Thirty-</word>
7612
+ <word ordinal="30">Thirtieth </word>
7613
+ <word cardinal="40">Forty-</word>
7614
+ <word ordinal="40">Fortieth </word>
7615
+ <word cardinal="50">Fifty-</word>
7616
+ <word ordinal="50">Fiftieth </word>
7617
+ <word cardinal="60">Sixty-</word>
7618
+ <word ordinal="60">Sixtieth </word>
7619
+ <word cardinal="70">Seventy-</word>
7620
+ <word ordinal="70">Seventieth </word>
7621
+ <word cardinal="80">Eighty-</word>
7622
+ <word ordinal="80">Eightieth </word>
7623
+ <word cardinal="90">Ninety-</word>
7624
+ <word ordinal="90">Ninetieth </word>
7625
+ <word cardinal="100">Hundred-</word>
7626
+ <word ordinal="100">Hundredth </word>
7627
+ </xsl:otherwise>
7628
+ </xsl:choose>
7161
7629
  </words>
7162
7630
  </xsl:variable>
7163
7631
 
@@ -7231,4 +7699,18 @@
7231
7699
  <xsl:otherwise>_</xsl:otherwise>
7232
7700
  </xsl:choose>
7233
7701
  </xsl:attribute>
7702
+ </xsl:template><xsl:template name="substring-after-last">
7703
+ <xsl:param name="value"/>
7704
+ <xsl:param name="delimiter"/>
7705
+ <xsl:choose>
7706
+ <xsl:when test="contains($value, $delimiter)">
7707
+ <xsl:call-template name="substring-after-last">
7708
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7709
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7710
+ </xsl:call-template>
7711
+ </xsl:when>
7712
+ <xsl:otherwise>
7713
+ <xsl:value-of select="$value"/>
7714
+ </xsl:otherwise>
7715
+ </xsl:choose>
7234
7716
  </xsl:template></xsl:stylesheet>