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.
@@ -57,8 +57,21 @@
57
57
  <xsl:copy-of select="@id"/>
58
58
  <xsl:variable name="title">
59
59
  <xsl:apply-templates select=".//ogc:p[@class = 'RecommendationTitle'][ancestor::ogc:table[1][@id= $table_id]]/node()"/>
60
+ <xsl:if test=".//ogc:p[@class = 'RecommendationLabel'][ancestor::ogc:table[1][@id= $table_id]]/node()">
61
+ <xsl:text>: </xsl:text>
62
+ <xsl:variable name="recommendationLabel">
63
+ <tt><xsl:copy-of select=".//ogc:p[@class = 'RecommendationLabel'][ancestor::ogc:table[1][@id= $table_id]]/node()"/></tt>
64
+ </xsl:variable>
65
+ <xsl:apply-templates select="xalan:nodeset($recommendationLabel)/node()"/>
66
+ </xsl:if>
67
+ </xsl:variable>
68
+ <xsl:variable name="bookmark">
69
+ <xsl:value-of select="normalize-space(.//ogc:p[@class = 'RecommendationTitle'][ancestor::ogc:table[1][@id= $table_id]]/node())"/>
70
+ <xsl:if test=".//ogc:p[@class = 'RecommendationLabel'][ancestor::ogc:table[1][@id= $table_id]]/node()">
71
+ <xsl:text>: </xsl:text>
72
+ <xsl:value-of select="normalize-space(.//ogc:p[@class = 'RecommendationLabel'][ancestor::ogc:table[1][@id= $table_id]]/node())"/>
73
+ </xsl:if>
60
74
  </xsl:variable>
61
- <xsl:variable name="bookmark" select="normalize-space(.//ogc:p[@class = 'RecommendationTitle'][ancestor::ogc:table[1][@id= $table_id]]/node())"/>
62
75
  <xsl:variable name="regex_str" select="'^([^0-9]+) (\d+).*'"/>
63
76
  <xsl:variable name="class" select="java:replaceAll(java:java.lang.String.new($bookmark), $regex_str, '$1')"/>
64
77
  <xsl:variable name="num" select="java:replaceAll(java:java.lang.String.new($bookmark), $regex_str, '$2')"/>
@@ -100,42 +113,20 @@
100
113
  </xsl:for-each>
101
114
  </xsl:variable>
102
115
 
103
- <xsl:variable name="contents">
116
+ <xsl:variable name="contents_">
104
117
  <contents>
105
-
106
118
  <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
