metanorma-bipm 2.0.8 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -225,7 +225,7 @@
225
225
  <fo:block font-size="10pt" border-bottom="0.5pt solid black" padding-bottom="2.5mm" margin-left="-1mm" space-after="4mm">
226
226
  <!-- Example: First edition July 2009 -->
227
227
  <xsl:call-template name="printEdition"/>
228
- <xsl:text>  </xsl:text>
228
+ <xsl:text>   </xsl:text>
229
229
  <xsl:call-template name="convertDate">
230
230
  <xsl:with-param name="date" select="(//jcgm:bipm-standard)[1]/jcgm:bibdata/jcgm:date[@type = 'published']/jcgm:on"/>
231
231
  </xsl:call-template>
@@ -487,7 +487,7 @@
487
487
  </fo:block>
488
488
 
489
489
  <xsl:variable name="edition">
490
- <xsl:apply-templates select="./*[local-name() = 'bibdata']/*[local-name() = 'edition']">
490
+ <xsl:apply-templates select="./*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) = '']">
491
491
  <xsl:with-param name="curr_lang" select="$curr_lang"/>
492
492
  </xsl:apply-templates>
493
493
  </xsl:variable>
@@ -794,24 +794,6 @@
794
794
  </xsl:template>
795
795
 
796
796
 
797
- <xsl:template match="mathml:math" priority="2">
798
- <fo:inline font-family="Cambria Math">
799
- <xsl:variable name="mathml">
800
- <xsl:apply-templates select="." mode="mathml"/>
801
- </xsl:variable>
802
- <fo:instream-foreign-object fox:alt-text="Math">
803
- <xsl:if test="local-name(../..) = 'formula' or (local-name(../..) = 'td' and count(../../*) = 1)">
804
- <xsl:attribute name="width">95%</xsl:attribute>
805
- <xsl:attribute name="content-height">100%</xsl:attribute>
806
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
807
- <xsl:attribute name="scaling">uniform</xsl:attribute>
808
- </xsl:if>
809
- <!-- <xsl:copy-of select="."/> -->
810
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
811
- </fo:instream-foreign-object>
812
- </fo:inline>
813
- </xsl:template>
814
-
815
797
  <!-- for chemical expressions, when prefix superscripted -->
816
798
  <xsl:template match="mathml:msup[count(*) = 2 and count(mathml:mrow) = 2]/mathml:mrow[1][count(*) = 1 and mathml:mtext and (mathml:mtext/text() = '' or not(mathml:mtext/text()))]/mathml:mtext" mode="mathml" priority="2">
817
799
  <mathml:mspace height="1ex"/>
@@ -905,29 +887,6 @@
905
887
  </xsl:template>
906
888
 
907
889
 
908
- <xsl:template name="printEdition">
909
- <xsl:variable name="edition" select="normalize-space(//*[local-name()='bibdata']/*[local-name()='edition'])"/>
910
- <xsl:text> </xsl:text>
911
- <xsl:choose>
912
- <xsl:when test="number($edition) = $edition">
913
- <xsl:call-template name="number-to-words">
914
- <xsl:with-param name="number" select="$edition"/>
915
- </xsl:call-template>
916
- </xsl:when>
917
- <xsl:when test="$edition != ''">
918
- <xsl:value-of select="$edition"/>
919
- </xsl:when>
920
- </xsl:choose>
921
- <xsl:variable name="title-edition">
922
- <xsl:call-template name="getTitle">
923
- <xsl:with-param name="name" select="'title-edition'"/>
924
- </xsl:call-template>
925
- </xsl:variable>
926
- <xsl:if test="$edition != ''"><xsl:text> </xsl:text><xsl:value-of select="java:toLowerCase(java:java.lang.String.new($title-edition))"/></xsl:if>
927
- </xsl:template>
928
-
929
-
930
-
931
890
  <!-- ================ -->
932
891
  <!-- JCGM specific templates -->
933
892
  <!-- ================ -->
@@ -1152,14 +1111,8 @@
1152
1111
  <xsl:param name="font-size" select="'65%'"/>
1153
1112
  <xsl:param name="baseline-shift" select="'30%'"/>
1154
1113
  <xsl:param name="curr_lang" select="'fr'"/>
1155
- <xsl:if test="normalize-space (.) != '1'">
1114
+ <xsl:if test="normalize-space (.) != '1'"> <!-- no need to show '1st edition' -->
1156
1115
  <fo:inline>
1157
- <xsl:variable name="title-edition">
1158
- <xsl:call-template name="getTitle">
1159
- <xsl:with-param name="name" select="'title-edition'"/>
1160
- <xsl:with-param name="lang" select="$curr_lang"/>
1161
- </xsl:call-template>
1162
- </xsl:variable>
1163
1116
  <xsl:value-of select="."/>
1164
1117
  <fo:inline font-size="{$font-size}" baseline-shift="{$baseline-shift}">
1165
1118
  <xsl:if test="$curr_lang = 'en'">
@@ -1172,7 +1125,9 @@
1172
1125
  </xsl:call-template>
1173
1126
  </fo:inline>
1174
1127
  <xsl:text> </xsl:text>
