metanorma-ogc 1.3.7 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1790,7 +1790,9 @@
1790
1790
 
1791
1791
 
1792
1792
 
1793
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1793
+ </xsl:attribute-set><xsl:variable name="table-border_">
1794
+
1795
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1794
1796
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1795
1797
 
1796
1798
 
@@ -2120,6 +2122,8 @@
2120
2122
  <fo:block>&#xA0;</fo:block>
2121
2123
  </xsl:if> -->
2122
2124
 
2125
+
2126
+ <!-- Display table's name before table as standalone block -->
2123
2127
  <!-- $namespace = 'iso' or -->
2124
2128
 
2125
2129
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -2203,6 +2207,12 @@
2203
2207
 
2204
2208
 
2205
2209
 
2210
+
2211
+
2212
+
2213
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
2214
+
2215
+
2206
2216
  <xsl:variable name="table_width">
2207
2217
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
2208
2218
 
@@ -2227,6 +2237,7 @@
2227
2237
 
2228
2238
 
2229
2239
 
2240
+
2230
2241
  <attribute name="margin-left">0mm</attribute>
2231
2242
  <attribute name="margin-right">0mm</attribute>
2232
2243
 
@@ -2651,6 +2662,8 @@
2651
2662
  </xsl:choose>
2652
2663
  </xsl:for-each>
2653
2664
 
2665
+
2666
+
2654
2667
  <xsl:choose>
2655
2668
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2656
2669
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -2689,6 +2702,7 @@
2689
2702
 
2690
2703
 
2691
2704
 
2705
+
2692
2706
  <!-- for BSI (not PAS) display Notes before footnotes -->
2693
2707
 
2694
2708
 
@@ -2774,6 +2788,8 @@
2774
2788
 
2775
2789
 
2776
2790
 
2791
+
2792
+
2777
2793
  </xsl:if>
2778
2794
  <xsl:if test="$parent-name = 'tfoot'">
2779
2795
 
@@ -2800,6 +2816,8 @@
2800
2816
 
2801
2817
 
2802
2818
 
2819
+
2820
+
2803
2821
  <!-- <xsl:if test="$namespace = 'bipm'">
2804
2822
  <xsl:attribute name="height">8mm</xsl:attribute>
2805
2823
  </xsl:if> -->
@@ -4332,7 +4350,24 @@
4332
4350
  </fo:instream-foreign-object>
4333
4351
  </xsl:when>
4334
4352
  <xsl:otherwise>
4335
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
4353
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
4354
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
4355
+
4356
+ <xsl:variable name="img_src">
4357
+ <xsl:choose>
4358
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
4359
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
4360
+ </xsl:choose>
4361
+ </xsl:variable>
4362
+
4363
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
4364
+ <xsl:if test="number($scale) &lt; 100">
4365
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
4366
+ </xsl:if>
4367
+
4368
+ </xsl:if>
4369
+
4370
+ </fo:external-graphic>
4336
4371
  </xsl:otherwise>
4337
4372
  </xsl:choose>
4338
4373
 
@@ -4503,11 +4538,13 @@
4503
4538
  <xsl:attribute name="width">100%</xsl:attribute>
4504
4539
  <xsl:attribute name="content-height">100%</xsl:attribute>
4505
4540
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4541
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
4542
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
4506
4543
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4507
4544
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4508
4545
  <!-- effective height / width = 1.48, 1.4 - with title -->
4509
- <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
4510
- <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
4546
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
4547
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
4511
4548
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4512
4549
  </xsl:if>
4513
4550
  <xsl:attribute name="scaling">uniform</xsl:attribute>
@@ -4524,6 +4561,23 @@
4524
4561
  <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4525
4562
  <xsl:value-of select="."/>
4526
4563
  </xsl:attribute>
