metanorma-un 0.12.10 → 0.12.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -631,12 +631,11 @@
631
631
  <xsl:if test="following-sibling::*">
632
632
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
633
633
  </xsl:if>
634
- <xsl:attribute name="text-align">
635
- <xsl:choose>
636
- <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
637
- <xsl:otherwise>justify</xsl:otherwise>
638
- </xsl:choose>
639
- </xsl:attribute>
634
+
635
+ <xsl:call-template name="setBlockAttributes">
636
+ <xsl:with-param name="text_align_default">justify</xsl:with-param>
637
+ </xsl:call-template>
638
+
640
639
  <xsl:apply-templates>
641
640
  <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
642
641
  </xsl:apply-templates>
@@ -840,7 +839,7 @@
840
839
  <xsl:strip-space xmlns:redirect="http://xml.apache.org/xalan/redirect" elements="un:xref"/>
841
840
 
842
841
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
843
- <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/>
842
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
844
843
 
845
844
  <!-- external parameters -->
846
845
 
@@ -2530,7 +2529,7 @@
2530
2529
 
2531
2530
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
2532
2531
 
2533
- <xsl:variable name="updated_xml_step_move_pagebreak_">
2532
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2534
2533
 
2535
2534
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2536
2535
 
@@ -2548,17 +2547,32 @@
2548
2547
  </xsl:variable>
2549
2548
 
2550
2549
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2551
-
2550
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
2551
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2552
2552
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2553
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
2553
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2554
2554
  </redirect:write>
2555
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2555
2556
 
2556
2557
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2557
2558
 
2559
+ <!-- TODO: instead of
2560
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
2561
+ in each template, add removing empty page_sequence here
2562
+ -->
2563
+
2564
+ <xsl:if test="$debug = 'true'">
2565
+ <redirect:write file="page_sequence_preface.xml">
2566
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2567
+ </redirect:write>
2568
+ </xsl:if>
2569
+
2570
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2558
2571
  <xsl:call-template name="deleteFile">
2559
2572
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2560
2573
  </xsl:call-template>
2561
- </xsl:template>
2574
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2575
+ </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
2562
2576
 
2563
2577
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
2564
2578
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
@@ -2583,37 +2597,7 @@
2583
2597
  </xsl:for-each>
2584
2598
  </xsl:template><!-- END: processMainSectionsDefault -->
2585
2599
 
2586
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_flatxml">
2587
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2588
- <xsl:sort select="@displayorder" data-type="number"/>
2589
- <xsl:variable name="flatxml">
2590
- <xsl:apply-templates select="." mode="flatxml"/>
2591
- </xsl:variable>
2592
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2593
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2594
-
2595
- </xsl:for-each>
2596
-
2597
- <xsl:for-each select="/*/*[local-name()='annex']">
2598
- <xsl:sort select="@displayorder" data-type="number"/>
2599
- <xsl:variable name="flatxml">
2600
- <xsl:apply-templates select="." mode="flatxml"/>
2601
- </xsl:variable>
2602
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2603
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2604
- </xsl:for-each>
2605
-
2606
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2607
- <xsl:sort select="@displayorder" data-type="number"/>
2608
- <xsl:variable name="flatxml">
2609
- <xsl:apply-templates select="." mode="flatxml"/>
2610
- </xsl:variable>
2611
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2612
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2613
- </xsl:for-each>
2614
- </xsl:template>
2615
-
2616
- <!-- Example:
2600
+ <!-- Example:
2617
2601
  <iso-standard>
2618
2602
  <sections>
2619
2603
  <page_sequence>
@@ -2633,7 +2617,7 @@
2633
2617
  -->
2634
2618
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
2635
2619
 
2636
- <xsl:variable name="updated_xml_step_move_pagebreak_">
2620
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2637
2621
 
2638
2622
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2639
2623
 
@@ -2670,11 +2654,17 @@
2670
2654
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2671
2655
 
2672
2656
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2673
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
2657
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2674
2658
  </redirect:write>
2675
2659
 
2676
2660
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2677
2661
 
2662
+ <xsl:if test="$debug = 'true'">
2663
+ <redirect:write file="page_sequence_main.xml">
2664
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2665
+ </redirect:write>
2666
+ </xsl:if>
2667
+
2678
2668
  <xsl:call-template name="deleteFile">
2679
2669
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2680
2670
  </xsl:call-template>
@@ -2687,6 +2677,14 @@
2687
2677
  <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
2688
2678
  </xsl:template>
2689
2679
 
2680
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getPageSequenceOrientation">
2681
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
2682
+ <xsl:choose>
2683
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
2684
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
2685
+ </xsl:choose>
2686
+ </xsl:template>
2687
+
2690
2688
  <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>
2691
2689
  <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>
2692
2690
  <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>
@@ -3025,7 +3023,9 @@
3025
3023
 
3026
3024
  <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']"/>
3027
3025
  <xsl:if test="$isNoteOrFnExist = 'true'">
3028
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3026
+
3027
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3028
+
3029
3029
  </xsl:if>
3030
3030
 
