metanorma-ribose 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,20 +41,32 @@
41
41
  <xsl:value-of select="/rsd:rsd-standard/rsd:bibdata/rsd:docidentifier[@type = 'rsd' or @type = 'Ribose']"/>
42
42
  <xsl:text>:</xsl:text>
43
43
  <xsl:value-of select="$copyright_year"/>
44
- <xsl:variable name="edition" select="normalize-space(/rsd:rsd-standard/rsd:bibdata/rsd:edition)"/>
44
+
45
+ <xsl:variable name="edition" select="normalize-space(/rsd:rsd-standard/rsd:bibdata/rsd:edition[normalize-space(@language) = ''])"/>
45
46
  <xsl:if test="$edition != ''">
46
- <xsl:variable name="title-edition">
47
- <xsl:call-template name="getTitle">
48
- <xsl:with-param name="name" select="'title-edition'"/>
47
+ <xsl:variable name="title-version">
48
+ <xsl:call-template name="capitalize">
49
+ <xsl:with-param name="str">
50
+ <xsl:call-template name="getLocalizedString">
51
+ <xsl:with-param name="key">version</xsl:with-param>
52
+ </xsl:call-template>
53
+ </xsl:with-param>
49
54
  </xsl:call-template>
50
55
  </xsl:variable>
51
- <xsl:text>, </xsl:text><xsl:value-of select="$title-edition"/><xsl:text> </xsl:text><xsl:value-of select="$edition"/>
56
+ <xsl:text>, </xsl:text><xsl:value-of select="$title-version"/><xsl:text> </xsl:text><xsl:value-of select="$edition"/>
52
57
  </xsl:if>
58
+
53
59
  </xsl:variable>
54
60
 
55
61
  <xsl:template match="/">
56
62
  <xsl:call-template name="namespaceCheck"/>
57
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
63
+ <fo:root xml:lang="{$lang}">
64
+ <xsl:variable name="root-style">
65
+ <root-style xsl:use-attribute-sets="root-style"/>
66
+ </xsl:variable>
67
+ <xsl:call-template name="insertRootStyle">
68
+ <xsl:with-param name="root-style" select="$root-style"/>
69
+ </xsl:call-template>
58
70
  <fo:layout-master-set>
59
71
 
60
72
  <!-- Cover page -->
@@ -608,18 +620,6 @@
608
620
  <!-- ============================= -->
609
621
  <!-- ============================= -->
610
622
 
611
- <xsl:template match="/rsd:rsd-standard/rsd:bibdata/rsd:edition">
612
- <fo:block margin-bottom="12pt">
613
- <xsl:variable name="title-edition">
614
- <xsl:call-template name="getTitle">
615
- <xsl:with-param name="name" select="'title-edition'"/>
616
- </xsl:call-template>
617
- </xsl:variable>
618
- <xsl:value-of select="$title-edition"/><xsl:text>: </xsl:text>
619
- <xsl:value-of select="."/><xsl:text> </xsl:text>
620
- </fo:block>
621
- </xsl:template>
622
-
623
623
 
624
624
  <xsl:template match="rsd:feedback-statement" priority="2">
625
625
  <fo:block-container border="1pt solid black" padding="1mm" padding-left="2mm">
@@ -1209,7 +1209,7 @@
1209
1209
 
1210
1210
 
1211
1211
 
1212
- <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">
1212
+ <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">
1213
1213
  <xsl:call-template name="getLang"/>
1214
1214
  </xsl:variable><xsl:variable name="pageWidth_">
1215
1215
  215.9
@@ -1224,20 +1224,7 @@
1224
1224
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1225
1225
  22
1226
1226
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1227
-
1228
- <title-edition lang="en">
1229
-
1230
- <xsl:text>Version</xsl:text>
1231
-
1232
- </title-edition>
1233
-
1234
- <title-edition lang="fr">
1235
- <xsl:text>Édition </xsl:text>
1236
- </title-edition>
1237
1227
 
1238
- <title-edition lang="ru">
1239
- <xsl:text>Издание </xsl:text>
1240
- </title-edition>
1241
1228
 
1242
1229
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1243
1230
  <title-toc lang="en">
@@ -1316,7 +1303,7 @@
1316
1303
  </xsl:variable><xsl:variable name="bibdata">
1317
1304
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1318
1305
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1319
- </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">
1306
+ </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">
1320
1307
  <xsl:param name="name"/>
1321
1308
  <xsl:param name="lang"/>
1322
1309
  <xsl:variable name="lang_">
@@ -1361,7 +1348,30 @@
1361
1348
  <xsl:attribute name="color">rgb(88, 88, 90)</xsl:attribute>
1362
1349
 
1363
1350
 
1364
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
1351
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
1352
+ <xsl:param name="root-style"/>
1353
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1354
+
1355
+ <xsl:variable name="additional_fonts_">
1356
+ <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']">
1357
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1358
+ </xsl:for-each>
1359
+ </xsl:variable>
1360
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
1361
+
1362
+ <xsl:for-each select="$root-style_/root-style/@*">
1363
+ <xsl:choose>
1364
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
1365
+ <xsl:attribute name="{local-name()}">
1366
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
1367
+ </xsl:attribute>
1368
+ </xsl:when>
1369
+ <xsl:otherwise>
1370
+ <xsl:copy-of select="."/>
1371
+ </xsl:otherwise>
1372
+ </xsl:choose>
1373
+ </xsl:for-each>
1374
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
1365
1375
 
1366
1376
  </xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
1367
1377
 
@@ -1423,7 +1433,6 @@
1423
1433
 
1424
1434
 
1425
1435
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1426
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
1427
1436
 
