metanorma-ribose 2.0.8 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,15 +41,21 @@
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="/">
@@ -614,18 +620,6 @@
614
620
  <!-- ============================= -->
615
621
  <!-- ============================= -->
616
622
 
617
- <xsl:template match="/rsd:rsd-standard/rsd:bibdata/rsd:edition">
618
- <fo:block margin-bottom="12pt">
619
- <xsl:variable name="title-edition">
620
- <xsl:call-template name="getTitle">
621
- <xsl:with-param name="name" select="'title-edition'"/>
622
- </xsl:call-template>
623
- </xsl:variable>
624
- <xsl:value-of select="$title-edition"/><xsl:text>: </xsl:text>
625
- <xsl:value-of select="."/><xsl:text> </xsl:text>
626
- </fo:block>
627
- </xsl:template>
628
-
629
623
 
630
624
  <xsl:template match="rsd:feedback-statement" priority="2">
631
625
  <fo:block-container border="1pt solid black" padding="1mm" padding-left="2mm">
@@ -1215,7 +1209,7 @@
1215
1209
 
1216
1210
 
1217
1211
 
1218
- <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">
1219
1213
  <xsl:call-template name="getLang"/>
1220
1214
  </xsl:variable><xsl:variable name="pageWidth_">
1221
1215
  215.9
@@ -1230,20 +1224,7 @@
1230
1224
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1231
1225
  22
1232
1226
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1233
-
1234
- <title-edition lang="en">
1235
-
1236
- <xsl:text>Version</xsl:text>
1237
-
1238
- </title-edition>
1239
-
1240
- <title-edition lang="fr">
1241
- <xsl:text>Édition </xsl:text>
1242
- </title-edition>
1243
1227
 
1244
- <title-edition lang="ru">
1245
- <xsl:text>Издание </xsl:text>
1246
- </title-edition>
1247
1228
 
1248
1229
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1249
1230
  <title-toc lang="en">
@@ -1322,7 +1303,7 @@
1322
1303
  </xsl:variable><xsl:variable name="bibdata">
1323
1304
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1324
1305
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1325
- </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">
1326
1307
  <xsl:param name="name"/>
1327
1308
  <xsl:param name="lang"/>
1328
1309
  <xsl:variable name="lang_">
@@ -1372,7 +1353,7 @@
1372
1353
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1373
1354
 
1374
1355
  <xsl:variable name="additional_fonts_">
1375
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
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']">
1376
1357
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1377
1358
  </xsl:for-each>
1378
1359
  </xsl:variable>
@@ -1452,7 +1433,6 @@
1452
1433
 
1453
1434
 
1454
1435
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1455
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
1456
1436
 
1457
1437
  <xsl:attribute name="space-after">12pt</xsl:attribute>
1458
1438
 
@@ -1540,6 +1520,7 @@
1540
1520
 
1541
1521
 
1542
1522
 
1523
+
1543
1524
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
1544
1525
 
1545
1526
 
@@ -2695,22 +2676,32 @@
2695
2676
  <xsl:sort select="@displayorder" data-type="number"/>
2696
2677
  <xsl:apply-templates select="."/>
2697
2678
  </xsl:for-each>
2698
- </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">
2699
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2700
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2701
- <xsl:call-template name="replace_fo_inline">
2702
- <xsl:with-param name="text" select="$text"/>
2703
- </xsl:call-template>
2704
- </xsl:template><xsl:template name="replace_fo_inline">
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"/>
2705
2692
  <xsl:param name="text"/>
2706
2693
  <xsl:choose>
2707
2694
  <xsl:when test="contains($text, $tag_open)">
2708
2695
  <xsl:value-of select="substring-before($text, $tag_open)"/>
2709
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2696
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
2710
2697
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2711
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2712
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2713
- <xsl:call-template name="replace_fo_inline">
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"/>
2714
2705
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2715
2706
  </xsl:call-template>
2716
2707
  </xsl:when>
@@ -2718,6 +2709,8 @@
2718
2709
  </xsl:choose>
2719
2710
  </xsl:template><xsl:template match="*[local-name()='br']">
2720
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>
2721
2714
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
2722
2715
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
2723
2716
  <xsl:apply-templates/>
@@ -2788,8 +2781,23 @@
2788
2781
  </xsl:call-template>
2789
2782
 
2790
2783
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
2791
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
2792
- <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>
2793
2801
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
2794
2802
 
2795
2803
  <xsl:variable name="table-preamble">
@@ -2905,16 +2913,9 @@
2905
2913
  </xsl:for-each>
2906
2914
  </xsl:when>
2907
2915
  <xsl:otherwise>
