metanorma-iho 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66c5c748928c3e562f2e08b28083454b58ce668b2fd7c20455bdf89e2065df30
4
- data.tar.gz: a7c8b9a6fe404166991360001587d6678607f6b17beb821207dee762b52f9763
3
+ metadata.gz: 06f1d064d6d7d528b761e38426c6bbcdca401b3d04ada30112f30cd1aeac2894
4
+ data.tar.gz: 3f0a6a43ad5dd59da972edfa730918441562fb5d879769f489331a26b67e7e4f
5
5
  SHA512:
6
- metadata.gz: bd1a556436caa4eb866204b4df0bf8c8370078c751629497274b2084f0d6cbc206cc7d92947c37301f4900c201c79b4ec93f1acc9c05b69ce1bd192b6fbb86f8
7
- data.tar.gz: ba9f23b84f3f83c0f6da61440e77d8aaef88ae74d6facea5dbd3b0a618178adf1984a71051acd9d2c497b7d351084feb195badf7df1175e83b45706cec6db55a
6
+ metadata.gz: aaf1ef03838c50d963fcf6324b26f80beb720263fcdcea79d55f47f96d193a9820f1d075f1b64ffeae05aea2aee2ba89f6f1e67961f85f3e4886550aa3cf0e68
7
+ data.tar.gz: 7281bf55683cb5ebda6cdb7833ce7f4912a348e95cdb2fdda74de535e49bd654b1c79f25d72b60b810abd5365759558c75c6f7e27f054d8a6d39522dbba33714
@@ -662,12 +662,14 @@
662
662
  <xsl:when test="ancestor::iho:quote">justify</xsl:when>
663
663
  <xsl:when test="ancestor::iho:feedback-statement">right</xsl:when>
664
664
  <xsl:when test="ancestor::iho:boilerplate and not(@align)">justify</xsl:when>
665
+ <xsl:when test="@align = 'justified'">justify</xsl:when>
665
666
  <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
666
667
  <xsl:when test="ancestor::iho:td/@align"><xsl:value-of select="ancestor::iho:td/@align"/></xsl:when>
667
668
  <xsl:when test="ancestor::iho:th/@align"><xsl:value-of select="ancestor::iho:th/@align"/></xsl:when>
668
669
  <xsl:otherwise>justify</xsl:otherwise>
669
670
  </xsl:choose>
670
671
  </xsl:attribute>
672
+ <xsl:call-template name="setKeepAttributes"/>
671
673
  <xsl:attribute name="space-after">6pt</xsl:attribute>
672
674
  <xsl:if test="parent::iho:dd">
673
675
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
@@ -843,7 +845,7 @@
843
845
  <xsl:strip-space xmlns:redirect="http://xml.apache.org/xalan/redirect" elements="iho:xref"/>
844
846
 
845
847
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
846
- <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/>
848
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
847
849
 
848
850
  <!-- external parameters -->
849
851
 
@@ -2534,7 +2536,7 @@
2534
2536
 
2535
2537
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
2536
2538
 
2537
- <xsl:variable name="updated_xml_step_move_pagebreak_">
2539
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2538
2540
 
2539
2541
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2540
2542
 
@@ -2552,17 +2554,32 @@
2552
2554
  </xsl:variable>
2553
2555
 
2554
2556
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2555
-
2557
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
2558
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2556
2559
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2557
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
2560
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2558
2561
  </redirect:write>
2562
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2559
2563
 
2560
2564
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2561
2565
 
2566
+ <!-- TODO: instead of
2567
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
2568
+ in each template, add removing empty page_sequence here
2569
+ -->
2570
+
2571
+ <xsl:if test="$debug = 'true'">
2572
+ <redirect:write file="page_sequence_preface.xml">
2573
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2574
+ </redirect:write>
2575
+ </xsl:if>
2576
+
2577
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2562
2578
  <xsl:call-template name="deleteFile">
2563
2579
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2564
2580
  </xsl:call-template>
2565
- </xsl:template>
2581
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2582
+ </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
2566
2583
 
