metanorma-ogc 2.0.4 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -113,16 +113,20 @@
113
113
  </xsl:for-each>
114
114
  </xsl:variable>
115
115
 
116
- <xsl:variable name="contents">
116
+ <xsl:variable name="contents_">
117
117
  <contents>
118
118
  <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
119
119
  <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
120
120
 
121
121
  <xsl:call-template name="processMainSectionsDefault_Contents"/>
122
122
  <xsl:apply-templates select="//ogc:indexsect" mode="contents"/>
123
+
124
+ <xsl:call-template name="processTablesFigures_Contents">
125
+ <xsl:with-param name="always">true</xsl:with-param>
126
+ </xsl:call-template>
123
127
  </contents>
124
128
  </xsl:variable>
125
-
129
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
126
130
 
127
131
  <xsl:template match="/">
128
132
  <xsl:call-template name="namespaceCheck"/>
@@ -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">
@@ -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>
@@ -678,6 +618,32 @@
678
618
  </fo:root>
679
619
  </xsl:template>
680
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>
681
647
 
682
648
  <!-- Lato font doesn't contain 'thin space' glyph -->
683
649
  <xsl:template match="text()" priority="1">
@@ -1531,7 +1497,7 @@
1531
1497
  <xsl:text>Contents</xsl:text>
1532
1498
 
1533
1499
  </title-toc>
1534
-
1500
+
1535
1501
  <title-descriptors lang="en">Descriptors</title-descriptors>
1536
1502
 
1537
1503
  <title-part lang="en">
@@ -1567,7 +1533,31 @@
1567
1533
  <title-continued lang="en">(continued)</title-continued>
1568
1534
  <title-continued lang="fr">(continué)</title-continued>
1569
1535
 
1570
- </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">
1571
1561
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1572
1562
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1573
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">
@@ -2895,6 +2885,30 @@
2895
2885
  <xsl:sort select="@displayorder" data-type="number"/>
2896
2886
  <xsl:apply-templates select="." mode="contents"/>
2897
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>
2898
2912
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2899
2913
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2900
2914
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2916,8 +2930,27 @@
2916
2930
  <xsl:sort select="@displayorder" data-type="number"/>
2917
2931
  <xsl:apply-templates select="."/>
2918
2932
  </xsl:for-each>
2919
- </xsl:template><xsl:template match="text()">
2920
- <xsl:value-of select="."/>
2933
+ </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
2934
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2935
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2936
+ <xsl:call-template name="replace_fo_inline">
2937
+ <xsl:with-param name="text" select="$text"/>
2938
+ </xsl:call-template>
2939
+ </xsl:template><xsl:template name="replace_fo_inline">
2940
+ <xsl:param name="text"/>
2941
+ <xsl:choose>
2942
+ <xsl:when test="contains($text, $tag_open)">
2943
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
2944
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2945
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2946
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2947
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2948
+ <xsl:call-template name="replace_fo_inline">
2949
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2950
+ </xsl:call-template>
2951
+ </xsl:when>
2952
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
2953
+ </xsl:choose>
2921
2954
  </xsl:template><xsl:template match="*[local-name()='br']">
2922
2955
  <xsl:value-of select="$linebreak"/>
2923
2956
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -3700,37 +3733,7 @@
3700
3733
 
3701
3734
  <!-- list of footnotes to calculate actual footnotes number -->
3702
3735
  <xsl:variable name="p_fn_">
