metanorma-cc 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,13 @@
32
32
 
33
33
  <xsl:template match="/">
34
34
  <xsl:call-template name="namespaceCheck"/>
35
- <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
35
+ <fo:root xml:lang="{$lang}">
36
+ <xsl:variable name="root-style">
37
+ <root-style xsl:use-attribute-sets="root-style"/>
38
+ </xsl:variable>
39
+ <xsl:call-template name="insertRootStyle">
40
+ <xsl:with-param name="root-style" select="$root-style"/>
41
+ </xsl:call-template>
36
42
  <fo:layout-master-set>
37
43
  <!-- Cover page -->
38
44
  <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
@@ -560,7 +566,7 @@
560
566
  </xsl:template>
561
567
 
562
568
 
563
- <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">
569
+ <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">
564
570
  <xsl:call-template name="getLang"/>
565
571
  </xsl:variable><xsl:variable name="pageWidth_">
566
572
  210
@@ -575,20 +581,7 @@
575
581
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
576
582
  20.3
577
583
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
578
-
579
- <title-edition lang="en">
580
-
581
- <xsl:text>Edition </xsl:text>
582
-
583
- </title-edition>
584
584
 
585
- <title-edition lang="fr">
586
- <xsl:text>Édition </xsl:text>
587
- </title-edition>
588
-
589
- <title-edition lang="ru">
590
- <xsl:text>Издание </xsl:text>
591
- </title-edition>
592
585
 
593
586
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
594
587
  <title-toc lang="en">
@@ -669,7 +662,7 @@
669
662
  </xsl:variable><xsl:variable name="bibdata">
670
663
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
671
664
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
672
- </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">
665
+ </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">
673
666
  <xsl:param name="name"/>
674
667
  <xsl:param name="lang"/>
675
668
  <xsl:variable name="lang_">
@@ -712,7 +705,30 @@
712
705
 
713
706
 
714
707
 
715
- </xsl:attribute-set><xsl:attribute-set name="copyright-statement-style">
708
+ </xsl:attribute-set><xsl:template name="insertRootStyle">
709
+ <xsl:param name="root-style"/>
710
+ <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
711
+
712
+ <xsl:variable name="additional_fonts_">
713
+ <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']">
714
+ <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
715
+ </xsl:for-each>
716
+ </xsl:variable>
717
+ <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
718
+
719
+ <xsl:for-each select="$root-style_/root-style/@*">
720
+ <xsl:choose>
721
+ <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
722
+ <xsl:attribute name="{local-name()}">
723
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
724
+ </xsl:attribute>
725
+ </xsl:when>
726
+ <xsl:otherwise>
727
+ <xsl:copy-of select="."/>
728
+ </xsl:otherwise>
729
+ </xsl:choose>
730
+ </xsl:for-each>
731
+ </xsl:template><xsl:attribute-set name="copyright-statement-style">
716
732
 
717
733
  </xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
718
734
 
@@ -769,7 +785,6 @@
769
785
 
770
786
 
771
787
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
772
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
773
788
 
774
789
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
775
790
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -856,6 +871,7 @@
856
871
 
857
872
 
858
873
 
874
+
859
875
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
860
876
 
861
877
 
@@ -1225,7 +1241,7 @@
1225
1241
 
1226
1242
 
1227
1243
 
1228
- </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1244
+ </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1229
1245
 
1230
1246
 
1231
1247
 
@@ -1915,10 +1931,41 @@
1915
1931
  <xsl:sort select="@displayorder" data-type="number"/>
1916
1932
  <xsl:apply-templates select="."/>
1917
1933
  </xsl:for-each>
1918
- </xsl:template><xsl:template match="text()">
1919
- <xsl:value-of select="."/>
1934
+ </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">
1935
+
1936
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
1937
+ <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))"/>
1938
+ <xsl:call-template name="replace_fo_inline_tags">
1939
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
1940
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
1941
+ <xsl:with-param name="text" select="$text"/>
1942
+ </xsl:call-template>
1943
+
1944
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
1945
+ <xsl:param name="tag_open"/>
1946
+ <xsl:param name="tag_close"/>
1947
+ <xsl:param name="text"/>
1948
+ <xsl:choose>
1949
+ <xsl:when test="contains($text, $tag_open)">
1950
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
1951
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
1952
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
1953
+ <fo:inline keep-together.within-line="always">
1954
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
1955
+ </fo:inline>
1956
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
1957
+ <xsl:call-template name="replace_fo_inline_tags">
1958
+ <xsl:with-param name="tag_open" select="$tag_open"/>
1959
+ <xsl:with-param name="tag_close" select="$tag_close"/>
1960
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
1961
+ </xsl:call-template>
1962
+ </xsl:when>
1963
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
1964
+ </xsl:choose>
1920
1965
  </xsl:template><xsl:template match="*[local-name()='br']">
1921
1966
  <xsl:value-of select="$linebreak"/>
1967
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
1968
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
1922
1969
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
1923
1970
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
1924
1971
  <xsl:apply-templates/>
@@ -1984,8 +2031,23 @@
1984
2031
  </xsl:call-template>
1985
2032
 