107
- <!-- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/*" mode="contents"/> -->
108
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:abstract" mode="contents"/>
109
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'executivesummary']" mode="contents"/>
110
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'keywords']" mode="contents"/>
111
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:foreword" mode="contents"/>
112
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'security']" mode="contents"/>
113
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'submitting_orgs']" mode="contents"/>
114
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:submitters" mode="contents"/>
115
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:introduction" mode="contents"/>
116
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[not(@type = 'executivesummary') and not(@type = 'security') and not(@type = 'submitting_orgs') and not(@type = 'keywords')]" mode="contents"/>
117
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:acknowledgements" mode="contents"/>
118
-
119
-
120
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='scope']" mode="contents"/>
121
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='conformance']" mode="contents"/>
122
- <!-- Normative references -->
123
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[@normative='true']" mode="contents"/>
124
- <!-- Terms and definitions -->
125
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:terms" mode="contents"/>
126
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:definitions" mode="contents"/>
127
-
128
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[not(@type='scope') and not(@type='conformance')]" mode="contents"/>
129
-
130
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:annex" mode="contents"/>
131
-
132
- <!-- Bibliography -->
133
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[not(@normative='true')]" mode="contents"/>
119
+ <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
134
120
 
121
+ <xsl:call-template name="processMainSectionsDefault_Contents"/>
122
+ <xsl:apply-templates select="//ogc:indexsect" mode="contents"/>
135
123
 
124
+ <xsl:call-template name="processTablesFigures_Contents">
125
+ <xsl:with-param name="always">true</xsl:with-param>
126
+ </xsl:call-template>
136
127
  </contents>
137
128
  </xsl:variable>
138
-
129
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
139
130
 
140
131
  <xsl:template match="/">
141
132
  <xsl:call-template name="namespaceCheck"/>
@@ -236,9 +227,22 @@
236
227
  </fo:table>
237
228
  </fo:block>
238
229
 
239
- <fo:block-container absolute-position="fixed" left="16.5mm" top="83mm" height="90mm">
240
- <fo:block-container width="155mm">
230
+ <!-- <fo:block-container absolute-position="fixed" left="16.5mm" top="83mm" height="90mm"> -->
231
+ <fo:block-container absolute-position="fixed" left="16.5mm" top="40mm" height="170mm">
232
+ <fo:block-container width="155mm" height="99%" display-align="center">
241
233
  <fo:block font-size="33pt" role="H1">
234
+ <xsl:variable name="length_title" select="string-length($doctitle)"/>
235
+ <xsl:variable name="fit_font-size">
236
+ <xsl:choose>
237
+ <xsl:when test="$length_title &gt; 230">20</xsl:when>
238
+ <xsl:when test="$length_title &gt; 170">26</xsl:when>
239
+ <xsl:when test="$length_title &gt; 155">28</xsl:when>
240
+ <xsl:when test="$length_title &gt; 130">30</xsl:when>
241
+ </xsl:choose>
242
+ </xsl:variable>
243
+ <xsl:if test="normalize-space($fit_font-size) != ''">
244
+ <xsl:attribute name="font-size"><xsl:value-of select="$fit_font-size"/>pt</xsl:attribute>
245
+ </xsl:if>
242
246
  <xsl:call-template name="addLetterSpacing">
243
247
  <xsl:with-param name="text" select="java:toUpperCase(java:java.lang.String.new($doctitle))"/>
244
248
  <xsl:with-param name="letter-spacing" select="1.1"/>
@@ -433,7 +437,7 @@
433
437
 
434
438
  <fo:block-container line-height="130%">
435
439
  <fo:block role="TOC">
436
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true' and normalize-space(@id) != '']">
440
+ <xsl:for-each select="$contents//item[@display = 'true' and normalize-space(@id) != '']">
437
441
 
438
442
  <fo:block role="TOCI">
439
443
  <xsl:if test="@level = 1">
@@ -442,7 +446,7 @@
442
446
  <xsl:if test="@level = 1 or @parent = 'annex'">
443
447
  <xsl:attribute name="font-size">12pt</xsl:attribute>
444
448
  </xsl:if>
445
- <xsl:if test="@level &gt;= 2 and not(@parent = 'annex')">
449
+ <xsl:if test="@level &gt;= 2"> <!-- and not(@parent = 'annex') -->
446
450
  <xsl:attribute name="font-size">10pt</xsl:attribute>
447
451
  </xsl:if>
448
452
 
@@ -510,100 +514,37 @@
510
514
  </fo:block>
511
515
  </fo:block-container>
512
516
 
513
- <xsl:if test="//ogc:table[@id and ogc:name]"> <!-- contains(ogc:name, '—') -->
514
- <xsl:variable name="title-list-tables">
515
- <xsl:call-template name="getTitle">
516
- <xsl:with-param name="name" select="'title-list-tables'"/>
517
- </xsl:call-template>
518
- </xsl:variable>
519
-
520
- <fo:block-container margin-left="-18mm" keep-with-next="always" margin-bottom="10pt" space-before="36pt">
521
- <fo:block-container margin-left="0mm">
522
- <xsl:call-template name="insertSectionTitle">
523
- <xsl:with-param name="title" select="$title-list-tables"/>
524
- </xsl:call-template>
525
- </fo:block-container>
526
- </fo:block-container>
517
+
518
+ <!-- List of Tables -->
519
+ <xsl:if test="$contents//tables/table">
520
+ <xsl:call-template name="insertListOf_Title">
521
+ <xsl:with-param name="title" select="$title-list-tables"/>
522
+ </xsl:call-template>
527
523
  <fo:block-container line-height="130%">
528
- <xsl:for-each select="//ogc:table[@id and ogc:name and normalize-space(@id) != '']"> <!-- contains(ogc:name, '—') -->
529
- <fo:block text-align-last="justify" margin-top="2pt" role="TOCI">
530
- <fo:basic-link internal-destination="{@id}">
531
- <xsl:call-template name="setAltText">
532
- <xsl:with-param name="value" select="ogc:name"/>
533
- </xsl:call-template>
534
- <xsl:apply-templates select="ogc:name" mode="contents"/>
535
- <fo:inline keep-together.within-line="always">
536
- <fo:leader leader-pattern="dots"/>
537
- <fo:page-number-citation ref-id="{@id}"/>
538
- </fo:inline>
539
- </fo:basic-link>
540
- </fo:block>
524
+ <xsl:for-each select="$contents//tables/table">
525
+ <xsl:call-template name="insertListOf_Item"/>
541
526
  </xsl:for-each>
542
- </fo:block-container>
527
+ </fo:block-container>
543
528
  </xsl:if>
544
529
 
545
- <xsl:variable name="list_of_figures_">
546
- <xsl:for-each select="//ogc:figure[@id and ogc:name and not(@unnumbered = 'true') and normalize-space(@id) != ''] | //*[@id and starts-with(ogc:name, 'Figure ') and normalize-space(@id) != '']">
547
- <figure id="{@id}" alt-text="{ogc:name}">
548
- <xsl:apply-templates select="ogc:name" mode="contents"/>
549
- </figure>
550
- </xsl:for-each>
551
- </xsl:variable>
552
- <xsl:variable name="list_of_figures" select="xalan:nodeset($list_of_figures_)"/>
553
-
554
- <!-- <xsl:if test="//ogc:figure[@id and ogc:name and not(@unnumbered = 'true')] or //*[@id and starts-with(ogc:name, 'Figure ')]"> --> <!-- contains(ogc:name, '—') -->
555
- <xsl:if test="$list_of_figures//figure">
556
- <xsl:variable name="title-list-figures">
557
- <xsl:call-template name="getTitle">
558
- <xsl:with-param name="name" select="'title-list-figures'"/>
559
- </xsl:call-template>
560
- </xsl:variable>
561
- <fo:block-container margin-left="-18mm" keep-with-next="always" margin-bottom="10pt" space-before="36pt">
562
- <fo:block-container margin-left="0mm">
563
- <xsl:call-template name="insertSectionTitle">
564
- <xsl:with-param name="title" select="$title-list-figures"/>
565
- </xsl:call-template>
566
- </fo:block-container>
567
- </fo:block-container>
568
-
530
+ <!-- List of Figures -->
531
+ <xsl:if test="$contents//figures/figure">
532
+ <xsl:call-template name="insertListOf_Title">
533
+ <xsl:with-param name="title" select="$title-list-figures"/>
534
+ </xsl:call-template>
569
535
  <fo:block-container line-height="130%">
570
- <!-- <xsl:for-each select="//ogc:figure[@id and ogc:name and not(@unnumbered = 'true')] or //*[@id and starts-with(ogc:name, 'Figure ')]"> --> <!-- contains(ogc:name, '—') -->
571
- <xsl:for-each select="$list_of_figures/figure"> <!-- contains(ogc:name, '—') -->
572
- <fo:block text-align-last="justify" margin-top="2pt" role="TOCI">
573
- <fo:basic-link internal-destination="{@id}">
574
- <xsl:call-template name="setAltText">
575
- <xsl:with-param name="value" select="@alt-text"/>
576
- </xsl:call-template>
577
- <!-- <xsl:apply-templates select="ogc:name" mode="contents"/> -->
578
- <xsl:copy-of select="node()"/>
579
- <fo:inline keep-together.within-line="always">
580
- <fo:leader leader-pattern="dots"/>
581
- <fo:page-number-citation ref-id="{@id}"/>
582
- </fo:inline>
583
- </fo:basic-link>
584
- </fo:block>
536
+ <xsl:for-each select="$contents//figures/figure">
537
+ <xsl:call-template name="insertListOf_Item"/>
585
538
  </xsl:for-each>
586
- </fo:block-container>
539
+ </fo:block-container>
587
540
  </xsl:if>
588
541
 
589
- <!-- <xsl:if test="//ogc:permission[@id and ogc:name] or //ogc:recommendation[@id and ogc:name] or //ogc:requirement[@id and ogc:name]"> -->
542
+ <!-- List of Recommendations -->
590
543
  <xsl:if test="//ogc:table[.//ogc:p[@class = 'RecommendationTitle']]">
591
- <xsl:variable name="title-list-recommendations">
592
- <xsl:call-template name="getTitle">
593
- <xsl:with-param name="name" select="'title-list-recommendations'"/>
594
- </xsl:call-template>
595
- </xsl:variable>
596
-
597
- <fo:block-container margin-left="-18mm" keep-with-next="always" margin-bottom="10pt" space-before="36pt">
598
- <fo:block-container margin-left="0mm">
599
- <xsl:call-template name="insertSectionTitle">
600
- <xsl:with-param name="title" select="$title-list-recommendations"/>
601
- </xsl:call-template>
602
- </fo:block-container>
603
- </fo:block-container>
604
-
544
+ <xsl:call-template name="insertListOf_Title">
545
+ <xsl:with-param name="title" select="$title-list-recommendations"/>
546
+ </xsl:call-template>
605
547
  <fo:block-container line-height="130%">
606
- <!-- <xsl:for-each select="//ogc:table[.//ogc:p[@class = 'RecommendationTitle']]"> -->
607
548
  <xsl:for-each select="xalan:nodeset($toc_recommendations)/*[normalize-space(@id) != '']">
608
549
  <fo:block text-align-last="justify" margin-top="6pt" role="TOCI">
609
550
  <fo:basic-link internal-destination="{@id}">
@@ -620,7 +561,6 @@
620
561
  </fo:block>
621
562
  </xsl:for-each>
622
563
  </fo:block-container>
623
-
624
564
  </xsl:if>
625
565
 
626
566
  </fo:block>
@@ -629,66 +569,81 @@
629
569
 
630
570
  <fo:block line-height="125%">
631
571
  <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
632
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:abstract"/>
633
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'executivesummary']"/>
634
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'keywords']"/>
635
- <xsl:if test="/ogc:ogc-standard/ogc:preface/ogc:foreword">
636
- <fo:block break-after="page"/>
637
- </xsl:if>
638
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:foreword"/>
639
-
640
- <xsl:if test="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'security']">
641
- <fo:block break-after="page"/>
642
- </xsl:if>
643
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'security']"/>
644
-
645
- <xsl:if test="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'submitting_orgs']">
646
- <fo:block break-after="page"/>
647
- </xsl:if>
648
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[@type = 'submitting_orgs']"/>
649
-
650
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:submitters"/>
651
- <xsl:if test="/ogc:ogc-standard/ogc:preface/ogc:introduction">
652
- <fo:block break-after="page"/>
653
- </xsl:if>
654
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:introduction"/>
655
-
656
572
 
573
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
574
+ <xsl:sort select="@displayorder" data-type="number"/>
575
+
576
+ <xsl:if test="local-name() = 'foreword' or (local-name() = 'clause' and @type = 'security') or (local-name() = 'clause' and @type = 'submitting_orgs') or local-name() = 'introduction'">
577
+ <fo:block break-after="page"/>
578
+ </xsl:if>
579
+
580
+ <xsl:apply-templates select="."/>
581
+ </xsl:for-each>
657
582
 
658
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:clause[not(@type = 'executivesummary') and not(@type = 'security') and not(@type = 'submitting_orgs') and not(@type = 'keywords')]"/>
659
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:preface/ogc:acknowledgements"/>
660
583
  </fo:block>
661
584
  </fo:flow>
662
585
  </fo:page-sequence>
663
586
 
664
587
 
665
588
  <!-- Document Pages -->
589
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
590
+ <xsl:sort select="@displayorder" data-type="number"/>
591
+ <xsl:choose>
592
+ <xsl:when test="local-name() = 'clause' and @type='scope'">
593
+ <xsl:apply-templates select="." mode="sections">
594
+ <xsl:with-param name="initial-page-number" select="1"/>
595
+ </xsl:apply-templates>
596
+ </xsl:when>
597
+ <xsl:otherwise>
598
+ <xsl:apply-templates select="." mode="sections"/>
599
+ </xsl:otherwise>
600
+ </xsl:choose>
601
+ </xsl:for-each>
666
602
 
667
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='scope']" mode="sections">
668
- <xsl:with-param name="initial-page-number" select="1"/>
669
- </xsl:apply-templates>
670
-
671
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[@type='conformance']" mode="sections"/>
672
-
673
- <!-- Normative references -->
674
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[@normative='true']" mode="sections"/>
675
-
676
- <!-- Terms and definitions -->
677
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:terms" mode="sections"/>
678
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:definitions" mode="sections"/>
679
-
680
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:sections/ogc:clause[not(@type='scope') and not(@type='conformance')]" mode="sections"/>
681
-
682
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:annex" mode="sections"/>
603
+ <xsl:for-each select="/*/*[local-name()='annex']">
604
+ <xsl:sort select="@displayorder" data-type="number"/>
605
+ <xsl:apply-templates select="." mode="sections"/>
606
+ </xsl:for-each>
683
607
 