1175
- <xsl:value-of select="java:toLowerCase(java:java.lang.String.new($title-edition))"/>
1128
+ <xsl:call-template name="getLocalizedString">
1129
+ <xsl:with-param name="key">edition</xsl:with-param>
1130
+ </xsl:call-template>
1176
1131
  <xsl:text/>
1177
1132
  </fo:inline>
1178
1133
  </xsl:if>
@@ -1766,7 +1721,7 @@
1766
1721
  </fo:block-container>
1767
1722
  </xsl:template>
1768
1723
 
1769
- <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">
1724
+ <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">
1770
1725
  <xsl:call-template name="getLang"/>
1771
1726
  </xsl:variable><xsl:variable name="pageWidth_">
1772
1727
  210
@@ -1781,20 +1736,7 @@
1781
1736
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1782
1737
  23.5
1783
1738
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1784
-
1785
- <title-edition lang="en">
1786
-
1787
- <xsl:text>Edition </xsl:text>
1788
-
1789
- </title-edition>
1790
-
1791
- <title-edition lang="fr">
1792
- <xsl:text>Édition </xsl:text>
1793
- </title-edition>
1794
1739
 
1795
- <title-edition lang="ru">
1796
- <xsl:text>Издание </xsl:text>
1797
- </title-edition>
1798
1740
 
1799
1741
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1800
1742
  <title-toc lang="en">
@@ -1873,7 +1815,7 @@
1873
1815
  </xsl:variable><xsl:variable name="bibdata">
1874
1816
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1875
1817
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1876
- </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">
1818
+ </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">
1877
1819
  <xsl:param name="name"/>
1878
1820
  <xsl:param name="lang"/>
1879
1821
  <xsl:variable name="lang_">
@@ -1921,7 +1863,7 @@
1921
1863
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1922
1864
 
1923
1865
  <xsl:variable name="additional_fonts_">
1924
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
1866
+ <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']">
1925
1867
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1926
1868
  </xsl:for-each>
1927
1869
  </xsl:variable>
@@ -1996,7 +1938,6 @@
1996
1938
 
1997
1939
 
1998
1940
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1999
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2000
1941
 
2001
1942
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
2002
1943
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -2084,6 +2025,7 @@
2084
2025
 
2085
2026
 
2086
2027
 
2028
+
2087
2029
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2088
2030
 
2089
2031
 
@@ -2678,6 +2620,8 @@
2678
2620
  </xsl:attribute-set><xsl:attribute-set name="mathml-style">
2679
2621
  <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
2680
2622
 
2623
+ <xsl:attribute name="font-family">Cambria Math</xsl:attribute>
2624
+
2681
2625
 
2682
2626
  </xsl:attribute-set><xsl:attribute-set name="list-style">
2683
2627
 
@@ -3188,22 +3132,32 @@
3188
3132
  <xsl:sort select="@displayorder" data-type="number"/>
3189
3133
  <xsl:apply-templates select="."/>
3190
3134
  </xsl:for-each>
3191
- </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">
3192
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3193
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3194
- <xsl:call-template name="replace_fo_inline">
3195
- <xsl:with-param name="text" select="$text"/>
3196
- </xsl:call-template>
3197
- </xsl:template><xsl:template name="replace_fo_inline">
3135
+ </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">
3136
+
3137
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3138
+ <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))"/>
3139
+ <xsl:call-template name="replace_fo_inline_tags">
3140
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3141
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3142
+ <xsl:with-param name="text" select="$text"/>
3143
+ </xsl:call-template>
3144
+
3145
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3146
+ <xsl:param name="tag_open"/>
3147
+ <xsl:param name="tag_close"/>
3198
3148
  <xsl:param name="text"/>
3199
3149
  <xsl:choose>
3200
3150
  <xsl:when test="contains($text, $tag_open)">
3201
3151
  <xsl:value-of select="substring-before($text, $tag_open)"/>
3202
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3152
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3203
3153
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3204
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3205
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3206
- <xsl:call-template name="replace_fo_inline">
3154
+ <fo:inline keep-together.within-line="always">
3155
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3156
+ </fo:inline>
3157
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3158
+ <xsl:call-template name="replace_fo_inline_tags">
3159
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3160
+ <xsl:with-param name="tag_close" select="$tag_close"/>
3207
3161
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3208
3162
  </xsl:call-template>
3209
3163
  </xsl:when>
@@ -3211,6 +3165,8 @@
3211
3165
  </xsl:choose>
3212
3166
  </xsl:template><xsl:template match="*[local-name()='br']">
3213
3167
  <xsl:value-of select="$linebreak"/>
3168
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3169
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3214
3170
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3215
3171
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3216
3172
  <xsl:apply-templates/>
@@ -3276,8 +3232,23 @@
3276
3232
  </xsl:call-template>
3277
3233
 
3278
3234
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3279
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3280
- <xsl:call-template name="add-zero-spaces-java"/>
3235
+ <xsl:choose>
3236
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3237
+ <xsl:value-of select="."/>
3238
+ </xsl:when>
3239
+ <xsl:otherwise>
3240
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3241
+ </xsl:otherwise>
3242
+ </xsl:choose>
3243
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3244
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3245
+ <!-- <xsl:copy-of select="$text"/> -->
3246
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3247
+ <xsl:choose>
3248
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3249
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3250
+ </xsl:choose>
3251
+ </xsl:for-each>
3281
3252
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3282
3253
 
