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.
@@ -72,16 +72,18 @@
72
72
  <xsl:attribute-set name="empty-style">
73
73
  </xsl:attribute-set>
74
74
 
75
- <xsl:variable name="contents">
75
+ <xsl:variable name="contents_">
76
76
  <contents>
77
77
  <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
78
78
  <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
79
79
 
80
80
  <xsl:call-template name="processMainSectionsDefault_Contents"/>
81
81
  <xsl:apply-templates select="//ogc:indexsect" mode="contents"/>
82
+
83
+ <xsl:call-template name="processTablesFigures_Contents"/>
82
84
  </contents>
83
85
  </xsl:variable>
84
-
86
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
85
87
 
86
88
  <xsl:template match="/">
87
89
  <xsl:call-template name="namespaceCheck"/>
@@ -206,7 +208,7 @@
206
208
  </xsl:call-template>
207
209
  </fo:block>
208
210
  <xsl:variable name="margin-left">3.9</xsl:variable>
209
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']">
211
+ <xsl:for-each select="$contents//item[@display = 'true']">
210
212
  <fo:block margin-top="8pt" margin-bottom="5pt" margin-left="{(@level - 1) * $margin-left}mm" text-align-last="justify" role="TOCI">
211
213
  <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
212
214
  <xsl:if test="@section != ''">
@@ -630,7 +632,7 @@
630
632
  </xsl:choose>
631
633
  </xsl:template>
632
634
 
633
- <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">
635
+ <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">
634
636
  <xsl:call-template name="getLang"/>
635
637
  </xsl:variable><xsl:variable name="pageWidth_">
636
638
  215.9
@@ -676,7 +678,7 @@
676
678
  <xsl:text>Contents</xsl:text>
677
679
 
678
680
  </title-toc>
679
-
681
+
680
682
  <title-descriptors lang="en">Descriptors</title-descriptors>
681
683
 
682
684
  <title-part lang="en">
@@ -712,7 +714,31 @@
712
714
  <title-continued lang="en">(continued)</title-continued>
713
715
  <title-continued lang="fr">(continué)</title-continued>
714
716
 
715
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
717
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
718
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
719
+ <xsl:value-of select="$toc_table_title"/>
720
+ <xsl:if test="normalize-space($toc_table_title) = ''">
721
+ <xsl:call-template name="getTitle">
722
+ <xsl:with-param name="name" select="'title-list-tables'"/>
723
+ </xsl:call-template>
724
+ </xsl:if>
725
+ </xsl:variable><xsl:variable name="title-list-figures">
726
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
727
+ <xsl:value-of select="$toc_figure_title"/>
728
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
729
+ <xsl:call-template name="getTitle">
730
+ <xsl:with-param name="name" select="'title-list-figures'"/>
731
+ </xsl:call-template>
732
+ </xsl:if>
733
+ </xsl:variable><xsl:variable name="title-list-recommendations">
734
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
735
+ <xsl:value-of select="$toc_requirement_title"/>
736
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
737
+ <xsl:call-template name="getTitle">
738
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
739
+ </xsl:call-template>
740
+ </xsl:if>
741
+ </xsl:variable><xsl:variable name="bibdata">
716
742
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
717
743
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
718
744
  </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
@@ -2048,6 +2074,30 @@
2048
2074
  <xsl:sort select="@displayorder" data-type="number"/>
2049
2075
  <xsl:apply-templates select="." mode="contents"/>
2050
2076
  </xsl:for-each>