2567
2584
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
2568
2585
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
@@ -2587,37 +2604,7 @@
2587
2604
  </xsl:for-each>
2588
2605
  </xsl:template><!-- END: processMainSectionsDefault -->
2589
2606
 
2590
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_flatxml">
2591
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2592
- <xsl:sort select="@displayorder" data-type="number"/>
2593
- <xsl:variable name="flatxml">
2594
- <xsl:apply-templates select="." mode="flatxml"/>
2595
- </xsl:variable>
2596
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2597
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2598
-
2599
- </xsl:for-each>
2600
-
2601
- <xsl:for-each select="/*/*[local-name()='annex']">
2602
- <xsl:sort select="@displayorder" data-type="number"/>
2603
- <xsl:variable name="flatxml">
2604
- <xsl:apply-templates select="." mode="flatxml"/>
2605
- </xsl:variable>
2606
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2607
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2608
- </xsl:for-each>
2609
-
2610
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2611
- <xsl:sort select="@displayorder" data-type="number"/>
2612
- <xsl:variable name="flatxml">
2613
- <xsl:apply-templates select="." mode="flatxml"/>
2614
- </xsl:variable>
2615
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2616
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2617
- </xsl:for-each>
2618
- </xsl:template>
2619
-
2620
- <!-- Example:
2607
+ <!-- Example:
2621
2608
  <iso-standard>
2622
2609
  <sections>
2623
2610
  <page_sequence>
@@ -2637,7 +2624,7 @@
2637
2624
  -->
2638
2625
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
2639
2626
 
2640
- <xsl:variable name="updated_xml_step_move_pagebreak_">
2627
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2641
2628
 
2642
2629
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2643
2630
 
@@ -2674,11 +2661,17 @@
2674
2661
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2675
2662
 
2676
2663
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2677
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
2664
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2678
2665
  </redirect:write>
2679
2666
 
2680
2667
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2681
2668
 
2669
+ <xsl:if test="$debug = 'true'">
2670
+ <redirect:write file="page_sequence_main.xml">
2671
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2672
+ </redirect:write>
2673
+ </xsl:if>
2674
+
2682
2675
  <xsl:call-template name="deleteFile">
2683
2676
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2684
2677
  </xsl:call-template>
@@ -2691,6 +2684,14 @@
2691
2684
  <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
2692
2685
  </xsl:template>
2693
2686
 
2687
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getPageSequenceOrientation">
2688
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
2689
+ <xsl:choose>
2690
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
2691
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
2692
+ </xsl:choose>
2693
+ </xsl:template>
2694
+
2694
2695
  <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>
2695
2696
  <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>
2696
2697
  <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>
@@ -3023,7 +3024,9 @@
3023
3024
 
3024
3025
  <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']"/>
3025
3026
  <xsl:if test="$isNoteOrFnExist = 'true'">
3026
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3027
+
3028
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3029
+
3027
3030
  </xsl:if>
3028
3031
 
3029
3032
  <xsl:choose>
@@ -3080,13 +3083,14 @@
3080
3083
  </fo:table>
3081
3084
 
3082
3085
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
3083
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3084
- <xsl:call-template name="insertTableFooterInSeparateTable">
3085
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
3086
- <xsl:with-param name="colwidths" select="$colwidths"/>
3087
- <xsl:with-param name="colgroup" select="$colgroup"/>
3088
- </xsl:call-template>
3089
- </xsl:for-each>
3086
+
3087
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3088
+ <xsl:call-template name="insertTableFooterInSeparateTable">
3089
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
3090
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3091
+ <xsl:with-param name="colgroup" select="$colgroup"/>
3092
+ </xsl:call-template>
3093
+ </xsl:for-each>
3090
3094
 
3091
3095
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
3092
3096
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -3476,8 +3480,10 @@
3476
3480
  <width_min><xsl:value-of select="@width_min"/></width_min>
3477
3481
  <e><xsl:value-of select="$d * $W div $D"/></e>
3478
3482
  <!-- set the column's width to the minimum width plus d times W over D. -->
3483
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3484
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
3479
3485
  <column divider="100">
