metanorma-mpfa 0.8.8 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -140,12 +140,19 @@
140
140
  <fo:block margin-bottom="12pt"> </fo:block>
141
141
  <fo:block-container text-align="center" border="0.5pt solid black" margin-bottom="12pt">
142
142
  <fo:block font-size="16pt" margin-bottom="12pt" padding-top="1mm">
143
- <xsl:value-of select="/mpfd:mpfd-standard/mpfd:bibdata/mpfd:edition"/>
144
- <xsl:text> </xsl:text>
145
- <xsl:call-template name="getTitle">
146
- <xsl:with-param name="name" select="'title-edition'"/>
147
- </xsl:call-template>
148
- <xsl:value-of select="$linebreak"/>
143
+ <xsl:variable name="edition" select="normalize-space(/mpfd:mpfd-standard/mpfd:bibdata/mpfd:edition[normalize-space(@language) = ''])"/>
144
+ <xsl:if test="$edition != ''">
145
+ <xsl:value-of select="$edition"/>
146
+ <xsl:text> </xsl:text>
147
+ <xsl:call-template name="capitalize">
148
+ <xsl:with-param name="str">
149
+ <xsl:call-template name="getLocalizedString">
150
+ <xsl:with-param name="key">edition</xsl:with-param>
151
+ </xsl:call-template>
152
+ </xsl:with-param>
153
+ </xsl:call-template>
154
+ <xsl:value-of select="$linebreak"/>
155
+ </xsl:if>
149
156
  <xsl:call-template name="convertDate">
150
157
  <xsl:with-param name="date" select="/mpfd:mpfd-standard/mpfd:bibdata/mpfd:version/mpfd:revision-date"/>
151
158
  <xsl:with-param name="format">ddMMyyyy</xsl:with-param>
@@ -576,7 +583,7 @@
576
583
  </xsl:template>
577
584
 
578
585
 
579
- <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">
586
+ <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">
580
587
  <xsl:call-template name="getLang"/>
581
588
  </xsl:variable><xsl:variable name="pageWidth_">
582
589
  210
@@ -591,20 +598,7 @@
591
598
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
592
599
  10
593
600
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
594
-
595
- <title-edition lang="en">
596
-
597
- <xsl:text>Edition </xsl:text>
598
-
599
- </title-edition>
600
601
 
601
- <title-edition lang="fr">
602
- <xsl:text>Édition </xsl:text>
603
- </title-edition>
604
-
605
- <title-edition lang="ru">
606
- <xsl:text>Издание </xsl:text>
607
- </title-edition>
608
602
 
609
603
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
610
604
  <title-toc lang="en">
@@ -685,7 +679,7 @@
685
679
  </xsl:variable><xsl:variable name="bibdata">
686
680
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
687
681
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
688
- </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">
682
+ </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">
689
683
  <xsl:param name="name"/>
690
684
  <xsl:param name="lang"/>
691
685
  <xsl:variable name="lang_">
@@ -733,7 +727,7 @@
733
727
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
734
728
 
735
729
  <xsl:variable name="additional_fonts_">
736
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
730
+ <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']">
737
731
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
738
732
  </xsl:for-each>
739
733
  </xsl:variable>
@@ -808,7 +802,6 @@
808
802
 
809
803
 
810
804
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
811
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
812
805
 
813
806
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
814
807
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -884,6 +877,7 @@
884
877
 
885
878
 
886
879
 
880
+
887
881
  <xsl:attribute name="margin-left">12.5mm</xsl:attribute>
888
882
  <xsl:attribute name="margin-bottom">18pt</xsl:attribute>
889
883
 
@@ -1927,22 +1921,32 @@
1927
1921
  <xsl:sort select="@displayorder" data-type="number"/>
1928
1922
  <xsl:apply-templates select="."/>
1929
1923
  </xsl:for-each>
1930
- </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">
1931
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
1932
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
1933
- <xsl:call-template name="replace_fo_inline">
1934
- <xsl:with-param name="text" select="$text"/>
1935
- </xsl:call-template>
1936
- </xsl:template><xsl:template name="replace_fo_inline">
1924
+ </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">
1925
+
1926
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
1927
+ <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))"/>
1928
+ <xsl:call-template name="replace_fo_inline_tags">
1929
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
1930
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
1931
+ <xsl:with-param name="text" select="$text"/>
1932
+ </xsl:call-template>
1933
+
1934
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
1935
+ <xsl:param name="tag_open"/>
1936
+ <xsl:param name="tag_close"/>
1937
1937
  <xsl:param name="text"/>
1938
1938
  <xsl:choose>
1939
1939
  <xsl:when test="contains($text, $tag_open)">
1940
1940
  <xsl:value-of select="substring-before($text, $tag_open)"/>