3703
- <xsl:choose>
3704
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3705
- <fn gen_id="{generate-id(.)}">
3706
- <xsl:copy-of select="@*"/>
3707
- <xsl:copy-of select="node()"/>
3708
- </fn>
3709
- </xsl:when>
3710
- <xsl:otherwise>
3711
- <!-- itetation for:
3712
- footnotes in bibdata/title
3713
- footnotes in bibliography
3714
- footnotes in document's body (except table's head/body/foot and figure text)
3715
- -->
3716
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3717
- <fn gen_id="{generate-id(.)}">
3718
- <xsl:copy-of select="@*"/>
3719
- <xsl:copy-of select="node()"/>
3720
- </fn>
3721
- </xsl:for-each>
3722
- <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']/*">
3723
- <xsl:sort select="@displayorder" data-type="number"/>
3724
- <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])]">
3725
- <!-- copy unique fn -->
3726
- <fn gen_id="{generate-id(.)}">
3727
- <xsl:copy-of select="@*"/>
3728
- <xsl:copy-of select="node()"/>
3729
- </fn>
3730
- </xsl:for-each>
3731
- </xsl:for-each>
3732
- </xsl:otherwise>
3733
- </xsl:choose>
3736
+ <xsl:call-template name="get_fn_list"/>
3734
3737
  </xsl:variable>
3735
3738
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3736
3739
 
@@ -3791,6 +3794,38 @@
3791
3794
  <xsl:copy-of select="$footnote_inline"/>
3792
3795
  </xsl:otherwise>
3793
3796
  </xsl:choose>
3797
+ </xsl:template><xsl:template name="get_fn_list">
3798
+ <xsl:choose>
3799
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3800
+ <fn gen_id="{generate-id(.)}">
3801
+ <xsl:copy-of select="@*"/>
3802
+ <xsl:copy-of select="node()"/>
3803
+ </fn>
3804
+ </xsl:when>
3805
+ <xsl:otherwise>
3806
+ <!-- itetation for:
3807
+ footnotes in bibdata/title
3808
+ footnotes in bibliography
3809
+ footnotes in document's body (except table's head/body/foot and figure text)
3810
+ -->
3811
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3812
+ <fn gen_id="{generate-id(.)}">
3813
+ <xsl:copy-of select="@*"/>
3814
+ <xsl:copy-of select="node()"/>
3815
+ </fn>
3816
+ </xsl:for-each>
3817
+ <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']/*">
3818
+ <xsl:sort select="@displayorder" data-type="number"/>
3819
+ <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])]">
3820
+ <!-- copy unique fn -->
3821
+ <fn gen_id="{generate-id(.)}">
3822
+ <xsl:copy-of select="@*"/>
3823
+ <xsl:copy-of select="node()"/>
3824
+ </fn>
3825
+ </xsl:for-each>
3826
+ </xsl:for-each>
3827
+ </xsl:otherwise>
3828
+ </xsl:choose>
3794
3829
  </xsl:template><xsl:template name="table_fn_display">
3795
3830
  <xsl:variable name="references">
3796
3831
 
@@ -3973,7 +4008,7 @@
3973
4008
  </fo:inline>
3974
4009
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3975
4010
  <fo:inline><xsl:value-of select="."/></fo:inline>
3976
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
4011
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3977
4012
  <fo:inline>
3978
4013
  <xsl:apply-templates/>
3979
4014
  </fo:inline>
@@ -5669,13 +5704,14 @@
5669
5704
  <xsl:apply-templates mode="bookmarks"/>
5670
5705
  </xsl:template><xsl:template name="addBookmarks">
5671
5706
  <xsl:param name="contents"/>
5672
- <xsl:if test="xalan:nodeset($contents)//item">
5707
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5708
+ <xsl:if test="$contents_nodes//item">
5673
5709
  <fo:bookmark-tree>
5674
5710
  <xsl:choose>
5675
- <xsl:when test="xalan:nodeset($contents)/doc">
5711
+ <xsl:when test="$contents_nodes/doc">
5676
5712
  <xsl:choose>
5677
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5678
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5713
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
5714
+ <xsl:for-each select="$contents_nodes/doc">
5679
5715
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5680
5716
  <xsl:if test="@bundle = 'true'">
5681
5717
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -5726,7 +5762,7 @@
5726
5762
  </xsl:for-each>
5727
5763
  </xsl:when>
5728
5764
  <xsl:otherwise>