2908
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2909
- <xsl:choose>
2910
- <xsl:when test=". = 1 or . = 0">
2911
- <fo:table-column column-width="proportional-column-width(2)"/>
2912
- </xsl:when>
2913
- <xsl:otherwise>
2914
- <fo:table-column column-width="proportional-column-width({.})"/>
2915
- </xsl:otherwise>
2916
- </xsl:choose>
2917
- </xsl:for-each>
2916
+ <xsl:call-template name="insertTableColumnWidth">
2917
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2918
+ </xsl:call-template>
2918
2919
  </xsl:otherwise>
2919
2920
  </xsl:choose>
2920
2921
 
@@ -3078,6 +3079,7 @@
3078
3079
  <xsl:with-param name="text" select="$td_text"/>
3079
3080
  </xsl:call-template>
3080
3081
  </xsl:variable>
3082
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3081
3083
  <xsl:call-template name="tokenize">
3082
3084
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3083
3085
  <!-- 2009 thinspace -->
@@ -3090,6 +3092,7 @@
3090
3092
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3091
3093
  </xsl:call-template>
3092
3094
  </xsl:variable>
3095
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3093
3096
  <width>
3094
3097
  <xsl:variable name="divider">
3095
3098
  <xsl:choose>
@@ -3122,6 +3125,10 @@
3122
3125
  <xsl:with-param name="table" select="$table"/>
3123
3126
  </xsl:call-template>
3124
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')"/>
3125
3132
  </xsl:template><xsl:template match="text()" mode="td_text">
3126
3133
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3127
3134
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -3223,16 +3230,9 @@
3223
3230
  </xsl:for-each>
3224
3231
  </xsl:when>
3225
3232
  <xsl:otherwise>
3226
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3227
- <xsl:choose>
3228
- <xsl:when test=". = 1 or . = 0">
3229
- <fo:table-column column-width="proportional-column-width(2)"/>
3230
- </xsl:when>
3231
- <xsl:otherwise>
3232
- <fo:table-column column-width="proportional-column-width({.})"/>
3233
- </xsl:otherwise>
3234
- </xsl:choose>
3235
- </xsl:for-each>
3233
+ <xsl:call-template name="insertTableColumnWidth">
3234
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3235
+ </xsl:call-template>
3236
3236
  </xsl:otherwise>
3237
3237
  </xsl:choose>
3238
3238
 
@@ -3778,8 +3778,10 @@
3778
3778
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
3779
3779
  </xsl:variable>
3780
3780
 
3781
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
3782
+
3781
3783
  <xsl:choose>
3782
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
3784
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
3783
3785
 
3784
3786
  <fo:block margin-bottom="12pt" text-align="left">
3785
3787
 
@@ -3794,7 +3796,7 @@
3794
3796
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3795
3797
  </fo:block>
3796
3798
 
3797
- </xsl:when>
3799
+ </xsl:when> <!-- END: only one component -->
3798
3800
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3799
3801
  <fo:block margin-bottom="12pt" text-align="left">
3800
3802
 
@@ -3808,8 +3810,8 @@
3808
3810
  </xsl:variable>
3809
3811
  <xsl:value-of select="$title-where"/>
3810
3812
  </fo:block>
3811
- </xsl:when>
3812
- <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 -->
3813
3815
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
3814
3816
 
3815
3817
 
@@ -3825,11 +3827,11 @@
3825
3827
  </xsl:variable>
3826
3828
  <xsl:value-of select="$title-key"/>
3827
3829
  </fo:block>
3828
- </xsl:when>
3830
+ </xsl:when> <!-- END: definition list in a figure -->
3829
3831
  </xsl:choose>
3830
3832
 
3831
3833
  <!-- a few components -->
3832
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
3834
+ <xsl:if test="$onlyOneComponent = 'false'">
3833
3835
  <fo:block>
3834
3836
 
3835
3837
 
@@ -3868,21 +3870,28 @@
3868
3870
  <xsl:apply-templates mode="dl"/>
3869
3871
  </tbody>
3870
3872
  </xsl:variable>
3871
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
3873
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
3872
3874
  <xsl:variable name="colwidths">
3873
3875
  <xsl:call-template name="calculate-column-widths">
3874
3876
  <xsl:with-param name="cols-count" select="2"/>
3875
3877
  <xsl:with-param name="table" select="$html-table"/>
3876
3878
  </xsl:call-template>
3877
3879
  </xsl:variable>
3878
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3880
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
3879
3881
  <xsl:variable name="maxlength_dt">
3880
3882
  <xsl:call-template name="getMaxLength_dt"/>