1941
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
1941
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
1942
1942
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
1943
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
1944
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
1945
- <xsl:call-template name="replace_fo_inline">
1943
+ <fo:inline keep-together.within-line="always">
1944
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
1945
+ </fo:inline>
1946
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
1947
+ <xsl:call-template name="replace_fo_inline_tags">
1948
+ <xsl:with-param name="tag_open" select="$tag_open"/>
1949
+ <xsl:with-param name="tag_close" select="$tag_close"/>
1946
1950
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
1947
1951
  </xsl:call-template>
1948
1952
  </xsl:when>
@@ -1950,6 +1954,8 @@
1950
1954
  </xsl:choose>
1951
1955
  </xsl:template><xsl:template match="*[local-name()='br']">
1952
1956
  <xsl:value-of select="$linebreak"/>
1957
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
1958
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
1953
1959
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
1954
1960
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
1955
1961
  <xsl:apply-templates/>
@@ -2015,8 +2021,23 @@
2015
2021
  </xsl:call-template>
2016
2022
 
2017
2023
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
2018
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
2019
- <xsl:call-template name="add-zero-spaces-java"/>
2024
+ <xsl:choose>
2025
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
2026
+ <xsl:value-of select="."/>
2027
+ </xsl:when>
2028
+ <xsl:otherwise>
2029
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
2030
+ </xsl:otherwise>
2031
+ </xsl:choose>
2032
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
2033
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
2034
+ <!-- <xsl:copy-of select="$text"/> -->
2035
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
2036
+ <xsl:choose>
2037
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
2038
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
2039
+ </xsl:choose>
2040
+ </xsl:for-each>
2020
2041
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
2021
2042
 
2022
2043
  <xsl:variable name="table-preamble">
@@ -2134,16 +2155,9 @@
2134
2155
  </xsl:for-each>
2135
2156
  </xsl:when>
2136
2157
  <xsl:otherwise>
2137
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2138
- <xsl:choose>
2139
- <xsl:when test=". = 1 or . = 0">
2140
- <fo:table-column column-width="proportional-column-width(2)"/>
2141
- </xsl:when>
2142
- <xsl:otherwise>
2143
- <fo:table-column column-width="proportional-column-width({.})"/>
2144
- </xsl:otherwise>
2145
- </xsl:choose>
2146
- </xsl:for-each>
2158
+ <xsl:call-template name="insertTableColumnWidth">
2159
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2160
+ </xsl:call-template>
2147
2161
  </xsl:otherwise>
2148
2162
  </xsl:choose>
2149
2163
 
@@ -2307,6 +2321,7 @@
2307
2321
  <xsl:with-param name="text" select="$td_text"/>
2308
2322
  </xsl:call-template>
2309
2323
  </xsl:variable>
2324
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
2310
2325
  <xsl:call-template name="tokenize">
2311
2326
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2312
2327
  <!-- 2009 thinspace -->
@@ -2319,6 +2334,7 @@
2319
2334
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
2320
2335
  </xsl:call-template>
2321
2336
  </xsl:variable>
2337
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
2322
2338
  <width>
2323
2339
  <xsl:variable name="divider">
2324
2340
  <xsl:choose>
@@ -2351,6 +2367,10 @@
2351
2367
  <xsl:with-param name="table" select="$table"/>
2352
2368
  </xsl:call-template>
2353
2369
  </xsl:if>
2370
+ </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
2371
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
2372
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
2373
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
2354
2374
  </xsl:template><xsl:template match="text()" mode="td_text">
2355
2375
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
2356
2376
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -2452,16 +2472,9 @@
2452
2472
  </xsl:for-each>
2453
2473
  </xsl:when>
2454
2474
  <xsl:otherwise>
2455
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2456
- <xsl:choose>
2457
- <xsl:when test=". = 1 or . = 0">
2458
- <fo:table-column column-width="proportional-column-width(2)"/>
2459
- </xsl:when>
2460
- <xsl:otherwise>
2461
- <fo:table-column column-width="proportional-column-width({.})"/>
2462
- </xsl:otherwise>
2463
- </xsl:choose>
2464
- </xsl:for-each>
2475
+ <xsl:call-template name="insertTableColumnWidth">
2476
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2477
+ </xsl:call-template>
2465
2478
  </xsl:otherwise>
2466
2479
  </xsl:choose>
2467
2480
 
@@ -3002,8 +3015,10 @@
3002
3015
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
3003
3016
  </xsl:variable>
3004
3017
 
3018
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
3019
+
3005
3020
  <xsl:choose>
3006
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
3021
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
3007
3022
 
3008
3023
  <fo:block margin-bottom="12pt" text-align="left">
3009
3024
 
@@ -3018,7 +3033,7 @@
3018
3033
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3019
3034
  </fo:block>