3480
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3486
+ <xsl:value-of select="$column_width"/>
3481
3487
  </column>
3482
3488
  </xsl:for-each>
3483
3489
 
@@ -3885,6 +3891,22 @@
3885
3891
 
3886
3892
  <xsl:call-template name="refine_table-header-cell-style"/>
3887
3893
 
3894
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
3895
+ <!-- <xsl:choose>
3896
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
3897
+ <fo:block-container reference-orientation="270">
3898
+ <fo:block role="SKIP" text-align="start">
3899
+ <xsl:apply-templates />
3900
+ </fo:block>
3901
+ </fo:block-container>
3902
+ </xsl:when>
3903
+ <xsl:otherwise>
3904
+ <fo:block role="SKIP">
3905
+ <xsl:apply-templates />
3906
+ </fo:block>
3907
+ </xsl:otherwise>
3908
+ </xsl:choose> -->
3909
+
3888
3910
  <fo:block role="SKIP">
3889
3911
  <xsl:apply-templates/>
3890
3912
  </fo:block>
@@ -7454,6 +7476,15 @@
7454
7476
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
7455
7477
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
7456
7478
  </xsl:when>
7479
+ <!-- in WebP format, then convert image into PNG -->
7480
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
7481
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7482
+ <xsl:value-of select="$src_png"/>
7483
+ </xsl:when>
7484
+ <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'))">
7485
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7486
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
7487
+ </xsl:when>
7457
7488
  <xsl:when test="not(starts-with(@src, 'data:'))">
7458
7489
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7459
7490
  </xsl:when>
@@ -11125,6 +11156,75 @@
11125
11156
  <!-- ===================================== -->
11126
11157
  <!-- Update xml -->
11127
11158
  <!-- ===================================== -->
11159
+
11160
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="updateXML">
11161
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
11162
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
11163
+
11164
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
11165
+ <xsl:variable name="updated_xml_step1">
11166
+ <xsl:if test="$table_if = 'false'">
11167
+ <xsl:apply-templates mode="update_xml_step1"/>
11168
+ </xsl:if>
11169
+ </xsl:variable>
11170
+
11171
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
11172
+ <xsl:if test="$debug = 'true'">
11173
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
11174
+ <xsl:message>END updated_xml_step1</xsl:message>
11175
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
11176
+ <xsl:copy-of select="$updated_xml_step1"/>
11177
+ </redirect:write> -->
11178
+ </xsl:if>
11179
+
11180
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
11181
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
11182
+
11183
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
11184
+ <xsl:variable name="updated_xml_step2">
11185
+
11186
+ <xsl:if test="$table_if = 'false'">
11187
+ <xsl:copy-of select="$updated_xml_step1"/>
11188
+ </xsl:if>
11189
+
11190
+ </xsl:variable>
11191
+
11192
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
11193
+ <xsl:if test="$debug = 'true'">
11194
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
11195
+ <xsl:message>END updated_xml_step2</xsl:message>
11196
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
11197
+ <xsl:copy-of select="$updated_xml_step2"/>
11198
+ </redirect:write> -->
11199
+ </xsl:if>
11200
+
11201
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
11202
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
11203
+
11204
+ <xsl:variable name="updated_xml_step3">
11205
+ <xsl:choose>
11206
+ <xsl:when test="$table_if = 'false'">
11207
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
11208
+ </xsl:when>
11209
+ <xsl:otherwise>
11210
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
11211
+ </xsl:otherwise>
11212
+ </xsl:choose>
11213
+ </xsl:variable>
11214
+
11215
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
11216
+ <xsl:if test="$debug = 'true'">
11217
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
11218
+ <xsl:message>END updated_xml_step3</xsl:message>
11219
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
11220
+ <xsl:copy-of select="$updated_xml_step3"/>
11221
+ </redirect:write> -->
11222
+ </xsl:if>
11223
+
11224
+ <xsl:copy-of select="$updated_xml_step3"/>
11225
+
11226
+ </xsl:template>
11227
+
11128
11228
  <!-- =========================================================================== -->
