metanorma-bipm 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,6 @@
5
5
  <xsl:param name="initial_page_number"/>
6
6
  <xsl:param name="doc_split_by_language"/>
7
7
 
8
- <xsl:param name="add_math_as_text">true</xsl:param>
9
-
10
8
  <xsl:param name="add_math_as_attachment">true</xsl:param>
11
9
 
12
10
  <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
@@ -220,7 +218,13 @@
220
218
 
221
219
 
222
220
  <xsl:template match="/">
223
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
221
+ <fo:root xml:lang="{$lang}">
222
+ <xsl:variable name="root-style">
223
+ <root-style xsl:use-attribute-sets="root-style"/>
224
+ </xsl:variable>
225
+ <xsl:call-template name="insertRootStyle">
226
+ <xsl:with-param name="root-style" select="$root-style"/>
227
+ </xsl:call-template>
224
228
  <fo:layout-master-set>
225
229
 
226
230
  <!-- blank page -->
@@ -979,7 +983,7 @@
979
983
  <fo:block-container font-size="9pt" border-bottom="1pt solid black" width="68mm" text-align="center" margin-bottom="14pt">
980
984
  <fo:block font-weight="bold" margin-bottom="2.5mm">
981
985
  <fo:inline padding-right="10mm">
982
- <xsl:apply-templates select="bipm:bibdata/bipm:edition">
986
+ <xsl:apply-templates select="bipm:bibdata/bipm:edition[normalize-space(@language) = '']">
983
987
  <xsl:with-param name="font-size" select="'70%'"/>
984
988
  <xsl:with-param name="baseline-shift" select="'45%'"/>
985
989
  <xsl:with-param name="curr_lang" select="$curr_lang"/>
@@ -1259,7 +1263,7 @@
1259
1263
  <fo:block-container font-size="9pt" border-bottom="1pt solid black" width="68mm" text-align="center" margin-bottom="14pt">
1260
1264
  <fo:block font-weight="bold" margin-bottom="2.5mm">
1261
1265
  <fo:inline padding-right="10mm">
1262
- <xsl:apply-templates select="bipm:bibdata/bipm:edition">
1266
+ <xsl:apply-templates select="bipm:bibdata/bipm:edition[normalize-space(@language) = '']">
1263
1267
  <xsl:with-param name="font-size" select="'70%'"/>
1264
1268
  <xsl:with-param name="baseline-shift" select="'45%'"/>
1265
1269
  <xsl:with-param name="curr_lang" select="$curr_lang"/>
@@ -1347,7 +1351,7 @@
1347
1351
  <xsl:call-template name="getLanguages"/>
1348
1352
  </xsl:variable>
1349
1353
  <xsl:variable name="editionFO">
1350
- <xsl:apply-templates select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:edition">
1354
+ <xsl:apply-templates select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:edition[normalize-space(@language) = '']">
1351
1355
  <xsl:with-param name="curr_lang" select="xalan:nodeset($languages)/lang[1]"/>
1352
1356
  </xsl:apply-templates>
1353
1357
  </xsl:variable>
@@ -1426,7 +1430,7 @@
1426
1430
 
1427
1431
  <xsl:variable name="edition_str">édition</xsl:variable>
1428
1432
 
1429
- <fo:block font-size="14pt" font-weight="{$weight-bold}" margin-top="4mm"><xsl:value-of select="concat((//bipm:bipm-standard)[1]/bipm:bibdata/bipm:edition, ' ', $edition_str, ' ', $copyrightYear)"/></fo:block>
1433
+ <fo:block font-size="14pt" font-weight="{$weight-bold}" margin-top="4mm"><xsl:value-of select="concat((//bipm:bipm-standard)[1]/bipm:bibdata/bipm:edition[normalize-space(@language) = ''], ' ', $edition_str, ' ', $copyrightYear)"/></fo:block>
1430
1434
  </fo:block-container>
1431
1435
 
1432
1436
  <fo:block-container absolute-position="fixed" left="12.5mm" top="92mm" height="170mm" width="144mm" display-align="center">
@@ -2103,12 +2107,6 @@
2103
2107
  <xsl:param name="baseline-shift" select="'30%'"/>
2104
2108
  <xsl:param name="curr_lang" select="'fr'"/>
2105
2109
  <fo:inline>
2106
- <xsl:variable name="title-edition">
2107
- <xsl:call-template name="getTitle">
2108
- <xsl:with-param name="name" select="'title-edition'"/>
2109
- <xsl:with-param name="lang" select="$curr_lang"/>
2110
- </xsl:call-template>
2111
- </xsl:variable>
2112
2110
  <xsl:value-of select="."/>
2113
2111
  <fo:inline font-size="{$font-size}" baseline-shift="{$baseline-shift}">
2114
2112
  <xsl:call-template name="number-to-ordinal">
@@ -2117,7 +2115,9 @@
2117
2115
  </xsl:call-template>
2118
2116
  </fo:inline>
2119
2117
  <xsl:text> </xsl:text>
2120
- <xsl:value-of select="java:toLowerCase(java:java.lang.String.new($title-edition))"/>
2118
+ <xsl:call-template name="getLocalizedString">
2119
+ <xsl:with-param name="key">edition</xsl:with-param>
2120
+ </xsl:call-template>
2121
2121
  <xsl:text/>
2122
2122
  </fo:inline>
2123
2123
  </xsl:template>
@@ -3201,112 +3201,6 @@
3201
3201
  <xsl:value-of select="translate(., ' ', ' ')"/>
3202
3202
  </xsl:template>
3203
3203
 