1428
1437
  <xsl:attribute name="space-after">12pt</xsl:attribute>
1429
1438
 
@@ -1511,6 +1520,7 @@
1511
1520
 
1512
1521
 
1513
1522
 
1523
+
1514
1524
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
1515
1525
 
1516
1526
 
@@ -1909,15 +1919,15 @@
1909
1919
 
1910
1920
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1911
1921
 
1912
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1922
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1913
1923
 
1914
1924
 
1915
1925
 
1916
1926
 
1917
- <xsl:attribute name="font-weight">bold</xsl:attribute>
1918
- <xsl:attribute name="color"><xsl:value-of select="$color_blue"/></xsl:attribute>
1919
- <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
1920
-
1927
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
1928
+ <xsl:attribute name="color"><xsl:value-of select="$color_blue"/></xsl:attribute>
1929
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
1930
+
1921
1931
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1922
1932
  <xsl:attribute name="margin-left">12mm</xsl:attribute>
1923
1933
  <xsl:attribute name="margin-right">12mm</xsl:attribute>
@@ -2666,10 +2676,41 @@
2666
2676
  <xsl:sort select="@displayorder" data-type="number"/>
2667
2677
  <xsl:apply-templates select="."/>
2668
2678
  </xsl:for-each>
2669
- </xsl:template><xsl:template match="text()">
2670
- <xsl:value-of select="."/>
2679
+ </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">
2680
+
2681
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2682
+ <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))"/>
2683
+ <xsl:call-template name="replace_fo_inline_tags">
2684
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
2685
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
2686
+ <xsl:with-param name="text" select="$text"/>
2687
+ </xsl:call-template>
2688
+
2689
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
2690
+ <xsl:param name="tag_open"/>
2691
+ <xsl:param name="tag_close"/>
2692
+ <xsl:param name="text"/>
2693
+ <xsl:choose>
2694
+ <xsl:when test="contains($text, $tag_open)">
2695
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
2696
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
2697
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2698
+ <fo:inline keep-together.within-line="always">
2699
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2700
+ </fo:inline>
2701
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
2702
+ <xsl:call-template name="replace_fo_inline_tags">
2703
+ <xsl:with-param name="tag_open" select="$tag_open"/>
2704
+ <xsl:with-param name="tag_close" select="$tag_close"/>
2705
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2706
+ </xsl:call-template>
2707
+ </xsl:when>
2708
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
2709
+ </xsl:choose>
2671
2710
  </xsl:template><xsl:template match="*[local-name()='br']">
2672
2711
  <xsl:value-of select="$linebreak"/>
2712
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
2713
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
2673
2714
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
2674
2715
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
2675
2716
  <xsl:apply-templates/>
@@ -2740,8 +2781,23 @@
2740
2781
  </xsl:call-template>
2741
2782
 
2742
2783
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
2743
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
2744
- <xsl:call-template name="add-zero-spaces-java"/>
2784
+ <xsl:choose>
2785
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
2786
+ <xsl:value-of select="."/>
2787
+ </xsl:when>
2788
+ <xsl:otherwise>
2789
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
2790
+ </xsl:otherwise>
2791
+ </xsl:choose>
2792
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
2793
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
2794
+ <!-- <xsl:copy-of select="$text"/> -->
2795
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
2796
+ <xsl:choose>
2797
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
2798
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
2799
+ </xsl:choose>
2800
+ </xsl:for-each>
2745
2801
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
2746
2802
 
2747
2803
  <xsl:variable name="table-preamble">
@@ -2857,16 +2913,9 @@
2857
2913
  </xsl:for-each>
2858
2914
  </xsl:when>
2859
2915
  <xsl:otherwise>
2860
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2861
- <xsl:choose>
2862
- <xsl:when test=". = 1 or . = 0">
2863
- <fo:table-column column-width="proportional-column-width(2)"/>
2864
- </xsl:when>
2865
- <xsl:otherwise>
2866
- <fo:table-column column-width="proportional-column-width({.})"/>
2867
- </xsl:otherwise>
2868
- </xsl:choose>
2869
- </xsl:for-each>
2916
+ <xsl:call-template name="insertTableColumnWidth">
2917
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2918
+ </xsl:call-template>
2870
2919
  </xsl:otherwise>
2871
2920
  </xsl:choose>
2872
2921
 
@@ -3030,6 +3079,7 @@
3030
3079
  <xsl:with-param name="text" select="$td_text"/>
3031
3080
  </xsl:call-template>
3032
3081
  </xsl:variable>
3082
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3033
3083
  <xsl:call-template name="tokenize">
3034
3084
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3035
3085
  <!-- 2009 thinspace -->
@@ -3042,6 +3092,7 @@
3042
3092
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3043
3093
  </xsl:call-template>
3044
3094
  </xsl:variable>
3095
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3045
3096
  <width>
3046
3097
  <xsl:variable name="divider">
3047
3098
  <xsl:choose>
@@ -3074,6 +3125,10 @@
3074
3125
  <xsl:with-param name="table" select="$table"/>
3075
3126
  </xsl:call-template>
3076
3127
  </xsl:if>
3128
+ </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
3129
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3130
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3131
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3077
3132
  </xsl:template><xsl:template match="text()" mode="td_text">
3078
3133
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3079
3134
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -3175,16 +3230,9 @@
3175
3230
  </xsl:for-each>
3176
3231
  </xsl:when>
3177
3232
  <xsl:otherwise>