3881
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"/> -->
3882
3889
  <xsl:call-template name="setColumnWidth_dl">
3883
3890
  <xsl:with-param name="colwidths" select="$colwidths"/>
3884
3891
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3892
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
3885
3893
  </xsl:call-template>
3894
+
3886
3895
  <fo:table-body>
3887
3896
  <xsl:apply-templates>
3888
3897
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -3891,12 +3900,13 @@
3891
3900
  </fo:table>
3892
3901
  </fo:block>
3893
3902
  </fo:block>
3894
- </xsl:if>
3903
+ </xsl:if> <!-- END: a few components -->
3895
3904
  </fo:block-container>
3896
3905
  </fo:block-container>
3897
3906
  </xsl:template><xsl:template name="setColumnWidth_dl">
3898
3907
  <xsl:param name="colwidths"/>
3899
3908
  <xsl:param name="maxlength_dt"/>
3909
+ <xsl:param name="isContainsKeepTogetherTag"/>
3900
3910
  <xsl:choose>
3901
3911
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
3902
3912
  <fo:table-column column-width="50%"/>
@@ -3904,6 +3914,11 @@
3904
3914
  </xsl:when>
3905
3915
  <xsl:otherwise>
3906
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>
3907
3922
  <!-- to set width check most wide chars like `W` -->
3908
3923
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
3909
3924
  <fo:table-column column-width="7%"/>
@@ -3934,20 +3949,25 @@
3934
3949
  <fo:table-column column-width="60%"/>
3935
3950
  </xsl:when>
3936
3951
  <xsl:otherwise>
3937
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3938
- <xsl:choose>
3939
- <xsl:when test=". = 1 or . = 0">
3940
- <fo:table-column column-width="proportional-column-width(2)"/>
3941
- </xsl:when>
3942
- <xsl:otherwise>
3943
- <fo:table-column column-width="proportional-column-width({.})"/>
3944
- </xsl:otherwise>
3945
- </xsl:choose>
3946
- </xsl:for-each>
3952
+ <xsl:call-template name="insertTableColumnWidth">
3953
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3954
+ </xsl:call-template>
3947
3955
  </xsl:otherwise>
3948
3956
  </xsl:choose>
3949
3957
  </xsl:otherwise>
3950
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>
3951
3971
  </xsl:template><xsl:template name="getMaxLength_dt">
3952
3972
  <xsl:variable name="lengths">
3953
3973
  <xsl:for-each select="*[local-name()='dt']">
@@ -3971,7 +3991,6 @@
3971
3991
  <xsl:value-of select="$maxLength"/>
3972
3992
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
3973
3993
  <xsl:param name="key_iso"/>
3974
-
3975
3994
  <!-- <tr>
3976
3995
  <td>NOTE</td>
3977
3996
  <td>
@@ -3979,18 +3998,30 @@
3979
3998
  </td>
3980
3999
  </tr>
3981
4000
  -->
3982
- <fo:table-row>
4001
+ <!-- OLD Variant -->
4002
+ <!-- <fo:table-row>
3983
4003
  <fo:table-cell>
3984
4004
  <fo:block margin-top="6pt">
3985
4005
  <xsl:if test="normalize-space($key_iso) = 'true'">
3986
4006
  <xsl:attribute name="margin-top">0</xsl:attribute>
3987
4007
  </xsl:if>
3988
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4008
+ <xsl:apply-templates select="*[local-name() = 'name']" />
3989
4009
  </fo:block>
3990
4010
  </fo:table-cell>
3991
4011
  <fo:table-cell>
3992
4012
  <fo:block>
3993
- <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"/>
3994
4025
  </fo:block>
3995
4026
  </fo:table-cell>
3996
4027
  </fo:table-row>
@@ -4102,13 +4133,15 @@
4102
4133
  <xsl:choose>
4103
4134
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4104
4135
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4105
- <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>
4106
4137
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4107
4138
  </xsl:choose>
4108
4139
  </xsl:attribute>
4109
4140
  </xsl:if>
4110
4141
  <xsl:apply-templates/>
4111
4142
  </fo:inline>
4143
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
4144
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4112
4145
  </xsl:template><xsl:template match="*[local-name()='underline']">
4113
4146
  <fo:inline text-decoration="underline">
4114
4147
  <xsl:apply-templates/>
@@ -4256,41 +4289,50 @@
4256
4289
  <fo:block break-after="page"/>
4257
4290
  <fo:block> </fo:block>
4258
4291
  <fo:block break-after="page"/>
4292
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
4293
+ <xsl:apply-templates/>
4259
4294
  </xsl:template><xsl:template name="tokenize">
