metanorma-un 0.8.3 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@
10
10
 
11
11
  <xsl:variable name="debug">false</xsl:variable>
12
12
 
13
- <xsl:variable name="contents">
13
+ <xsl:variable name="contents_">
14
14
  <contents>
15
15
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
16
16
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
@@ -20,9 +20,11 @@
20
20
  <xsl:apply-templates select="/un:un-standard/un:sections/*" mode="contents"/>
21
21
  <xsl:apply-templates select="/un:un-standard/un:annex" mode="contents"/>
22
22
  <xsl:apply-templates select="/un:un-standard/un:bibliography/un:references" mode="contents"/>
23
+
24
+ <xsl:call-template name="processTablesFigures_Contents"/>
23
25
  </contents>
24
26
  </xsl:variable>
25
-
27
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
26
28
 
27
29
  <xsl:variable name="title" select="/un:un-standard/un:bibdata/un:title[@language = 'en' and @type = 'main']"/>
28
30
 
@@ -276,7 +278,7 @@
276
278
  <xsl:if test="$debug = 'true'">
277
279
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
278
280
  DEBUG
279
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
281
+ contents=<xsl:copy-of select="$contents"/>
280
282
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
281
283
  </xsl:if>
282
284
 
@@ -851,6 +853,10 @@
851
853
  <xsl:text>Édition </xsl:text>
852
854
  </title-edition>
853
855
 
856
+ <title-edition lang="ru">
857
+ <xsl:text>Издание </xsl:text>
858
+ </title-edition>
859
+
854
860
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
855
861
  <title-toc lang="en">
856
862
 
@@ -865,7 +871,7 @@
865
871
  <xsl:text>Contents</xsl:text>
866
872
 
867
873
  </title-toc>
868
-
874
+
869
875
  <title-descriptors lang="en">Descriptors</title-descriptors>
870
876
 
871
877
  <title-part lang="en">
@@ -877,7 +883,11 @@
877
883
 
878
884
 
879
885
 
880
- </title-part>
886
+ </title-part>
887
+ <title-part lang="ru">
888
+
889
+
890
+ </title-part>
881
891
  <title-part lang="zh">第 # 部分:</title-part>
882
892
 
883
893
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -893,10 +903,35 @@
893
903
 
894
904
  <title-summary lang="en">Summary</title-summary>
895
905
 
906
+ <title-continued lang="ru">(продолжение)</title-continued>
896
907
  <title-continued lang="en">(continued)</title-continued>
897
908
  <title-continued lang="fr">(continué)</title-continued>
898
909
 
899
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
910
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
911
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
912
+ <xsl:value-of select="$toc_table_title"/>
913
+ <xsl:if test="normalize-space($toc_table_title) = ''">
914
+ <xsl:call-template name="getTitle">
915
+ <xsl:with-param name="name" select="'title-list-tables'"/>
916
+ </xsl:call-template>
917
+ </xsl:if>
918
+ </xsl:variable><xsl:variable name="title-list-figures">
919
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
920
+ <xsl:value-of select="$toc_figure_title"/>
921
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
922
+ <xsl:call-template name="getTitle">
923
+ <xsl:with-param name="name" select="'title-list-figures'"/>
924
+ </xsl:call-template>
925
+ </xsl:if>
926
+ </xsl:variable><xsl:variable name="title-list-recommendations">
927
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
928
+ <xsl:value-of select="$toc_requirement_title"/>
929
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
930
+ <xsl:call-template name="getTitle">
931
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
932
+ </xsl:call-template>
933
+ </xsl:if>
934
+ </xsl:variable><xsl:variable name="bibdata">
900
935
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
901
936
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
902
937
  </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">
@@ -1619,13 +1654,19 @@
1619
1654
  </xsl:attribute-set><xsl:variable name="color-added-text">
1620
1655
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1621
1656
  </xsl:variable><xsl:attribute-set name="add-style">
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
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1657
+
1658
+ <xsl:attribute name="color">red</xsl:attribute>
1659
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1660
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1661
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1662
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1663
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1664
+
1665
+ </xsl:attribute-set><xsl:variable name="add-style">
1666
+ <add-style xsl:use-attribute-sets="add-style"/>
1667
+ </xsl:variable><xsl:template name="append_add-style">
1668
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1669
+ </xsl:template><xsl:variable name="color-deleted-text">
1629
1670
  <xsl:text>red</xsl:text>
1630
1671
  </xsl:variable><xsl:attribute-set name="del-style">
1631
1672
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -2054,14 +2095,42 @@
2054
2095
 
2055
2096
 
2056
2097
  </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">
2098
+ <xsl:variable name="nodes_preface_">
2099
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2100
+ <node id="{@id}"/>
2101
+ </xsl:for-each>
2102
+ </xsl:variable>
2103
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2104
+
2057
2105
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2058
2106
  <xsl:sort select="@displayorder" data-type="number"/>
2107
+
2108
+ <!-- process Section's title -->
2109
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2110
+ <xsl:if test="$preceding-sibling_id != ''">
2111
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2112
+ </xsl:if>
2113
+
2059
2114
  <xsl:apply-templates select="." mode="contents"/>
2060
2115
  </xsl:for-each>
