metanorma-bipm 2.0.8 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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"/>
@@ -985,7 +983,7 @@
985
983
  <fo:block-container font-size="9pt" border-bottom="1pt solid black" width="68mm" text-align="center" margin-bottom="14pt">
986
984
  <fo:block font-weight="bold" margin-bottom="2.5mm">
987
985
  <fo:inline padding-right="10mm">
988
- <xsl:apply-templates select="bipm:bibdata/bipm:edition">
986
+ <xsl:apply-templates select="bipm:bibdata/bipm:edition[normalize-space(@language) = '']">
989
987
  <xsl:with-param name="font-size" select="'70%'"/>
990
988
  <xsl:with-param name="baseline-shift" select="'45%'"/>
991
989
  <xsl:with-param name="curr_lang" select="$curr_lang"/>
@@ -1265,7 +1263,7 @@
1265
1263
  <fo:block-container font-size="9pt" border-bottom="1pt solid black" width="68mm" text-align="center" margin-bottom="14pt">
1266
1264
  <fo:block font-weight="bold" margin-bottom="2.5mm">
1267
1265
  <fo:inline padding-right="10mm">
1268
- <xsl:apply-templates select="bipm:bibdata/bipm:edition">
1266
+ <xsl:apply-templates select="bipm:bibdata/bipm:edition[normalize-space(@language) = '']">
1269
1267
  <xsl:with-param name="font-size" select="'70%'"/>
1270
1268
  <xsl:with-param name="baseline-shift" select="'45%'"/>
1271
1269
  <xsl:with-param name="curr_lang" select="$curr_lang"/>
@@ -1353,7 +1351,7 @@
1353
1351
  <xsl:call-template name="getLanguages"/>
1354
1352
  </xsl:variable>
1355
1353
  <xsl:variable name="editionFO">
1356
- <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) = '']">
1357
1355
  <xsl:with-param name="curr_lang" select="xalan:nodeset($languages)/lang[1]"/>
1358
1356
  </xsl:apply-templates>
1359
1357
  </xsl:variable>
@@ -1432,7 +1430,7 @@
1432
1430
 
1433
1431
  <xsl:variable name="edition_str">édition</xsl:variable>
1434
1432
 
1435
- <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>
1436
1434
  </fo:block-container>
1437
1435
 
1438
1436
  <fo:block-container absolute-position="fixed" left="12.5mm" top="92mm" height="170mm" width="144mm" display-align="center">
@@ -2109,12 +2107,6 @@
2109
2107
  <xsl:param name="baseline-shift" select="'30%'"/>
2110
2108
  <xsl:param name="curr_lang" select="'fr'"/>
2111
2109
  <fo:inline>
2112
- <xsl:variable name="title-edition">
2113
- <xsl:call-template name="getTitle">
2114
- <xsl:with-param name="name" select="'title-edition'"/>
2115
- <xsl:with-param name="lang" select="$curr_lang"/>
2116
- </xsl:call-template>
2117
- </xsl:variable>
2118
2110
  <xsl:value-of select="."/>
2119
2111
  <fo:inline font-size="{$font-size}" baseline-shift="{$baseline-shift}">
2120
2112
  <xsl:call-template name="number-to-ordinal">
@@ -2123,7 +2115,9 @@
2123
2115
  </xsl:call-template>
2124
2116
  </fo:inline>
2125
2117
  <xsl:text> </xsl:text>
2126
- <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>
2127
2121
  <xsl:text/>
2128
2122
  </fo:inline>
2129
2123
  </xsl:template>
@@ -3207,112 +3201,6 @@
3207
3201
  <xsl:value-of select="translate(., ' ', ' ')"/>
3208
3202
  </xsl:template>
3209
3203
 