4260
4295
  <xsl:param name="text"/>
4261
4296
  <xsl:param name="separator" select="' '"/>
4262
4297
  <xsl:choose>
4263
4298
  <xsl:when test="not(contains($text, $separator))">
4264
4299
  <word>
4265
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4266
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4267
4300
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4268
- <xsl:variable name="len_str">
4269
- <xsl:choose>
4270
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4271
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4272
- </xsl:when>
4273
- <xsl:otherwise>
4274
- <xsl:value-of select="$len_str_tmp"/>
4275
- </xsl:otherwise>
4276
- </xsl:choose>
4277
- </xsl:variable>
4278
-
4279
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4280
- <xsl:message>
4281
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4282
- len_str=<xsl:value-of select="$len_str"/>
4283
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4284
- </xsl:message>
4285
- </xsl:if> -->
4286
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4287
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4288
4301
  <xsl:choose>
4289
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4290
- <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"/>
4291
4304
  </xsl:when>
4292
4305
  <xsl:otherwise>
4293
- <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>
4294
4336
  </xsl:otherwise>
4295
4337
  </xsl:choose>
4296
4338
  </word>
@@ -4565,6 +4607,9 @@
4565
4607
  <xsl:variable name="isDeleted" select="@deleted"/>
4566
4608
 
4567
4609
  <fo:inline xsl:use-attribute-sets="mathml-style">
4610
+
4611
+
4612
+
4568
4613
 
4569
4614
 
4570
4615
  <xsl:call-template name="setTrackChangesStyles">
@@ -4572,48 +4617,80 @@
4572
4617
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
4573
4618
  </xsl:call-template>
4574
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>
4575
4626
 
4576
-
4577
- <xsl:variable name="mathml">
4578
- <xsl:apply-templates select="." mode="mathml"/>
4627
+ <xsl:variable name="mathml_content">
4628
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
4579
4629
  </xsl:variable>
4580
- <fo:instream-foreign-object fox:alt-text="Math">
4581
4630
 
4631
+
4632
+ <xsl:call-template name="mathml_instream_object">
4633
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
4634
+ </xsl:call-template>
4582
4635
 
4583
-
4584
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
4585
- <xsl:variable name="comment_text_">
4586
- <xsl:choose>
4587
- <xsl:when test="normalize-space($comment_text_following) != ''">
4588
- <xsl:value-of select="$comment_text_following"/>
4589
- </xsl:when>
4590
- <xsl:otherwise>
4591
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
4592
- </xsl:otherwise>
4593
- </xsl:choose>
4594
- </xsl:variable>
4595
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
4596
-
4597
- <xsl:if test="normalize-space($comment_text) != ''">
4598
- <!-- put Mathin Alternate Text -->
4599
- <xsl:attribute name="fox:alt-text">
4600
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
4601
- </xsl:attribute>
4602
- </xsl:if>
4603
-
4604
- <xsl:variable name="mathml_content">
4605
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
4606
- </xsl:variable>
4607
- <!-- put MathML in Actual Text -->
4608
- <xsl:attribute name="fox:actual-text">
4609
- <xsl:value-of select="$mathml_content"/>
4610
- </xsl:attribute>
4611
-
4612
-
4613
-
4614
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
4615
- </fo:instream-foreign-object>
4636
+
4616
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>
4617
4694
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
4618
4695
  <!-- <xsl:text>a+b</xsl:text> -->
4619
4696
  <xsl:text>&lt;</xsl:text>
@@ -4644,7 +4721,9 @@
4644
4721
  <!-- replace start and end spaces to non-break space -->
4645
4722
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4646
4723
  </xsl:copy>
4647
- </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">
4648
4727
  <xsl:variable name="target">
4649
4728
  <xsl:choose>
4650
4729
  <xsl:when test="@updatetype = 'true'">
@@ -5250,18 +5329,33 @@
5250
5329
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5251
5330
  <xsl:copy>
5252
5331
  <xsl:apply-templates select="@*" mode="svg_update"/>
5253
- <xsl:variable name="viewbox">
5332
+ <xsl:variable name="viewbox_">
5254
5333
  <xsl:call-template name="split">
5255
5334
  <xsl:with-param name="pText" select="@viewBox"/>
5256
5335
  <xsl:with-param name="sep" select="' '"/>
5257
5336
  </xsl:call-template>
5258
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
+
5259
5342
  <xsl:attribute name="width">
5260
- <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>
5261
5349
  </xsl:attribute>
5262
5350
  <xsl:attribute name="height">
5263
- <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>
5264
5357
  </xsl:attribute>
5358
+
5265
5359
  <xsl:apply-templates mode="svg_update"/>
