metanorma-ogc 2.0.4 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 != ''">
@@ -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"/>
@@ -2069,8 +2119,27 @@
2069
2119
  <xsl:sort select="@displayorder" data-type="number"/>
2070
2120
  <xsl:apply-templates select="."/>
2071
2121
  </xsl:for-each>
2072
- </xsl:template><xsl:template match="text()">
2073
- <xsl:value-of select="."/>
2122
+ </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">
2123
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2124
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2125
+ <xsl:call-template name="replace_fo_inline">
2126
+ <xsl:with-param name="text" select="$text"/>
2127
+ </xsl:call-template>
2128
+ </xsl:template><xsl:template name="replace_fo_inline">
2129
+ <xsl:param name="text"/>
2130
+ <xsl:choose>
2131
+ <xsl:when test="contains($text, $tag_open)">
2132
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
2133
+ <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2134
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2135
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2136
+ <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2137
+ <xsl:call-template name="replace_fo_inline">
2138
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2139
+ </xsl:call-template>
2140
+ </xsl:when>
2141
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
2142
+ </xsl:choose>
2074
2143
  </xsl:template><xsl:template match="*[local-name()='br']">
2075
2144
  <xsl:value-of select="$linebreak"/>
2076
2145
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
@@ -2865,37 +2934,7 @@
2865
2934
 
2866
2935
  <!-- list of footnotes to calculate actual footnotes number -->
2867
2936
  <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>
2937
+ <xsl:call-template name="get_fn_list"/>
2899
2938
  </xsl:variable>
2900
2939
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2901
2940
 
@@ -2956,6 +2995,38 @@
2956
2995
  <xsl:copy-of select="$footnote_inline"/>
2957
2996
  </xsl:otherwise>
2958
2997
  </xsl:choose>
2998
+ </xsl:template><xsl:template name="get_fn_list">
2999
+ <xsl:choose>
3000
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
3001
+ <fn gen_id="{generate-id(.)}">
3002
+ <xsl:copy-of select="@*"/>
3003
+ <xsl:copy-of select="node()"/>
3004
+ </fn>
3005
+ </xsl:when>
3006
+ <xsl:otherwise>
3007
+ <!-- itetation for:
3008
+ footnotes in bibdata/title
3009
+ footnotes in bibliography
3010
+ footnotes in document's body (except table's head/body/foot and figure text)
3011
+ -->
3012
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
3013
+ <fn gen_id="{generate-id(.)}">
3014
+ <xsl:copy-of select="@*"/>
3015
+ <xsl:copy-of select="node()"/>
3016
+ </fn>
3017
+ </xsl:for-each>
3018
+ <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']/*">
3019
+ <xsl:sort select="@displayorder" data-type="number"/>
3020
+ <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])]">
3021
+ <!-- copy unique fn -->
3022
+ <fn gen_id="{generate-id(.)}">
3023
+ <xsl:copy-of select="@*"/>
3024
+ <xsl:copy-of select="node()"/>
3025
+ </fn>
3026
+ </xsl:for-each>
3027
+ </xsl:for-each>
3028
+ </xsl:otherwise>
3029
+ </xsl:choose>
2959
3030
  </xsl:template><xsl:template name="table_fn_display">
2960
3031
  <xsl:variable name="references">
2961
3032
 
@@ -3138,7 +3209,7 @@
3138
3209
  </fo:inline>
3139
3210
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
3140
3211
  <fo:inline><xsl:value-of select="."/></fo:inline>
3141
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
3212
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
3142
3213
  <fo:inline>
3143
3214
  <xsl:apply-templates/>
3144
3215
  </fo:inline>
@@ -4830,13 +4901,14 @@
4830
4901
  <xsl:apply-templates mode="bookmarks"/>
4831
4902
  </xsl:template><xsl:template name="addBookmarks">
4832
4903
  <xsl:param name="contents"/>
4833
- <xsl:if test="xalan:nodeset($contents)//item">
4904
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4905
+ <xsl:if test="$contents_nodes//item">
4834
4906
  <fo:bookmark-tree>
4835
4907
  <xsl:choose>
4836
- <xsl:when test="xalan:nodeset($contents)/doc">
4908
+ <xsl:when test="$contents_nodes/doc">
4837
4909
  <xsl:choose>