3178
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3179
- <xsl:choose>
3180
- <xsl:when test=". = 1 or . = 0">
3181
- <fo:table-column column-width="proportional-column-width(2)"/>
3182
- </xsl:when>
3183
- <xsl:otherwise>
3184
- <fo:table-column column-width="proportional-column-width({.})"/>
3185
- </xsl:otherwise>
3186
- </xsl:choose>
3187
- </xsl:for-each>
3233
+ <xsl:call-template name="insertTableColumnWidth">
3234
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3235
+ </xsl:call-template>
3188
3236
  </xsl:otherwise>
3189
3237
  </xsl:choose>
3190
3238
 
@@ -3730,8 +3778,10 @@
3730
3778
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
3731
3779
  </xsl:variable>
3732
3780
 
3781
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
3782
+
3733
3783
  <xsl:choose>
3734
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
3784
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
3735
3785
 
3736
3786
  <fo:block margin-bottom="12pt" text-align="left">
3737
3787
 
@@ -3746,7 +3796,7 @@
3746
3796
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3747
3797
  </fo:block>
3748
3798
 
3749
- </xsl:when>
3799
+ </xsl:when> <!-- END: only one component -->
3750
3800
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3751
3801
  <fo:block margin-bottom="12pt" text-align="left">
3752
3802
 
@@ -3760,8 +3810,8 @@
3760
3810
  </xsl:variable>
3761
3811
  <xsl:value-of select="$title-where"/>
3762
3812
  </fo:block>
3763
- </xsl:when>
3764
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
3813
+ </xsl:when> <!-- END: a few components -->
3814
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
3765
3815
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
3766
3816
 
3767
3817
 
@@ -3777,11 +3827,11 @@
3777
3827
  </xsl:variable>
3778
3828
  <xsl:value-of select="$title-key"/>
3779
3829
  </fo:block>
3780
- </xsl:when>
3830
+ </xsl:when> <!-- END: definition list in a figure -->
3781
3831
  </xsl:choose>
3782
3832
 
3783
3833
  <!-- a few components -->
3784
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
3834
+ <xsl:if test="$onlyOneComponent = 'false'">
3785
3835
  <fo:block>
3786
3836
 
3787
3837
 
@@ -3820,21 +3870,28 @@
3820
3870
  <xsl:apply-templates mode="dl"/>
3821
3871
  </tbody>
3822
3872
  </xsl:variable>
3823
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
3873
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
3824
3874
  <xsl:variable name="colwidths">
3825
3875
  <xsl:call-template name="calculate-column-widths">
3826
3876
  <xsl:with-param name="cols-count" select="2"/>
3827
3877
  <xsl:with-param name="table" select="$html-table"/>
3828
3878
  </xsl:call-template>
3829
3879
  </xsl:variable>
3830
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3880
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
3831
3881
  <xsl:variable name="maxlength_dt">
3832
3882
  <xsl:call-template name="getMaxLength_dt"/>
3833
3883
  </xsl:variable>
3884
+ <xsl:variable name="isContainsKeepTogetherTag_">
3885
+ false
3886
+ </xsl:variable>
3887
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
3888
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
3834
3889
  <xsl:call-template name="setColumnWidth_dl">
3835
3890
  <xsl:with-param name="colwidths" select="$colwidths"/>
3836
3891
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3892
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
3837
3893
  </xsl:call-template>
3894
+
3838
3895
  <fo:table-body>
3839
3896
  <xsl:apply-templates>
3840
3897
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -3843,12 +3900,13 @@
3843
3900
  </fo:table>
3844
3901
  </fo:block>
3845
3902
  </fo:block>
3846
- </xsl:if>
3903
+ </xsl:if> <!-- END: a few components -->
3847
3904
  </fo:block-container>
3848
3905
  </fo:block-container>
3849
3906
  </xsl:template><xsl:template name="setColumnWidth_dl">
3850
3907
  <xsl:param name="colwidths"/>
3851
3908
  <xsl:param name="maxlength_dt"/>
3909
+ <xsl:param name="isContainsKeepTogetherTag"/>
3852
3910
  <xsl:choose>
3853
3911
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
3854
3912
  <fo:table-column column-width="50%"/>
@@ -3856,6 +3914,11 @@
3856
3914
  </xsl:when>
3857
3915
  <xsl:otherwise>
3858
3916
  <xsl:choose>
3917
+ <xsl:when test="$isContainsKeepTogetherTag">
3918
+ <xsl:call-template name="insertTableColumnWidth">
3919
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3920
+ </xsl:call-template>
3921
+ </xsl:when>
3859
3922
  <!-- to set width check most wide chars like `W` -->
3860
3923
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
3861
3924
  <fo:table-column column-width="7%"/>
@@ -3886,20 +3949,25 @@
3886
3949
  <fo:table-column column-width="60%"/>
3887
3950
  </xsl:when>
3888
3951
  <xsl:otherwise>
3889
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3890
- <xsl:choose>
3891
- <xsl:when test=". = 1 or . = 0">
3892
- <fo:table-column column-width="proportional-column-width(2)"/>
3893
- </xsl:when>
3894
- <xsl:otherwise>
3895
- <fo:table-column column-width="proportional-column-width({.})"/>
3896
- </xsl:otherwise>
3897
- </xsl:choose>
3898
- </xsl:for-each>
3952
+ <xsl:call-template name="insertTableColumnWidth">
3953
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3954
+ </xsl:call-template>
3899
3955
  </xsl:otherwise>
3900
3956
  </xsl:choose>
3901
3957
  </xsl:otherwise>
3902
3958
  </xsl:choose>