2061
2116
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2062
2117
 
2118
+ <xsl:variable name="nodes_sections_">
2119
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
2120
+ <node id="{@id}"/>
2121
+ </xsl:for-each>
2122
+ </xsl:variable>
2123
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
2124
+
2063
2125
  <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']]">
2064
2126
  <xsl:sort select="@displayorder" data-type="number"/>
2127
+
2128
+ <!-- process Section's title -->
2129
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2130
+ <xsl:if test="$preceding-sibling_id != ''">
2131
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2132
+ </xsl:if>
2133
+
2065
2134
  <xsl:apply-templates select="." mode="contents"/>
2066
2135
  </xsl:for-each>
2067
2136
 
@@ -2074,6 +2143,30 @@
2074
2143
  <xsl:sort select="@displayorder" data-type="number"/>
2075
2144
  <xsl:apply-templates select="." mode="contents"/>
2076
2145
  </xsl:for-each>
2146
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2147
+ <xsl:param name="always"/>
2148
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2149
+ <xsl:call-template name="processTables_Contents"/>
2150
+ </xsl:if>
2151
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2152
+ <xsl:call-template name="processFigures_Contents"/>
2153
+ </xsl:if>
2154
+ </xsl:template><xsl:template name="processTables_Contents">
2155
+ <tables>
2156
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2157
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2158
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2159
+ </table>
2160
+ </xsl:for-each>
2161
+ </tables>
2162
+ </xsl:template><xsl:template name="processFigures_Contents">
2163
+ <figures>
2164
+ <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) != '']">
2165
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2166
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2167
+ </figure>
2168
+ </xsl:for-each>
2169
+ </figures>
2077
2170
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2078
2171
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2079
2172
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2200,7 +2293,7 @@
2200
2293
  </xsl:call-template>
2201
2294
  </xsl:if>
2202
2295
  </xsl:variable>
2203
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2296
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2204
2297
 
2205
2298
 
2206
2299
  <xsl:variable name="margin-side">
@@ -2468,7 +2561,7 @@
2468
2561
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2469
2562
  <!-- 2009 thinspace -->
2470
2563
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2471
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2564
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2472
2565
  </xsl:call-template>
2473
2566
  </xsl:variable>
2474
2567
  <xsl:variable name="max_length">
@@ -2862,37 +2955,7 @@
2862
2955
 
2863
2956
  <!-- list of footnotes to calculate actual footnotes number -->
2864
2957
  <xsl:variable name="p_fn_">
2865
- <xsl:choose>
2866
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2867
- <fn gen_id="{generate-id(.)}">
2868
- <xsl:copy-of select="@*"/>
2869
- <xsl:copy-of select="node()"/>
2870
- </fn>
2871
- </xsl:when>
2872
- <xsl:otherwise>
2873
- <!-- itetation for:
2874
- footnotes in bibdata/title
2875
- footnotes in bibliography
2876
- footnotes in document's body (except table's head/body/foot and figure text)
2877
- -->
2878
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2879
- <fn gen_id="{generate-id(.)}">
2880
- <xsl:copy-of select="@*"/>
2881
- <xsl:copy-of select="node()"/>
2882
- </fn>
2883
- </xsl:for-each>
2884
- <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']/*">
2885
- <xsl:sort select="@displayorder" data-type="number"/>
2886
- <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])]">
2887
- <!-- copy unique fn -->
2888
- <fn gen_id="{generate-id(.)}">
2889
- <xsl:copy-of select="@*"/>
2890
- <xsl:copy-of select="node()"/>
2891
- </fn>
2892
- </xsl:for-each>
2893
- </xsl:for-each>
2894
- </xsl:otherwise>
2895
- </xsl:choose>
2958
+ <xsl:call-template name="get_fn_list"/>
2896
2959
  </xsl:variable>
2897
2960
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2898
2961
 
@@ -2953,6 +3016,38 @@
2953
3016
  <xsl:copy-of select="$footnote_inline"/>
2954
3017
  </xsl:otherwise>
2955
3018
  </xsl:choose>
3019
+ </xsl:template><xsl:template name="get_fn_list">
3020
+ <xsl:choose>
3021
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3022
+ <fn gen_id="{generate-id(.)}">
3023
+ <xsl:copy-of select="@*"/>
3024
+ <xsl:copy-of select="node()"/>
3025
+ </fn>
3026
+ </xsl:when>
3027
+ <xsl:otherwise>
3028
+ <!-- itetation for:
3029
+ footnotes in bibdata/title
3030
+ footnotes in bibliography
3031
+ footnotes in document's body (except table's head/body/foot and figure text)
3032
+ -->
3033
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3034
+ <fn gen_id="{generate-id(.)}">
3035
+ <xsl:copy-of select="@*"/>
3036
+ <xsl:copy-of select="node()"/>
3037
+ </fn>
3038
+ </xsl:for-each>
3039
+ <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']/*">
3040
+ <xsl:sort select="@displayorder" data-type="number"/>
3041
+ <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])]">
3042
+ <!-- copy unique fn -->
3043
+ <fn gen_id="{generate-id(.)}">
3044
+ <xsl:copy-of select="@*"/>
3045
+ <xsl:copy-of select="node()"/>
3046
+ </fn>
3047
+ </xsl:for-each>
3048
+ </xsl:for-each>
3049
+ </xsl:otherwise>
3050
+ </xsl:choose>
2956
3051
  </xsl:template><xsl:template name="table_fn_display">
