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.
@@ -709,14 +709,11 @@
709
709
  </xsl:choose>
710
710
  </xsl:variable>
711
711
  <xsl:element name="{$element-name}">
712
- <xsl:attribute name="text-align">
713
- <xsl:choose>
714
- <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
715
- <xsl:when test="ancestor::*[local-name()='td']/@align"><xsl:value-of select="ancestor::*[local-name()='td']/@align"/></xsl:when>
716
- <xsl:when test="ancestor::*[local-name()='th']/@align"><xsl:value-of select="ancestor::*[local-name()='th']/@align"/></xsl:when>
717
- <xsl:otherwise>justify</xsl:otherwise><!-- left -->
718
- </xsl:choose>
719
- </xsl:attribute>
712
+
713
+ <xsl:call-template name="setBlockAttributes">
714
+ <xsl:with-param name="text_align_default">justify</xsl:with-param>
715
+ </xsl:call-template>
716
+
720
717
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
721
718
  <xsl:if test="ancestor::*[@first or @slave]">
722
719
  <!-- JCGM two column layout -->
@@ -1733,7 +1730,7 @@
1733
1730
  <xsl:strip-space xmlns:redirect="http://xml.apache.org/xalan/redirect" elements="jcgm:xref"/>
1734
1731
 
1735
1732
  <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso -->
1736
- <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/>
1733
+ <xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="root_element" select="local-name(/*)"/> <!-- example: iso-standard -->
1737
1734
 
1738
1735
  <!-- external parameters -->
1739
1736
 
@@ -3451,7 +3448,7 @@
3451
3448
 
3452
3449
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processPrefaceSectionsDefault_items">
3453
3450
 
3454
- <xsl:variable name="updated_xml_step_move_pagebreak_">
3451
+ <xsl:variable name="updated_xml_step_move_pagebreak">
3455
3452
 
3456
3453
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
3457
3454
 
@@ -3469,17 +3466,32 @@
3469
3466
  </xsl:variable>
3470
3467
 
3471
3468
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/>
3472
-
3469
+ <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message>
3470
+ <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> -->
3473
3471
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
3474
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
3472
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
3475
3473
  </redirect:write>
3474
+ <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> -->
3476
3475
 
3477
3476
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
3478
3477
 
3478
+ <!-- TODO: instead of
3479
+ <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]">
3480
+ in each template, add removing empty page_sequence here
3481
+ -->
3482
+
3483
+ <xsl:if test="$debug = 'true'">
3484
+ <redirect:write file="page_sequence_preface.xml">
3485
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
3486
+ </redirect:write>
3487
+ </xsl:if>
3488
+
3489
+ <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
3479
3490
  <xsl:call-template name="deleteFile">
3480
3491
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
3481
3492
  </xsl:call-template>
3482
- </xsl:template>
3493
+ <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> -->
3494
+ </xsl:template> <!-- END: processPrefaceSectionsDefault_items -->
3483
3495
 
3484
3496
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="copyCommonElements">
3485
3497
  <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate -->
@@ -3504,37 +3516,7 @@
3504
3516
  </xsl:for-each>
3505
3517
  </xsl:template><!-- END: processMainSectionsDefault -->
3506
3518
 
3507
- <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_flatxml">
3508
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3509
- <xsl:sort select="@displayorder" data-type="number"/>
3510
- <xsl:variable name="flatxml">
3511
- <xsl:apply-templates select="." mode="flatxml"/>
3512
- </xsl:variable>
3513
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3514
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3515
-
3516
- </xsl:for-each>
3517
-
3518
- <xsl:for-each select="/*/*[local-name()='annex']">
3519
- <xsl:sort select="@displayorder" data-type="number"/>
3520
- <xsl:variable name="flatxml">
3521
- <xsl:apply-templates select="." mode="flatxml"/>
3522
- </xsl:variable>
3523
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3524
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3525
- </xsl:for-each>
3526
-
3527
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3528
- <xsl:sort select="@displayorder" data-type="number"/>
3529
- <xsl:variable name="flatxml">
3530
- <xsl:apply-templates select="." mode="flatxml"/>
3531
- </xsl:variable>
3532
- <!-- debug_flatxml='<xsl:copy-of select="$flatxml"/>' -->
3533
- <xsl:apply-templates select="xalan:nodeset($flatxml)/*"/>
3534
- </xsl:for-each>
3535
- </xsl:template>
3536
-
3537
- <!-- Example:
3519
+ <!-- Example:
3538
3520
  <iso-standard>