3959
+ </xsl:template><xsl:template name="insertTableColumnWidth">
3960
+ <xsl:param name="colwidths"/>
3961
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
3962
+ <xsl:choose>
3963
+ <xsl:when test=". = 1 or . = 0">
3964
+ <fo:table-column column-width="proportional-column-width(2)"/>
3965
+ </xsl:when>
3966
+ <xsl:otherwise>
3967
+ <fo:table-column column-width="proportional-column-width({.})"/>
3968
+ </xsl:otherwise>
3969
+ </xsl:choose>
3970
+ </xsl:for-each>
3903
3971
  </xsl:template><xsl:template name="getMaxLength_dt">
3904
3972
  <xsl:variable name="lengths">
3905
3973
  <xsl:for-each select="*[local-name()='dt']">
@@ -3923,7 +3991,6 @@
3923
3991
  <xsl:value-of select="$maxLength"/>
3924
3992
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
3925
3993
  <xsl:param name="key_iso"/>
3926
-
3927
3994
  <!-- <tr>
3928
3995
  <td>NOTE</td>
3929
3996
  <td>
@@ -3931,18 +3998,30 @@
3931
3998
  </td>
3932
3999
  </tr>
3933
4000
  -->
3934
- <fo:table-row>
4001
+ <!-- OLD Variant -->
4002
+ <!-- <fo:table-row>
3935
4003
  <fo:table-cell>
3936
4004
  <fo:block margin-top="6pt">
3937
4005
  <xsl:if test="normalize-space($key_iso) = 'true'">
3938
4006
  <xsl:attribute name="margin-top">0</xsl:attribute>
3939
4007
  </xsl:if>
3940
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4008
+ <xsl:apply-templates select="*[local-name() = 'name']" />
3941
4009
  </fo:block>
3942
4010
  </fo:table-cell>
3943
4011
  <fo:table-cell>
3944
4012
  <fo:block>
3945
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4013
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4014
+ </fo:block>
4015
+ </fo:table-cell>
4016
+ </fo:table-row> -->
4017
+ <!-- <tr>
4018
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4019
+ </tr>
4020
+ -->
4021
+ <fo:table-row>
4022
+ <fo:table-cell number-columns-spanned="2">
4023
+ <fo:block>
4024
+ <xsl:call-template name="note"/>
3946
4025
  </fo:block>
3947
4026
  </fo:table-cell>
3948
4027
  </fo:table-row>
@@ -4054,13 +4133,15 @@
4054
4133
  <xsl:choose>
4055
4134
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4056
4135
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4057
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4136
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4058
4137
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4059
4138
  </xsl:choose>
4060
4139
  </xsl:attribute>
4061
4140
  </xsl:if>
4062
4141
  <xsl:apply-templates/>
4063
4142
  </fo:inline>
4143
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
4144
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4064
4145
  </xsl:template><xsl:template match="*[local-name()='underline']">
4065
4146
  <fo:inline text-decoration="underline">
4066
4147
  <xsl:apply-templates/>
@@ -4208,41 +4289,50 @@
4208
4289
  <fo:block break-after="page"/>
4209
4290
  <fo:block> </fo:block>
4210
4291
  <fo:block break-after="page"/>
4292
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
4293
+ <xsl:apply-templates/>
4211
4294
  </xsl:template><xsl:template name="tokenize">
4212
4295
  <xsl:param name="text"/>
4213
4296
  <xsl:param name="separator" select="' '"/>
4214
4297
  <xsl:choose>
4215
4298
  <xsl:when test="not(contains($text, $separator))">
4216
4299
  <word>
4217
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4218
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4219
4300
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4220
- <xsl:variable name="len_str">
4221
- <xsl:choose>
4222
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4223
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4224
- </xsl:when>
4225
- <xsl:otherwise>
4226
- <xsl:value-of select="$len_str_tmp"/>
4227
- </xsl:otherwise>
4228
- </xsl:choose>
4229
- </xsl:variable>
4230
-
4231
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4232
- <xsl:message>
4233
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4234
- len_str=<xsl:value-of select="$len_str"/>
4235
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4236
- </xsl:message>
4237
- </xsl:if> -->
4238
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4239
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4240
4301
  <xsl:choose>
4241
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4242
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4302
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
4303
+ <xsl:value-of select="$len_str_tmp"/>
4243
4304
  </xsl:when>
4244
4305
  <xsl:otherwise>
4245
- <xsl:value-of select="$len_str"/>
4306
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4307
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4308
+ <xsl:variable name="len_str">
4309
+ <xsl:choose>
4310
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4311
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
4312
+ </xsl:when>
4313
+ <xsl:otherwise>
4314
+ <xsl:value-of select="$len_str_tmp"/>
4315
+ </xsl:otherwise>
4316
+ </xsl:choose>
4317
+ </xsl:variable>
4318
+
4319
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4320
+ <xsl:message>
4321
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4322
+ len_str=<xsl:value-of select="$len_str"/>
4323
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4324
+ </xsl:message>
4325
+ </xsl:if> -->
4326
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4327
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
4328
+ <xsl:choose>
4329
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4330
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4331
+ </xsl:when>
4332
+ <xsl:otherwise>
4333
+ <xsl:value-of select="$len_str"/>
4334
+ </xsl:otherwise>
4335
+ </xsl:choose>
4246
4336
  </xsl:otherwise>
4247
4337
  </xsl:choose>
4248
4338
  </word>
@@ -4328,24 +4418,28 @@
4328
4418
  </xsl:template><xsl:template name="add-zero-spaces-equal">
4329
4419
  <xsl:param name="text" select="."/>
4330
4420
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
4421
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
4331
4422
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
4423
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
4332
4424
  <xsl:variable name="zero-space">​</xsl:variable>
4333
4425
  <xsl:choose>
4334
4426
  <xsl:when test="contains($text, $zero-space-after-equals)">
4335
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4427
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
4336
4428
  <xsl:value-of select="$zero-space-after-equals"/>