2957
3052
  <xsl:variable name="references">
2958
3053
 
@@ -3124,7 +3219,7 @@
3124
3219
  </fo:inline>
3125
3220
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3126
3221
  <fo:inline><xsl:value-of select="."/></fo:inline>
3127
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3222
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3128
3223
  <fo:inline>
3129
3224
  <xsl:apply-templates/>
3130
3225
  </fo:inline>
@@ -4100,6 +4195,9 @@
4100
4195
  </fo:inline>
4101
4196
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
4102
4197
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4198
+ <xsl:if test="parent::*[local-name() = 'add']">
4199
+ <xsl:call-template name="append_add-style"/>
4200
+ </xsl:if>
4103
4201
  <xsl:apply-templates/>
4104
4202
  </fo:basic-link>
4105
4203
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -4211,6 +4309,13 @@
4211
4309
 
4212
4310
 
4213
4311
 
4312
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4313
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4314
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4315
+ <xsl:call-template name="append_add-style"/>
4316
+ </xsl:if>
4317
+
4318
+
4214
4319
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
4215
4320
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
4216
4321
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -4249,6 +4354,12 @@
4249
4354
 
4250
4355
 
4251
4356
 
4357
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4358
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4359
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4360
+ <xsl:call-template name="append_add-style"/>
4361
+ </xsl:if>
4362
+
4252
4363
  <xsl:apply-templates select="*[local-name() = 'name']"/>
4253
4364
 
4254
4365
  </fo:inline>
@@ -4302,6 +4413,7 @@
4302
4413
  </fo:block>
4303
4414
  </xsl:template><xsl:template match="*[local-name() = 'term']">
4304
4415
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4416
+
4305
4417
 
4306
4418
 
4307
4419
 
@@ -4738,7 +4850,11 @@
4738
4850
  <xsl:value-of select="."/>
4739
4851
  </xsl:template><xsl:template match="node()" mode="contents">
4740
4852
  <xsl:apply-templates mode="contents"/>
4741
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4853
+ </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">
4854
+ <xsl:call-template name="contents_section-title"/>
4855
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4856
+ <xsl:call-template name="contents_section-title"/>
4857
+ </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">
4742
4858
  <xsl:variable name="level">
4743
4859
  <xsl:call-template name="getLevel">
4744
4860
  <xsl:with-param name="depth" select="@depth"/>
@@ -4807,13 +4923,14 @@
4807
4923
  <xsl:apply-templates mode="bookmarks"/>
4808
4924
  </xsl:template><xsl:template name="addBookmarks">
4809
4925
  <xsl:param name="contents"/>
4810
- <xsl:if test="xalan:nodeset($contents)//item">
4926
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4927
+ <xsl:if test="$contents_nodes//item">
4811
4928
  <fo:bookmark-tree>
4812
4929
  <xsl:choose>
4813
- <xsl:when test="xalan:nodeset($contents)/doc">
4930
+ <xsl:when test="$contents_nodes/doc">
4814
4931
  <xsl:choose>
4815
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4816
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4932
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4933
+ <xsl:for-each select="$contents_nodes/doc">
4817
4934
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4818
4935
  <xsl:if test="@bundle = 'true'">
4819
4936
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4864,7 +4981,7 @@
4864
4981
  </xsl:for-each>
4865
4982
  </xsl:when>
4866
4983
  <xsl:otherwise>
4867
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4984
+ <xsl:for-each select="$contents_nodes/doc">
4868
4985
 
4869
4986
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4870
4987
 
@@ -4882,25 +4999,36 @@
4882
4999
  </xsl:choose>
4883
5000
  </xsl:when>
4884
5001
  <xsl:otherwise>
4885
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
5002
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
5003
+
5004
+ <xsl:call-template name="insertFigureBookmarks">
5005
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5006
+ </xsl:call-template>
5007
+
5008
+ <xsl:call-template name="insertTableBookmarks">
5009
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5010
+ <xsl:with-param name="lang" select="@lang"/>
5011
+ </xsl:call-template>
5012
+
4886
5013
  </xsl:otherwise>
4887
5014
  </xsl:choose>
4888
5015
 
5016
+
4889
5017
 
4890
5018
 
4891
5019
 
4892
5020
 
4893
-
4894
-
5021
+
4895
5022
 
4896
5023
  </fo:bookmark-tree>
4897
5024
  </xsl:if>
4898
5025
  </xsl:template><xsl:template name="insertFigureBookmarks">
4899
5026
  <xsl:param name="contents"/>
4900
- <xsl:if test="xalan:nodeset($contents)/figure">
4901
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
5027
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5028
+ <xsl:if test="$contents_nodes/figure">
5029
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4902
5030
  <fo:bookmark-title>Figures</fo:bookmark-title>
4903
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5031
+ <xsl:for-each select="$contents_nodes/figure">
4904
5032
  <fo:bookmark internal-destination="{@id}">