684
608
  <!-- Bibliography -->
685
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibliography/ogc:references[not(@normative='true')]" mode="sections"/>
609
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
610
+ <xsl:sort select="@displayorder" data-type="number"/>
611
+ <xsl:apply-templates select="." mode="sections"/>
612
+ </xsl:for-each>
613
+
614
+ <xsl:apply-templates select="//ogc:indexsect" mode="sections"/>
686
615
 
687
616
  <!-- End Document Pages -->
688
617
 
689
618
  </fo:root>
690
619
  </xsl:template>
691
620
 
621
+ <xsl:template name="insertListOf_Title">
622
+ <xsl:param name="title"/>
623
+ <fo:block-container margin-left="-18mm" keep-with-next="always" margin-bottom="10pt" space-before="36pt">
624
+ <fo:block-container margin-left="0mm">
625
+ <xsl:call-template name="insertSectionTitle">
626
+ <xsl:with-param name="title" select="$title"/>
627
+ </xsl:call-template>
628
+ </fo:block-container>
629
+ </fo:block-container>
630
+ </xsl:template>
631
+
632
+ <xsl:template name="insertListOf_Item">
633
+ <fo:block text-align-last="justify" margin-top="2pt" role="TOCI">
634
+ <fo:basic-link internal-destination="{@id}">
635
+ <xsl:call-template name="setAltText">
636
+ <xsl:with-param name="value" select="@alt-text"/>
637
+ </xsl:call-template>
638
+ <!-- <xsl:copy-of select="node()"/> -->
639
+ <xsl:apply-templates select="." mode="contents"/>
640
+ <fo:inline keep-together.within-line="always">
641
+ <fo:leader leader-pattern="dots"/>
642
+ <fo:page-number-citation ref-id="{@id}"/>
643
+ </fo:inline>
644
+ </fo:basic-link>
645
+ </fo:block>
646
+ </xsl:template>
692
647
 
693
648
  <!-- Lato font doesn't contain 'thin space' glyph -->
694
649
  <xsl:template match="text()" priority="1">
@@ -1059,7 +1014,14 @@
1059
1014
 
1060
1015
 
1061
1016
  <xsl:template match="ogc:ul | ogc:ol" mode="list" priority="2">
1017
+ <xsl:variable name="ul_indent">6mm</xsl:variable>
1062
1018
  <fo:block-container margin-left="13mm">
1019
+ <xsl:if test="self::ogc:ul and not(ancestor::ogc:ul) and not(ancestor::ogc:ol)"> <!-- if first level -->
1020
+ <xsl:attribute name="margin-left">4mm</xsl:attribute>
1021
+ </xsl:if>
1022
+ <xsl:if test="self::ogc:ul and ancestor::*[2][self::ogc:ul]"> <!-- ul/li/ul -->
1023
+ <xsl:attribute name="margin-left"><xsl:value-of select="$ul_indent"/></xsl:attribute>
1024
+ </xsl:if>
1063
1025
  <xsl:if test="ancestor::ogc:table">
1064
1026
  <xsl:attribute name="margin-left">4mm</xsl:attribute>
1065
1027
  </xsl:if>
@@ -1071,6 +1033,9 @@
1071
1033
  </xsl:if>
1072
1034
  <fo:block-container margin-left="0mm">
1073
1035
  <fo:list-block xsl:use-attribute-sets="list-style">
1036
+ <xsl:if test="self::ogc:ul">
1037
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$ul_indent"/></xsl:attribute>
1038
+ </xsl:if>
1074
1039
  <xsl:if test="ancestor::ogc:table">
1075
1040
  <xsl:attribute name="provisional-distance-between-starts">5mm</xsl:attribute>
1076
1041
  </xsl:if>
@@ -1512,6 +1477,10 @@
1512
1477
  <xsl:text>Édition </xsl:text>
1513
1478
  </title-edition>
1514
1479
 
1480
+ <title-edition lang="ru">
1481
+ <xsl:text>Издание </xsl:text>
1482
+ </title-edition>
1483
+
1515
1484
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1516
1485
  <title-toc lang="en">
1517
1486
 
@@ -1528,7 +1497,7 @@
1528
1497
  <xsl:text>Contents</xsl:text>
1529
1498
 
1530
1499
  </title-toc>
1531
-
1500
+
1532
1501
  <title-descriptors lang="en">Descriptors</title-descriptors>
1533
1502
 
1534
1503
  <title-part lang="en">
@@ -1540,7 +1509,11 @@
1540
1509
 
1541
1510
 
1542
1511
 
1543
- </title-part>
1512
+ </title-part>
1513
+ <title-part lang="ru">
1514
+
1515
+
1516
+ </title-part>
1544
1517
  <title-part lang="zh">第 # 部分:</title-part>
1545
1518
 
1546
1519
  <title-subpart lang="en">Sub-part #</title-subpart>
@@ -1556,10 +1529,35 @@
1556
1529
 
1557
1530
  <title-summary lang="en">Summary</title-summary>
1558
1531
 
1532
+ <title-continued lang="ru">(продолжение)</title-continued>
1559
1533
  <title-continued lang="en">(continued)</title-continued>
1560
1534
  <title-continued lang="fr">(continué)</title-continued>
1561
1535
 
1562
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
1536
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
1537
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
1538
+ <xsl:value-of select="$toc_table_title"/>
1539
+ <xsl:if test="normalize-space($toc_table_title) = ''">
1540
+ <xsl:call-template name="getTitle">
1541
+ <xsl:with-param name="name" select="'title-list-tables'"/>
1542
+ </xsl:call-template>
1543
+ </xsl:if>
1544
+ </xsl:variable><xsl:variable name="title-list-figures">
1545
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
1546
+ <xsl:value-of select="$toc_figure_title"/>
1547
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
1548
+ <xsl:call-template name="getTitle">
1549
+ <xsl:with-param name="name" select="'title-list-figures'"/>
1550
+ </xsl:call-template>
1551
+ </xsl:if>
1552
+ </xsl:variable><xsl:variable name="title-list-recommendations">
1553
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
1554
+ <xsl:value-of select="$toc_requirement_title"/>
1555
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
1556
+ <xsl:call-template name="getTitle">
1557
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
1558
+ </xsl:call-template>
1559
+ </xsl:if>
1560
+ </xsl:variable><xsl:variable name="bibdata">
1563
1561
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1564
1562
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1565
1563
  </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">
@@ -2383,13 +2381,19 @@
2383
2381
  </xsl:attribute-set><xsl:variable name="color-added-text">
2384
2382
  <xsl:text>rgb(0, 255, 0)</xsl:text>
2385
2383
  </xsl:variable><xsl:attribute-set name="add-style">
2386
- <xsl:attribute name="color">red</xsl:attribute>
2387
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
2388
- <!-- <xsl:attribute name="color">black</xsl:attribute>
2389
- <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2390
- <xsl:attribute name="padding-top">1mm</xsl:attribute>
2391
- <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2392
- </xsl:attribute-set><xsl:variable name="color-deleted-text">
2384
+
2385
+ <xsl:attribute name="color">red</xsl:attribute>
2386
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
2387
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
2388
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2389
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
2390
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2391
+
2392
+ </xsl:attribute-set><xsl:variable name="add-style">
2393
+ <add-style xsl:use-attribute-sets="add-style"/>
2394
+ </xsl:variable><xsl:template name="append_add-style">
2395
+ <xsl:copy-of select="xalan:nodeset($add-style)/add-style/@*"/>
2396
+ </xsl:template><xsl:variable name="color-deleted-text">
2393
2397
  <xsl:text>red</xsl:text>