4337
4429
  <xsl:value-of select="$zero-space"/>
4338
4430
  <xsl:call-template name="add-zero-spaces-equal">
4339
4431
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
4340
- </xsl:call-template>
4432
+ </xsl:call-template> -->
4433
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
4341
4434
  </xsl:when>
4342
4435
  <xsl:when test="contains($text, $zero-space-after-equal)">
4343
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4436
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
4344
4437
  <xsl:value-of select="$zero-space-after-equal"/>
4345
4438
  <xsl:value-of select="$zero-space"/>
4346
4439
  <xsl:call-template name="add-zero-spaces-equal">
4347
4440
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
4348
- </xsl:call-template>
4441
+ </xsl:call-template> -->
4442
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
4349
4443
  </xsl:when>
4350
4444
  <xsl:otherwise>
4351
4445
  <xsl:value-of select="$text"/>
@@ -4513,6 +4607,9 @@
4513
4607
  <xsl:variable name="isDeleted" select="@deleted"/>
4514
4608
 
4515
4609
  <fo:inline xsl:use-attribute-sets="mathml-style">
4610
+
4611
+
4612
+
4516
4613
 
4517
4614
 
4518
4615
  <xsl:call-template name="setTrackChangesStyles">
@@ -4520,48 +4617,80 @@
4520
4617
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
4521
4618
  </xsl:call-template>
4522
4619
 
4620
+ <xsl:if test="$add_math_as_text = 'true'">
4621
+ <!-- insert helper tag -->
4622
+ <!-- set unique font-size (fiction) -->
4623
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
4624
+ <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 -->
4625
+ </xsl:if>
4523
4626
 
4524
-
4525
- <xsl:variable name="mathml">
4526
- <xsl:apply-templates select="." mode="mathml"/>
4627
+ <xsl:variable name="mathml_content">
4628
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
4527
4629
  </xsl:variable>
4528
- <fo:instream-foreign-object fox:alt-text="Math">
4529
4630
 
4631
+
4632
+ <xsl:call-template name="mathml_instream_object">
4633
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
4634
+ </xsl:call-template>
4530
4635
 
4531
-
4532
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
4533
- <xsl:variable name="comment_text_">
4534
- <xsl:choose>
4535
- <xsl:when test="normalize-space($comment_text_following) != ''">
4536
- <xsl:value-of select="$comment_text_following"/>
4537
- </xsl:when>
4538
- <xsl:otherwise>
4539
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
4540
- </xsl:otherwise>
4541
- </xsl:choose>
4542
- </xsl:variable>
4543
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
4544
-
4545
- <xsl:if test="normalize-space($comment_text) != ''">
4546
- <!-- put Mathin Alternate Text -->
4547
- <xsl:attribute name="fox:alt-text">
4548
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
4549
- </xsl:attribute>
4550
- </xsl:if>
4551
-
4552
- <xsl:variable name="mathml_content">
4553
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
4554
- </xsl:variable>
4555
- <!-- put MathML in Actual Text -->
4556
- <xsl:attribute name="fox:actual-text">
4557
- <xsl:value-of select="$mathml_content"/>
4558
- </xsl:attribute>
4559
-
4560
-
4561
-
4562
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
4563
- </fo:instream-foreign-object>
4636
+
4564
4637
  </fo:inline>
4638
+ </xsl:template><xsl:template name="getMathml_comment_text">
4639
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
4640
+ <xsl:variable name="comment_text_">
4641
+ <xsl:choose>
4642
+ <xsl:when test="normalize-space($comment_text_following) != ''">
4643
+ <xsl:value-of select="$comment_text_following"/>
4644
+ </xsl:when>
4645
+ <xsl:otherwise>
4646
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
4647
+ </xsl:otherwise>
4648
+ </xsl:choose>
4649
+ </xsl:variable>
4650
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
4651
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
4652
+ <xsl:value-of select="$comment_text"/>
4653
+ </xsl:template><xsl:template name="mathml_instream_object">
4654
+ <xsl:param name="comment_text"/>
4655
+ <xsl:param name="mathml_content"/>
4656
+
4657
+ <xsl:variable name="comment_text_">
4658
+ <xsl:choose>
4659
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
4660
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
4661
+ </xsl:choose>
4662
+ </xsl:variable>
4663
+
4664
+ <xsl:variable name="mathml">
4665
+ <xsl:apply-templates select="." mode="mathml"/>
4666
+ </xsl:variable>
4667
+
4668
+ <fo:instream-foreign-object fox:alt-text="Math">
4669
+
4670
+
4671
+
4672
+
4673
+
4674
+
4675
+
4676
+ <!-- put MathML in Actual Text -->
4677
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
4678
+ <xsl:attribute name="fox:actual-text">
4679
+ <xsl:value-of select="$mathml_content"/>
4680
+ </xsl:attribute>
4681
+
4682
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
4683
+ <xsl:if test="normalize-space($comment_text_) != ''">
4684
+ <!-- put Mathin Alternate Text -->
4685
+ <xsl:attribute name="fox:alt-text">
4686
+ <xsl:value-of select="$comment_text_"/>
4687
+ </xsl:attribute>
4688
+ </xsl:if>
4689
+ <!-- </xsl:if> -->
4690
+
4691
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
4692
+
4693
+ </fo:instream-foreign-object>
4565
4694
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
4566
4695
  <!-- <xsl:text>a+b</xsl:text> -->
4567
4696
  <xsl:text>&lt;</xsl:text>
@@ -4592,7 +4721,9 @@
4592
4721
  <!-- replace start and end spaces to non-break space -->
4593
4722
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4594
4723
  </xsl:copy>