3210
- <xsl:template match="mathml:math" priority="2">
3211
- <xsl:variable name="isAdded" select="@added"/>
3212
- <xsl:variable name="isDeleted" select="@deleted"/>
3213
-
3214
- <fo:inline xsl:use-attribute-sets="mathml-style">
3215
-
3216
- <xsl:if test="ancestor::*[local-name()='table']">
3217
- <xsl:attribute name="font-size">95%</xsl:attribute> <!-- base font in table is 10pt -->
3218
- </xsl:if>
3219
-
3220
- <xsl:call-template name="setTrackChangesStyles">
3221
- <xsl:with-param name="isAdded" select="$isAdded"/>
3222
- <xsl:with-param name="isDeleted" select="$isDeleted"/>
3223
- </xsl:call-template>
3224
-
3225
- <xsl:if test="$add_math_as_text = 'true'">
3226
- <!-- set unique font-size (fiction) -->
3227
- <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
3228
- <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 -->
3229
- </xsl:if>
3230
-
3231
- <!-- <fo:wrapper role="artifact"> -->
3232
-
3233
- <xsl:variable name="mathml_content">
3234
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
3235
- </xsl:variable>
3236
- <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
3237
-
3238
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3239
- <xsl:variable name="comment_text_">
3240
- <xsl:choose>
3241
- <xsl:when test="normalize-space($comment_text_following) != ''">
3242
- <xsl:value-of select="$comment_text_following"/>
3243
- </xsl:when>
3244
- <xsl:otherwise>
3245
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3246
- </xsl:otherwise>
3247
- </xsl:choose>
3248
- </xsl:variable>
3249
- <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3250
- <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
3251
-
3252
- <xsl:variable name="filename" select="xalan:nodeset($mathml_attachments)//attachment[. = $mathml_content]/@filename"/>
3253
- <xsl:choose>
3254
- <xsl:when test="$add_math_as_attachment = 'true' and normalize-space($filename) != ''">
3255
- <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
3256
- <fo:basic-link external-destination="{$url}" fox:alt-text="MathLink">
3257
- <xsl:if test="normalize-space($comment_text) != ''">
3258
- <!-- put Mathin Alternate Text -->
3259
- <xsl:attribute name="fox:alt-text">
3260
- <xsl:value-of select="$comment_text"/>
3261
- </xsl:attribute>
3262
- </xsl:if>
3263
- <xsl:call-template name="mathml_instream_object">
3264
- <xsl:with-param name="mathml_content" select="$mathml_content"/>
3265
- <xsl:with-param name="comment_text" select="$comment_text"/>
3266
- </xsl:call-template>
3267
- </fo:basic-link>
3268
- <!-- </xsl:if> -->
3269
- </xsl:when>
3270
- <xsl:otherwise>
3271
- <xsl:call-template name="mathml_instream_object">
3272
- <xsl:with-param name="mathml_content" select="$mathml_content"/>
3273
- <xsl:with-param name="comment_text" select="$comment_text"/>
3274
- </xsl:call-template>
3275
- </xsl:otherwise>
3276
- </xsl:choose>
3277
- <!-- </fo:wrapper> -->
3278
- </fo:inline>
3279
- </xsl:template>
3280
-
3281
- <xsl:template name="mathml_instream_object">
3282
- <xsl:param name="mathml_content"/>
3283
- <xsl:param name="comment_text"/>
3284
-
3285
- <xsl:variable name="mathml">
3286
- <xsl:apply-templates select="." mode="mathml"/>
3287
- </xsl:variable>
3288
-
3289
- <fo:instream-foreign-object fox:alt-text="Math">
3290
-
3291
- <xsl:if test="local-name(../..) = 'formula'">
3292
- <xsl:attribute name="width">95%</xsl:attribute>
3293
- <xsl:attribute name="content-height">100%</xsl:attribute>
3294
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3295
- <xsl:attribute name="scaling">uniform</xsl:attribute>
3296
- </xsl:if>
3297
-
3298
- <!-- put MathML in Actual Text -->
3299
- <xsl:attribute name="fox:actual-text">
3300
- <xsl:value-of select="$mathml_content"/>
3301
- </xsl:attribute>
3302
-
3303
- <xsl:if test="$add_math_as_text = 'true'">
3304
- <xsl:if test="normalize-space($comment_text) != ''">
3305
- <!-- put Mathin Alternate Text -->
3306
- <xsl:attribute name="fox:alt-text">
3307
- <xsl:value-of select="$comment_text"/>
3308
- </xsl:attribute>
3309
- </xsl:if>
3310
- </xsl:if>
3311
-
3312
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
3313
- </fo:instream-foreign-object>
3314
- </xsl:template>
3315
-
3316
3204
 
