metanorma-ogc 2.0.4 → 2.0.5

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">
@@ -1485,7 +1451,7 @@
1485
1451
  </fo:static-content>
1486
1452
  </xsl:template>
1487
1453
 
1488
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
1454
+ <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:key name="bibitems" match="*[local-name() = 'bibitem']" use="@id"/><xsl:key name="bibitems_hidden" match="*[local-name() = 'bibitem'][@hidden='true'] | *[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']" use="@id"/><xsl:variable name="lang">
1489
1455
  <xsl:call-template name="getLang"/>
1490
1456
  </xsl:variable><xsl:variable name="pageWidth_">
1491
1457
  215.9
@@ -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"/>
@@ -3700,37 +3714,7 @@
3700
3714
 
3701
3715
  <!-- list of footnotes to calculate actual footnotes number -->
3702
3716
  <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>
3717
+ <xsl:call-template name="get_fn_list"/>
3734
3718
  </xsl:variable>
3735
3719
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
3736
3720
 
@@ -3791,6 +3775,38 @@
3791
3775
  <xsl:copy-of select="$footnote_inline"/>
3792
3776
  </xsl:otherwise>
3793
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>
3794
3810
  </xsl:template><xsl:template name="table_fn_display">
3795
3811
  <xsl:variable name="references">
3796
3812
 
@@ -3973,7 +3989,7 @@
3973
3989
  </fo:inline>
3974
3990
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3975
3991
  <fo:inline><xsl:value-of select="."/></fo:inline>
3976
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3992
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3977
3993
  <fo:inline>
3978
3994
  <xsl:apply-templates/>
3979
3995
  </fo:inline>
@@ -5669,13 +5685,14 @@
5669
5685
  <xsl:apply-templates mode="bookmarks"/>
5670
5686
  </xsl:template><xsl:template name="addBookmarks">
5671
5687
  <xsl:param name="contents"/>
5672
- <xsl:if test="xalan:nodeset($contents)//item">
5688
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5689
+ <xsl:if test="$contents_nodes//item">
5673
5690
  <fo:bookmark-tree>
5674
5691
  <xsl:choose>
5675
- <xsl:when test="xalan:nodeset($contents)/doc">
5692
+ <xsl:when test="$contents_nodes/doc">
5676
5693
  <xsl:choose>
5677
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5678
- <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">
5679
5696
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5680
5697
  <xsl:if test="@bundle = 'true'">
5681
5698
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -5726,7 +5743,7 @@
5726
5743
  </xsl:for-each>
5727
5744
  </xsl:when>
5728
5745
  <xsl:otherwise>
5729
- <xsl:for-each select="xalan:nodeset($contents)/doc">
5746
+ <xsl:for-each select="$contents_nodes/doc">
5730
5747
 
5731
5748
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5732
5749
 
@@ -5744,97 +5761,89 @@
5744
5761
  </xsl:choose>
5745
5762
  </xsl:when>
5746
5763
  <xsl:otherwise>
5747
- <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
+
5748
5775
  </xsl:otherwise>
5749
5776
  </xsl:choose>
5750
5777
 
5778
+
5751
5779
 
5752
5780
 
5753
5781
 
5754
5782
 
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']]">
5783
+ <xsl:if test="$contents//tables/table or $contents//figures/figure or //*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]">
5771
5784
  <fo:bookmark internal-destination="empty_bookmark">
5772
5785
  <fo:bookmark-title>—————</fo:bookmark-title>
5773
5786
  </fo:bookmark>
5774
5787
  </xsl:if>
5775
5788
 
5776
- <xsl:if test="$list_of_tables//table">
5777
- <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">
5778
5791
  <fo:bookmark-title>
5779
- <xsl:call-template name="getTitle">
5780
- <xsl:with-param name="name" select="'title-list-tables'"/>
5781
- </xsl:call-template>
5792
+ <xsl:value-of select="$title-list-tables"/>
5782
5793
  </fo:bookmark-title>
5783
- <xsl:for-each select="$list_of_tables//table">
5794
+ <xsl:for-each select="$contents//tables/table">
5784
5795
  <fo:bookmark internal-destination="{@id}">
5785
- <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>
5786
5800
  </fo:bookmark>
5787
5801
  </xsl:for-each>
5788
5802
  </fo:bookmark>
5789
5803
  </xsl:if>
5790
5804
 
5791
- <xsl:if test="$list_of_figures//figure">
5792
- <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">
5793
5807
  <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
-
5808
+ <xsl:value-of select="$title-list-figures"/>
5800
5809
  </fo:bookmark-title>
5801
- <xsl:for-each select="$list_of_figures//figure">
5810
+ <xsl:for-each select="$contents//figures/figure">
5802
5811
  <fo:bookmark internal-destination="{@id}">
5803
- <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>
5804
5816
  </fo:bookmark>
5805
5817
  </xsl:for-each>
5806
5818
  </fo:bookmark>
5807
5819
  </xsl:if>
5808
5820
 
