metanorma-bipm 2.4.8 → 2.4.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -2737,6 +2737,7 @@
2737
2737
  <xsl:otherwise>justify</xsl:otherwise>
2738
2738
  </xsl:choose>
2739
2739
  </xsl:attribute>
2740
+ <xsl:call-template name="setKeepAttributes"/>
2740
2741
  <xsl:copy-of select="@font-family"/>
2741
2742
  <xsl:if test="not(ancestor::bipm:table)">
2742
2743
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
@@ -3872,7 +3873,7 @@
3872
3873
  <xsl:strip-space xmlns:redirect="http://xml.apache.org/xalan/redirect" elements="bipm:xref"/>
3873
3874
 
3874
3875
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
3875
- <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/>
3876
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
3876
3877
 
3877
3878
  <!-- external parameters -->
3878
3879
 
@@ -5596,7 +5597,7 @@
5596
5597
 
5597
5598
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
5598
5599
 
5599
- <xsl:variable name="updated_xml_step_move_pagebreak_">
5600
+ <xsl:variable name="updated_xml_step_move_pagebreak">
5600
5601
 
5601
5602
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5602
5603
 
@@ -5614,17 +5615,32 @@
5614
5615
  </xsl:variable>
5615
5616
 
5616
5617
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5617
-
5618
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
5619
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5618
5620
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5619
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
5621
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5620
5622
  </redirect:write>
5623
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
5621
5624
 
5622
5625
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5623
5626
 
5627
+ <!-- TODO: instead of
5628
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
5629
+ in each template, add removing empty page_sequence here
5630
+ -->
5631
+
5632
+ <xsl:if test="$debug = 'true'">
5633
+ <redirect:write file="page_sequence_preface.xml">
5634
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5635
+ </redirect:write>
5636
+ </xsl:if>
5637
+
5638
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5624
5639
  <xsl:call-template name="deleteFile">
5625
5640
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5626
5641
  </xsl:call-template>
5627
- </xsl:template>
5642
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
5643
+ </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
5628
5644
 
5629
5645
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
5630
5646
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
@@ -5649,37 +5665,7 @@
5649
5665
  </xsl:for-each>
5650
5666
  </xsl:template><!-- END: processMainSectionsDefault -->
5651
5667
 
5652
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_flatxml">
5653
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5654
- <xsl:sort select="@displayorder" data-type="number"/>
5655
- <xsl:variable name="flatxml">
5656
- <xsl:apply-templates select="." mode="flatxml"/>
5657
- </xsl:variable>
5658
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
5659
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
5660
-
5661
- </xsl:for-each>
5662
-
5663
- <xsl:for-each select="/*/*[local-name()='annex']">
5664
- <xsl:sort select="@displayorder" data-type="number"/>
5665
- <xsl:variable name="flatxml">
5666
- <xsl:apply-templates select="." mode="flatxml"/>
5667
- </xsl:variable>
5668
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
5669
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
5670
- </xsl:for-each>
5671
-
5672
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5673
- <xsl:sort select="@displayorder" data-type="number"/>
5674
- <xsl:variable name="flatxml">
5675
- <xsl:apply-templates select="." mode="flatxml"/>
5676
- </xsl:variable>
5677
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
5678
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
5679
- </xsl:for-each>
5680
- </xsl:template>
5681
-
5682
- <!-- Example:
5668
+ <!-- Example:
5683
5669
  <iso-standard>
5684
5670
  <sections>
5685
5671
  <page_sequence>
@@ -5699,7 +5685,7 @@
5699
5685
  -->
5700
5686
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
5701
5687
 
5702
- <xsl:variable name="updated_xml_step_move_pagebreak_">
5688
+ <xsl:variable name="updated_xml_step_move_pagebreak">
5703
5689
 
5704
5690
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
5705
5691
 
@@ -5736,11 +5722,17 @@
5736
5722
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
5737
5723
 
5738
5724
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
5739
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
5725
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
5740
5726
  </redirect:write>