3283
3254
  <xsl:variable name="table-preamble">
@@ -3395,16 +3366,9 @@
3395
3366
  </xsl:for-each>
3396
3367
  </xsl:when>
3397
3368
  <xsl:otherwise>
3398
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3399
- <xsl:choose>
3400
- <xsl:when test=". = 1 or . = 0">
3401
- <fo:table-column column-width="proportional-column-width(2)"/>
3402
- </xsl:when>
3403
- <xsl:otherwise>
3404
- <fo:table-column column-width="proportional-column-width({.})"/>
3405
- </xsl:otherwise>
3406
- </xsl:choose>
3407
- </xsl:for-each>
3369
+ <xsl:call-template name="insertTableColumnWidth">
3370
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3371
+ </xsl:call-template>
3408
3372
  </xsl:otherwise>
3409
3373
  </xsl:choose>
3410
3374
 
@@ -3570,6 +3534,7 @@
3570
3534
  <xsl:with-param name="text" select="$td_text"/>
3571
3535
  </xsl:call-template>
3572
3536
  </xsl:variable>
3537
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3573
3538
  <xsl:call-template name="tokenize">
3574
3539
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3575
3540
  <!-- 2009 thinspace -->
@@ -3582,6 +3547,7 @@
3582
3547
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3583
3548
  </xsl:call-template>
3584
3549
  </xsl:variable>
3550
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3585
3551
  <width>
3586
3552
  <xsl:variable name="divider">
3587
3553
  <xsl:choose>
@@ -3614,6 +3580,10 @@
3614
3580
  <xsl:with-param name="table" select="$table"/>
3615
3581
  </xsl:call-template>
3616
3582
  </xsl:if>
3583
+ </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
3584
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3585
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3586
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3617
3587
  </xsl:template><xsl:template match="text()" mode="td_text">
3618
3588
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3619
3589
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
@@ -3728,16 +3698,9 @@
3728
3698
  </xsl:for-each>
3729
3699
  </xsl:when>
3730
3700
  <xsl:otherwise>
3731
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3732
- <xsl:choose>
3733
- <xsl:when test=". = 1 or . = 0">
3734
- <fo:table-column column-width="proportional-column-width(2)"/>
3735
- </xsl:when>
3736
- <xsl:otherwise>
3737
- <fo:table-column column-width="proportional-column-width({.})"/>
3738
- </xsl:otherwise>
3739
- </xsl:choose>
3740
- </xsl:for-each>
3701
+ <xsl:call-template name="insertTableColumnWidth">
3702
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3703
+ </xsl:call-template>
3741
3704
  </xsl:otherwise>
3742
3705
  </xsl:choose>
3743
3706
 
@@ -4348,8 +4311,10 @@
4348
4311
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4349
4312
  </xsl:variable>
4350
4313
 
4314
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
4315
+
4351
4316
  <xsl:choose>
4352
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
4317
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4353
4318
 
4354
4319
  <fo:block margin-bottom="12pt" text-align="left">
4355
4320
 
@@ -4366,7 +4331,7 @@
4366
4331
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4367
4332
  </fo:block>
4368
4333
 
4369
- </xsl:when>
4334
+ </xsl:when> <!-- END: only one component -->
4370
4335
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4371
4336
  <fo:block margin-bottom="12pt" text-align="left">
4372
4337
 
@@ -4382,8 +4347,8 @@
4382
4347
  </xsl:variable>
4383
4348
  <xsl:value-of select="$title-where"/>
4384
4349
  </fo:block>
4385
- </xsl:when>
4386
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
4350
+ </xsl:when> <!-- END: a few components -->
4351
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4387
4352
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4388
4353
 
4389
4354
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -4399,11 +4364,11 @@
4399
4364
  </xsl:variable>
4400
4365
  <xsl:value-of select="$title-key"/>
4401
4366
  </fo:block>
4402
- </xsl:when>
4367
+ </xsl:when> <!-- END: definition list in a figure -->
4403
4368
  </xsl:choose>
4404
4369
 
4405
4370
  <!-- a few components -->
4406
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
4371
+ <xsl:if test="$onlyOneComponent = 'false'">
4407
4372
  <fo:block>
4408
4373
 
4409
4374
  <xsl:if test="$parent = 'formula'">
@@ -4447,21 +4412,28 @@
4447
4412
  <xsl:apply-templates mode="dl"/>
4448
4413
  </tbody>
4449
4414
  </xsl:variable>
4450
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4415
+ <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
4451
4416
  <xsl:variable name="colwidths">
4452
4417
  <xsl:call-template name="calculate-column-widths">
4453
4418
  <xsl:with-param name="cols-count" select="2"/>
4454
4419
  <xsl:with-param name="table" select="$html-table"/>
4455
4420
  </xsl:call-template>
4456
4421
  </xsl:variable>
4457
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4422
+ <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
4458
4423
  <xsl:variable name="maxlength_dt">
4459
4424
  <xsl:call-template name="getMaxLength_dt"/>
4460
4425
  </xsl:variable>