5729
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5765
+ <xsl:for-each select="$contents_nodes/doc">
5730
5766
 
5731
5767
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5732
5768
 
@@ -5744,97 +5780,89 @@
5744
5780
  </xsl:choose>
5745
5781
  </xsl:when>
5746
5782
  <xsl:otherwise>
5747
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
5783
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
5784
+
5785
+ <xsl:call-template name="insertFigureBookmarks">
5786
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5787
+ </xsl:call-template>
5788
+
5789
+ <xsl:call-template name="insertTableBookmarks">
5790
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
5791
+ <xsl:with-param name="lang" select="@lang"/>
5792
+ </xsl:call-template>
5793
+
5748
5794
  </xsl:otherwise>
5749
5795
  </xsl:choose>
5750
5796
 
5797
+
5751
5798
 
5752
5799
 
5753
5800
 
5754
5801
 
5755
-
5756
- <xsl:variable name="list_of_tables_">
5757
- <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name']]"> <!-- contains(*[local-name() = 'name'], '—') -->
5758
- <table id="{@id}"><xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/></table>
5759
- </xsl:for-each>
5760
- </xsl:variable>
5761
- <xsl:variable name="list_of_tables" select="xalan:nodeset($list_of_tables_)"/>
5762
-
5763
- <xsl:variable name="list_of_figures_">
5764
- <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'], '—') -->
5765
- <figure id="{@id}"><xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/></figure>
5766
- </xsl:for-each>
5767
- </xsl:variable>
5768
- <xsl:variable name="list_of_figures" select="xalan:nodeset($list_of_figures_)"/>
5769
-
5770
- <xsl:if test="$list_of_tables//table or $list_of_figures/figure or //*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]">
5802
+ <xsl:if test="$contents//tables/table or $contents//figures/figure or //*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]">
5771
5803
  <fo:bookmark internal-destination="empty_bookmark">
5772
5804
  <fo:bookmark-title>—————</fo:bookmark-title>
5773
5805
  </fo:bookmark>
5774
5806
  </xsl:if>
5775
5807
 