4905
5033
  <fo:bookmark-title>
4906
5034
  <xsl:value-of select="normalize-space(title)"/>
@@ -4909,18 +5037,40 @@
4909
5037
  </xsl:for-each>
4910
5038
  </fo:bookmark>
4911
5039
  </xsl:if>
5040
+
5041
+
5042
+ <xsl:if test="$contents_nodes//figures/figure">
5043
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5044
+
5045
+
5046
+
5047
+ <xsl:variable name="bookmark-title">
5048
+
5049
+ <xsl:value-of select="$title-list-figures"/>
5050
+
5051
+ </xsl:variable>
5052
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
5053
+ <xsl:for-each select="$contents_nodes//figures/figure">
5054
+ <fo:bookmark internal-destination="{@id}">
5055
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5056
+ </fo:bookmark>
5057
+ </xsl:for-each>
5058
+ </fo:bookmark>
5059
+ </xsl:if>
5060
+
4912
5061
  </xsl:template><xsl:template name="insertTableBookmarks">
4913
5062
  <xsl:param name="contents"/>
4914
5063
  <xsl:param name="lang"/>
4915
- <xsl:if test="xalan:nodeset($contents)/table">
4916
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5064
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5065
+ <xsl:if test="$contents_nodes/table">
5066
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4917
5067
  <fo:bookmark-title>
4918
5068
  <xsl:choose>
4919
5069
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4920
5070
  <xsl:otherwise>Tables</xsl:otherwise>
4921
5071
  </xsl:choose>
4922
5072
  </fo:bookmark-title>
4923
- <xsl:for-each select="xalan:nodeset($contents)/table">
5073
+ <xsl:for-each select="$contents_nodes/table">
4924
5074
  <fo:bookmark internal-destination="{@id}">
4925
5075
  <fo:bookmark-title>
4926
5076
  <xsl:value-of select="normalize-space(title)"/>
@@ -4929,6 +5079,29 @@
4929
5079
  </xsl:for-each>
4930
5080
  </fo:bookmark>
4931
5081
  </xsl:if>
5082
+
5083
+
5084
+ <xsl:if test="$contents_nodes//tables/table">
5085
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5086
+
5087
+
5088
+
5089
+ <xsl:variable name="bookmark-title">
5090
+
5091
+ <xsl:value-of select="$title-list-tables"/>
5092
+
5093
+ </xsl:variable>
5094
+
5095
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
5096
+
5097
+ <xsl:for-each select="$contents_nodes//tables/table">
5098
+ <fo:bookmark internal-destination="{@id}">
5099
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
5100
+ </fo:bookmark>
5101
+ </xsl:for-each>
5102
+ </fo:bookmark>
5103
+ </xsl:if>
5104
+
4932
5105
  </xsl:template><xsl:template name="getLangVersion">
4933
5106
  <xsl:param name="lang"/>
4934
5107
  <xsl:param name="doctype" select="''"/>
@@ -5153,7 +5326,51 @@
5153
5326
  <xsl:with-param name="text" select="$text_step1"/>
5154
5327
  </xsl:call-template>
5155
5328
  </xsl:variable>
5156
- <xsl:value-of select="$text_step2"/>
5329
+
5330
+ <!-- <xsl:value-of select="$text_step2"/> -->
5331
+
5332
+ <!-- add zero-width space after space -->
5333
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5334
+
5335
+ <!-- split text by zero-width space -->
5336
+ <xsl:variable name="text_step4">
5337
+ <xsl:call-template name="split">
5338
+ <xsl:with-param name="pText" select="$text_step3"/>
5339
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5340
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5341
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5342
+ </xsl:call-template>
5343
+ </xsl:variable>
5344
+
5345
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5346
+ <xsl:choose>
5347
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5348
+ <xsl:call-template name="interspers">
5349
+ <xsl:with-param name="str" select="."/>
5350
+ </xsl:call-template>
5351
+ </xsl:when>
5352
+ <xsl:otherwise>
5353
+ <xsl:value-of select="."/>
5354
+ </xsl:otherwise>
5355
+ </xsl:choose>
5356
+ </xsl:for-each>
5357
+
5358
+ </xsl:template><xsl:template name="interspers">
5359
+ <xsl:param name="str"/>
5360
+ <xsl:param name="char" select="$zero_width_space"/>
5361
+ <xsl:if test="$str != ''">
5362
+ <xsl:value-of select="substring($str, 1, 1)"/>
5363
+
5364
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5365
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5366
+ <xsl:value-of select="$char"/>
5367
+ </xsl:if>
5368
+
5369
+ <xsl:call-template name="interspers">
5370
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5371
+ <xsl:with-param name="char" select="$char"/>
5372
+ </xsl:call-template>
5373
+ </xsl:if>
5157
5374
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5158
5375
  <xsl:apply-templates mode="syntax_highlight"/>
5159
5376
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5589,6 +5806,8 @@
5589
5806
  </xsl:otherwise>
5590
5807
  </xsl:choose> -->
5591
5808
  </fo:block>
5809
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5810
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5592
5811
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5593
5812
  <xsl:if test="normalize-space() != ''">
5594
5813
  <xsl:value-of select="."/>