1986
2033
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
1987
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
1988
- <xsl:call-template name="add-zero-spaces-java"/>
2034
+ <xsl:choose>
2035
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
2036
+ <xsl:value-of select="."/>
2037
+ </xsl:when>
2038
+ <xsl:otherwise>
2039
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
2040
+ </xsl:otherwise>
2041
+ </xsl:choose>
2042
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
2043
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
2044
+ <!-- <xsl:copy-of select="$text"/> -->
2045
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
2046
+ <xsl:choose>
2047
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
2048
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
2049
+ </xsl:choose>
2050
+ </xsl:for-each>
1989
2051
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
1990
2052
 
1991
2053
  <xsl:variable name="table-preamble">
@@ -2109,16 +2171,9 @@
2109
2171
  </xsl:for-each>
2110
2172
  </xsl:when>
2111
2173
  <xsl:otherwise>
2112
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2113
- <xsl:choose>
2114
- <xsl:when test=". = 1 or . = 0">
2115
- <fo:table-column column-width="proportional-column-width(2)"/>
2116
- </xsl:when>
2117
- <xsl:otherwise>
2118
- <fo:table-column column-width="proportional-column-width({.})"/>
2119
- </xsl:otherwise>
2120
- </xsl:choose>
2121
- </xsl:for-each>
2174
+ <xsl:call-template name="insertTableColumnWidth">
2175
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2176
+ </xsl:call-template>
2122
2177
  </xsl:otherwise>
2123
2178
  </xsl:choose>
2124
2179
 
@@ -2282,6 +2337,7 @@
2282
2337
  <xsl:with-param name="text" select="$td_text"/>
2283
2338
  </xsl:call-template>
2284
2339
  </xsl:variable>
2340
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
2285
2341
  <xsl:call-template name="tokenize">
2286
2342
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2287
2343
  <!-- 2009 thinspace -->
@@ -2294,6 +2350,7 @@
2294
2350
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
2295
2351
  </xsl:call-template>
2296
2352
  </xsl:variable>
2353
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
2297
2354
  <width>
2298
2355
  <xsl:variable name="divider">
2299
2356
  <xsl:choose>
@@ -2326,6 +2383,10 @@
2326
2383
  <xsl:with-param name="table" select="$table"/>
2327
2384
  </xsl:call-template>
2328
2385
  </xsl:if>
2386
+ </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
2387
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
2388
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
2389
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
2329
2390
  </xsl:template><xsl:template match="text()" mode="td_text">
2330
2391
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
2331
2392
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -2427,16 +2488,9 @@
2427
2488
  </xsl:for-each>
2428
2489
  </xsl:when>
2429
2490
  <xsl:otherwise>
2430
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2431
- <xsl:choose>
2432
- <xsl:when test=". = 1 or . = 0">
2433
- <fo:table-column column-width="proportional-column-width(2)"/>
2434
- </xsl:when>
2435
- <xsl:otherwise>
2436
- <fo:table-column column-width="proportional-column-width({.})"/>
2437
- </xsl:otherwise>
2438
- </xsl:choose>
2439
- </xsl:for-each>
2491
+ <xsl:call-template name="insertTableColumnWidth">
2492
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2493
+ </xsl:call-template>
2440
2494
  </xsl:otherwise>
2441
2495
  </xsl:choose>
2442
2496
 
@@ -2977,8 +3031,10 @@
2977
3031
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
2978
3032
  </xsl:variable>
2979
3033
 
3034
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
3035
+
2980
3036
  <xsl:choose>
2981
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
3037
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
2982
3038
 
2983
3039
  <fo:block margin-bottom="12pt" text-align="left">
2984
3040
 
@@ -2993,7 +3049,7 @@
2993
3049
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
2994
3050
  </fo:block>
2995
3051
 
2996
- </xsl:when>
3052
+ </xsl:when> <!-- END: only one component -->
2997
3053
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
2998
3054
  <fo:block margin-bottom="12pt" text-align="left">
2999
3055
 
@@ -3007,8 +3063,8 @@
3007
3063
  </xsl:variable>
3008
3064
  <xsl:value-of select="$title-where"/>
3009
3065
  </fo:block>
3010
- </xsl:when>
3011
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
3066
+ </xsl:when> <!-- END: a few components -->
3067
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
3012
3068
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
3013
3069
 
3014
3070
 
@@ -3021,11 +3077,11 @@
3021
3077
  </xsl:variable>
3022
3078
  <xsl:value-of select="$title-key"/>
3023
3079
  </fo:block>
3024
- </xsl:when>
3080
+ </xsl:when> <!-- END: definition list in a figure -->
3025
3081
  </xsl:choose>
3026
3082
 
3027
3083
  <!-- a few components -->
3028
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
3084
+ <xsl:if test="$onlyOneComponent = 'false'">
3029
3085
  <fo:block>
3030
3086
 
3031
3087
 
@@ -3064,21 +3120,28 @@
3064
3120
  <xsl:apply-templates mode="dl"/>
3065
3121
  </tbody>
3066
3122
  </xsl:variable>
3067
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
3123
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
3068
3124
  <xsl:variable name="colwidths">
3069
3125
  <xsl:call-template name="calculate-column-widths">
3070
3126
  <xsl:with-param name="cols-count" select="2"/>
3071
3127
  <xsl:with-param name="table" select="$html-table"/>
3072
3128
  </xsl:call-template>
3073
3129
  </xsl:variable>
3074
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3130
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
3075
3131
  <xsl:variable name="maxlength_dt">