3020
3035
 
3021
- </xsl:when>
3036
+ </xsl:when> <!-- END: only one component -->
3022
3037
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3023
3038
  <fo:block margin-bottom="12pt" text-align="left">
3024
3039
 
@@ -3032,8 +3047,8 @@
3032
3047
  </xsl:variable>
3033
3048
  <xsl:value-of select="$title-where"/>
3034
3049
  </fo:block>
3035
- </xsl:when>
3036
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
3050
+ </xsl:when> <!-- END: a few components -->
3051
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
3037
3052
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
3038
3053
 
3039
3054
 
@@ -3046,11 +3061,11 @@
3046
3061
  </xsl:variable>
3047
3062
  <xsl:value-of select="$title-key"/>
3048
3063
  </fo:block>
3049
- </xsl:when>
3064
+ </xsl:when> <!-- END: definition list in a figure -->
3050
3065
  </xsl:choose>
3051
3066
 
3052
3067
  <!-- a few components -->
3053
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
3068
+ <xsl:if test="$onlyOneComponent = 'false'">
3054
3069
  <fo:block>
3055
3070
 
3056
3071
 
@@ -3089,21 +3104,28 @@
3089
3104
  <xsl:apply-templates mode="dl"/>
3090
3105
  </tbody>
3091
3106
  </xsl:variable>
3092
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
3107
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
3093
3108
  <xsl:variable name="colwidths">
3094
3109
  <xsl:call-template name="calculate-column-widths">
3095
3110
  <xsl:with-param name="cols-count" select="2"/>
3096
3111
  <xsl:with-param name="table" select="$html-table"/>
3097
3112
  </xsl:call-template>
3098
3113
  </xsl:variable>
3099
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3114
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
3100
3115
  <xsl:variable name="maxlength_dt">
3101
3116
  <xsl:call-template name="getMaxLength_dt"/>
3102
3117
  </xsl:variable>
3118
+ <xsl:variable name="isContainsKeepTogetherTag_">
3119
+ false
3120
+ </xsl:variable>
3121
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
3122
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
3103
3123
  <xsl:call-template name="setColumnWidth_dl">
3104
3124
  <xsl:with-param name="colwidths" select="$colwidths"/>
3105
3125
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3126
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
3106
3127
  </xsl:call-template>
3128
+
3107
3129
  <fo:table-body>
3108
3130
  <xsl:apply-templates>
3109
3131
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -3112,12 +3134,13 @@
3112
3134
  </fo:table>
3113
3135
  </fo:block>
3114
3136
  </fo:block>
3115
- </xsl:if>
3137
+ </xsl:if> <!-- END: a few components -->
3116
3138
  </fo:block-container>
3117
3139
  </fo:block-container>
3118
3140
  </xsl:template><xsl:template name="setColumnWidth_dl">
3119
3141
  <xsl:param name="colwidths"/>
3120
3142
  <xsl:param name="maxlength_dt"/>
3143
+ <xsl:param name="isContainsKeepTogetherTag"/>
3121
3144
  <xsl:choose>
3122
3145
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
3123
3146
  <fo:table-column column-width="50%"/>
@@ -3125,6 +3148,11 @@
3125
3148
  </xsl:when>
3126
3149
  <xsl:otherwise>
3127
3150
  <xsl:choose>
3151
+ <xsl:when test="$isContainsKeepTogetherTag">
3152
+ <xsl:call-template name="insertTableColumnWidth">
3153
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3154
+ </xsl:call-template>
3155
+ </xsl:when>
3128
3156
  <!-- to set width check most wide chars like `W` -->
3129
3157
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
3130
3158
  <fo:table-column column-width="7%"/>
@@ -3155,20 +3183,25 @@
3155
3183
  <fo:table-column column-width="60%"/>
3156
3184
  </xsl:when>
3157
3185
  <xsl:otherwise>
3158
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3159
- <xsl:choose>
3160
- <xsl:when test=". = 1 or . = 0">
3161
- <fo:table-column column-width="proportional-column-width(2)"/>
3162
- </xsl:when>
3163
- <xsl:otherwise>
3164
- <fo:table-column column-width="proportional-column-width({.})"/>
3165
- </xsl:otherwise>
3166
- </xsl:choose>
3167
- </xsl:for-each>
3186
+ <xsl:call-template name="insertTableColumnWidth">
3187
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3188
+ </xsl:call-template>
3168
3189
  </xsl:otherwise>
3169
3190
  </xsl:choose>
3170
3191
  </xsl:otherwise>
3171
3192
  </xsl:choose>
