metanorma-ogc 1.3.7 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -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"/>
@@ -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"/>