5776
- <xsl:if test="$list_of_tables//table">
5777
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {$list_of_tables//table[1]/@id} -->
5808
+ <xsl:if test="$contents//tables/table">
5809
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5778
5810
  <fo:bookmark-title>
5779
- <xsl:call-template name="getTitle">
5780
- <xsl:with-param name="name" select="'title-list-tables'"/>
5781
- </xsl:call-template>
5811
+ <xsl:value-of select="$title-list-tables"/>
5782
5812
  </fo:bookmark-title>
5783
- <xsl:for-each select="$list_of_tables//table">
5813
+ <xsl:for-each select="$contents//tables/table">
5784
5814
  <fo:bookmark internal-destination="{@id}">
5785
- <fo:bookmark-title><xsl:value-of select="."/></fo:bookmark-title>
5815
+ <xsl:variable name="title">
5816
+ <xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/>
5817
+ </xsl:variable>
5818
+ <fo:bookmark-title><xsl:value-of select="$title"/></fo:bookmark-title>
5786
5819
  </fo:bookmark>
5787
5820
  </xsl:for-each>
5788
5821
  </fo:bookmark>
5789
5822
  </xsl:if>
5790
5823
 
5791
- <xsl:if test="$list_of_figures//figure">
5792
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {$list_of_figures//figure[1]/@id} -->
5824
+ <xsl:if test="$contents//figures/figure">
5825
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5793
5826
  <fo:bookmark-title>
5794
-
5795
- <xsl:call-template name="getTitle">
5796
- <xsl:with-param name="name" select="'title-list-figures'"/>
5797
- </xsl:call-template>
5798
-
5799
-
5827
+ <xsl:value-of select="$title-list-figures"/>
5800
5828
  </fo:bookmark-title>
5801
- <xsl:for-each select="$list_of_figures//figure">
5829
+ <xsl:for-each select="$contents//figures/figure">
5802
5830
  <fo:bookmark internal-destination="{@id}">
5803
- <fo:bookmark-title><xsl:value-of select="."/></fo:bookmark-title>
5831
+ <xsl:variable name="title">
5832
+ <xsl:apply-templates select="*[local-name() = 'name']" mode="bookmarks"/>
5833
+ </xsl:variable>
5834
+ <fo:bookmark-title><xsl:value-of select="$title"/></fo:bookmark-title>
5804
5835
  </fo:bookmark>
5805
5836
  </xsl:for-each>
5806
5837
  </fo:bookmark>
5807
5838
  </xsl:if>
5808
5839
 
5809
-
5810
5840
  <xsl:if test="//*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]">
5811
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {//*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']][1]/@id} -->
5841
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5812
5842
  <fo:bookmark-title>
5813
- <xsl:call-template name="getTitle">
5814
- <xsl:with-param name="name" select="'title-list-recommendations'"/>
5815
- </xsl:call-template>
5843
+ <xsl:value-of select="$title-list-recommendations"/>
5816
5844
  </fo:bookmark-title>
5817
- <!-- <xsl:for-each select="//*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]"> -->
5818
5845
  <xsl:for-each select="xalan:nodeset($toc_recommendations)/*">
5819
- <xsl:variable name="table_id" select="@id"/>
5820
5846
  <fo:bookmark internal-destination="{@id}">
5821
5847
  <fo:bookmark-title><xsl:value-of select="bookmark"/></fo:bookmark-title>
5822
5848
  </fo:bookmark>
5823
5849
  </xsl:for-each>
5824
5850
  </fo:bookmark>
5825
5851
  </xsl:if>
5852
+ <!-- $namespace = 'ogc' -->
5826
5853
 
5827
5854
 
5828
-
5855
+
5829
5856
 
5830
5857
  </fo:bookmark-tree>
5831
5858
  </xsl:if>
5832
5859
  </xsl:template><xsl:template name="insertFigureBookmarks">
5833
5860
  <xsl:param name="contents"/>
5834
- <xsl:if test="xalan:nodeset($contents)/figure">
5835
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
5861
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5862
+ <xsl:if test="$contents_nodes/figure">
5863
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
5836
5864
  <fo:bookmark-title>Figures</fo:bookmark-title>
5837
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5865
+ <xsl:for-each select="$contents_nodes/figure">
5838
5866
  <fo:bookmark internal-destination="{@id}">
5839
5867
  <fo:bookmark-title>
5840
5868
  <xsl:value-of select="normalize-space(title)"/>
@@ -5843,18 +5871,21 @@
5843
5871
  </xsl:for-each>
5844
5872
  </fo:bookmark>
5845
5873
  </xsl:if>
5874
+
5875
+ <!-- see template addBookmarks -->
5846
5876
  </xsl:template><xsl:template name="insertTableBookmarks">
5847
5877
  <xsl:param name="contents"/>
5848
5878
  <xsl:param name="lang"/>
5849
- <xsl:if test="xalan:nodeset($contents)/table">
5850
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5879
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5880
+ <xsl:if test="$contents_nodes/table">
5881
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
5851
5882
  <fo:bookmark-title>
5852
5883
  <xsl:choose>
5853
5884
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
5854
5885
  <xsl:otherwise>Tables</xsl:otherwise>
5855
5886
  </xsl:choose>
5856
5887
  </fo:bookmark-title>
5857
- <xsl:for-each select="xalan:nodeset($contents)/table">
5888
+ <xsl:for-each select="$contents_nodes/table">
5858
5889
  <fo:bookmark internal-destination="{@id}">
5859
5890
  <fo:bookmark-title>
5860
5891
  <xsl:value-of select="normalize-space(title)"/>
@@ -5863,6 +5894,8 @@
5863
5894
  </xsl:for-each>
5864
5895
  </fo:bookmark>
5865
5896
  </xsl:if>
5897
+
5898
+ <!-- see template addBookmarks -->
5866
5899
  </xsl:template><xsl:template name="getLangVersion">
5867
5900
  <xsl:param name="lang"/>
5868
5901
  <xsl:param name="doctype" select="''"/>
@@ -6099,7 +6132,51 @@
6099
6132
  <xsl:with-param name="text" select="$text_step1"/>
6100
6133
  </xsl:call-template>
6101
6134
  </xsl:variable>
6102
- <xsl:value-of select="$text_step2"/>
6135
+
6136
+ <!-- <xsl:value-of select="$text_step2"/> -->
6137
+
6138
+ <!-- add zero-width space after space -->
6139
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
6140
+
6141
+ <!-- split text by zero-width space -->
6142
+ <xsl:variable name="text_step4">
6143
+ <xsl:call-template name="split">
6144
+ <xsl:with-param name="pText" select="$text_step3"/>
6145
+ <xsl:with-param name="sep" select="$zero_width_space"/>
6146
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
6147
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
6148
+ </xsl:call-template>
6149
+ </xsl:variable>
6150
+
6151
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
6152
+ <xsl:choose>
6153
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6154
+ <xsl:call-template name="interspers">
6155
+ <xsl:with-param name="str" select="."/>
6156
+ </xsl:call-template>
6157
+ </xsl:when>
6158
+ <xsl:otherwise>
6159
+ <xsl:value-of select="."/>
6160
+ </xsl:otherwise>
6161
+ </xsl:choose>
6162
+ </xsl:for-each>
6163
+
6164
+ </xsl:template><xsl:template name="interspers">
6165
+ <xsl:param name="str"/>
6166
+ <xsl:param name="char" select="$zero_width_space"/>
6167
+ <xsl:if test="$str != ''">
6168
+ <xsl:value-of select="substring($str, 1, 1)"/>
6169
+
6170
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
6171
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
6172
+ <xsl:value-of select="$char"/>
6173
+ </xsl:if>
6174
+
6175
+ <xsl:call-template name="interspers">
6176
+ <xsl:with-param name="str" select="substring($str, 2)"/>
6177
+ <xsl:with-param name="char" select="$char"/>
6178
+ </xsl:call-template>
6179
+ </xsl:if>
6103
6180
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6104
6181
  <xsl:apply-templates mode="syntax_highlight"/>
6105
6182
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6541,6 +6618,8 @@
6541
6618
  </xsl:otherwise>
6542
6619
  </xsl:choose> -->
6543
6620
  </fo:block>
6621
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6622
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6544
6623
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6545
6624
  <xsl:if test="normalize-space() != ''">
6546
6625
  <xsl:value-of select="."/>
@@ -6575,7 +6654,8 @@
6575
6654
  <fo:inline><xsl:apply-templates/></fo:inline>
6576
6655
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
6577
6656
  <xsl:if test="normalize-space() != ''">
6578
- <xsl:value-of select="."/>
6657
+ <!-- <xsl:value-of select="."/> -->
6658
+ <xsl:call-template name="text"/>
6579
6659
  </xsl:if>
6580
6660
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
6581
6661
  <fo:block-container margin-left="0mm">
@@ -6615,26 +6695,24 @@
6615
6695
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6616
6696
  <xsl:text>— </xsl:text>
6617
6697
  <xsl:apply-templates/>
6618
- </xsl:template><xsl:variable name="bibitem_hidden_">
6698
+ </xsl:template><xsl:variable name="bibitems_">
6699
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
6700
+ <xsl:copy-of select="."/>
6701
+ </xsl:for-each>
6702
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
6619
6703
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6620
6704
  <xsl:copy-of select="."/>
6621
6705
  </xsl:for-each>
6622
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6706
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
6623
6707
  <xsl:copy-of select="."/>
6624
6708
  </xsl:for-each>
6625
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6626
-
6627
- <xsl:variable name="bibitemid">
6628
- <xsl:choose>
6629
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6630
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6631
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6632
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6633
- </xsl:choose>
6634
- </xsl:variable>
6635
-
6709
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6710
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6711
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
6712
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
6636
6713
  <xsl:choose>
6637
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
6714
+ <!-- <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) -->
6715
+ <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) -->
6638
6716
  <fo:inline xsl:use-attribute-sets="eref-style">
6639
6717
  <xsl:if test="@type = 'footnote'">
6640
6718
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6648,8 +6726,8 @@
6648
6726
  <xsl:variable name="text" select="normalize-space()"/>
6649
6727
 
6650
6728
 
6651
-
6652
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6729
+
6730
+ <fo:basic-link fox:alt-text="{@citeas}">
6653
6731
  <xsl:if test="normalize-space(@citeas) = ''">
6654
6732
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6655
6733
  </xsl:if>
@@ -6659,14 +6737,21 @@
6659
6737
 
6660
6738
  </xsl:if>
6661
6739
 
6662
-
6740
+ <xsl:choose>
6741
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6742
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6743
+ </xsl:when>
6744
+ <xsl:otherwise>
6745
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6746
+ </xsl:otherwise>
6747
+ </xsl:choose>
6663
6748
 
6664
6749
  <xsl:apply-templates/>
6665
6750
  </fo:basic-link>
6666
-
6751
+
6667
6752
  </fo:inline>
6668
6753
  </xsl:when>
6669
- <xsl:otherwise>
6754
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6670
6755
  <fo:inline><xsl:apply-templates/></fo:inline>
6671
6756
  </xsl:otherwise>
6672
6757
  </xsl:choose>
@@ -7515,6 +7600,24 @@
7515
7600
  <xsl:apply-templates/>
7516
7601
  </fo:inline>
7517
7602
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7603
+
7604
+ <!-- list of footnotes to calculate actual footnotes number -->
7605
+ <xsl:variable name="p_fn_">
7606
+ <xsl:call-template name="get_fn_list"/>
7607
+ </xsl:variable>
7608
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7609
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7610
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7611
+ <!-- fn sequence number in document -->
7612
+ <xsl:variable name="current_fn_number">
7613
+ <xsl:choose>
7614
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7615
+ <xsl:otherwise>
7616
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7617
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7618
+ </xsl:otherwise>
7619
+ </xsl:choose>
7620
+ </xsl:variable>
7518
7621
  <fo:footnote>
7519
7622
  <xsl:variable name="number">
7520
7623
 
@@ -7523,22 +7626,26 @@
7523
7626
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7524
7627
  </xsl:when>
7525
7628
  <xsl:otherwise>
7526
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7629
+ <xsl:value-of select="$current_fn_number"/>
7527
7630
  </xsl:otherwise>
7528
7631
  </xsl:choose>
7529
7632
 
7530
7633
  </xsl:variable>
7634
+
7635
+ <xsl:variable name="current_fn_number_text">
7636
+ <xsl:value-of select="$number"/>
7637
+
7638
+ </xsl:variable>
7639
+
7531
7640
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
7532
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
7533
- <xsl:value-of select="$number"/>
7534
-
7641
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7642
+ <xsl:value-of select="$current_fn_number_text"/>
7535
7643
  </fo:basic-link>
7536
7644
  </fo:inline>
7537
7645
  <fo:footnote-body>
7538
7646
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
7539
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7540
- <xsl:value-of select="$number"/>
7541
-
7647
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7648
+ <xsl:value-of select="$current_fn_number_text"/>
7542
7649
  </fo:inline>
7543
7650
  <xsl:apply-templates/>
7544
7651
  </fo:block>
@@ -7784,6 +7891,78 @@
7784
7891
  <xsl:apply-templates/>
7785
7892
  </fo:block>
7786
7893
 
7894
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7895
+ <xsl:copy>
7896
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7897
+ </xsl:copy>
7898
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7899
+ <xsl:copy>
7900
+ <xsl:copy-of select="@*"/>
7901
+
7902
+ <xsl:variable name="nodes_preface_">
7903
+ <xsl:for-each select="*">
7904
+ <node id="{@id}"/>
7905
+ </xsl:for-each>
7906
+ </xsl:variable>
7907
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7908
+
7909
+ <xsl:for-each select="*">
7910
+ <xsl:sort select="@displayorder" data-type="number"/>
7911
+
7912
+ <!-- process Section's title -->
7913
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7914
+ <xsl:if test="$preceding-sibling_id != ''">
7915
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7916
+ </xsl:if>
7917
+
7918
+ <xsl:choose>
7919
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7920
+ <xsl:otherwise>
7921
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7922
+ </xsl:otherwise>
7923
+ </xsl:choose>
7924
+
7925
+ </xsl:for-each>
7926
+ </xsl:copy>
7927
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7928
+ <xsl:copy>
7929
+ <xsl:copy-of select="@*"/>
7930
+
7931
+ <xsl:variable name="nodes_sections_">
7932
+ <xsl:for-each select="*">
7933
+ <node id="{@id}"/>
7934
+ </xsl:for-each>
7935
+ </xsl:variable>
7936
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7937
+
7938
+ <!-- move section 'Normative references' inside 'sections' -->
7939
+ <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']]">
7940
+ <xsl:sort select="@displayorder" data-type="number"/>
7941
+
7942
+ <!-- process Section's title -->
7943
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7944
+ <xsl:if test="$preceding-sibling_id != ''">
7945
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7946
+ </xsl:if>
7947
+
7948
+ <xsl:choose>
7949
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7950
+ <xsl:otherwise>
7951
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7952
+ </xsl:otherwise>
7953
+ </xsl:choose>
7954
+
7955
+ </xsl:for-each>
7956
+ </xsl:copy>
7957
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7958
+ <xsl:copy>
7959
+ <xsl:copy-of select="@*"/>
7960
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7961
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7962
+ <xsl:sort select="@displayorder" data-type="number"/>
7963
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7964
+ </xsl:for-each>
7965
+ </xsl:copy>
7787
7966
  </xsl:template><xsl:template name="convertDate">
7788
7967
  <xsl:param name="date"/>
7789
7968
  <xsl:param name="format" select="'short'"/>
@@ -8028,22 +8207,25 @@
8028
8207
  <xsl:param name="pText" select="."/>
8029
8208
  <xsl:param name="sep" select="','"/>
8030
8209
  <xsl:param name="normalize-space" select="'true'"/>
8210
+ <xsl:param name="keep_sep" select="'false'"/>
8031
8211
  <xsl:if test="string-length($pText) &gt;0">
8032
- <item>
8033
- <xsl:choose>
8034
- <xsl:when test="$normalize-space = 'true'">
8035
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8036
- </xsl:when>
8037
- <xsl:otherwise>
8038
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8039
- </xsl:otherwise>
8040
- </xsl:choose>
8041
- </item>
8042
- <xsl:call-template name="split">
8043
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8044
- <xsl:with-param name="sep" select="$sep"/>
8045
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
8046
- </xsl:call-template>
8212
+ <item>
8213
+ <xsl:choose>
8214
+ <xsl:when test="$normalize-space = 'true'">
8215
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
8216
+ </xsl:when>
8217
+ <xsl:otherwise>
8218
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
8219
+ </xsl:otherwise>
8220
+ </xsl:choose>
8221
+ </item>
8222
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
8223
+ <xsl:call-template name="split">
8224
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
8225
+ <xsl:with-param name="sep" select="$sep"/>
8226
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
8227
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
8228
+ </xsl:call-template>
8047
8229
  </xsl:if>
8048
8230
  </xsl:template><xsl:template name="getDocumentId">
8049
8231
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>