metanorma-bipm 2.4.3 → 2.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -4116,6 +4116,7 @@
4116
4116
  <xsl:variable name="zero_width_space">​</xsl:variable>
4117
4117
  <xsl:variable name="hair_space"> </xsl:variable>
4118
4118
  <xsl:variable name="en_dash">–</xsl:variable>
4119
+ <xsl:variable name="em_dash">—</xsl:variable>
4119
4120
 
4120
4121
  <xsl:template name="getTitle">
4121
4122
  <xsl:param name="name"/>
@@ -4432,6 +4433,10 @@
4432
4433
 
4433
4434
  </xsl:attribute-set> <!-- example-name-style -->
4434
4435
 
4436
+ <xsl:template name="refine_example-name-style">
4437
+
4438
+ </xsl:template>
4439
+
4435
4440
  <xsl:attribute-set name="example-p-style">
4436
4441
 
4437
4442
  </xsl:attribute-set> <!-- example-p-style -->
@@ -4446,6 +4451,10 @@
4446
4451
 
4447
4452
  </xsl:attribute-set> <!-- termexample-name-style -->
4448
4453
 
4454
+ <xsl:template name="refine_termexample-name-style">
4455
+
4456
+ </xsl:template>
4457
+
4449
4458
  <!-- ========================== -->
4450
4459
  <!-- Table styles -->
4451
4460
  <!-- ========================== -->
@@ -4662,6 +4671,10 @@
4662
4671
 
4663
4672
  </xsl:attribute-set> <!-- table-fn-style -->
4664
4673
 
4674
+ <xsl:template name="refine_table-fn-style">
4675
+
4676
+ </xsl:template>
4677
+
4665
4678
  <xsl:attribute-set name="table-fn-number-style">
4666
4679
  <xsl:attribute name="font-size">80%</xsl:attribute>
4667
4680
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
@@ -4671,6 +4684,10 @@
4671
4684
 
4672
4685
  </xsl:attribute-set> <!-- table-fn-number-style -->
4673
4686
 
4687
+ <xsl:template name="refine_table-fn-number-style">
4688
+
4689
+ </xsl:template>
4690
+
4674
4691
  <xsl:attribute-set name="fn-container-body-style">
4675
4692
  <xsl:attribute name="text-indent">0</xsl:attribute>
4676
4693
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -7086,8 +7103,9 @@
7086
7103
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
7087
7104
 
7088
7105
  <fo:block xsl:use-attribute-sets="table-fn-style">
7089
-
7106
+ <xsl:call-template name="refine_table-fn-style"/>
7090
7107
  <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
7108
+ <xsl:call-template name="refine_table-fn-number-style"/>
7091
7109
 