@@ -5663,26 +5882,24 @@
5663
5882
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5664
5883
  <xsl:text>— </xsl:text>
5665
5884
  <xsl:apply-templates/>
5666
- </xsl:template><xsl:variable name="bibitem_hidden_">
5885
+ </xsl:template><xsl:variable name="bibitems_">
5886
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5887
+ <xsl:copy-of select="."/>
5888
+ </xsl:for-each>
5889
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5667
5890
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5668
5891
  <xsl:copy-of select="."/>
5669
5892
  </xsl:for-each>
5670
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5893
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5671
5894
  <xsl:copy-of select="."/>
5672
5895
  </xsl:for-each>
5673
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5674
-
5675
- <xsl:variable name="bibitemid">
5676
- <xsl:choose>
5677
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5678
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5679
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5680
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5681
- </xsl:choose>
5682
- </xsl:variable>
5683
-
5896
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5897
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5898
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5899
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5684
5900
  <xsl:choose>
5685
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5901
+ <!-- <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) -->
5902
+ <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) -->
5686
5903
  <fo:inline xsl:use-attribute-sets="eref-style">
5687
5904
  <xsl:if test="@type = 'footnote'">
5688
5905
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5696,8 +5913,8 @@
5696
5913
  <xsl:variable name="text" select="normalize-space()"/>
5697
5914
 
5698
5915
 
5699
-
5700
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5916
+
5917
+ <fo:basic-link fox:alt-text="{@citeas}">
5701
5918
  <xsl:if test="normalize-space(@citeas) = ''">
5702
5919
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5703
5920
  </xsl:if>
@@ -5709,14 +5926,21 @@
5709
5926
 
5710
5927
  </xsl:if>
5711
5928
 
5712
-
5929
+ <xsl:choose>
5930
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5931
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5932
+ </xsl:when>
5933
+ <xsl:otherwise>
5934
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5935
+ </xsl:otherwise>
5936
+ </xsl:choose>
5713
5937
 
5714
5938
  <xsl:apply-templates/>
5715
5939
  </fo:basic-link>
5716
-
5940
+
5717
5941
  </fo:inline>
5718
5942
  </xsl:when>
5719
- <xsl:otherwise>
5943
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5720
5944
  <fo:inline><xsl:apply-templates/></fo:inline>
5721
5945
  </xsl:otherwise>
5722
5946
  </xsl:choose>
@@ -6055,7 +6279,7 @@
6055
6279
 
6056
6280
 
6057
6281
 
6058
-
6282
+
6059
6283
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6060
6284
  </fo:list-block>
6061
6285
  <!-- <xsl:for-each select="./iho:note">
@@ -6073,6 +6297,11 @@
6073
6297
 
6074
6298
 
6075
6299
 
6300
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6301
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6302
+ <xsl:call-template name="append_add-style"/>
6303
+ </xsl:if>
6304
+
6076
6305
  <xsl:call-template name="getListItemFormat"/>
6077
6306
  </fo:block>
6078
6307
  </fo:list-item-label>
@@ -6410,23 +6639,45 @@
6410
6639
  <xsl:apply-templates/>
6411
6640
  </fo:inline>
6412
6641
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6642
+
6643
+ <!-- list of footnotes to calculate actual footnotes number -->
6644
+ <xsl:variable name="p_fn_">
6645
+ <xsl:call-template name="get_fn_list"/>
6646
+ </xsl:variable>
6647
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6648
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6649
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6650
+ <!-- fn sequence number in document -->
6651
+ <xsl:variable name="current_fn_number">
6652
+ <xsl:choose>
6653
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6654
+ <xsl:otherwise>
6655
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6656
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6657
+ </xsl:otherwise>
6658
+ </xsl:choose>
6659
+ </xsl:variable>
6413
6660
  <fo:footnote>
6414
6661
  <xsl:variable name="number">
6415
6662
 
6416
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6663
+ <xsl:value-of select="$current_fn_number"/>
6417
6664
 
6418
6665
  </xsl:variable>
6666
+
6667
+ <xsl:variable name="current_fn_number_text">
6668
+ <xsl:value-of select="$number"/>
6669
+
6670
+ </xsl:variable>
6671
+
6419
6672
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6420
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6421
- <xsl:value-of select="$number"/>
6422
-
6673
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6674
+ <xsl:value-of select="$current_fn_number_text"/>
6423
6675
  </fo:basic-link>
6424
6676
  </fo:inline>
6425
6677
  <fo:footnote-body>
6426
6678
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6427
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6428
- <xsl:value-of select="$number"/>
6429
-
6679
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6680
+ <xsl:value-of select="$current_fn_number_text"/>
6430
6681
  </fo:inline>
6431
6682
  <xsl:apply-templates/>
6432
6683
  </fo:block>
@@ -6677,6 +6928,78 @@
6677
6928
  <xsl:apply-templates/>
6678
6929
  </fo:block>
6679
6930
 