11129
11229
  <!-- STEP1: -->
11130
11230
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
@@ -11324,7 +11424,7 @@
11324
11424
 
11325
11425
  <!-- determine pagebreak is last element before </fo:flow> or not -->
11326
11426
  <xsl:variable name="isLast">
11327
- <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11427
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11328
11428
  <xsl:if test="following-sibling::*">false</xsl:if>
11329
11429
  </xsl:for-each>
11330
11430
  </xsl:variable>
@@ -11346,7 +11446,7 @@
11346
11446
  <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
11347
11447
 
11348
11448
  <!-- create a new page_sequence (opening elements) -->
11349
- <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>
11449
+ <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>
11350
11450
 
11351
11451
  <xsl:call-template name="insertOpeningElements">
11352
11452
  <xsl:with-param name="tree" select="$tree"/>
@@ -11356,7 +11456,7 @@
11356
11456
  </xsl:template>
11357
11457
 
11358
11458
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
11359
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11459
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11360
11460
  <element pos="{position()}">
11361
11461
  <xsl:copy-of select="@*[local-name() != 'id']"/>
11362
11462
  <xsl:value-of select="name()"/>
@@ -11537,7 +11637,7 @@
11537
11637
  <xsl:value-of select="substring-before($text, $tag_open)"/>
11538
11638
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
11539
11639
 
11540
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
11640
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
11541
11641
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
11542
11642
  </xsl:element>
11543
11643
 
@@ -12359,7 +12459,10 @@
12359
12459
  <xsl:call-template name="setTextAlignment">
12360
12460
  <xsl:with-param name="default" select="$text_align_default"/>
12361
12461
  </xsl:call-template>
12462
+ <xsl:call-template name="setKeepAttributes"/>
12463
+ </xsl:template>
12362
12464
 
12465
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="setKeepAttributes">
12363
12466
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
12364
12467
  <!-- Example: keep-lines-together="true" -->
12365
12468
  <xsl:if test="@keep-lines-together = 'true'">
@@ -12371,6 +12474,72 @@
12371
12474
  </xsl:if>
12372
12475
  </xsl:template>
12373
12476
 
12477
+ <!-- insert cover page image -->
12478
+ <!-- background cover image -->
12479
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
12480
+ <xsl:param name="number">1</xsl:param>
12481
+ <xsl:param name="name">coverpage-image</xsl:param>
12482
+ <xsl:variable name="num" select="number($number)"/>
12483
+ <!-- background image -->
12484
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
12485
+ <fo:block>
12486
+ <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]">
12487
+ <xsl:choose>
12488
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
12489
+ <fo:instream-foreign-object fox:alt-text="Image Front">
12490
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
12491
+ <xsl:call-template name="getSVG"/>
12492
+ </fo:instream-foreign-object>
12493
+ </xsl:when>
12494
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
12495
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
12496
+ </xsl:when>
12497
+ <xsl:otherwise> <!-- bitmap image -->
12498
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
12499
+ <xsl:if test="$coverimage_src != ''">
12500
+ <xsl:variable name="coverpage">
12501
+ <xsl:call-template name="getImageURL">
12502
+ <xsl:with-param name="src" select="$coverimage_src"/>
12503
+ </xsl:call-template>
12504
+ </xsl:variable>
12505
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
12506
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
12507
+ </xsl:if>
12508
+ </xsl:otherwise>
12509
+ </xsl:choose>
12510
+ </xsl:for-each>
12511
+ </fo:block>
12512
+ </fo:block-container>
12513
+ </xsl:template>
12514
+
12515
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getImageURL">
12516
+ <xsl:param name="src"/>
12517
+ <xsl:choose>
12518
+ <xsl:when test="starts-with($src, 'data:image')">
12519
+ <xsl:value-of select="$src"/>
12520
+ </xsl:when>
12521
+ <xsl:otherwise>
12522
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
12523
+ </xsl:otherwise>
12524
+ </xsl:choose>
12525
+ </xsl:template>
12526
+
12527
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getSVG">
12528
+ <xsl:choose>
12529
+ <xsl:when test="*[local-name() = 'svg']">
12530
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
12531
+ </xsl:when>
12532
+ <xsl:otherwise>
12533
+ <xsl:variable name="svg_content" select="document(@src)"/>
12534
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
12535
+ <xsl:apply-templates select="." mode="svg_update"/>
12536
+ </xsl:for-each>
12537
+ </xsl:otherwise>
12538
+ </xsl:choose>
12539
+ </xsl:template>
12540
+
12541
+ <!-- END: insert cover page image -->
12542
+
12374
12543
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="number-to-words">
12375
12544
  <xsl:param name="number"/>