4595
- </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">
4724
+ </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">
4725
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
4726
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
4596
4727
  <xsl:variable name="target">
4597
4728
  <xsl:choose>
4598
4729
  <xsl:when test="@updatetype = 'true'">
@@ -4832,7 +4963,12 @@
4832
4963
 
4833
4964
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
4834
4965
 
4966
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
4967
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
4968
+ </xsl:if>
4969
+
4835
4970
 
4971
+
4836
4972
 
4837
4973
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4838
4974
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -5193,18 +5329,33 @@
5193
5329
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5194
5330
  <xsl:copy>
5195
5331
  <xsl:apply-templates select="@*" mode="svg_update"/>
5196
- <xsl:variable name="viewbox">
5332
+ <xsl:variable name="viewbox_">
5197
5333
  <xsl:call-template name="split">
5198
5334
  <xsl:with-param name="pText" select="@viewBox"/>
5199
5335
  <xsl:with-param name="sep" select="' '"/>
5200
5336
  </xsl:call-template>
5201
5337
  </xsl:variable>
5338
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
5339
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
5340
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
5341
+
5202
5342
  <xsl:attribute name="width">
5203
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
5343
+ <xsl:choose>
5344
+ <xsl:when test="$width != ''">
5345
+ <xsl:value-of select="round($width)"/>
5346
+ </xsl:when>
5347
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
5348
+ </xsl:choose>
5204
5349
  </xsl:attribute>
5205
5350
  <xsl:attribute name="height">
5206
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
5351
+ <xsl:choose>
5352
+ <xsl:when test="$height != ''">
5353
+ <xsl:value-of select="round($height)"/>
5354
+ </xsl:when>
5355
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
5356
+ </xsl:choose>
5207
5357
  </xsl:attribute>
5358
+
5208
5359
  <xsl:apply-templates mode="svg_update"/>
5209
5360
  </xsl:copy>
5210
5361
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -5399,7 +5550,11 @@
5399
5550
  <xsl:apply-templates mode="bookmarks"/>
5400
5551
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
5401
5552
  <xsl:apply-templates select="."/>
5402
- </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">
5553
+ </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">
5554
+ <xsl:apply-templates mode="contents"/>
5555
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
5556
+ <xsl:apply-templates mode="bookmarks"/>
5557
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
5403
5558
  <xsl:apply-templates mode="bookmarks"/>
5404
5559
  </xsl:template><xsl:template name="addBookmarks">
5405
5560
  <xsl:param name="contents"/>
@@ -5681,7 +5836,9 @@
5681
5836
  <xsl:apply-templates/>
5682
5837
  </xsl:otherwise>
5683
5838
  </xsl:choose>
5684
- </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">
5839
+ </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">
5840
+ <xsl:value-of select="."/>
5841
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
5685
5842
  <xsl:text> </xsl:text>
5686
5843
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
5687
5844
  <xsl:copy>
@@ -5712,9 +5869,22 @@
5712
5869
  </xsl:when>
5713
5870
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
5714
5871
  </xsl:choose>
5872
+ </xsl:template><xsl:template match="text()" mode="contents_item">
5873
+ <xsl:call-template name="keep_together_standard_number"/>
5874
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
5875
+ <xsl:apply-templates mode="contents_item"/>
5715
5876
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
5716
5877
 
5717
5878
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
5879
+
5880
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
5881
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
5882
+ </xsl:if>
5883
+
5884
+ <xsl:if test="ancestor::*[local-name() = 'example']">
5885
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
5886
+ </xsl:if>
5887
+
5718
5888
  <xsl:copy-of select="@id"/>
5719
5889
 
5720
5890
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -5832,17 +6002,15 @@
5832
6002
 
5833
6003
  <!-- split text by zero-width space -->
5834
6004
  <xsl:variable name="text_step4">
5835
- <xsl:call-template name="split">
6005
+ <xsl:call-template name="split_for_interspers">
5836
6006
  <xsl:with-param name="pText" select="$text_step3"/>
5837
6007
  <xsl:with-param name="sep" select="$zero_width_space"/>
5838
- <xsl:with-param name="normalize-space">false</xsl:with-param>
5839
- <xsl:with-param name="keep_sep">true</xsl:with-param>
5840
6008
  </xsl:call-template>
5841
6009
  </xsl:variable>
5842
6010
 
5843
- <xsl:for-each select="xalan:nodeset($text_step4)/item">
6011
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
5844
6012
  <xsl:choose>
5845
- <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6013
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5846
6014
  <xsl:call-template name="interspers">
5847
6015
  <xsl:with-param name="str" select="."/>
5848
6016
  </xsl:call-template>
@@ -5853,6 +6021,30 @@
5853
6021
  </xsl:choose>
5854
6022
  </xsl:for-each>
5855
6023
 
6024
+ </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">
6025
+ <xsl:param name="pText" select="."/>
6026
+ <xsl:param name="sep" select="','"/>
6027
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
6028
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
6029
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
6030
+ <xsl:call-template name="replace_tag_interspers">
6031
+ <xsl:with-param name="text" select="$text"/>
6032
+ </xsl:call-template>
6033
+ </xsl:template><xsl:template name="replace_tag_interspers">
6034
+ <xsl:param name="text"/>
6035
+ <xsl:choose>
6036
+ <xsl:when test="contains($text, $interspers_tag_open)">
6037
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
6038
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
6039
+ <interspers>
6040
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
6041
+ </interspers>
6042
+ <xsl:call-template name="replace_tag_interspers">
6043
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
6044
+ </xsl:call-template>
6045
+ </xsl:when>
6046
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
6047
+ </xsl:choose>
5856
6048
  </xsl:template><xsl:template name="interspers">