2077
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
2078
+ <xsl:param name="always"/>
2079
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2080
+ <xsl:call-template name="processTables_Contents"/>
2081
+ </xsl:if>
2082
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
2083
+ <xsl:call-template name="processFigures_Contents"/>
2084
+ </xsl:if>
2085
+ </xsl:template><xsl:template name="processTables_Contents">
2086
+ <tables>
2087
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
2088
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
2089
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2090
+ </table>
2091
+ </xsl:for-each>
2092
+ </tables>
2093
+ </xsl:template><xsl:template name="processFigures_Contents">
2094
+ <figures>
2095
+ <xsl:for-each select="//*[local-name() = 'figure'][@id and *[local-name() = 'name'] and not(@unnumbered = 'true') and normalize-space(@id) != ''] | //*[@id and starts-with(*[local-name() = 'name'], 'Figure ') and normalize-space(@id) != '']">
2096
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
2097
+ <xsl:copy-of select="*[local-name() = 'name']"/>
2098
+ </figure>
2099
+ </xsl:for-each>
2100
+ </figures>
2051
2101
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2052
2102
  <xsl:for-each select="/*/*[local-name()='preface']/*">
2053
2103
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2865,37 +2915,7 @@
2865
2915
 
2866
2916
  <!-- list of footnotes to calculate actual footnotes number -->
2867
2917
  <xsl:variable name="p_fn_">
2868
- <xsl:choose>
2869
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2870
- <fn gen_id="{generate-id(.)}">
2871
- <xsl:copy-of select="@*"/>
2872
- <xsl:copy-of select="node()"/>
2873
- </fn>
2874
- </xsl:when>
2875
- <xsl:otherwise>
2876
- <!-- itetation for:
2877
- footnotes in bibdata/title
2878
- footnotes in bibliography
2879
- footnotes in document's body (except table's head/body/foot and figure text)
2880
- -->
2881
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2882
- <fn gen_id="{generate-id(.)}">
2883
- <xsl:copy-of select="@*"/>
2884
- <xsl:copy-of select="node()"/>
2885
- </fn>
2886
- </xsl:for-each>
2887
- <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']/*">
2888
- <xsl:sort select="@displayorder" data-type="number"/>
2889
- <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])]">
2890
- <!-- copy unique fn -->
2891
- <fn gen_id="{generate-id(.)}">
2892
- <xsl:copy-of select="@*"/>
2893
- <xsl:copy-of select="node()"/>
2894
- </fn>
2895
- </xsl:for-each>
2896
- </xsl:for-each>
2897
- </xsl:otherwise>
2898
- </xsl:choose>
2918
+ <xsl:call-template name="get_fn_list"/>
2899
2919
  </xsl:variable>
2900
2920
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2901
2921
 
@@ -2956,6 +2976,38 @@
2956
2976
  <xsl:copy-of select="$footnote_inline"/>
2957
2977
  </xsl:otherwise>
2958
2978
  </xsl:choose>
2979
+ </xsl:template><xsl:template name="get_fn_list">
2980
+ <xsl:choose>
2981
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2982
+ <fn gen_id="{generate-id(.)}">
2983
+ <xsl:copy-of select="@*"/>
2984
+ <xsl:copy-of select="node()"/>
2985
+ </fn>
2986
+ </xsl:when>
2987
+ <xsl:otherwise>
2988
+ <!-- itetation for:
2989
+ footnotes in bibdata/title
2990
+ footnotes in bibliography
2991
+ footnotes in document's body (except table's head/body/foot and figure text)
2992
+ -->
2993
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2994
+ <fn gen_id="{generate-id(.)}">
2995
+ <xsl:copy-of select="@*"/>
2996
+ <xsl:copy-of select="node()"/>
2997
+ </fn>
2998
+ </xsl:for-each>
2999
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
3000
+ <xsl:sort select="@displayorder" data-type="number"/>
3001
+ <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
3002
+ <!-- copy unique fn -->
3003
+ <fn gen_id="{generate-id(.)}">
3004
+ <xsl:copy-of select="@*"/>
3005
+ <xsl:copy-of select="node()"/>
3006
+ </fn>
3007
+ </xsl:for-each>
3008
+ </xsl:for-each>
3009
+ </xsl:otherwise>
3010
+ </xsl:choose>
2959
3011
  </xsl:template><xsl:template name="table_fn_display">
2960
3012
  <xsl:variable name="references">