3076
3132
  <xsl:call-template name="getMaxLength_dt"/>
3077
3133
  </xsl:variable>
3134
+ <xsl:variable name="isContainsKeepTogetherTag_">
3135
+ false
3136
+ </xsl:variable>
3137
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
3138
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
3078
3139
  <xsl:call-template name="setColumnWidth_dl">
3079
3140
  <xsl:with-param name="colwidths" select="$colwidths"/>
3080
3141
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3142
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
3081
3143
  </xsl:call-template>
3144
+
3082
3145
  <fo:table-body>
3083
3146
  <xsl:apply-templates>
3084
3147
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -3087,12 +3150,13 @@
3087
3150
  </fo:table>
3088
3151
  </fo:block>
3089
3152
  </fo:block>
3090
- </xsl:if>
3153
+ </xsl:if> <!-- END: a few components -->
3091
3154
  </fo:block-container>
3092
3155
  </fo:block-container>
3093
3156
  </xsl:template><xsl:template name="setColumnWidth_dl">
3094
3157
  <xsl:param name="colwidths"/>
3095
3158
  <xsl:param name="maxlength_dt"/>
3159
+ <xsl:param name="isContainsKeepTogetherTag"/>
3096
3160
  <xsl:choose>
3097
3161
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
3098
3162
  <fo:table-column column-width="50%"/>
@@ -3100,6 +3164,11 @@
3100
3164
  </xsl:when>
3101
3165
  <xsl:otherwise>
3102
3166
  <xsl:choose>
3167
+ <xsl:when test="$isContainsKeepTogetherTag">
3168
+ <xsl:call-template name="insertTableColumnWidth">
3169
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3170
+ </xsl:call-template>
3171
+ </xsl:when>
3103
3172
  <!-- to set width check most wide chars like `W` -->
3104
3173
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
3105
3174
  <fo:table-column column-width="7%"/>
@@ -3130,20 +3199,25 @@
3130
3199
  <fo:table-column column-width="60%"/>
3131
3200
  </xsl:when>
3132
3201
  <xsl:otherwise>
3133
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3134
- <xsl:choose>
3135
- <xsl:when test=". = 1 or . = 0">
3136
- <fo:table-column column-width="proportional-column-width(2)"/>
3137
- </xsl:when>
3138
- <xsl:otherwise>
3139
- <fo:table-column column-width="proportional-column-width({.})"/>
3140
- </xsl:otherwise>
3141
- </xsl:choose>
3142
- </xsl:for-each>
3202
+ <xsl:call-template name="insertTableColumnWidth">
3203
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3204
+ </xsl:call-template>
3143
3205
  </xsl:otherwise>
3144
3206
  </xsl:choose>
3145
3207
  </xsl:otherwise>
3146
3208
  </xsl:choose>
3209
+ </xsl:template><xsl:template name="insertTableColumnWidth">
3210
+ <xsl:param name="colwidths"/>
3211
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
3212
+ <xsl:choose>
3213
+ <xsl:when test=". = 1 or . = 0">
3214
+ <fo:table-column column-width="proportional-column-width(2)"/>
3215
+ </xsl:when>
3216
+ <xsl:otherwise>
3217
+ <fo:table-column column-width="proportional-column-width({.})"/>
3218
+ </xsl:otherwise>
3219
+ </xsl:choose>
3220
+ </xsl:for-each>
3147
3221
  </xsl:template><xsl:template name="getMaxLength_dt">
3148
3222
  <xsl:variable name="lengths">
3149
3223
  <xsl:for-each select="*[local-name()='dt']">
@@ -3167,7 +3241,6 @@
3167
3241
  <xsl:value-of select="$maxLength"/>
3168
3242
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
3169
3243
  <xsl:param name="key_iso"/>
3170
-
3171
3244
  <!-- <tr>
3172
3245
  <td>NOTE</td>
3173
3246
  <td>
@@ -3175,18 +3248,30 @@
3175
3248
  </td>
3176
3249
  </tr>
3177
3250
  -->
3178
- <fo:table-row>
3251
+ <!-- OLD Variant -->
3252
+ <!-- <fo:table-row>
3179
3253
  <fo:table-cell>
3180
3254
  <fo:block margin-top="6pt">
3181
3255
  <xsl:if test="normalize-space($key_iso) = 'true'">
3182
3256
  <xsl:attribute name="margin-top">0</xsl:attribute>
3183
3257
  </xsl:if>
3184
- <xsl:apply-templates select="*[local-name() = 'name']"/>
3258
+ <xsl:apply-templates select="*[local-name() = 'name']" />
3185
3259
  </fo:block>
3186
3260
  </fo:table-cell>
3187
3261
  <fo:table-cell>
3188
3262
  <fo:block>
3189
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3263
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
3264
+ </fo:block>
3265
+ </fo:table-cell>
3266
+ </fo:table-row> -->
3267
+ <!-- <tr>
3268
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
3269
+ </tr>
3270
+ -->
3271
+ <fo:table-row>
3272
+ <fo:table-cell number-columns-spanned="2">
3273
+ <fo:block>
3274
+ <xsl:call-template name="note"/>
3190
3275
  </fo:block>
3191
3276
  </fo:table-cell>
3192
3277
  </fo:table-row>
@@ -3288,13 +3373,15 @@
3288
3373
  <xsl:choose>