5741
5727
 
5742
5728
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5743
5729
 
5730
+ <xsl:if test="$debug = 'true'">
5731
+ <redirect:write file="page_sequence_main.xml">
5732
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
5733
+ </redirect:write>
5734
+ </xsl:if>
5735
+
5744
5736
  <xsl:call-template name="deleteFile">
5745
5737
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
5746
5738
  </xsl:call-template>
@@ -5753,6 +5745,14 @@
5753
5745
  <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
5754
5746
  </xsl:template>
5755
5747
 
5748
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getPageSequenceOrientation">
5749
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
5750
+ <xsl:choose>
5751
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
5752
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
5753
+ </xsl:choose>
5754
+ </xsl:template>
5755
+
5756
5756
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5757
5757
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable>
5758
5758
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable>
@@ -6097,7 +6097,9 @@
6097
6097
 
6098
6098
  <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'][not(@type = 'units')] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
6099
6099
  <xsl:if test="$isNoteOrFnExist = 'true'">
6100
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
6100
+
6101
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
6102
+
6101
6103
  </xsl:if>
6102
6104
 
6103
6105
  <xsl:choose>
@@ -6154,13 +6156,14 @@
6154
6156
  </fo:table>
6155
6157
 
6156
6158
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
6157
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
6158
- <xsl:call-template name="insertTableFooterInSeparateTable">
6159
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
6160
- <xsl:with-param name="colwidths" select="$colwidths"/>
6161
- <xsl:with-param name="colgroup" select="$colgroup"/>
6162
- </xsl:call-template>
6163
- </xsl:for-each>
6159
+
6160
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
6161
+ <xsl:call-template name="insertTableFooterInSeparateTable">
6162
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
6163
+ <xsl:with-param name="colwidths" select="$colwidths"/>
6164
+ <xsl:with-param name="colgroup" select="$colgroup"/>
6165
+ </xsl:call-template>
6166
+ </xsl:for-each>
6164
6167
 
6165
6168
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
6166
6169
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -6554,8 +6557,10 @@
6554
6557
  <width_min><xsl:value-of select="@width_min"/></width_min>
6555
6558
  <e><xsl:value-of select="$d * $W div $D"/></e>
6556
6559
  <!-- set the column's width to the minimum width plus d times W over D. -->
6560
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
6561
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
6557
6562
  <column divider="100">
6558
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
6563
+ <xsl:value-of select="$column_width"/>
6559
6564
  </column>
6560
6565
  </xsl:for-each>
6561
6566
 
@@ -6980,6 +6985,22 @@
6980
6985
 
6981
6986
  <xsl:call-template name="refine_table-header-cell-style"/>
6982
6987
 
6988
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
6989
+ <!-- <xsl:choose>
6990
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
6991
+ <fo:block-container reference-orientation="270">
6992
+ <fo:block role="SKIP" text-align="start">
6993
+ <xsl:apply-templates />
6994
+ </fo:block>
6995
+ </fo:block-container>
6996
+ </xsl:when>
6997
+ <xsl:otherwise>
6998
+ <fo:block role="SKIP">
6999
+ <xsl:apply-templates />
7000
+ </fo:block>
7001
+ </xsl:otherwise>
7002
+ </xsl:choose> -->
7003
+
6983
7004
  <fo:block role="SKIP">
6984
7005
  <xsl:apply-templates/>
6985
7006
  </fo:block>
@@ -10544,6 +10565,15 @@
10544
10565
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
10545
10566
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
10546
10567
  </xsl:when>
10568
+ <!-- in WebP format, then convert image into PNG -->
10569
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
10570
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
10571
+ <xsl:value-of select="$src_png"/>
10572
+ </xsl:when>
10573
+ <xsl:when test="not(starts-with(@src, 'data:')) and (java:endsWith(java:java.lang.String.new(@src), '.webp') or java:endsWith(java:java.lang.String.new(@src), '.WEBP'))">
10574
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
10575
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
10576
+ </xsl:when>
10547
10577
  <xsl:when test="not(starts-with(@src, 'data:'))">