5809
-
5810
5821
  <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} -->
5822
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
5812
5823
  <fo:bookmark-title>
5813
- <xsl:call-template name="getTitle">
5814
- <xsl:with-param name="name" select="'title-list-recommendations'"/>
5815
- </xsl:call-template>
5824
+ <xsl:value-of select="$title-list-recommendations"/>
5816
5825
  </fo:bookmark-title>
5817
- <!-- <xsl:for-each select="//*[local-name() = 'table'][.//*[local-name() = 'p'][@class = 'RecommendationTitle']]"> -->
5818
5826
  <xsl:for-each select="xalan:nodeset($toc_recommendations)/*">
5819
- <xsl:variable name="table_id" select="@id"/>
5820
5827
  <fo:bookmark internal-destination="{@id}">
5821
5828
  <fo:bookmark-title><xsl:value-of select="bookmark"/></fo:bookmark-title>
5822
5829
  </fo:bookmark>
5823
5830
  </xsl:for-each>
5824
5831
  </fo:bookmark>
5825
5832
  </xsl:if>
5833
+ <!-- $namespace = 'ogc' -->
5826
5834
 
5827
5835
 
5828
-
5836
+
5829
5837
 
5830
5838
  </fo:bookmark-tree>
5831
5839
  </xsl:if>
5832
5840
  </xsl:template><xsl:template name="insertFigureBookmarks">
5833
5841
  <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">
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">
5836
5845
  <fo:bookmark-title>Figures</fo:bookmark-title>
5837
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5846
+ <xsl:for-each select="$contents_nodes/figure">
5838
5847
  <fo:bookmark internal-destination="{@id}">
5839
5848
  <fo:bookmark-title>
5840
5849
  <xsl:value-of select="normalize-space(title)"/>
@@ -5843,18 +5852,21 @@
5843
5852
  </xsl:for-each>
5844
5853
  </fo:bookmark>
5845
5854
  </xsl:if>
5855
+
5856
+ <!-- see template addBookmarks -->
5846
5857
  </xsl:template><xsl:template name="insertTableBookmarks">
5847
5858
  <xsl:param name="contents"/>
5848
5859
  <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">
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">
5851
5863
  <fo:bookmark-title>
5852
5864
  <xsl:choose>
5853
5865
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
5854
5866
  <xsl:otherwise>Tables</xsl:otherwise>
5855
5867
  </xsl:choose>
5856
5868
  </fo:bookmark-title>
5857
- <xsl:for-each select="xalan:nodeset($contents)/table">
5869
+ <xsl:for-each select="$contents_nodes/table">
5858
5870
  <fo:bookmark internal-destination="{@id}">
5859
5871
  <fo:bookmark-title>
5860
5872
  <xsl:value-of select="normalize-space(title)"/>
@@ -5863,6 +5875,8 @@
5863
5875
  </xsl:for-each>
5864
5876
  </fo:bookmark>
5865
5877
  </xsl:if>
5878
+
5879
+ <!-- see template addBookmarks -->
5866
5880
  </xsl:template><xsl:template name="getLangVersion">
5867
5881
  <xsl:param name="lang"/>
5868
5882
  <xsl:param name="doctype" select="''"/>
@@ -6541,6 +6555,8 @@
6541
6555
  </xsl:otherwise>
6542
6556
  </xsl:choose> -->
6543
6557
  </fo:block>
6558
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6559
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6544
6560
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6545
6561
  <xsl:if test="normalize-space() != ''">
6546
6562
  <xsl:value-of select="."/>
@@ -6615,26 +6631,11 @@
6615
6631
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6616
6632
  <xsl:text>— </xsl:text>
6617
6633
  <xsl:apply-templates/>
6618
- </xsl:template><xsl:variable name="bibitem_hidden_">
6619
- <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6620
- <xsl:copy-of select="."/>
6621
- </xsl:for-each>
6622
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6623
- <xsl:copy-of select="."/>
6624
- </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
-
6634
+ </xsl:template><xsl:template match="*[local-name() = 'eref']">
6635
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
6636
+ <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
6636
6637
  <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 -->
6638
+ <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) -->
6638
6639
  <fo:inline xsl:use-attribute-sets="eref-style">
6639
6640
  <xsl:if test="@type = 'footnote'">
6640
6641
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -6648,8 +6649,8 @@
6648
6649
  <xsl:variable name="text" select="normalize-space()"/>
6649
6650
 
6650
6651
 
6651
-
6652
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6652
+
6653
+ <fo:basic-link fox:alt-text="{@citeas}">
6653
6654
  <xsl:if test="normalize-space(@citeas) = ''">
6654
6655
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
6655
6656
  </xsl:if>
@@ -6659,14 +6660,21 @@
6659
6660
 
6660
6661
  </xsl:if>
6661
6662
 
6662
-
6663
+ <xsl:choose>
6664
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
6665
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
6666
+ </xsl:when>
6667
+ <xsl:otherwise>
6668
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6669
+ </xsl:otherwise>
6670
+ </xsl:choose>
6663
6671
 