3289
3374
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
3290
3375
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
3291
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
3376
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
3292
3377
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
3293
3378
  </xsl:choose>
3294
3379
  </xsl:attribute>
3295
3380
  </xsl:if>
3296
3381
  <xsl:apply-templates/>
3297
3382
  </fo:inline>
3383
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
3384
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
3298
3385
  </xsl:template><xsl:template match="*[local-name()='underline']">
3299
3386
  <fo:inline text-decoration="underline">
3300
3387
  <xsl:apply-templates/>
@@ -3442,41 +3529,50 @@
3442
3529
  <fo:block break-after="page"/>
3443
3530
  <fo:block> </fo:block>
3444
3531
  <fo:block break-after="page"/>
3532
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
3533
+ <xsl:apply-templates/>
3445
3534
  </xsl:template><xsl:template name="tokenize">
3446
3535
  <xsl:param name="text"/>
3447
3536
  <xsl:param name="separator" select="' '"/>
3448
3537
  <xsl:choose>
3449
3538
  <xsl:when test="not(contains($text, $separator))">
3450
3539
  <word>
3451
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
3452
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
3453
3540
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
3454
- <xsl:variable name="len_str">
3455
- <xsl:choose>
3456
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
3457
- <xsl:value-of select="$len_str_tmp * 1.5"/>
3458
- </xsl:when>
3459
- <xsl:otherwise>
3460
- <xsl:value-of select="$len_str_tmp"/>
3461
- </xsl:otherwise>
3462
- </xsl:choose>
3463
- </xsl:variable>
3464
-
3465
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
3466
- <xsl:message>
3467
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
3468
- len_str=<xsl:value-of select="$len_str"/>
3469
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
3470
- </xsl:message>
3471
- </xsl:if> -->
3472
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
3473
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
3474
3541
  <xsl:choose>
3475
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
3476
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
3542
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
3543
+ <xsl:value-of select="$len_str_tmp"/>
3477
3544
  </xsl:when>
3478
3545
  <xsl:otherwise>
3479
- <xsl:value-of select="$len_str"/>
3546
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
3547
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
3548
+ <xsl:variable name="len_str">
3549
+ <xsl:choose>
3550
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
3551
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
3552
+ </xsl:when>
3553
+ <xsl:otherwise>
3554
+ <xsl:value-of select="$len_str_tmp"/>
3555
+ </xsl:otherwise>
3556
+ </xsl:choose>
3557
+ </xsl:variable>
3558
+
3559
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
3560
+ <xsl:message>
3561
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
3562
+ len_str=<xsl:value-of select="$len_str"/>
3563
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
3564
+ </xsl:message>
3565
+ </xsl:if> -->
3566
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
3567
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
3568
+ <xsl:choose>
3569
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
3570
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
3571
+ </xsl:when>
3572
+ <xsl:otherwise>
3573
+ <xsl:value-of select="$len_str"/>
3574
+ </xsl:otherwise>
3575
+ </xsl:choose>
3480
3576
  </xsl:otherwise>
3481
3577
  </xsl:choose>
3482
3578
  </word>
@@ -3562,24 +3658,28 @@
3562
3658
  </xsl:template><xsl:template name="add-zero-spaces-equal">
3563
3659
  <xsl:param name="text" select="."/>
3564
3660
  <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
3661
+ <xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
3565
3662
  <xsl:variable name="zero-space-after-equal">=</xsl:variable>
3663
+ <xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
3566
3664
  <xsl:variable name="zero-space">​</xsl:variable>
3567
3665
  <xsl:choose>
3568
3666
  <xsl:when test="contains($text, $zero-space-after-equals)">
3569
- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
3667
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
3570
3668
  <xsl:value-of select="$zero-space-after-equals"/>
3571
3669
  <xsl:value-of select="$zero-space"/>
3572
3670
  <xsl:call-template name="add-zero-spaces-equal">
3573
3671
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
3574
- </xsl:call-template>
3672
+ </xsl:call-template> -->
3673
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
3575
3674
  </xsl:when>
3576
3675
  <xsl:when test="contains($text, $zero-space-after-equal)">
3577
- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
3676
+ <!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
3578
3677
  <xsl:value-of select="$zero-space-after-equal"/>
3579
3678
  <xsl:value-of select="$zero-space"/>
3580
3679
  <xsl:call-template name="add-zero-spaces-equal">
3581
3680
  <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
3582
- </xsl:call-template>
3681
+ </xsl:call-template> -->
3682
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
3583
3683
  </xsl:when>
3584
3684
  <xsl:otherwise>
3585
3685
  <xsl:value-of select="$text"/>
@@ -3747,6 +3847,9 @@
3747
3847
  <xsl:variable name="isDeleted" select="@deleted"/>
3748
3848
 
3749
3849
  <fo:inline xsl:use-attribute-sets="mathml-style">
3850
+
3851
+
3852
+
3750
3853
 
3751
3854
 
3752
3855
  <xsl:call-template name="setTrackChangesStyles">
@@ -3754,48 +3857,80 @@
3754
3857
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
3755
3858
  </xsl:call-template>
3756
3859
 
3860
+ <xsl:if test="$add_math_as_text = 'true'">
3861
+ <!-- insert helper tag -->
3862
+ <!-- set unique font-size (fiction) -->
3863
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
3864
+ <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 -->
3865
+ </xsl:if>
3757
3866
 
