metanorma-mpfa 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,7 @@
32
32
  <item level="1" id="Foreword" display="true">Foreword</item>
33
33
  <item id="term-script" display="false">3.2</item>
34
34
  -->
35
- <xsl:variable name="contents">
35
+ <xsl:variable name="contents_">
36
36
  <contents>
37
37
  <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:preface/*[not(local-name() = 'terms')]" mode="contents"/>
38
38
  <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:preface/mpfd:terms" mode="contents"/>
@@ -41,11 +41,12 @@
41
41
 
42
42
  <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:annex" mode="contents"/>
43
43
 
44
- <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:bibliography" mode="contents"/>
44
+ <xsl:apply-templates select="/mpfd:mpfd-standard/mpfd:bibliography" mode="contents"/>
45
45
 
46
+ <xsl:call-template name="processTablesFigures_Contents"/>
46
47
  </contents>
47
48
  </xsl:variable>
48
-
49
+ <xsl:variable name="contents" select="xalan:nodeset($contents_)"/>
49
50
 
50
51
  <xsl:template match="/">
51
52
  <xsl:call-template name="namespaceCheck"/>
@@ -159,7 +160,7 @@
159
160
  <xsl:if test="$debug = 'true'">
160
161
  <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
161
162
  DEBUG
162
- contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
163
+ contents=<xsl:copy-of select="$contents"/>
163
164
  <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
164
165
  </xsl:if>
165
166
  <!-- Table of content -->
@@ -171,7 +172,7 @@
171
172
  </xsl:variable>
172
173
  <fo:block font-size="14pt" margin-bottom="15.5pt" role="H1"><xsl:value-of select="$title-toc"/></fo:block>
173
174
  <fo:block line-height="115%" role="TOC">
174
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']">
175
+ <xsl:for-each select="$contents//item[@display = 'true']">
175
176
  <fo:block role="TOCI">
176
177
  <xsl:if test="@level = 1">
177
178
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
@@ -191,21 +192,43 @@
191
192
  </xsl:if>
192
193
  </fo:block>
193
194
  </fo:list-item-label>
194
- <fo:list-item-body start-indent="body-start()">
195
- <fo:block text-align-last="justify">
196
- <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
197
- <xsl:apply-templates select="title"/>
198
- <fo:inline keep-together.within-line="always">
199
- <fo:leader leader-pattern="dots"/>
200
- <fo:page-number-citation ref-id="{@id}"/>
201
- </fo:inline>
202
- </fo:basic-link>
203
- </fo:block>
204
- </fo:list-item-body>
195
+ <fo:list-item-body start-indent="body-start()">
196
+ <fo:block text-align-last="justify">
197
+ <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
198
+ <xsl:apply-templates select="title"/>
199
+ <fo:inline keep-together.within-line="always">
200
+ <fo:leader leader-pattern="dots"/>
201
+ <fo:page-number-citation ref-id="{@id}"/>
202
+ </fo:inline>
203
+ </fo:basic-link>
204
+ </fo:block>
205
+ </fo:list-item-body>
205
206
  </fo:list-item>
206
207
  </fo:list-block>
207
208
  </fo:block>
208
209
  </xsl:for-each>
210
+
211
+
212
+ <!-- List of Tables -->
213
+ <xsl:if test="$contents//tables/table">
214
+ <xsl:call-template name="insertListOf_Title">
215
+ <xsl:with-param name="title" select="$title-list-tables"/>
216
+ </xsl:call-template>
217
+ <xsl:for-each select="$contents//tables/table">
218
+ <xsl:call-template name="insertListOf_Item"/>
219
+ </xsl:for-each>
220
+ </xsl:if>
221
+
222
+ <!-- List of Figures -->
223
+ <xsl:if test="$contents//figures/figure">
224
+ <xsl:call-template name="insertListOf_Title">
225
+ <xsl:with-param name="title" select="$title-list-figures"/>
226
+ </xsl:call-template>
227
+ <xsl:for-each select="$contents//figures/figure">
228
+ <xsl:call-template name="insertListOf_Item"/>
229
+ </xsl:for-each>
230
+ </xsl:if>
231
+
209
232
  </fo:block>
210
233
  </fo:block-container>
211
234
  <xsl:if test="/mpfd:mpfd-standard/mpfd:preface/*">
@@ -246,6 +269,28 @@
246
269
  </fo:root>
247
270
  </xsl:template>
248
271
 
272
+ <xsl:template name="insertListOf_Title">
273
+ <xsl:param name="title"/>
274
+ <fo:block margin-top="6pt" keep-with-next="always">
275
+ <xsl:value-of select="$title"/>
276
+ </fo:block>
277
+ </xsl:template>
278
+
279
+ <xsl:template name="insertListOf_Item">
280
+ <fo:block role="TOCI" text-align-last="justify">
281
+ <fo:basic-link internal-destination="{@id}">
282
+ <xsl:call-template name="setAltText">
283
+ <xsl:with-param name="value" select="@alt-text"/>
284
+ </xsl:call-template>
285
+ <xsl:apply-templates select="." mode="contents"/>
286
+ <fo:inline keep-together.within-line="always">
287
+ <fo:leader leader-pattern="dots"/>
288
+ <fo:page-number-citation ref-id="{@id}"/>
289
+ </fo:inline>
290
+ </fo:basic-link>
291
+ </fo:block>
292
+ </xsl:template>
293
+
249
294
  <xsl:template match="node()">
250
295
  <xsl:apply-templates/>
251
296
  </xsl:template>
@@ -525,7 +570,7 @@
525
570
  </xsl:template>
526
571
 
527
572
 
528
- <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">
573
+ <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">
529
574
  <xsl:call-template name="getLang"/>
530
575
  </xsl:variable><xsl:variable name="pageWidth_">
531
576
  210
@@ -571,7 +616,7 @@
571
616
  <xsl:text>Contents</xsl:text>
572
617
 
573
618
  </title-toc>
574
-
619
+
575
620
  <title-descriptors lang="en">Descriptors</title-descriptors>
576
621
 
577
622
  <title-part lang="en">
@@ -607,7 +652,31 @@
607
652
  <title-continued lang="en">(continued)</title-continued>
608
653
  <title-continued lang="fr">(continué)</title-continued>
609
654
 
610
- </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="bibdata">
655
+ </xsl:variable><xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="title-list-tables">
656
+ <xsl:variable name="toc_table_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']"/>
657
+ <xsl:value-of select="$toc_table_title"/>
658
+ <xsl:if test="normalize-space($toc_table_title) = ''">
659
+ <xsl:call-template name="getTitle">
660
+ <xsl:with-param name="name" select="'title-list-tables'"/>
661
+ </xsl:call-template>
662
+ </xsl:if>
663
+ </xsl:variable><xsl:variable name="title-list-figures">
664
+ <xsl:variable name="toc_figure_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']"/>
665
+ <xsl:value-of select="$toc_figure_title"/>
666
+ <xsl:if test="normalize-space($toc_figure_title) = ''">
667
+ <xsl:call-template name="getTitle">
668
+ <xsl:with-param name="name" select="'title-list-figures'"/>
669
+ </xsl:call-template>
670
+ </xsl:if>
671
+ </xsl:variable><xsl:variable name="title-list-recommendations">
672
+ <xsl:variable name="toc_requirement_title" select="//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='requirement']/*[local-name() = 'title']"/>
673
+ <xsl:value-of select="$toc_requirement_title"/>
674
+ <xsl:if test="normalize-space($toc_requirement_title) = ''">
675
+ <xsl:call-template name="getTitle">
676
+ <xsl:with-param name="name" select="'title-list-recommendations'"/>
677
+ </xsl:call-template>
678
+ </xsl:if>
679
+ </xsl:variable><xsl:variable name="bibdata">
611
680
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
612
681
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
613
682
  </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">
@@ -1784,6 +1853,30 @@
1784
1853
  <xsl:sort select="@displayorder" data-type="number"/>
1785
1854
  <xsl:apply-templates select="." mode="contents"/>
1786
1855
  </xsl:for-each>
1856
+ </xsl:template><xsl:template name="processTablesFigures_Contents">
1857
+ <xsl:param name="always"/>
1858
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='table']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1859
+ <xsl:call-template name="processTables_Contents"/>
1860
+ </xsl:if>
1861
+ <xsl:if test="(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'toc'][@type='figure']/*[local-name() = 'title']) or normalize-space($always) = 'true'">
1862
+ <xsl:call-template name="processFigures_Contents"/>
1863
+ </xsl:if>
1864
+ </xsl:template><xsl:template name="processTables_Contents">
1865
+ <tables>
1866
+ <xsl:for-each select="//*[local-name() = 'table'][@id and *[local-name() = 'name'] and normalize-space(@id) != '']">
1867
+ <table id="{@id}" alt-text="{*[local-name() = 'name']}">
1868
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1869
+ </table>
1870
+ </xsl:for-each>
1871
+ </tables>
1872
+ </xsl:template><xsl:template name="processFigures_Contents">
1873
+ <figures>
1874
+ <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) != '']">
1875
+ <figure id="{@id}" alt-text="{*[local-name() = 'name']}">
1876
+ <xsl:copy-of select="*[local-name() = 'name']"/>
1877
+ </figure>
1878
+ </xsl:for-each>
1879
+ </figures>
1787
1880
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1788
1881
  <xsl:for-each select="/*/*[local-name()='preface']/*">
1789
1882
  <xsl:sort select="@displayorder" data-type="number"/>
@@ -2556,37 +2649,7 @@
2556
2649
 
2557
2650
  <!-- list of footnotes to calculate actual footnotes number -->
2558
2651
  <xsl:variable name="p_fn_">
2559
- <xsl:choose>
2560
- <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2561
- <fn gen_id="{generate-id(.)}">
2562
- <xsl:copy-of select="@*"/>
2563
- <xsl:copy-of select="node()"/>
2564
- </fn>
2565
- </xsl:when>
2566
- <xsl:otherwise>
2567
- <!-- itetation for:
2568
- footnotes in bibdata/title
2569
- footnotes in bibliography
2570
- footnotes in document's body (except table's head/body/foot and figure text)
2571
- -->
2572
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2573
- <fn gen_id="{generate-id(.)}">
2574
- <xsl:copy-of select="@*"/>
2575
- <xsl:copy-of select="node()"/>
2576
- </fn>
2577
- </xsl:for-each>
2578
- <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']/*">
2579
- <xsl:sort select="@displayorder" data-type="number"/>
2580
- <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])]">
2581
- <!-- copy unique fn -->
2582
- <fn gen_id="{generate-id(.)}">
2583
- <xsl:copy-of select="@*"/>
2584
- <xsl:copy-of select="node()"/>
2585
- </fn>
2586
- </xsl:for-each>
2587
- </xsl:for-each>
2588
- </xsl:otherwise>
2589
- </xsl:choose>
2652
+ <xsl:call-template name="get_fn_list"/>
2590
2653
  </xsl:variable>
2591
2654
  <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2592
2655
 
@@ -2647,6 +2710,38 @@
2647
2710
  <xsl:copy-of select="$footnote_inline"/>
2648
2711
  </xsl:otherwise>
2649
2712
  </xsl:choose>
2713
+ </xsl:template><xsl:template name="get_fn_list">
2714
+ <xsl:choose>
2715
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2716
+ <fn gen_id="{generate-id(.)}">
2717
+ <xsl:copy-of select="@*"/>
2718
+ <xsl:copy-of select="node()"/>
2719
+ </fn>
2720
+ </xsl:when>
2721
+ <xsl:otherwise>
2722
+ <!-- itetation for:
2723
+ footnotes in bibdata/title
2724
+ footnotes in bibliography
2725
+ footnotes in document's body (except table's head/body/foot and figure text)
2726
+ -->
2727
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2728
+ <fn gen_id="{generate-id(.)}">
2729
+ <xsl:copy-of select="@*"/>
2730
+ <xsl:copy-of select="node()"/>
2731
+ </fn>
2732
+ </xsl:for-each>
2733
+ <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']/*">
2734
+ <xsl:sort select="@displayorder" data-type="number"/>
2735
+ <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])]">
2736
+ <!-- copy unique fn -->
2737
+ <fn gen_id="{generate-id(.)}">
2738
+ <xsl:copy-of select="@*"/>
2739
+ <xsl:copy-of select="node()"/>
2740
+ </fn>
2741
+ </xsl:for-each>
2742
+ </xsl:for-each>
2743
+ </xsl:otherwise>
2744
+ </xsl:choose>
2650
2745
  </xsl:template><xsl:template name="table_fn_display">
2651
2746
  <xsl:variable name="references">
2652
2747
 
@@ -2818,7 +2913,7 @@
2818
2913
  </fo:inline>
2819
2914
  </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
2820
2915
  <fo:inline><xsl:value-of select="."/></fo:inline>
2821
- </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
2916
+ </xsl:template><xsl:template match="*[local-name()='fn']//*[local-name()='p']">
2822
2917
  <fo:inline>
2823
2918
  <xsl:apply-templates/>
2824
2919
  </fo:inline>
@@ -4504,13 +4599,14 @@
4504
4599
  <xsl:apply-templates mode="bookmarks"/>
4505
4600
  </xsl:template><xsl:template name="addBookmarks">
4506
4601
  <xsl:param name="contents"/>
4507
- <xsl:if test="xalan:nodeset($contents)//item">
4602
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4603
+ <xsl:if test="$contents_nodes//item">
4508
4604
  <fo:bookmark-tree>
4509
4605
  <xsl:choose>
4510
- <xsl:when test="xalan:nodeset($contents)/doc">
4606
+ <xsl:when test="$contents_nodes/doc">
4511
4607
  <xsl:choose>
4512
- <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4513
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4608
+ <xsl:when test="count($contents_nodes/doc) &gt; 1">
4609
+ <xsl:for-each select="$contents_nodes/doc">
4514
4610
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4515
4611
  <xsl:if test="@bundle = 'true'">
4516
4612
  <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
@@ -4561,7 +4657,7 @@
4561
4657
  </xsl:for-each>
4562
4658
  </xsl:when>
4563
4659
  <xsl:otherwise>
4564
- <xsl:for-each select="xalan:nodeset($contents)/doc">
4660
+ <xsl:for-each select="$contents_nodes/doc">
4565
4661
 
4566
4662
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4567
4663
 
@@ -4579,25 +4675,36 @@
4579
4675
  </xsl:choose>
4580
4676
  </xsl:when>
4581
4677
  <xsl:otherwise>
4582
- <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>
4678
+ <xsl:apply-templates select="$contents_nodes/contents/item" mode="bookmark"/>
4679
+
4680
+ <xsl:call-template name="insertFigureBookmarks">
4681
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4682
+ </xsl:call-template>
4683
+
4684
+ <xsl:call-template name="insertTableBookmarks">
4685
+ <xsl:with-param name="contents" select="$contents_nodes/contents"/>
4686
+ <xsl:with-param name="lang" select="@lang"/>
4687
+ </xsl:call-template>
4688
+
4583
4689
  </xsl:otherwise>
4584
4690
  </xsl:choose>
4585
4691
 
4692
+
4586
4693
 
4587
4694
 
4588
4695
 
4589
4696
 
4590
-
4591
-
4697
+
4592
4698
 
4593
4699
  </fo:bookmark-tree>
4594
4700
  </xsl:if>
4595
4701
  </xsl:template><xsl:template name="insertFigureBookmarks">
4596
4702
  <xsl:param name="contents"/>
4597
- <xsl:if test="xalan:nodeset($contents)/figure">
4598
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
4703
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4704
+ <xsl:if test="$contents_nodes/figure">
4705
+ <fo:bookmark internal-destination="{$contents_nodes/figure[1]/@id}" starting-state="hide">
4599
4706
  <fo:bookmark-title>Figures</fo:bookmark-title>
4600
- <xsl:for-each select="xalan:nodeset($contents)/figure">
4707
+ <xsl:for-each select="$contents_nodes/figure">
4601
4708
  <fo:bookmark internal-destination="{@id}">
4602
4709
  <fo:bookmark-title>
4603
4710
  <xsl:value-of select="normalize-space(title)"/>
@@ -4606,18 +4713,40 @@
4606
4713
  </xsl:for-each>
4607
4714
  </fo:bookmark>
4608
4715
  </xsl:if>
4716
+
4717
+
4718
+ <xsl:if test="$contents_nodes//figures/figure">
4719
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4720
+
4721
+
4722
+
4723
+ <xsl:variable name="bookmark-title">
4724
+
4725
+ <xsl:value-of select="$title-list-figures"/>
4726
+
4727
+ </xsl:variable>
4728
+ <fo:bookmark-title><xsl:value-of select="normalize-space($bookmark-title)"/></fo:bookmark-title>
4729
+ <xsl:for-each select="$contents_nodes//figures/figure">
4730
+ <fo:bookmark internal-destination="{@id}">
4731
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4732
+ </fo:bookmark>
4733
+ </xsl:for-each>
4734
+ </fo:bookmark>
4735
+ </xsl:if>
4736
+
4609
4737
  </xsl:template><xsl:template name="insertTableBookmarks">
4610
4738
  <xsl:param name="contents"/>
4611
4739
  <xsl:param name="lang"/>
4612
- <xsl:if test="xalan:nodeset($contents)/table">
4613
- <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
4740
+ <xsl:variable name="contents_nodes" select="xalan:nodeset($contents)"/>
4741
+ <xsl:if test="$contents_nodes/table">
4742
+ <fo:bookmark internal-destination="{$contents_nodes/table[1]/@id}" starting-state="hide">
4614
4743
  <fo:bookmark-title>
4615
4744
  <xsl:choose>
4616
4745
  <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
4617
4746
  <xsl:otherwise>Tables</xsl:otherwise>
4618
4747
  </xsl:choose>
4619
4748
  </fo:bookmark-title>
4620
- <xsl:for-each select="xalan:nodeset($contents)/table">
4749
+ <xsl:for-each select="$contents_nodes/table">
4621
4750
  <fo:bookmark internal-destination="{@id}">
4622
4751
  <fo:bookmark-title>
4623
4752
  <xsl:value-of select="normalize-space(title)"/>
@@ -4626,6 +4755,29 @@
4626
4755
  </xsl:for-each>
4627
4756
  </fo:bookmark>
4628
4757
  </xsl:if>
4758
+
4759
+
4760
+ <xsl:if test="$contents_nodes//tables/table">
4761
+ <fo:bookmark internal-destination="empty_bookmark" starting-state="hide">
4762
+
4763
+
4764
+
4765
+ <xsl:variable name="bookmark-title">
4766
+
4767
+ <xsl:value-of select="$title-list-tables"/>
4768
+
4769
+ </xsl:variable>
4770
+
4771
+ <fo:bookmark-title><xsl:value-of select="$bookmark-title"/></fo:bookmark-title>
4772
+
4773
+ <xsl:for-each select="$contents_nodes//tables/table">
4774
+ <fo:bookmark internal-destination="{@id}">
4775
+ <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
4776
+ </fo:bookmark>
4777
+ </xsl:for-each>
4778
+ </fo:bookmark>
4779
+ </xsl:if>
4780
+
4629
4781
  </xsl:template><xsl:template name="getLangVersion">
4630
4782
  <xsl:param name="lang"/>
4631
4783
  <xsl:param name="doctype" select="''"/>
@@ -5282,6 +5434,8 @@
5282
5434
  </xsl:otherwise>
5283
5435
  </xsl:choose> -->
5284
5436
  </fo:block>
5437
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5438
+ <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5285
5439
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5286
5440
  <xsl:if test="normalize-space() != ''">
5287
5441
  <xsl:value-of select="."/>
@@ -5356,26 +5510,11 @@
5356
5510
  </xsl:template><xsl:template match="*[local-name() = 'author']">
5357
5511
  <xsl:text>— </xsl:text>
5358
5512
  <xsl:apply-templates/>
5359
- </xsl:template><xsl:variable name="bibitem_hidden_">
5360
- <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
5361
- <xsl:copy-of select="."/>
5362
- </xsl:for-each>
5363
- <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
5364
- <xsl:copy-of select="."/>
5365
- </xsl:for-each>
5366
- </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
5367
-
5368
- <xsl:variable name="bibitemid">
5369
- <xsl:choose>
5370
- <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
5371
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
5372
- <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
5373
- <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
5374
- </xsl:choose>
5375
- </xsl:variable>
5376
-
5513
+ </xsl:template><xsl:template match="*[local-name() = 'eref']">
5514
+ <xsl:variable name="current_bibitemid" select="@bibitemid"/>
5515
+ <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/>
5377
5516
  <xsl:choose>
5378
- <xsl:when test="normalize-space($bibitemid) != ''"> <!-- if in the bibliography there is the item with @bibitemid (and not hidden), then create link -->
5517
+ <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) -->
5379
5518
  <fo:inline xsl:use-attribute-sets="eref-style">
5380
5519
  <xsl:if test="@type = 'footnote'">
5381
5520
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
@@ -5389,8 +5528,8 @@
5389
5528
  <xsl:variable name="text" select="normalize-space()"/>
5390
5529
 
5391
5530
 
5392
-
5393
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5531
+
5532
+ <fo:basic-link fox:alt-text="{@citeas}">
5394
5533
  <xsl:if test="normalize-space(@citeas) = ''">
5395
5534
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
5396
5535
  </xsl:if>
@@ -5403,14 +5542,21 @@
5403
5542
 
5404
5543
  </xsl:if>
5405
5544
 
5406
-
5545
+ <xsl:choose>
5546
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
5547
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
5548
+ </xsl:when>
5549
+ <xsl:otherwise>
5550
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
5551
+ </xsl:otherwise>
5552
+ </xsl:choose>
5407
5553
 
5408
5554
  <xsl:apply-templates/>
5409
5555
  </fo:basic-link>
5410
-
5556
+
5411
5557
  </fo:inline>
5412
5558
  </xsl:when>
5413
- <xsl:otherwise>
5559
+ <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5414
5560
  <fo:inline><xsl:apply-templates/></fo:inline>
5415
5561
  </xsl:otherwise>
5416
5562
  </xsl:choose>
@@ -6130,23 +6276,45 @@
6130
6276
  <xsl:apply-templates/>
6131
6277
  </fo:inline>
6132
6278
  </xsl:template><xsl:template match="*[local-name() = 'bibitem']/*[local-name() = 'note']" priority="2">
6279
+
6280
+ <!-- list of footnotes to calculate actual footnotes number -->
6281
+ <xsl:variable name="p_fn_">
6282
+ <xsl:call-template name="get_fn_list"/>
6283
+ </xsl:variable>
6284
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
6285
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
6286
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6287
+ <!-- fn sequence number in document -->
6288
+ <xsl:variable name="current_fn_number">
6289
+ <xsl:choose>
6290
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
6291
+ <xsl:otherwise>
6292
+ <!-- <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1" /> -->
6293
+ <xsl:value-of select="count($p_fn//fn[@gen_id = $gen_id]/preceding-sibling::fn) + 1"/>
6294
+ </xsl:otherwise>
6295
+ </xsl:choose>
6296
+ </xsl:variable>
6133
6297
  <fo:footnote>
6134
6298
  <xsl:variable name="number">
6135
6299
 
6136
- <xsl:number level="any" count="*[local-name() = 'bibitem']/*[local-name() = 'note']"/>
6300
+ <xsl:value-of select="$current_fn_number"/>
6137
6301
 
6138
6302
  </xsl:variable>
6303
+
6304
+ <xsl:variable name="current_fn_number_text">
6305
+ <xsl:value-of select="$number"/>
6306
+
6307
+ </xsl:variable>
6308
+
6139
6309
  <fo:inline xsl:use-attribute-sets="bibitem-note-fn-style">
6140
- <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
6141
- <xsl:value-of select="$number"/>
6142
-
6310
+ <fo:basic-link internal-destination="{$gen_id}" fox:alt-text="footnote {$number}">
6311
+ <xsl:value-of select="$current_fn_number_text"/>
6143
6312
  </fo:basic-link>
6144
6313
  </fo:inline>
6145
6314
  <fo:footnote-body>
6146
6315
  <fo:block xsl:use-attribute-sets="bibitem-note-fn-body-style">
6147
- <fo:inline id="{generate-id()}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6148
- <xsl:value-of select="$number"/>
6149
-
6316
+ <fo:inline id="{$gen_id}" xsl:use-attribute-sets="bibitem-note-fn-number-style">
6317
+ <xsl:value-of select="$current_fn_number_text"/>
6150
6318
  </fo:inline>
6151
6319
  <xsl:apply-templates/>
6152
6320
  </fo:block>
@@ -6387,6 +6555,78 @@
6387
6555
  <!-- processing for admonition/p found in the template for 'p' -->
6388
6556
  <xsl:call-template name="paragraph"/>
6389
6557
 
6558
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_step1">
6559
+ <xsl:copy>
6560
+ <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/>
6561
+ </xsl:copy>
6562
+ </xsl:template><xsl:template match="*[local-name() = 'preface']" mode="update_xml_step1">
6563
+ <xsl:copy>
6564
+ <xsl:copy-of select="@*"/>
6565
+
6566
+ <xsl:variable name="nodes_preface_">
6567
+ <xsl:for-each select="*">
6568
+ <node id="{@id}"/>
6569
+ </xsl:for-each>
6570
+ </xsl:variable>
6571
+ <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
6572
+
6573
+ <xsl:for-each select="*">
6574
+ <xsl:sort select="@displayorder" data-type="number"/>
6575
+
6576
+ <!-- process Section's title -->
6577
+ <xsl:variable name="preceding-sibling_id" select="$nodes_preface/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6578
+ <xsl:if test="$preceding-sibling_id != ''">
6579
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6580
+ </xsl:if>
6581
+
6582
+ <xsl:choose>
6583
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6584
+ <xsl:otherwise>
6585
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6586
+ </xsl:otherwise>
6587
+ </xsl:choose>
6588
+
6589
+ </xsl:for-each>
6590
+ </xsl:copy>
6591
+ </xsl:template><xsl:template match="*[local-name() = 'sections']" mode="update_xml_step1">
6592
+ <xsl:copy>
6593
+ <xsl:copy-of select="@*"/>
6594
+
6595
+ <xsl:variable name="nodes_sections_">
6596
+ <xsl:for-each select="*">
6597
+ <node id="{@id}"/>
6598
+ </xsl:for-each>
6599
+ </xsl:variable>
6600
+ <xsl:variable name="nodes_sections" select="xalan:nodeset($nodes_sections_)"/>
6601
+
6602
+ <!-- move section 'Normative references' inside 'sections' -->
6603
+ <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']]">
6604
+ <xsl:sort select="@displayorder" data-type="number"/>
6605
+
6606
+ <!-- process Section's title -->
6607
+ <xsl:variable name="preceding-sibling_id" select="$nodes_sections/node[@id = current()/@id]/preceding-sibling::node[1]/@id"/>
6608
+ <xsl:if test="$preceding-sibling_id != ''">
6609
+ <xsl:apply-templates select="parent::*/*[@type = 'section-title' and @id = $preceding-sibling_id and not(@displayorder)]" mode="update_xml_step1"/>
6610
+ </xsl:if>
6611
+
6612
+ <xsl:choose>
6613
+ <xsl:when test="@type = 'section-title' and not(@displayorder)"><!-- skip, don't copy, because copied in above 'apply-templates' --></xsl:when>
6614
+ <xsl:otherwise>
6615
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6616
+ </xsl:otherwise>
6617
+ </xsl:choose>
6618
+
6619
+ </xsl:for-each>
6620
+ </xsl:copy>
6621
+ </xsl:template><xsl:template match="*[local-name() = 'bibliography']" mode="update_xml_step1">
6622
+ <xsl:copy>
6623
+ <xsl:copy-of select="@*"/>
6624
+ <!-- copy all elements from bibliography except 'Normative references' (moved to 'sections') -->
6625
+ <xsl:for-each select="*[not(@normative='true') and not(*[*[@normative='true']])]">
6626
+ <xsl:sort select="@displayorder" data-type="number"/>
6627
+ <xsl:apply-templates select="." mode="update_xml_step1"/>
6628
+ </xsl:for-each>
6629
+ </xsl:copy>
6390
6630
  </xsl:template><xsl:template name="convertDate">
6391
6631
  <xsl:param name="date"/>
6392
6632
  <xsl:param name="format" select="'short'"/>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module MPFA
3
- VERSION = "0.8.4".freeze
3
+ VERSION = "0.8.5".freeze
4
4
  end
5
5
  end