4838
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4839
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4910
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4911
+ <xsl:for-each select="$contents_nodes/doc">
4840
4912
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4841
4913
  <xsl:if test="@bundle = 'true'">
4842
4914
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4887,7 +4959,7 @@
4887
4959
  </xsl:for-each>
4888
4960
  </xsl:when>
4889
4961
  <xsl:otherwise>
4890
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4962
+ <xsl:for-each select="$contents_nodes/doc">
4891
4963
 
4892
4964
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4893
4965
 
@@ -4905,11 +4977,21 @@
4905
4977
  </xsl:choose>
4906
4978
  </xsl:when>
4907
4979
  <xsl:otherwise>
4908
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4980
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4981
+
4982
+ <xsl:call-template name="insertFigureBookmarks">
4983
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4984
+ </xsl:call-template>
4985
+
4986
+ <xsl:call-template name="insertTableBookmarks">
4987
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4988
+ <xsl:with-param name="lang" select="@lang"/>
4989
+ </xsl:call-template>
4990
+
4909
4991
  </xsl:otherwise>
4910
4992
  </xsl:choose>
4911
4993
 
4912
-
4994
+
4913
4995
 
4914
4996
 
4915
4997
 
@@ -4922,7 +5004,6 @@
4922
5004
  </xsl:variable>
4923
5005
  <xsl:variable name="list_of_tables_figures" select="xalan:nodeset($list_of_tables_figures_)"/>
4924
5006
 
4925
-
4926
5007
  <xsl:if test="$list_of_tables_figures/table_figure">
4927
5008
  <fo:bookmark internal-destination="empty_bookmark">
4928
5009
  <fo:bookmark-title>—————</fo:bookmark-title>
@@ -4930,7 +5011,7 @@
4930
5011
  </xsl:if>
4931
5012
 
4932
5013
  <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} -->
5014
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4934
5015
  <fo:bookmark-title>
4935
5016
  <xsl:call-template name="getTitle">
4936
5017
  <xsl:with-param name="name" select="'title-table-figures'"/>
@@ -4943,17 +5024,18 @@
4943
5024
  </xsl:for-each>
4944
5025
  </fo:bookmark>
4945
5026
  </xsl:if>
4946
-
4947
-
5027
+ <!-- $namespace = 'ogc-white-paper' -->
5028
+
4948
5029
 
4949
5030
  </fo:bookmark-tree>
4950
5031
  </xsl:if>
4951
5032
  </xsl:template><xsl:template name="insertFigureBookmarks">
4952
5033
  <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">
5034
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5035
+ <xsl:if test="$contents_nodes/figure">
5036
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4955
5037
  <fo:bookmark-title>Figures</fo:bookmark-title>
4956
- <xsl:for-each select="xalan:nodeset($contents)/figure">
5038
+ <xsl:for-each select="$contents_nodes/figure">
4957
5039
  <fo:bookmark internal-destination="{@id}">
4958
5040
  <fo:bookmark-title>
4959
5041
  <xsl:value-of select="normalize-space(title)"/>
@@ -4962,18 +5044,21 @@
4962
5044
  </xsl:for-each>
4963
5045
  </fo:bookmark>
4964
5046
  </xsl:if>
5047
+
5048
+ <!-- see template addBookmarks -->
4965
5049
  </xsl:template><xsl:template name="insertTableBookmarks">
4966
5050
  <xsl:param name="contents"/>
4967
5051
  <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">
5052
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
5053
+ <xsl:if test="$contents_nodes/table">
5054
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4970
5055
  <fo:bookmark-title>
4971
5056
  <xsl:choose>
4972
5057
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4973
5058
  <xsl:otherwise>Tables</xsl:otherwise>
4974
5059
  </xsl:choose>
4975
5060
  </fo:bookmark-title>
4976
- <xsl:for-each select="xalan:nodeset($contents)/table">
5061
+ <xsl:for-each select="$contents_nodes/table">
4977
5062
  <fo:bookmark internal-destination="{@id}">
4978
5063
  <fo:bookmark-title>
4979
5064
  <xsl:value-of select="normalize-space(title)"/>
@@ -4982,6 +5067,8 @@
4982
5067
  </xsl:for-each>