3317
3205
  <!-- =================== -->
3318
3206
  <!-- Table of Contents (ToC) processing -->
@@ -3922,7 +3810,7 @@
3922
3810
  </xsl:template>
3923
3811
 
3924
3812
 
3925
- <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">
3926
3814
  <xsl:call-template name="getLang"/>
3927
3815
  </xsl:variable><xsl:variable name="pageWidth_">
3928
3816
  210
@@ -3937,20 +3825,7 @@
3937
3825
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
3938
3826
  22
3939
3827
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
3940
-
3941
- <title-edition lang="en">
3942
-
3943
- <xsl:text>Edition </xsl:text>
3944
-
3945
- </title-edition>
3946
-
3947
- <title-edition lang="fr">
3948
- <xsl:text>Édition </xsl:text>
3949
- </title-edition>
3950
3828
 
3951
- <title-edition lang="ru">
3952
- <xsl:text>Издание </xsl:text>
3953
- </title-edition>
3954
3829
 
3955
3830
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
3956
3831
  <title-toc lang="en">
@@ -4033,7 +3908,7 @@
4033
3908
  </xsl:variable><xsl:variable name="bibdata">
4034
3909
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
4035
3910
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
4036
- </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">
4037
3912
  <xsl:param name="name"/>
4038
3913
  <xsl:param name="lang"/>
4039
3914
  <xsl:variable name="lang_">
@@ -4081,7 +3956,7 @@
4081
3956
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
4082
3957
 
4083
3958
  <xsl:variable name="additional_fonts_">
4084
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
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']">
4085
3960
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
4086
3961
  </xsl:for-each>
4087
3962
  </xsl:variable>
@@ -4168,7 +4043,6 @@
4168
4043
 
4169
4044
 
4170
4045
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
4171
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
4172
4046
 
4173
4047
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
4174
4048
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -4247,6 +4121,7 @@
4247
4121
 
4248
4122
 
4249
4123
 
4124
+
4250
4125
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
4251
4126
 
4252
4127
 
@@ -5331,22 +5206,32 @@
5331
5206
  <xsl:sort select="@displayorder" data-type="number"/>
5332
5207
  <xsl:apply-templates select="."/>
5333
5208
  </xsl:for-each>
5334
- </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
5335
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
5336
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
5337
- <xsl:call-template name="replace_fo_inline">
5338
- <xsl:with-param name="text" select="$text"/>
5339
- </xsl:call-template>
5340
- </xsl:template><xsl:template name="replace_fo_inline">
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"/>
5341
5222
  <xsl:param name="text"/>
5342
5223
  <xsl:choose>
5343
5224
  <xsl:when test="contains($text, $tag_open)">
5344
5225
  <xsl:value-of select="substring-before($text, $tag_open)"/>
5345
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
5226
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
5346
5227
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
5347
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
5348
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
5349
- <xsl:call-template name="replace_fo_inline">
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"/>
5350
5235
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
5351
5236
  </xsl:call-template>
5352
5237
  </xsl:when>
@@ -5354,6 +5239,8 @@
5354
5239
  </xsl:choose>
5355
5240
  </xsl:template><xsl:template match="*[local-name()='br']">
5356
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>
5357
5244
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
5358
5245
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
5359
5246
  <xsl:apply-templates/>
@@ -5429,8 +5316,23 @@
5429
5316
  </xsl:call-template>
5430
5317
 
5431
5318
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
5432
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
5433
- <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>
5434
5336
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
5435
5337
 
5436
5338
  <xsl:variable name="table-preamble">
@@ -5566,16 +5468,9 @@
5566
5468
  </xsl:for-each>
5567
5469
  </xsl:when>
5568
5470
  <xsl:otherwise>