2961
3013
 
@@ -3138,7 +3190,7 @@
3138
3190
  </fo:inline>
3139
3191
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3140
3192
  <fo:inline><xsl:value-of select="."/></fo:inline>
3141
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3193
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3142
3194
  <fo:inline>
3143
3195
  <xsl:apply-templates/>
3144
3196
  </fo:inline>
@@ -4830,13 +4882,14 @@
4830
4882
  <xsl:apply-templates mode="bookmarks"/>
4831
4883
  </xsl:template><xsl:template name="addBookmarks">
4832
4884
  <xsl:param name="contents"/>
4833
- <xsl:if test="xalan:nodeset($contents)//item">
4885
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4886
+ <xsl:if test="$contents_nodes//item">
4834
4887
  <fo:bookmark-tree>
4835
4888
  <xsl:choose>
4836
- <xsl:when test="xalan:nodeset($contents)/doc">
4889
+ <xsl:when test="$contents_nodes/doc">
4837
4890
  <xsl:choose>
4838
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4839
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4891
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4892
+ <xsl:for-each select="$contents_nodes/doc">
4840
4893
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4841
4894
  <xsl:if test="@bundle = 'true'">
4842
4895
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4887,7 +4940,7 @@
4887
4940
  </xsl:for-each>
4888
4941
  </xsl:when>
4889
4942
  <xsl:otherwise>
4890
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4943
+ <xsl:for-each select="$contents_nodes/doc">
4891
4944
 
4892
4945
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4893
4946
 
@@ -4905,11 +4958,21 @@
4905
4958
  </xsl:choose>
4906
4959
  </xsl:when>
4907
4960
  <xsl:otherwise>
4908
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4961
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4962
+
4963
+ <xsl:call-template name="insertFigureBookmarks">
4964
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4965
+ </xsl:call-template>
4966
+
4967
+ <xsl:call-template name="insertTableBookmarks">
4968
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4969
+ <xsl:with-param name="lang" select="@lang"/>
4970
+ </xsl:call-template>
4971
+
4909
4972
  </xsl:otherwise>
4910
4973
  </xsl:choose>
4911
4974
 
4912
-
4975
+
4913
4976
 
4914
4977
 
4915
4978
 
@@ -4922,7 +4985,6 @@
4922
4985
  </xsl:variable>
4923
4986
  <xsl:variable name="list_of_tables_figures" select="xalan:nodeset($list_of_tables_figures_)"/>
4924
4987
 
4925
-
4926
4988
  <xsl:if test="$list_of_tables_figures/table_figure">
4927
4989
  <fo:bookmark internal-destination="empty_bookmark">
4928
4990
  <fo:bookmark-title>—————</fo:bookmark-title>
@@ -4930,7 +4992,7 @@
4930
4992
  </xsl:if>
4931
4993
 
4932
4994
  <xsl:if test="$list_of_tables_figures//table_figure">