4426
+ <xsl:variable name="isContainsKeepTogetherTag_">
4427
+ false
4428
+ </xsl:variable>
4429
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4430
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4461
4431
  <xsl:call-template name="setColumnWidth_dl">
4462
4432
  <xsl:with-param name="colwidths" select="$colwidths"/>
4463
4433
  <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4434
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4464
4435
  </xsl:call-template>
4436
+
4465
4437
  <fo:table-body>
4466
4438
  <xsl:apply-templates>
4467
4439
  <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
@@ -4470,12 +4442,13 @@
4470
4442
  </fo:table>
4471
4443
  </fo:block>
4472
4444
  </fo:block>
4473
- </xsl:if>
4445
+ </xsl:if> <!-- END: a few components -->
4474
4446
  </fo:block-container>
4475
4447
  </fo:block-container>
4476
4448
  </xsl:template><xsl:template name="setColumnWidth_dl">
4477
4449
  <xsl:param name="colwidths"/>
4478
4450
  <xsl:param name="maxlength_dt"/>
4451
+ <xsl:param name="isContainsKeepTogetherTag"/>
4479
4452
  <xsl:choose>
4480
4453
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4481
4454
  <fo:table-column column-width="50%"/>
@@ -4483,6 +4456,11 @@
4483
4456
  </xsl:when>
4484
4457
  <xsl:otherwise>
4485
4458
  <xsl:choose>
4459
+ <xsl:when test="$isContainsKeepTogetherTag">
4460
+ <xsl:call-template name="insertTableColumnWidth">
4461
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4462
+ </xsl:call-template>
4463
+ </xsl:when>
4486
4464
  <!-- to set width check most wide chars like `W` -->
4487
4465
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
4488
4466
  <fo:table-column column-width="7%"/>
@@ -4513,20 +4491,25 @@
4513
4491
  <fo:table-column column-width="60%"/>
4514
4492
  </xsl:when>
4515
4493
  <xsl:otherwise>
4516
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
4517
- <xsl:choose>
4518
- <xsl:when test=". = 1 or . = 0">
4519
- <fo:table-column column-width="proportional-column-width(2)"/>
4520
- </xsl:when>
4521
- <xsl:otherwise>
4522
- <fo:table-column column-width="proportional-column-width({.})"/>
4523
- </xsl:otherwise>
4524
- </xsl:choose>
4525
- </xsl:for-each>
4494
+ <xsl:call-template name="insertTableColumnWidth">
4495
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4496
+ </xsl:call-template>
4526
4497
  </xsl:otherwise>
4527
4498
  </xsl:choose>
4528
4499
  </xsl:otherwise>
4529
4500
  </xsl:choose>
4501
+ </xsl:template><xsl:template name="insertTableColumnWidth">
4502
+ <xsl:param name="colwidths"/>
4503
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
4504
+ <xsl:choose>
4505
+ <xsl:when test=". = 1 or . = 0">
4506
+ <fo:table-column column-width="proportional-column-width(2)"/>
4507
+ </xsl:when>
4508
+ <xsl:otherwise>
4509
+ <fo:table-column column-width="proportional-column-width({.})"/>
4510
+ </xsl:otherwise>
4511
+ </xsl:choose>
4512
+ </xsl:for-each>
4530
4513
  </xsl:template><xsl:template name="getMaxLength_dt">
4531
4514
  <xsl:variable name="lengths">
4532
4515
  <xsl:for-each select="*[local-name()='dt']">
@@ -4550,7 +4533,6 @@
4550
4533
  <xsl:value-of select="$maxLength"/>
4551
4534
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4552
4535
  <xsl:param name="key_iso"/>
4553
-
4554
4536
  <!-- <tr>
4555
4537
  <td>NOTE</td>
4556
4538
  <td>
@@ -4558,18 +4540,30 @@
4558
4540
  </td>
4559
4541
  </tr>
4560
4542
  -->
4561
- <fo:table-row>
4543
+ <!-- OLD Variant -->
4544
+ <!-- <fo:table-row>
4562
4545
  <fo:table-cell>
4563
4546
  <fo:block margin-top="6pt">
4564
4547
  <xsl:if test="normalize-space($key_iso) = 'true'">
4565
4548
  <xsl:attribute name="margin-top">0</xsl:attribute>
4566
4549
  </xsl:if>
4567
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4550
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4568
4551
  </fo:block>
4569
4552
  </fo:table-cell>
4570
4553
  <fo:table-cell>
4571
4554
  <fo:block>
4572
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4555
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4556
+ </fo:block>
4557
+ </fo:table-cell>
4558
+ </fo:table-row> -->
4559
+ <!-- <tr>
4560
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4561
+ </tr>
4562
+ -->
4563
+ <fo:table-row>
4564
+ <fo:table-cell number-columns-spanned="2">
4565
+ <fo:block>
4566
+ <xsl:call-template name="note"/>
4573
4567
  </fo:block>
4574
4568
  </fo:table-cell>
4575
4569
  </fo:table-row>
@@ -4671,13 +4665,15 @@
4671
4665
  <xsl:choose>
4672
4666
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4673
4667
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4674
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4668
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4675
4669
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4676
4670
  </xsl:choose>