3031
3031
  <xsl:choose>
@@ -3082,13 +3082,14 @@
3082
3082
  </fo:table>
3083
3083
 
3084
3084
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
3085
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3086
- <xsl:call-template name="insertTableFooterInSeparateTable">
3087
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
3088
- <xsl:with-param name="colwidths" select="$colwidths"/>
3089
- <xsl:with-param name="colgroup" select="$colgroup"/>
3090
- </xsl:call-template>
3091
- </xsl:for-each>
3085
+
3086
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3087
+ <xsl:call-template name="insertTableFooterInSeparateTable">
3088
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
3089
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3090
+ <xsl:with-param name="colgroup" select="$colgroup"/>
3091
+ </xsl:call-template>
3092
+ </xsl:for-each>
3092
3093
 
3093
3094
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
3094
3095
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -3474,8 +3475,10 @@
3474
3475
  <width_min><xsl:value-of select="@width_min"/></width_min>
3475
3476
  <e><xsl:value-of select="$d * $W div $D"/></e>
3476
3477
  <!-- set the column's width to the minimum width plus d times W over D. -->
3478
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3479
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
3477
3480
  <column divider="100">
3478
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3481
+ <xsl:value-of select="$column_width"/>
3479
3482
  </column>
3480
3483
  </xsl:for-each>
3481
3484
 
@@ -3883,6 +3886,22 @@
3883
3886
 
3884
3887
  <xsl:call-template name="refine_table-header-cell-style"/>
3885
3888
 
3889
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
3890
+ <!-- <xsl:choose>
3891
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
3892
+ <fo:block-container reference-orientation="270">
3893
+ <fo:block role="SKIP" text-align="start">
3894
+ <xsl:apply-templates />
3895
+ </fo:block>
3896
+ </fo:block-container>
3897
+ </xsl:when>
3898
+ <xsl:otherwise>
3899
+ <fo:block role="SKIP">
3900
+ <xsl:apply-templates />
3901
+ </fo:block>
3902
+ </xsl:otherwise>
3903
+ </xsl:choose> -->
3904
+
3886
3905
  <fo:block role="SKIP">
3887
3906
  <xsl:apply-templates/>
3888
3907
  </fo:block>
@@ -7385,6 +7404,15 @@
7385
7404
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
7386
7405
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
7387
7406
  </xsl:when>
7407
+ <!-- in WebP format, then convert image into PNG -->
7408
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
7409
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7410
+ <xsl:value-of select="$src_png"/>
7411
+ </xsl:when>
7412
+ <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'))">
7413
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7414
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
7415
+ </xsl:when>
7388
7416
  <xsl:when test="not(starts-with(@src, 'data:'))">
7389
7417
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7390
7418
  </xsl:when>
@@ -11047,6 +11075,75 @@
11047
11075
  <!-- ===================================== -->
11048
11076
  <!-- Update xml -->
11049
11077
  <!-- ===================================== -->
11078
+
11079
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="updateXML">
11080
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
11081
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
11082
+
11083
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
11084
+ <xsl:variable name="updated_xml_step1">
11085
+ <xsl:if test="$table_if = 'false'">
11086
+ <xsl:apply-templates mode="update_xml_step1"/>
11087
+ </xsl:if>
11088
+ </xsl:variable>
11089
+
11090
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
11091
+ <xsl:if test="$debug = 'true'">
11092
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
11093
+ <xsl:message>END updated_xml_step1</xsl:message>
11094
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
11095
+ <xsl:copy-of select="$updated_xml_step1"/>
11096
+ </redirect:write> -->
11097
+ </xsl:if>
11098
+
11099
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
11100
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
11101
+
11102
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
11103
+ <xsl:variable name="updated_xml_step2">
11104
+
11105
+ <xsl:if test="$table_if = 'false'">
11106
+ <xsl:copy-of select="$updated_xml_step1"/>
11107
+ </xsl:if>
11108
+
11109
+ </xsl:variable>
11110
+
11111
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
11112
+ <xsl:if test="$debug = 'true'">
11113
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
11114
+ <xsl:message>END updated_xml_step2</xsl:message>
11115
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
11116
+ <xsl:copy-of select="$updated_xml_step2"/>
11117
+ </redirect:write> -->
11118
+ </xsl:if>
11119
+
11120
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
11121
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
11122
+
11123
+ <xsl:variable name="updated_xml_step3">
11124
+ <xsl:choose>
11125
+ <xsl:when test="$table_if = 'false'">
11126
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
11127
+ </xsl:when>
11128
+ <xsl:otherwise>
11129
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
11130
+ </xsl:otherwise>
11131
+ </xsl:choose>
11132
+ </xsl:variable>
11133
+
11134
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
11135
+ <xsl:if test="$debug = 'true'">
11136
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
11137
+ <xsl:message>END updated_xml_step3</xsl:message>
11138
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
11139
+ <xsl:copy-of select="$updated_xml_step3"/>
11140
+ </redirect:write> -->
11141
+ </xsl:if>
11142
+
11143
+ <xsl:copy-of select="$updated_xml_step3"/>
11144
+
11145
+ </xsl:template>
11146
+
11050
11147
  <!-- =========================================================================== -->