3539
3521
  <sections>
3540
3522
  <page_sequence>
@@ -3554,7 +3536,7 @@
3554
3536
  -->
3555
3537
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="processMainSectionsDefault_items">
3556
3538
 
3557
- <xsl:variable name="updated_xml_step_move_pagebreak_">
3539
+ <xsl:variable name="updated_xml_step_move_pagebreak">
3558
3540
 
3559
3541
  <xsl:element name="{$root_element}" namespace="{$namespace_full}">
3560
3542
 
@@ -3591,11 +3573,17 @@
3591
3573
  <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/>
3592
3574
 
3593
3575
  <redirect:write file="{$updated_xml_step_move_pagebreak_filename}">
3594
- <xsl:copy-of select="$updated_xml_step_move_pagebreak_"/>
3576
+ <xsl:copy-of select="$updated_xml_step_move_pagebreak"/>
3595
3577
  </redirect:write>
3596
3578
 
3597
3579
  <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
3598
3580
 
3581
+ <xsl:if test="$debug = 'true'">
3582
+ <redirect:write file="page_sequence_main.xml">
3583
+ <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/>
3584
+ </redirect:write>
3585
+ </xsl:if>
3586
+
3599
3587
  <xsl:call-template name="deleteFile">
3600
3588
  <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/>
3601
3589
  </xsl:call-template>
@@ -3608,6 +3596,14 @@
3608
3596
  <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/>
3609
3597
  </xsl:template>
3610
3598
 
3599
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getPageSequenceOrientation">
3600
+ <xsl:variable name="previous_orientation" select="preceding-sibling::*[local-name() = 'page_sequence'][@orientation][1]/@orientation"/>
3601
+ <xsl:choose>
3602
+ <xsl:when test="@orientation = 'landscape'">-<xsl:value-of select="@orientation"/></xsl:when>
3603
+ <xsl:when test="$previous_orientation = 'landscape' and not(@orientation = 'portrait')">-<xsl:value-of select="$previous_orientation"/></xsl:when>
3604
+ </xsl:choose>
3605
+ </xsl:template>
3606
+
3611
3607
  <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>
3612
3608
  <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>
3613
3609
  <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>
@@ -3936,7 +3932,9 @@
3936
3932
 
3937
3933
  <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']"/>
3938
3934
  <xsl:if test="$isNoteOrFnExist = 'true'">
3939
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3935
+
3936
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3937
+
3940
3938
  </xsl:if>
3941
3939
 
3942
3940
  <xsl:choose>
@@ -3993,13 +3991,14 @@
3993
3991
  </fo:table>
3994
3992
 
3995
3993
  <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
3996
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3997
- <xsl:call-template name="insertTableFooterInSeparateTable">
3998
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
3999
- <xsl:with-param name="colwidths" select="$colwidths"/>
4000
- <xsl:with-param name="colgroup" select="$colgroup"/>
4001
- </xsl:call-template>
4002
- </xsl:for-each>
3994
+
3995
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
3996
+ <xsl:call-template name="insertTableFooterInSeparateTable">
3997
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
3998
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3999
+ <xsl:with-param name="colgroup" select="$colgroup"/>
4000
+ </xsl:call-template>
4001
+ </xsl:for-each>
4003
4002
 
4004
4003
  <xsl:if test="*[local-name()='bookmark']"> <!-- special case: table/bookmark -->
4005
4004
  <fo:block keep-with-previous="always" line-height="0.1">
@@ -4391,8 +4390,10 @@
4391
4390
  <width_min><xsl:value-of select="@width_min"/></width_min>
4392
4391
  <e><xsl:value-of select="$d * $W div $D"/></e>
4393
4392
  <!-- set the column's width to the minimum width plus d times W over D. -->
4393
+ <xsl:variable name="column_width_" select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4394
+ <xsl:variable name="column_width" select="$column_width_*($column_width_ &gt;= 0) - $column_width_*($column_width_ &lt; 0)"/> <!-- absolute value -->
4394
4395
  <column divider="100">
4395
- <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4396
+ <xsl:value-of select="$column_width"/>
4396
4397
  </column>
4397
4398
  </xsl:for-each>
4398
4399
 
@@ -4854,6 +4855,22 @@
4854
4855
 