4677
4671
  </xsl:attribute>
4678
4672
  </xsl:if>
4679
4673
  <xsl:apply-templates/>
4680
4674
  </fo:inline>
4675
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
4676
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4681
4677
  </xsl:template><xsl:template match="*[local-name()='underline']">
4682
4678
  <fo:inline text-decoration="underline">
4683
4679
  <xsl:apply-templates/>
@@ -4825,41 +4821,50 @@
4825
4821
  <fo:block break-after="page"/>
4826
4822
  <fo:block> </fo:block>
4827
4823
  <fo:block break-after="page"/>
4824
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
4825
+ <xsl:apply-templates/>
4828
4826
  </xsl:template><xsl:template name="tokenize">
4829
4827
  <xsl:param name="text"/>
4830
4828
  <xsl:param name="separator" select="' '"/>
4831
4829
  <xsl:choose>
4832
4830
  <xsl:when test="not(contains($text, $separator))">
4833
4831
  <word>
4834
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4835
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4836
4832
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4837
- <xsl:variable name="len_str">
4838
- <xsl:choose>
4839
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4840
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4841
- </xsl:when>
4842
- <xsl:otherwise>
4843
- <xsl:value-of select="$len_str_tmp"/>
4844
- </xsl:otherwise>
4845
- </xsl:choose>
4846
- </xsl:variable>
4847
-
4848
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4849
- <xsl:message>
4850
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4851
- len_str=<xsl:value-of select="$len_str"/>
4852
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4853
- </xsl:message>
4854
- </xsl:if> -->
4855
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4856
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4857
4833
  <xsl:choose>
4858
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4859
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4834
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
4835
+ <xsl:value-of select="$len_str_tmp"/>
4860
4836
  </xsl:when>
4861
4837
  <xsl:otherwise>
4862
- <xsl:value-of select="$len_str"/>
4838
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4839
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4840
+ <xsl:variable name="len_str">
4841
+ <xsl:choose>
4842
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4843
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
4844
+ </xsl:when>
4845
+ <xsl:otherwise>
4846
+ <xsl:value-of select="$len_str_tmp"/>
4847
+ </xsl:otherwise>
4848
+ </xsl:choose>
4849
+ </xsl:variable>
4850
+
4851
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4852
+ <xsl:message>
4853
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4854
+ len_str=<xsl:value-of select="$len_str"/>
4855
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4856
+ </xsl:message>
4857
+ </xsl:if> -->
4858
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4859
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
4860
+ <xsl:choose>
4861
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4862
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4863
+ </xsl:when>
4864
+ <xsl:otherwise>
4865
+ <xsl:value-of select="$len_str"/>
4866
+ </xsl:otherwise>
4867
+ </xsl:choose>
4863
4868
  </xsl:otherwise>
4864
4869
  </xsl:choose>
4865
4870
  </word>
@@ -5134,6 +5139,9 @@
5134
5139
  <xsl:variable name="isDeleted" select="@deleted"/>
5135
5140
 
5136
5141
  <fo:inline xsl:use-attribute-sets="mathml-style">
5142
+
5143
+
5144
+
5137
5145
 
5138
5146
 
5139
5147
  <xsl:call-template name="setTrackChangesStyles">
@@ -5141,48 +5149,87 @@
5141
5149
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
5142
5150
  </xsl:call-template>
5143
5151
 
5152
+ <xsl:if test="$add_math_as_text = 'true'">
5153
+ <!-- insert helper tag -->
5154
+ <!-- set unique font-size (fiction) -->
5155
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
5156
+ <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 -->
5157
+ </xsl:if>
5144
5158
 
5145
-
5146
- <xsl:variable name="mathml">
5147
- <xsl:apply-templates select="." mode="mathml"/>
5159
+ <xsl:variable name="mathml_content">
5160
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
5148
5161
  </xsl:variable>
5149
- <fo:instream-foreign-object fox:alt-text="Math">
5150
5162
 
5163
+
5164
+ <xsl:call-template name="mathml_instream_object">
5165
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
5166
+ </xsl:call-template>
5151
5167
 