3758
-
3759
- <xsl:variable name="mathml">
3760
- <xsl:apply-templates select="." mode="mathml"/>
3867
+ <xsl:variable name="mathml_content">
3868
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
3761
3869
  </xsl:variable>
3762
- <fo:instream-foreign-object fox:alt-text="Math">
3763
3870
 
3871
+
3872
+ <xsl:call-template name="mathml_instream_object">
3873
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
3874
+ </xsl:call-template>
3764
3875
 
3765
-
3766
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3767
- <xsl:variable name="comment_text_">
3768
- <xsl:choose>
3769
- <xsl:when test="normalize-space($comment_text_following) != ''">
3770
- <xsl:value-of select="$comment_text_following"/>
3771
- </xsl:when>
3772
- <xsl:otherwise>
3773
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3774
- </xsl:otherwise>
3775
- </xsl:choose>
3776
- </xsl:variable>
3777
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3778
-
3779
- <xsl:if test="normalize-space($comment_text) != ''">
3780
- <!-- put Mathin Alternate Text -->
3781
- <xsl:attribute name="fox:alt-text">
3782
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
3783
- </xsl:attribute>
3784
- </xsl:if>
3785
-
3786
- <xsl:variable name="mathml_content">
3787
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
3788
- </xsl:variable>
3789
- <!-- put MathML in Actual Text -->
3790
- <xsl:attribute name="fox:actual-text">
3791
- <xsl:value-of select="$mathml_content"/>
3792
- </xsl:attribute>
3793
-
3794
-
3795
-
3796
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
3797
- </fo:instream-foreign-object>
3876
+
3798
3877
  </fo:inline>
3878
+ </xsl:template><xsl:template name="getMathml_comment_text">
3879
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3880
+ <xsl:variable name="comment_text_">
3881
+ <xsl:choose>
3882
+ <xsl:when test="normalize-space($comment_text_following) != ''">
3883
+ <xsl:value-of select="$comment_text_following"/>
3884
+ </xsl:when>
3885
+ <xsl:otherwise>
3886
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3887
+ </xsl:otherwise>
3888
+ </xsl:choose>
3889
+ </xsl:variable>
3890
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3891
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
3892
+ <xsl:value-of select="$comment_text"/>
3893
+ </xsl:template><xsl:template name="mathml_instream_object">
3894
+ <xsl:param name="comment_text"/>
3895
+ <xsl:param name="mathml_content"/>
3896
+
3897
+ <xsl:variable name="comment_text_">
3898
+ <xsl:choose>
3899
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
3900
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
3901
+ </xsl:choose>
3902
+ </xsl:variable>
3903
+
3904
+ <xsl:variable name="mathml">
3905
+ <xsl:apply-templates select="." mode="mathml"/>
3906
+ </xsl:variable>
3907
+
3908
+ <fo:instream-foreign-object fox:alt-text="Math">
3909
+
3910
+
3911
+
3912
+
3913
+
3914
+
3915
+
3916
+ <!-- put MathML in Actual Text -->
3917
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
3918
+ <xsl:attribute name="fox:actual-text">
3919
+ <xsl:value-of select="$mathml_content"/>
3920
+ </xsl:attribute>
3921
+
3922
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
3923
+ <xsl:if test="normalize-space($comment_text_) != ''">
3924
+ <!-- put Mathin Alternate Text -->
3925
+ <xsl:attribute name="fox:alt-text">
3926
+ <xsl:value-of select="$comment_text_"/>
3927
+ </xsl:attribute>
3928
+ </xsl:if>
3929
+ <!-- </xsl:if> -->
3930
+
3931
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
3932
+
3933
+ </fo:instream-foreign-object>
3799
3934
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
3800
3935
  <!-- <xsl:text>a+b</xsl:text> -->
3801
3936
  <xsl:text>&lt;</xsl:text>
@@ -3826,7 +3961,9 @@
3826
3961
  <!-- replace start and end spaces to non-break space -->
3827
3962
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
3828
3963
  </xsl:copy>
3829
- </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">
3964
+ </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">
3965
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
3966
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
3830
3967
  <xsl:variable name="target">
3831
3968
  <xsl:choose>
3832
3969
  <xsl:when test="@updatetype = 'true'">
@@ -4055,7 +4192,12 @@
4055
4192
 
4056
4193
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
4057
4194
 
4195
+ <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
4196
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
4197
+ </xsl:if>
4198
+
4058
4199
 
4200
+
4059
4201
 
4060
4202
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
4061
4203
  <!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
@@ -4412,18 +4554,33 @@
4412
4554
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4413
4555
  <xsl:copy>
4414
4556
  <xsl:apply-templates select="@*" mode="svg_update"/>
4415
- <xsl:variable name="viewbox">
4557
+ <xsl:variable name="viewbox_">
4416
4558
  <xsl:call-template name="split">
4417
4559
  <xsl:with-param name="pText" select="@viewBox"/>
4418
4560
  <xsl:with-param name="sep" select="' '"/>
4419
4561
  </xsl:call-template>
4420
4562
  </xsl:variable>
4563
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
4564
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
4565
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
4566
+
4421
4567
  <xsl:attribute name="width">