5857
6049
  <xsl:param name="str"/>
5858
6050
  <xsl:param name="char" select="$zero_width_space"/>
@@ -6188,44 +6380,72 @@
6188
6380
  </xsl:otherwise>
6189
6381
  </xsl:choose>
6190
6382
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6191
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6383
+
6384
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
6385
+
6192
6386
 
6193
6387
  <xsl:if test="ancestor::rsd:ul or ancestor::rsd:ol">
6194
6388
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
6195
6389
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
6196
6390
  </xsl:if>
6197
6391
 
6198
-
6392
+
6199
6393
  <xsl:variable name="fo_element">
6200
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
6394
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6201
6395
  inline
6202
6396
  </xsl:variable>
6203
6397
 
6204
- <!-- display 'EXAMPLE' -->
6205
- <xsl:apply-templates select="*[local-name()='name']">
6206
- <xsl:with-param name="fo_element" select="$fo_element"/>
6207
- </xsl:apply-templates>
6398
+ <fo:block-container margin-left="0mm">
6208
6399
 
6209
- <xsl:choose>
6210
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6211
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6212
- <fo:block-container margin-left="0mm" margin-right="0mm">
6213
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6400
+ <xsl:choose>
6401
+
6402
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
6403
+
6404
+ <!-- display name 'EXAMPLE' in a separate block -->
6405
+ <fo:block>
6406
+ <xsl:apply-templates select="*[local-name()='name']">
6214
6407
  <xsl:with-param name="fo_element" select="$fo_element"/>
6215
6408
  </xsl:apply-templates>
6409
+ </fo:block>
6410
+
6411
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6412
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6413
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6414
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6415
+ </xsl:apply-templates>
6416
+ </fo:block-container>
6216
6417
  </fo:block-container>
6217
- </fo:block-container>
6218
- </xsl:when>
6219
- <xsl:otherwise>
6220
- <fo:inline>
6221
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6222
- <xsl:with-param name="fo_element" select="$fo_element"/>
6223
- </xsl:apply-templates>
6224
- </fo:inline>
6225
- </xsl:otherwise>
6226
- </xsl:choose>
6227
-
6228
- </fo:block>
6418
+ </xsl:when> <!-- end block -->
6419
+
6420
+ <xsl:otherwise> <!-- inline -->
6421
+
6422
+ <!-- display 'EXAMPLE' and first element in the same line -->
6423
+ <fo:block>
6424
+ <xsl:apply-templates select="*[local-name()='name']">
6425
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6426
+ </xsl:apply-templates>
6427
+ <fo:inline>
6428
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
6429
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6430
+ </xsl:apply-templates>
6431
+ </fo:inline>
6432
+ </fo:block>
6433
+
6434
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
6435
+ <!-- display further elements in blocks -->
6436
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6437
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6438
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
6439
+ <xsl:with-param name="fo_element" select="'block'"/>
6440
+ </xsl:apply-templates>
6441
+ </fo:block-container>
6442
+ </fo:block-container>
6443
+ </xsl:if>
6444
+ </xsl:otherwise> <!-- end inline -->
6445
+
6446
+ </xsl:choose>
6447
+ </fo:block-container>
6448
+ </fo:block-container>
6229
6449
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6230
6450
  <xsl:param name="fo_element">block</xsl:param>
6231
6451
 
@@ -6254,7 +6474,7 @@
6254
6474
  <xsl:variable name="element">
6255
6475
 
6256
6476
  <xsl:choose>
6257
- <xsl:when test="$num = 1">inline</xsl:when>
6477
+ <xsl:when test="$num = 1 and not(contains($fo_element, 'block'))">inline</xsl:when>
6258
6478
  <xsl:otherwise>block</xsl:otherwise>
6259
6479
  </xsl:choose>
6260
6480
 
@@ -6262,10 +6482,16 @@
6262
6482
  </xsl:variable>
6263
6483
  <xsl:choose>
6264
6484
  <xsl:when test="starts-with(normalize-space($element), 'block')">
6265
- <fo:block xsl:use-attribute-sets="example-p-style">
6266
-
6267
- <xsl:apply-templates/>
6268
- </fo:block>
6485
+ <fo:block-container>
6486
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
6487
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6488
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6489
+ </xsl:if>
6490
+ <fo:block xsl:use-attribute-sets="example-p-style">
6491
+
6492
+ <xsl:apply-templates/>
6493
+ </fo:block>
6494
+ </fo:block-container>
6269
6495
  </xsl:when>
6270
6496
  <xsl:otherwise>
6271
6497
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -6310,7 +6536,7 @@
6310
6536
  </xsl:otherwise>
6311
6537
  </xsl:choose> -->
6312
6538
  </fo:block>
6313
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
6539
+ </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">
6314
6540
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
6315
6541
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6316
6542
  <xsl:if test="normalize-space() != ''">
@@ -6346,7 +6572,8 @@
6346
6572
  <fo:inline><xsl:apply-templates/></fo:inline>
6347
6573
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
6348
6574
  <xsl:if test="normalize-space() != ''">
6349
- <xsl:value-of select="."/>
6575
+ <!-- <xsl:value-of select="."/> -->
6576
+ <xsl:call-template name="text"/>
6350
6577
  </xsl:if>
6351
6578
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
6352
6579
  <fo:block-container margin-left="0mm">
@@ -6443,7 +6670,16 @@
6443
6670
  </fo:inline>
6444
6671
  </xsl:when>
6445
6672
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6446
- <fo:inline><xsl:apply-templates/></fo:inline>
6673
+
6674
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
6675
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
6676
+ <xsl:choose>
6677
+ <xsl:when test="$uri_src != ''">
6678
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
6679
+ </xsl:when>
6680
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
6681
+ </xsl:choose>
6682
+
6447
6683
  </xsl:otherwise>