4855
4856
  <xsl:call-template name="refine_table-header-cell-style"/>
4856
4857
 
4858
+ <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 -->
4859
+ <!-- <xsl:choose>
4860
+ <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]">
4861
+ <fo:block-container reference-orientation="270">
4862
+ <fo:block role="SKIP" text-align="start">
4863
+ <xsl:apply-templates />
4864
+ </fo:block>
4865
+ </fo:block-container>
4866
+ </xsl:when>
4867
+ <xsl:otherwise>
4868
+ <fo:block role="SKIP">
4869
+ <xsl:apply-templates />
4870
+ </fo:block>
4871
+ </xsl:otherwise>
4872
+ </xsl:choose> -->
4873
+
4857
4874
  <fo:block role="SKIP">
4858
4875
  <xsl:apply-templates/>
4859
4876
  </fo:block>
@@ -8369,6 +8386,15 @@
8369
8386
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
8370
8387
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
8371
8388
  </xsl:when>
8389
+ <!-- in WebP format, then convert image into PNG -->
8390
+ <xsl:when test="starts-with(@src, 'data:image/webp')">
8391
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
8392
+ <xsl:value-of select="$src_png"/>
8393
+ </xsl:when>
8394
+ <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'))">
8395
+ <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/>
8396
+ <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
8397
+ </xsl:when>
8372
8398
  <xsl:when test="not(starts-with(@src, 'data:'))">
8373
8399
  <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
8374
8400
  </xsl:when>
@@ -12060,6 +12086,75 @@
12060
12086
  <!-- ===================================== -->
12061
12087
  <!-- Update xml -->
12062
12088
  <!-- ===================================== -->
12089
+
12090
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="updateXML">
12091
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step1</xsl:message></xsl:if>
12092
+ <xsl:variable name="startTime1" select="java:getTime(java:java.util.Date.new())"/>
12093
+
12094
+ <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
12095
+ <xsl:variable name="updated_xml_step1">
12096
+ <xsl:if test="$table_if = 'false'">
12097
+ <xsl:apply-templates mode="update_xml_step1"/>
12098
+ </xsl:if>
12099
+ </xsl:variable>
12100
+
12101
+ <xsl:variable name="endTime1" select="java:getTime(java:java.util.Date.new())"/>
12102
+ <xsl:if test="$debug = 'true'">
12103
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime1 - $startTime1"/> msec.</xsl:message>
12104
+ <xsl:message>END updated_xml_step1</xsl:message>
12105
+ <!-- <redirect:write file="updated_xml_step1_{java:getTime(java:java.util.Date.new())}.xml">
12106
+ <xsl:copy-of select="$updated_xml_step1"/>
12107
+ </redirect:write> -->
12108
+ </xsl:if>
12109
+
12110
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step2</xsl:message></xsl:if>
12111
+ <xsl:variable name="startTime2" select="java:getTime(java:java.util.Date.new())"/>
12112
+
12113
+ <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
12114
+ <xsl:variable name="updated_xml_step2">
12115
+
12116
+ <xsl:if test="$table_if = 'false'">
12117
+ <xsl:copy-of select="$updated_xml_step1"/>
12118
+ </xsl:if>
12119
+
12120
+ </xsl:variable>
12121
+
12122
+ <xsl:variable name="endTime2" select="java:getTime(java:java.util.Date.new())"/>
12123
+ <xsl:if test="$debug = 'true'">
12124
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime2 - $startTime2"/> msec.</xsl:message>
12125
+ <xsl:message>END updated_xml_step2</xsl:message>
12126
+ <!-- <redirect:write file="updated_xml_step2_{java:getTime(java:java.util.Date.new())}.xml">
12127
+ <xsl:copy-of select="$updated_xml_step2"/>
12128
+ </redirect:write> -->
12129
+ </xsl:if>
12130
+
12131
+ <xsl:if test="$debug = 'true'"><xsl:message>START updated_xml_step3</xsl:message></xsl:if>
12132
+ <xsl:variable name="startTime3" select="java:getTime(java:java.util.Date.new())"/>
12133
+
12134
+ <xsl:variable name="updated_xml_step3">
12135
+ <xsl:choose>
12136
+ <xsl:when test="$table_if = 'false'">
12137
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
12138
+ </xsl:when>
12139
+ <xsl:otherwise>
12140
+ <xsl:apply-templates select="." mode="update_xml_enclose_keep-together_within-line"/>
12141
+ </xsl:otherwise>
12142
+ </xsl:choose>
12143
+ </xsl:variable>
12144
+
12145
+ <xsl:variable name="endTime3" select="java:getTime(java:java.util.Date.new())"/>
12146
+ <xsl:if test="$debug = 'true'">
12147
+ <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime3 - $startTime3"/> msec.</xsl:message>
12148
+ <xsl:message>END updated_xml_step3</xsl:message>
12149
+ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml">
12150
+ <xsl:copy-of select="$updated_xml_step3"/>
12151
+ </redirect:write> -->
12152
+ </xsl:if>
12153
+
12154
+ <xsl:copy-of select="$updated_xml_step3"/>
12155
+
12156
+ </xsl:template>
12157
+
12063
12158
  <!-- =========================================================================== -->