12376
12545
  <xsl:param name="first"/>
@@ -662,12 +662,14 @@
662
662
  <xsl:when test="ancestor::iho:quote">justify</xsl:when>
663
663
  <xsl:when test="ancestor::iho:feedback-statement">right</xsl:when>
664
664
  <xsl:when test="ancestor::iho:boilerplate and not(@align)">justify</xsl:when>
665
+ <xsl:when test="@align = 'justified'">justify</xsl:when>
665
666
  <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
666
667
  <xsl:when test="ancestor::iho:td/@align"><xsl:value-of select="ancestor::iho:td/@align"/></xsl:when>
667
668
  <xsl:when test="ancestor::iho:th/@align"><xsl:value-of select="ancestor::iho:th/@align"/></xsl:when>
668
669
  <xsl:otherwise>justify</xsl:otherwise>
669
670
  </xsl:choose>
670
671
  </xsl:attribute>
672
+ <xsl:call-template name="setKeepAttributes"/>
671
673
  <xsl:attribute name="space-after">6pt</xsl:attribute>
672
674
  <xsl:if test="parent::iho:dd">
673
675
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
@@ -843,7 +845,7 @@
843
845
  <xsl:strip-space xmlns:redirect="http://xml.apache.org/xalan/redirect" elements="iho:xref"/>
844
846
 
845
847
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
846
- <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/>
848
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
847
849
 
848
850
  <!-- external parameters -->
849
851
 
@@ -2534,7 +2536,7 @@
2534
2536
 
2535
2537
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
2536
2538
 
2537
- <xsl:variable name="updated_xml_step_move_pagebreak_">
2539
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2538
2540
 
2539
2541
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2540
2542
 
@@ -2552,17 +2554,32 @@
2552
2554
  </xsl:variable>
2553
2555
 
2554
2556
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2555
-
2557
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
2558
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2556
2559
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2557
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
2560
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2558
2561
  </redirect:write>
2562
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
2559
2563
 
2560
2564
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2561
2565
 
2566
+ <!-- TODO: instead of
2567
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
2568
+ in each template, add removing empty page_sequence here
2569
+ -->
2570
+
2571
+ <xsl:if test="$debug = 'true'">
2572
+ <redirect:write file="page_sequence_preface.xml">
2573
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2574
+ </redirect:write>
2575
+ </xsl:if>
2576
+
2577
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2562
2578
  <xsl:call-template name="deleteFile">
2563
2579
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2564
2580
  </xsl:call-template>
2565
- </xsl:template>
2581
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
2582
+ </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
2566
2583
 
2567
2584
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
2568
2585
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
@@ -2587,37 +2604,7 @@
2587
2604
  </xsl:for-each>
2588
2605
  </xsl:template><!-- END: processMainSectionsDefault -->
2589
2606
 
2590
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_flatxml">
2591
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2592
- <xsl:sort select="@displayorder" data-type="number"/>
2593
- <xsl:variable name="flatxml">
2594
- <xsl:apply-templates select="." mode="flatxml"/>
2595
- </xsl:variable>
2596
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2597
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2598
-
2599
- </xsl:for-each>
2600
-
2601
- <xsl:for-each select="/*/*[local-name()='annex']">
2602
- <xsl:sort select="@displayorder" data-type="number"/>
2603
- <xsl:variable name="flatxml">
2604
- <xsl:apply-templates select="." mode="flatxml"/>
2605
- </xsl:variable>
2606
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2607
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2608
- </xsl:for-each>
2609
-
2610
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2611
- <xsl:sort select="@displayorder" data-type="number"/>
2612
- <xsl:variable name="flatxml">
2613
- <xsl:apply-templates select="." mode="flatxml"/>
2614
- </xsl:variable>
2615
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
2616
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
2617
- </xsl:for-each>
2618
- </xsl:template>
2619
-
2620
- <!-- Example:
2607
+ <!-- Example:
2621
2608
  <iso-standard>