4564
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4565
+ <xsl:copy>
4566
+ <xsl:apply-templates select="@*" mode="svg_update"/>
4567
+ <xsl:variable name="viewbox">
4568
+ <xsl:call-template name="split">
4569
+ <xsl:with-param name="pText" select="@viewBox"/>
4570
+ <xsl:with-param name="sep" select="' '"/>
4571
+ </xsl:call-template>
4572
+ </xsl:variable>
4573
+ <xsl:attribute name="width">
4574
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4575
+ </xsl:attribute>
4576
+ <xsl:attribute name="height">
4577
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4578
+ </xsl:attribute>
4579
+ <xsl:apply-templates mode="svg_update"/>
4580
+ </xsl:copy>
4527
4581
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4528
4582
  <xsl:variable name="svg_content" select="document(@src)"/>
4529
4583
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -6410,20 +6464,40 @@
6410
6464
  </xsl:call-template>
6411
6465
  </xsl:if>
6412
6466
  </xsl:template><xsl:template name="getLocalizedString">
6413
- <xsl:param name="key"/>
6467
+ <xsl:param name="key"/>
6468
+ <xsl:param name="formatted">false</xsl:param>
6414
6469
 
6415
6470
  <xsl:variable name="curr_lang">
6416
6471
  <xsl:call-template name="getLang"/>
6417
6472
  </xsl:variable>
6418
6473
 
6419
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
6474
+ <xsl:variable name="data_value">
6475
+ <xsl:choose>
6476
+ <xsl:when test="$formatted = 'true'">
6477
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6478
+ </xsl:when>
6479
+ <xsl:otherwise>
6480
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
6481
+ </xsl:otherwise>
6482
+ </xsl:choose>
6483
+ </xsl:variable>
6420
6484
 
6421
6485
  <xsl:choose>
6422
- <xsl:when test="$data_value != ''">
6423
- <xsl:value-of select="$data_value"/>
6486
+ <xsl:when test="normalize-space($data_value) != ''">
6487
+ <xsl:choose>
6488
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
6489
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
6490
+ </xsl:choose>
6424
6491
  </xsl:when>
6425
6492
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
6426
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6493
+ <xsl:choose>
6494
+ <xsl:when test="$formatted = 'true'">
6495
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6496
+ </xsl:when>
6497
+ <xsl:otherwise>
6498
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6499
+ </xsl:otherwise>
6500
+ </xsl:choose>
6427
6501
  </xsl:when>
6428
6502
  <xsl:otherwise>
6429
6503
  <xsl:variable name="key_">
@@ -6434,7 +6508,7 @@
6434
6508
  <xsl:value-of select="$key_"/>
6435
6509
  </xsl:otherwise>
6436
6510
  </xsl:choose>
6437
-
6511
+
6438
6512
  </xsl:template><xsl:template name="setTrackChangesStyles">
6439
6513
  <xsl:param name="isAdded"/>
6440
6514
  <xsl:param name="isDeleted"/>
@@ -1790,7 +1790,9 @@
1790
1790
 
1791
1791
 
1792
1792
 
1793
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1793
+ </xsl:attribute-set><xsl:variable name="table-border_">
1794
+
1795
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1794
1796
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1795
1797
 
1796
1798
 
@@ -2120,6 +2122,8 @@
2120
2122
  <fo:block>&#xA0;</fo:block>
2121
2123
  </xsl:if> -->
2122
2124
 
2125
+
2126
+ <!-- Display table's name before table as standalone block -->
2123
2127
  <!-- $namespace = 'iso' or -->
2124
2128
 
2125
2129
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -2203,6 +2207,12 @@
2203
2207
 
2204
2208
 
2205
2209
 
2210
+
2211
+
2212
+
2213
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
2214
+
2215
+
2206
2216
  <xsl:variable name="table_width">
2207
2217
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
2208
2218
 
@@ -2227,6 +2237,7 @@
2227
2237
 
2228
2238
 
2229
2239
 
2240
+
2230
2241
  <attribute name="margin-left">0mm</attribute>
2231
2242
  <attribute name="margin-right">0mm</attribute>
2232
2243
 
@@ -2651,6 +2662,8 @@
2651
2662
  </xsl:choose>
2652
2663
  </xsl:for-each>
2653
2664
 