3204
- <xsl:template match="mathml:math" priority="2">
3205
- <xsl:variable name="isAdded" select="@added"/>
3206
- <xsl:variable name="isDeleted" select="@deleted"/>
3207
-
3208
- <fo:inline xsl:use-attribute-sets="mathml-style">
3209
-
3210
- <xsl:if test="ancestor::*[local-name()='table']">
3211
- <xsl:attribute name="font-size">95%</xsl:attribute> <!-- base font in table is 10pt -->
3212
- </xsl:if>
3213
-
3214
- <xsl:call-template name="setTrackChangesStyles">
3215
- <xsl:with-param name="isAdded" select="$isAdded"/>
3216
- <xsl:with-param name="isDeleted" select="$isDeleted"/>
3217
- </xsl:call-template>
3218
-
3219
- <xsl:if test="$add_math_as_text = 'true'">
3220
- <!-- set unique font-size (fiction) -->
3221
- <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
3222
- <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal"><xsl:value-of select="$zero_width_space"/></fo:inline> <!-- zero width space -->
3223
- </xsl:if>
3224
-
3225
- <!-- <fo:wrapper role="artifact"> -->
3226
-
3227
- <xsl:variable name="mathml_content">
3228
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
3229
- </xsl:variable>
3230
- <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
3231
-
3232
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3233
- <xsl:variable name="comment_text_">
3234
- <xsl:choose>
3235
- <xsl:when test="normalize-space($comment_text_following) != ''">
3236
- <xsl:value-of select="$comment_text_following"/>
3237
- </xsl:when>
3238
- <xsl:otherwise>
3239
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3240
- </xsl:otherwise>
3241
- </xsl:choose>
3242
- </xsl:variable>
3243
- <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3244
- <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
3245
-
3246
- <xsl:variable name="filename" select="xalan:nodeset($mathml_attachments)//attachment[. = $mathml_content]/@filename"/>
3247
- <xsl:choose>
3248
- <xsl:when test="$add_math_as_attachment = 'true' and normalize-space($filename) != ''">
3249
- <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
3250
- <fo:basic-link external-destination="{$url}" fox:alt-text="MathLink">
3251
- <xsl:if test="normalize-space($comment_text) != ''">
3252
- <!-- put Mathin Alternate Text -->
3253
- <xsl:attribute name="fox:alt-text">
3254
- <xsl:value-of select="$comment_text"/>
3255
- </xsl:attribute>
3256
- </xsl:if>
3257
- <xsl:call-template name="mathml_instream_object">
3258
- <xsl:with-param name="mathml_content" select="$mathml_content"/>
3259
- <xsl:with-param name="comment_text" select="$comment_text"/>
3260
- </xsl:call-template>
3261
- </fo:basic-link>
3262
- <!-- </xsl:if> -->
3263
- </xsl:when>
3264
- <xsl:otherwise>
3265
- <xsl:call-template name="mathml_instream_object">
3266
- <xsl:with-param name="mathml_content" select="$mathml_content"/>
3267
- <xsl:with-param name="comment_text" select="$comment_text"/>
3268
- </xsl:call-template>
3269
- </xsl:otherwise>
3270
- </xsl:choose>
3271
- <!-- </fo:wrapper> -->
3272
- </fo:inline>
3273
- </xsl:template>
3274
-
3275
- <xsl:template name="mathml_instream_object">
3276
- <xsl:param name="mathml_content"/>
3277
- <xsl:param name="comment_text"/>
3278
-
3279
- <xsl:variable name="mathml">
3280
- <xsl:apply-templates select="." mode="mathml"/>
3281
- </xsl:variable>
3282
-
3283
- <fo:instream-foreign-object fox:alt-text="Math">
3284
-
3285
- <xsl:if test="local-name(../..) = 'formula'">
3286
- <xsl:attribute name="width">95%</xsl:attribute>
3287
- <xsl:attribute name="content-height">100%</xsl:attribute>
3288
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3289
- <xsl:attribute name="scaling">uniform</xsl:attribute>
3290
- </xsl:if>
3291
-
3292
- <!-- put MathML in Actual Text -->
3293
- <xsl:attribute name="fox:actual-text">
3294
- <xsl:value-of select="$mathml_content"/>
3295
- </xsl:attribute>
3296
-
3297
- <xsl:if test="$add_math_as_text = 'true'">
3298
- <xsl:if test="normalize-space($comment_text) != ''">
3299
- <!-- put Mathin Alternate Text -->
3300
- <xsl:attribute name="fox:alt-text">
3301
- <xsl:value-of select="$comment_text"/>
3302
- </xsl:attribute>
3303
- </xsl:if>
3304
- </xsl:if>
3305
-
3306
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
3307
- </fo:instream-foreign-object>
3308
- </xsl:template>
3309
-
3310
3204
 
3311
3205
  <!-- =================== -->
3312
3206
  <!-- Table of Contents (ToC) processing -->
@@ -3916,7 +3810,7 @@
3916
3810
  </xsl:template>
3917
3811
 
3918
3812
 
3919
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
3813
+ <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:param name="add_math_as_text">true</xsl:param><xsl:variable name="lang">
3920
3814
  <xsl:call-template name="getLang"/>
3921
3815
  </xsl:variable><xsl:variable name="pageWidth_">
3922
3816
  210
@@ -3931,20 +3825,7 @@
3931
3825
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
3932
3826
  22
3933
3827
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
3934
-
3935
- <title-edition lang="en">
3936
-
3937
- <xsl:text>Edition </xsl:text>
3938
-
3939
- </title-edition>
3940
-
3941
- <title-edition lang="fr">
3942
- <xsl:text>Édition </xsl:text>
3943
- </title-edition>
3944
3828
 
3945
- <title-edition lang="ru">
3946
- <xsl:text>Издание </xsl:text>
3947
- </title-edition>
3948
3829
 
3949
3830
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
3950
3831
  <title-toc lang="en">
@@ -4027,7 +3908,7 @@
4027
3908
  </xsl:variable><xsl:variable name="bibdata">
4028
3909
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
4029
3910
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
4030
- </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
3911
+ </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="hair_space"> </xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
4031
3912
  <xsl:param name="name"/>
4032
3913
  <xsl:param name="lang"/>
4033
3914
  <xsl:variable name="lang_">
@@ -4070,7 +3951,30 @@
4070
3951
 
4071
3952
 
4072
3953
 
4073
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
3954
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
3955
+ <xsl:param name="root-style"/>
3956
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
3957
+
3958
+ <xsl:variable name="additional_fonts_">
3959
+ <xsl:for-each select="//*[contains(local-name(), '-standard')][1]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value'] | //*[contains(local-name(), '-standard')][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
3960
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
3961
+ </xsl:for-each>
3962
+ </xsl:variable>
3963
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
3964
+
3965
+ <xsl:for-each select="$root-style_/root-style/@*">
3966
+ <xsl:choose>
3967
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
3968
+ <xsl:attribute name="{local-name()}">
3969
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
3970
+ </xsl:attribute>
3971
+ </xsl:when>
3972
+ <xsl:otherwise>
3973
+ <xsl:copy-of select="."/>
3974
+ </xsl:otherwise>
3975
+ </xsl:choose>
3976
+ </xsl:for-each>
3977
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
4074
3978
 
4075
3979
  </xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
4076
3980
 
@@ -4139,7 +4043,6 @@
4139
4043
 
4140
4044
 
4141
4045
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
4142
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
4143
4046
 
4144
4047
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
4145
4048
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -4218,6 +4121,7 @@
4218
4121
 
4219
4122
 
4220
4123
 
4124
+
4221
4125
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
4222
4126
 
4223
4127
 
@@ -4589,7 +4493,7 @@
4589
4493
 
4590
4494
 
4591
4495
 
4592
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
4496
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
4593
4497
 
4594
4498
 
4595
4499
 
@@ -5302,10 +5206,41 @@
5302
5206
  <xsl:sort select="@displayorder" data-type="number"/>
5303
5207
  <xsl:apply-templates select="."/>
5304
5208
  </xsl:for-each>