6931
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6932
+ <xsl:copy>
6933
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6934
+ </xsl:copy>
6935
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6936
+ <xsl:copy>
6937
+ <xsl:copy-of select="@*"/>
6938
+
6939
+ <xsl:variable name="nodes_preface_">
6940
+ <xsl:for-each select="*">
6941
+ <node id="{@id}"/>
6942
+ </xsl:for-each>
6943
+ </xsl:variable>
6944
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6945
+
6946
+ <xsl:for-each select="*">
6947
+ <xsl:sort select="@displayorder" data-type="number"/>
6948
+
6949
+ <!-- process Section's title -->
6950
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6951
+ <xsl:if test="$preceding-sibling_id != ''">
6952
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6953
+ </xsl:if>
6954
+
6955
+ <xsl:choose>
6956
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6957
+ <xsl:otherwise>
6958
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6959
+ </xsl:otherwise>
6960
+ </xsl:choose>
6961
+
6962
+ </xsl:for-each>
6963
+ </xsl:copy>
6964
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
6965
+ <xsl:copy>
6966
+ <xsl:copy-of select="@*"/>
6967
+
6968
+ <xsl:variable name="nodes_sections_">
6969
+ <xsl:for-each select="*">
6970
+ <node id="{@id}"/>
6971
+ </xsl:for-each>
6972
+ </xsl:variable>
6973
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
6974
+
6975
+ <!-- move section 'Normative references' inside 'sections' -->
6976
+ <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']]">
6977
+ <xsl:sort select="@displayorder" data-type="number"/>
6978
+
6979
+ <!-- process Section's title -->
6980
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6981
+ <xsl:if test="$preceding-sibling_id != ''">
6982
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6983
+ </xsl:if>
6984
+
6985
+ <xsl:choose>
6986
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6987
+ <xsl:otherwise>
6988
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6989
+ </xsl:otherwise>
6990
+ </xsl:choose>
6991
+
6992
+ </xsl:for-each>
6993
+ </xsl:copy>
6994
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
6995
+ <xsl:copy>
6996
+ <xsl:copy-of select="@*"/>
6997
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
6998
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
6999
+ <xsl:sort select="@displayorder" data-type="number"/>
7000
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7001
+ </xsl:for-each>
7002
+ </xsl:copy>
6680
7003
  </xsl:template><xsl:template name="convertDate">
6681
7004
  <xsl:param name="date"/>
6682
7005
  <xsl:param name="format" select="'short'"/>
@@ -6921,22 +7244,25 @@
6921
7244
  <xsl:param name="pText" select="."/>
6922
7245
  <xsl:param name="sep" select="','"/>
6923
7246
  <xsl:param name="normalize-space" select="'true'"/>
7247
+ <xsl:param name="keep_sep" select="'false'"/>
6924
7248
  <xsl:if test="string-length($pText) &gt;0">
6925
- <item>
6926
- <xsl:choose>
6927
- <xsl:when test="$normalize-space = 'true'">
6928
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
6929
- </xsl:when>
6930
- <xsl:otherwise>
6931
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
6932
- </xsl:otherwise>
6933
- </xsl:choose>
6934
- </item>
6935
- <xsl:call-template name="split">
6936
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
6937
- <xsl:with-param name="sep" select="$sep"/>
6938
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
6939
- </xsl:call-template>
7249
+ <item>
7250
+ <xsl:choose>
7251
+ <xsl:when test="$normalize-space = 'true'">
7252
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7253
+ </xsl:when>
7254
+ <xsl:otherwise>
7255
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7256
+ </xsl:otherwise>
7257
+ </xsl:choose>
7258
+ </item>
7259
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7260
+ <xsl:call-template name="split">
7261
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7262
+ <xsl:with-param name="sep" select="$sep"/>
7263
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7264
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7265
+ </xsl:call-template>
6940
7266
  </xsl:if>
6941
7267
  </xsl:template><xsl:template name="getDocumentId">
6942
7268
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -7127,53 +7453,153 @@
7127
7453
  <xsl:param name="first"/>
7128
7454
  <xsl:if test="$number != ''">
7129
7455
  <xsl:variable name="words">