2394
2398
  </xsl:variable><xsl:attribute-set name="del-style">
2395
2399
  <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
@@ -2833,14 +2837,42 @@
2833
2837
 
2834
2838
 
2835
2839
  </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">
2840
+ <xsl:variable name="nodes_preface_">
2841
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2842
+ <node id="{@id}"/>
2843
+ </xsl:for-each>
2844
+ </xsl:variable>
2845
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2846
+
2836
2847
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2837
2848
  <xsl:sort select="@displayorder" data-type="number"/>
2849
+
2850
+ <!-- process Section's title -->
2851
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2852
+ <xsl:if test="$preceding-sibling_id != ''">
2853
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2854
+ </xsl:if>
2855
+
2838
2856
  <xsl:apply-templates select="." mode="contents"/>
2839
2857
  </xsl:for-each>
2840
2858
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2841
2859
 
2860
+ <xsl:variable name="nodes_sections_">
2861
+ <xsl:for-each select="/*/*[local-name()='sections']/*">
2862
+ <node id="{@id}"/>
2863
+ </xsl:for-each>
2864
+ </xsl:variable>
2865
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
2866
+
2842
2867
  <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']]">
2843
2868
  <xsl:sort select="@displayorder" data-type="number"/>
2869
+
2870
+ <!-- process Section's title -->
2871
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
2872
+ <xsl:if test="$preceding-sibling_id != ''">
2873
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="contents_no_displayorder"/>
2874
+ </xsl:if>
2875
+
2844
2876
  <xsl:apply-templates select="." mode="contents"/>
2845
2877
  </xsl:for-each>
2846
2878
 
@@ -2853,6 +2885,30 @@
2853
2885
  <xsl:sort select="@displayorder" data-type="number"/>
2854
2886
  <xsl:apply-templates select="." mode="contents"/>
2855
2887
  </xsl:for-each>
2888
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2889
+ <xsl:param name="always"/>
2890
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2891
+ <xsl:call-template name="processTables_Contents"/>
2892
+ </xsl:if>
2893
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2894
+ <xsl:call-template name="processFigures_Contents"/>
2895
+ </xsl:if>
2896
+ </xsl:template><xsl:template name="processTables_Contents">
2897
+ <tables>
2898
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2899
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2900
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2901
+ </table>
2902
+ </xsl:for-each>
2903
+ </tables>
2904
+ </xsl:template><xsl:template name="processFigures_Contents">
2905
+ <figures>
2906
+ <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) != '']">
2907
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2908
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2909
+ </figure>
2910
+ </xsl:for-each>
2911
+ </figures>
2856
2912
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2857
2913
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2858
2914
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -3001,7 +3057,7 @@
3001
3057
  </xsl:call-template>
3002
3058
  </xsl:if>
3003
3059
  </xsl:variable>
3004
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3060
+ <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3005
3061
 
3006
3062
 
3007
3063
  <xsl:variable name="margin-side">
@@ -3267,7 +3323,7 @@
3267
3323
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3268
3324
  <!-- 2009 thinspace -->
3269
3325
  <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', ' ')"/> -->
3270
- <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/>
3326
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3271
3327
  </xsl:call-template>
3272
3328
  </xsl:variable>
3273
3329
  <xsl:variable name="max_length">
@@ -3658,37 +3714,7 @@
3658
3714
 
3659
3715
  <!-- list of footnotes to calculate actual footnotes number -->
3660
3716
  <xsl:variable name="p_fn_">
3661
- <xsl:choose>
3662
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3663
- <fn gen_id="{generate-id(.)}">
3664
- <xsl:copy-of select="@*"/>
3665
- <xsl:copy-of select="node()"/>
3666
- </fn>
3667
- </xsl:when>
3668
- <xsl:otherwise>
3669
- <!-- itetation for:
3670
- footnotes in bibdata/title
3671
- footnotes in bibliography
3672
- footnotes in document's body (except table's head/body/foot and figure text)
3673
- -->
3674
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3675
- <fn gen_id="{generate-id(.)}">
3676
- <xsl:copy-of select="@*"/>
3677
- <xsl:copy-of select="node()"/>
3678
- </fn>
3679
- </xsl:for-each>
3680
- <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']/*">
3681
- <xsl:sort select="@displayorder" data-type="number"/>
3682
- <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])]">
3683
- <!-- copy unique fn -->
3684
- <fn gen_id="{generate-id(.)}">
3685
- <xsl:copy-of select="@*"/>
3686
- <xsl:copy-of select="node()"/>
3687
- </fn>
3688
- </xsl:for-each>
3689
- </xsl:for-each>
3690
- </xsl:otherwise>
3691
- </xsl:choose>
3717
+ <xsl:call-template name="get_fn_list"/>
3692
3718
  </xsl:variable>
3693
3719
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3694
3720
 
@@ -3749,6 +3775,38 @@
3749
3775
  <xsl:copy-of select="$footnote_inline"/>
3750
3776
  </xsl:otherwise>
3751
3777
  </xsl:choose>
3778
+ </xsl:template><xsl:template name="get_fn_list">
3779
+ <xsl:choose>
3780
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3781
+ <fn gen_id="{generate-id(.)}">
3782
+ <xsl:copy-of select="@*"/>
3783
+ <xsl:copy-of select="node()"/>
3784
+ </fn>
3785
+ </xsl:when>
3786
+ <xsl:otherwise>
3787
+ <!-- itetation for:
3788
+ footnotes in bibdata/title
3789
+ footnotes in bibliography
3790
+ footnotes in document's body (except table's head/body/foot and figure text)
3791
+ -->
3792
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3793
+ <fn gen_id="{generate-id(.)}">
3794
+ <xsl:copy-of select="@*"/>
3795
+ <xsl:copy-of select="node()"/>
3796
+ </fn>
3797
+ </xsl:for-each>
3798
+ <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']/*">
3799
+ <xsl:sort select="@displayorder" data-type="number"/>
3800
+ <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])]">
3801
+ <!-- copy unique fn -->
3802
+ <fn gen_id="{generate-id(.)}">
3803
+ <xsl:copy-of select="@*"/>
3804
+ <xsl:copy-of select="node()"/>
3805
+ </fn>
3806
+ </xsl:for-each>
3807
+ </xsl:for-each>
3808
+ </xsl:otherwise>
3809
+ </xsl:choose>
3752
3810
  </xsl:template><xsl:template name="table_fn_display">
3753
3811
  <xsl:variable name="references">
3754
3812
 
@@ -3931,7 +3989,7 @@
3931
3989
  </fo:inline>
3932
3990
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3933
3991
  <fo:inline><xsl:value-of select="."/></fo:inline>
3934
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3992
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3935
3993
  <fo:inline>
3936
3994
  <xsl:apply-templates/>
3937
3995
  </fo:inline>
@@ -4907,6 +4965,9 @@
4907
4965
  </fo:inline>
4908
4966
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
4909
4967
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
4968
+ <xsl:if test="parent::*[local-name() = 'add']">
4969
+ <xsl:call-template name="append_add-style"/>
4970
+ </xsl:if>
4910
4971
  <xsl:apply-templates/>
4911
4972
  </fo:basic-link>
4912
4973
  </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
@@ -5008,6 +5069,13 @@
5008
5069
 
5009
5070
 
5010
5071
 
5072
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5073
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
5074
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
5075
+ <xsl:call-template name="append_add-style"/>
5076
+ </xsl:if>
5077
+
5078
+
5011
5079
  <!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
5012
5080
  <xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
5013
5081
  <xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
@@ -5046,6 +5114,12 @@
5046
5114
 
5047
5115
 
5048
5116
 
5117
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
5118
+ <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
5119
+ <xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
5120
+ <xsl:call-template name="append_add-style"/>
5121
+ </xsl:if>
5122
+
5049
5123
  <xsl:apply-templates select="*[local-name() = 'name']"/>
5050
5124
 
5051
5125
  </fo:inline>
@@ -5099,6 +5173,7 @@
5099
5173
  </fo:block>
5100
5174
  </xsl:template><xsl:template match="*[local-name() = 'term']">
5101
5175
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
5176
+
5102
5177
 
5103
5178
 
5104
5179
 
@@ -5537,7 +5612,11 @@
5537
5612
  <xsl:value-of select="."/>