5569
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
5570
- <xsl:choose>
5571
- <xsl:when test=". = 1 or . = 0">
5572
- <fo:table-column column-width="proportional-column-width(2)"/>
5573
- </xsl:when>
5574
- <xsl:otherwise>
5575
- <fo:table-column column-width="proportional-column-width({.})"/>
5576
- </xsl:otherwise>
5577
- </xsl:choose>
5578
- </xsl:for-each>
5471
+ <xsl:call-template name="insertTableColumnWidth">
5472
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5473
+ </xsl:call-template>
5579
5474
  </xsl:otherwise>
5580
5475
  </xsl:choose>
5581
5476
 
@@ -5743,6 +5638,7 @@
5743
5638
  <xsl:with-param name="text" select="$td_text"/>
5744
5639
  </xsl:call-template>
5745
5640
  </xsl:variable>
5641
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
5746
5642
  <xsl:call-template name="tokenize">
5747
5643
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
5748
5644
  <!-- 2009 thinspace -->
@@ -5755,6 +5651,7 @@
5755
5651
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
5756
5652
  </xsl:call-template>
5757
5653
  </xsl:variable>
5654
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
5758
5655
  <width>
5759
5656
  <xsl:variable name="divider">
5760
5657
  <xsl:choose>
@@ -5787,6 +5684,10 @@
5787
5684
  <xsl:with-param name="table" select="$table"/>
5788
5685
  </xsl:call-template>
5789
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')"/>
5790
5691
  </xsl:template><xsl:template match="text()" mode="td_text">
5791
5692
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
5792
5693
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -5888,16 +5789,9 @@
5888
5789
  </xsl:for-each>
5889
5790
  </xsl:when>
5890
5791
  <xsl:otherwise>
5891
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
5892
- <xsl:choose>
5893
- <xsl:when test=". = 1 or . = 0">
5894
- <fo:table-column column-width="proportional-column-width(2)"/>
5895
- </xsl:when>
5896
- <xsl:otherwise>
5897
- <fo:table-column column-width="proportional-column-width({.})"/>
5898
- </xsl:otherwise>
5899
- </xsl:choose>
5900
- </xsl:for-each>
5792
+ <xsl:call-template name="insertTableColumnWidth">
5793
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5794
+ </xsl:call-template>
5901
5795
  </xsl:otherwise>
5902
5796
  </xsl:choose>
5903
5797
 
@@ -6508,8 +6402,10 @@
6508
6402
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
6509
6403
  </xsl:variable>
6510
6404
 
6405
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
6406
+
6511
6407
  <xsl:choose>
6512
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
6408
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
6513
6409
 
6514
6410
  <fo:block margin-bottom="12pt" text-align="left">
6515
6411
 
@@ -6524,7 +6420,7 @@
6524
6420
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
6525
6421
  </fo:block>
6526
6422
 
6527
- </xsl:when>
6423
+ </xsl:when> <!-- END: only one component -->
6528
6424
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
6529
6425
  <fo:block margin-bottom="12pt" text-align="left">
6530
6426
 
@@ -6538,8 +6434,8 @@
6538
6434
  </xsl:variable>
6539
6435
  <xsl:value-of select="$title-where"/>
6540
6436
  </fo:block>
6541
- </xsl:when>
6542
- <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 -->
6543
6439
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
6544
6440
 
6545
6441
 
@@ -6552,11 +6448,11 @@
6552
6448
  </xsl:variable>
6553
6449
  <xsl:value-of select="$title-key"/>
6554
6450
  </fo:block>
6555
- </xsl:when>
6451
+ </xsl:when> <!-- END: definition list in a figure -->
6556
6452
  </xsl:choose>
6557
6453
 
6558
6454
  <!-- a few components -->
6559
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
6455
+ <xsl:if test="$onlyOneComponent = 'false'">
6560
6456
  <fo:block>
6561
6457
 
6562
6458
 
@@ -6595,21 +6491,28 @@
6595
6491
  <xsl:apply-templates mode="dl"/>
6596
6492
  </tbody>
6597
6493
  </xsl:variable>
6598
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
6494
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
6599
6495
  <xsl:variable name="colwidths">