4422
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4568
+ <xsl:choose>
4569
+ <xsl:when test="$width != ''">
4570
+ <xsl:value-of select="round($width)"/>
4571
+ </xsl:when>
4572
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
4573
+ </xsl:choose>
4423
4574
  </xsl:attribute>
4424
4575
  <xsl:attribute name="height">
4425
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4576
+ <xsl:choose>
4577
+ <xsl:when test="$height != ''">
4578
+ <xsl:value-of select="round($height)"/>
4579
+ </xsl:when>
4580
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
4581
+ </xsl:choose>
4426
4582
  </xsl:attribute>
4583
+
4427
4584
  <xsl:apply-templates mode="svg_update"/>
4428
4585
  </xsl:copy>
4429
4586
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -4618,7 +4775,11 @@
4618
4775
  <xsl:apply-templates mode="bookmarks"/>
4619
4776
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
4620
4777
  <xsl:apply-templates select="."/>
4621
- </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">
4778
+ </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">
4779
+ <xsl:apply-templates mode="contents"/>
4780
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
4781
+ <xsl:apply-templates mode="bookmarks"/>
4782
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
4622
4783
  <xsl:apply-templates mode="bookmarks"/>
4623
4784
  </xsl:template><xsl:template name="addBookmarks">
4624
4785
  <xsl:param name="contents"/>
@@ -4900,7 +5061,9 @@
4900
5061
  <xsl:apply-templates/>
4901
5062
  </xsl:otherwise>
4902
5063
  </xsl:choose>
4903
- </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">
5064
+ </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">
5065
+ <xsl:value-of select="."/>
5066
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
4904
5067
  <xsl:text> </xsl:text>
4905
5068
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
4906
5069
  <xsl:copy>
@@ -4931,9 +5094,22 @@
4931
5094
  </xsl:when>
4932
5095
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
4933
5096
  </xsl:choose>
5097
+ </xsl:template><xsl:template match="text()" mode="contents_item">
5098
+ <xsl:call-template name="keep_together_standard_number"/>
5099
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
5100
+ <xsl:apply-templates mode="contents_item"/>
4934
5101
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
4935
5102
 
4936
5103
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
5104
+
5105
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
5106
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
5107
+ </xsl:if>
5108
+
5109
+ <xsl:if test="ancestor::*[local-name() = 'example']">
5110
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
5111
+ </xsl:if>
5112
+
4937
5113
  <xsl:copy-of select="@id"/>
4938
5114
 
4939
5115
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -5033,17 +5209,15 @@
5033
5209
 
5034
5210
  <!-- split text by zero-width space -->
5035
5211
  <xsl:variable name="text_step4">
5036
- <xsl:call-template name="split">
5212
+ <xsl:call-template name="split_for_interspers">
5037
5213
  <xsl:with-param name="pText" select="$text_step3"/>
5038
5214
  <xsl:with-param name="sep" select="$zero_width_space"/>
5039
- <xsl:with-param name="normalize-space">false</xsl:with-param>
5040
- <xsl:with-param name="keep_sep">true</xsl:with-param>
5041
5215
  </xsl:call-template>
5042
5216
  </xsl:variable>
5043
5217
 
5044
- <xsl:for-each select="xalan:nodeset($text_step4)/item">
5218
+ <xsl:for-each select="xalan:nodeset($text_step4)/node()">
5045
5219
  <xsl:choose>
5046
- <xsl:when test="string-length() &gt; 30"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5220
+ <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5047
5221
  <xsl:call-template name="interspers">
5048
5222
  <xsl:with-param name="str" select="."/>
5049
5223
  </xsl:call-template>
@@ -5054,6 +5228,30 @@
5054
5228
  </xsl:choose>
5055
5229
  </xsl:for-each>
5056
5230
 
5231
+ </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">
5232
+ <xsl:param name="pText" select="."/>
5233
+ <xsl:param name="sep" select="','"/>
5234
+ <!-- word with length more than 30 will be interspersed with zero-width space -->
5235
+ <xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
5236
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
5237
+ <xsl:call-template name="replace_tag_interspers">
5238
+ <xsl:with-param name="text" select="$text"/>
5239
+ </xsl:call-template>
5240
+ </xsl:template><xsl:template name="replace_tag_interspers">
5241
+ <xsl:param name="text"/>
5242
+ <xsl:choose>
5243
+ <xsl:when test="contains($text, $interspers_tag_open)">
5244
+ <xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
5245
+ <xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
5246
+ <interspers>
5247
+ <xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
5248
+ </interspers>
5249
+ <xsl:call-template name="replace_tag_interspers">
5250
+ <xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
5251
+ </xsl:call-template>
5252
+ </xsl:when>
5253
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
5254
+ </xsl:choose>
5057
5255
  </xsl:template><xsl:template name="interspers">
5058
5256
  <xsl:param name="str"/>
5059
5257
  <xsl:param name="char" select="$zero_width_space"/>
@@ -5389,39 +5587,67 @@
5389
5587
  </xsl:otherwise>
5390
5588
  </xsl:choose>
5391
5589
  </xsl:template><xsl:template match="*[local-name() = 'example']">
5392
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
5393
-
5590
+
5591
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
5592
+
5394
5593
 
5594
+
5395
5595
  <xsl:variable name="fo_element">
5396
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
5596
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
5397
5597
  block
5398
5598
  </xsl:variable>