2665
+
2666
+
2654
2667
  <xsl:choose>
2655
2668
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2656
2669
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -2689,6 +2702,7 @@
2689
2702
 
2690
2703
 
2691
2704
 
2705
+
2692
2706
  <!-- for BSI (not PAS) display Notes before footnotes -->
2693
2707
 
2694
2708
 
@@ -2774,6 +2788,8 @@
2774
2788
 
2775
2789
 
2776
2790
 
2791
+
2792
+
2777
2793
  </xsl:if>
2778
2794
  <xsl:if test="$parent-name = 'tfoot'">
2779
2795
 
@@ -2800,6 +2816,8 @@
2800
2816
 
2801
2817
 
2802
2818
 
2819
+
2820
+
2803
2821
  <!-- <xsl:if test="$namespace = 'bipm'">
2804
2822
  <xsl:attribute name="height">8mm</xsl:attribute>
2805
2823
  </xsl:if> -->
@@ -4332,7 +4350,24 @@
4332
4350
  </fo:instream-foreign-object>
4333
4351
  </xsl:when>
4334
4352
  <xsl:otherwise>
4335
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
4353
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
4354
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
4355
+
4356
+ <xsl:variable name="img_src">
4357
+ <xsl:choose>
4358
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
4359
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
4360
+ </xsl:choose>
4361
+ </xsl:variable>
4362
+
4363
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
4364
+ <xsl:if test="number($scale) &lt; 100">
4365
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
4366
+ </xsl:if>
4367
+
4368
+ </xsl:if>
4369
+
4370
+ </fo:external-graphic>
4336
4371
  </xsl:otherwise>
4337
4372
  </xsl:choose>
4338
4373
 
@@ -4503,11 +4538,13 @@
4503
4538
  <xsl:attribute name="width">100%</xsl:attribute>
4504
4539
  <xsl:attribute name="content-height">100%</xsl:attribute>
4505
4540
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4541
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
4542
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
4506
4543
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4507
4544
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4508
4545
  <!-- effective height / width = 1.48, 1.4 - with title -->
4509
- <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
4510
- <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
4546
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
4547
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
4511
4548
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4512
4549
  </xsl:if>
4513
4550
  <xsl:attribute name="scaling">uniform</xsl:attribute>
@@ -4524,6 +4561,23 @@
4524
4561
  <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4525
4562
  <xsl:value-of select="."/>
4526
4563
  </xsl:attribute>
4564
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4565
+ <xsl:copy>
4566
+ <xsl:apply-templates select="@*" mode="svg_update"/>
4567
+ <xsl:variable name="viewbox">
4568
+ <xsl:call-template name="split">
4569
+ <xsl:with-param name="pText" select="@viewBox"/>
4570
+ <xsl:with-param name="sep" select="' '"/>
4571
+ </xsl:call-template>
4572
+ </xsl:variable>
4573
+ <xsl:attribute name="width">
4574
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4575
+ </xsl:attribute>
4576
+ <xsl:attribute name="height">
4577
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4578
+ </xsl:attribute>
4579
+ <xsl:apply-templates mode="svg_update"/>
4580
+ </xsl:copy>
4527
4581
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4528
4582
  <xsl:variable name="svg_content" select="document(@src)"/>
4529
4583
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -6410,20 +6464,40 @@
6410
6464
  </xsl:call-template>
6411
6465
  </xsl:if>
6412
6466
  </xsl:template><xsl:template name="getLocalizedString">
6413
- <xsl:param name="key"/>
6467
+ <xsl:param name="key"/>
6468
+ <xsl:param name="formatted">false</xsl:param>
6414
6469
 
6415
6470
  <xsl:variable name="curr_lang">
6416
6471
  <xsl:call-template name="getLang"/>
6417
6472
  </xsl:variable>
6418
6473
 
6419
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
6474
+ <xsl:variable name="data_value">
6475
+ <xsl:choose>
6476
+ <xsl:when test="$formatted = 'true'">
6477
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6478
+ </xsl:when>
6479
+ <xsl:otherwise>
6480
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
6481
+ </xsl:otherwise>
6482
+ </xsl:choose>
6483
+ </xsl:variable>
6420
6484
 