5152
-
5153
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5154
- <xsl:variable name="comment_text_">
5155
- <xsl:choose>
5156
- <xsl:when test="normalize-space($comment_text_following) != ''">
5157
- <xsl:value-of select="$comment_text_following"/>
5158
- </xsl:when>
5159
- <xsl:otherwise>
5160
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5161
- </xsl:otherwise>
5162
- </xsl:choose>
5163
- </xsl:variable>
5164
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5165
-
5166
- <xsl:if test="normalize-space($comment_text) != ''">
5167
- <!-- put Mathin Alternate Text -->
5168
- <xsl:attribute name="fox:alt-text">
5169
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
5170
- </xsl:attribute>
5168
+
5169
+ </fo:inline>
5170
+ </xsl:template><xsl:template name="getMathml_comment_text">
5171
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5172
+ <xsl:variable name="comment_text_">
5173
+ <xsl:choose>
5174
+ <xsl:when test="normalize-space($comment_text_following) != ''">
5175
+ <xsl:value-of select="$comment_text_following"/>
5176
+ </xsl:when>
5177
+ <xsl:otherwise>
5178
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5179
+ </xsl:otherwise>
5180
+ </xsl:choose>
5181
+ </xsl:variable>
5182
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5183
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
5184
+ <xsl:value-of select="$comment_text"/>
5185
+ </xsl:template><xsl:template name="mathml_instream_object">
5186
+ <xsl:param name="comment_text"/>
5187
+ <xsl:param name="mathml_content"/>
5188
+
5189
+ <xsl:variable name="comment_text_">
5190
+ <xsl:choose>
5191
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
5192
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
5193
+ </xsl:choose>
5194
+ </xsl:variable>
5195
+
5196
+ <xsl:variable name="mathml">
5197
+ <xsl:apply-templates select="." mode="mathml"/>
5198
+ </xsl:variable>
5199
+
5200
+ <fo:instream-foreign-object fox:alt-text="Math">
5201
+
5202
+
5203
+
5204
+
5205
+
5206
+
5207
+ <xsl:if test="local-name(../..) = 'formula' or (local-name(../..) = 'td' and count(../../*) = 1)">
5208
+ <xsl:attribute name="width">95%</xsl:attribute>
5209
+ <xsl:attribute name="content-height">100%</xsl:attribute>
5210
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5211
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5171
5212
  </xsl:if>
5172
-
5173
- <xsl:variable name="mathml_content">
5174
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
5175
- </xsl:variable>
5176
- <!-- put MathML in Actual Text -->
5177
- <xsl:attribute name="fox:actual-text">
5178
- <xsl:value-of select="$mathml_content"/>
5213
+
5214
+
5215
+ <!-- put MathML in Actual Text -->
5216
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
5217
+ <xsl:attribute name="fox:actual-text">
5218
+ <xsl:value-of select="$mathml_content"/>
5219
+ </xsl:attribute>
5220
+
5221
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
5222
+ <xsl:if test="normalize-space($comment_text_) != ''">
5223
+ <!-- put Mathin Alternate Text -->
5224
+ <xsl:attribute name="fox:alt-text">
5225
+ <xsl:value-of select="$comment_text_"/>
5179
5226
  </xsl:attribute>
5180
-
5181
-
5182
-
5183
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
5184
- </fo:instream-foreign-object>
5185
- </fo:inline>
5227
+ </xsl:if>
5228
+ <!-- </xsl:if> -->
5229
+
5230
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
5231
+
5232
+ </fo:instream-foreign-object>
5186
5233
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
5187
5234
  <!-- <xsl:text>a+b</xsl:text> -->
5188
5235
  <xsl:text>&lt;</xsl:text>
@@ -5213,7 +5260,9 @@
5213
5260
  <!-- replace start and end spaces to non-break space -->
5214
5261
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
5215
5262
  </xsl:copy>
5216
- </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">
5263
+ </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">
5264
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5265
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5217
5266
  <xsl:variable name="target">
5218
5267
  <xsl:choose>
5219
5268
  <xsl:when test="@updatetype = 'true'">
@@ -5806,18 +5855,33 @@
5806
5855
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5807
5856
  <xsl:copy>
5808
5857
  <xsl:apply-templates select="@*" mode="svg_update"/>
5809
- <xsl:variable name="viewbox">
5858
+ <xsl:variable name="viewbox_">
5810
5859
  <xsl:call-template name="split">
5811
5860
  <xsl:with-param name="pText" select="@viewBox"/>
5812
5861
  <xsl:with-param name="sep" select="' '"/>
5813
5862
  </xsl:call-template>
5814
5863
  </xsl:variable>
5864
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
5865
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
5866
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
5867
+
5815
5868
  <xsl:attribute name="width">
5816
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
5869
+ <xsl:choose>
5870
+ <xsl:when test="$width != ''">
5871
+ <xsl:value-of select="round($width)"/>
5872
+ </xsl:when>
5873
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
5874
+ </xsl:choose>
5817
5875
  </xsl:attribute>
5818
5876
  <xsl:attribute name="height">
5819
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
5877
+ <xsl:choose>
5878
+ <xsl:when test="$height != ''">
5879
+ <xsl:value-of select="round($height)"/>
5880
+ </xsl:when>
5881
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
5882
+ </xsl:choose>
5820
5883
  </xsl:attribute>
5884
+
5821
5885
  <xsl:apply-templates mode="svg_update"/>
5822
5886
  </xsl:copy>
5823
5887
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -6012,7 +6076,11 @@
6012
6076
  <xsl:apply-templates mode="bookmarks"/>
6013
6077
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
6014
6078
  <xsl:apply-templates select="."/>
6015
- </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">
6079
+ </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">
6080
+ <xsl:apply-templates mode="contents"/>
6081
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
6082
+ <xsl:apply-templates mode="bookmarks"/>
6083
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
6016
6084
  <xsl:apply-templates mode="bookmarks"/>
6017
6085
  </xsl:template><xsl:template name="addBookmarks">
6018
6086
  <xsl:param name="contents"/>
@@ -6294,7 +6362,9 @@
6294
6362
  <xsl:apply-templates/>
6295
6363
  </xsl:otherwise>
6296
6364
  </xsl:choose>
6297
- </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">
6365
+ </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">
6366
+ <xsl:value-of select="."/>
6367
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6298
6368
  <xsl:text> </xsl:text>