6600
6496
  <xsl:call-template name="calculate-column-widths">
6601
6497
  <xsl:with-param name="cols-count" select="2"/>
6602
6498
  <xsl:with-param name="table" select="$html-table"/>
6603
6499
  </xsl:call-template>
6604
6500
  </xsl:variable>
6605
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
6501
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
6606
6502
  <xsl:variable name="maxlength_dt">
6607
6503
  <xsl:call-template name="getMaxLength_dt"/>
6608
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"/> -->
6609
6510
  <xsl:call-template name="setColumnWidth_dl">
6610
6511
  <xsl:with-param name="colwidths" select="$colwidths"/>
6611
6512
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
6513
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
6612
6514
  </xsl:call-template>
6515
+
6613
6516
  <fo:table-body>
6614
6517
  <xsl:apply-templates>
6615
6518
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -6618,12 +6521,13 @@
6618
6521
  </fo:table>
6619
6522
  </fo:block>
6620
6523
  </fo:block>
6621
- </xsl:if>
6524
+ </xsl:if> <!-- END: a few components -->
6622
6525
  </fo:block-container>
6623
6526
  </fo:block-container>
6624
6527
  </xsl:template><xsl:template name="setColumnWidth_dl">
6625
6528
  <xsl:param name="colwidths"/>
6626
6529
  <xsl:param name="maxlength_dt"/>
6530
+ <xsl:param name="isContainsKeepTogetherTag"/>
6627
6531
  <xsl:choose>
6628
6532
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
6629
6533
  <fo:table-column column-width="50%"/>
@@ -6631,6 +6535,11 @@
6631
6535
  </xsl:when>
6632
6536
  <xsl:otherwise>
6633
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>
6634
6543
  <!-- to set width check most wide chars like `W` -->
6635
6544
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
6636
6545
  <fo:table-column column-width="7%"/>
@@ -6661,20 +6570,25 @@
6661
6570
  <fo:table-column column-width="60%"/>
6662
6571
  </xsl:when>
6663
6572
  <xsl:otherwise>
6664
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
6665
- <xsl:choose>
6666
- <xsl:when test=". = 1 or . = 0">
6667
- <fo:table-column column-width="proportional-column-width(2)"/>
6668
- </xsl:when>
6669
- <xsl:otherwise>
6670
- <fo:table-column column-width="proportional-column-width({.})"/>
6671
- </xsl:otherwise>
6672
- </xsl:choose>
6673
- </xsl:for-each>
6573
+ <xsl:call-template name="insertTableColumnWidth">
6574
+ <xsl:with-param name="colwidths" select="$colwidths"/>
6575
+ </xsl:call-template>
6674
6576
  </xsl:otherwise>
6675
6577
  </xsl:choose>
6676
6578
  </xsl:otherwise>
6677
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>
6678
6592
  </xsl:template><xsl:template name="getMaxLength_dt">
6679
6593
  <xsl:variable name="lengths">
6680
6594
  <xsl:for-each select="*[local-name()='dt']">
@@ -6698,7 +6612,6 @@
6698
6612
  <xsl:value-of select="$maxLength"/>
6699
6613
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
6700
6614
  <xsl:param name="key_iso"/>
6701
-
6702
6615
  <!-- <tr>
6703
6616
  <td>NOTE</td>
6704
6617
  <td>
@@ -6706,18 +6619,30 @@
6706
6619
  </td>
6707
6620
  </tr>
6708
6621
  -->
6709
- <fo:table-row>
6622
+ <!-- OLD Variant -->
6623
+ <!-- <fo:table-row>
6710
6624
  <fo:table-cell>
6711
6625
  <fo:block margin-top="6pt">
6712
6626
  <xsl:if test="normalize-space($key_iso) = 'true'">
6713
6627
  <xsl:attribute name="margin-top">0</xsl:attribute>
6714
6628
  </xsl:if>
6715
- <xsl:apply-templates select="*[local-name() = 'name']"/>
6629
+ <xsl:apply-templates select="*[local-name() = 'name']" />
6716
6630
  </fo:block>