6664
6672
  <xsl:apply-templates/>
6665
6673
  </fo:basic-link>
6666
-
6674
+
6667
6675
  </fo:inline>
6668
6676
  </xsl:when>
6669
- <xsl:otherwise>
6677
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6670
6678
  <fo:inline><xsl:apply-templates/></fo:inline>
6671
6679
  </xsl:otherwise>
6672
6680
  </xsl:choose>
@@ -7515,6 +7523,24 @@
7515
7523
  <xsl:apply-templates/>
7516
7524
  </fo:inline>
7517
7525
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
7526
+
7527
+ <!-- list of footnotes to calculate actual footnotes number -->
7528
+ <xsl:variable name="p_fn_">
7529
+ <xsl:call-template name="get_fn_list"/>
7530
+ </xsl:variable>
7531
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
7532
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
7533
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
7534
+ <!-- fn sequence number in document -->
7535
+ <xsl:variable name="current_fn_number">
7536
+ <xsl:choose>
7537
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
7538
+ <xsl:otherwise>
7539
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
7540
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
7541
+ </xsl:otherwise>
7542
+ </xsl:choose>
7543
+ </xsl:variable>
7518
7544
  <fo:footnote>
7519
7545
  <xsl:variable name="number">
7520
7546
 
@@ -7523,22 +7549,26 @@
7523
7549
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7524
7550
  </xsl:when>
7525
7551
  <xsl:otherwise>
7526
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
7552
+ <xsl:value-of select="$current_fn_number"/>
7527
7553
  </xsl:otherwise>
7528
7554
  </xsl:choose>
7529
7555
 
7530
7556
  </xsl:variable>
7557
+
7558
+ <xsl:variable name="current_fn_number_text">
7559
+ <xsl:value-of select="$number"/>
7560
+
7561
+ </xsl:variable>
7562
+
7531
7563
  <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
-
7564
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
7565
+ <xsl:value-of select="$current_fn_number_text"/>
7535
7566
  </fo:basic-link>
7536
7567
  </fo:inline>
7537
7568
  <fo:footnote-body>
7538
7569
  <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
-
7570
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
7571
+ <xsl:value-of select="$current_fn_number_text"/>
7542
7572
  </fo:inline>
7543
7573
  <xsl:apply-templates/>
7544
7574
  </fo:block>
@@ -7784,6 +7814,78 @@
7784
7814
  <xsl:apply-templates/>
7785
7815
  </fo:block>
7786
7816
 
7817
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7818
+ <xsl:copy>
7819
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7820
+ </xsl:copy>
7821
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7822
+ <xsl:copy>
7823
+ <xsl:copy-of select="@*"/>
7824
+
7825
+ <xsl:variable name="nodes_preface_">
7826
+ <xsl:for-each select="*">
7827
+ <node id="{@id}"/>
7828
+ </xsl:for-each>
7829
+ </xsl:variable>
7830
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7831
+
7832
+ <xsl:for-each select="*">
7833
+ <xsl:sort select="@displayorder" data-type="number"/>
7834
+
7835
+ <!-- process Section's title -->
7836
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7837
+ <xsl:if test="$preceding-sibling_id != ''">
7838
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7839
+ </xsl:if>
7840
+
7841
+ <xsl:choose>
7842
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7843
+ <xsl:otherwise>
7844
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7845
+ </xsl:otherwise>
7846
+ </xsl:choose>
7847
+
7848
+ </xsl:for-each>
7849
+ </xsl:copy>
7850
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7851
+ <xsl:copy>
7852
+ <xsl:copy-of select="@*"/>
7853
+
7854
+ <xsl:variable name="nodes_sections_">
7855
+ <xsl:for-each select="*">
7856
+ <node id="{@id}"/>
7857
+ </xsl:for-each>
7858
+ </xsl:variable>
7859
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7860
+
7861
+ <!-- move section 'Normative references' inside 'sections' -->
7862
+ <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']]">
7863
+ <xsl:sort select="@displayorder" data-type="number"/>
7864
+
7865
+ <!-- process Section's title -->
7866
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7867
+ <xsl:if test="$preceding-sibling_id != ''">
7868
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7869
+ </xsl:if>
7870
+
7871
+ <xsl:choose>
7872
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7873
+ <xsl:otherwise>
7874
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7875
+ </xsl:otherwise>
7876
+ </xsl:choose>
7877
+
7878
+ </xsl:for-each>
7879
+ </xsl:copy>
7880
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7881
+ <xsl:copy>
7882
+ <xsl:copy-of select="@*"/>
7883
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7884
+ <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
7885
+ <xsl:sort select="@displayorder" data-type="number"/>
7886
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7887
+ </xsl:for-each>
7888
+ </xsl:copy>
7787
7889
  </xsl:template><xsl:template name="convertDate">
7788
7890
  <xsl:param name="date"/>
7789
7891
  <xsl:param name="format" select="'short'"/>