6299
6369
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6300
6370
  <xsl:copy>
@@ -6325,9 +6395,22 @@
6325
6395
  </xsl:when>
6326
6396
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6327
6397
  </xsl:choose>
6398
+ </xsl:template><xsl:template match="text()" mode="contents_item">
6399
+ <xsl:call-template name="keep_together_standard_number"/>
6400
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
6401
+ <xsl:apply-templates mode="contents_item"/>
6328
6402
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6329
6403
 
6330
6404
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
6405
+
6406
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
6407
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6408
+ </xsl:if>
6409
+
6410
+ <xsl:if test="ancestor::*[local-name() = 'example']">
6411
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6412
+ </xsl:if>
6413
+
6331
6414
  <xsl:copy-of select="@id"/>
6332
6415
 
6333
6416
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6805,39 +6888,67 @@
6805
6888
  </xsl:otherwise>
6806
6889
  </xsl:choose>
6807
6890
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6808
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6809
-
6891
+
6892
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
6893
+
6810
6894
 
6895
+
6811
6896
  <xsl:variable name="fo_element">
6812
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
6897
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6813
6898
  inline
6814
6899
  </xsl:variable>
6815
6900
 
6816
- <!-- display 'EXAMPLE' -->
6817
- <xsl:apply-templates select="*[local-name()='name']">
6818
- <xsl:with-param name="fo_element" select="$fo_element"/>
6819
- </xsl:apply-templates>
6901
+ <fo:block-container margin-left="0mm">
6820
6902
 
6821
- <xsl:choose>
6822
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6823
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6824
- <fo:block-container margin-left="0mm" margin-right="0mm">
6825
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6903
+ <xsl:choose>
6904
+
6905
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
6906
+
6907
+ <!-- display name 'EXAMPLE' in a separate block -->
6908
+ <fo:block>
6909
+ <xsl:apply-templates select="*[local-name()='name']">
6826
6910
  <xsl:with-param name="fo_element" select="$fo_element"/>
6827
6911
  </xsl:apply-templates>
6912
+ </fo:block>
6913
+
6914
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6915
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6916
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6917
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6918
+ </xsl:apply-templates>
6919
+ </fo:block-container>
6828
6920
  </fo:block-container>
6829
- </fo:block-container>
6830
- </xsl:when>
6831
- <xsl:otherwise>
6832
- <fo:inline>
6833
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6834
- <xsl:with-param name="fo_element" select="$fo_element"/>
6835
- </xsl:apply-templates>
6836
- </fo:inline>
6837
- </xsl:otherwise>
6838
- </xsl:choose>
6839
-
6840
- </fo:block>
6921
+ </xsl:when> <!-- end block -->
6922
+
6923
+ <xsl:otherwise> <!-- inline -->
6924
+
6925
+ <!-- display 'EXAMPLE' and first element in the same line -->
6926
+ <fo:block>
6927
+ <xsl:apply-templates select="*[local-name()='name']">
6928
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6929
+ </xsl:apply-templates>
6930
+ <fo:inline>
6931
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
6932
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6933
+ </xsl:apply-templates>
6934
+ </fo:inline>
6935
+ </fo:block>
6936
+
6937
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
6938
+ <!-- display further elements in blocks -->
6939
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6940
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6941
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
6942
+ <xsl:with-param name="fo_element" select="'block'"/>
6943
+ </xsl:apply-templates>
6944
+ </fo:block-container>
6945
+ </fo:block-container>
6946
+ </xsl:if>
6947
+ </xsl:otherwise> <!-- end inline -->
6948
+
6949
+ </xsl:choose>
6950
+ </fo:block-container>
6951
+ </fo:block-container>
6841
6952
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6842
6953
  <xsl:param name="fo_element">block</xsl:param>
6843
6954
 
@@ -6874,10 +6985,16 @@
6874
6985
  </xsl:variable>
6875
6986
  <xsl:choose>
6876
6987
  <xsl:when test="starts-with(normalize-space($element), 'block')">
6877
- <fo:block xsl:use-attribute-sets="example-p-style">
6878
-
6879
- <xsl:apply-templates/>
6880
- </fo:block>
6988
+ <fo:block-container>
6989
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
6990
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6991
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6992
+ </xsl:if>
6993
+ <fo:block xsl:use-attribute-sets="example-p-style">
6994
+
6995
+ <xsl:apply-templates/>
6996
+ </fo:block>
6997
+ </fo:block-container>
6881
6998
  </xsl:when>
6882
6999
  <xsl:otherwise>
6883
7000
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -7066,7 +7183,16 @@
7066
7183
  </fo:inline>
7067
7184
  </xsl:when>
7068
7185
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7069
- <fo:inline><xsl:apply-templates/></fo:inline>
7186
+
7187
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
7188
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
7189
+ <xsl:choose>
7190
+ <xsl:when test="$uri_src != ''">
7191
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
7192
+ </xsl:when>
7193
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
7194
+ </xsl:choose>
7195
+
7070
7196
  </xsl:otherwise>
7071
7197
  </xsl:choose>
7072
7198
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7246,10 +7372,24 @@
7246
7372
 