4983
5068
  </fo:bookmark>
4984
5069
  </xsl:if>
5070
+
5071
+ <!-- see template addBookmarks -->
4985
5072
  </xsl:template><xsl:template name="getLangVersion">
4986
5073
  <xsl:param name="lang"/>
4987
5074
  <xsl:param name="doctype" select="''"/>
@@ -5206,7 +5293,51 @@
5206
5293
  <xsl:with-param name="text" select="$text_step1"/>
5207
5294
  </xsl:call-template>
5208
5295
  </xsl:variable>
5209
- <xsl:value-of select="$text_step2"/>
5296
+
5297
+ <!-- <xsl:value-of select="$text_step2"/> -->
5298
+
5299
+ <!-- add zero-width space after space -->
5300
+ <xsl:variable name="text_step3" select="java:replaceAll(java:java.lang.String.new($text_step2),' ',' ​')"/>
5301
+
5302
+ <!-- split text by zero-width space -->
5303
+ <xsl:variable name="text_step4">
5304
+ <xsl:call-template name="split">
5305
+ <xsl:with-param name="pText" select="$text_step3"/>
5306
+ <xsl:with-param name="sep" select="$zero_width_space"/>
5307
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5308
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5309
+ </xsl:call-template>
5310
+ </xsl:variable>
5311
+
5312
+ <xsl:for-each select="xalan:nodeset($text_step4)/item">
5313
+ <xsl:choose>
5314
+ <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5315
+ <xsl:call-template name="interspers">
5316
+ <xsl:with-param name="str" select="."/>
5317
+ </xsl:call-template>
5318
+ </xsl:when>
5319
+ <xsl:otherwise>
5320
+ <xsl:value-of select="."/>
5321
+ </xsl:otherwise>
5322
+ </xsl:choose>
5323
+ </xsl:for-each>
5324
+
5325
+ </xsl:template><xsl:template name="interspers">
5326
+ <xsl:param name="str"/>
5327
+ <xsl:param name="char" select="$zero_width_space"/>
5328
+ <xsl:if test="$str != ''">
5329
+ <xsl:value-of select="substring($str, 1, 1)"/>
5330
+
5331
+ <xsl:variable name="next_char" select="substring($str, 2, 1)"/>
5332
+ <xsl:if test="not(contains(concat(' -.:=_— ', $char), $next_char))">
5333
+ <xsl:value-of select="$char"/>
5334
+ </xsl:if>
5335
+
5336
+ <xsl:call-template name="interspers">
5337
+ <xsl:with-param name="str" select="substring($str, 2)"/>
5338
+ <xsl:with-param name="char" select="$char"/>
5339
+ </xsl:call-template>
5340
+ </xsl:if>
5210
5341
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5211
5342
  <xsl:apply-templates mode="syntax_highlight"/>
5212
5343
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5648,6 +5779,8 @@
5648
5779
  </xsl:otherwise>
5649
5780
  </xsl:choose> -->
5650
5781
  </fo:block>
5782
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5783
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5651
5784
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5652
5785
  <xsl:if test="normalize-space() != ''">
5653
5786
  <xsl:value-of select="."/>
@@ -5682,7 +5815,8 @@
5682
5815
  <fo:inline><xsl:apply-templates/></fo:inline>
5683
5816
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
5684
5817
  <xsl:if test="normalize-space() != ''">
5685
- <xsl:value-of select="."/>
5818
+ <!-- <xsl:value-of select="."/> -->
5819
+ <xsl:call-template name="text"/>
5686
5820
  </xsl:if>
5687
5821
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
5688
5822
  <fo:block-container margin-left="0mm">
@@ -5722,26 +5856,24 @@
5722
5856
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5723
5857
  <xsl:text>— </xsl:text>
5724
5858
  <xsl:apply-templates/>
5725
- </xsl:template><xsl:variable name="bibitem_hidden_">
5859
+ </xsl:template><xsl:variable name="bibitems_">
5860
+ <xsl:for-each select="//*[local-name() = 'bibitem']">
5861
+ <xsl:copy-of select="."/>
5862
+ </xsl:for-each>
5863
+ </xsl:variable><xsl:variable name="bibitems" select="xalan:nodeset($bibitems_)"/><xsl:variable name="bibitems_hidden_">
5726
5864
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5727
5865
  <xsl:copy-of select="."/>