5305
- </xsl:template><xsl:template match="text()">
5306
- <xsl:value-of select="."/>
5209
+ </xsl:template><xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable><xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable><xsl:template match="text()" name="text">
5210
+
5211
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5212
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_fo_inline_keep-together_within-line_open,'$1',$tag_fo_inline_keep-together_within-line_close))"/>
5213
+ <xsl:call-template name="replace_fo_inline_tags">
5214
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
5215
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
5216
+ <xsl:with-param name="text" select="$text"/>
5217
+ </xsl:call-template>
5218
+
5219
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
5220
+ <xsl:param name="tag_open"/>
5221
+ <xsl:param name="tag_close"/>
5222
+ <xsl:param name="text"/>
5223
+ <xsl:choose>
5224
+ <xsl:when test="contains($text, $tag_open)">
5225
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
5226
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
5227
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5228
+ <fo:inline keep-together.within-line="always">
5229
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5230
+ </fo:inline>
5231
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
5232
+ <xsl:call-template name="replace_fo_inline_tags">
5233
+ <xsl:with-param name="tag_open" select="$tag_open"/>
5234
+ <xsl:with-param name="tag_close" select="$tag_close"/>
5235
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
5236
+ </xsl:call-template>
5237
+ </xsl:when>
5238
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
5239
+ </xsl:choose>
5307
5240
  </xsl:template><xsl:template match="*[local-name()='br']">
5308
5241
  <xsl:value-of select="$linebreak"/>
5242
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
5243
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
5309
5244
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
5310
5245
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
5311
5246
  <xsl:apply-templates/>
@@ -5381,8 +5316,23 @@
5381
5316
  </xsl:call-template>
5382
5317
 
5383
5318
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
5384
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
5385
- <xsl:call-template name="add-zero-spaces-java"/>
5319
+ <xsl:choose>
5320
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
5321
+ <xsl:value-of select="."/>
5322
+ </xsl:when>
5323
+ <xsl:otherwise>
5324
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
5325
+ </xsl:otherwise>
5326
+ </xsl:choose>
5327
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
5328
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
5329
+ <!-- <xsl:copy-of select="$text"/> -->
5330
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
5331
+ <xsl:choose>
5332
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
5333
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
5334
+ </xsl:choose>
5335
+ </xsl:for-each>
5386
5336
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
5387
5337
 
5388
5338
  <xsl:variable name="table-preamble">
@@ -5518,16 +5468,9 @@
5518
5468
  </xsl:for-each>
5519
5469
  </xsl:when>
5520
5470
  <xsl:otherwise>
5521
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
5522
- <xsl:choose>
5523
- <xsl:when test=". = 1 or . = 0">
5524
- <fo:table-column column-width="proportional-column-width(2)"/>
5525
- </xsl:when>
5526
- <xsl:otherwise>
5527
- <fo:table-column column-width="proportional-column-width({.})"/>
5528
- </xsl:otherwise>
5529
- </xsl:choose>
5530
- </xsl:for-each>
5471
+ <xsl:call-template name="insertTableColumnWidth">
5472
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5473
+ </xsl:call-template>
5531
5474
  </xsl:otherwise>
5532
5475
  </xsl:choose>
5533
5476
 
@@ -5695,6 +5638,7 @@
5695
5638
  <xsl:with-param name="text" select="$td_text"/>
5696
5639
  </xsl:call-template>
5697
5640
  </xsl:variable>
5641
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
5698
5642
  <xsl:call-template name="tokenize">
5699
5643
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
5700
5644
  <!-- 2009 thinspace -->
@@ -5707,6 +5651,7 @@
5707
5651
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
5708
5652
  </xsl:call-template>
5709
5653
  </xsl:variable>
5654
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
5710
5655
  <width>
5711
5656
  <xsl:variable name="divider">
5712
5657
  <xsl:choose>
@@ -5739,6 +5684,10 @@
5739
5684
  <xsl:with-param name="table" select="$table"/>
5740
5685
  </xsl:call-template>
5741
5686
  </xsl:if>
5687
+ </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
5688
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
5689
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
5690
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
5742
5691
  </xsl:template><xsl:template match="text()" mode="td_text">
5743
5692
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
5744
5693
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -5840,16 +5789,9 @@
5840
5789
  </xsl:for-each>
5841
5790
  </xsl:when>
5842
5791
  <xsl:otherwise>
5843
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
5844
- <xsl:choose>
5845
- <xsl:when test=". = 1 or . = 0">
5846
- <fo:table-column column-width="proportional-column-width(2)"/>
5847
- </xsl:when>
5848
- <xsl:otherwise>
5849
- <fo:table-column column-width="proportional-column-width({.})"/>
5850
- </xsl:otherwise>
5851
- </xsl:choose>
5852
- </xsl:for-each>
5792
+ <xsl:call-template name="insertTableColumnWidth">
5793
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5794
+ </xsl:call-template>
5853
5795
  </xsl:otherwise>
5854
5796
  </xsl:choose>
5855
5797
 
@@ -6460,8 +6402,10 @@
6460
6402
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
6461
6403
  </xsl:variable>
6462
6404
 
6405
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
6406
+
6463
6407
  <xsl:choose>
6464
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
6408
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
6465
6409
 
6466
6410
  <fo:block margin-bottom="12pt" text-align="left">
6467
6411
 
@@ -6476,7 +6420,7 @@
6476
6420
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
6477
6421
  </fo:block>
6478
6422
 
6479
- </xsl:when>
6423
+ </xsl:when> <!-- END: only one component -->
6480
6424
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
6481
6425
  <fo:block margin-bottom="12pt" text-align="left">
6482
6426
 
@@ -6490,8 +6434,8 @@
6490
6434
  </xsl:variable>
6491
6435
  <xsl:value-of select="$title-where"/>
6492
6436
  </fo:block>
6493
- </xsl:when>
6494
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
6437
+ </xsl:when> <!-- END: a few components -->
6438
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
6495
6439
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
6496
6440
 
6497
6441
 
@@ -6504,11 +6448,11 @@
6504
6448
  </xsl:variable>
6505
6449
  <xsl:value-of select="$title-key"/>
6506
6450
  </fo:block>
6507
- </xsl:when>
6451
+ </xsl:when> <!-- END: definition list in a figure -->
6508
6452
  </xsl:choose>
6509
6453
 
6510
6454
  <!-- a few components -->
6511
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
6455
+ <xsl:if test="$onlyOneComponent = 'false'">
6512
6456
  <fo:block>
6513
6457
 
6514
6458
 
@@ -6547,21 +6491,28 @@
6547
6491
  <xsl:apply-templates mode="dl"/>
6548
6492
  </tbody>
6549
6493
  </xsl:variable>
6550
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
6494
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
6551
6495
  <xsl:variable name="colwidths">
6552
6496
  <xsl:call-template name="calculate-column-widths">
6553
6497
  <xsl:with-param name="cols-count" select="2"/>
6554
6498
  <xsl:with-param name="table" select="$html-table"/>
6555
6499
  </xsl:call-template>
6556
6500
  </xsl:variable>
6557
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
6501
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
6558
6502
  <xsl:variable name="maxlength_dt">
6559
6503
  <xsl:call-template name="getMaxLength_dt"/>