5266
5360
  </xsl:copy>
5267
5361
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -5456,7 +5550,11 @@
5456
5550
  <xsl:apply-templates mode="bookmarks"/>
5457
5551
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
5458
5552
  <xsl:apply-templates select="."/>
5459
- </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">
5460
5558
  <xsl:apply-templates mode="bookmarks"/>
5461
5559
  </xsl:template><xsl:template name="addBookmarks">
5462
5560
  <xsl:param name="contents"/>
@@ -5738,7 +5836,9 @@
5738
5836
  <xsl:apply-templates/>
5739
5837
  </xsl:otherwise>
5740
5838
  </xsl:choose>
5741
- </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">
5742
5842
  <xsl:text> </xsl:text>
5743
5843
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
5744
5844
  <xsl:copy>
@@ -5769,9 +5869,22 @@
5769
5869
  </xsl:when>
5770
5870
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
5771
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"/>
5772
5876
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
5773
5877
 
5774
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
+
5775
5888
  <xsl:copy-of select="@id"/>
5776
5889
 
5777
5890
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6267,44 +6380,72 @@
6267
6380
  </xsl:otherwise>
6268
6381
  </xsl:choose>
6269
6382
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6270
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6383
+
6384
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
6385
+
6271
6386
 
6272
6387
  <xsl:if test="ancestor::rsd:ul or ancestor::rsd:ol">
6273
6388
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
6274
6389
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
6275
6390
  </xsl:if>
6276
6391
 
6277
-
6392
+
6278
6393
  <xsl:variable name="fo_element">
6279
- <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>
6280
6395
  inline
6281
6396
  </xsl:variable>
6282
6397
 
6283
- <!-- display 'EXAMPLE' -->
6284
- <xsl:apply-templates select="*[local-name()='name']">
6285
- <xsl:with-param name="fo_element" select="$fo_element"/>
6286
- </xsl:apply-templates>
6398
+ <fo:block-container margin-left="0mm">
6287
6399
 
6288
- <xsl:choose>
6289
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6290
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6291
- <fo:block-container margin-left="0mm" margin-right="0mm">
6292
- <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']">
6293
6407
  <xsl:with-param name="fo_element" select="$fo_element"/>
6294
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>
6295
6417
  </fo:block-container>
6296
- </fo:block-container>
6297
- </xsl:when>
6298
- <xsl:otherwise>
6299
- <fo:inline>
6300
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6301
- <xsl:with-param name="fo_element" select="$fo_element"/>
6302
- </xsl:apply-templates>
6303
- </fo:inline>
6304
- </xsl:otherwise>
6305
- </xsl:choose>
6306
-
6307
- </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>
6308
6449
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6309
6450
  <xsl:param name="fo_element">block</xsl:param>
6310
6451
 
@@ -6341,10 +6482,16 @@
6341
6482
  </xsl:variable>
6342
6483
  <xsl:choose>
6343
6484
  <xsl:when test="starts-with(normalize-space($element), 'block')">
6344
- <fo:block xsl:use-attribute-sets="example-p-style">
6345
-
6346
- <xsl:apply-templates/>
6347
- </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>
6348
6495
  </xsl:when>
6349
6496
  <xsl:otherwise>
6350
6497
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -6523,7 +6670,16 @@
6523
6670
  </fo:inline>
6524
6671
  </xsl:when>
6525
6672
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6526
- <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
+
6527
6683
  </xsl:otherwise>
6528
6684
  </xsl:choose>
6529
6685
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -6694,10 +6850,24 @@
6694
6850
 
6695
6851
  </fo:block>
6696
6852
  <xsl:apply-templates/>
6697
- </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 -->
6698
6854
  <!-- comment 2019-11-29 -->
6699
6855
  <!-- <fo:block font-weight="bold">Review:</fo:block>
6700
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
+
6701
6871
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
6702
6872
  <!-- 0xA0 to space replacement -->
6703
6873
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7056,7 +7226,10 @@
7056
7226
  <!-- to split by '_' and other chars -->
7057
7227
  <xsl:call-template name="add-zero-spaces-java"/>
7058
7228
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7059
- <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>
7060
7233
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7061
7234
  <!-- <row>
7062
7235
  <date>05-07-2013</date>
@@ -7627,6 +7800,120 @@
7627
7800
  <xsl:apply-templates select="." mode="update_xml_step1"/>
7628
7801
  </xsl:for-each>
7629
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>
7630
7917
  </xsl:template><xsl:template name="convertDate">
7631
7918
  <xsl:param name="date"/>
7632
7919
  <xsl:param name="format" select="'short'"/>