7247
7373
  </fo:block>
7248
7374
  <xsl:apply-templates/>
7249
- </xsl:template><xsl:template match="*[local-name() = 'review']">
7375
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7250
7376
  <!-- comment 2019-11-29 -->
7251
7377
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7252
7378
  <xsl:apply-templates /> -->
7379
+
7380
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
7381
+
7382
+ <xsl:choose>
7383
+ <!-- if there isn't the attribute '@from', then -->
7384
+ <xsl:when test="$id_from = ''">
7385
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7386
+ </xsl:when>
7387
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
7388
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
7389
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7390
+ </xsl:when>
7391
+ </xsl:choose>
7392
+
7253
7393
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7254
7394
  <!-- 0xA0 to space replacement -->
7255
7395
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7608,7 +7748,10 @@
7608
7748
  <!-- to split by '_' and other chars -->
7609
7749
  <xsl:call-template name="add-zero-spaces-java"/>
7610
7750
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7611
- <fo:inline id="{@id}" font-size="1pt"/>
7751
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
7752
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
7753
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
7754
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
7612
7755
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7613
7756
  <!-- <row>
7614
7757
  <date>05-07-2013</date>
@@ -8154,6 +8297,120 @@
8154
8297
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8155
8298
  </xsl:for-each>
8156
8299
  </xsl:copy>
8300
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
8301
+ <xsl:apply-templates mode="update_xml_step1"/>
8302
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
8303
+ <xsl:copy>
8304
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
8305
+ </xsl:copy>
8306
+ </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">
8307
+
8308
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
8309
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
8310
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8311
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8312
+ <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))"/>
8313
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
8314
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8315
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8316
+ <xsl:with-param name="text" select="$text_"/>
8317
+ </xsl:call-template></text></xsl:variable>
8318
+
8319
+ <xsl:variable name="parent" select="local-name(..)"/>
8320
+
8321
+ <xsl:variable name="text2">
8322
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
8323
+ <xsl:copy-of select="."/>
8324
+ </xsl:for-each></text>
8325
+ </xsl:variable>
8326
+
8327
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
8328
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
8329
+ <xsl:variable name="text3">
8330
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
8331
+ <xsl:choose>
8332
+ <xsl:when test="self::text()">
8333
+ <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))"/>
8334
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
8335
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8336
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8337
+ <xsl:with-param name="text" select="$text_units_"/>
8338
+ </xsl:call-template></text></xsl:variable>
8339
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
8340
+ </xsl:when>
8341
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8342
+ </xsl:choose>
8343
+ </xsl:for-each></text>
8344
+ </xsl:variable>
8345
+
8346
+ <xsl:choose>
8347
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
8348
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
8349
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
8350
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
8351
+ <xsl:choose>
8352
+ <xsl:when test="self::text()">
8353
+ <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))"/>
8354
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
8355
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8356
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8357
+ <xsl:with-param name="text" select="$text_dots_"/>
8358
+ </xsl:call-template></text></xsl:variable>
8359
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
8360
+ </xsl:when>
8361
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8362
+ </xsl:choose>
8363
+ </xsl:for-each>
8364
+ </xsl:when>
8365
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
8366
+ </xsl:choose>
8367
+
8368
+ </xsl:template><xsl:template name="replace_text_tags">
8369
+ <xsl:param name="tag_open"/>
8370
+ <xsl:param name="tag_close"/>
8371
+ <xsl:param name="text"/>
8372
+ <xsl:choose>
8373
+ <xsl:when test="contains($text, $tag_open)">
8374
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
8375
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
8376
+
8377
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
8378
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
8379
+ </xsl:element>
8380
+
8381
+ <xsl:call-template name="replace_text_tags">
8382
+ <xsl:with-param name="tag_open" select="$tag_open"/>
8383
+ <xsl:with-param name="tag_close" select="$tag_close"/>
8384
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
8385
+ </xsl:call-template>
8386
+ </xsl:when>
8387
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8388
+ </xsl:choose>
8389
+ </xsl:template><xsl:template name="printEdition">
8390
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
8391
+ <xsl:text> </xsl:text>
8392
+ <xsl:choose>
8393
+ <xsl:when test="$edition_i18n != ''">
8394
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
8395
+ <xsl:call-template name="capitalize">
8396
+ <xsl:with-param name="str" select="$edition_i18n"/>
8397
+ </xsl:call-template>
8398
+ </xsl:when>
8399
+ <xsl:otherwise>
8400
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
8401
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
8402
+ <xsl:call-template name="capitalize">
8403
+ <xsl:with-param name="str">
8404
+ <xsl:call-template name="getLocalizedString">
8405
+ <xsl:with-param name="key">edition</xsl:with-param>
8406
+ </xsl:call-template>
8407
+ </xsl:with-param>
8408
+ </xsl:call-template>
8409
+ <xsl:text> </xsl:text>
8410
+ <xsl:value-of select="$edition"/>
8411
+ </xsl:if>
8412
+ </xsl:otherwise>
8413
+ </xsl:choose>
8157
8414
  </xsl:template><xsl:template name="convertDate">
8158
8415
  <xsl:param name="date"/>
8159
8416
  <xsl:param name="format" select="'short'"/>