6421
6485
  <xsl:choose>
6422
- <xsl:when test="$data_value != ''">
6423
- <xsl:value-of select="$data_value"/>
6486
+ <xsl:when test="normalize-space($data_value) != ''">
6487
+ <xsl:choose>
6488
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
6489
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
6490
+ </xsl:choose>
6424
6491
  </xsl:when>
6425
6492
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
6426
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6493
+ <xsl:choose>
6494
+ <xsl:when test="$formatted = 'true'">
6495
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6496
+ </xsl:when>
6497
+ <xsl:otherwise>
6498
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6499
+ </xsl:otherwise>
6500
+ </xsl:choose>
6427
6501
  </xsl:when>
6428
6502
  <xsl:otherwise>
6429
6503
  <xsl:variable name="key_">
@@ -6434,7 +6508,7 @@
6434
6508
  <xsl:value-of select="$key_"/>
6435
6509
  </xsl:otherwise>
6436
6510
  </xsl:choose>
6437
-
6511
+
6438
6512
  </xsl:template><xsl:template name="setTrackChangesStyles">
6439
6513
  <xsl:param name="isAdded"/>
6440
6514
  <xsl:param name="isDeleted"/>
@@ -1228,7 +1228,9 @@
1228
1228
 
1229
1229
 
1230
1230
 
1231
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1231
+ </xsl:attribute-set><xsl:variable name="table-border_">
1232
+
1233
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1232
1234
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1233
1235
 
1234
1236
 
@@ -1569,6 +1571,8 @@
1569
1571
  <fo:block>&#xA0;</fo:block>
1570
1572
  </xsl:if> -->
1571
1573
 
1574
+
1575
+ <!-- Display table's name before table as standalone block -->
1572
1576
  <!-- $namespace = 'iso' or -->
1573
1577
 
1574
1578
 
@@ -1648,6 +1652,12 @@
1648
1652
 
1649
1653
 
1650
1654
 
1655
+
1656
+
1657
+
1658
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
1659
+
1660
+
1651
1661
  <xsl:variable name="table_width">
1652
1662
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
1653
1663
 
@@ -1672,6 +1682,7 @@
1672
1682
 
1673
1683
 
1674
1684
 
1685
+
1675
1686
  <attribute name="margin-left">0mm</attribute>
1676
1687
  <attribute name="margin-right">0mm</attribute>
1677
1688
 
@@ -2096,6 +2107,8 @@
2096
2107
  </xsl:choose>
2097
2108
  </xsl:for-each>
2098
2109
 
2110
+
2111
+
2099
2112
  <xsl:choose>
2100
2113
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2101
2114
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -2132,6 +2145,7 @@
2132
2145
 
2133
2146
 
2134
2147
 
2148
+
2135
2149
  <!-- for BSI (not PAS) display Notes before footnotes -->
2136
2150
 
2137
2151
 
@@ -2217,6 +2231,8 @@
2217
2231
 
2218
2232
 
2219
2233
 
2234
+
2235
+
2220
2236
  </xsl:if>
2221
2237
  <xsl:if test="$parent-name = 'tfoot'">
2222
2238
 
@@ -2231,6 +2247,8 @@
2231
2247
 
2232
2248
 
2233
2249
 
2250
+
2251
+
2234
2252
  <!-- <xsl:if test="$namespace = 'bipm'">
2235
2253
  <xsl:attribute name="height">8mm</xsl:attribute>
2236
2254
  </xsl:if> -->
@@ -3768,7 +3786,24 @@
3768
3786
  </fo:instream-foreign-object>
3769
3787
  </xsl:when>
3770
3788
  <xsl:otherwise>