6717
6631
  </fo:table-cell>
6718
6632
  <fo:table-cell>
6719
6633
  <fo:block>
6720
- <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"/>
6721
6646
  </fo:block>
6722
6647
  </fo:table-cell>
6723
6648
  </fo:table-row>
@@ -6819,13 +6744,15 @@
6819
6744
  <xsl:choose>
6820
6745
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
6821
6746
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
6822
- <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>
6823
6748
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
6824
6749
  </xsl:choose>
6825
6750
  </xsl:attribute>
6826
6751
  </xsl:if>
6827
6752
  <xsl:apply-templates/>
6828
6753
  </fo:inline>
6754
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
6755
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
6829
6756
  </xsl:template><xsl:template match="*[local-name()='underline']">
6830
6757
  <fo:inline text-decoration="underline">
6831
6758
  <xsl:apply-templates/>
@@ -6973,41 +6900,50 @@
6973
6900
  <fo:block break-after="page"/>
6974
6901
  <fo:block> </fo:block>
6975
6902
  <fo:block break-after="page"/>
6903
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
6904
+ <xsl:apply-templates/>
6976
6905
  </xsl:template><xsl:template name="tokenize">
6977
6906
  <xsl:param name="text"/>
6978
6907
  <xsl:param name="separator" select="' '"/>
6979
6908
  <xsl:choose>
6980
6909
  <xsl:when test="not(contains($text, $separator))">
6981
6910
  <word>
6982
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
6983
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
6984
6911
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
6985
- <xsl:variable name="len_str">
6986
- <xsl:choose>
6987
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
6988
- <xsl:value-of select="$len_str_tmp * 1.5"/>
6989
- </xsl:when>
6990
- <xsl:otherwise>
6991
- <xsl:value-of select="$len_str_tmp"/>
6992
- </xsl:otherwise>
6993
- </xsl:choose>
6994
- </xsl:variable>
6995
-
6996
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
6997
- <xsl:message>
6998
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
6999
- len_str=<xsl:value-of select="$len_str"/>
7000
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
7001
- </xsl:message>
7002
- </xsl:if> -->
7003
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
7004
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
7005
6912
  <xsl:choose>
7006
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
7007
- <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"/>
7008
6915
  </xsl:when>
7009
6916
  <xsl:otherwise>
7010
- <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>
7011
6947
  </xsl:otherwise>
7012
6948
  </xsl:choose>
7013
6949
  </word>
@@ -7282,81 +7218,125 @@
7282
7218
  <xsl:variable name="isDeleted" select="@deleted"/>
7283
7219
 
7284
7220
  <fo:inline xsl:use-attribute-sets="mathml-style">
7221
+
7285
7222
 
7286
7223
  <xsl:if test="ancestor::*[local-name()='table']">
7287
7224
  <xsl:attribute name="font-size">95%</xsl:attribute> <!-- base font in table is 10pt -->
7288
7225
  </xsl:if>
7289
7226
 
7290
7227
 
7228
+
7229
+
7291
7230
  <xsl:call-template name="setTrackChangesStyles">
7292
7231
  <xsl:with-param name="isAdded" select="$isAdded"/>
7293
7232
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
7294
7233
  </xsl:call-template>
7295
7234
 
7296
- <!-- insert helper tag -->
7297
- <xsl:if test="$add_math_as_text = 'true'">
7298
- <fo:inline color="white" font-size="1pt" font-style="normal" font-weight="normal">​</fo:inline> <!-- zero width space -->
7299
- </xsl:if>
7300
-
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>
7301
7241
 
7302
- <xsl:variable name="mathml">
7303
- <xsl:apply-templates select="." mode="mathml"/>
7242
+ <xsl:variable name="mathml_content">
7243
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
7304
7244
  </xsl:variable>
7305
- <fo:instream-foreign-object fox:alt-text="Math">
7306
7245
 