3193
+ </xsl:template><xsl:template name="insertTableColumnWidth">
3194
+ <xsl:param name="colwidths"/>
3195
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
3196
+ <xsl:choose>
3197
+ <xsl:when test=". = 1 or . = 0">
3198
+ <fo:table-column column-width="proportional-column-width(2)"/>
3199
+ </xsl:when>
3200
+ <xsl:otherwise>
3201
+ <fo:table-column column-width="proportional-column-width({.})"/>
3202
+ </xsl:otherwise>
3203
+ </xsl:choose>
3204
+ </xsl:for-each>
3172
3205
  </xsl:template><xsl:template name="getMaxLength_dt">
3173
3206
  <xsl:variable name="lengths">
3174
3207
  <xsl:for-each select="*[local-name()='dt']">
@@ -3192,7 +3225,6 @@
3192
3225
  <xsl:value-of select="$maxLength"/>
3193
3226
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
3194
3227
  <xsl:param name="key_iso"/>
3195
-
3196
3228
  <!-- <tr>
3197
3229
  <td>NOTE</td>
3198
3230
  <td>
@@ -3200,18 +3232,30 @@
3200
3232
  </td>
3201
3233
  </tr>
3202
3234
  -->
3203
- <fo:table-row>
3235
+ <!-- OLD Variant -->
3236
+ <!-- <fo:table-row>
3204
3237
  <fo:table-cell>
3205
3238
  <fo:block margin-top="6pt">
3206
3239
  <xsl:if test="normalize-space($key_iso) = 'true'">
3207
3240
  <xsl:attribute name="margin-top">0</xsl:attribute>
3208
3241
  </xsl:if>
3209
- <xsl:apply-templates select="*[local-name() = 'name']"/>
3242
+ <xsl:apply-templates select="*[local-name() = 'name']" />
3210
3243
  </fo:block>
3211
3244
  </fo:table-cell>
3212
3245
  <fo:table-cell>
3213
3246
  <fo:block>
3214
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3247
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
3248
+ </fo:block>
3249
+ </fo:table-cell>
3250
+ </fo:table-row> -->
3251
+ <!-- <tr>
3252
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
3253
+ </tr>
3254
+ -->
3255
+ <fo:table-row>
3256
+ <fo:table-cell number-columns-spanned="2">
3257
+ <fo:block>
3258
+ <xsl:call-template name="note"/>
3215
3259
  </fo:block>
3216
3260
  </fo:table-cell>
3217
3261
  </fo:table-row>
@@ -3313,13 +3357,15 @@
3313
3357
  <xsl:choose>
3314
3358
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
3315
3359
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
3316
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
3360
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
3317
3361
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
3318
3362
  </xsl:choose>
3319
3363
  </xsl:attribute>
3320
3364
  </xsl:if>
3321
3365
  <xsl:apply-templates/>
3322
3366
  </fo:inline>
3367
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
3368
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
3323
3369
  </xsl:template><xsl:template match="*[local-name()='underline']">
3324
3370
  <fo:inline text-decoration="underline">
3325
3371
  <xsl:apply-templates/>
@@ -3467,41 +3513,50 @@
3467
3513
  <fo:block break-after="page"/>
3468
3514
  <fo:block> </fo:block>
3469
3515
  <fo:block break-after="page"/>
3516
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
3517
+ <xsl:apply-templates/>
3470
3518
  </xsl:template><xsl:template name="tokenize">
3471
3519
  <xsl:param name="text"/>
3472
3520
  <xsl:param name="separator" select="' '"/>
3473
3521
  <xsl:choose>
3474
3522
  <xsl:when test="not(contains($text, $separator))">
3475
3523
  <word>
3476
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
3477
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
3478
3524
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
3479
- <xsl:variable name="len_str">
3480
- <xsl:choose>
3481
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
3482
- <xsl:value-of select="$len_str_tmp * 1.5"/>
3483
- </xsl:when>
3484
- <xsl:otherwise>
3485
- <xsl:value-of select="$len_str_tmp"/>
3486
- </xsl:otherwise>
3487
- </xsl:choose>
3488
- </xsl:variable>
3489
-
3490
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
3491
- <xsl:message>
3492
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
3493
- len_str=<xsl:value-of select="$len_str"/>
3494
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
3495
- </xsl:message>
3496
- </xsl:if> -->
3497
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
3498
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
3499
3525
  <xsl:choose>
3500
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
3501
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
3526
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
3527
+ <xsl:value-of select="$len_str_tmp"/>
3502
3528
  </xsl:when>
3503
3529
  <xsl:otherwise>