5728
5866
  </xsl:for-each>
5729
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5867
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']//*[local-name() = 'bibitem']">
5730
5868
  <xsl:copy-of select="."/>
5731
5869
  </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
-
5870
+ </xsl:variable><xsl:variable name="bibitems_hidden" select="xalan:nodeset($bibitems_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5871
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5872
+ <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
5873
+ <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
5743
5874
  <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 -->
5875
+ <!-- <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) -->
5876
+ <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) -->
5745
5877
  <fo:inline xsl:use-attribute-sets="eref-style">
5746
5878
  <xsl:if test="@type = 'footnote'">
5747
5879
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5755,8 +5887,8 @@
5755
5887
  <xsl:variable name="text" select="normalize-space()"/>
5756
5888
 
5757
5889
 
5758
-
5759
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5890
+
5891
+ <fo:basic-link fox:alt-text="{@citeas}">
5760
5892
  <xsl:if test="normalize-space(@citeas) = ''">
5761
5893
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5762
5894
  </xsl:if>
@@ -5769,14 +5901,21 @@
5769
5901
 
5770
5902
  </xsl:if>
5771
5903
 
5772
-
5904
+ <xsl:choose>
5905
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5906
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5907
+ </xsl:when>
5908
+ <xsl:otherwise>
5909
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5910
+ </xsl:otherwise>
5911
+ </xsl:choose>
5773
5912
 
5774
5913
  <xsl:apply-templates/>
5775
5914
  </fo:basic-link>
5776
-
5915
+
5777
5916
  </fo:inline>
5778
5917
  </xsl:when>
5779
- <xsl:otherwise>
5918
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5780
5919
  <fo:inline><xsl:apply-templates/></fo:inline>
5781
5920
  </xsl:otherwise>
5782
5921
  </xsl:choose>
@@ -6627,6 +6766,24 @@
6627
6766
  <xsl:apply-templates/>
6628
6767
  </fo:inline>
6629
6768
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6769
+
6770
+ <!-- list of footnotes to calculate actual footnotes number -->
6771
+ <xsl:variable name="p_fn_">
6772
+ <xsl:call-template name="get_fn_list"/>
6773
+ </xsl:variable>
6774
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6775
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6776
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6777
+ <!-- fn sequence number in document -->
6778
+ <xsl:variable name="current_fn_number">
6779
+ <xsl:choose>
6780
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6781
+ <xsl:otherwise>
6782
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6783
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6784
+ </xsl:otherwise>
6785
+ </xsl:choose>
6786
+ </xsl:variable>
6630
6787
  <fo:footnote>
6631
6788
  <xsl:variable name="number">
6632
6789
 
@@ -6635,22 +6792,26 @@
6635
6792
  <xsl:number level="any" count="*[local-name() = 'references'][preceding-sibling::*[local-name() = 'references']]//*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6636
6793
  </xsl:when>
6637
6794
  <xsl:otherwise>
6638
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6795
+ <xsl:value-of select="$current_fn_number"/>
6639
6796
  </xsl:otherwise>
6640
6797
  </xsl:choose>
6641
6798
 
6642
6799
  </xsl:variable>
6800
+
6801
+ <xsl:variable name="current_fn_number_text">
6802
+ <xsl:value-of select="$number"/>
6803
+
6804
+ </xsl:variable>
6805
+
6643
6806
  <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
-
6807
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6808
+ <xsl:value-of select="$current_fn_number_text"/>
6647
6809
  </fo:basic-link>
6648
6810
  </fo:inline>
6649
6811
  <fo:footnote-body>
6650
6812
  <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
-
6813
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6814
+ <xsl:value-of select="$current_fn_number_text"/>
6654
6815
  </fo:inline>
6655
6816
  <xsl:apply-templates/>
6656
6817
  </fo:block>
@@ -6896,6 +7057,78 @@
6896
7057
  <xsl:apply-templates/>
6897
7058
  </fo:block>
6898
7059
 