5399
5599
 
5400
- <!-- display 'EXAMPLE' -->
5401
- <xsl:apply-templates select="*[local-name()='name']">
5402
- <xsl:with-param name="fo_element" select="$fo_element"/>
5403
- </xsl:apply-templates>
5600
+ <fo:block-container margin-left="0mm">
5404
5601
 
5405
- <xsl:choose>
5406
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
5407
- <fo:block-container xsl:use-attribute-sets="example-body-style">
5408
- <fo:block-container margin-left="0mm" margin-right="0mm">
5409
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5602
+ <xsl:choose>
5603
+
5604
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
5605
+
5606
+ <!-- display name 'EXAMPLE' in a separate block -->
5607
+ <fo:block>
5608
+ <xsl:apply-templates select="*[local-name()='name']">
5410
5609
  <xsl:with-param name="fo_element" select="$fo_element"/>
5411
5610
  </xsl:apply-templates>
5611
+ </fo:block>
5612
+
5613
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
5614
+ <fo:block-container margin-left="0mm" margin-right="0mm">
5615
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5616
+ <xsl:with-param name="fo_element" select="$fo_element"/>
5617
+ </xsl:apply-templates>
5618
+ </fo:block-container>
5412
5619
  </fo:block-container>
5413
- </fo:block-container>
5414
- </xsl:when>
5415
- <xsl:otherwise>
5416
- <fo:inline>
5417
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5418
- <xsl:with-param name="fo_element" select="$fo_element"/>
5419
- </xsl:apply-templates>
5420
- </fo:inline>
5421
- </xsl:otherwise>
5422
- </xsl:choose>
5423
-
5424
- </fo:block>
5620
+ </xsl:when> <!-- end block -->
5621
+
5622
+ <xsl:otherwise> <!-- inline -->
5623
+
5624
+ <!-- display 'EXAMPLE' and first element in the same line -->
5625
+ <fo:block>
5626
+ <xsl:apply-templates select="*[local-name()='name']">
5627
+ <xsl:with-param name="fo_element" select="$fo_element"/>
5628
+ </xsl:apply-templates>
5629
+ <fo:inline>
5630
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
5631
+ <xsl:with-param name="fo_element" select="$fo_element"/>
5632
+ </xsl:apply-templates>
5633
+ </fo:inline>
5634
+ </fo:block>
5635
+
5636
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
5637
+ <!-- display further elements in blocks -->
5638
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
5639
+ <fo:block-container margin-left="0mm" margin-right="0mm">
5640
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
5641
+ <xsl:with-param name="fo_element" select="'block'"/>
5642
+ </xsl:apply-templates>
5643
+ </fo:block-container>
5644
+ </fo:block-container>
5645
+ </xsl:if>
5646
+ </xsl:otherwise> <!-- end inline -->
5647
+
5648
+ </xsl:choose>
5649
+ </fo:block-container>
5650
+ </fo:block-container>
5425
5651
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
5426
5652
  <xsl:param name="fo_element">block</xsl:param>
5427
5653
 
@@ -5453,10 +5679,16 @@
5453
5679
  </xsl:variable>
5454
5680
  <xsl:choose>
5455
5681
  <xsl:when test="starts-with(normalize-space($element), 'block')">
5456
- <fo:block xsl:use-attribute-sets="example-p-style">
5457
-
5458
- <xsl:apply-templates/>
5459
- </fo:block>
5682
+ <fo:block-container>
5683
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
5684
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
5685
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
5686
+ </xsl:if>
5687
+ <fo:block xsl:use-attribute-sets="example-p-style">
5688
+
5689
+ <xsl:apply-templates/>
5690
+ </fo:block>
5691
+ </fo:block-container>
5460
5692
  </xsl:when>
5461
5693
  <xsl:otherwise>
5462
5694
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -5501,7 +5733,7 @@
5501
5733
  </xsl:otherwise>
5502
5734
  </xsl:choose> -->
5503
5735
  </fo:block>
5504
- </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
5736
+ </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">
5505
5737
  <xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
5506
5738
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
5507
5739
  <xsl:if test="normalize-space() != ''">
@@ -5537,7 +5769,8 @@
5537
5769
  <fo:inline><xsl:apply-templates/></fo:inline>
5538
5770
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
5539
5771
  <xsl:if test="normalize-space() != ''">
5540
- <xsl:value-of select="."/>
5772
+ <!-- <xsl:value-of select="."/> -->
5773
+ <xsl:call-template name="text"/>
5541
5774
  </xsl:if>
5542
5775
  </xsl:template><xsl:template match="*[local-name() = 'quote']">
5543
5776
  <fo:block-container margin-left="0mm">
@@ -5637,7 +5870,16 @@
5637
5870
  </fo:inline>
5638
5871
  </xsl:when>
5639
5872
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5640
- <fo:inline><xsl:apply-templates/></fo:inline>
5873
+
5874
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
5875
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
5876
+ <xsl:choose>
5877
+ <xsl:when test="$uri_src != ''">
5878
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
5879
+ </xsl:when>
5880
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
5881
+ </xsl:choose>
5882
+
5641
5883
  </xsl:otherwise>
5642
5884
  </xsl:choose>
5643
5885
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -5819,10 +6061,24 @@
5819
6061
 
5820
6062
  </fo:block>
5821
6063
  <xsl:apply-templates/>