3504
- <xsl:value-of select="$len_str"/>
3530
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
3531
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
3532
+ <xsl:variable name="len_str">
3533
+ <xsl:choose>
3534
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
3535
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
3536
+ </xsl:when>
3537
+ <xsl:otherwise>
3538
+ <xsl:value-of select="$len_str_tmp"/>
3539
+ </xsl:otherwise>
3540
+ </xsl:choose>
3541
+ </xsl:variable>
3542
+
3543
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
3544
+ <xsl:message>
3545
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
3546
+ len_str=<xsl:value-of select="$len_str"/>
3547
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
3548
+ </xsl:message>
3549
+ </xsl:if> -->
3550
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
3551
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
3552
+ <xsl:choose>
3553
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
3554
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
3555
+ </xsl:when>
3556
+ <xsl:otherwise>
3557
+ <xsl:value-of select="$len_str"/>
3558
+ </xsl:otherwise>
3559
+ </xsl:choose>
3505
3560
  </xsl:otherwise>
3506
3561
  </xsl:choose>
3507
3562
  </word>
@@ -3776,6 +3831,9 @@
3776
3831
  <xsl:variable name="isDeleted" select="@deleted"/>
3777
3832
 
3778
3833
  <fo:inline xsl:use-attribute-sets="mathml-style">
3834
+
3835
+
3836
+
3779
3837
 
3780
3838
 
3781
3839
  <xsl:call-template name="setTrackChangesStyles">
@@ -3783,48 +3841,80 @@
3783
3841
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
3784
3842
  </xsl:call-template>
3785
3843
 
3844
+ <xsl:if test="$add_math_as_text = 'true'">
3845
+ <!-- insert helper tag -->
3846
+ <!-- set unique font-size (fiction) -->
3847
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
3848
+ <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 -->
3849
+ </xsl:if>
3786
3850
 
3787
-
3788
- <xsl:variable name="mathml">
3789
- <xsl:apply-templates select="." mode="mathml"/>
3851
+ <xsl:variable name="mathml_content">
3852
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
3790
3853
  </xsl:variable>
3791
- <fo:instream-foreign-object fox:alt-text="Math">
3792
3854
 
3855
+
3856
+ <xsl:call-template name="mathml_instream_object">
3857
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
3858
+ </xsl:call-template>
3793
3859
 
3794
-
3795
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3796
- <xsl:variable name="comment_text_">
3797
- <xsl:choose>
3798
- <xsl:when test="normalize-space($comment_text_following) != ''">
3799
- <xsl:value-of select="$comment_text_following"/>
3800
- </xsl:when>
3801
- <xsl:otherwise>
3802
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3803
- </xsl:otherwise>
3804
- </xsl:choose>
3805
- </xsl:variable>
3806
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3807
-
3808
- <xsl:if test="normalize-space($comment_text) != ''">
3809
- <!-- put Mathin Alternate Text -->
3810
- <xsl:attribute name="fox:alt-text">
3811
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
3812
- </xsl:attribute>
3813
- </xsl:if>
3814
-
3815
- <xsl:variable name="mathml_content">
3816
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
3817
- </xsl:variable>
3818
- <!-- put MathML in Actual Text -->
3819
- <xsl:attribute name="fox:actual-text">
3820
- <xsl:value-of select="$mathml_content"/>
3821
- </xsl:attribute>
3822
-
3823
-
3824
-
3825
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
3826
- </fo:instream-foreign-object>
3860
+
3827
3861
  </fo:inline>
3862
+ </xsl:template><xsl:template name="getMathml_comment_text">
3863
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3864
+ <xsl:variable name="comment_text_">
3865
+ <xsl:choose>
3866
+ <xsl:when test="normalize-space($comment_text_following) != ''">
3867
+ <xsl:value-of select="$comment_text_following"/>
3868
+ </xsl:when>
3869
+ <xsl:otherwise>
3870
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3871
+ </xsl:otherwise>
3872
+ </xsl:choose>
3873
+ </xsl:variable>
3874
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3875
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
3876
+ <xsl:value-of select="$comment_text"/>
3877
+ </xsl:template><xsl:template name="mathml_instream_object">
3878
+ <xsl:param name="comment_text"/>
3879
+ <xsl:param name="mathml_content"/>
3880
+
3881
+ <xsl:variable name="comment_text_">
3882
+ <xsl:choose>
3883
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
3884
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
3885
+ </xsl:choose>
3886
+ </xsl:variable>
3887
+
3888
+ <xsl:variable name="mathml">
3889
+ <xsl:apply-templates select="." mode="mathml"/>
3890
+ </xsl:variable>
3891
+
3892
+ <fo:instream-foreign-object fox:alt-text="Math">
3893
+
3894
+
3895
+
3896
+
3897
+
3898
+
3899
+
3900
+ <!-- put MathML in Actual Text -->
3901
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
3902
+ <xsl:attribute name="fox:actual-text">
3903
+ <xsl:value-of select="$mathml_content"/>
3904
+ </xsl:attribute>
3905
+
3906
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
3907
+ <xsl:if test="normalize-space($comment_text_) != ''">
3908
+ <!-- put Mathin Alternate Text -->
3909
+ <xsl:attribute name="fox:alt-text">
3910
+ <xsl:value-of select="$comment_text_"/>
3911
+ </xsl:attribute>
3912
+ </xsl:if>
3913
+ <!-- </xsl:if> -->
3914
+
3915
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
3916
+
3917
+ </fo:instream-foreign-object>
3828
3918
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
3829
3919
  <!-- <xsl:text>a+b</xsl:text> -->