5538
5613
  </xsl:template><xsl:template match="node()" mode="contents">
5539
5614
  <xsl:apply-templates mode="contents"/>
5540
- </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title' or @type = 'section-title']" priority="2" mode="contents">
5615
+ </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">
5616
+ <xsl:call-template name="contents_section-title"/>
5617
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'section-title']" mode="contents_in_clause">
5618
+ <xsl:call-template name="contents_section-title"/>
5619
+ </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">
5541
5620
  <xsl:variable name="level">
5542
5621
  <xsl:call-template name="getLevel">
5543
5622
  <xsl:with-param name="depth" select="@depth"/>
@@ -5606,13 +5685,14 @@
5606
5685
  <xsl:apply-templates mode="bookmarks"/>
5607
5686
  </xsl:template><xsl:template name="addBookmarks">
5608
5687
  <xsl:param name="contents"/>
5609
- <xsl:if test="xalan:nodeset($contents)//item">
5688
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5689
+ <xsl:if test="$contents_nodes//item">
5610
5690
  <fo:bookmark-tree>
5611
5691
  <xsl:choose>
5612
- <xsl:when test="xalan:nodeset($contents)/doc">
5692
+ <xsl:when test="$contents_nodes/doc">
5613
5693
  <xsl:choose>
5614
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5615
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5694
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
5695
+ <xsl:for-each select="$contents_nodes/doc">
5616
5696
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5617
5697
  <xsl:if test="@bundle = 'true'">
5618
5698
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -5663,7 +5743,7 @@
5663
5743
  </xsl:for-each>
5664
5744
  </xsl:when>
5665
5745
  <xsl:otherwise>
5666
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5746
+ <xsl:for-each select="$contents_nodes/doc">
5667
5747
 
5668
5748
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5669
5749
 
@@ -5681,97 +5761,89 @@
5681
5761
  </xsl:choose>
5682
5762
  </xsl:when>
5683
5763
  <xsl:otherwise>
5684
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
5764
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
5765
+
5766
+ <xsl:call-template name="insertFigureBookmarks">
5767
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5768
+ </xsl:call-template>
5769
+
5770
+ <xsl:call-template name="insertTableBookmarks">
5771
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5772
+ <xsl:with-param name="lang" select="@lang"/>
5773
+ </xsl:call-template>
5774
+
5685
5775
  </xsl:otherwise>
5686
5776
  </xsl:choose>
5687
5777
 
5778
+
5688
5779
 
5689
5780
 
5690
5781
 
5691
5782
 
5692
-
5693
- <xsl:variable name="list_of_tables_">
5694
- <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name']]"> <!-- contains(*[local-name() = 'name'], '—') -->
5695
- <table id="{@id}"><xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/></table>
5696
- </xsl:for-each>
5697
- </xsl:variable>
5698
- <xsl:variable name="list_of_tables" select="xalan:nodeset($list_of_tables_)"/>
5699
-
5700
- <xsl:variable name="list_of_figures_">
5701
- <xsl:for-each select="//*[local-name() = 'figure'][@id and *[local-name() = 'name'] and not(@unnumbered = 'true')] | //*[@id and starts-with(*[local-name() = 'name'], 'Figure ')]"> <!-- contains(*[local-name() = 'name'], '—') -->
5702
- <figure id="{@id}"><xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/></figure>
5703
- </xsl:for-each>
5704
- </xsl:variable>
5705
- <xsl:variable name="list_of_figures" select="xalan:nodeset($list_of_figures_)"/>
5706
-
5707
- <xsl:if test="$list_of_tables//table or $list_of_figures/figure or //*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]">
5783
+ <xsl:if test="$contents//tables/table or $contents//figures/figure or //*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]">
5708
5784
  <fo:bookmark internal-destination="empty_bookmark">
5709
5785
  <fo:bookmark-title>—————</fo:bookmark-title>
5710
5786
  </fo:bookmark>
5711
5787
  </xsl:if>
5712
5788
 