5822
- </xsl:template><xsl:template match="*[local-name() = 'review']">
6064
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
5823
6065
  <!-- comment 2019-11-29 -->
5824
6066
  <!-- <fo:block font-weight="bold">Review:</fo:block>
5825
6067
  <xsl:apply-templates /> -->
6068
+
6069
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
6070
+
6071
+ <xsl:choose>
6072
+ <!-- if there isn't the attribute '@from', then -->
6073
+ <xsl:when test="$id_from = ''">
6074
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
6075
+ </xsl:when>
6076
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
6077
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
6078
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
6079
+ </xsl:when>
6080
+ </xsl:choose>
6081
+
5826
6082
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
5827
6083
  <!-- 0xA0 to space replacement -->
5828
6084
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -6183,7 +6439,10 @@
6183
6439
  <!-- to split by '_' and other chars -->
6184
6440
  <xsl:call-template name="add-zero-spaces-java"/>
6185
6441
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
6186
- <fo:inline id="{@id}" font-size="1pt"/>
6442
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
6443
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
6444
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
6445
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
6187
6446
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
6188
6447
  <!-- <row>
6189
6448
  <date>05-07-2013</date>
@@ -6729,6 +6988,120 @@
6729
6988
  <xsl:apply-templates select="." mode="update_xml_step1"/>
6730
6989
  </xsl:for-each>
6731
6990
  </xsl:copy>
6991
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
6992
+ <xsl:apply-templates mode="update_xml_step1"/>
6993
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
6994
+ <xsl:copy>
6995
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
6996
+ </xsl:copy>
6997
+ </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">
6998
+
6999
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
7000
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
7001
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
7002
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
7003
+ <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))"/>
7004
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
7005
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
7006
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
7007
+ <xsl:with-param name="text" select="$text_"/>
7008
+ </xsl:call-template></text></xsl:variable>
7009
+
7010
+ <xsl:variable name="parent" select="local-name(..)"/>
7011
+
7012
+ <xsl:variable name="text2">
7013
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
7014
+ <xsl:copy-of select="."/>
7015
+ </xsl:for-each></text>
7016
+ </xsl:variable>
7017
+
7018
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
7019
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
7020
+ <xsl:variable name="text3">
7021
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
7022
+ <xsl:choose>
7023
+ <xsl:when test="self::text()">
7024
+ <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))"/>
7025
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
7026
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
7027
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
7028
+ <xsl:with-param name="text" select="$text_units_"/>
7029
+ </xsl:call-template></text></xsl:variable>
7030
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
7031
+ </xsl:when>
7032
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
7033
+ </xsl:choose>
7034
+ </xsl:for-each></text>
7035
+ </xsl:variable>
7036
+
7037
+ <xsl:choose>
7038
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
7039
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
7040
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
7041
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
7042
+ <xsl:choose>
7043
+ <xsl:when test="self::text()">
7044
+ <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))"/>
7045
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
7046
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
7047
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
7048
+ <xsl:with-param name="text" select="$text_dots_"/>
7049
+ </xsl:call-template></text></xsl:variable>
7050
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
7051
+ </xsl:when>
7052
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
7053
+ </xsl:choose>
7054
+ </xsl:for-each>
7055
+ </xsl:when>
7056
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
7057
+ </xsl:choose>
7058
+
7059
+ </xsl:template><xsl:template name="replace_text_tags">
7060
+ <xsl:param name="tag_open"/>
7061
+ <xsl:param name="tag_close"/>
7062
+ <xsl:param name="text"/>
7063
+ <xsl:choose>
7064
+ <xsl:when test="contains($text, $tag_open)">
7065
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
7066
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
7067
+
7068
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
7069
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
7070
+ </xsl:element>
7071
+
7072
+ <xsl:call-template name="replace_text_tags">
7073
+ <xsl:with-param name="tag_open" select="$tag_open"/>
7074
+ <xsl:with-param name="tag_close" select="$tag_close"/>
7075
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
7076
+ </xsl:call-template>
7077
+ </xsl:when>
7078
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
7079
+ </xsl:choose>
7080
+ </xsl:template><xsl:template name="printEdition">
7081
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
7082
+ <xsl:text> </xsl:text>
7083
+ <xsl:choose>
7084
+ <xsl:when test="$edition_i18n != ''">
7085
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
7086
+ <xsl:call-template name="capitalize">
7087
+ <xsl:with-param name="str" select="$edition_i18n"/>
7088
+ </xsl:call-template>
7089
+ </xsl:when>
7090
+ <xsl:otherwise>
7091
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
7092
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
7093
+ <xsl:call-template name="capitalize">
7094
+ <xsl:with-param name="str">
7095
+ <xsl:call-template name="getLocalizedString">
7096
+ <xsl:with-param name="key">edition</xsl:with-param>
7097
+ </xsl:call-template>
7098
+ </xsl:with-param>
7099
+ </xsl:call-template>
7100
+ <xsl:text> </xsl:text>
7101
+ <xsl:value-of select="$edition"/>
7102
+ </xsl:if>
7103
+ </xsl:otherwise>
7104
+ </xsl:choose>
6732
7105
  </xsl:template><xsl:template name="convertDate">
6733
7106
  <xsl:param name="date"/>
6734
7107
  <xsl:param name="format" select="'short'"/>