3830
3920
  <xsl:text>&lt;</xsl:text>
@@ -3855,7 +3945,9 @@
3855
3945
  <!-- replace start and end spaces to non-break space -->
3856
3946
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
3857
3947
  </xsl:copy>
3858
- </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">
3948
+ </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">
3949
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
3950
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
3859
3951
  <xsl:variable name="target">
3860
3952
  <xsl:choose>
3861
3953
  <xsl:when test="@updatetype = 'true'">
@@ -4446,18 +4538,33 @@
4446
4538
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4447
4539
  <xsl:copy>
4448
4540
  <xsl:apply-templates select="@*" mode="svg_update"/>
4449
- <xsl:variable name="viewbox">
4541
+ <xsl:variable name="viewbox_">
4450
4542
  <xsl:call-template name="split">
4451
4543
  <xsl:with-param name="pText" select="@viewBox"/>
4452
4544
  <xsl:with-param name="sep" select="' '"/>
4453
4545
  </xsl:call-template>
4454
4546
  </xsl:variable>
4547
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
4548
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
4549
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
4550
+
4455
4551
  <xsl:attribute name="width">
4456
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4552
+ <xsl:choose>
4553
+ <xsl:when test="$width != ''">
4554
+ <xsl:value-of select="round($width)"/>
4555
+ </xsl:when>
4556
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
4557
+ </xsl:choose>
4457
4558
  </xsl:attribute>
4458
4559
  <xsl:attribute name="height">
4459
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4560
+ <xsl:choose>
4561
+ <xsl:when test="$height != ''">
4562
+ <xsl:value-of select="round($height)"/>
4563
+ </xsl:when>
4564
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
4565
+ </xsl:choose>
4460
4566
  </xsl:attribute>
4567
+
4461
4568
  <xsl:apply-templates mode="svg_update"/>
4462
4569
  </xsl:copy>
4463
4570
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -4652,7 +4759,11 @@
4652
4759
  <xsl:apply-templates mode="bookmarks"/>
4653
4760
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
4654
4761
  <xsl:apply-templates select="."/>
4655
- </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">
4762
+ </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">
4763
+ <xsl:apply-templates mode="contents"/>
4764
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
4765
+ <xsl:apply-templates mode="bookmarks"/>
4766
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
4656
4767
  <xsl:apply-templates mode="bookmarks"/>
4657
4768
  </xsl:template><xsl:template name="addBookmarks">
4658
4769
  <xsl:param name="contents"/>
@@ -4934,7 +5045,9 @@
4934
5045
  <xsl:apply-templates/>
4935
5046
  </xsl:otherwise>
4936
5047
  </xsl:choose>
4937
- </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">
5048
+ </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">
5049
+ <xsl:value-of select="."/>
5050
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
4938
5051
  <xsl:text> </xsl:text>
4939
5052
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
4940
5053
  <xsl:copy>
@@ -4965,9 +5078,22 @@
4965
5078
  </xsl:when>
4966
5079
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
4967
5080
  </xsl:choose>
5081
+ </xsl:template><xsl:template match="text()" mode="contents_item">
5082
+ <xsl:call-template name="keep_together_standard_number"/>
5083
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
5084
+ <xsl:apply-templates mode="contents_item"/>
4968
5085
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
4969
5086
 
4970
5087
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
5088
+
5089
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
5090
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
5091
+ </xsl:if>
5092
+
5093
+ <xsl:if test="ancestor::*[local-name() = 'example']">
5094
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
5095
+ </xsl:if>
5096
+
4971
5097
  <xsl:copy-of select="@id"/>
4972
5098
 
4973
5099
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -5445,39 +5571,67 @@
5445
5571
  </xsl:otherwise>
5446
5572
  </xsl:choose>
5447
5573
  </xsl:template><xsl:template match="*[local-name() = 'example']">
5448
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
5449
-
5574
+
5575
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
5576
+
5450
5577
 
5578
+
5451
5579
  <xsl:variable name="fo_element">
5452
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
5580
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
5453
5581
  block
5454
5582
  </xsl:variable>
5455
5583
 
5456
- <!-- display 'EXAMPLE' -->
5457
- <xsl:apply-templates select="*[local-name()='name']">
5458
- <xsl:with-param name="fo_element" select="$fo_element"/>
5459
- </xsl:apply-templates>
5584
+ <fo:block-container margin-left="0mm">
5460
5585
 