4933
- <fo:bookmark internal-destination="empty_bookmark" starting-state="hide"> <!-- {$list_of_figures//figure[1]/@id} -->
4995
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4934
4996
  <fo:bookmark-title>
4935
4997
  <xsl:call-template name="getTitle">
4936
4998
  <xsl:with-param name="name" select="'title-table-figures'"/>
@@ -4943,17 +5005,18 @@
4943
5005
  </xsl:for-each>
4944
5006
  </fo:bookmark>
4945
5007
  </xsl:if>
4946
-
4947
-
5008
+ <!-- $namespace = 'ogc-white-paper' -->
5009
+
4948
5010
 
4949
5011
  </fo:bookmark-tree>
4950
5012
  </xsl:if>
4951
5013
  </xsl:template><xsl:template name="insertFigureBookmarks">
4952
5014
  <xsl:param name="contents"/>
4953
- <xsl:if test="xalan:nodeset($contents)/figure">
4954
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
5015
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5016
+ <xsl:if test="$contents_nodes/figure">
5017
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4955
5018
  <fo:bookmark-title>Figures</fo:bookmark-title>
4956
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5019
+ <xsl:for-each select="$contents_nodes/figure">
4957
5020
  <fo:bookmark internal-destination="{@id}">
4958
5021
  <fo:bookmark-title>
4959
5022
  <xsl:value-of select="normalize-space(title)"/>
@@ -4962,18 +5025,21 @@
4962
5025
  </xsl:for-each>
4963
5026
  </fo:bookmark>
4964
5027
  </xsl:if>
5028
+
5029
+ <!-- see template addBookmarks -->
4965
5030
  </xsl:template><xsl:template name="insertTableBookmarks">
4966
5031
  <xsl:param name="contents"/>
4967
5032
  <xsl:param name="lang"/>
4968
- <xsl:if test="xalan:nodeset($contents)/table">
4969
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
5033
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5034
+ <xsl:if test="$contents_nodes/table">
5035
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4970
5036
  <fo:bookmark-title>
4971
5037
  <xsl:choose>
4972
5038
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4973
5039
  <xsl:otherwise>Tables</xsl:otherwise>
4974
5040
  </xsl:choose>
4975
5041
  </fo:bookmark-title>
4976
- <xsl:for-each select="xalan:nodeset($contents)/table">
5042
+ <xsl:for-each select="$contents_nodes/table">
4977
5043
  <fo:bookmark internal-destination="{@id}">
4978
5044
  <fo:bookmark-title>
4979
5045
  <xsl:value-of select="normalize-space(title)"/>
@@ -4982,6 +5048,8 @@
4982
5048
  </xsl:for-each>
4983
5049
  </fo:bookmark>
4984
5050
  </xsl:if>
5051
+
5052
+ <!-- see template addBookmarks -->
4985
5053
  </xsl:template><xsl:template name="getLangVersion">
4986
5054
  <xsl:param name="lang"/>
4987
5055
  <xsl:param name="doctype" select="''"/>
@@ -5648,6 +5716,8 @@
5648
5716
  </xsl:otherwise>
5649
5717
  </xsl:choose> -->
5650
5718
  </fo:block>
5719
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5720
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5651
5721
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5652
5722
  <xsl:if test="normalize-space() != ''">
5653
5723
  <xsl:value-of select="."/>
@@ -5722,26 +5792,11 @@
5722
5792
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5723
5793
  <xsl:text>— </xsl:text>
5724
5794
  <xsl:apply-templates/>
5725
- </xsl:template><xsl:variable name="bibitem_hidden_">
5726
- <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5727
- <xsl:copy-of select="."/>
5728
- </xsl:for-each>
5729
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5730
- <xsl:copy-of select="."/>
5731
- </xsl:for-each>
5732
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5733
-
5734
- <xsl:variable name="bibitemid">
5735
- <xsl:choose>
5736
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5737
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5738
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5739
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5740
- </xsl:choose>
5741
- </xsl:variable>
5742
-
5795
+ </xsl:template><xsl:template match="*[local-name() = 'eref']">
5796
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5797
+ <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
5743
5798
  <xsl:choose>
5744
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5799
+ <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) -->
5745
5800
  <fo:inline xsl:use-attribute-sets="eref-style">
5746
5801
  <xsl:if test="@type = 'footnote'">
5747
5802
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5755,8 +5810,8 @@
5755
5810
  <xsl:variable name="text" select="normalize-space()"/>
5756
5811
 
5757
5812
 
5758
-
5759
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5813
+
5814
+ <fo:basic-link fox:alt-text="{@citeas}">
5760
5815
  <xsl:if test="normalize-space(@citeas) = ''">
5761
5816
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5762
5817
  </xsl:if>
@@ -5769,14 +5824,21 @@
5769
5824
 
5770
5825
  </xsl:if>
5771
5826
 
5772
-
5827
+ <xsl:choose>
5828
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5829
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5830
+ </xsl:when>
5831
+ <xsl:otherwise>
5832
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5833
+ </xsl:otherwise>
5834
+ </xsl:choose>
5773
5835
 