12064
12159
  <!-- STEP1: -->
12065
12160
  <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
@@ -12259,7 +12354,7 @@
12259
12354
 
12260
12355
  <!-- determine pagebreak is last element before </fo:flow> or not -->
12261
12356
  <xsl:variable name="isLast">
12262
- <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12357
+ <xsl:for-each select="ancestor-or-self::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12263
12358
  <xsl:if test="following-sibling::*">false</xsl:if>
12264
12359
  </xsl:for-each>
12265
12360
  </xsl:variable>
@@ -12281,7 +12376,7 @@
12281
12376
  <xsl:text disable-output-escaping="yes">&lt;/page_sequence&gt;</xsl:text>
12282
12377
 
12283
12378
  <!-- create a new page_sequence (opening elements) -->
12284
- <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>
12379
+ <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>
12285
12380
 
12286
12381
  <xsl:call-template name="insertOpeningElements">
12287
12382
  <xsl:with-param name="tree" select="$tree"/>
@@ -12291,7 +12386,7 @@
12291
12386
  </xsl:template>
12292
12387
 
12293
12388
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="makeAncestorsElementsTree">
12294
- <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12389
+ <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]">
12295
12390
  <element pos="{position()}">
12296
12391
  <xsl:copy-of select="@*[local-name() != 'id']"/>
12297
12392
  <xsl:value-of select="name()"/>
@@ -12472,7 +12567,7 @@
12472
12567
  <xsl:value-of select="substring-before($text, $tag_open)"/>
12473
12568
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
12474
12569
 
12475
- <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
12570
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}" namespace="{$namespace_full}">
12476
12571
  <xsl:value-of select="substring-before($text_after, $tag_close)"/>
12477
12572
  </xsl:element>
12478
12573
 
@@ -13292,7 +13387,10 @@
13292
13387
  <xsl:call-template name="setTextAlignment">
13293
13388
  <xsl:with-param name="default" select="$text_align_default"/>
13294
13389
  </xsl:call-template>
13390
+ <xsl:call-template name="setKeepAttributes"/>
13391
+ </xsl:template>
13295
13392
 
13393
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="setKeepAttributes">
13296
13394
  <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
13297
13395
  <!-- Example: keep-lines-together="true" -->
13298
13396
  <xsl:if test="@keep-lines-together = 'true'">
@@ -13304,6 +13402,72 @@
13304
13402
  </xsl:if>
13305
13403
  </xsl:template>
13306
13404
 