5461
- <xsl:choose>
5462
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
5463
- <fo:block-container xsl:use-attribute-sets="example-body-style">
5464
- <fo:block-container margin-left="0mm" margin-right="0mm">
5465
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5586
+ <xsl:choose>
5587
+
5588
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
5589
+
5590
+ <!-- display name 'EXAMPLE' in a separate block -->
5591
+ <fo:block>
5592
+ <xsl:apply-templates select="*[local-name()='name']">
5466
5593
  <xsl:with-param name="fo_element" select="$fo_element"/>
5467
5594
  </xsl:apply-templates>
5595
+ </fo:block>
5596
+
5597
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
5598
+ <fo:block-container margin-left="0mm" margin-right="0mm">
5599
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5600
+ <xsl:with-param name="fo_element" select="$fo_element"/>
5601
+ </xsl:apply-templates>
5602
+ </fo:block-container>
5468
5603
  </fo:block-container>
5469
- </fo:block-container>
5470
- </xsl:when>
5471
- <xsl:otherwise>
5472
- <fo:inline>
5473
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5474
- <xsl:with-param name="fo_element" select="$fo_element"/>
5475
- </xsl:apply-templates>
5476
- </fo:inline>
5477
- </xsl:otherwise>
5478
- </xsl:choose>
5479
-
5480
- </fo:block>
5604
+ </xsl:when> <!-- end block -->
5605
+
5606
+ <xsl:otherwise> <!-- inline -->
5607
+
5608
+ <!-- display 'EXAMPLE' and first element in the same line -->
5609
+ <fo:block>
5610
+ <xsl:apply-templates select="*[local-name()='name']">
5611
+ <xsl:with-param name="fo_element" select="$fo_element"/>
5612
+ </xsl:apply-templates>
5613
+ <fo:inline>
5614
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
5615
+ <xsl:with-param name="fo_element" select="$fo_element"/>
5616
+ </xsl:apply-templates>
5617
+ </fo:inline>
5618
+ </fo:block>
5619
+
5620
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
5621
+ <!-- display further elements in blocks -->
5622
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
5623
+ <fo:block-container margin-left="0mm" margin-right="0mm">
5624
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
5625
+ <xsl:with-param name="fo_element" select="'block'"/>
5626
+ </xsl:apply-templates>
5627
+ </fo:block-container>
5628
+ </fo:block-container>
5629
+ </xsl:if>
5630
+ </xsl:otherwise> <!-- end inline -->
5631
+
5632
+ </xsl:choose>
5633
+ </fo:block-container>
5634
+ </fo:block-container>
5481
5635
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
5482
5636
  <xsl:param name="fo_element">block</xsl:param>
5483
5637
 
@@ -5509,10 +5663,16 @@
5509
5663
  </xsl:variable>
5510
5664
  <xsl:choose>
5511
5665
  <xsl:when test="starts-with(normalize-space($element), 'block')">
5512
- <fo:block xsl:use-attribute-sets="example-p-style">
5513
-
5514
- <xsl:apply-templates/>
5515
- </fo:block>
5666
+ <fo:block-container>
5667
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
5668
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
5669
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
5670
+ </xsl:if>
5671
+ <fo:block xsl:use-attribute-sets="example-p-style">
5672
+
5673
+ <xsl:apply-templates/>
5674
+ </fo:block>
5675
+ </fo:block-container>
5516
5676
  </xsl:when>
5517
5677
  <xsl:otherwise>
5518
5678
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -5694,7 +5854,16 @@
5694
5854
  </fo:inline>
5695
5855
  </xsl:when>
5696
5856
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
5697
- <fo:inline><xsl:apply-templates/></fo:inline>
5857
+
5858
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
5859
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
5860
+ <xsl:choose>
5861
+ <xsl:when test="$uri_src != ''">
5862
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
5863
+ </xsl:when>
5864
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
5865
+ </xsl:choose>
5866
+
5698
5867
  </xsl:otherwise>
5699
5868
  </xsl:choose>
5700
5869
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -5860,10 +6029,24 @@
5860
6029
 
5861
6030
  </fo:block>
5862
6031
  <xsl:apply-templates/>
5863
- </xsl:template><xsl:template match="*[local-name() = 'review']">
6032
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
5864
6033
  <!-- comment 2019-11-29 -->
5865
6034
  <!-- <fo:block font-weight="bold">Review:</fo:block>
5866
6035
  <xsl:apply-templates /> -->
6036
+
6037
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
6038
+
6039
+ <xsl:choose>
6040
+ <!-- if there isn't the attribute '@from', then -->
6041
+ <xsl:when test="$id_from = ''">
6042
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
6043
+ </xsl:when>
6044
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
6045
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
6046
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
6047
+ </xsl:when>
6048
+ </xsl:choose>
6049
+
5867
6050
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
5868
6051
  <!-- 0xA0 to space replacement -->