3771
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
3789
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
3790
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
3791
+
3792
+ <xsl:variable name="img_src">
3793
+ <xsl:choose>
3794
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
3795
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
3796
+ </xsl:choose>
3797
+ </xsl:variable>
3798
+
3799
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
3800
+ <xsl:if test="number($scale) &lt; 100">
3801
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
3802
+ </xsl:if>
3803
+
3804
+ </xsl:if>
3805
+
3806
+ </fo:external-graphic>
3772
3807
  </xsl:otherwise>
3773
3808
  </xsl:choose>
3774
3809
 
@@ -3939,11 +3974,13 @@
3939
3974
  <xsl:attribute name="width">100%</xsl:attribute>
3940
3975
  <xsl:attribute name="content-height">100%</xsl:attribute>
3941
3976
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3977
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
3978
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
3942
3979
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
3943
3980
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
3944
3981
  <!-- effective height / width = 1.48, 1.4 - with title -->
3945
- <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
3946
- <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
3982
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
3983
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
3947
3984
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
3948
3985
  </xsl:if>
3949
3986
  <xsl:attribute name="scaling">uniform</xsl:attribute>
@@ -3960,6 +3997,23 @@
3960
3997
  <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
3961
3998
  <xsl:value-of select="."/>
3962
3999
  </xsl:attribute>
4000
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4001
+ <xsl:copy>
4002
+ <xsl:apply-templates select="@*" mode="svg_update"/>
4003
+ <xsl:variable name="viewbox">
4004
+ <xsl:call-template name="split">
4005
+ <xsl:with-param name="pText" select="@viewBox"/>
4006
+ <xsl:with-param name="sep" select="' '"/>
4007
+ </xsl:call-template>
4008
+ </xsl:variable>
4009
+ <xsl:attribute name="width">
4010
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4011
+ </xsl:attribute>
4012
+ <xsl:attribute name="height">
4013
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4014
+ </xsl:attribute>
4015
+ <xsl:apply-templates mode="svg_update"/>
4016
+ </xsl:copy>
3963
4017
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
3964
4018
  <xsl:variable name="svg_content" select="document(@src)"/>
3965
4019
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -5819,20 +5873,40 @@
5819
5873
  </xsl:call-template>
5820
5874
  </xsl:if>
5821
5875
  </xsl:template><xsl:template name="getLocalizedString">
5822
- <xsl:param name="key"/>
5876
+ <xsl:param name="key"/>
5877
+ <xsl:param name="formatted">false</xsl:param>
5823
5878
 
5824
5879
  <xsl:variable name="curr_lang">
5825
5880
  <xsl:call-template name="getLang"/>
5826
5881
  </xsl:variable>
5827
5882
 
5828
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5883
+ <xsl:variable name="data_value">
5884
+ <xsl:choose>
5885
+ <xsl:when test="$formatted = 'true'">
5886
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5887
+ </xsl:when>
5888
+ <xsl:otherwise>
5889
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5890
+ </xsl:otherwise>
5891
+ </xsl:choose>
5892
+ </xsl:variable>
5829
5893
 
5830
5894
  <xsl:choose>
5831
- <xsl:when test="$data_value != ''">
5832
- <xsl:value-of select="$data_value"/>
5895
+ <xsl:when test="normalize-space($data_value) != ''">
5896
+ <xsl:choose>
5897
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
5898
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
5899
+ </xsl:choose>
5833
5900
  </xsl:when>
5834
5901
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5835
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5902
+ <xsl:choose>
5903
+ <xsl:when test="$formatted = 'true'">
5904
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5905
+ </xsl:when>
5906
+ <xsl:otherwise>
5907
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5908
+ </xsl:otherwise>
5909
+ </xsl:choose>
5836
5910
  </xsl:when>
5837
5911
  <xsl:otherwise>
5838
5912
  <xsl:variable name="key_">
@@ -5843,7 +5917,7 @@
5843
5917
  <xsl:value-of select="$key_"/>
5844
5918
  </xsl:otherwise>
5845
5919
  </xsl:choose>
5846
-
5920
+
5847
5921
  </xsl:template><xsl:template name="setTrackChangesStyles">
5848
5922
  <xsl:param name="isAdded"/>
5849
5923
  <xsl:param name="isDeleted"/>