2622
2609
  <sections>
2623
2610
  <page_sequence>
@@ -2637,7 +2624,7 @@
2637
2624
  -->
2638
2625
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
2639
2626
 
2640
- <xsl:variable name="updated_xml_step_move_pagebreak_">
2627
+ <xsl:variable name="updated_xml_step_move_pagebreak">
2641
2628
 
2642
2629
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
2643
2630
 
@@ -2674,11 +2661,17 @@
2674
2661
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
2675
2662
 
2676
2663
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
2677
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
2664
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
2678
2665
  </redirect:write>
2679
2666
 
2680
2667
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2681
2668
 
2669
+ <xsl:if test="$debug = 'true'">
2670
+ <redirect:write file="page_sequence_main.xml">
2671
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
2672
+ </redirect:write>
2673
+ </xsl:if>
2674
+
2682
2675
  <xsl:call-template name="deleteFile">
2683
2676
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
2684
2677
  </xsl:call-template>
@@ -2691,6 +2684,14 @@
2691
2684
  <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
2692
2685
  </xsl:template>
2693
2686
 
2687
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getPageSequenceOrientation">
2688
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
2689
+ <xsl:choose>
2690
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
2691
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
2692
+ </xsl:choose>
2693
+ </xsl:template>
2694
+
2694
2695
  <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>
2695
2696
  <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>
2696
2697
  <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>
@@ -3023,7 +3024,9 @@
3023
3024
 
3024
3025
  <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']"/>
3025
3026
  <xsl:if test="$isNoteOrFnExist = 'true'">
3026
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3027
+
3028
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3029
+
3027
3030
  </xsl:if>
3028
3031
 
3029
3032
  <xsl:choose>
@@ -3080,13 +3083,14 @@
3080
3083
  </fo:table>
3081
3084
 
3082
3085
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
3083
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3084
- <xsl:call-template name="insertTableFooterInSeparateTable">
3085
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
3086
- <xsl:with-param name="colwidths" select="$colwidths"/>
3087
- <xsl:with-param name="colgroup" select="$colgroup"/>
3088
- </xsl:call-template>
3089
- </xsl:for-each>
3086
+
3087
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3088
+ <xsl:call-template name="insertTableFooterInSeparateTable">
3089
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
3090
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3091
+ <xsl:with-param name="colgroup" select="$colgroup"/>
3092
+ </xsl:call-template>
3093
+ </xsl:for-each>
3090
3094
 
3091
3095
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
3092
3096
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -3476,8 +3480,10 @@
3476
3480
  <width_min><xsl:value-of select="@width_min"/></width_min>
3477
3481
  <e><xsl:value-of select="$d * $W div $D"/></e>
3478
3482
  <!-- set the column's width to the minimum width plus d times W over D. -->
3483
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3484
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
3479
3485
  <column divider="100">
3480
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3486
+ <xsl:value-of select="$column_width"/>
3481
3487
  </column>
3482
3488
  </xsl:for-each>
3483
3489
 
@@ -3885,6 +3891,22 @@
3885
3891
 
3886
3892
  <xsl:call-template name="refine_table-header-cell-style"/>
3887
3893
 
3894
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
3895
+ <!-- <xsl:choose>
3896
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
3897
+ <fo:block-container reference-orientation="270">
3898
+ <fo:block role="SKIP" text-align="start">
3899
+ <xsl:apply-templates />
3900
+ </fo:block>
3901
+ </fo:block-container>
3902
+ </xsl:when>
3903
+ <xsl:otherwise>
3904
+ <fo:block role="SKIP">
3905
+ <xsl:apply-templates />
3906
+ </fo:block>
3907
+ </xsl:otherwise>
3908
+ </xsl:choose> -->
3909
+
3888
3910
  <fo:block role="SKIP">