5869
6052
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -6224,7 +6407,10 @@
6224
6407
  <!-- to split by '_' and other chars -->
6225
6408
  <xsl:call-template name="add-zero-spaces-java"/>
6226
6409
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
6227
- <fo:inline id="{@id}" font-size="1pt"/>
6410
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
6411
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
6412
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
6413
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
6228
6414
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
6229
6415
  <!-- <row>
6230
6416
  <date>05-07-2013</date>
@@ -6764,6 +6950,120 @@
6764
6950
  <xsl:apply-templates select="." mode="update_xml_step1"/>
6765
6951
  </xsl:for-each>
6766
6952
  </xsl:copy>
6953
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
6954
+ <xsl:apply-templates mode="update_xml_step1"/>
6955
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
6956
+ <xsl:copy>
6957
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
6958
+ </xsl:copy>
6959
+ </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">
6960
+
6961
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
6962
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
6963
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
6964
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
6965
+ <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))"/>
6966
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
6967
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
6968
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
6969
+ <xsl:with-param name="text" select="$text_"/>
6970
+ </xsl:call-template></text></xsl:variable>
6971
+
6972
+ <xsl:variable name="parent" select="local-name(..)"/>
6973
+
6974
+ <xsl:variable name="text2">
6975
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
6976
+ <xsl:copy-of select="."/>
6977
+ </xsl:for-each></text>
6978
+ </xsl:variable>
6979
+
6980
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
6981
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
6982
+ <xsl:variable name="text3">
6983
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
6984
+ <xsl:choose>
6985
+ <xsl:when test="self::text()">
6986
+ <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))"/>
6987
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
6988
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
6989
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
6990
+ <xsl:with-param name="text" select="$text_units_"/>
6991
+ </xsl:call-template></text></xsl:variable>
6992
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
6993
+ </xsl:when>
6994
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
6995
+ </xsl:choose>
6996
+ </xsl:for-each></text>
6997
+ </xsl:variable>
6998
+
6999
+ <xsl:choose>
7000
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
7001
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
7002
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
7003
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
7004
+ <xsl:choose>
7005
+ <xsl:when test="self::text()">
7006
+ <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))"/>
7007
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
7008
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
7009
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
7010
+ <xsl:with-param name="text" select="$text_dots_"/>
7011
+ </xsl:call-template></text></xsl:variable>
7012
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
7013
+ </xsl:when>
7014
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
7015
+ </xsl:choose>
7016
+ </xsl:for-each>
7017
+ </xsl:when>
7018
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
7019
+ </xsl:choose>
7020
+
7021
+ </xsl:template><xsl:template name="replace_text_tags">
7022
+ <xsl:param name="tag_open"/>
7023
+ <xsl:param name="tag_close"/>
7024
+ <xsl:param name="text"/>
7025
+ <xsl:choose>
7026
+ <xsl:when test="contains($text, $tag_open)">
7027
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
7028
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
7029
+
7030
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
7031
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
7032
+ </xsl:element>
7033
+
7034
+ <xsl:call-template name="replace_text_tags">
7035
+ <xsl:with-param name="tag_open" select="$tag_open"/>
7036
+ <xsl:with-param name="tag_close" select="$tag_close"/>
7037
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
7038
+ </xsl:call-template>
7039
+ </xsl:when>
7040
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
7041
+ </xsl:choose>
7042
+ </xsl:template><xsl:template name="printEdition">
7043
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
7044
+ <xsl:text> </xsl:text>
7045
+ <xsl:choose>
7046
+ <xsl:when test="$edition_i18n != ''">
7047
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
7048
+ <xsl:call-template name="capitalize">
7049
+ <xsl:with-param name="str" select="$edition_i18n"/>
7050
+ </xsl:call-template>
7051
+ </xsl:when>
7052
+ <xsl:otherwise>
7053
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
7054
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
7055
+ <xsl:call-template name="capitalize">
7056
+ <xsl:with-param name="str">
7057
+ <xsl:call-template name="getLocalizedString">
7058
+ <xsl:with-param name="key">edition</xsl:with-param>
7059
+ </xsl:call-template>
7060
+ </xsl:with-param>
7061
+ </xsl:call-template>
7062
+ <xsl:text> </xsl:text>
7063
+ <xsl:value-of select="$edition"/>
7064
+ </xsl:if>
7065
+ </xsl:otherwise>
7066
+ </xsl:choose>
6767
7067
  </xsl:template><xsl:template name="convertDate">
6768
7068
  <xsl:param name="date"/>
6769
7069
  <xsl:param name="format" select="'short'"/>