7307
-
7308
- <xsl:if test="local-name(../..) = 'formula'">
7309
- <xsl:attribute name="width">95%</xsl:attribute>
7310
- <xsl:attribute name="content-height">100%</xsl:attribute>
7311
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7312
- <xsl:attribute name="scaling">uniform</xsl:attribute>
7313
- </xsl:if>
7314
-
7315
- <xsl:if test="$add_math_as_text = 'true'">
7316
- <!-- <xsl:variable name="comment_text" select="following-sibling::node()[1][self::comment()]"/> -->
7317
- <xsl:variable name="comment_text" select="normalize-space(translate(.,' ⁢',' '))"/>
7318
- <xsl:if test="normalize-space($comment_text) != ''">
7319
- <!-- put Mathin Alternate Text -->
7320
- <xsl:attribute name="fox:alt-text">
7321
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7322
- </xsl:attribute>
7323
- </xsl:if>
7324
- </xsl:if>
7325
-
7326
-
7327
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
7328
- <xsl:variable name="comment_text_">
7246
+
7247
+ <xsl:variable name="filename" select="xalan:nodeset($mathml_attachments)//attachment[. = $mathml_content]/@filename"/>
7329
7248
  <xsl:choose>
7330
- <xsl:when test="normalize-space($comment_text_following) != ''">
7331
- <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>
7332
7266
  </xsl:when>
7333
7267
  <xsl:otherwise>
7334
- <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>
7335
7271
  </xsl:otherwise>
7336
7272
  </xsl:choose>
7337
- </xsl:variable>
7338
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
7273
+ <!-- end BSI -->
7339
7274
 
7340
- <xsl:if test="normalize-space($comment_text) != ''">
7341
- <!-- put Mathin Alternate Text -->
7342
- <xsl:attribute name="fox:alt-text">
7343
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7344
- </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>
7345
7315
  </xsl:if>
7346
-
7347
- <xsl:variable name="mathml_content">
7348
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
7349
- </xsl:variable>
7350
- <!-- put MathML in Actual Text -->
7351
- <xsl:attribute name="fox:actual-text">
7352
- <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_"/>
7353
7333
  </xsl:attribute>
7354
-
7355
-
7356
-
7357
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
7358
- </fo:instream-foreign-object>
7359
- </fo:inline>
7334
+ </xsl:if>
7335
+ <!-- </xsl:if> -->
7336
+
7337
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
7338
+
7339
+ </fo:instream-foreign-object>
7360
7340
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
7361
7341
  <!-- <xsl:text>a+b</xsl:text> -->
7362
7342
  <xsl:text>&lt;</xsl:text>
@@ -7387,7 +7367,9 @@
7387
7367
  <!-- replace start and end spaces to non-break space -->
7388
7368
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
7389
7369
  </xsl:copy>
7390
- </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">
7391
7373
  <xsl:variable name="target">
7392
7374
  <xsl:choose>
7393
7375
  <xsl:when test="@updatetype = 'true'">
@@ -7998,18 +7980,33 @@
7998
7980
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
7999
7981
  <xsl:copy>
8000
7982
  <xsl:apply-templates select="@*" mode="svg_update"/>
8001
- <xsl:variable name="viewbox">
7983
+ <xsl:variable name="viewbox_">
8002
7984
  <xsl:call-template name="split">
8003
7985
  <xsl:with-param name="pText" select="@viewBox"/>
8004
7986
  <xsl:with-param name="sep" select="' '"/>
8005
7987
  </xsl:call-template>
8006
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
+
8007
7993
  <xsl:attribute name="width">
8008
- <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>
8009
8000
  </xsl:attribute>
8010
8001
  <xsl:attribute name="height">
8011
- <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>
8012
8008
  </xsl:attribute>
8009
+
8013
8010
  <xsl:apply-templates mode="svg_update"/>
8014
8011
  </xsl:copy>
8015
8012
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -8204,7 +8201,11 @@
8204
8201
  <xsl:apply-templates mode="bookmarks"/>
8205
8202
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
8206
8203
  <xsl:apply-templates select="."/>
8207
- </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">
8208
8209
  <xsl:apply-templates mode="bookmarks"/>
8209
8210
  </xsl:template><xsl:template name="addBookmarks">
8210
8211
  <xsl:param name="contents"/>
