metanorma-ogc 2.0.3 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -72,41 +72,18 @@
72
72
  <xsl:attribute-set name="empty-style">
73
73
  </xsl:attribute-set>
74
74
 
75
- <xsl:variable name="contents">
75
+ <xsl:variable name="contents_">
76
76
  <contents>
77
-
78
- <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
79
- <!-- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/*" mode="contents"/> -->
80
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:abstract" mode="contents"/>
81
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'executivesummary']" mode="contents"/>
82
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'keyword']" mode="contents"/>
83
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:foreword" mode="contents"/>
84
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:introduction" mode="contents"/>
85
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'submitting_orgs']" mode="contents"/>
86
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:submitters" mode="contents"/>
87
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[not(@type = 'executivesummary') and not(@type = 'submitting_orgs') and not(@type = 'keyword')]" mode="contents"/>
88
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:acknowledgements" mode="contents"/>
89
-
90
-
91
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='scope']" mode="contents"/>
92
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='conformance']" mode="contents"/>
93
- <!-- Normative references -->
94
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[@normative='true']" mode="contents"/>
95
- <!-- Terms and definitions -->
96
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:terms" mode="contents"/>
97
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:definitions" mode="contents"/>
98
-
99
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[not(@type='scope') and not(@type='conformance')]" mode="contents"/>
100
-
101
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:annex" mode="contents"/>
102
-
103
- <!-- Bibliography -->
104
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[not(@normative='true')]" mode="contents"/>
77
+ <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
78
+ <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
105
79
 
80
+ <xsl:call-template name="processMainSectionsDefault_Contents"/>
81
+ <xsl:apply-templates select="//ogc:indexsect" mode="contents"/>
106
82
 
83
+ <xsl:call-template name="processTablesFigures_Contents"/>
107
84
  </contents>
108
85
  </xsl:variable>
109
-
86
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
110
87
 
111
88
  <xsl:template match="/">
112
89
  <xsl:call-template name="namespaceCheck"/>
@@ -231,7 +208,7 @@
231
208
  </xsl:call-template>
232
209
  </fo:block>
233
210
  <xsl:variable name="margin-left">3.9</xsl:variable>
234
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']">
211
+ <xsl:for-each select="$contents//item[@display = 'true']">
235
212
  <fo:block margin-top="8pt" margin-bottom="5pt" margin-left="{(@level - 1) * $margin-left}mm" text-align-last="justify" role="TOCI">
236
213
  <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
237
214
  <xsl:if test="@section != ''">
@@ -272,27 +249,16 @@
272
249
 
273
250
 
274
251
  <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
275
- <!-- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/*" mode="preface"/> -->
276
- <xsl:if test="/ogc:ogc-standard/ogc:preface/ogc:abstract">
277
- <fo:block break-after="page"/>
278
- </xsl:if>
279
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:abstract"/>
280
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'executivesummary']"/>
281
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'keyword']"/>
282
- <xsl:if test="/ogc:ogc-standard/ogc:preface/ogc:foreword">
283
- <fo:block break-after="page"/>
284
- </xsl:if>
285
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:foreword"/>
286
- <xsl:if test="/ogc:ogc-standard/ogc:preface/ogc:introduction">
287
- <fo:block break-after="page"/>
288
- </xsl:if>
289
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:introduction"/>
290
-
291
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'submitting_orgs']"/>
292
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:submitters"/>
293
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[not(@type = 'executivesummary') and not(@type = 'submitting_orgs') and not(@type = 'keyword')]"/>
294
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:acknowledgements"/>
252
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
253
+ <xsl:sort select="@displayorder" data-type="number"/>
254
+
255
+ <xsl:if test="local-name() = 'abstract' or local-name() = 'foreword' or local-name() = 'introduction'">
256
+ <fo:block break-after="page"/>
257
+ </xsl:if>
295
258
 
259
+ <xsl:apply-templates select="."/>
260
+ </xsl:for-each>
261
+
296
262
  </fo:flow>
297
263
  </fo:page-sequence>
298
264
 
@@ -306,23 +272,7 @@
306
272
 
307
273
  <fo:block line-height="125%">
308
274
 
309
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='scope']"/>
310
-
311
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='conformance']"/>
312
-
313
- <!-- Normative references -->
314
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[@normative='true']"/>
315
-
316
- <!-- Terms and definitions -->
317
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:terms"/>
318
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:definitions"/>
319
-
320
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[not(@type='scope') and not(@type='conformance')]"/>
321
-
322
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:annex"/>
323
-
324
- <!-- Bibliography -->
325
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[not(@normative='true')]"/>
275
+ <xsl:call-template name="processMainSectionsDefault"/>
326
276
 
327
277
  </fo:block>
328
278
  </fo:flow>
@@ -449,14 +399,6 @@
449
399
  </fo:block>
450
400
  </xsl:template>
451
401
 
452
- <xsl:template match="ogc:ogc-standard/ogc:preface/*" mode="preface">
453
- <xsl:if test="local-name() = 'introduction' or local-name() = 'abstract' or local-name() = 'foreword'">
454
- <fo:block break-after="page"/>
455
- </xsl:if>
456
- <xsl:apply-templates select="current()"/>
457
- </xsl:template>
458
-
459
-
460
402
 
461
403
  <!-- ====== -->
462
404
  <!-- title -->
@@ -716,6 +658,10 @@
716
658
  <xsl:text>Édition </xsl:text>
717
659
  </title-edition>
718
660
 
661
+ <title-edition lang="ru">
662
+ <xsl:text>Издание </xsl:text>
663
+ </title-edition>
664
+
719
665
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
720
666
  <title-toc lang="en">
721
667
 
@@ -732,7 +678,7 @@
732
678
  <xsl:text>Contents</xsl:text>
733
679
 
734
680
  </title-toc>
735
-
681
+
736
682
  <title-descriptors lang="en">Descriptors</title-descriptors>
737
683
 
738
684
  <title-part lang="en">
@@ -744,7 +690,11 @@
744
690
 
745
691
 
746
692
 
747
- </title-part>
693
+ </title-part>
694
+ <title-part lang="ru">
695
+
696
+
697
+ </title-part>
748
698
  <title-part lang="zh">第 # 部分:</title-part>
749
699
 
750
700
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -760,10 +710,35 @@
760
710
 
761
711
  <title-summary lang="en">Summary</title-summary>
762
712
 
713
+ <title-continued lang="ru">(продолжение)</title-continued>
763
714
  <title-continued lang="en">(continued)</title-continued>
764
715
  <title-continued lang="fr">(continué)</title-continued>
765
716
 
766
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
717
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
718
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
719
+ <xsl:value-of select="$toc_table_title"/>
720
+ <xsl:if test="normalize-space($toc_table_title) = ''">
721
+ <xsl:call-template name="getTitle">
722
+ <xsl:with-param name="name" select="'title-list-tables'"/>
723
+ </xsl:call-template>
724
+ </xsl:if>
725
+ </xsl:variable><xsl:variable name="title-list-figures">
726
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
727
+ <xsl:value-of select="$toc_figure_title"/>
728
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
729
+ <xsl:call-template name="getTitle">
730
+ <xsl:with-param name="name" select="'title-list-figures'"/>
731
+ </xsl:call-template>
732
+ </xsl:if>
733
+ </xsl:variable><xsl:variable name="title-list-recommendations">
734
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
735
+ <xsl:value-of select="$toc_requirement_title"/>
736
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
737
+ <xsl:call-template name="getTitle">
738
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
739
+ </xsl:call-template>
740
+ </xsl:if>
741
+ </xsl:variable><xsl:variable name="bibdata">
767
742
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
768
743
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
769
744
  </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">
@@ -1596,13 +1571,19 @@
1596
1571
  </xsl:attribute-set><xsl:variable name="color-added-text">
1597
1572
  <xsl:text>rgb(0, 255, 0)</xsl:text>
1598
1573
  </xsl:variable><xsl:attribute-set name="add-style">
1599
- <xsl:attribute name="color">red</xsl:attribute>
1600
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
1601
- <!-- <xsl:attribute name="color">black</xsl:attribute>
1602
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1603
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
1604
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1605
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
1574
+
1575
+ <xsl:attribute name="color">red</xsl:attribute>
1576
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
1577
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
1578
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
1579
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
1580
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
1581
+
1582
+ </xsl:attribute-set><xsl:variable name="add-style">
1583
+ <add-style xsl:use-attribute-sets="add-style"/>
1584
+ </xsl:variable><xsl:template name="append_add-style">
1585
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
1586
+ </xsl:template><xsl:variable name="color-deleted-text">
1606
1587
  <xsl:text>red</xsl:text>
1607
1588
  </xsl:variable><xsl:attribute-set name="del-style">
1608
1589
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -2045,14 +2026,42 @@
2045
2026
 
2046
2027
 
2047
2028
  </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">
2029
+ <xsl:variable name="nodes_preface_">
2030
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2031
+ <node id="{@id}"/>
2032
+ </xsl:for-each>
2033
+ </xsl:variable>
2034
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2035
+
2048
2036
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2049
2037
  <xsl:sort select="@displayorder" data-type="number"/>
2038
+
2039
+ <!-- process Section's title -->
2040
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2041
+ <xsl:if test="$preceding-sibling_id != ''">
2042
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2043
+ </xsl:if>
2044
+
2050
2045
  <xsl:apply-templates select="." mode="contents"/>
2051
2046
  </xsl:for-each>
2052
2047
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2053
2048
 
2049
+ <xsl:variable name="nodes_sections_">
2050
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
2051
+ <node id="{@id}"/>
2052
+ </xsl:for-each>
2053
+ </xsl:variable>
2054
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
2055
+
2054
2056
  <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']]">
2055
2057
  <xsl:sort select="@displayorder" data-type="number"/>
2058
+
2059
+ <!-- process Section's title -->
2060
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2061
+ <xsl:if test="$preceding-sibling_id != ''">
2062
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2063
+ </xsl:if>
2064
+
2056
2065
  <xsl:apply-templates select="." mode="contents"/>
2057
2066
  </xsl:for-each>
2058
2067
 
@@ -2065,6 +2074,30 @@
2065
2074
  <xsl:sort select="@displayorder" data-type="number"/>
2066
2075
  <xsl:apply-templates select="." mode="contents"/>
2067
2076
  </xsl:for-each>
2077
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2078
+ <xsl:param name="always"/>
2079
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2080
+ <xsl:call-template name="processTables_Contents"/>
2081
+ </xsl:if>
2082
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2083
+ <xsl:call-template name="processFigures_Contents"/>
2084
+ </xsl:if>
2085
+ </xsl:template><xsl:template name="processTables_Contents">
2086
+ <tables>
2087
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2088
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2089
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2090
+ </table>
2091
+ </xsl:for-each>
2092
+ </tables>
2093
+ </xsl:template><xsl:template name="processFigures_Contents">
2094
+ <figures>
2095
+ <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) != '']">
2096
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2097
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2098
+ </figure>
2099
+ </xsl:for-each>
2100
+ </figures>
2068
2101
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2069
2102
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2070
2103
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2232,7 +2265,7 @@
2232
2265
  </xsl:call-template>
2233
2266
  </xsl:if>
2234
2267
  </xsl:variable>
2235
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2268
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2236
2269
 
2237
2270
 
2238
2271
  <xsl:variable name="margin-side">
@@ -2496,7 +2529,7 @@
2496
2529
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2497
2530
  <!-- 2009 thinspace -->
2498
2531
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
2499
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
2532
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2500
2533
  </xsl:call-template>
2501
2534
  </xsl:variable>
2502
2535
  <xsl:variable name="max_length">
@@ -2882,37 +2915,7 @@
2882
2915
 
2883
2916
  <!-- list of footnotes to calculate actual footnotes number -->
2884
2917
  <xsl:variable name="p_fn_">
2885
- <xsl:choose>
2886
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2887
- <fn gen_id="{generate-id(.)}">
2888
- <xsl:copy-of select="@*"/>
2889
- <xsl:copy-of select="node()"/>
2890
- </fn>
2891
- </xsl:when>
2892
- <xsl:otherwise>
2893
- <!-- itetation for:
2894
- footnotes in bibdata/title
2895
- footnotes in bibliography
2896
- footnotes in document's body (except table's head/body/foot and figure text)
2897
- -->
2898
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2899
- <fn gen_id="{generate-id(.)}">
2900
- <xsl:copy-of select="@*"/>
2901
- <xsl:copy-of select="node()"/>
2902
- </fn>
2903
- </xsl:for-each>
2904
- <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']/*">
2905
- <xsl:sort select="@displayorder" data-type="number"/>
2906
- <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])]">
2907
- <!-- copy unique fn -->
2908
- <fn gen_id="{generate-id(.)}">
2909
- <xsl:copy-of select="@*"/>
2910
- <xsl:copy-of select="node()"/>
2911
- </fn>
2912
- </xsl:for-each>
2913
- </xsl:for-each>
2914
- </xsl:otherwise>
2915
- </xsl:choose>
2918
+ <xsl:call-template name="get_fn_list"/>
2916
2919
  </xsl:variable>
2917
2920
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2918
2921
 
@@ -2973,6 +2976,38 @@
2973
2976
  <xsl:copy-of select="$footnote_inline"/>
2974
2977
  </xsl:otherwise>
2975
2978
  </xsl:choose>
2979
+ </xsl:template><xsl:template name="get_fn_list">
2980
+ <xsl:choose>
2981
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2982
+ <fn gen_id="{generate-id(.)}">
2983
+ <xsl:copy-of select="@*"/>
2984
+ <xsl:copy-of select="node()"/>
2985
+ </fn>
2986
+ </xsl:when>
2987
+ <xsl:otherwise>
2988
+ <!-- itetation for:
2989
+ footnotes in bibdata/title
2990
+ footnotes in bibliography
2991
+ footnotes in document's body (except table's head/body/foot and figure text)
2992
+ -->
2993
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2994
+ <fn gen_id="{generate-id(.)}">
2995
+ <xsl:copy-of select="@*"/>
2996
+ <xsl:copy-of select="node()"/>
2997
+ </fn>
2998
+ </xsl:for-each>
2999
+ <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']/*">
3000
+ <xsl:sort select="@displayorder" data-type="number"/>
3001
+ <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])]">
3002
+ <!-- copy unique fn -->
3003
+ <fn gen_id="{generate-id(.)}">
3004
+ <xsl:copy-of select="@*"/>
3005
+ <xsl:copy-of select="node()"/>
3006
+ </fn>
3007
+ </xsl:for-each>
3008
+ </xsl:for-each>
3009
+ </xsl:otherwise>
3010
+ </xsl:choose>
2976
3011
  </xsl:template><xsl:template name="table_fn_display">
2977
3012
  <xsl:variable name="references">
2978
3013
 
@@ -3155,7 +3190,7 @@
3155
3190
  </fo:inline>
3156
3191
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3157
3192
  <fo:inline><xsl:value-of select="."/></fo:inline>
3158
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3193
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3159
3194
  <fo:inline>
3160
3195
  <xsl:apply-templates/>
3161
3196
  </fo:inline>
@@ -4131,6 +4166,9 @@
4131
4166
  </fo:inline>
4132
4167
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
4133
4168
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4169
+ <xsl:if test="parent::*[local-name() = 'add']">
4170
+ <xsl:call-template name="append_add-style"/>
4171
+ </xsl:if>
4134
4172
  <xsl:apply-templates/>
4135
4173
  </fo:basic-link>
4136
4174
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -4232,6 +4270,13 @@
4232
4270
 
4233
4271
 
4234
4272
 
4273
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4274
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4275
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4276
+ <xsl:call-template name="append_add-style"/>
4277
+ </xsl:if>
4278
+
4279
+
4235
4280
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
4236
4281
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
4237
4282
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -4270,6 +4315,12 @@
4270
4315
 
4271
4316
 
4272
4317
 
4318
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4319
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
4320
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
4321
+ <xsl:call-template name="append_add-style"/>
4322
+ </xsl:if>
4323
+
4273
4324
  <xsl:apply-templates select="*[local-name() = 'name']"/>
4274
4325
 
4275
4326
  </fo:inline>
@@ -4321,6 +4372,7 @@
4321
4372
  </fo:block>
4322
4373
  </xsl:template><xsl:template match="*[local-name() = 'term']">
4323
4374
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4375
+
4324
4376
 
4325
4377
 
4326
4378
 
@@ -4757,7 +4809,11 @@
4757
4809
  <xsl:value-of select="."/>
4758
4810
  </xsl:template><xsl:template match="node()" mode="contents">
4759
4811
  <xsl:apply-templates mode="contents"/>
4760
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
4812
+ </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">
4813
+ <xsl:call-template name="contents_section-title"/>
4814
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
4815
+ <xsl:call-template name="contents_section-title"/>
4816
+ </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">
4761
4817
  <xsl:variable name="level">
4762
4818
  <xsl:call-template name="getLevel">
4763
4819
  <xsl:with-param name="depth" select="@depth"/>
@@ -4826,13 +4882,14 @@
4826
4882
  <xsl:apply-templates mode="bookmarks"/>
4827
4883
  </xsl:template><xsl:template name="addBookmarks">
4828
4884
  <xsl:param name="contents"/>
4829
- <xsl:if test="xalan:nodeset($contents)//item">
4885
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4886
+ <xsl:if test="$contents_nodes//item">
4830
4887
  <fo:bookmark-tree>
4831
4888
  <xsl:choose>
4832
- <xsl:when test="xalan:nodeset($contents)/doc">
4889
+ <xsl:when test="$contents_nodes/doc">
4833
4890
  <xsl:choose>
4834
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4835
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4891
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4892
+ <xsl:for-each select="$contents_nodes/doc">
4836
4893
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4837
4894
  <xsl:if test="@bundle = 'true'">
4838
4895
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4883,7 +4940,7 @@
4883
4940
  </xsl:for-each>
4884
4941
  </xsl:when>
4885
4942
  <xsl:otherwise>
4886
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4943
+ <xsl:for-each select="$contents_nodes/doc">
4887
4944
 
4888
4945
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4889
4946
 
@@ -4901,11 +4958,21 @@
4901
4958
  </xsl:choose>
4902
4959
  </xsl:when>
4903
4960
  <xsl:otherwise>
4904
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4961
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4962
+
4963
+ <xsl:call-template name="insertFigureBookmarks">
4964
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4965
+ </xsl:call-template>
4966
+
4967
+ <xsl:call-template name="insertTableBookmarks">
4968
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4969
+ <xsl:with-param name="lang" select="@lang"/>
4970
+ </xsl:call-template>
4971
+
4905
4972
  </xsl:otherwise>
4906
4973
  </xsl:choose>
4907
4974
 
4908
-
4975
+
4909
4976
 
4910
4977
 
4911
4978
 
@@ -4918,7 +4985,6 @@
4918
4985
  </xsl:variable>
4919
4986
  <xsl:variable name="list_of_tables_figures" select="xalan:nodeset($list_of_tables_figures_)"/>
4920
4987
 
4921
-
4922
4988
  <xsl:if test="$list_of_tables_figures/table_figure">
4923
4989
  <fo:bookmark internal-destination="empty_bookmark">
4924
4990
  <fo:bookmark-title>—————</fo:bookmark-title>
@@ -4926,7 +4992,7 @@
4926
4992
  </xsl:if>
4927
4993
 
4928
4994
  <xsl:if test="$list_of_tables_figures//table_figure">
4929
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {$list_of_figures//figure[1]/@id} -->
4995
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4930
4996
  <fo:bookmark-title>
4931
4997
  <xsl:call-template name="getTitle">
4932
4998
  <xsl:with-param name="name" select="'title-table-figures'"/>
@@ -4939,17 +5005,18 @@
4939
5005
  </xsl:for-each>
4940
5006
  </fo:bookmark>
4941
5007
  </xsl:if>
4942
-
4943
-
5008
+ <!-- $namespace = 'ogc-white-paper' -->
5009
+
4944
5010
 
4945
5011
  </fo:bookmark-tree>
4946
5012
  </xsl:if>
4947
5013
  </xsl:template><xsl:template name="insertFigureBookmarks">
4948
5014
  <xsl:param name="contents"/>
4949
- <xsl:if test="xalan:nodeset($contents)/figure">
4950
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
5015
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5016
+ <xsl:if test="$contents_nodes/figure">
5017
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4951
5018
  <fo:bookmark-title>Figures</fo:bookmark-title>
4952
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5019
+ <xsl:for-each select="$contents_nodes/figure">
4953
5020
  <fo:bookmark internal-destination="{@id}">
4954
5021
  <fo:bookmark-title>
4955
5022
  <xsl:value-of select="normalize-space(title)"/>
@@ -4958,18 +5025,21 @@
4958
5025
  </xsl:for-each>
4959
5026
  </fo:bookmark>
4960
5027
  </xsl:if>
5028
+
5029
+ <!-- see template addBookmarks -->
4961
5030
  </xsl:template><xsl:template name="insertTableBookmarks">
4962
5031
  <xsl:param name="contents"/>
4963
5032
  <xsl:param name="lang"/>
4964
- <xsl:if test="xalan:nodeset($contents)/table">
4965
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5033
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5034
+ <xsl:if test="$contents_nodes/table">
5035
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4966
5036
  <fo:bookmark-title>
4967
5037
  <xsl:choose>
4968
5038
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4969
5039
  <xsl:otherwise>Tables</xsl:otherwise>
4970
5040
  </xsl:choose>
4971
5041
  </fo:bookmark-title>
4972
- <xsl:for-each select="xalan:nodeset($contents)/table">
5042
+ <xsl:for-each select="$contents_nodes/table">
4973
5043
  <fo:bookmark internal-destination="{@id}">
4974
5044
  <fo:bookmark-title>
4975
5045
  <xsl:value-of select="normalize-space(title)"/>
@@ -4978,6 +5048,8 @@
4978
5048
  </xsl:for-each>
4979
5049
  </fo:bookmark>
4980
5050
  </xsl:if>
5051
+
5052
+ <!-- see template addBookmarks -->
4981
5053
  </xsl:template><xsl:template name="getLangVersion">
4982
5054
  <xsl:param name="lang"/>
4983
5055
  <xsl:param name="doctype" select="''"/>
@@ -5202,7 +5274,51 @@
5202
5274
  <xsl:with-param name="text" select="$text_step1"/>
5203
5275
  </xsl:call-template>
5204
5276
  </xsl:variable>
5205
- <xsl:value-of select="$text_step2"/>
5277
+
5278
+ <!-- <xsl:value-of select="$text_step2"/> -->
5279
+
5280
+ <!-- add zero-width space after space -->
5281
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5282
+
5283
+ <!-- split text by zero-width space -->
5284
+ <xsl:variable name="text_step4">
5285
+ <xsl:call-template name="split">
5286
+ <xsl:with-param name="pText" select="$text_step3"/>
5287
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5288
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5289
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5290
+ </xsl:call-template>
5291
+ </xsl:variable>
5292
+
5293
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5294
+ <xsl:choose>
5295
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5296
+ <xsl:call-template name="interspers">
5297
+ <xsl:with-param name="str" select="."/>
5298
+ </xsl:call-template>
5299
+ </xsl:when>
5300
+ <xsl:otherwise>
5301
+ <xsl:value-of select="."/>
5302
+ </xsl:otherwise>
5303
+ </xsl:choose>
5304
+ </xsl:for-each>
5305
+
5306
+ </xsl:template><xsl:template name="interspers">
5307
+ <xsl:param name="str"/>
5308
+ <xsl:param name="char" select="$zero_width_space"/>
5309
+ <xsl:if test="$str != ''">
5310
+ <xsl:value-of select="substring($str, 1, 1)"/>
5311
+
5312
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5313
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5314
+ <xsl:value-of select="$char"/>
5315
+ </xsl:if>
5316
+
5317
+ <xsl:call-template name="interspers">
5318
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5319
+ <xsl:with-param name="char" select="$char"/>
5320
+ </xsl:call-template>
5321
+ </xsl:if>
5206
5322
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5207
5323
  <xsl:apply-templates mode="syntax_highlight"/>
5208
5324
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5644,6 +5760,8 @@
5644
5760
  </xsl:otherwise>
5645
5761
  </xsl:choose> -->
5646
5762
  </fo:block>
5763
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5764
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5647
5765
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5648
5766
  <xsl:if test="normalize-space() != ''">
5649
5767
  <xsl:value-of select="."/>
@@ -5718,26 +5836,24 @@
5718
5836
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5719
5837
  <xsl:text>— </xsl:text>
5720
5838
  <xsl:apply-templates/>
5721
- </xsl:template><xsl:variable name="bibitem_hidden_">
5839
+ </xsl:template><xsl:variable name="bibitems_">
5840
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5841
+ <xsl:copy-of select="."/>
5842
+ </xsl:for-each>
5843
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5722
5844
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5723
5845
  <xsl:copy-of select="."/>
5724
5846
  </xsl:for-each>
5725
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5847
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5726
5848
  <xsl:copy-of select="."/>
5727
5849
  </xsl:for-each>
5728
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5729
-
5730
- <xsl:variable name="bibitemid">
5731
- <xsl:choose>
5732
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5733
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5734
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5735
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5736
- </xsl:choose>
5737
- </xsl:variable>
5738
-
5850
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5851
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5852
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5853
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5739
5854
  <xsl:choose>
5740
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5855
+ <!-- <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) -->
5856
+ <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) -->
5741
5857
  <fo:inline xsl:use-attribute-sets="eref-style">
5742
5858
  <xsl:if test="@type = 'footnote'">
5743
5859
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5751,8 +5867,8 @@
5751
5867
  <xsl:variable name="text" select="normalize-space()"/>
5752
5868
 
5753
5869
 
5754
-
5755
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5870
+
5871
+ <fo:basic-link fox:alt-text="{@citeas}">
5756
5872
  <xsl:if test="normalize-space(@citeas) = ''">
5757
5873
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5758
5874
  </xsl:if>
@@ -5765,14 +5881,21 @@
5765
5881
 
5766
5882
  </xsl:if>
5767
5883
 
5768
-
5884
+ <xsl:choose>
5885
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5886
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5887
+ </xsl:when>
5888
+ <xsl:otherwise>
5889
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5890
+ </xsl:otherwise>
5891
+ </xsl:choose>
5769
5892
 
5770
5893
  <xsl:apply-templates/>
5771
5894
  </fo:basic-link>
5772
-
5895
+
5773
5896
  </fo:inline>
5774
5897
  </xsl:when>
5775
- <xsl:otherwise>
5898
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5776
5899
  <fo:inline><xsl:apply-templates/></fo:inline>
5777
5900
  </xsl:otherwise>
5778
5901
  </xsl:choose>
@@ -6115,7 +6238,7 @@
6115
6238
 
6116
6239
 
6117
6240
 
6118
-
6241
+
6119
6242
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6120
6243
  </fo:list-block>
6121
6244
  <!-- <xsl:for-each select="./iho:note">
@@ -6133,6 +6256,11 @@
6133
6256
 
6134
6257
 
6135
6258
 
6259
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
6260
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
6261
+ <xsl:call-template name="append_add-style"/>
6262
+ </xsl:if>
6263
+
6136
6264
  <xsl:call-template name="getListItemFormat"/>
6137
6265
  </fo:block>
6138
6266
  </fo:list-item-label>
@@ -6618,6 +6746,24 @@
6618
6746
  <xsl:apply-templates/>
6619
6747
  </fo:inline>
6620
6748
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6749
+
6750
+ <!-- list of footnotes to calculate actual footnotes number -->
6751
+ <xsl:variable name="p_fn_">
6752
+ <xsl:call-template name="get_fn_list"/>
6753
+ </xsl:variable>
6754
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6755
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6756
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6757
+ <!-- fn sequence number in document -->
6758
+ <xsl:variable name="current_fn_number">
6759
+ <xsl:choose>
6760
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6761
+ <xsl:otherwise>
6762
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6763
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6764
+ </xsl:otherwise>
6765
+ </xsl:choose>
6766
+ </xsl:variable>
6621
6767
  <fo:footnote>
6622
6768
  <xsl:variable name="number">
6623
6769
 
@@ -6626,22 +6772,26 @@
6626
6772
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6627
6773
  </xsl:when>
6628
6774
  <xsl:otherwise>
6629
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6775
+ <xsl:value-of select="$current_fn_number"/>
6630
6776
  </xsl:otherwise>
6631
6777
  </xsl:choose>
6632
6778
 
6633
6779
  </xsl:variable>
6780
+
6781
+ <xsl:variable name="current_fn_number_text">
6782
+ <xsl:value-of select="$number"/>
6783
+
6784
+ </xsl:variable>
6785
+
6634
6786
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6635
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6636
- <xsl:value-of select="$number"/>
6637
-
6787
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6788
+ <xsl:value-of select="$current_fn_number_text"/>
6638
6789
  </fo:basic-link>
6639
6790
  </fo:inline>
6640
6791
  <fo:footnote-body>
6641
6792
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6642
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6643
- <xsl:value-of select="$number"/>
6644
-
6793
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6794
+ <xsl:value-of select="$current_fn_number_text"/>
6645
6795
  </fo:inline>
6646
6796
  <xsl:apply-templates/>
6647
6797
  </fo:block>
@@ -6887,6 +7037,78 @@
6887
7037
  <xsl:apply-templates/>
6888
7038
  </fo:block>
6889
7039
 
7040
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7041
+ <xsl:copy>
7042
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7043
+ </xsl:copy>
7044
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7045
+ <xsl:copy>
7046
+ <xsl:copy-of select="@*"/>
7047
+
7048
+ <xsl:variable name="nodes_preface_">
7049
+ <xsl:for-each select="*">
7050
+ <node id="{@id}"/>
7051
+ </xsl:for-each>
7052
+ </xsl:variable>
7053
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7054
+
7055
+ <xsl:for-each select="*">
7056
+ <xsl:sort select="@displayorder" data-type="number"/>
7057
+
7058
+ <!-- process Section's title -->
7059
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7060
+ <xsl:if test="$preceding-sibling_id != ''">
7061
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7062
+ </xsl:if>
7063
+
7064
+ <xsl:choose>
7065
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7066
+ <xsl:otherwise>
7067
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7068
+ </xsl:otherwise>
7069
+ </xsl:choose>
7070
+
7071
+ </xsl:for-each>
7072
+ </xsl:copy>
7073
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7074
+ <xsl:copy>
7075
+ <xsl:copy-of select="@*"/>
7076
+
7077
+ <xsl:variable name="nodes_sections_">
7078
+ <xsl:for-each select="*">
7079
+ <node id="{@id}"/>
7080
+ </xsl:for-each>
7081
+ </xsl:variable>
7082
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7083
+
7084
+ <!-- move section 'Normative references' inside 'sections' -->
7085
+ <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']]">
7086
+ <xsl:sort select="@displayorder" data-type="number"/>
7087
+
7088
+ <!-- process Section's title -->
7089
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7090
+ <xsl:if test="$preceding-sibling_id != ''">
7091
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7092
+ </xsl:if>
7093
+
7094
+ <xsl:choose>
7095
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7096
+ <xsl:otherwise>
7097
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7098
+ </xsl:otherwise>
7099
+ </xsl:choose>
7100
+
7101
+ </xsl:for-each>
7102
+ </xsl:copy>
7103
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7104
+ <xsl:copy>
7105
+ <xsl:copy-of select="@*"/>
7106
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7107
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7108
+ <xsl:sort select="@displayorder" data-type="number"/>
7109
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7110
+ </xsl:for-each>
7111
+ </xsl:copy>
6890
7112
  </xsl:template><xsl:template name="convertDate">
6891
7113
  <xsl:param name="date"/>
6892
7114
  <xsl:param name="format" select="'short'"/>
@@ -7131,22 +7353,25 @@
7131
7353
  <xsl:param name="pText" select="."/>
7132
7354
  <xsl:param name="sep" select="','"/>
7133
7355
  <xsl:param name="normalize-space" select="'true'"/>
7356
+ <xsl:param name="keep_sep" select="'false'"/>
7134
7357
  <xsl:if test="string-length($pText) &gt;0">
7135
- <item>
7136
- <xsl:choose>
7137
- <xsl:when test="$normalize-space = 'true'">
7138
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7139
- </xsl:when>
7140
- <xsl:otherwise>
7141
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7142
- </xsl:otherwise>
7143
- </xsl:choose>
7144
- </item>
7145
- <xsl:call-template name="split">
7146
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7147
- <xsl:with-param name="sep" select="$sep"/>
7148
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
7149
- </xsl:call-template>
7358
+ <item>
7359
+ <xsl:choose>
7360
+ <xsl:when test="$normalize-space = 'true'">
7361
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7362
+ </xsl:when>
7363
+ <xsl:otherwise>
7364
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7365
+ </xsl:otherwise>
7366
+ </xsl:choose>
7367
+ </item>
7368
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7369
+ <xsl:call-template name="split">
7370
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7371
+ <xsl:with-param name="sep" select="$sep"/>
7372
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7373
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7374
+ </xsl:call-template>
7150
7375
  </xsl:if>
7151
7376
  </xsl:template><xsl:template name="getDocumentId">
7152
7377
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -7337,53 +7562,153 @@
7337
7562
  <xsl:param name="first"/>
7338
7563
  <xsl:if test="$number != ''">
7339
7564
  <xsl:variable name="words">
7340
- <words>
7341
- <word cardinal="1">One-</word>
7342
- <word ordinal="1">First </word>
7343
- <word cardinal="2">Two-</word>
7344
- <word ordinal="2">Second </word>
7345
- <word cardinal="3">Three-</word>
7346
- <word ordinal="3">Third </word>
7347
- <word cardinal="4">Four-</word>
7348
- <word ordinal="4">Fourth </word>
7349
- <word cardinal="5">Five-</word>
7350
- <word ordinal="5">Fifth </word>
7351
- <word cardinal="6">Six-</word>
7352
- <word ordinal="6">Sixth </word>
7353
- <word cardinal="7">Seven-</word>
7354
- <word ordinal="7">Seventh </word>
7355
- <word cardinal="8">Eight-</word>
7356
- <word ordinal="8">Eighth </word>
7357
- <word cardinal="9">Nine-</word>
7358
- <word ordinal="9">Ninth </word>
7359
- <word ordinal="10">Tenth </word>
7360
- <word ordinal="11">Eleventh </word>
7361
- <word ordinal="12">Twelfth </word>
7362
- <word ordinal="13">Thirteenth </word>
7363
- <word ordinal="14">Fourteenth </word>
7364
- <word ordinal="15">Fifteenth </word>
7365
- <word ordinal="16">Sixteenth </word>
7366
- <word ordinal="17">Seventeenth </word>
7367
- <word ordinal="18">Eighteenth </word>
7368
- <word ordinal="19">Nineteenth </word>
7369
- <word cardinal="20">Twenty-</word>
7370
- <word ordinal="20">Twentieth </word>
7371
- <word cardinal="30">Thirty-</word>
7372
- <word ordinal="30">Thirtieth </word>
7373
- <word cardinal="40">Forty-</word>
7374
- <word ordinal="40">Fortieth </word>
7375
- <word cardinal="50">Fifty-</word>
7376
- <word ordinal="50">Fiftieth </word>
7377
- <word cardinal="60">Sixty-</word>
7378
- <word ordinal="60">Sixtieth </word>
7379
- <word cardinal="70">Seventy-</word>
7380
- <word ordinal="70">Seventieth </word>
7381
- <word cardinal="80">Eighty-</word>
7382
- <word ordinal="80">Eightieth </word>
7383
- <word cardinal="90">Ninety-</word>
7384
- <word ordinal="90">Ninetieth </word>
7385
- <word cardinal="100">Hundred-</word>
7386
- <word ordinal="100">Hundredth </word>
7565
+ <words>
7566
+ <xsl:choose>
7567
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
7568
+ <word cardinal="1">Une-</word>
7569
+ <word ordinal="1">Première </word>
7570
+ <word cardinal="2">Deux-</word>
7571
+ <word ordinal="2">Seconde </word>
7572
+ <word cardinal="3">Trois-</word>
7573
+ <word ordinal="3">Tierce </word>
7574
+ <word cardinal="4">Quatre-</word>
7575
+ <word ordinal="4">Quatrième </word>
7576
+ <word cardinal="5">Cinq-</word>
7577
+ <word ordinal="5">Cinquième </word>
7578
+ <word cardinal="6">Six-</word>
7579
+ <word ordinal="6">Sixième </word>
7580
+ <word cardinal="7">Sept-</word>
7581
+ <word ordinal="7">Septième </word>
7582
+ <word cardinal="8">Huit-</word>
7583
+ <word ordinal="8">Huitième </word>
7584
+ <word cardinal="9">Neuf-</word>
7585
+ <word ordinal="9">Neuvième </word>
7586
+ <word ordinal="10">Dixième </word>
7587
+ <word ordinal="11">Onzième </word>
7588
+ <word ordinal="12">Douzième </word>
7589
+ <word ordinal="13">Treizième </word>
7590
+ <word ordinal="14">Quatorzième </word>
7591
+ <word ordinal="15">Quinzième </word>
7592
+ <word ordinal="16">Seizième </word>
7593
+ <word ordinal="17">Dix-septième </word>
7594
+ <word ordinal="18">Dix-huitième </word>
7595
+ <word ordinal="19">Dix-neuvième </word>
7596
+ <word cardinal="20">Vingt-</word>
7597
+ <word ordinal="20">Vingtième </word>
7598
+ <word cardinal="30">Trente-</word>
7599
+ <word ordinal="30">Trentième </word>
7600
+ <word cardinal="40">Quarante-</word>
7601
+ <word ordinal="40">Quarantième </word>
7602
+ <word cardinal="50">Cinquante-</word>
7603
+ <word ordinal="50">Cinquantième </word>
7604
+ <word cardinal="60">Soixante-</word>
7605
+ <word ordinal="60">Soixantième </word>
7606
+ <word cardinal="70">Septante-</word>
7607
+ <word ordinal="70">Septantième </word>
7608
+ <word cardinal="80">Huitante-</word>
7609
+ <word ordinal="80">Huitantième </word>
7610
+ <word cardinal="90">Nonante-</word>
7611
+ <word ordinal="90">Nonantième </word>
7612
+ <word cardinal="100">Cent-</word>
7613
+ <word ordinal="100">Centième </word>
7614
+ </xsl:when>
7615
+ <xsl:when test="$lang = 'ru'">
7616
+ <word cardinal="1">Одна-</word>
7617
+ <word ordinal="1">Первое </word>
7618
+ <word cardinal="2">Две-</word>
7619
+ <word ordinal="2">Второе </word>
7620
+ <word cardinal="3">Три-</word>
7621
+ <word ordinal="3">Третье </word>
7622
+ <word cardinal="4">Четыре-</word>
7623
+ <word ordinal="4">Четвертое </word>
7624
+ <word cardinal="5">Пять-</word>
7625
+ <word ordinal="5">Пятое </word>
7626
+ <word cardinal="6">Шесть-</word>
7627
+ <word ordinal="6">Шестое </word>
7628
+ <word cardinal="7">Семь-</word>
7629
+ <word ordinal="7">Седьмое </word>
7630
+ <word cardinal="8">Восемь-</word>
7631
+ <word ordinal="8">Восьмое </word>
7632
+ <word cardinal="9">Девять-</word>
7633
+ <word ordinal="9">Девятое </word>
7634
+ <word ordinal="10">Десятое </word>
7635
+ <word ordinal="11">Одиннадцатое </word>
7636
+ <word ordinal="12">Двенадцатое </word>
7637
+ <word ordinal="13">Тринадцатое </word>
7638
+ <word ordinal="14">Четырнадцатое </word>
7639
+ <word ordinal="15">Пятнадцатое </word>
7640
+ <word ordinal="16">Шестнадцатое </word>
7641
+ <word ordinal="17">Семнадцатое </word>
7642
+ <word ordinal="18">Восемнадцатое </word>
7643
+ <word ordinal="19">Девятнадцатое </word>
7644
+ <word cardinal="20">Двадцать-</word>
7645
+ <word ordinal="20">Двадцатое </word>
7646
+ <word cardinal="30">Тридцать-</word>
7647
+ <word ordinal="30">Тридцатое </word>
7648
+ <word cardinal="40">Сорок-</word>
7649
+ <word ordinal="40">Сороковое </word>
7650
+ <word cardinal="50">Пятьдесят-</word>
7651
+ <word ordinal="50">Пятидесятое </word>
7652
+ <word cardinal="60">Шестьдесят-</word>
7653
+ <word ordinal="60">Шестидесятое </word>
7654
+ <word cardinal="70">Семьдесят-</word>
7655
+ <word ordinal="70">Семидесятое </word>
7656
+ <word cardinal="80">Восемьдесят-</word>
7657
+ <word ordinal="80">Восьмидесятое </word>
7658
+ <word cardinal="90">Девяносто-</word>
7659
+ <word ordinal="90">Девяностое </word>
7660
+ <word cardinal="100">Сто-</word>
7661
+ <word ordinal="100">Сотое </word>
7662
+ </xsl:when>
7663
+ <xsl:otherwise> <!-- default english -->
7664
+ <word cardinal="1">One-</word>
7665
+ <word ordinal="1">First </word>
7666
+ <word cardinal="2">Two-</word>
7667
+ <word ordinal="2">Second </word>
7668
+ <word cardinal="3">Three-</word>
7669
+ <word ordinal="3">Third </word>
7670
+ <word cardinal="4">Four-</word>
7671
+ <word ordinal="4">Fourth </word>
7672
+ <word cardinal="5">Five-</word>
7673
+ <word ordinal="5">Fifth </word>
7674
+ <word cardinal="6">Six-</word>
7675
+ <word ordinal="6">Sixth </word>
7676
+ <word cardinal="7">Seven-</word>
7677
+ <word ordinal="7">Seventh </word>
7678
+ <word cardinal="8">Eight-</word>
7679
+ <word ordinal="8">Eighth </word>
7680
+ <word cardinal="9">Nine-</word>
7681
+ <word ordinal="9">Ninth </word>
7682
+ <word ordinal="10">Tenth </word>
7683
+ <word ordinal="11">Eleventh </word>
7684
+ <word ordinal="12">Twelfth </word>
7685
+ <word ordinal="13">Thirteenth </word>
7686
+ <word ordinal="14">Fourteenth </word>
7687
+ <word ordinal="15">Fifteenth </word>
7688
+ <word ordinal="16">Sixteenth </word>
7689
+ <word ordinal="17">Seventeenth </word>
7690
+ <word ordinal="18">Eighteenth </word>
7691
+ <word ordinal="19">Nineteenth </word>
7692
+ <word cardinal="20">Twenty-</word>
7693
+ <word ordinal="20">Twentieth </word>
7694
+ <word cardinal="30">Thirty-</word>
7695
+ <word ordinal="30">Thirtieth </word>
7696
+ <word cardinal="40">Forty-</word>
7697
+ <word ordinal="40">Fortieth </word>
7698
+ <word cardinal="50">Fifty-</word>
7699
+ <word ordinal="50">Fiftieth </word>
7700
+ <word cardinal="60">Sixty-</word>
7701
+ <word ordinal="60">Sixtieth </word>
7702
+ <word cardinal="70">Seventy-</word>
7703
+ <word ordinal="70">Seventieth </word>
7704
+ <word cardinal="80">Eighty-</word>
7705
+ <word ordinal="80">Eightieth </word>
7706
+ <word cardinal="90">Ninety-</word>
7707
+ <word ordinal="90">Ninetieth </word>
7708
+ <word cardinal="100">Hundred-</word>
7709
+ <word ordinal="100">Hundredth </word>
7710
+ </xsl:otherwise>
7711
+ </xsl:choose>
7387
7712
  </words>
7388
7713
  </xsl:variable>
7389
7714
 
@@ -7457,4 +7782,18 @@
7457
7782
  <xsl:otherwise>_</xsl:otherwise>
7458
7783
  </xsl:choose>
7459
7784
  </xsl:attribute>
7785
+ </xsl:template><xsl:template name="substring-after-last">
7786
+ <xsl:param name="value"/>
7787
+ <xsl:param name="delimiter"/>
7788
+ <xsl:choose>
7789
+ <xsl:when test="contains($value, $delimiter)">
7790
+ <xsl:call-template name="substring-after-last">
7791
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
7792
+ <xsl:with-param name="delimiter" select="$delimiter"/>
7793
+ </xsl:call-template>
7794
+ </xsl:when>
7795
+ <xsl:otherwise>
7796
+ <xsl:value-of select="$value"/>
7797
+ </xsl:otherwise>
7798
+ </xsl:choose>
7460
7799
  </xsl:template></xsl:stylesheet>