10548
10578
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
10549
10579
  </xsl:when>
@@ -14232,6 +14262,75 @@
14232
14262
  <!-- ===================================== -->
14233
14263
  <!-- Update xml -->
14234
14264
  <!-- ===================================== -->
14265
+
14266
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="updateXML">
14267
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
14268
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
14269
+
14270
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
14271
+ <xsl:variable name="updated_xml_step1">
14272
+ <xsl:if test="$table_if = 'false'">
14273
+ <xsl:apply-templates mode="update_xml_step1"/>
14274
+ </xsl:if>
14275
+ </xsl:variable>
14276
+
14277
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
14278
+ <xsl:if test="$debug = 'true'">
14279
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
14280
+ <xsl:message>END updated_xml_step1</xsl:message>
14281
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
14282
+ <xsl:copy-of select="$updated_xml_step1"/>
14283
+ </redirect:write> -->
14284
+ </xsl:if>
14285
+
14286
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
14287
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
14288
+
14289
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
14290
+ <xsl:variable name="updated_xml_step2">
14291
+
14292
+ <xsl:if test="$table_if = 'false'">
14293
+ <xsl:copy-of select="$updated_xml_step1"/>
14294
+ </xsl:if>
14295
+
14296
+ </xsl:variable>
14297
+
14298
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
14299
+ <xsl:if test="$debug = 'true'">
14300
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
14301
+ <xsl:message>END updated_xml_step2</xsl:message>
14302
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
14303
+ <xsl:copy-of select="$updated_xml_step2"/>
14304
+ </redirect:write> -->
14305
+ </xsl:if>
14306
+
14307
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
14308
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
14309
+
14310
+ <xsl:variable name="updated_xml_step3">
14311
+ <xsl:choose>
14312
+ <xsl:when test="$table_if = 'false'">
14313
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
14314
+ </xsl:when>
14315
+ <xsl:otherwise>
14316
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
14317
+ </xsl:otherwise>
14318
+ </xsl:choose>
14319
+ </xsl:variable>
14320
+
14321
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
14322
+ <xsl:if test="$debug = 'true'">
14323
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
14324
+ <xsl:message>END updated_xml_step3</xsl:message>
14325
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
14326
+ <xsl:copy-of select="$updated_xml_step3"/>
14327
+ </redirect:write> -->
14328
+ </xsl:if>
14329
+
14330
+ <xsl:copy-of select="$updated_xml_step3"/>
14331
+
14332
+ </xsl:template>
14333
+
14235
14334
  <!-- =========================================================================== -->
14236
14335
  <!-- STEP1: -->
14237
14336
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
@@ -14431,7 +14530,7 @@
14431
14530
 
14432
14531
  <!-- determine pagebreak is last element before </fo:flow> or not -->
14433
14532
  <xsl:variable name="isLast">
14434
- <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14533
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14435
14534
  <xsl:if test="following-sibling::*">false</xsl:if>
14436
14535
  </xsl:for-each>
14437
14536
  </xsl:variable>
@@ -14453,7 +14552,7 @@
14453
14552
  <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
14454
14553
 
14455
14554
  <!-- create a new page_sequence (opening elements) -->
14456
- <xsl:text disable-output-escaping="yes">&lt;page_sequence namespace="</xsl:text><xsl:value-of select="$namespace_full"/>"<xsl:if test="$orientation != ''"> orientation="<xsl:value-of select="$orientation"/>"</xsl:if><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
14555
+ <xsl:text disable-output-escaping="yes">&lt;page_sequence xmlns="</xsl:text><xsl:value-of select="$namespace_full"/>"<xsl:if test="$orientation != ''"> orientation="<xsl:value-of select="$orientation"/>"</xsl:if><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
14457
14556
 
14458
14557
  <xsl:call-template name="insertOpeningElements">
14459
14558
  <xsl:with-param name="tree" select="$tree"/>