3889
3911
  <xsl:apply-templates/>
3890
3912
  </fo:block>
@@ -7454,6 +7476,15 @@
7454
7476
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
7455
7477
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
7456
7478
  </xsl:when>
7479
+ <!-- in WebP format, then convert image into PNG -->
7480
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
7481
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7482
+ <xsl:value-of select="$src_png"/>
7483
+ </xsl:when>
7484
+ <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'))">
7485
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
7486
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
7487
+ </xsl:when>
7457
7488
  <xsl:when test="not(starts-with(@src, 'data:'))">
7458
7489
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7459
7490
  </xsl:when>
@@ -11125,6 +11156,75 @@
11125
11156
  <!-- ===================================== -->
11126
11157
  <!-- Update xml -->
11127
11158
  <!-- ===================================== -->
11159
+
11160
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="updateXML">
11161
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
11162
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
11163
+
11164
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
11165
+ <xsl:variable name="updated_xml_step1">
11166
+ <xsl:if test="$table_if = 'false'">
11167
+ <xsl:apply-templates mode="update_xml_step1"/>
11168
+ </xsl:if>
11169
+ </xsl:variable>
11170
+
11171
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
11172
+ <xsl:if test="$debug = 'true'">
11173
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
11174
+ <xsl:message>END updated_xml_step1</xsl:message>
11175
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
11176
+ <xsl:copy-of select="$updated_xml_step1"/>
11177
+ </redirect:write> -->
11178
+ </xsl:if>
11179
+
11180
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
11181
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
11182
+
11183
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
11184
+ <xsl:variable name="updated_xml_step2">
11185
+
11186
+ <xsl:if test="$table_if = 'false'">
11187
+ <xsl:copy-of select="$updated_xml_step1"/>
11188
+ </xsl:if>
11189
+
11190
+ </xsl:variable>
11191
+
11192
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
11193
+ <xsl:if test="$debug = 'true'">
11194
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
11195
+ <xsl:message>END updated_xml_step2</xsl:message>
11196
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
11197
+ <xsl:copy-of select="$updated_xml_step2"/>
11198
+ </redirect:write> -->
11199
+ </xsl:if>
11200
+
11201
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
11202
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
11203
+
11204
+ <xsl:variable name="updated_xml_step3">
11205
+ <xsl:choose>
11206
+ <xsl:when test="$table_if = 'false'">
11207
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
11208
+ </xsl:when>
11209
+ <xsl:otherwise>
11210
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
11211
+ </xsl:otherwise>
11212
+ </xsl:choose>
11213
+ </xsl:variable>
11214
+
11215
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
11216
+ <xsl:if test="$debug = 'true'">
11217
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
11218
+ <xsl:message>END updated_xml_step3</xsl:message>
11219
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
11220
+ <xsl:copy-of select="$updated_xml_step3"/>
11221
+ </redirect:write> -->
11222
+ </xsl:if>
11223
+
11224
+ <xsl:copy-of select="$updated_xml_step3"/>
11225
+
11226
+ </xsl:template>
11227
+
11128
11228
  <!-- =========================================================================== -->
11129
11229
  <!-- STEP1: -->
11130
11230
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
@@ -11324,7 +11424,7 @@
11324
11424
 
11325
11425
  <!-- determine pagebreak is last element before </fo:flow> or not -->
11326
11426
  <xsl:variable name="isLast">
11327
- <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11427
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11328
11428
  <xsl:if test="following-sibling::*">false</xsl:if>
11329
11429
  </xsl:for-each>
11330
11430
  </xsl:variable>
@@ -11346,7 +11446,7 @@
11346
11446
  <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
11347
11447
 
11348
11448
  <!-- create a new page_sequence (opening elements) -->
11349
- <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>
11449
+ <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>
11350
11450
 
11351
11451
  <xsl:call-template name="insertOpeningElements">