6560
6504
  </xsl:variable>
6505
+ <xsl:variable name="isContainsKeepTogetherTag_">
6506
+ false
6507
+ </xsl:variable>
6508
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
6509
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
6561
6510
  <xsl:call-template name="setColumnWidth_dl">
6562
6511
  <xsl:with-param name="colwidths" select="$colwidths"/>
6563
6512
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
6513
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
6564
6514
  </xsl:call-template>
6515
+
6565
6516
  <fo:table-body>
6566
6517
  <xsl:apply-templates>
6567
6518
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -6570,12 +6521,13 @@
6570
6521
  </fo:table>
6571
6522
  </fo:block>
6572
6523
  </fo:block>
6573
- </xsl:if>
6524
+ </xsl:if> <!-- END: a few components -->
6574
6525
  </fo:block-container>
6575
6526
  </fo:block-container>
6576
6527
  </xsl:template><xsl:template name="setColumnWidth_dl">
6577
6528
  <xsl:param name="colwidths"/>
6578
6529
  <xsl:param name="maxlength_dt"/>
6530
+ <xsl:param name="isContainsKeepTogetherTag"/>
6579
6531
  <xsl:choose>
6580
6532
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
6581
6533
  <fo:table-column column-width="50%"/>
@@ -6583,6 +6535,11 @@
6583
6535
  </xsl:when>
6584
6536
  <xsl:otherwise>
6585
6537
  <xsl:choose>
6538
+ <xsl:when test="$isContainsKeepTogetherTag">
6539
+ <xsl:call-template name="insertTableColumnWidth">
6540
+ <xsl:with-param name="colwidths" select="$colwidths"/>
6541
+ </xsl:call-template>
6542
+ </xsl:when>
6586
6543
  <!-- to set width check most wide chars like `W` -->
6587
6544
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
6588
6545
  <fo:table-column column-width="7%"/>
@@ -6613,20 +6570,25 @@
6613
6570
  <fo:table-column column-width="60%"/>
6614
6571
  </xsl:when>
6615
6572
  <xsl:otherwise>
6616
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
6617
- <xsl:choose>
6618
- <xsl:when test=". = 1 or . = 0">
6619
- <fo:table-column column-width="proportional-column-width(2)"/>
6620
- </xsl:when>
6621
- <xsl:otherwise>
6622
- <fo:table-column column-width="proportional-column-width({.})"/>
6623
- </xsl:otherwise>
6624
- </xsl:choose>
6625
- </xsl:for-each>
6573
+ <xsl:call-template name="insertTableColumnWidth">
6574
+ <xsl:with-param name="colwidths" select="$colwidths"/>
6575
+ </xsl:call-template>
6626
6576
  </xsl:otherwise>
6627
6577
  </xsl:choose>
6628
6578
  </xsl:otherwise>
6629
6579
  </xsl:choose>
6580
+ </xsl:template><xsl:template name="insertTableColumnWidth">
6581
+ <xsl:param name="colwidths"/>
6582
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
6583
+ <xsl:choose>
6584
+ <xsl:when test=". = 1 or . = 0">
6585
+ <fo:table-column column-width="proportional-column-width(2)"/>
6586
+ </xsl:when>
6587
+ <xsl:otherwise>
6588
+ <fo:table-column column-width="proportional-column-width({.})"/>
6589
+ </xsl:otherwise>
6590
+ </xsl:choose>
6591
+ </xsl:for-each>
6630
6592
  </xsl:template><xsl:template name="getMaxLength_dt">
6631
6593
  <xsl:variable name="lengths">
6632
6594
  <xsl:for-each select="*[local-name()='dt']">
@@ -6650,7 +6612,6 @@
6650
6612
  <xsl:value-of select="$maxLength"/>
6651
6613
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
6652
6614
  <xsl:param name="key_iso"/>
6653
-
6654
6615
  <!-- <tr>
6655
6616
  <td>NOTE</td>
6656
6617
  <td>
@@ -6658,18 +6619,30 @@
6658
6619
  </td>
6659
6620
  </tr>
6660
6621
  -->
6661
- <fo:table-row>
6622
+ <!-- OLD Variant -->
6623
+ <!-- <fo:table-row>
6662
6624
  <fo:table-cell>
6663
6625
  <fo:block margin-top="6pt">
6664
6626
  <xsl:if test="normalize-space($key_iso) = 'true'">
6665
6627
  <xsl:attribute name="margin-top">0</xsl:attribute>
6666
6628
  </xsl:if>
6667
- <xsl:apply-templates select="*[local-name() = 'name']"/>
6629
+ <xsl:apply-templates select="*[local-name() = 'name']" />
6668
6630
  </fo:block>
6669
6631
  </fo:table-cell>
6670
6632
  <fo:table-cell>
6671
6633
  <fo:block>
6672
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
6634
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
6635
+ </fo:block>
6636
+ </fo:table-cell>
6637
+ </fo:table-row> -->
6638
+ <!-- <tr>
6639
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
6640
+ </tr>
6641
+ -->
6642
+ <fo:table-row>
6643
+ <fo:table-cell number-columns-spanned="2">
6644
+ <fo:block>
6645
+ <xsl:call-template name="note"/>
6673
6646
  </fo:block>
6674
6647
  </fo:table-cell>
6675
6648
  </fo:table-row>
@@ -6771,13 +6744,15 @@
6771
6744
  <xsl:choose>
6772
6745
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
6773
6746
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
6774
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
6747
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
6775
6748
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
6776
6749
  </xsl:choose>
6777
6750
  </xsl:attribute>
6778
6751
  </xsl:if>
6779
6752
  <xsl:apply-templates/>
6780
6753
  </fo:inline>
6754
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
6755
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
6781
6756
  </xsl:template><xsl:template match="*[local-name()='underline']">
6782
6757
  <fo:inline text-decoration="underline">
6783
6758
  <xsl:apply-templates/>
@@ -6925,41 +6900,50 @@
6925
6900
  <fo:block break-after="page"/>
6926
6901
  <fo:block> </fo:block>
6927
6902
  <fo:block break-after="page"/>
6903
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
6904
+ <xsl:apply-templates/>
6928
6905
  </xsl:template><xsl:template name="tokenize">
6929
6906
  <xsl:param name="text"/>
6930
6907
  <xsl:param name="separator" select="' '"/>
6931
6908
  <xsl:choose>
6932
6909
  <xsl:when test="not(contains($text, $separator))">
6933
6910
  <word>
6934
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
6935
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
6936
6911
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
6937
- <xsl:variable name="len_str">
6938
- <xsl:choose>
6939
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
6940
- <xsl:value-of select="$len_str_tmp * 1.5"/>
6941
- </xsl:when>
6942
- <xsl:otherwise>
6943
- <xsl:value-of select="$len_str_tmp"/>
6944
- </xsl:otherwise>
6945
- </xsl:choose>
6946
- </xsl:variable>
6947
-
6948
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
6949
- <xsl:message>
6950
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
6951
- len_str=<xsl:value-of select="$len_str"/>
6952
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
6953
- </xsl:message>
6954
- </xsl:if> -->
6955
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
6956
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
6957
6912
  <xsl:choose>