@@ -14463,7 +14562,7 @@
14463
14562
  </xsl:template>
14464
14563
 
14465
14564
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
14466
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14565
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
14467
14566
  <element pos="{position()}">
14468
14567
  <xsl:copy-of select="@*[local-name() != 'id']"/>
14469
14568
  <xsl:value-of select="name()"/>
@@ -14644,7 +14743,7 @@
14644
14743
  <xsl:value-of select="substring-before($text, $tag_open)"/>
14645
14744
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
14646
14745
 
14647
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
14746
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
14648
14747
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
14649
14748
  </xsl:element>
14650
14749
 
@@ -15466,7 +15565,10 @@
15466
15565
  <xsl:call-template name="setTextAlignment">
15467
15566
  <xsl:with-param name="default" select="$text_align_default"/>
15468
15567
  </xsl:call-template>
15568
+ <xsl:call-template name="setKeepAttributes"/>
15569
+ </xsl:template>
15469
15570
 
15571
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="setKeepAttributes">
15470
15572
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
15471
15573
  <!-- Example: keep-lines-together="true" -->
15472
15574
  <xsl:if test="@keep-lines-together = 'true'">
@@ -15478,6 +15580,72 @@
15478
15580
  </xsl:if>
15479
15581
  </xsl:template>
15480
15582
 
15583
+ <!-- insert cover page image -->
15584
+ <!-- background cover image -->
15585
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
15586
+ <xsl:param name="number">1</xsl:param>
15587
+ <xsl:param name="name">coverpage-image</xsl:param>
15588
+ <xsl:variable name="num" select="number($number)"/>
15589
+ <!-- background image -->
15590
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
15591
+ <fo:block>
15592
+ <xsl:for-each select="/*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = $name][1]/*[local-name() = 'value']/*[local-name() = 'image'][$num]">
15593
+ <xsl:choose>
15594
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
15595
+ <fo:instream-foreign-object fox:alt-text="Image Front">
15596
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
15597
+ <xsl:call-template name="getSVG"/>
15598
+ </fo:instream-foreign-object>
15599
+ </xsl:when>
15600
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
15601
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
15602
+ </xsl:when>
15603
+ <xsl:otherwise> <!-- bitmap image -->
15604
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
15605
+ <xsl:if test="$coverimage_src != ''">
15606
+ <xsl:variable name="coverpage">
15607
+ <xsl:call-template name="getImageURL">
15608
+ <xsl:with-param name="src" select="$coverimage_src"/>
15609
+ </xsl:call-template>
15610
+ </xsl:variable>
15611
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
15612
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
15613
+ </xsl:if>
15614
+ </xsl:otherwise>
15615
+ </xsl:choose>
15616
+ </xsl:for-each>
15617
+ </fo:block>
15618
+ </fo:block-container>
15619
+ </xsl:template>
15620
+
15621
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getImageURL">
15622
+ <xsl:param name="src"/>
15623
+ <xsl:choose>
15624
+ <xsl:when test="starts-with($src, 'data:image')">
15625
+ <xsl:value-of select="$src"/>
15626
+ </xsl:when>
15627
+ <xsl:otherwise>
15628
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
15629
+ </xsl:otherwise>
15630
+ </xsl:choose>
15631
+ </xsl:template>
15632
+
15633
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getSVG">
15634
+ <xsl:choose>
15635
+ <xsl:when test="*[local-name() = 'svg']">
15636
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
15637
+ </xsl:when>
15638
+ <xsl:otherwise>
15639
+ <xsl:variable name="svg_content" select="document(@src)"/>
15640
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
15641
+ <xsl:apply-templates select="." mode="svg_update"/>
15642
+ </xsl:for-each>
15643
+ </xsl:otherwise>
15644
+ </xsl:choose>
15645
+ </xsl:template>
15646
+
15647
+ <!-- END: insert cover page image -->
15648
+
15481
15649
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="number-to-words">
15482
15650
  <xsl:param name="number"/>
15483
15651
  <xsl:param name="first"/>