11352
11452
  <xsl:with-param name="tree" select="$tree"/>
@@ -11356,7 +11456,7 @@
11356
11456
  </xsl:template>
11357
11457
 
11358
11458
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
11359
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11459
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
11360
11460
  <element pos="{position()}">
11361
11461
  <xsl:copy-of select="@*[local-name() != 'id']"/>
11362
11462
  <xsl:value-of select="name()"/>
@@ -11537,7 +11637,7 @@
11537
11637
  <xsl:value-of select="substring-before($text, $tag_open)"/>
11538
11638
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
11539
11639
 
11540
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
11640
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
11541
11641
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
11542
11642
  </xsl:element>
11543
11643
 
@@ -12359,7 +12459,10 @@
12359
12459
  <xsl:call-template name="setTextAlignment">
12360
12460
  <xsl:with-param name="default" select="$text_align_default"/>
12361
12461
  </xsl:call-template>
12462
+ <xsl:call-template name="setKeepAttributes"/>
12463
+ </xsl:template>
12362
12464
 
12465
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="setKeepAttributes">
12363
12466
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
12364
12467
  <!-- Example: keep-lines-together="true" -->
12365
12468
  <xsl:if test="@keep-lines-together = 'true'">
@@ -12371,6 +12474,72 @@
12371
12474
  </xsl:if>
12372
12475
  </xsl:template>
12373
12476
 
12477
+ <!-- insert cover page image -->
12478
+ <!-- background cover image -->
12479
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
12480
+ <xsl:param name="number">1</xsl:param>
12481
+ <xsl:param name="name">coverpage-image</xsl:param>
12482
+ <xsl:variable name="num" select="number($number)"/>
12483
+ <!-- background image -->
12484
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
12485
+ <fo:block>
12486
+ <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]">
12487
+ <xsl:choose>
12488
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
12489
+ <fo:instream-foreign-object fox:alt-text="Image Front">
12490
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
12491
+ <xsl:call-template name="getSVG"/>
12492
+ </fo:instream-foreign-object>
12493
+ </xsl:when>
12494
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
12495
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
12496
+ </xsl:when>
12497
+ <xsl:otherwise> <!-- bitmap image -->
12498
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
12499
+ <xsl:if test="$coverimage_src != ''">
12500
+ <xsl:variable name="coverpage">
12501
+ <xsl:call-template name="getImageURL">
12502
+ <xsl:with-param name="src" select="$coverimage_src"/>
12503
+ </xsl:call-template>
12504
+ </xsl:variable>
12505
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
12506
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
12507
+ </xsl:if>
12508
+ </xsl:otherwise>
12509
+ </xsl:choose>
12510
+ </xsl:for-each>
12511
+ </fo:block>
12512
+ </fo:block-container>
12513
+ </xsl:template>
12514
+
12515
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getImageURL">
12516
+ <xsl:param name="src"/>
12517
+ <xsl:choose>
12518
+ <xsl:when test="starts-with($src, 'data:image')">
12519
+ <xsl:value-of select="$src"/>
12520
+ </xsl:when>
12521
+ <xsl:otherwise>
12522
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
12523
+ </xsl:otherwise>
12524
+ </xsl:choose>
12525
+ </xsl:template>
12526
+
12527
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getSVG">
12528
+ <xsl:choose>
12529
+ <xsl:when test="*[local-name() = 'svg']">
12530
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
12531
+ </xsl:when>
12532
+ <xsl:otherwise>
12533
+ <xsl:variable name="svg_content" select="document(@src)"/>
12534
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
12535
+ <xsl:apply-templates select="." mode="svg_update"/>
12536
+ </xsl:for-each>
12537
+ </xsl:otherwise>
12538
+ </xsl:choose>
12539
+ </xsl:template>
12540
+
12541
+ <!-- END: insert cover page image -->
12542
+
12374
12543
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="number-to-words">
12375
12544
  <xsl:param name="number"/>
12376
12545
  <xsl:param name="first"/>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IHO
3
- VERSION = "0.9.8".freeze
3
+ VERSION = "0.9.9".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
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: metanorma-generic