11051
11148
  <!-- STEP1: -->
11052
11149
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
@@ -11246,7 +11343,7 @@
11246
11343
 
11247
11344
  <!-- determine pagebreak is last element before </fo:flow> or not -->
11248
11345
  <xsl:variable name="isLast">
11249
- <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11346
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11250
11347
  <xsl:if test="following-sibling::*">false</xsl:if>
11251
11348
  </xsl:for-each>
11252
11349
  </xsl:variable>
@@ -11268,7 +11365,7 @@
11268
11365
  <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
11269
11366
 
11270
11367
  <!-- create a new page_sequence (opening elements) -->
11271
- <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>
11368
+ <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>
11272
11369
 
11273
11370
  <xsl:call-template name="insertOpeningElements">
11274
11371
  <xsl:with-param name="tree" select="$tree"/>
@@ -11278,7 +11375,7 @@
11278
11375
  </xsl:template>
11279
11376
 
11280
11377
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
11281
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11378
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11282
11379
  <element pos="{position()}">
11283
11380
  <xsl:copy-of select="@*[local-name() != 'id']"/>
11284
11381
  <xsl:value-of select="name()"/>
@@ -11459,7 +11556,7 @@
11459
11556
  <xsl:value-of select="substring-before($text, $tag_open)"/>
11460
11557
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
11461
11558
 
11462
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
11559
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
11463
11560
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
11464
11561
  </xsl:element>
11465
11562
 
@@ -12281,7 +12378,10 @@
12281
12378
  <xsl:call-template name="setTextAlignment">
12282
12379
  <xsl:with-param name="default" select="$text_align_default"/>
12283
12380
  </xsl:call-template>
12381
+ <xsl:call-template name="setKeepAttributes"/>
12382
+ </xsl:template>
12284
12383
 
12384
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="setKeepAttributes">
12285
12385
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
12286
12386
  <!-- Example: keep-lines-together="true" -->
12287
12387
  <xsl:if test="@keep-lines-together = 'true'">
@@ -12293,6 +12393,72 @@
12293
12393
  </xsl:if>
12294
12394
  </xsl:template>
12295
12395
 
12396
+ <!-- insert cover page image -->
12397
+ <!-- background cover image -->
12398
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
12399
+ <xsl:param name="number">1</xsl:param>
12400
+ <xsl:param name="name">coverpage-image</xsl:param>
12401
+ <xsl:variable name="num" select="number($number)"/>
12402
+ <!-- background image -->
12403
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
12404
+ <fo:block>
12405
+ <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]">
12406
+ <xsl:choose>
12407
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
12408
+ <fo:instream-foreign-object fox:alt-text="Image Front">
12409
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
12410
+ <xsl:call-template name="getSVG"/>
12411
+ </fo:instream-foreign-object>
12412
+ </xsl:when>
12413
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
12414
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
12415
+ </xsl:when>
12416
+ <xsl:otherwise> <!-- bitmap image -->
12417
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
12418
+ <xsl:if test="$coverimage_src != ''">
12419
+ <xsl:variable name="coverpage">
12420
+ <xsl:call-template name="getImageURL">
12421
+ <xsl:with-param name="src" select="$coverimage_src"/>
12422
+ </xsl:call-template>
12423
+ </xsl:variable>
12424
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
12425
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
12426
+ </xsl:if>
12427
+ </xsl:otherwise>
12428
+ </xsl:choose>
12429
+ </xsl:for-each>
12430
+ </fo:block>
12431
+ </fo:block-container>
12432
+ </xsl:template>
12433
+
12434
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getImageURL">
12435
+ <xsl:param name="src"/>
12436
+ <xsl:choose>
12437
+ <xsl:when test="starts-with($src, 'data:image')">
12438
+ <xsl:value-of select="$src"/>
12439
+ </xsl:when>
12440
+ <xsl:otherwise>
12441
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
12442
+ </xsl:otherwise>
12443
+ </xsl:choose>
12444
+ </xsl:template>
12445
+
12446
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getSVG">
12447
+ <xsl:choose>
12448
+ <xsl:when test="*[local-name() = 'svg']">
12449
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
12450
+ </xsl:when>
12451
+ <xsl:otherwise>
12452
+ <xsl:variable name="svg_content" select="document(@src)"/>
12453
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
12454
+ <xsl:apply-templates select="." mode="svg_update"/>
12455
+ </xsl:for-each>
12456
+ </xsl:otherwise>
12457
+ </xsl:choose>
12458
+ </xsl:template>
12459
+
12460
+ <!-- END: insert cover page image -->
12461
+
12296
12462
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="number-to-words">
12297
12463
  <xsl:param name="number"/>
12298
12464
  <xsl:param name="first"/>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module UN
3
- VERSION = "0.12.10".freeze
3
+ VERSION = "0.12.11".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.10
4
+ version: 0.12.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-03 00:00:00.000000000 Z
11
+ date: 2024-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639