6958
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
6959
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
6913
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
6914
+ <xsl:value-of select="$len_str_tmp"/>
6960
6915
  </xsl:when>
6961
6916
  <xsl:otherwise>
6962
- <xsl:value-of select="$len_str"/>
6917
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
6918
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
6919
+ <xsl:variable name="len_str">
6920
+ <xsl:choose>
6921
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
6922
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
6923
+ </xsl:when>
6924
+ <xsl:otherwise>
6925
+ <xsl:value-of select="$len_str_tmp"/>
6926
+ </xsl:otherwise>
6927
+ </xsl:choose>
6928
+ </xsl:variable>
6929
+
6930
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
6931
+ <xsl:message>
6932
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
6933
+ len_str=<xsl:value-of select="$len_str"/>
6934
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
6935
+ </xsl:message>
6936
+ </xsl:if> -->
6937
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
6938
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
6939
+ <xsl:choose>
6940
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
6941
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
6942
+ </xsl:when>
6943
+ <xsl:otherwise>
6944
+ <xsl:value-of select="$len_str"/>
6945
+ </xsl:otherwise>
6946
+ </xsl:choose>
6963
6947
  </xsl:otherwise>
6964
6948
  </xsl:choose>
6965
6949
  </word>
@@ -7045,24 +7029,28 @@
7045
7029
  </xsl:template><xsl:template name="add-zero-spaces-equal">
7046
7030
  <xsl:param name="text" select="."/>
7047
7031
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
7032
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
7048
7033
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
7034
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
7049
7035
  <xsl:variable name="zero-space">​</xsl:variable>
7050
7036
  <xsl:choose>
7051
7037
  <xsl:when test="contains($text, $zero-space-after-equals)">
7052
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
7038
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
7053
7039
  <xsl:value-of select="$zero-space-after-equals"/>
7054
7040
  <xsl:value-of select="$zero-space"/>
7055
7041
  <xsl:call-template name="add-zero-spaces-equal">
7056
7042
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
7057
- </xsl:call-template>
7043
+ </xsl:call-template> -->
7044
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
7058
7045
  </xsl:when>
7059
7046
  <xsl:when test="contains($text, $zero-space-after-equal)">
7060
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
7047
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
7061
7048
  <xsl:value-of select="$zero-space-after-equal"/>
7062
7049
  <xsl:value-of select="$zero-space"/>
7063
7050
  <xsl:call-template name="add-zero-spaces-equal">
7064
7051
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
7065
- </xsl:call-template>
7052
+ </xsl:call-template> -->
7053
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
7066
7054
  </xsl:when>
7067
7055
  <xsl:otherwise>
7068
7056
  <xsl:value-of select="$text"/>
@@ -7230,81 +7218,125 @@
7230
7218
  <xsl:variable name="isDeleted" select="@deleted"/>
7231
7219
 
7232
7220
  <fo:inline xsl:use-attribute-sets="mathml-style">
7221
+
7233
7222
 
7234
7223
  <xsl:if test="ancestor::*[local-name()='table']">
7235
7224
  <xsl:attribute name="font-size">95%</xsl:attribute> <!-- base font in table is 10pt -->
7236
7225
  </xsl:if>
7237
7226
 
7238
7227
 
7228
+
7229
+
7239
7230
  <xsl:call-template name="setTrackChangesStyles">
7240
7231
  <xsl:with-param name="isAdded" select="$isAdded"/>
7241
7232
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
7242
7233
  </xsl:call-template>
7243
7234
 
7244
- <!-- insert helper tag -->
7245
- <xsl:if test="$add_math_as_text = 'true'">
7246
- <fo:inline color="white" font-size="1pt" font-style="normal" font-weight="normal">​</fo:inline> <!-- zero width space -->
7247
- </xsl:if>
7248
-
7235
+ <xsl:if test="$add_math_as_text = 'true'">
7236
+ <!-- insert helper tag -->
7237
+ <!-- set unique font-size (fiction) -->
7238
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
7239
+ <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal"><xsl:value-of select="$zero_width_space"/></fo:inline> <!-- zero width space -->
7240
+ </xsl:if>
7249
7241
 
7250
- <xsl:variable name="mathml">
7251
- <xsl:apply-templates select="." mode="mathml"/>
7242
+ <xsl:variable name="mathml_content">
7243
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
7252
7244
  </xsl:variable>
7253
- <fo:instream-foreign-object fox:alt-text="Math">
7254
7245
 
7255
-
7256
- <xsl:if test="local-name(../..) = 'formula'">
7257
- <xsl:attribute name="width">95%</xsl:attribute>
7258
- <xsl:attribute name="content-height">100%</xsl:attribute>
7259
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7260
- <xsl:attribute name="scaling">uniform</xsl:attribute>
7261
- </xsl:if>
7262
-
7263
- <xsl:if test="$add_math_as_text = 'true'">
7264
- <!-- <xsl:variable name="comment_text" select="following-sibling::node()[1][self::comment()]"/> -->
7265
- <xsl:variable name="comment_text" select="normalize-space(translate(.,' ⁢',' '))"/>
7266
- <xsl:if test="normalize-space($comment_text) != ''">
7267
- <!-- put Mathin Alternate Text -->
7268
- <xsl:attribute name="fox:alt-text">
7269
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7270
- </xsl:attribute>
7271
- </xsl:if>
7272
- </xsl:if>
7273
-
7274
-
7275
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
7276
- <xsl:variable name="comment_text_">
7246
+
7247
+ <xsl:variable name="filename" select="xalan:nodeset($mathml_attachments)//attachment[. = $mathml_content]/@filename"/>
7277
7248
  <xsl:choose>
7278
- <xsl:when test="normalize-space($comment_text_following) != ''">
7279
- <xsl:value-of select="$comment_text_following"/>
7249
+ <xsl:when test="$add_math_as_attachment = 'true' and normalize-space($filename) != ''">
7250
+ <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
7251
+ <fo:basic-link external-destination="{$url}" fox:alt-text="MathLink">
7252
+ <xsl:variable name="comment_text">
7253
+ <xsl:call-template name="getMathml_comment_text"/>
7254
+ </xsl:variable>
7255
+ <xsl:if test="normalize-space($comment_text) != ''">
7256
+ <!-- put Mathin Alternate Text -->
7257
+ <xsl:attribute name="fox:alt-text">
7258
+ <xsl:value-of select="$comment_text"/>
7259
+ </xsl:attribute>
7260
+ </xsl:if>
7261
+ <xsl:call-template name="mathml_instream_object">
7262
+ <xsl:with-param name="comment_text" select="$comment_text"/>
7263
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
7264
+ </xsl:call-template>
7265
+ </fo:basic-link>
7280
7266
  </xsl:when>