7130
- <words>
7131
- <word cardinal="1">One-</word>
7132
- <word ordinal="1">First </word>
7133
- <word cardinal="2">Two-</word>
7134
- <word ordinal="2">Second </word>
7135
- <word cardinal="3">Three-</word>
7136
- <word ordinal="3">Third </word>
7137
- <word cardinal="4">Four-</word>
7138
- <word ordinal="4">Fourth </word>
7139
- <word cardinal="5">Five-</word>
7140
- <word ordinal="5">Fifth </word>
7141
- <word cardinal="6">Six-</word>
7142
- <word ordinal="6">Sixth </word>
7143
- <word cardinal="7">Seven-</word>
7144
- <word ordinal="7">Seventh </word>
7145
- <word cardinal="8">Eight-</word>
7146
- <word ordinal="8">Eighth </word>
7147
- <word cardinal="9">Nine-</word>
7148
- <word ordinal="9">Ninth </word>
7149
- <word ordinal="10">Tenth </word>
7150
- <word ordinal="11">Eleventh </word>
7151
- <word ordinal="12">Twelfth </word>
7152
- <word ordinal="13">Thirteenth </word>
7153
- <word ordinal="14">Fourteenth </word>
7154
- <word ordinal="15">Fifteenth </word>
7155
- <word ordinal="16">Sixteenth </word>
7156
- <word ordinal="17">Seventeenth </word>
7157
- <word ordinal="18">Eighteenth </word>
7158
- <word ordinal="19">Nineteenth </word>
7159
- <word cardinal="20">Twenty-</word>
7160
- <word ordinal="20">Twentieth </word>
7161
- <word cardinal="30">Thirty-</word>
7162
- <word ordinal="30">Thirtieth </word>
7163
- <word cardinal="40">Forty-</word>
7164
- <word ordinal="40">Fortieth </word>
7165
- <word cardinal="50">Fifty-</word>
7166
- <word ordinal="50">Fiftieth </word>
7167
- <word cardinal="60">Sixty-</word>
7168
- <word ordinal="60">Sixtieth </word>
7169
- <word cardinal="70">Seventy-</word>
7170
- <word ordinal="70">Seventieth </word>
7171
- <word cardinal="80">Eighty-</word>
7172
- <word ordinal="80">Eightieth </word>
7173
- <word cardinal="90">Ninety-</word>
7174
- <word ordinal="90">Ninetieth </word>
7175
- <word cardinal="100">Hundred-</word>
7176
- <word ordinal="100">Hundredth </word>
7456
+ <words>
7457
+ <xsl:choose>
7458
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7459
+ <word cardinal="1">Une-</word>
7460
+ <word ordinal="1">Première </word>
7461
+ <word cardinal="2">Deux-</word>
7462
+ <word ordinal="2">Seconde </word>
7463
+ <word cardinal="3">Trois-</word>
7464
+ <word ordinal="3">Tierce </word>
7465
+ <word cardinal="4">Quatre-</word>
7466
+ <word ordinal="4">Quatrième </word>
7467
+ <word cardinal="5">Cinq-</word>
7468
+ <word ordinal="5">Cinquième </word>
7469
+ <word cardinal="6">Six-</word>
7470
+ <word ordinal="6">Sixième </word>
7471
+ <word cardinal="7">Sept-</word>
7472
+ <word ordinal="7">Septième </word>
7473
+ <word cardinal="8">Huit-</word>
7474
+ <word ordinal="8">Huitième </word>
7475
+ <word cardinal="9">Neuf-</word>
7476
+ <word ordinal="9">Neuvième </word>
7477
+ <word ordinal="10">Dixième </word>
7478
+ <word ordinal="11">Onzième </word>
7479
+ <word ordinal="12">Douzième </word>
7480
+ <word ordinal="13">Treizième </word>
7481
+ <word ordinal="14">Quatorzième </word>
7482
+ <word ordinal="15">Quinzième </word>
7483
+ <word ordinal="16">Seizième </word>
7484
+ <word ordinal="17">Dix-septième </word>
7485
+ <word ordinal="18">Dix-huitième </word>
7486
+ <word ordinal="19">Dix-neuvième </word>
7487
+ <word cardinal="20">Vingt-</word>
7488
+ <word ordinal="20">Vingtième </word>
7489
+ <word cardinal="30">Trente-</word>
7490
+ <word ordinal="30">Trentième </word>
7491
+ <word cardinal="40">Quarante-</word>
7492
+ <word ordinal="40">Quarantième </word>
7493
+ <word cardinal="50">Cinquante-</word>
7494
+ <word ordinal="50">Cinquantième </word>
7495
+ <word cardinal="60">Soixante-</word>
7496
+ <word ordinal="60">Soixantième </word>
7497
+ <word cardinal="70">Septante-</word>
7498
+ <word ordinal="70">Septantième </word>
7499
+ <word cardinal="80">Huitante-</word>
7500
+ <word ordinal="80">Huitantième </word>
7501
+ <word cardinal="90">Nonante-</word>
7502
+ <word ordinal="90">Nonantième </word>
7503
+ <word cardinal="100">Cent-</word>
7504
+ <word ordinal="100">Centième </word>
7505
+ </xsl:when>
7506
+ <xsl:when test="$lang = 'ru'">
7507
+ <word cardinal="1">Одна-</word>
7508
+ <word ordinal="1">Первое </word>
7509
+ <word cardinal="2">Две-</word>
7510
+ <word ordinal="2">Второе </word>
7511
+ <word cardinal="3">Три-</word>
7512
+ <word ordinal="3">Третье </word>
7513
+ <word cardinal="4">Четыре-</word>
7514
+ <word ordinal="4">Четвертое </word>
7515
+ <word cardinal="5">Пять-</word>
7516
+ <word ordinal="5">Пятое </word>
7517
+ <word cardinal="6">Шесть-</word>
7518
+ <word ordinal="6">Шестое </word>
7519
+ <word cardinal="7">Семь-</word>
7520
+ <word ordinal="7">Седьмое </word>
7521
+ <word cardinal="8">Восемь-</word>
7522
+ <word ordinal="8">Восьмое </word>
7523
+ <word cardinal="9">Девять-</word>
7524
+ <word ordinal="9">Девятое </word>
7525
+ <word ordinal="10">Десятое </word>
7526
+ <word ordinal="11">Одиннадцатое </word>
7527
+ <word ordinal="12">Двенадцатое </word>
7528
+ <word ordinal="13">Тринадцатое </word>
7529
+ <word ordinal="14">Четырнадцатое </word>
7530
+ <word ordinal="15">Пятнадцатое </word>
7531
+ <word ordinal="16">Шестнадцатое </word>
7532
+ <word ordinal="17">Семнадцатое </word>
7533
+ <word ordinal="18">Восемнадцатое </word>
7534
+ <word ordinal="19">Девятнадцатое </word>
7535
+ <word cardinal="20">Двадцать-</word>
7536
+ <word ordinal="20">Двадцатое </word>
7537
+ <word cardinal="30">Тридцать-</word>
7538
+ <word ordinal="30">Тридцатое </word>
7539
+ <word cardinal="40">Сорок-</word>
7540
+ <word ordinal="40">Сороковое </word>
7541
+ <word cardinal="50">Пятьдесят-</word>
7542
+ <word ordinal="50">Пятидесятое </word>
7543
+ <word cardinal="60">Шестьдесят-</word>
7544
+ <word ordinal="60">Шестидесятое </word>
7545
+ <word cardinal="70">Семьдесят-</word>
7546
+ <word ordinal="70">Семидесятое </word>
7547
+ <word cardinal="80">Восемьдесят-</word>
7548
+ <word ordinal="80">Восьмидесятое </word>
7549
+ <word cardinal="90">Девяносто-</word>
7550
+ <word ordinal="90">Девяностое </word>
7551
+ <word cardinal="100">Сто-</word>
7552
+ <word ordinal="100">Сотое </word>
7553
+ </xsl:when>
7554
+ <xsl:otherwise> <!-- default english -->
7555
+ <word cardinal="1">One-</word>
7556
+ <word ordinal="1">First </word>
7557
+ <word cardinal="2">Two-</word>
7558
+ <word ordinal="2">Second </word>
7559
+ <word cardinal="3">Three-</word>
7560
+ <word ordinal="3">Third </word>
7561
+ <word cardinal="4">Four-</word>
7562
+ <word ordinal="4">Fourth </word>
7563
+ <word cardinal="5">Five-</word>
7564
+ <word ordinal="5">Fifth </word>
7565
+ <word cardinal="6">Six-</word>
7566
+ <word ordinal="6">Sixth </word>
7567
+ <word cardinal="7">Seven-</word>
7568
+ <word ordinal="7">Seventh </word>
7569
+ <word cardinal="8">Eight-</word>
7570
+ <word ordinal="8">Eighth </word>
7571
+ <word cardinal="9">Nine-</word>
7572
+ <word ordinal="9">Ninth </word>
7573
+ <word ordinal="10">Tenth </word>
7574
+ <word ordinal="11">Eleventh </word>
7575
+ <word ordinal="12">Twelfth </word>
7576
+ <word ordinal="13">Thirteenth </word>
7577
+ <word ordinal="14">Fourteenth </word>
7578
+ <word ordinal="15">Fifteenth </word>
7579
+ <word ordinal="16">Sixteenth </word>
7580
+ <word ordinal="17">Seventeenth </word>
7581
+ <word ordinal="18">Eighteenth </word>
7582
+ <word ordinal="19">Nineteenth </word>
7583
+ <word cardinal="20">Twenty-</word>
7584
+ <word ordinal="20">Twentieth </word>
7585
+ <word cardinal="30">Thirty-</word>
7586
+ <word ordinal="30">Thirtieth </word>
7587
+ <word cardinal="40">Forty-</word>
7588
+ <word ordinal="40">Fortieth </word>
7589
+ <word cardinal="50">Fifty-</word>
7590
+ <word ordinal="50">Fiftieth </word>
7591
+ <word cardinal="60">Sixty-</word>
7592
+ <word ordinal="60">Sixtieth </word>
7593
+ <word cardinal="70">Seventy-</word>
7594
+ <word ordinal="70">Seventieth </word>
7595
+ <word cardinal="80">Eighty-</word>
7596
+ <word ordinal="80">Eightieth </word>
7597
+ <word cardinal="90">Ninety-</word>
7598
+ <word ordinal="90">Ninetieth </word>
7599
+ <word cardinal="100">Hundred-</word>
7600
+ <word ordinal="100">Hundredth </word>
7601
+ </xsl:otherwise>
7602
+ </xsl:choose>
7177
7603
  </words>
7178
7604
  </xsl:variable>
7179
7605
 
@@ -7247,4 +7673,18 @@
7247
7673
  <xsl:otherwise>_</xsl:otherwise>
7248
7674
  </xsl:choose>
7249
7675
  </xsl:attribute>
7676
+ </xsl:template><xsl:template name="substring-after-last">
7677
+ <xsl:param name="value"/>
7678
+ <xsl:param name="delimiter"/>
7679
+ <xsl:choose>
7680
+ <xsl:when test="contains($value, $delimiter)">
7681
+ <xsl:call-template name="substring-after-last">
7682
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7683
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7684
+ </xsl:call-template>
7685
+ </xsl:when>
7686
+ <xsl:otherwise>
7687
+ <xsl:value-of select="$value"/>
7688
+ </xsl:otherwise>
7689
+ </xsl:choose>
7250
7690
  </xsl:template></xsl:stylesheet>