@@ -8500,7 +8501,9 @@
8500
8501
  <xsl:apply-templates/>
8501
8502
  </xsl:otherwise>
8502
8503
  </xsl:choose>
8503
- </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">
8504
8507
  <xsl:text> </xsl:text>
8505
8508
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
8506
8509
  <xsl:copy>
@@ -8531,9 +8534,22 @@
8531
8534
  </xsl:when>
8532
8535
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
8533
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"/>
8534
8541
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
8535
8542
 
8536
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
+
8537
8553
  <xsl:copy-of select="@id"/>
8538
8554
 
8539
8555
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -9011,39 +9027,67 @@
9011
9027
  </xsl:otherwise>
9012
9028
  </xsl:choose>
9013
9029
  </xsl:template><xsl:template match="*[local-name() = 'example']">
9014
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
9015
-
9030
+
9031
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
9032
+
9016
9033
 
9034
+
9017
9035
  <xsl:variable name="fo_element">
9018
- <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>
9019
9037
  block
9020
9038
  </xsl:variable>
9021
9039
 
9022
- <!-- display 'EXAMPLE' -->
9023
- <xsl:apply-templates select="*[local-name()='name']">
9024
- <xsl:with-param name="fo_element" select="$fo_element"/>
9025
- </xsl:apply-templates>
9040
+ <fo:block-container margin-left="0mm">
9026
9041
 
9027
- <xsl:choose>
9028
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
9029
- <fo:block-container xsl:use-attribute-sets="example-body-style">
9030
- <fo:block-container margin-left="0mm" margin-right="0mm">
9031
- <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']">
9032
9049
  <xsl:with-param name="fo_element" select="$fo_element"/>
9033
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>
9034
9059
  </fo:block-container>
9035
- </fo:block-container>
9036
- </xsl:when>
9037
- <xsl:otherwise>
9038
- <fo:inline>
9039
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9040
- <xsl:with-param name="fo_element" select="$fo_element"/>
9041
- </xsl:apply-templates>
9042
- </fo:inline>
9043
- </xsl:otherwise>
9044
- </xsl:choose>
9045
-
9046
- </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>
9047
9091
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
9048
9092
  <xsl:param name="fo_element">block</xsl:param>
9049
9093
 
@@ -9075,10 +9119,16 @@
9075
9119
  </xsl:variable>
9076
9120
  <xsl:choose>
9077
9121
  <xsl:when test="starts-with(normalize-space($element), 'block')">
9078
- <fo:block xsl:use-attribute-sets="example-p-style">
9079
-
9080
- <xsl:apply-templates/>
9081
- </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>
9082
9132
  </xsl:when>
9083
9133
  <xsl:otherwise>
9084
9134
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -9266,7 +9316,16 @@
9266
9316
  </fo:inline>
9267
9317
  </xsl:when>
9268
9318
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
9269
- <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
+
9270
9329
  </xsl:otherwise>
9271
9330
  </xsl:choose>
9272
9331
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -9439,10 +9498,24 @@
9439
9498
 
9440
9499
  </fo:block>
9441
9500
  <xsl:apply-templates/>
9442
- </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 -->
9443
9502
  <!-- comment 2019-11-29 -->
9444
9503
  <!-- <fo:block font-weight="bold">Review:</fo:block>
9445
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
+
9446
9519
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
9447
9520
  <!-- 0xA0 to space replacement -->
9448
9521
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -9803,7 +9876,10 @@
9803
9876
  <!-- to split by '_' and other chars -->
9804
9877
  <xsl:call-template name="add-zero-spaces-java"/>
9805
9878
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
9806
- <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>
9807
9883
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
9808
9884
  <!-- <row>
9809
9885
  <date>05-07-2013</date>
@@ -10363,6 +10439,120 @@
10363
10439
  <xsl:apply-templates select="." mode="update_xml_step1"/>
10364
10440
  </xsl:for-each>
10365
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>
10366
10556
  </xsl:template><xsl:template name="convertDate">
10367
10557
  <xsl:param name="date"/>
10368
10558
  <xsl:param name="format" select="'short'"/>