7092
7110
  <fo:inline font-style="normal">(</fo:inline>
7093
7111
 
@@ -8232,12 +8250,18 @@
8232
8250
  </xsl:template>
8233
8251
 
8234
8252
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
8235
- <xsl:variable name="text" select="normalize-space(.)"/>
8236
- <fo:inline font-size="75%" role="SKIP">
8253
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
8254
+ <xsl:variable name="text" select="."/>
8255
+ <xsl:variable name="ratio_">
8256
+ 0.75
8257
+ </xsl:variable>
8258
+ <xsl:variable name="ratio" select="number(normalize-space($ratio_))"/>
8259
+ <fo:inline font-size="{$ratio * 100}%" role="SKIP">
8237
8260
  <xsl:if test="string-length($text) &gt; 0">
8238
8261
  <xsl:variable name="smallCapsText">
8239
8262
  <xsl:call-template name="recursiveSmallCaps">
8240
8263
  <xsl:with-param name="text" select="$text"/>
8264
+ <xsl:with-param name="ratio" select="$ratio"/>
8241
8265
  </xsl:call-template>
8242
8266
  </xsl:variable>
8243
8267
  <!-- merge neighboring fo:inline -->
@@ -8274,12 +8298,13 @@
8274
8298
 
8275
8299
  <xsl:template name="recursiveSmallCaps">
8276
8300
  <xsl:param name="text"/>
8301
+ <xsl:param name="ratio"/>
8277
8302
  <xsl:variable name="char" select="substring($text,1,1)"/>
8278
8303
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
8279
8304
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
8280
8305
  <xsl:choose>
8281
8306
  <xsl:when test="$char=$upperCase">
8282
- <fo:inline font-size="{100 div 0.75}%" role="SKIP">
8307
+ <fo:inline font-size="{100 div $ratio}%" role="SKIP">
8283
8308
  <xsl:value-of select="$upperCase"/>
8284
8309
  </fo:inline>
8285
8310
  </xsl:when>
@@ -8290,6 +8315,7 @@
8290
8315
  <xsl:if test="string-length($text) &gt; 1">
8291
8316
  <xsl:call-template name="recursiveSmallCaps">
8292
8317
  <xsl:with-param name="text" select="substring($text,2)"/>
8318
+ <xsl:with-param name="ratio" select="$ratio"/>
8293
8319
  </xsl:call-template>
8294
8320
  </xsl:if>
8295
8321
  </xsl:template>
@@ -8326,6 +8352,9 @@
8326
8352
  <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color'">
8327
8353
  <style name="{$key}"><xsl:value-of select="$value"/></style>
8328
8354
  </xsl:if>
8355
+ <xsl:if test="$key = 'text-indent'">
8356
+ <style name="padding-left"><xsl:value-of select="$value"/></style>
8357
+ </xsl:if>
8329
8358
  </xsl:for-each>
8330
8359
  </xsl:variable>
8331
8360
  <xsl:variable name="styles" select="xalan:nodeset($styles_)"/>
@@ -9760,6 +9789,11 @@
9760
9789
  </xsl:call-template>
9761
9790
  </xsl:template>
9762
9791
 
9792
+ <!-- command between two xref points to non-standard bibitem -->
9793
+ <xsl:template match="text()[. = ','][preceding-sibling::node()[1][local-name() = 'sup'][*[local-name() = 'xref'][@type = 'footnote']] and following-sibling::node()[1][local-name() = 'sup'][*[local-name() = 'xref'][@type = 'footnote']]]">
9794
+ <xsl:value-of select="."/>
9795
+ </xsl:template>
9796
+
9763
9797
  <!-- ====== -->
9764
9798
  <!-- formula -->
9765
9799
  <!-- ====== -->
@@ -10420,16 +10454,44 @@
10420
10454
  </xsl:choose>
10421
10455
 
10422
10456
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
10423
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
10424
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
10457
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
10458
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
10459
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
10460
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
10461
+
10462
+ <!-- Example: -->
10425
10463
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
10426
10464
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
10427
10465
  <!-- effective height / width = 1.48, 1.4 - with title -->
10428
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
10466
+
10467
+ <xsl:variable name="scale_x">
10468
+ <xsl:choose>
10469
+ <xsl:when test="$svg_width &gt; $width_effective_px">
10470
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
10471
+ </xsl:when>
10472
+ <xsl:otherwise>1</xsl:otherwise>
10473
+ </xsl:choose>
10474
+ </xsl:variable>
10475
+ <xsl:variable name="scale_y">
10476
+ <xsl:choose>
10477
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
10478
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
10479
+ </xsl:when>
10480
+ <xsl:otherwise>1</xsl:otherwise>
10481
+ </xsl:choose>
10482
+ </xsl:variable>
10483
+
10484
+ <!-- for images with big height -->
10485
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
10429
10486
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
10430
10487
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
10431
- </xsl:if>
10488
+ </xsl:if> -->
10432
10489
  <xsl:attribute name="scaling">uniform</xsl:attribute>
10490
+
10491
+ <xsl:if test="$scale_y != 1">
10492
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
10493
+ </xsl:if>
10494
+
10433
10495
  <xsl:copy-of select="$svg_content"/>
10434
10496
  </fo:instream-foreign-object>
10435
10497
  <!-- </fo:block> -->
@@ -10454,6 +10516,8 @@
10454
10516
  </xsl:attribute>
10455
10517
  </xsl:template>
10456
10518
 
10519
+ <xsl:variable name="regex_starts_with_digit">^[0-9].*</xsl:variable>
10520
+
10457
10521
  <xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
10458
10522
  <xsl:copy>
10459
10523
  <xsl:apply-templates select="@*" mode="svg_update"/>
@@ -10467,8 +10531,13 @@
10467
10531
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
10468
10532
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
10469
10533
 
10534
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
10535
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
10536
+
10470
10537
  <xsl:attribute name="width">
10471
10538
  <xsl:choose>
10539
+ <!-- width is non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
10540
+ <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10472
10541
  <xsl:when test="$width != ''">
10473
10542
  <xsl:value-of select="round($width)"/>
10474
10543
  </xsl:when>
@@ -10477,6 +10546,8 @@
10477
10546
  </xsl:attribute>
10478
10547
  <xsl:attribute name="height">
10479
10548
  <xsl:choose>
10549
+ <!-- height non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
10550
+ <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10480
10551
  <xsl:when test="$height != ''">
10481
10552
  <xsl:value-of select="round($height)"/>
10482
10553
  </xsl:when>
@@ -10488,6 +10559,28 @@
10488
10559
  </xsl:copy>
10489
10560
  </xsl:template>
10490
10561
 
10562
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
10563
+ <!-- image[@width]/svg -->
10564
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
10565
+ <xsl:attribute name="width">
10566
+ <xsl:choose>
10567
+ <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10568
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10569
+ </xsl:choose>
10570
+ </xsl:attribute>
10571
+ </xsl:template>
10572
+
10573
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
10574
+ <!-- image[@height]/svg -->
10575
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
10576
+ <xsl:attribute name="height">
10577
+ <xsl:choose>
10578
+ <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10579
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10580
+ </xsl:choose>
10581
+ </xsl:attribute>
10582
+ </xsl:template>
10583
+
10491
10584
  <!-- regex for 'display: inline-block;' -->
10492
10585
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
10493
10586
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -11957,6 +12050,7 @@
11957
12050
  <xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']">
11958
12051
  <xsl:if test="normalize-space() != ''">
11959
12052
  <fo:inline xsl:use-attribute-sets="termexample-name-style">
12053
+ <xsl:call-template name="refine_termexample-name-style"/>
11960
12054
  <xsl:apply-templates/>
11961
12055
  </fo:inline>
11962
12056
  </xsl:if>
@@ -12107,6 +12201,7 @@
12107
12201
  </xsl:when>
12108
12202
  <xsl:otherwise>
12109
12203
  <fo:inline xsl:use-attribute-sets="example-name-style">
12204
+ <xsl:call-template name="refine_example-name-style"/>
12110
12205
  <xsl:apply-templates/>
12111
12206
  </fo:inline>
12112
12207
  </xsl:otherwise>
@@ -12572,7 +12667,9 @@
12572
12667
  </xsl:template> <!-- sections_element_style -->
12573
12668
 
12574
12669
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
12575
- <fo:block break-after="page"/>
12670
+
12671
+ <fo:block break-after="page"/>
12672
+
12576
12673
  <fo:block>
12577
12674
  <xsl:call-template name="setId"/>
12578
12675
  <xsl:apply-templates/>
@@ -12641,7 +12738,7 @@
12641
12738
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
12642
12739
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
12643
12740
  </xsl:when>
12644
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
12741
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
12645
12742
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
12646
12743
  </xsl:when>
12647
12744
  </xsl:choose>
@@ -13317,6 +13414,7 @@
13317
13414
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
13318
13415
 
13319
13416
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
13417
+
13320
13418
  <xsl:call-template name="processBibitem"/>
13321
13419
  </fo:block>
13322
13420
 
@@ -13356,6 +13454,7 @@
13356
13454
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
13357
13455
  <xsl:otherwise>
13358
13456
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
13457
+
13359
13458
  <fo:list-item-label end-indent="label-end()">
13360
13459
  <fo:block role="SKIP">
13361
13460
  <fo:inline role="SKIP">
@@ -15121,4 +15220,6 @@
15121
15220
  </xsl:if>
15122
15221
  </xsl:template>
15123
15222
 
15223
+ <!-- update -->
15224
+
15124
15225
  </xsl:stylesheet>
@@ -4116,6 +4116,7 @@
4116
4116
  <xsl:variable name="zero_width_space">​</xsl:variable>
4117
4117
  <xsl:variable name="hair_space"> </xsl:variable>
4118
4118
  <xsl:variable name="en_dash">–</xsl:variable>
4119
+ <xsl:variable name="em_dash">—</xsl:variable>
4119
4120
 
4120
4121
  <xsl:template name="getTitle">
4121
4122
  <xsl:param name="name"/>
@@ -4432,6 +4433,10 @@
4432
4433
 
4433
4434
  </xsl:attribute-set> <!-- example-name-style -->
4434
4435
 
4436
+ <xsl:template name="refine_example-name-style">
4437
+
4438
+ </xsl:template>
4439
+
4435
4440
  <xsl:attribute-set name="example-p-style">
4436
4441
 
4437
4442
  </xsl:attribute-set> <!-- example-p-style -->
@@ -4446,6 +4451,10 @@
4446
4451
 
4447
4452
  </xsl:attribute-set> <!-- termexample-name-style -->
4448
4453
 
4454
+ <xsl:template name="refine_termexample-name-style">
4455
+
4456
+ </xsl:template>
4457
+
4449
4458
  <!-- ========================== -->
4450
4459
  <!-- Table styles -->
4451
4460
  <!-- ========================== -->
@@ -4662,6 +4671,10 @@
4662
4671
 
4663
4672
  </xsl:attribute-set> <!-- table-fn-style -->
4664
4673
 
4674
+ <xsl:template name="refine_table-fn-style">
4675
+
4676
+ </xsl:template>
4677
+
4665
4678
  <xsl:attribute-set name="table-fn-number-style">
4666
4679
  <xsl:attribute name="font-size">80%</xsl:attribute>
4667
4680
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
@@ -4671,6 +4684,10 @@
4671
4684
 
4672
4685
  </xsl:attribute-set> <!-- table-fn-number-style -->
4673
4686
 
4687
+ <xsl:template name="refine_table-fn-number-style">
4688
+
4689
+ </xsl:template>
4690
+
4674
4691
  <xsl:attribute-set name="fn-container-body-style">
4675
4692
  <xsl:attribute name="text-indent">0</xsl:attribute>
4676
4693
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -7086,8 +7103,9 @@
7086
7103
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
7087
7104
 
7088
7105
  <fo:block xsl:use-attribute-sets="table-fn-style">
7089
-
7106
+ <xsl:call-template name="refine_table-fn-style"/>
7090
7107
  <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
7108
+ <xsl:call-template name="refine_table-fn-number-style"/>
7091
7109
 
7092
7110
  <fo:inline font-style="normal">(</fo:inline>
7093
7111
 
@@ -8232,12 +8250,18 @@
8232
8250
  </xsl:template>
8233
8251
 
8234
8252
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
8235
- <xsl:variable name="text" select="normalize-space(.)"/>
8236
- <fo:inline font-size="75%" role="SKIP">
8253
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
8254
+ <xsl:variable name="text" select="."/>
8255
+ <xsl:variable name="ratio_">
8256
+ 0.75
8257
+ </xsl:variable>
8258
+ <xsl:variable name="ratio" select="number(normalize-space($ratio_))"/>
8259
+ <fo:inline font-size="{$ratio * 100}%" role="SKIP">
8237
8260
  <xsl:if test="string-length($text) &gt; 0">
8238
8261
  <xsl:variable name="smallCapsText">
8239
8262
  <xsl:call-template name="recursiveSmallCaps">
8240
8263
  <xsl:with-param name="text" select="$text"/>
8264
+ <xsl:with-param name="ratio" select="$ratio"/>
8241
8265
  </xsl:call-template>
8242
8266
  </xsl:variable>
8243
8267
  <!-- merge neighboring fo:inline -->
@@ -8274,12 +8298,13 @@
8274
8298
 
8275
8299
  <xsl:template name="recursiveSmallCaps">
8276
8300
  <xsl:param name="text"/>
8301
+ <xsl:param name="ratio"/>
8277
8302
  <xsl:variable name="char" select="substring($text,1,1)"/>
8278
8303
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
8279
8304
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
8280
8305
  <xsl:choose>
8281
8306
  <xsl:when test="$char=$upperCase">
8282
- <fo:inline font-size="{100 div 0.75}%" role="SKIP">
8307
+ <fo:inline font-size="{100 div $ratio}%" role="SKIP">
8283
8308
  <xsl:value-of select="$upperCase"/>
8284
8309
  </fo:inline>
8285
8310
  </xsl:when>
@@ -8290,6 +8315,7 @@
8290
8315
  <xsl:if test="string-length($text) &gt; 1">
8291
8316
  <xsl:call-template name="recursiveSmallCaps">
8292
8317
  <xsl:with-param name="text" select="substring($text,2)"/>
8318
+ <xsl:with-param name="ratio" select="$ratio"/>
8293
8319
  </xsl:call-template>
8294
8320
  </xsl:if>
8295
8321
  </xsl:template>
@@ -8326,6 +8352,9 @@
8326
8352
  <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color'">
8327
8353
  <style name="{$key}"><xsl:value-of select="$value"/></style>
8328
8354
  </xsl:if>
8355
+ <xsl:if test="$key = 'text-indent'">
8356
+ <style name="padding-left"><xsl:value-of select="$value"/></style>
8357
+ </xsl:if>
8329
8358
  </xsl:for-each>
8330
8359
  </xsl:variable>
8331
8360
  <xsl:variable name="styles" select="xalan:nodeset($styles_)"/>
@@ -9760,6 +9789,11 @@
9760
9789
  </xsl:call-template>
9761
9790
  </xsl:template>
9762
9791
 
9792
+ <!-- command between two xref points to non-standard bibitem -->
9793
+ <xsl:template match="text()[. = ','][preceding-sibling::node()[1][local-name() = 'sup'][*[local-name() = 'xref'][@type = 'footnote']] and following-sibling::node()[1][local-name() = 'sup'][*[local-name() = 'xref'][@type = 'footnote']]]">
9794
+ <xsl:value-of select="."/>
9795
+ </xsl:template>
9796
+
9763
9797
  <!-- ====== -->
9764
9798
  <!-- formula -->
9765
9799
  <!-- ====== -->
@@ -10420,16 +10454,44 @@
10420
10454
  </xsl:choose>
10421
10455
 
10422
10456
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
10423
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
10424
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
10457
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
10458
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
10459
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
10460
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
10461
+
10462
+ <!-- Example: -->
10425
10463
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
10426
10464
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
10427
10465
  <!-- effective height / width = 1.48, 1.4 - with title -->
10428
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
10466
+
10467
+ <xsl:variable name="scale_x">
10468
+ <xsl:choose>
10469
+ <xsl:when test="$svg_width &gt; $width_effective_px">
10470
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
10471
+ </xsl:when>
10472
+ <xsl:otherwise>1</xsl:otherwise>
10473
+ </xsl:choose>
10474
+ </xsl:variable>
10475
+ <xsl:variable name="scale_y">
10476
+ <xsl:choose>
10477
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
10478
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
10479
+ </xsl:when>
10480
+ <xsl:otherwise>1</xsl:otherwise>
10481
+ </xsl:choose>
10482
+ </xsl:variable>
10483
+
10484
+ <!-- for images with big height -->
10485
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
10429
10486
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
10430
10487
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
10431
- </xsl:if>
10488
+ </xsl:if> -->
10432
10489
  <xsl:attribute name="scaling">uniform</xsl:attribute>
10490
+
10491
+ <xsl:if test="$scale_y != 1">
10492
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
10493
+ </xsl:if>
10494
+
10433
10495
  <xsl:copy-of select="$svg_content"/>
10434
10496
  </fo:instream-foreign-object>
10435
10497
  <!-- </fo:block> -->
@@ -10454,6 +10516,8 @@
10454
10516
  </xsl:attribute>
10455
10517
  </xsl:template>
10456
10518
 
10519
+ <xsl:variable name="regex_starts_with_digit">^[0-9].*</xsl:variable>
10520
+
10457
10521
  <xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
10458
10522
  <xsl:copy>
10459
10523
  <xsl:apply-templates select="@*" mode="svg_update"/>
@@ -10467,8 +10531,13 @@
10467
10531
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
10468
10532
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
10469
10533
 
10534
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
10535
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
10536
+
10470
10537
  <xsl:attribute name="width">
10471
10538
  <xsl:choose>
10539
+ <!-- width is non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
10540
+ <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10472
10541
  <xsl:when test="$width != ''">
10473
10542
  <xsl:value-of select="round($width)"/>
10474
10543
  </xsl:when>
@@ -10477,6 +10546,8 @@
10477
10546
  </xsl:attribute>
10478
10547
  <xsl:attribute name="height">
10479
10548
  <xsl:choose>
10549
+ <!-- height non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
10550
+ <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10480
10551
  <xsl:when test="$height != ''">
10481
10552
  <xsl:value-of select="round($height)"/>
10482
10553
  </xsl:when>
@@ -10488,6 +10559,28 @@
10488
10559
  </xsl:copy>
10489
10560
  </xsl:template>
10490
10561
 
10562
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
10563
+ <!-- image[@width]/svg -->
10564
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
10565
+ <xsl:attribute name="width">
10566
+ <xsl:choose>
10567
+ <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10568
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10569
+ </xsl:choose>
10570
+ </xsl:attribute>
10571
+ </xsl:template>
10572
+
10573
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
10574
+ <!-- image[@height]/svg -->
10575
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
10576
+ <xsl:attribute name="height">
10577
+ <xsl:choose>
10578
+ <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10579
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10580
+ </xsl:choose>
10581
+ </xsl:attribute>
10582
+ </xsl:template>
10583
+
10491
10584
  <!-- regex for 'display: inline-block;' -->
10492
10585
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
10493
10586
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -11957,6 +12050,7 @@
11957
12050
  <xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']">
11958
12051
  <xsl:if test="normalize-space() != ''">
11959
12052
  <fo:inline xsl:use-attribute-sets="termexample-name-style">
12053
+ <xsl:call-template name="refine_termexample-name-style"/>
11960
12054
  <xsl:apply-templates/>
11961
12055
  </fo:inline>
11962
12056
  </xsl:if>
@@ -12107,6 +12201,7 @@
12107
12201
  </xsl:when>
12108
12202
  <xsl:otherwise>
12109
12203
  <fo:inline xsl:use-attribute-sets="example-name-style">
12204
+ <xsl:call-template name="refine_example-name-style"/>
12110
12205
  <xsl:apply-templates/>
12111
12206
  </fo:inline>
12112
12207
  </xsl:otherwise>
@@ -12572,7 +12667,9 @@
12572
12667
  </xsl:template> <!-- sections_element_style -->
12573
12668
 
12574
12669
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
12575
- <fo:block break-after="page"/>
12670
+
12671
+ <fo:block break-after="page"/>
12672
+
12576
12673
  <fo:block>
12577
12674
  <xsl:call-template name="setId"/>
12578
12675
  <xsl:apply-templates/>
@@ -12641,7 +12738,7 @@
12641
12738
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
12642
12739
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
12643
12740
  </xsl:when>
12644
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
12741
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
12645
12742
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
12646
12743
  </xsl:when>
12647
12744
  </xsl:choose>
@@ -13317,6 +13414,7 @@
13317
13414
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
13318
13415
 
13319
13416
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
13417
+
13320
13418
  <xsl:call-template name="processBibitem"/>
13321
13419
  </fo:block>
13322
13420
 
@@ -13356,6 +13454,7 @@
13356
13454
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
13357
13455
  <xsl:otherwise>
13358
13456
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
13457
+
13359
13458
  <fo:list-item-label end-indent="label-end()">
13360
13459
  <fo:block role="SKIP">
13361
13460
  <fo:inline role="SKIP">
@@ -15121,4 +15220,6 @@
15121
15220
  </xsl:if>
15122
15221
  </xsl:template>
15123
15222
 
15223
+ <!-- update -->
15224
+
15124
15225
  </xsl:stylesheet>