7281
7267
  <xsl:otherwise>
7282
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
7268
+ <xsl:call-template name="mathml_instream_object">
7269
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
7270
+ </xsl:call-template>
7283
7271
  </xsl:otherwise>
7284
7272
  </xsl:choose>
7285
- </xsl:variable>
7286
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
7273
+ <!-- end BSI -->
7287
7274
 
7288
- <xsl:if test="normalize-space($comment_text) != ''">
7289
- <!-- put Mathin Alternate Text -->
7290
- <xsl:attribute name="fox:alt-text">
7291
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7292
- </xsl:attribute>
7275
+
7276
+ </fo:inline>
7277
+ </xsl:template><xsl:template name="getMathml_comment_text">
7278
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
7279
+ <xsl:variable name="comment_text_">
7280
+ <xsl:choose>
7281
+ <xsl:when test="normalize-space($comment_text_following) != ''">
7282
+ <xsl:value-of select="$comment_text_following"/>
7283
+ </xsl:when>
7284
+ <xsl:otherwise>
7285
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
7286
+ </xsl:otherwise>
7287
+ </xsl:choose>
7288
+ </xsl:variable>
7289
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
7290
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
7291
+ <xsl:value-of select="$comment_text"/>
7292
+ </xsl:template><xsl:template name="mathml_instream_object">
7293
+ <xsl:param name="comment_text"/>
7294
+ <xsl:param name="mathml_content"/>
7295
+
7296
+ <xsl:variable name="comment_text_">
7297
+ <xsl:choose>
7298
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
7299
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
7300
+ </xsl:choose>
7301
+ </xsl:variable>
7302
+
7303
+ <xsl:variable name="mathml">
7304
+ <xsl:apply-templates select="." mode="mathml"/>
7305
+ </xsl:variable>
7306
+
7307
+ <fo:instream-foreign-object fox:alt-text="Math">
7308
+
7309
+
7310
+ <xsl:if test="local-name(../..) = 'formula'">
7311
+ <xsl:attribute name="width">95%</xsl:attribute>
7312
+ <xsl:attribute name="content-height">100%</xsl:attribute>
7313
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7314
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
7293
7315
  </xsl:if>
7294
-
7295
- <xsl:variable name="mathml_content">
7296
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
7297
- </xsl:variable>
7298
- <!-- put MathML in Actual Text -->
7299
- <xsl:attribute name="fox:actual-text">
7300
- <xsl:value-of select="$mathml_content"/>
7316
+
7317
+
7318
+
7319
+
7320
+
7321
+
7322
+ <!-- put MathML in Actual Text -->
7323
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
7324
+ <xsl:attribute name="fox:actual-text">
7325
+ <xsl:value-of select="$mathml_content"/>
7326
+ </xsl:attribute>
7327
+
7328
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
7329
+ <xsl:if test="normalize-space($comment_text_) != ''">
7330
+ <!-- put Mathin Alternate Text -->
7331
+ <xsl:attribute name="fox:alt-text">
7332
+ <xsl:value-of select="$comment_text_"/>
7301
7333
  </xsl:attribute>
7302
-
7303
-
7304
-
7305
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
7306
- </fo:instream-foreign-object>
7307
- </fo:inline>
7334
+ </xsl:if>
7335
+ <!-- </xsl:if> -->
7336
+
7337
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
7338
+
7339
+ </fo:instream-foreign-object>
7308
7340
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
7309
7341
  <!-- <xsl:text>a+b</xsl:text> -->
7310
7342
  <xsl:text>&lt;</xsl:text>
@@ -7335,7 +7367,9 @@
7335
7367
  <!-- replace start and end spaces to non-break space -->
7336
7368
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
7337
7369
  </xsl:copy>
7338
- </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
7370
+ </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="mathml:mtd/mathml:mo/text()[. = '/']" mode="mathml">
7371
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
7372
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
7339
7373
  <xsl:variable name="target">
7340
7374
  <xsl:choose>
7341
7375
  <xsl:when test="@updatetype = 'true'">
@@ -7576,7 +7610,12 @@
7576
7610
 
7577
7611
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
7578
7612
 
7613
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
7614
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
7615
+ </xsl:if>
7616
+
7579
7617
 
7618
+
7580
7619
 
7581
7620
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
7582
7621
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -7941,18 +7980,33 @@
7941
7980
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
7942
7981
  <xsl:copy>
7943
7982
  <xsl:apply-templates select="@*" mode="svg_update"/>
7944
- <xsl:variable name="viewbox">
7983
+ <xsl:variable name="viewbox_">
7945
7984
  <xsl:call-template name="split">
7946
7985
  <xsl:with-param name="pText" select="@viewBox"/>
7947
7986
  <xsl:with-param name="sep" select="' '"/>
7948
7987
  </xsl:call-template>
7949
7988
  </xsl:variable>
7989
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
7990
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7991
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7992
+
7950
7993
  <xsl:attribute name="width">
7951
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
7994
+ <xsl:choose>
7995
+ <xsl:when test="$width != ''">
7996
+ <xsl:value-of select="round($width)"/>
7997
+ </xsl:when>
7998
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
7999
+ </xsl:choose>
7952
8000
  </xsl:attribute>
7953
8001
  <xsl:attribute name="height">
7954
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
8002
+ <xsl:choose>
8003
+ <xsl:when test="$height != ''">
8004
+ <xsl:value-of select="round($height)"/>
8005
+ </xsl:when>
8006
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
8007
+ </xsl:choose>
7955
8008
  </xsl:attribute>
8009
+
7956
8010
  <xsl:apply-templates mode="svg_update"/>
7957
8011
  </xsl:copy>
7958
8012
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -8147,7 +8201,11 @@
8147
8201
  <xsl:apply-templates mode="bookmarks"/>
8148
8202
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
8149
8203
  <xsl:apply-templates select="."/>
8150
- </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
8204
+ </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'span']" mode="contents">
8205
+ <xsl:apply-templates mode="contents"/>
8206
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
8207
+ <xsl:apply-templates mode="bookmarks"/>
8208
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
8151
8209
  <xsl:apply-templates mode="bookmarks"/>
8152
8210
  </xsl:template><xsl:template name="addBookmarks">
8153
8211
  <xsl:param name="contents"/>
@@ -8443,7 +8501,9 @@
8443
8501
  <xsl:apply-templates/>
8444
8502
  </xsl:otherwise>
8445
8503
  </xsl:choose>
8446
- </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
8504
+ </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'xref']" mode="contents">
8505
+ <xsl:value-of select="."/>
8506
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
8447
8507
  <xsl:text> </xsl:text>
8448
8508
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
8449
8509
  <xsl:copy>
@@ -8474,9 +8534,22 @@
8474
8534
  </xsl:when>
8475
8535
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
8476
8536
  </xsl:choose>