6448
6684
  </xsl:choose>
6449
6685
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -6614,10 +6850,24 @@
6614
6850
 
6615
6851
  </fo:block>
6616
6852
  <xsl:apply-templates/>
6617
- </xsl:template><xsl:template match="*[local-name() = 'review']">
6853
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
6618
6854
  <!-- comment 2019-11-29 -->
6619
6855
  <!-- <fo:block font-weight="bold">Review:</fo:block>
6620
6856
  <xsl:apply-templates /> -->
6857
+
6858
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
6859
+
6860
+ <xsl:choose>
6861
+ <!-- if there isn't the attribute '@from', then -->
6862
+ <xsl:when test="$id_from = ''">
6863
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
6864
+ </xsl:when>
6865
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
6866
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
6867
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
6868
+ </xsl:when>
6869
+ </xsl:choose>
6870
+
6621
6871
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
6622
6872
  <!-- 0xA0 to space replacement -->
6623
6873
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -6976,7 +7226,10 @@
6976
7226
  <!-- to split by '_' and other chars -->
6977
7227
  <xsl:call-template name="add-zero-spaces-java"/>
6978
7228
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
6979
- <fo:inline id="{@id}" font-size="1pt"/>
7229
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
7230
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
7231
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
7232
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
6980
7233
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
6981
7234
  <!-- <row>
6982
7235
  <date>05-07-2013</date>
@@ -7547,6 +7800,120 @@
7547
7800
  <xsl:apply-templates select="." mode="update_xml_step1"/>
7548
7801
  </xsl:for-each>
7549
7802
  </xsl:copy>
7803
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
7804
+ <xsl:apply-templates mode="update_xml_step1"/>
7805
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
7806
+ <xsl:copy>
7807
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
7808
+ </xsl:copy>
7809
+ </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">
7810
+
7811
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
7812
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
7813
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
7814
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
7815
+ <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))"/>
7816
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
7817
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
7818
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
7819
+ <xsl:with-param name="text" select="$text_"/>
7820
+ </xsl:call-template></text></xsl:variable>
7821
+
7822
+ <xsl:variable name="parent" select="local-name(..)"/>
7823
+
7824
+ <xsl:variable name="text2">
7825
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
7826
+ <xsl:copy-of select="."/>
7827
+ </xsl:for-each></text>
7828
+ </xsl:variable>
7829
+
7830
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
7831
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
7832
+ <xsl:variable name="text3">
7833
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
7834
+ <xsl:choose>
7835
+ <xsl:when test="self::text()">
7836
+ <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))"/>
7837
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
7838
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
7839
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
7840
+ <xsl:with-param name="text" select="$text_units_"/>
7841
+ </xsl:call-template></text></xsl:variable>
7842
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
7843
+ </xsl:when>
7844
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
7845
+ </xsl:choose>
7846
+ </xsl:for-each></text>
7847
+ </xsl:variable>
7848
+
7849
+ <xsl:choose>
7850
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
7851
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
7852
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
7853
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
7854
+ <xsl:choose>
7855
+ <xsl:when test="self::text()">
7856
+ <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))"/>
7857
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
7858
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
7859
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
7860
+ <xsl:with-param name="text" select="$text_dots_"/>
7861
+ </xsl:call-template></text></xsl:variable>
7862
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
7863
+ </xsl:when>
7864
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
7865
+ </xsl:choose>
7866
+ </xsl:for-each>
7867
+ </xsl:when>
7868
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
7869
+ </xsl:choose>
7870
+
7871
+ </xsl:template><xsl:template name="replace_text_tags">
7872
+ <xsl:param name="tag_open"/>
7873
+ <xsl:param name="tag_close"/>
7874
+ <xsl:param name="text"/>
7875
+ <xsl:choose>
7876
+ <xsl:when test="contains($text, $tag_open)">
7877
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
7878
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
7879
+
7880
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
7881
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
7882
+ </xsl:element>
7883
+
7884
+ <xsl:call-template name="replace_text_tags">
7885
+ <xsl:with-param name="tag_open" select="$tag_open"/>
7886
+ <xsl:with-param name="tag_close" select="$tag_close"/>
7887
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
7888
+ </xsl:call-template>
7889
+ </xsl:when>
7890
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
7891
+ </xsl:choose>
7892
+ </xsl:template><xsl:template name="printEdition">
7893
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
7894
+ <xsl:text> </xsl:text>
7895
+ <xsl:choose>
7896
+ <xsl:when test="$edition_i18n != ''">
7897
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
7898
+ <xsl:call-template name="capitalize">
7899
+ <xsl:with-param name="str" select="$edition_i18n"/>
7900
+ </xsl:call-template>
7901
+ </xsl:when>
7902
+ <xsl:otherwise>
7903
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
7904
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
7905
+ <xsl:call-template name="capitalize">
7906
+ <xsl:with-param name="str">
7907
+ <xsl:call-template name="getLocalizedString">
7908
+ <xsl:with-param name="key">edition</xsl:with-param>
7909
+ </xsl:call-template>
7910
+ </xsl:with-param>
7911
+ </xsl:call-template>
7912
+ <xsl:text> </xsl:text>
7913
+ <xsl:value-of select="$edition"/>
7914
+ </xsl:if>
7915
+ </xsl:otherwise>
7916
+ </xsl:choose>
7550
7917
  </xsl:template><xsl:template name="convertDate">
7551
7918
  <xsl:param name="date"/>
7552
7919
  <xsl:param name="format" select="'short'"/>