5774
5836
  <xsl:apply-templates/>
5775
5837
  </fo:basic-link>
5776
-
5838
+
5777
5839
  </fo:inline>
5778
5840
  </xsl:when>
5779
- <xsl:otherwise>
5841
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5780
5842
  <fo:inline><xsl:apply-templates/></fo:inline>
5781
5843
  </xsl:otherwise>
5782
5844
  </xsl:choose>
@@ -6627,6 +6689,24 @@
6627
6689
  <xsl:apply-templates/>
6628
6690
  </fo:inline>
6629
6691
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6692
+
6693
+ <!-- list of footnotes to calculate actual footnotes number -->
6694
+ <xsl:variable name="p_fn_">
6695
+ <xsl:call-template name="get_fn_list"/>
6696
+ </xsl:variable>
6697
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6698
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6699
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6700
+ <!-- fn sequence number in document -->
6701
+ <xsl:variable name="current_fn_number">
6702
+ <xsl:choose>
6703
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6704
+ <xsl:otherwise>
6705
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6706
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6707
+ </xsl:otherwise>
6708
+ </xsl:choose>
6709
+ </xsl:variable>
6630
6710
  <fo:footnote>
6631
6711
  <xsl:variable name="number">
6632
6712
 
@@ -6635,22 +6715,26 @@
6635
6715
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6636
6716
  </xsl:when>
6637
6717
  <xsl:otherwise>
6638
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6718
+ <xsl:value-of select="$current_fn_number"/>
6639
6719
  </xsl:otherwise>
6640
6720
  </xsl:choose>
6641
6721
 
6642
6722
  </xsl:variable>
6723
+
6724
+ <xsl:variable name="current_fn_number_text">
6725
+ <xsl:value-of select="$number"/>
6726
+
6727
+ </xsl:variable>
6728
+
6643
6729
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6644
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6645
- <xsl:value-of select="$number"/>
6646
-
6730
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6731
+ <xsl:value-of select="$current_fn_number_text"/>
6647
6732
  </fo:basic-link>
6648
6733
  </fo:inline>
6649
6734
  <fo:footnote-body>
6650
6735
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6651
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6652
- <xsl:value-of select="$number"/>
6653
-
6736
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6737
+ <xsl:value-of select="$current_fn_number_text"/>
6654
6738
  </fo:inline>
6655
6739
  <xsl:apply-templates/>
6656
6740
  </fo:block>
@@ -6896,6 +6980,78 @@
6896
6980
  <xsl:apply-templates/>
6897
6981
  </fo:block>
6898
6982
 
6983
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6984
+ <xsl:copy>
6985
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6986
+ </xsl:copy>
6987
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6988
+ <xsl:copy>
6989
+ <xsl:copy-of select="@*"/>
6990
+
6991
+ <xsl:variable name="nodes_preface_">
6992
+ <xsl:for-each select="*">
6993
+ <node id="{@id}"/>
6994
+ </xsl:for-each>
6995
+ </xsl:variable>
6996
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6997
+
6998
+ <xsl:for-each select="*">
6999
+ <xsl:sort select="@displayorder" data-type="number"/>
7000
+
7001
+ <!-- process Section's title -->
7002
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7003
+ <xsl:if test="$preceding-sibling_id != ''">
7004
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7005
+ </xsl:if>
7006
+
7007
+ <xsl:choose>
7008
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7009
+ <xsl:otherwise>
7010
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7011
+ </xsl:otherwise>
7012
+ </xsl:choose>
7013
+
7014
+ </xsl:for-each>
7015
+ </xsl:copy>
7016
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7017
+ <xsl:copy>
7018
+ <xsl:copy-of select="@*"/>
7019
+
7020
+ <xsl:variable name="nodes_sections_">
7021
+ <xsl:for-each select="*">
7022
+ <node id="{@id}"/>
7023
+ </xsl:for-each>
7024
+ </xsl:variable>
7025
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7026
+
7027
+ <!-- move section 'Normative references' inside 'sections' -->
7028
+ <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']]">
7029
+ <xsl:sort select="@displayorder" data-type="number"/>
7030
+
7031
+ <!-- process Section's title -->
7032
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7033
+ <xsl:if test="$preceding-sibling_id != ''">
7034
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7035
+ </xsl:if>
7036
+
7037
+ <xsl:choose>
7038
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7039
+ <xsl:otherwise>
7040
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7041
+ </xsl:otherwise>
7042
+ </xsl:choose>
7043
+
7044
+ </xsl:for-each>
7045
+ </xsl:copy>
7046
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7047
+ <xsl:copy>
7048
+ <xsl:copy-of select="@*"/>
7049
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7050
+ <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
7051
+ <xsl:sort select="@displayorder" data-type="number"/>
7052
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7053
+ </xsl:for-each>
7054
+ </xsl:copy>
6899
7055
  </xsl:template><xsl:template name="convertDate">