8537
+ </xsl:template><xsl:template match="text()" mode="contents_item">
8538
+ <xsl:call-template name="keep_together_standard_number"/>
8539
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
8540
+ <xsl:apply-templates mode="contents_item"/>
8477
8541
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
8478
8542
 
8479
8543
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
8544
+
8545
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
8546
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
8547
+ </xsl:if>
8548
+
8549
+ <xsl:if test="ancestor::*[local-name() = 'example']">
8550
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
8551
+ </xsl:if>
8552
+
8480
8553
  <xsl:copy-of select="@id"/>
8481
8554
 
8482
8555
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -8576,17 +8649,15 @@
8576
8649
 
8577
8650
  <!-- split text by zero-width space -->
8578
8651
  <xsl:variable name="text_step4">
8579
- <xsl:call-template name="split">
8652
+ <xsl:call-template name="split_for_interspers">
8580
8653
  <xsl:with-param name="pText" select="$text_step3"/>
8581
8654
  <xsl:with-param name="sep" select="$zero_width_space"/>
8582
- <xsl:with-param name="normalize-space">false</xsl:with-param>
8583
- <xsl:with-param name="keep_sep">true</xsl:with-param>
8584
8655
  </xsl:call-template>
8585
8656
  </xsl:variable>
8586
8657
 
8587
- <xsl:for-each select="xalan:nodeset($text_step4)/item">
8658
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
8588
8659
  <xsl:choose>
8589
- <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
8660
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
8590
8661
  <xsl:call-template name="interspers">
8591
8662
  <xsl:with-param name="str" select="."/>
8592
8663
  </xsl:call-template>
@@ -8597,6 +8668,30 @@
8597
8668
  </xsl:choose>
8598
8669
  </xsl:for-each>
8599
8670
 
8671
+ </xsl:template><xsl:variable name="interspers_tag_open">###interspers123###</xsl:variable><xsl:variable name="interspers_tag_close">###/interspers123###</xsl:variable><xsl:template name="split_for_interspers">
8672
+ <xsl:param name="pText" select="."/>
8673
+ <xsl:param name="sep" select="','"/>
8674
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
8675
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
8676
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
8677
+ <xsl:call-template name="replace_tag_interspers">
8678
+ <xsl:with-param name="text" select="$text"/>
8679
+ </xsl:call-template>
8680
+ </xsl:template><xsl:template name="replace_tag_interspers">
8681
+ <xsl:param name="text"/>
8682
+ <xsl:choose>
8683
+ <xsl:when test="contains($text, $interspers_tag_open)">
8684
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
8685
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
8686
+ <interspers>
8687
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
8688
+ </interspers>
8689
+ <xsl:call-template name="replace_tag_interspers">
8690
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
8691
+ </xsl:call-template>
8692
+ </xsl:when>
8693
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8694
+ </xsl:choose>
8600
8695
  </xsl:template><xsl:template name="interspers">
8601
8696
  <xsl:param name="str"/>
8602
8697
  <xsl:param name="char" select="$zero_width_space"/>
@@ -8932,39 +9027,67 @@
8932
9027
  </xsl:otherwise>
8933
9028
  </xsl:choose>
8934
9029
  </xsl:template><xsl:template match="*[local-name() = 'example']">
8935
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
8936
-
9030
+
9031
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
9032
+
8937
9033
 
9034
+
8938
9035
  <xsl:variable name="fo_element">
8939
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
9036
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
8940
9037
  block
8941
9038
  </xsl:variable>
8942
9039
 
8943
- <!-- display 'EXAMPLE' -->
8944
- <xsl:apply-templates select="*[local-name()='name']">
8945
- <xsl:with-param name="fo_element" select="$fo_element"/>
8946
- </xsl:apply-templates>
9040
+ <fo:block-container margin-left="0mm">
8947
9041
 
8948
- <xsl:choose>
8949
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
8950
- <fo:block-container xsl:use-attribute-sets="example-body-style">
8951
- <fo:block-container margin-left="0mm" margin-right="0mm">
8952
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9042
+ <xsl:choose>
9043
+
9044
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
9045
+
9046
+ <!-- display name 'EXAMPLE' in a separate block -->
9047
+ <fo:block>
9048
+ <xsl:apply-templates select="*[local-name()='name']">
8953
9049
  <xsl:with-param name="fo_element" select="$fo_element"/>
8954
9050
  </xsl:apply-templates>
9051
+ </fo:block>
9052
+
9053
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
9054
+ <fo:block-container margin-left="0mm" margin-right="0mm">
9055
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9056
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9057
+ </xsl:apply-templates>
9058
+ </fo:block-container>
8955
9059
  </fo:block-container>
8956
- </fo:block-container>
8957
- </xsl:when>
8958
- <xsl:otherwise>
8959
- <fo:inline>
8960
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8961
- <xsl:with-param name="fo_element" select="$fo_element"/>
8962
- </xsl:apply-templates>
8963
- </fo:inline>
8964
- </xsl:otherwise>
8965
- </xsl:choose>
8966
-
8967
- </fo:block>
9060
+ </xsl:when> <!-- end block -->
9061
+
9062
+ <xsl:otherwise> <!-- inline -->
9063
+
9064
+ <!-- display 'EXAMPLE' and first element in the same line -->
9065
+ <fo:block>
9066
+ <xsl:apply-templates select="*[local-name()='name']">
9067
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9068
+ </xsl:apply-templates>
9069
+ <fo:inline>
9070
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
9071
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9072
+ </xsl:apply-templates>
9073
+ </fo:inline>
9074
+ </fo:block>
9075
+
9076
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
9077
+ <!-- display further elements in blocks -->
9078
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
9079
+ <fo:block-container margin-left="0mm" margin-right="0mm">
9080
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
9081
+ <xsl:with-param name="fo_element" select="'block'"/>
9082
+ </xsl:apply-templates>
9083
+ </fo:block-container>
9084
+ </fo:block-container>
9085
+ </xsl:if>
9086
+ </xsl:otherwise> <!-- end inline -->
9087
+
9088
+ </xsl:choose>
9089
+ </fo:block-container>
9090
+ </fo:block-container>
8968
9091
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
8969
9092
  <xsl:param name="fo_element">block</xsl:param>
8970
9093
 
@@ -8996,10 +9119,16 @@
8996
9119
  </xsl:variable>
8997
9120
  <xsl:choose>
8998
9121
  <xsl:when test="starts-with(normalize-space($element), 'block')">
8999
- <fo:block xsl:use-attribute-sets="example-p-style">
9000
-
9001
- <xsl:apply-templates/>
9002
- </fo:block>
9122
+ <fo:block-container>
9123
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
9124
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
9125
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
9126
+ </xsl:if>
9127
+ <fo:block xsl:use-attribute-sets="example-p-style">
9128
+
9129
+ <xsl:apply-templates/>
9130
+ </fo:block>
9131
+ </fo:block-container>
9003
9132
  </xsl:when>
9004
9133
  <xsl:otherwise>
9005
9134
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -9044,7 +9173,7 @@
9044
9173
  </xsl:otherwise>