13405
+ <!-- insert cover page image -->
13406
+ <!-- background cover image -->
13407
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
13408
+ <xsl:param name="number">1</xsl:param>
13409
+ <xsl:param name="name">coverpage-image</xsl:param>
13410
+ <xsl:variable name="num" select="number($number)"/>
13411
+ <!-- background image -->
13412
+ <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
13413
+ <fo:block>
13414
+ <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]">
13415
+ <xsl:choose>
13416
+ <xsl:when test="*[local-name() = 'svg'] or java:endsWith(java:java.lang.String.new(@src), '.svg')">
13417
+ <fo:instream-foreign-object fox:alt-text="Image Front">
13418
+ <xsl:attribute name="content-height"><xsl:value-of select="$pageHeight"/>mm</xsl:attribute>
13419
+ <xsl:call-template name="getSVG"/>
13420
+ </fo:instream-foreign-object>
13421
+ </xsl:when>
13422
+ <xsl:when test="starts-with(@src, 'data:application/pdf;base64')">
13423
+ <fo:external-graphic src="{@src}" fox:alt-text="Image Front"/>
13424
+ </xsl:when>
13425
+ <xsl:otherwise> <!-- bitmap image -->
13426
+ <xsl:variable name="coverimage_src" select="normalize-space(@src)"/>
13427
+ <xsl:if test="$coverimage_src != ''">
13428
+ <xsl:variable name="coverpage">
13429
+ <xsl:call-template name="getImageURL">
13430
+ <xsl:with-param name="src" select="$coverimage_src"/>
13431
+ </xsl:call-template>
13432
+ </xsl:variable>
13433
+ <!-- <xsl:variable name="coverpage" select="concat('url(file:',$basepath, 'coverpage1.png', ')')"/> --> <!-- for DEBUG -->
13434
+ <fo:external-graphic src="{$coverpage}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
13435
+ </xsl:if>
13436
+ </xsl:otherwise>
13437
+ </xsl:choose>
13438
+ </xsl:for-each>
13439
+ </fo:block>
13440
+ </fo:block-container>
13441
+ </xsl:template>
13442
+
13443
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getImageURL">
13444
+ <xsl:param name="src"/>
13445
+ <xsl:choose>
13446
+ <xsl:when test="starts-with($src, 'data:image')">
13447
+ <xsl:value-of select="$src"/>
13448
+ </xsl:when>
13449
+ <xsl:otherwise>
13450
+ <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/>
13451
+ </xsl:otherwise>
13452
+ </xsl:choose>
13453
+ </xsl:template>
13454
+
13455
+ <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="getSVG">
13456
+ <xsl:choose>
13457
+ <xsl:when test="*[local-name() = 'svg']">
13458
+ <xsl:apply-templates select="*[local-name() = 'svg']" mode="svg_update"/>
13459
+ </xsl:when>
13460
+ <xsl:otherwise>
13461
+ <xsl:variable name="svg_content" select="document(@src)"/>
13462
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
13463
+ <xsl:apply-templates select="." mode="svg_update"/>
13464
+ </xsl:for-each>
13465
+ </xsl:otherwise>
13466
+ </xsl:choose>
13467
+ </xsl:template>
13468
+
13469
+ <!-- END: insert cover page image -->
13470
+
13307
13471
  <xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="number-to-words">
13308
13472
  <xsl:param name="number"/>
13309
13473
  <xsl:param name="first"/>
@@ -79,17 +79,28 @@ module IsoDoc
79
79
  fraction_group_digits: 3 }
80
80
  end
81
81
 
82
- def localized_number(num, locale, precision)
83
- g = Regexp.quote(@twitter_cldr_reader[:group])
84
- f = Regexp.quote(@twitter_cldr_reader[:fraction_group])
85
- d = Regexp.quote(@twitter_cldr_reader[:decimal])
86
- super.sub(/^(\d)#{g}(\d) (?= \d\d$ | \d\d#{d} )/x, "\\1\\2")
87
- .sub(/(?<= ^\d\d | #{d}\d\d ) (\d)#{f}(\d) $/x, "\\1\\2")
82
+ def localize_maths(node, locale)
83
+ super
84
+ node.xpath(".//m:mn", MATHML).each do |x|
85
+ x.children = x.text
86
+ .sub(/^(\d)#{@cldr[:g]}(\d) (?= \d\d$ | \d\d#{@cldr[:d]} )/x,
87
+ "\\1\\2")
88
+ .sub(/(?<= ^\d\d | #{@cldr[:d]}\d\d ) (\d)#{@cldr[:f]}(\d) $/x,
89
+ "\\1\\2")
90
+ end
88
91
  end
89
92
 
90
- def mathml1(elem, locale)
91
- asciimath_dup(elem)
92
- localize_maths(elem, locale)
93
+ def mathml1(node, locale)
94
+ unless @cldr
95
+ r = @numfmt.twitter_cldr_reader(locale: locale)
96
+ .transform_values { |v| @c.decode(v) }
97
+ @cldr = {
98
+ g: Regexp.quote(r[:group]),
99
+ f: Regexp.quote(r[:fraction_group]),
100
+ d: Regexp.quote(r[:decimal]),
101
+ }
102
+ end
103
+ super
93
104
  end
94
105
 
95
106
  def bibdata_i18n(bibdata)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "2.4.8".freeze
3
+ VERSION = "2.4.9".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.8
4
+ version: 2.4.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