5713
- <xsl:if test="$list_of_tables//table">
5714
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {$list_of_tables//table[1]/@id} -->
5789
+ <xsl:if test="$contents//tables/table">
5790
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5715
5791
  <fo:bookmark-title>
5716
- <xsl:call-template name="getTitle">
5717
- <xsl:with-param name="name" select="'title-list-tables'"/>
5718
- </xsl:call-template>
5792
+ <xsl:value-of select="$title-list-tables"/>
5719
5793
  </fo:bookmark-title>
5720
- <xsl:for-each select="$list_of_tables//table">
5794
+ <xsl:for-each select="$contents//tables/table">
5721
5795
  <fo:bookmark internal-destination="{@id}">
5722
- <fo:bookmark-title><xsl:value-of select="."/></fo:bookmark-title>
5796
+ <xsl:variable name="title">
5797
+ <xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/>
5798
+ </xsl:variable>
5799
+ <fo:bookmark-title><xsl:value-of select="$title"/></fo:bookmark-title>
5723
5800
  </fo:bookmark>
5724
5801
  </xsl:for-each>
5725
5802
  </fo:bookmark>
5726
5803
  </xsl:if>
5727
5804
 
5728
- <xsl:if test="$list_of_figures//figure">
5729
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {$list_of_figures//figure[1]/@id} -->
5805
+ <xsl:if test="$contents//figures/figure">
5806
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5730
5807
  <fo:bookmark-title>
5731
-
5732
- <xsl:call-template name="getTitle">
5733
- <xsl:with-param name="name" select="'title-list-figures'"/>
5734
- </xsl:call-template>
5735
-
5736
-
5808
+ <xsl:value-of select="$title-list-figures"/>
5737
5809
  </fo:bookmark-title>
5738
- <xsl:for-each select="$list_of_figures//figure">
5810
+ <xsl:for-each select="$contents//figures/figure">
5739
5811
  <fo:bookmark internal-destination="{@id}">
5740
- <fo:bookmark-title><xsl:value-of select="."/></fo:bookmark-title>
5812
+ <xsl:variable name="title">
5813
+ <xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/>
5814
+ </xsl:variable>
5815
+ <fo:bookmark-title><xsl:value-of select="$title"/></fo:bookmark-title>
5741
5816
  </fo:bookmark>
5742
5817
  </xsl:for-each>
5743
5818
  </fo:bookmark>
5744
5819
  </xsl:if>
5745
5820
 
5746
-
5747
5821
  <xsl:if test="//*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]">
5748
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {//*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']][1]/@id} -->
5822
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5749
5823
  <fo:bookmark-title>
5750
- <xsl:call-template name="getTitle">
5751
- <xsl:with-param name="name" select="'title-list-recommendations'"/>
5752
- </xsl:call-template>
5824
+ <xsl:value-of select="$title-list-recommendations"/>
5753
5825
  </fo:bookmark-title>
5754
- <!-- <xsl:for-each select="//*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]"> -->
5755
5826
  <xsl:for-each select="xalan:nodeset($toc_recommendations)/*">
5756
- <xsl:variable name="table_id" select="@id"/>
5757
5827
  <fo:bookmark internal-destination="{@id}">
5758
5828
  <fo:bookmark-title><xsl:value-of select="bookmark"/></fo:bookmark-title>
5759
5829
  </fo:bookmark>
5760
5830
  </xsl:for-each>
5761
5831
  </fo:bookmark>
5762
5832
  </xsl:if>
5833
+ <!-- $namespace = 'ogc' -->
5763
5834
 
5764
5835
 
5765
-
5836
+
5766
5837
 
5767
5838
  </fo:bookmark-tree>
5768
5839
  </xsl:if>
5769
5840
  </xsl:template><xsl:template name="insertFigureBookmarks">
5770
5841
  <xsl:param name="contents"/>
5771
- <xsl:if test="xalan:nodeset($contents)/figure">
5772
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
5842
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5843
+ <xsl:if test="$contents_nodes/figure">
5844
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
5773
5845
  <fo:bookmark-title>Figures</fo:bookmark-title>
5774
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5846
+ <xsl:for-each select="$contents_nodes/figure">
5775
5847
  <fo:bookmark internal-destination="{@id}">
5776
5848
  <fo:bookmark-title>
5777
5849
  <xsl:value-of select="normalize-space(title)"/>
@@ -5780,18 +5852,21 @@
5780
5852
  </xsl:for-each>
5781
5853
  </fo:bookmark>
5782
5854
  </xsl:if>
5855
+
5856
+ <!-- see template addBookmarks -->
5783
5857
  </xsl:template><xsl:template name="insertTableBookmarks">
5784
5858
  <xsl:param name="contents"/>
5785
5859
  <xsl:param name="lang"/>
5786
- <xsl:if test="xalan:nodeset($contents)/table">
5787
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5860
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5861
+ <xsl:if test="$contents_nodes/table">
5862
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
5788
5863
  <fo:bookmark-title>
5789
5864
  <xsl:choose>
5790
5865
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
5791
5866
  <xsl:otherwise>Tables</xsl:otherwise>
5792
5867
  </xsl:choose>
5793
5868
  </fo:bookmark-title>
5794
- <xsl:for-each select="xalan:nodeset($contents)/table">
5869
+ <xsl:for-each select="$contents_nodes/table">
5795
5870
  <fo:bookmark internal-destination="{@id}">
5796
5871
  <fo:bookmark-title>
5797
5872
  <xsl:value-of select="normalize-space(title)"/>
@@ -5800,6 +5875,8 @@
5800
5875
  </xsl:for-each>
5801
5876
  </fo:bookmark>
5802
5877
  </xsl:if>
5878
+
5879
+ <!-- see template addBookmarks -->
5803
5880
  </xsl:template><xsl:template name="getLangVersion">
5804
5881
  <xsl:param name="lang"/>
5805
5882
  <xsl:param name="doctype" select="''"/>
@@ -6036,7 +6113,51 @@
6036
6113
  <xsl:with-param name="text" select="$text_step1"/>
6037
6114
  </xsl:call-template>
6038
6115
  </xsl:variable>
6039
- <xsl:value-of select="$text_step2"/>
6116
+
6117
+ <!-- <xsl:value-of select="$text_step2"/> -->
6118
+
6119
+ <!-- add zero-width space after space -->
6120
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
6121
+
6122
+ <!-- split text by zero-width space -->
6123
+ <xsl:variable name="text_step4">
6124
+ <xsl:call-template name="split">
6125
+ <xsl:with-param name="pText" select="$text_step3"/>
6126
+ <xsl:with-param name="sep" select="$zero_width_space"/>
6127
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
6128
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
6129
+ </xsl:call-template>
6130
+ </xsl:variable>
6131
+
6132
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
6133
+ <xsl:choose>
6134
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6135
+ <xsl:call-template name="interspers">
6136
+ <xsl:with-param name="str" select="."/>
6137
+ </xsl:call-template>
6138
+ </xsl:when>
6139
+ <xsl:otherwise>
6140
+ <xsl:value-of select="."/>
6141
+ </xsl:otherwise>
6142
+ </xsl:choose>
6143
+ </xsl:for-each>
6144
+
6145
+ </xsl:template><xsl:template name="interspers">
6146
+ <xsl:param name="str"/>
6147
+ <xsl:param name="char" select="$zero_width_space"/>
6148
+ <xsl:if test="$str != ''">
6149
+ <xsl:value-of select="substring($str, 1, 1)"/>
6150
+
6151
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
6152
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
6153
+ <xsl:value-of select="$char"/>
6154
+ </xsl:if>
6155
+
6156
+ <xsl:call-template name="interspers">
6157
+ <xsl:with-param name="str" select="substring($str, 2)"/>
6158
+ <xsl:with-param name="char" select="$char"/>
6159
+ </xsl:call-template>
6160
+ </xsl:if>
6040
6161
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6041
6162
  <xsl:apply-templates mode="syntax_highlight"/>
6042
6163
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6478,6 +6599,8 @@
6478
6599
  </xsl:otherwise>
6479
6600
  </xsl:choose> -->
6480
6601
  </fo:block>
6602
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6603
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6481
6604
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6482
6605
  <xsl:if test="normalize-space() != ''">
6483
6606
  <xsl:value-of select="."/>
@@ -6552,26 +6675,24 @@
6552
6675
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6553
6676
  <xsl:text>— </xsl:text>
6554
6677
  <xsl:apply-templates/>
6555
- </xsl:template><xsl:variable name="bibitem_hidden_">
6678
+ </xsl:template><xsl:variable name="bibitems_">
6679
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
6680
+ <xsl:copy-of select="."/>
6681
+ </xsl:for-each>
6682
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
6556
6683
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6557
6684
  <xsl:copy-of select="."/>
6558
6685
  </xsl:for-each>
6559
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6686
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
6560
6687
  <xsl:copy-of select="."/>
6561
6688
  </xsl:for-each>
6562
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6563
-
6564
- <xsl:variable name="bibitemid">
6565
- <xsl:choose>
6566
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6567
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6568
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6569
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6570
- </xsl:choose>
6571
- </xsl:variable>
6572
-
6689
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6690
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6691
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
6692
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
6573
6693
  <xsl:choose>
6574
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
6694
+ <!-- <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) -->
6695
+ <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) -->
6575
6696
  <fo:inline xsl:use-attribute-sets="eref-style">
6576
6697
  <xsl:if test="@type = 'footnote'">
6577
6698
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6585,8 +6706,8 @@
6585
6706
  <xsl:variable name="text" select="normalize-space()"/>
6586
6707
 
6587
6708
 
6588
-
6589
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6709
+
6710
+ <fo:basic-link fox:alt-text="{@citeas}">
6590
6711
  <xsl:if test="normalize-space(@citeas) = ''">
6591
6712
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6592
6713
  </xsl:if>
@@ -6596,14 +6717,21 @@
6596
6717
 
6597
6718
  </xsl:if>
6598
6719
 
6599
-
6720
+ <xsl:choose>
6721
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6722
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6723
+ </xsl:when>
6724
+ <xsl:otherwise>
6725
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6726
+ </xsl:otherwise>
6727
+ </xsl:choose>
6600
6728
 
6601
6729
  <xsl:apply-templates/>
6602
6730
  </fo:basic-link>
6603
-
6731
+
6604
6732
  </fo:inline>
6605
6733
  </xsl:when>
6606
- <xsl:otherwise>
6734
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6607
6735
  <fo:inline><xsl:apply-templates/></fo:inline>
6608
6736
  </xsl:otherwise>
6609
6737
  </xsl:choose>
@@ -6937,7 +7065,7 @@
6937
7065
 
6938
7066
 
6939
7067
 
6940
-
7068
+
6941
7069
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6942
7070
  </fo:list-block>
6943
7071
  <!-- <xsl:for-each select="./iho:note">
@@ -6955,6 +7083,11 @@
6955
7083
 
6956
7084
 
6957
7085
 
7086
+ <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7087
+ <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
7088
+ <xsl:call-template name="append_add-style"/>
7089
+ </xsl:if>
7090
+
6958
7091
  <xsl:call-template name="getListItemFormat"/>
6959
7092
  </fo:block>
6960
7093
  </fo:list-item-label>
@@ -7447,6 +7580,24 @@
7447
7580
  <xsl:apply-templates/>
7448
7581
  </fo:inline>
7449
7582
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7583
+
7584
+ <!-- list of footnotes to calculate actual footnotes number -->
7585
+ <xsl:variable name="p_fn_">
7586
+ <xsl:call-template name="get_fn_list"/>
7587
+ </xsl:variable>
7588
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7589
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7590
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7591
+ <!-- fn sequence number in document -->
7592
+ <xsl:variable name="current_fn_number">
7593
+ <xsl:choose>
7594
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7595
+ <xsl:otherwise>
7596
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7597
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7598
+ </xsl:otherwise>
7599
+ </xsl:choose>
7600
+ </xsl:variable>
7450
7601
  <fo:footnote>
7451
7602
  <xsl:variable name="number">
7452
7603
 
@@ -7455,22 +7606,26 @@
7455
7606
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7456
7607
  </xsl:when>
7457
7608
  <xsl:otherwise>
7458
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7609
+ <xsl:value-of select="$current_fn_number"/>
7459
7610
  </xsl:otherwise>
7460
7611
  </xsl:choose>
7461
7612
 
7462
7613
  </xsl:variable>
7614
+
7615
+ <xsl:variable name="current_fn_number_text">
7616
+ <xsl:value-of select="$number"/>
7617
+
7618
+ </xsl:variable>
7619
+
7463
7620
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7464
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
7465
- <xsl:value-of select="$number"/>
7466
-
7621
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7622
+ <xsl:value-of select="$current_fn_number_text"/>
7467
7623
  </fo:basic-link>
7468
7624
  </fo:inline>
7469
7625
  <fo:footnote-body>
7470
7626
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
7471
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7472
- <xsl:value-of select="$number"/>
7473
-
7627
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7628
+ <xsl:value-of select="$current_fn_number_text"/>
7474
7629
  </fo:inline>
7475
7630
  <xsl:apply-templates/>
7476
7631
  </fo:block>
@@ -7716,6 +7871,78 @@
7716
7871
  <xsl:apply-templates/>
7717
7872
  </fo:block>
7718
7873
 
7874
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7875
+ <xsl:copy>
7876
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7877
+ </xsl:copy>
7878
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7879
+ <xsl:copy>
7880
+ <xsl:copy-of select="@*"/>
7881
+
7882
+ <xsl:variable name="nodes_preface_">
7883
+ <xsl:for-each select="*">
7884
+ <node id="{@id}"/>
7885
+ </xsl:for-each>
7886
+ </xsl:variable>
7887
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7888
+
7889
+ <xsl:for-each select="*">
7890
+ <xsl:sort select="@displayorder" data-type="number"/>
7891
+
7892
+ <!-- process Section's title -->
7893
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7894
+ <xsl:if test="$preceding-sibling_id != ''">
7895
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7896
+ </xsl:if>
7897
+
7898
+ <xsl:choose>
7899
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7900
+ <xsl:otherwise>
7901
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7902
+ </xsl:otherwise>
7903
+ </xsl:choose>
7904
+
7905
+ </xsl:for-each>
7906
+ </xsl:copy>
7907
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7908
+ <xsl:copy>
7909
+ <xsl:copy-of select="@*"/>
7910
+
7911
+ <xsl:variable name="nodes_sections_">
7912
+ <xsl:for-each select="*">
7913
+ <node id="{@id}"/>
7914
+ </xsl:for-each>
7915
+ </xsl:variable>
7916
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7917
+
7918
+ <!-- move section 'Normative references' inside 'sections' -->
7919
+ <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']]">
7920
+ <xsl:sort select="@displayorder" data-type="number"/>
7921
+
7922
+ <!-- process Section's title -->
7923
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7924
+ <xsl:if test="$preceding-sibling_id != ''">
7925
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7926
+ </xsl:if>
7927
+
7928
+ <xsl:choose>
7929
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7930
+ <xsl:otherwise>
7931
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7932
+ </xsl:otherwise>
7933
+ </xsl:choose>
7934
+
7935
+ </xsl:for-each>
7936
+ </xsl:copy>
7937
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7938
+ <xsl:copy>
7939
+ <xsl:copy-of select="@*"/>
7940
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7941
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7942
+ <xsl:sort select="@displayorder" data-type="number"/>
7943
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7944
+ </xsl:for-each>
7945
+ </xsl:copy>
7719
7946
  </xsl:template><xsl:template name="convertDate">
7720
7947
  <xsl:param name="date"/>
7721
7948
  <xsl:param name="format" select="'short'"/>
@@ -7960,22 +8187,25 @@
7960
8187
  <xsl:param name="pText" select="."/>
7961
8188
  <xsl:param name="sep" select="','"/>
7962
8189
  <xsl:param name="normalize-space" select="'true'"/>
8190
+ <xsl:param name="keep_sep" select="'false'"/>
7963
8191
  <xsl:if test="string-length($pText) &gt;0">
7964
- <item>
7965
- <xsl:choose>
7966
- <xsl:when test="$normalize-space = 'true'">
7967
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7968
- </xsl:when>
7969
- <xsl:otherwise>
7970
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7971
- </xsl:otherwise>
7972
- </xsl:choose>
7973
- </item>
7974
- <xsl:call-template name="split">
7975
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7976
- <xsl:with-param name="sep" select="$sep"/>
7977
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
7978
- </xsl:call-template>
8192
+ <item>
8193
+ <xsl:choose>
8194
+ <xsl:when test="$normalize-space = 'true'">
8195
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8196
+ </xsl:when>
8197
+ <xsl:otherwise>
8198
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8199
+ </xsl:otherwise>
8200
+ </xsl:choose>
8201
+ </item>
8202
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
8203
+ <xsl:call-template name="split">
8204
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8205
+ <xsl:with-param name="sep" select="$sep"/>
8206
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
8207
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
8208
+ </xsl:call-template>
7979
8209
  </xsl:if>
7980
8210
  </xsl:template><xsl:template name="getDocumentId">
7981
8211
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
@@ -8166,53 +8396,153 @@
8166
8396
  <xsl:param name="first"/>
8167
8397
  <xsl:if test="$number != ''">
8168
8398
  <xsl:variable name="words">
8169
- <words>
8170
- <word cardinal="1">One-</word>
8171
- <word ordinal="1">First </word>
8172
- <word cardinal="2">Two-</word>
8173
- <word ordinal="2">Second </word>
8174
- <word cardinal="3">Three-</word>
8175
- <word ordinal="3">Third </word>
8176
- <word cardinal="4">Four-</word>
8177
- <word ordinal="4">Fourth </word>
8178
- <word cardinal="5">Five-</word>
8179
- <word ordinal="5">Fifth </word>
8180
- <word cardinal="6">Six-</word>
8181
- <word ordinal="6">Sixth </word>
8182
- <word cardinal="7">Seven-</word>
8183
- <word ordinal="7">Seventh </word>
8184
- <word cardinal="8">Eight-</word>
8185
- <word ordinal="8">Eighth </word>
8186
- <word cardinal="9">Nine-</word>
8187
- <word ordinal="9">Ninth </word>
8188
- <word ordinal="10">Tenth </word>
8189
- <word ordinal="11">Eleventh </word>
8190
- <word ordinal="12">Twelfth </word>
8191
- <word ordinal="13">Thirteenth </word>
8192
- <word ordinal="14">Fourteenth </word>
8193
- <word ordinal="15">Fifteenth </word>
8194
- <word ordinal="16">Sixteenth </word>
8195
- <word ordinal="17">Seventeenth </word>
8196
- <word ordinal="18">Eighteenth </word>
8197
- <word ordinal="19">Nineteenth </word>
8198
- <word cardinal="20">Twenty-</word>
8199
- <word ordinal="20">Twentieth </word>
8200
- <word cardinal="30">Thirty-</word>
8201
- <word ordinal="30">Thirtieth </word>
8202
- <word cardinal="40">Forty-</word>
8203
- <word ordinal="40">Fortieth </word>
8204
- <word cardinal="50">Fifty-</word>
8205
- <word ordinal="50">Fiftieth </word>
8206
- <word cardinal="60">Sixty-</word>
8207
- <word ordinal="60">Sixtieth </word>
8208
- <word cardinal="70">Seventy-</word>
8209
- <word ordinal="70">Seventieth </word>
8210
- <word cardinal="80">Eighty-</word>
8211
- <word ordinal="80">Eightieth </word>
8212
- <word cardinal="90">Ninety-</word>
8213
- <word ordinal="90">Ninetieth </word>
8214
- <word cardinal="100">Hundred-</word>
8215
- <word ordinal="100">Hundredth </word>
8399
+ <words>
8400
+ <xsl:choose>
8401
+ <xsl:when test="$lang = 'fr'"> <!-- https://en.wiktionary.org/wiki/Appendix:French_numbers -->
8402
+ <word cardinal="1">Une-</word>
8403
+ <word ordinal="1">Première </word>
8404
+ <word cardinal="2">Deux-</word>
8405
+ <word ordinal="2">Seconde </word>
8406
+ <word cardinal="3">Trois-</word>
8407
+ <word ordinal="3">Tierce </word>
8408
+ <word cardinal="4">Quatre-</word>
8409
+ <word ordinal="4">Quatrième </word>
8410
+ <word cardinal="5">Cinq-</word>
8411
+ <word ordinal="5">Cinquième </word>
8412
+ <word cardinal="6">Six-</word>
8413
+ <word ordinal="6">Sixième </word>
8414
+ <word cardinal="7">Sept-</word>
8415
+ <word ordinal="7">Septième </word>
8416
+ <word cardinal="8">Huit-</word>
8417
+ <word ordinal="8">Huitième </word>
8418
+ <word cardinal="9">Neuf-</word>
8419
+ <word ordinal="9">Neuvième </word>
8420
+ <word ordinal="10">Dixième </word>
8421
+ <word ordinal="11">Onzième </word>
8422
+ <word ordinal="12">Douzième </word>
8423
+ <word ordinal="13">Treizième </word>
8424
+ <word ordinal="14">Quatorzième </word>
8425
+ <word ordinal="15">Quinzième </word>
8426
+ <word ordinal="16">Seizième </word>
8427
+ <word ordinal="17">Dix-septième </word>
8428
+ <word ordinal="18">Dix-huitième </word>
8429
+ <word ordinal="19">Dix-neuvième </word>
8430
+ <word cardinal="20">Vingt-</word>
8431
+ <word ordinal="20">Vingtième </word>
8432
+ <word cardinal="30">Trente-</word>
8433
+ <word ordinal="30">Trentième </word>
8434
+ <word cardinal="40">Quarante-</word>
8435
+ <word ordinal="40">Quarantième </word>
8436
+ <word cardinal="50">Cinquante-</word>
8437
+ <word ordinal="50">Cinquantième </word>
8438
+ <word cardinal="60">Soixante-</word>
8439
+ <word ordinal="60">Soixantième </word>
8440
+ <word cardinal="70">Septante-</word>
8441
+ <word ordinal="70">Septantième </word>
8442
+ <word cardinal="80">Huitante-</word>
8443
+ <word ordinal="80">Huitantième </word>
8444
+ <word cardinal="90">Nonante-</word>
8445
+ <word ordinal="90">Nonantième </word>
8446
+ <word cardinal="100">Cent-</word>
8447
+ <word ordinal="100">Centième </word>
8448
+ </xsl:when>
8449
+ <xsl:when test="$lang = 'ru'">
8450
+ <word cardinal="1">Одна-</word>
8451
+ <word ordinal="1">Первое </word>
8452
+ <word cardinal="2">Две-</word>
8453
+ <word ordinal="2">Второе </word>
8454
+ <word cardinal="3">Три-</word>
8455
+ <word ordinal="3">Третье </word>
8456
+ <word cardinal="4">Четыре-</word>
8457
+ <word ordinal="4">Четвертое </word>
8458
+ <word cardinal="5">Пять-</word>
8459
+ <word ordinal="5">Пятое </word>
8460
+ <word cardinal="6">Шесть-</word>
8461
+ <word ordinal="6">Шестое </word>
8462
+ <word cardinal="7">Семь-</word>
8463
+ <word ordinal="7">Седьмое </word>
8464
+ <word cardinal="8">Восемь-</word>
8465
+ <word ordinal="8">Восьмое </word>
8466
+ <word cardinal="9">Девять-</word>
8467
+ <word ordinal="9">Девятое </word>
8468
+ <word ordinal="10">Десятое </word>
8469
+ <word ordinal="11">Одиннадцатое </word>
8470
+ <word ordinal="12">Двенадцатое </word>
8471
+ <word ordinal="13">Тринадцатое </word>
8472
+ <word ordinal="14">Четырнадцатое </word>
8473
+ <word ordinal="15">Пятнадцатое </word>
8474
+ <word ordinal="16">Шестнадцатое </word>
8475
+ <word ordinal="17">Семнадцатое </word>
8476
+ <word ordinal="18">Восемнадцатое </word>
8477
+ <word ordinal="19">Девятнадцатое </word>
8478
+ <word cardinal="20">Двадцать-</word>
8479
+ <word ordinal="20">Двадцатое </word>
8480
+ <word cardinal="30">Тридцать-</word>
8481
+ <word ordinal="30">Тридцатое </word>
8482
+ <word cardinal="40">Сорок-</word>
8483
+ <word ordinal="40">Сороковое </word>
8484
+ <word cardinal="50">Пятьдесят-</word>
8485
+ <word ordinal="50">Пятидесятое </word>
8486
+ <word cardinal="60">Шестьдесят-</word>
8487
+ <word ordinal="60">Шестидесятое </word>
8488
+ <word cardinal="70">Семьдесят-</word>
8489
+ <word ordinal="70">Семидесятое </word>
8490
+ <word cardinal="80">Восемьдесят-</word>
8491
+ <word ordinal="80">Восьмидесятое </word>
8492
+ <word cardinal="90">Девяносто-</word>
8493
+ <word ordinal="90">Девяностое </word>
8494
+ <word cardinal="100">Сто-</word>
8495
+ <word ordinal="100">Сотое </word>
8496
+ </xsl:when>
8497
+ <xsl:otherwise> <!-- default english -->
8498
+ <word cardinal="1">One-</word>
8499
+ <word ordinal="1">First </word>
8500
+ <word cardinal="2">Two-</word>
8501
+ <word ordinal="2">Second </word>
8502
+ <word cardinal="3">Three-</word>
8503
+ <word ordinal="3">Third </word>
8504
+ <word cardinal="4">Four-</word>
8505
+ <word ordinal="4">Fourth </word>
8506
+ <word cardinal="5">Five-</word>
8507
+ <word ordinal="5">Fifth </word>
8508
+ <word cardinal="6">Six-</word>
8509
+ <word ordinal="6">Sixth </word>
8510
+ <word cardinal="7">Seven-</word>
8511
+ <word ordinal="7">Seventh </word>
8512
+ <word cardinal="8">Eight-</word>
8513
+ <word ordinal="8">Eighth </word>
8514
+ <word cardinal="9">Nine-</word>
8515
+ <word ordinal="9">Ninth </word>
8516
+ <word ordinal="10">Tenth </word>
8517
+ <word ordinal="11">Eleventh </word>
8518
+ <word ordinal="12">Twelfth </word>
8519
+ <word ordinal="13">Thirteenth </word>
8520
+ <word ordinal="14">Fourteenth </word>
8521
+ <word ordinal="15">Fifteenth </word>
8522
+ <word ordinal="16">Sixteenth </word>
8523
+ <word ordinal="17">Seventeenth </word>
8524
+ <word ordinal="18">Eighteenth </word>
8525
+ <word ordinal="19">Nineteenth </word>
8526
+ <word cardinal="20">Twenty-</word>
8527
+ <word ordinal="20">Twentieth </word>
8528
+ <word cardinal="30">Thirty-</word>
8529
+ <word ordinal="30">Thirtieth </word>
8530
+ <word cardinal="40">Forty-</word>
8531
+ <word ordinal="40">Fortieth </word>
8532
+ <word cardinal="50">Fifty-</word>
8533
+ <word ordinal="50">Fiftieth </word>
8534
+ <word cardinal="60">Sixty-</word>
8535
+ <word ordinal="60">Sixtieth </word>
8536
+ <word cardinal="70">Seventy-</word>
8537
+ <word ordinal="70">Seventieth </word>
8538
+ <word cardinal="80">Eighty-</word>
8539
+ <word ordinal="80">Eightieth </word>
8540
+ <word cardinal="90">Ninety-</word>
8541
+ <word ordinal="90">Ninetieth </word>
8542
+ <word cardinal="100">Hundred-</word>
8543
+ <word ordinal="100">Hundredth </word>
8544
+ </xsl:otherwise>
8545
+ </xsl:choose>
8216
8546
  </words>
8217
8547
  </xsl:variable>
8218
8548
 
@@ -8286,4 +8616,18 @@
8286
8616
  <xsl:otherwise>_</xsl:otherwise>
8287
8617
  </xsl:choose>
8288
8618
  </xsl:attribute>
8619
+ </xsl:template><xsl:template name="substring-after-last">
8620
+ <xsl:param name="value"/>
8621
+ <xsl:param name="delimiter"/>
8622
+ <xsl:choose>
8623
+ <xsl:when test="contains($value, $delimiter)">
8624
+ <xsl:call-template name="substring-after-last">
8625
+ <xsl:with-param name="value" select="substring-after($value, $delimiter)"/>
8626
+ <xsl:with-param name="delimiter" select="$delimiter"/>
8627
+ </xsl:call-template>
8628
+ </xsl:when>
8629
+ <xsl:otherwise>
8630
+ <xsl:value-of select="$value"/>
8631
+ </xsl:otherwise>
8632
+ </xsl:choose>
8289
8633
  </xsl:template></xsl:stylesheet>