6900
7056
  <xsl:param name="date"/>
6901
7057
  <xsl:param name="format" select="'short'"/>
@@ -12,11 +12,16 @@ module IsoDoc
12
12
  super
13
13
  end
14
14
 
15
- def insert_preface_sections(docxml)
16
- insert_executivesummary(docxml)
17
- insert_submitting_orgs(docxml)
18
- insert_security(docxml)
19
- insert_keywords(docxml)
15
+ def insert_preface_sections(doc)
16
+ preface_insert(doc&.at(ns("//preface/clause"\
17
+ "[@type = 'executivesummary']")),
18
+ doc.at(ns("//preface/abstract")), doc)
19
+ preface_insert(doc&.at(ns("//preface//submitters")),
20
+ submit_orgs_append_pt(doc), doc)
21
+ insert_submitting_orgs(doc)
22
+ preface_insert(doc&.at(ns("//preface/clause[@type = 'security']")),
23
+ submit_orgs_append_pt(doc), doc)
24
+ insert_keywords(doc)
20
25
  end
21
26
 
22
27
  def preface_init_insert_pt(docxml)
@@ -25,31 +30,22 @@ module IsoDoc
25
30
  .add_previous_sibling("<preface> </preface>").first
26
31
  end
27
32
 
28
- def submit_orgs_append_pt(docxml)
29
- docxml.at(ns("//introduction")) ||
30
- docxml.at(ns("//foreword")) ||
31
- docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
32
- docxml.at(ns("//preface/abstract"))
33
- end
33
+ def preface_insert(clause, after, docxml)
34
+ return unless clause
34
35
 
35
- def insert_security(docxml)
36
- s = docxml&.at(ns("//preface/clause[@type = 'security']"))&.remove or
37
- return
38
- if a = submit_orgs_append_pt(docxml) then a.next = s
36
+ clause.remove
37
+ if after then after.next = clause
39
38
  else
40
39
  preface_init_insert_pt(docxml)&.children&.first
41
- &.add_previous_sibling(s)
40
+ &.add_previous_sibling(clause)
42
41
  end
43
42
  end
44
43
 
45
- def insert_executivesummary(docxml)
46
- s = docxml&.at(ns("//preface/clause[@type = 'executivesummary']"))
47
- &.remove or return
48
- if a = docxml.at(ns("//preface/abstract")) then a.next = s
49
- else
50
- preface_init_insert_pt(docxml)&.children&.first
51
- &.add_previous_sibling(s)
52
- end
44
+ def submit_orgs_append_pt(docxml)
45
+ docxml.at(ns("//foreword")) ||
46
+ docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
47
+ docxml.at(ns("//preface/clause[@type = 'executivesummary']")) ||
48
+ docxml.at(ns("//preface/abstract"))
53
49
  end
54
50
 
55
51
  def insert_submitting_orgs(docxml)