7060
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
7061
+ <xsl:copy>
7062
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
7063
+ </xsl:copy>
7064
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
7065
+ <xsl:copy>
7066
+ <xsl:copy-of select="@*"/>
7067
+
7068
+ <xsl:variable name="nodes_preface_">
7069
+ <xsl:for-each select="*">
7070
+ <node id="{@id}"/>
7071
+ </xsl:for-each>
7072
+ </xsl:variable>
7073
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
7074
+
7075
+ <xsl:for-each select="*">
7076
+ <xsl:sort select="@displayorder" data-type="number"/>
7077
+
7078
+ <!-- process Section's title -->
7079
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7080
+ <xsl:if test="$preceding-sibling_id != ''">
7081
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7082
+ </xsl:if>
7083
+
7084
+ <xsl:choose>
7085
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7086
+ <xsl:otherwise>
7087
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7088
+ </xsl:otherwise>
7089
+ </xsl:choose>
7090
+
7091
+ </xsl:for-each>
7092
+ </xsl:copy>
7093
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
7094
+ <xsl:copy>
7095
+ <xsl:copy-of select="@*"/>
7096
+
7097
+ <xsl:variable name="nodes_sections_">
7098
+ <xsl:for-each select="*">
7099
+ <node id="{@id}"/>
7100
+ </xsl:for-each>
7101
+ </xsl:variable>
7102
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
7103
+
7104
+ <!-- move section 'Normative references' inside 'sections' -->
7105
+ <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']]">
7106
+ <xsl:sort select="@displayorder" data-type="number"/>
7107
+
7108
+ <!-- process Section's title -->
7109
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
7110
+ <xsl:if test="$preceding-sibling_id != ''">
7111
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
7112
+ </xsl:if>
7113
+
7114
+ <xsl:choose>
7115
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
7116
+ <xsl:otherwise>
7117
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7118
+ </xsl:otherwise>
7119
+ </xsl:choose>
7120
+
7121
+ </xsl:for-each>
7122
+ </xsl:copy>
7123
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
7124
+ <xsl:copy>
7125
+ <xsl:copy-of select="@*"/>
7126
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
7127
+ <xsl:for-each select="*[not(@normative='true') and not(*[@normative='true'])]">
7128
+ <xsl:sort select="@displayorder" data-type="number"/>
7129
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
7130
+ </xsl:for-each>
7131
+ </xsl:copy>
6899
7132
  </xsl:template><xsl:template name="convertDate">
6900
7133
  <xsl:param name="date"/>
6901
7134
  <xsl:param name="format" select="'short'"/>
@@ -7140,22 +7373,25 @@
7140
7373
  <xsl:param name="pText" select="."/>
7141
7374
  <xsl:param name="sep" select="','"/>
7142
7375
  <xsl:param name="normalize-space" select="'true'"/>
7376
+ <xsl:param name="keep_sep" select="'false'"/>
7143
7377
  <xsl:if test="string-length($pText) &gt;0">
7144
- <item>
7145
- <xsl:choose>
7146
- <xsl:when test="$normalize-space = 'true'">
7147
- <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7148
- </xsl:when>
7149
- <xsl:otherwise>
7150
- <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7151
- </xsl:otherwise>
7152
- </xsl:choose>
7153
- </item>
7154
- <xsl:call-template name="split">
7155
- <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7156
- <xsl:with-param name="sep" select="$sep"/>
7157
- <xsl:with-param name="normalize-space" select="$normalize-space"/>
7158
- </xsl:call-template>
7378
+ <item>
7379
+ <xsl:choose>
7380
+ <xsl:when test="$normalize-space = 'true'">
7381
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
7382
+ </xsl:when>
7383
+ <xsl:otherwise>
7384
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
7385
+ </xsl:otherwise>
7386
+ </xsl:choose>
7387
+ </item>
7388
+ <xsl:if test="$keep_sep = 'true' and contains($pText, $sep)"><item><xsl:value-of select="$sep"/></item></xsl:if>
7389
+ <xsl:call-template name="split">
7390
+ <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
7391
+ <xsl:with-param name="sep" select="$sep"/>
7392
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
7393
+ <xsl:with-param name="keep_sep" select="$keep_sep"/>
7394
+ </xsl:call-template>
7159
7395
  </xsl:if>
7160
7396
  </xsl:template><xsl:template name="getDocumentId">
7161
7397
  <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>