9045
9174
  </xsl:choose> -->
9046
9175
  </fo:block>
9047
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
9176
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ') or starts-with(., '[SOURCE: Quoted from: ') or starts-with(., '[SOURCE: Modified from: ')]" priority="2">
9048
9177
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
9049
9178
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
9050
9179
  <xsl:if test="normalize-space() != ''">
@@ -9080,7 +9209,8 @@
9080
9209
  <fo:inline><xsl:apply-templates/></fo:inline>
9081
9210
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
9082
9211
  <xsl:if test="normalize-space() != ''">
9083
- <xsl:value-of select="."/>
9212
+ <!-- <xsl:value-of select="."/> -->
9213
+ <xsl:call-template name="text"/>
9084
9214
  </xsl:if>
9085
9215
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
9086
9216
  <fo:block-container margin-left="0mm">
@@ -9186,7 +9316,16 @@
9186
9316
  </fo:inline>
9187
9317
  </xsl:when>
9188
9318
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
9189
- <fo:inline><xsl:apply-templates/></fo:inline>
9319
+
9320
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
9321
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
9322
+ <xsl:choose>
9323
+ <xsl:when test="$uri_src != ''">
9324
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
9325
+ </xsl:when>
9326
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
9327
+ </xsl:choose>
9328
+
9190
9329
  </xsl:otherwise>
9191
9330
  </xsl:choose>
9192
9331
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -9359,10 +9498,24 @@
9359
9498
 
9360
9499
  </fo:block>
9361
9500
  <xsl:apply-templates/>
9362
- </xsl:template><xsl:template match="*[local-name() = 'review']">
9501
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
9363
9502
  <!-- comment 2019-11-29 -->
9364
9503
  <!-- <fo:block font-weight="bold">Review:</fo:block>
9365
9504
  <xsl:apply-templates /> -->
9505
+
9506
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
9507
+
9508
+ <xsl:choose>
9509
+ <!-- if there isn't the attribute '@from', then -->
9510
+ <xsl:when test="$id_from = ''">
9511
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9512
+ </xsl:when>
9513
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
9514
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9515
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9516
+ </xsl:when>
9517
+ </xsl:choose>
9518
+
9366
9519
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
9367
9520
  <!-- 0xA0 to space replacement -->
9368
9521
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -9723,7 +9876,10 @@
9723
9876
  <!-- to split by '_' and other chars -->
9724
9877
  <xsl:call-template name="add-zero-spaces-java"/>
9725
9878
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
9726
- <fo:inline id="{@id}" font-size="1pt"/>
9879
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
9880
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
9881
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
9882
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
9727
9883
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
9728
9884
  <!-- <row>
9729
9885
  <date>05-07-2013</date>
@@ -10283,6 +10439,120 @@
10283
10439
  <xsl:apply-templates select="." mode="update_xml_step1"/>
10284
10440
  </xsl:for-each>
10285
10441
  </xsl:copy>
10442
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
10443
+ <xsl:apply-templates mode="update_xml_step1"/>
10444
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
10445
+ <xsl:copy>
10446
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
10447
+ </xsl:copy>
10448
+ </xsl:template><xsl:variable name="express_reference_separators">_.\</xsl:variable><xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/><xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable><xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'])]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
10449
+
10450
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
10451
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
10452
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
10453
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
10454
+ <xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
10455
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
10456
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
10457
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
10458
+ <xsl:with-param name="text" select="$text_"/>
10459
+ </xsl:call-template></text></xsl:variable>
10460
+
10461
+ <xsl:variable name="parent" select="local-name(..)"/>
10462
+
10463
+ <xsl:variable name="text2">
10464
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
10465
+ <xsl:copy-of select="."/>
10466
+ </xsl:for-each></text>
10467
+ </xsl:variable>
10468
+
10469
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
10470
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
10471
+ <xsl:variable name="text3">
10472
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
10473
+ <xsl:choose>
10474
+ <xsl:when test="self::text()">
10475
+ <xsl:variable name="text_units_" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
10476
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
10477
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
10478
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
10479
+ <xsl:with-param name="text" select="$text_units_"/>
10480
+ </xsl:call-template></text></xsl:variable>
10481
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
10482
+ </xsl:when>
10483
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
10484
+ </xsl:choose>
10485
+ </xsl:for-each></text>
10486
+ </xsl:variable>
10487
+
10488
+ <xsl:choose>
10489
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
10490
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
10491
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
10492
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
10493
+ <xsl:choose>
10494
+ <xsl:when test="self::text()">
10495
+ <xsl:variable name="text_dots_" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
10496
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
10497
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
10498
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
10499
+ <xsl:with-param name="text" select="$text_dots_"/>
10500
+ </xsl:call-template></text></xsl:variable>
10501
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
10502
+ </xsl:when>
10503
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
10504
+ </xsl:choose>
10505
+ </xsl:for-each>
10506
+ </xsl:when>
10507
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
10508
+ </xsl:choose>
10509
+
10510
+ </xsl:template><xsl:template name="replace_text_tags">
10511
+ <xsl:param name="tag_open"/>
10512
+ <xsl:param name="tag_close"/>
10513
+ <xsl:param name="text"/>
10514
+ <xsl:choose>
10515
+ <xsl:when test="contains($text, $tag_open)">
10516
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
10517
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
10518
+
10519
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
10520
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
10521
+ </xsl:element>
10522
+
10523
+ <xsl:call-template name="replace_text_tags">
10524
+ <xsl:with-param name="tag_open" select="$tag_open"/>
10525
+ <xsl:with-param name="tag_close" select="$tag_close"/>
10526
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
10527
+ </xsl:call-template>
10528
+ </xsl:when>
10529
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
10530
+ </xsl:choose>
10531
+ </xsl:template><xsl:template name="printEdition">
10532
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
10533
+ <xsl:text> </xsl:text>
10534
+ <xsl:choose>
10535
+ <xsl:when test="$edition_i18n != ''">
10536
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
10537
+ <xsl:call-template name="capitalize">
10538
+ <xsl:with-param name="str" select="$edition_i18n"/>
10539
+ </xsl:call-template>
10540
+ </xsl:when>
10541
+ <xsl:otherwise>
10542
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
10543
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
10544
+ <xsl:call-template name="capitalize">
10545
+ <xsl:with-param name="str">
10546
+ <xsl:call-template name="getLocalizedString">
10547
+ <xsl:with-param name="key">edition</xsl:with-param>
10548
+ </xsl:call-template>
10549
+ </xsl:with-param>
10550
+ </xsl:call-template>
10551
+ <xsl:text> </xsl:text>
10552
+ <xsl:value-of select="$edition"/>
10553
+ </xsl:if>
10554
+ </xsl:otherwise>
10555
+ </xsl:choose>
10286
10556
  </xsl:template><xsl:template name="convertDate">
10287
10557
  <xsl:param name="date"/>
10288
10558
  <xsl:param name="format" select="'short'"/>