metanorma-bipm 2.0.8 → 2.1.2

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>
@@ -440,7 +440,7 @@
440
440
  </xsl:for-each>
441
441
  <xsl:for-each select="//*[contains(local-name(), '-standard')]">
442
442
  <fo:block break-after="page"/>
443
- <xsl:apply-templates select="./*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']"/>
443
+ <xsl:apply-templates select="./*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements' and local-name() != 'note' and local-name() != 'admonition']"/>
444
444
  </xsl:for-each>
445
445
  <xsl:for-each select="//*[contains(local-name(), '-standard')]">
446
446
  <fo:block break-after="page"/>
@@ -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>
@@ -676,6 +676,7 @@
676
676
 
677
677
  <xsl:template match="*[local-name()='p']" name="paragraph">
678
678
  <xsl:param name="inline" select="'false'"/>
679
+ <xsl:param name="split_keep-within-line"/>
679
680
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
680
681
  <xsl:variable name="element-name">
681
682
  <xsl:choose>
@@ -701,7 +702,9 @@
701
702
  <xsl:attribute name="widows">1</xsl:attribute>
702
703
  <xsl:attribute name="orphans">1</xsl:attribute>
703
704
  </xsl:if>
704
- <xsl:apply-templates/>
705
+ <xsl:apply-templates>
706
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
707
+ </xsl:apply-templates>
705
708
  </xsl:element>
706
709
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
707
710
  <fo:block margin-bottom="12pt">
@@ -794,24 +797,6 @@
794
797
  </xsl:template>
795
798
 
796
799
 
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
800
  <!-- for chemical expressions, when prefix superscripted -->
816
801
  <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
802
  <mathml:mspace height="1ex"/>
@@ -905,29 +890,6 @@
905
890
  </xsl:template>
906
891
 
907
892
 
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
893
  <!-- ================ -->
932
894
  <!-- JCGM specific templates -->
933
895
  <!-- ================ -->
@@ -1152,14 +1114,8 @@
1152
1114
  <xsl:param name="font-size" select="'65%'"/>
1153
1115
  <xsl:param name="baseline-shift" select="'30%'"/>
1154
1116
  <xsl:param name="curr_lang" select="'fr'"/>
1155
- <xsl:if test="normalize-space (.) != '1'">
1117
+ <xsl:if test="normalize-space (.) != '1'"> <!-- no need to show '1st edition' -->
1156
1118
  <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
1119
  <xsl:value-of select="."/>
1164
1120
  <fo:inline font-size="{$font-size}" baseline-shift="{$baseline-shift}">
1165
1121
  <xsl:if test="$curr_lang = 'en'">
@@ -1172,7 +1128,9 @@
1172
1128
  </xsl:call-template>
1173
1129
  </fo:inline>
1174
1130
  <xsl:text> </xsl:text>
1175
- <xsl:value-of select="java:toLowerCase(java:java.lang.String.new($title-edition))"/>
1131
+ <xsl:call-template name="getLocalizedString">
1132
+ <xsl:with-param name="key">edition</xsl:with-param>
1133
+ </xsl:call-template>
1176
1134
  <xsl:text/>
1177
1135
  </fo:inline>
1178
1136
  </xsl:if>
@@ -1766,12 +1724,41 @@
1766
1724
  </fo:block-container>
1767
1725
  </xsl:template>
1768
1726
 
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">
1727
+ <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:param name="table_if">false</xsl:param><xsl:param name="table_widths"/><xsl:variable name="table_widths_from_if" select="xalan:nodeset($table_widths)"/><xsl:variable name="table_widths_from_if_calculated_">
1728
+ <xsl:for-each select="$table_widths_from_if//table">
1729
+ <xsl:copy>
1730
+ <xsl:copy-of select="@*"/>
1731
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
1732
+ </xsl:copy>
1733
+ </xsl:for-each>
1734
+ </xsl:variable><xsl:variable name="table_widths_from_if_calculated" select="xalan:nodeset($table_widths_from_if_calculated_)"/><xsl:param name="table_if_debug">false</xsl:param><xsl:variable name="isGenerateTableIF_">
1735
+ false
1736
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
1770
1737
  <xsl:call-template name="getLang"/>
1771
- </xsl:variable><xsl:variable name="pageWidth_">
1772
- 210
1738
+ </xsl:variable><xsl:variable name="papersize" select="java:toLowerCase(java:java.lang.String.new(normalize-space(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata']/*[local-name() = 'papersize'])))"/><xsl:variable name="papersize_width_">
1739
+ <xsl:choose>
1740
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
1741
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
1742
+ </xsl:choose>
1743
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
1744
+ <xsl:choose>
1745
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
1746
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
1747
+ </xsl:choose>
1748
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
1749
+ <xsl:choose>
1750
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
1751
+ <xsl:otherwise>
1752
+ 210
1753
+ </xsl:otherwise>
1754
+ </xsl:choose>
1773
1755
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
1774
- 297
1756
+ <xsl:choose>
1757
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
1758
+ <xsl:otherwise>
1759
+ 297
1760
+ </xsl:otherwise>
1761
+ </xsl:choose>
1775
1762
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
1776
1763
  25
1777
1764
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -1781,20 +1768,7 @@
1781
1768
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1782
1769
  23.5
1783
1770
  </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
1771
 
1791
- <title-edition lang="fr">
1792
- <xsl:text>Édition </xsl:text>
1793
- </title-edition>
1794
-
1795
- <title-edition lang="ru">
1796
- <xsl:text>Издание </xsl:text>
1797
- </title-edition>
1798
1772
 
1799
1773
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1800
1774
  <title-toc lang="en">
@@ -1873,7 +1847,7 @@
1873
1847
  </xsl:variable><xsl:variable name="bibdata">
1874
1848
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1875
1849
  <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">
1850
+ </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
1851
  <xsl:param name="name"/>
1878
1852
  <xsl:param name="lang"/>
1879
1853
  <xsl:variable name="lang_">
@@ -1921,7 +1895,7 @@
1921
1895
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1922
1896
 
1923
1897
  <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']">
1898
+ <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
1899
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1926
1900
  </xsl:for-each>
1927
1901
  </xsl:variable>
@@ -1996,7 +1970,6 @@
1996
1970
 
1997
1971
 
1998
1972
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1999
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2000
1973
 
2001
1974
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
2002
1975
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -2084,6 +2057,7 @@
2084
2057
 
2085
2058
 
2086
2059
 
2060
+
2087
2061
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2088
2062
 
2089
2063
 
@@ -2245,6 +2219,7 @@
2245
2219
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2246
2220
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2247
2221
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2222
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2248
2223
  <xsl:attribute name="display-align">center</xsl:attribute>
2249
2224
 
2250
2225
 
@@ -2265,6 +2240,7 @@
2265
2240
  <xsl:attribute name="display-align">center</xsl:attribute>
2266
2241
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2267
2242
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2243
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2268
2244
 
2269
2245
 
2270
2246
 
@@ -2359,7 +2335,8 @@
2359
2335
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
2360
2336
 
2361
2337
 
2362
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2338
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2339
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2363
2340
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2364
2341
 
2365
2342
 
@@ -2373,6 +2350,27 @@
2373
2350
 
2374
2351
 
2375
2352
 
2353
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
2354
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2355
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2356
+
2357
+
2358
+
2359
+
2360
+
2361
+
2362
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2363
+
2364
+
2365
+
2366
+
2367
+
2368
+
2369
+
2370
+
2371
+
2372
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2373
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2376
2374
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2377
2375
 
2378
2376
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -2678,6 +2676,8 @@
2678
2676
  </xsl:attribute-set><xsl:attribute-set name="mathml-style">
2679
2677
  <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
2680
2678
 
2679
+ <xsl:attribute name="font-family">Cambria Math</xsl:attribute>
2680
+
2681
2681
 
2682
2682
  </xsl:attribute-set><xsl:attribute-set name="list-style">
2683
2683
 
@@ -2700,6 +2700,25 @@
2700
2700
 
2701
2701
 
2702
2702
 
2703
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
2704
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2705
+
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+ <xsl:attribute name="margin-top">8pt</xsl:attribute>
2712
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2703
2722
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
2704
2723
 
2705
2724
 
@@ -3096,13 +3115,13 @@
3096
3115
 
3097
3116
  </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
3098
3117
  <xsl:variable name="nodes_preface_">
3099
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3118
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3100
3119
  <node id="{@id}"/>
3101
3120
  </xsl:for-each>
3102
3121
  </xsl:variable>
3103
3122
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
3104
3123
 
3105
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3124
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3106
3125
  <xsl:sort select="@displayorder" data-type="number"/>
3107
3126
 
3108
3127
  <!-- process Section's title -->
@@ -3168,7 +3187,7 @@
3168
3187
  </xsl:for-each>
3169
3188
  </figures>
3170
3189
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3171
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3190
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3172
3191
  <xsl:sort select="@displayorder" data-type="number"/>
3173
3192
  <xsl:apply-templates select="."/>
3174
3193
  </xsl:for-each>
@@ -3188,22 +3207,32 @@
3188
3207
  <xsl:sort select="@displayorder" data-type="number"/>
3189
3208
  <xsl:apply-templates select="."/>
3190
3209
  </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">
3210
+ </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">
3211
+
3212
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3213
+ <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))"/>
3214
+ <xsl:call-template name="replace_fo_inline_tags">
3215
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3216
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3217
+ <xsl:with-param name="text" select="$text"/>
3218
+ </xsl:call-template>
3219
+
3220
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3221
+ <xsl:param name="tag_open"/>
3222
+ <xsl:param name="tag_close"/>
3198
3223
  <xsl:param name="text"/>
3199
3224
  <xsl:choose>
3200
3225
  <xsl:when test="contains($text, $tag_open)">
3201
3226
  <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>
3227
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3203
3228
  <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">
3229
+ <fo:inline keep-together.within-line="always">
3230
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3231
+ </fo:inline>
3232
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3233
+ <xsl:call-template name="replace_fo_inline_tags">
3234
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3235
+ <xsl:with-param name="tag_close" select="$tag_close"/>
3207
3236
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3208
3237
  </xsl:call-template>
3209
3238
  </xsl:when>
@@ -3211,6 +3240,39 @@
3211
3240
  </xsl:choose>
3212
3241
  </xsl:template><xsl:template match="*[local-name()='br']">
3213
3242
  <xsl:value-of select="$linebreak"/>
3243
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3244
+ <xsl:param name="split_keep-within-line"/>
3245
+
3246
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3247
+ <xsl:choose>
3248
+
3249
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3250
+ <xsl:variable name="sep">_</xsl:variable>
3251
+ <xsl:variable name="items">
3252
+ <xsl:call-template name="split">
3253
+ <xsl:with-param name="pText" select="."/>
3254
+ <xsl:with-param name="sep" select="$sep"/>
3255
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3256
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3257
+ </xsl:call-template>
3258
+ </xsl:variable>
3259
+ <xsl:for-each select="xalan:nodeset($items)/item">
3260
+ <xsl:choose>
3261
+ <xsl:when test=". = $sep">
3262
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3263
+ </xsl:when>
3264
+ <xsl:otherwise>
3265
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3266
+ </xsl:otherwise>
3267
+ </xsl:choose>
3268
+ </xsl:for-each>
3269
+ </xsl:when>
3270
+
3271
+ <xsl:otherwise>
3272
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3273
+ </xsl:otherwise>
3274
+
3275
+ </xsl:choose>
3214
3276
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3215
3277
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3216
3278
  <xsl:apply-templates/>
@@ -3276,8 +3338,23 @@
3276
3338
  </xsl:call-template>
3277
3339
 
3278
3340
  </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"/>
3341
+ <xsl:choose>
3342
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3343
+ <xsl:value-of select="."/>
3344
+ </xsl:when>
3345
+ <xsl:otherwise>
3346
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3347
+ </xsl:otherwise>
3348
+ </xsl:choose>
3349
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3350
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3351
+ <!-- <xsl:copy-of select="$text"/> -->
3352
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3353
+ <xsl:choose>
3354
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3355
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3356
+ </xsl:choose>
3357
+ </xsl:for-each>
3281
3358
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3282
3359
 
3283
3360
  <xsl:variable name="table-preamble">
@@ -3287,9 +3364,14 @@
3287
3364
 
3288
3365
  <xsl:variable name="table">
3289
3366
 
3290
- <xsl:variable name="simple-table">
3291
- <xsl:call-template name="getSimpleTable"/>
3367
+ <xsl:variable name="simple-table">
3368
+ <xsl:call-template name="getSimpleTable">
3369
+ <xsl:with-param name="id" select="@id"/>
3370
+ </xsl:call-template>
3292
3371
  </xsl:variable>
3372
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3373
+
3374
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3293
3375
 
3294
3376
 
3295
3377
  <!-- Display table's name before table as standalone block -->
@@ -3308,7 +3390,23 @@
3308
3390
  </xsl:call-template>
3309
3391
  </xsl:if>
3310
3392
  </xsl:variable>
3311
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3393
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3394
+
3395
+ <!-- DEBUG -->
3396
+ <xsl:if test="$table_if_debug = 'true'">
3397
+ <fo:block font-size="60%">
3398
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3399
+ </fo:block>
3400
+ </xsl:if>
3401
+
3402
+
3403
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3404
+
3405
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3406
+ DEBUG
3407
+ colwidths=<xsl:copy-of select="$colwidths"/>
3408
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3409
+
3312
3410
 
3313
3411
 
3314
3412
  <xsl:variable name="margin-side">
@@ -3373,9 +3471,17 @@
3373
3471
  </xsl:element>
3374
3472
  </xsl:variable>
3375
3473
 
3474
+ <xsl:if test="$isGenerateTableIF = 'true'">
3475
+ <!-- to determine start of table -->
3476
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3477
+ </xsl:if>
3376
3478
 
3377
3479
  <fo:table id="{@id}">
3378
3480
 
3481
+ <xsl:if test="$isGenerateTableIF = 'true'">
3482
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3483
+ </xsl:if>
3484
+
3379
3485
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3380
3486
  <xsl:attribute name="{local-name()}">
3381
3487
  <xsl:value-of select="."/>
@@ -3389,31 +3495,47 @@
3389
3495
 
3390
3496
 
3391
3497
  <xsl:choose>
3392
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3393
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3394
- <fo:table-column column-width="{@width}"/>
3395
- </xsl:for-each>
3498
+ <xsl:when test="$isGenerateTableIF = 'true'">
3499
+ <!-- generate IF for table widths -->
3500
+ <!-- example:
3501
+ <tr>
3502
+ <td valign="top" align="left" id="tab-symdu_1_1">
3503
+ <p>Symbol</p>
3504
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3505
+ </td>
3506
+ <td valign="top" align="left" id="tab-symdu_1_2">
3507
+ <p>Description</p>
3508
+ <word id="tab-symdu_1_2_word_1">Description</word>
3509
+ </td>
3510
+ </tr>
3511
+ -->
3512
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3513
+
3396
3514
  </xsl:when>
3397
3515
  <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>
3408
- </xsl:otherwise>
3409
- </xsl:choose>
3410
3516
 
3411
- <xsl:choose>
3412
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3413
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3414
- </xsl:when>
3415
- <xsl:otherwise>
3416
- <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
3517
+ <xsl:choose>
3518
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3519
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3520
+ <fo:table-column column-width="{@width}"/>
3521
+ </xsl:for-each>
3522
+ </xsl:when>
3523
+ <xsl:otherwise>
3524
+ <xsl:call-template name="insertTableColumnWidth">
3525
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3526
+ </xsl:call-template>
3527
+ </xsl:otherwise>
3528
+ </xsl:choose>
3529
+
3530
+ <xsl:choose>
3531
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3532
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3533
+ </xsl:when>
3534
+ <xsl:otherwise>
3535
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
3536
+ </xsl:otherwise>
3537
+ </xsl:choose>
3538
+
3417
3539
  </xsl:otherwise>
3418
3540
  </xsl:choose>
3419
3541
 
@@ -3518,11 +3640,22 @@
3518
3640
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3519
3641
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3520
3642
  </xsl:template><xsl:template name="calculate-column-widths">
3643
+ <xsl:param name="table"/>
3644
+ <xsl:param name="cols-count"/>
3645
+
3646
+ <xsl:call-template name="calculate-column-widths-proportional">
3647
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3648
+ <xsl:with-param name="table" select="$table"/>
3649
+ </xsl:call-template>
3650
+
3651
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3521
3652
  <xsl:param name="table"/>
3522
3653
  <xsl:param name="cols-count"/>
3523
3654
  <xsl:param name="curr-col" select="1"/>
3524
3655
  <xsl:param name="width" select="0"/>
3525
3656
 
3657
+ <!-- table=<xsl:copy-of select="$table"/> -->
3658
+
3526
3659
  <xsl:if test="$curr-col &lt;= $cols-count">
3527
3660
  <xsl:variable name="widths">
3528
3661
  <xsl:choose>
@@ -3560,16 +3693,22 @@
3560
3693
  </xsl:for-each>
3561
3694
  </xsl:when>
3562
3695
  <xsl:otherwise>
3563
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3696
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3697
+
3698
+ <!-- <table><xsl:copy-of select="$table"/></table>
3699
+ -->
3700
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3564
3701
  <xsl:variable name="td_text">
3565
3702
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3566
3703
  </xsl:variable>
3704
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3567
3705
  <xsl:variable name="words">
3568
3706
  <xsl:variable name="string_with_added_zerospaces">
3569
3707
  <xsl:call-template name="add-zero-spaces-java">
3570
3708
  <xsl:with-param name="text" select="$td_text"/>
3571
3709
  </xsl:call-template>
3572
3710
  </xsl:variable>
3711
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3573
3712
  <xsl:call-template name="tokenize">
3574
3713
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3575
3714
  <!-- 2009 thinspace -->
@@ -3577,11 +3716,13 @@
3577
3716
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3578
3717
  </xsl:call-template>
3579
3718
  </xsl:variable>
3719
+ <!-- words=<xsl:copy-of select="$words"/> -->
3580
3720
  <xsl:variable name="max_length">
3581
3721
  <xsl:call-template name="max_length">
3582
3722
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3583
3723
  </xsl:call-template>
3584
3724
  </xsl:variable>
3725
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3585
3726
  <width>
3586
3727
  <xsl:variable name="divider">
3587
3728
  <xsl:choose>
@@ -3600,6 +3741,8 @@
3600
3741
  </xsl:choose>
3601
3742
  </xsl:variable>
3602
3743
 
3744
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3745
+
3603
3746
  <column>
3604
3747
  <xsl:for-each select="xalan:nodeset($widths)//width">
3605
3748
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3608,93 +3751,335 @@
3608
3751
  </xsl:if>
3609
3752
  </xsl:for-each>
3610
3753
  </column>
3611
- <xsl:call-template name="calculate-column-widths">
3754
+ <xsl:call-template name="calculate-column-widths-proportional">
3612
3755
  <xsl:with-param name="cols-count" select="$cols-count"/>
3613
3756
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3614
3757
  <xsl:with-param name="table" select="$table"/>
3615
3758
  </xsl:call-template>
3616
3759
  </xsl:if>
3760
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
3761
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3762
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3763
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3764
+
3765
+ <!-- if all capitals english letters or digits -->
3766
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
3767
+ <xsl:call-template name="repeat">
3768
+ <xsl:with-param name="char" select="'X'"/>
3769
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
3770
+ </xsl:call-template>
3771
+ </xsl:if>
3617
3772
  </xsl:template><xsl:template match="text()" mode="td_text">
3618
3773
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3619
3774
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3620
3775
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3621
3776
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3622
3777
  <xsl:value-of select="@target"/>
3623
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3624
- <xsl:variable name="mathml">
3625
- <xsl:for-each select="*">
3626
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3627
- <xsl:copy-of select="."/>
3628
- </xsl:if>
3629
- </xsl:for-each>
3630
- </xsl:variable>
3631
-
3632
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3633
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3634
- </xsl:template><xsl:template match="*[local-name()='thead']">
3635
- <xsl:param name="cols-count"/>
3636
- <fo:table-header>
3637
-
3638
- <xsl:call-template name="table-header-title">
3639
- <xsl:with-param name="cols-count" select="$cols-count"/>
3640
- </xsl:call-template>
3641
-
3642
-
3643
- <xsl:apply-templates/>
3644
- </fo:table-header>
3645
- </xsl:template><xsl:template name="table-header-title">
3646
- <xsl:param name="cols-count"/>
3647
- <!-- row for title -->
3648
- <fo:table-row>
3649
- <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
3650
-
3651
- <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
3652
- <xsl:with-param name="continued">true</xsl:with-param>
3653
- </xsl:apply-templates>
3654
-
3655
-
3656
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
3657
- <xsl:call-template name="table_name_fn_display"/>
3658
- </xsl:for-each>
3778
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
3779
+ <xsl:if test="$isGenerateTableIF = 'false'">
3780
+ <xsl:variable name="mathml_">
3781
+ <xsl:for-each select="*">
3782
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3783
+ <xsl:copy-of select="."/>
3784
+ </xsl:if>
3785
+ </xsl:for-each>
3786
+ </xsl:variable>
3787
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
3659
3788
 
3660
- <fo:block text-align="right" font-style="italic">
3661
- <xsl:text> </xsl:text>
3662
- <fo:retrieve-table-marker retrieve-class-name="table_continued"/>
3663
- </fo:block>
3664
-
3665
-
3666
- </fo:table-cell>
3667
- </fo:table-row>
3668
- </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
3669
- <fo:table-body>
3670
- <xsl:apply-templates/>
3671
- </fo:table-body>
3672
- </xsl:template><xsl:template match="*[local-name()='tfoot']">
3673
- <xsl:apply-templates/>
3674
- </xsl:template><xsl:template name="insertTableFooter">
3675
- <xsl:param name="cols-count"/>
3676
- <xsl:if test="../*[local-name()='tfoot']">
3677
- <fo:table-footer>
3678
- <xsl:apply-templates select="../*[local-name()='tfoot']"/>
3679
- </fo:table-footer>
3789
+ <xsl:variable name="math_text">
3790
+ <xsl:value-of select="normalize-space($mathml)"/>
3791
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
3792
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
3793
+ </xsl:variable>
3794
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3680
3795
  </xsl:if>
3681
- </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
3682
- <xsl:param name="table_attributes"/>
3683
- <xsl:param name="colwidths"/>
3684
- <xsl:param name="colgroup"/>
3796
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
3797
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
3685
3798
 
3686
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3799
+ <!-- via intermediate format -->
3800
+
3801
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
3802
+
3803
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
3804
+
3805
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
3806
+
3807
+ <!-- get current table id -->
3808
+ <xsl:variable name="table_id" select="@id"/>
3809
+ <!-- find table by id in the file 'table_widths' -->
3810
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
3811
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
3812
+
3813
+ <!-- table='<xsl:copy-of select="$table"/>' -->
3814
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
3815
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
3816
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
3817
+
3818
+ <xsl:variable name="table_with_cell_widths_">
3819
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
3820
+ </xsl:variable>
3821
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
3687
3822
 
3688
- <xsl:variable name="isNoteOrFnExistShowAfterTable">
3689
-
3823
+ <!-- <xsl:if test="$table_if_debug = 'true'">
3824
+ <xsl:copy-of select="$table_with_cell_widths"/>
3825
+ </xsl:if> -->
3826
+
3827
+
3828
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
3829
+
3830
+ <xsl:variable name="column_widths_">
3831
+ <!-- iteration of columns -->
3832
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
3833
+ <xsl:variable name="pos" select="position()"/>
3834
+ <column>
3835
+ <xsl:attribute name="width_max">
3836
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
3837
+ <xsl:sort select="." data-type="number" order="descending"/>
3838
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3839
+ </xsl:for-each>
3840
+ </xsl:attribute>
3841
+ <xsl:attribute name="width_min">
3842
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
3843
+ <xsl:sort select="." data-type="number" order="descending"/>
3844
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3845
+ </xsl:for-each>
3846
+ </xsl:attribute>
3847
+ </column>
3848
+ </xsl:for-each>
3690
3849
  </xsl:variable>
3850
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
3691
3851
 
3692
- <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
3852
+ <!-- <column_widths>
3853
+ <xsl:copy-of select="$column_widths"/>
3854
+ </column_widths> -->
3693
3855
 
3694
- <xsl:variable name="cols-count">
3695
- <xsl:choose>
3696
- <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
3697
- <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
3856
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
3857
+ <xsl:variable name="table_widths_">
3858
+ <table>
3859
+ <xsl:attribute name="width_max">
3860
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
3861
+ </xsl:attribute>
3862
+ <xsl:attribute name="width_min">
3863
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
3864
+ </xsl:attribute>
3865
+ </table>
3866
+ </xsl:variable>
3867
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
3868
+
3869
+ <xsl:variable name="page_width">
3870
+ <xsl:choose>
3871
+ <xsl:when test="$parent_table_page-width != ''">
3872
+ <xsl:value-of select="$parent_table_page-width"/>
3873
+ </xsl:when>
3874
+ <xsl:otherwise>
3875
+ <xsl:value-of select="@page-width"/>
3876
+ </xsl:otherwise>
3877
+ </xsl:choose>
3878
+ </xsl:variable>
3879
+
3880
+ <xsl:if test="$table_if_debug = 'true'">
3881
+ <table_width>
3882
+ <xsl:copy-of select="$table_widths"/>
3883
+ </table_width>
3884
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
3885
+ </xsl:if>
3886
+
3887
+
3888
+ <!-- There are three cases: -->
3889
+ <xsl:choose>
3890
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
3891
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
3892
+ <!-- call old algorithm -->
3893
+ <case1/>
3894
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
3895
+ <xsl:call-template name="calculate-column-widths-proportional">
3896
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3897
+ <xsl:with-param name="table" select="$table"/>
3898
+ </xsl:call-template> -->
3899
+ </xsl:when>
3900
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
3901
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
3902
+ <case2/>
3903
+ <autolayout/>
3904
+ <xsl:for-each select="$column_widths/column/@width_max">
3905
+ <column divider="100"><xsl:value-of select="."/></column>
3906
+ </xsl:for-each>
3907
+ </xsl:when>
3908
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
3909
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
3910
+ Lets also call D the difference between maximum and minimum width of the table.
3911
+ For each column, let d be the difference between maximum and minimum width of that column.
3912
+ Now set the column's width to the minimum width plus d times W over D.
3913
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
3914
+ <xsl:when test="($table_widths/table/@width_max &gt; $page_width and $table_widths/table/@width_min &lt; $page_width) or ($table_widths/table/@width_min &gt;= $page_width)">
3915
+ <!-- difference between the available space and the minimum table width -->
3916
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
3917
+ <W><xsl:value-of select="$W"/></W>
3918
+ <!-- difference between maximum and minimum width of the table -->
3919
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
3920
+ <D><xsl:value-of select="$D"/></D>
3921
+ <case3/>
3922
+ <autolayout/>
3923
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
3924
+ <split_keep-within-line>true</split_keep-within-line>
3925
+ </xsl:if>
3926
+ <xsl:for-each select="$column_widths/column">
3927
+ <!-- difference between maximum and minimum width of that column. -->
3928
+ <xsl:variable name="d" select="@width_max - @width_min"/>
3929
+ <d><xsl:value-of select="$d"/></d>
3930
+ <width_min><xsl:value-of select="@width_min"/></width_min>
3931
+ <e><xsl:value-of select="$d * $W div $D"/></e>
3932
+ <!-- set the column's width to the minimum width plus d times W over D. -->
3933
+ <column divider="100">
3934
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3935
+ </column>
3936
+ </xsl:for-each>
3937
+
3938
+ </xsl:when>
3939
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
3940
+ </xsl:choose>
3941
+
3942
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
3943
+
3944
+ <!-- if nested 'dl' or 'table' -->
3945
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
3946
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
3947
+
3948
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
3949
+
3950
+ <xsl:variable name="parent_table_page-width_">
3951
+ <xsl:if test="$parent_table_id != ''">
3952
+ <!-- determine column number in the parent table -->
3953
+ <xsl:variable name="parent_table_column_number">
3954
+ <xsl:choose>
3955
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
3956
+ <xsl:otherwise> <!-- parent is table -->
3957
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
3958
+ </xsl:otherwise>
3959
+ </xsl:choose>
3960
+ </xsl:variable>
3961
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
3962
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
3963
+ </xsl:if>
3964
+ </xsl:variable>
3965
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
3966
+
3967
+ <!-- get current table id -->
3968
+ <xsl:variable name="table_id" select="@id"/>
3969
+
3970
+ <xsl:choose>
3971
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
3972
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
3973
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
3974
+ </xsl:when>
3975
+ <xsl:otherwise>
3976
+ <!-- recalculate columns width based on parent table width -->
3977
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
3978
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
3979
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
3980
+ </xsl:call-template>
3981
+ </xsl:for-each>
3982
+ </xsl:otherwise>
3983
+ </xsl:choose>
3984
+
3985
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
3986
+ <xsl:copy>
3987
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
3988
+ </xsl:copy>
3989
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
3990
+ <xsl:copy>
3991
+ <xsl:copy-of select="@*"/>
3992
+
3993
+ <!-- The maximum width is given by the widest line. -->
3994
+ <xsl:attribute name="width_max">
3995
+ <xsl:for-each select="p_len">
3996
+ <xsl:sort select="." data-type="number" order="descending"/>
3997
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3998
+ </xsl:for-each>
3999
+ </xsl:attribute>
4000
+
4001
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4002
+ <xsl:variable name="width_min">
4003
+ <xsl:for-each select="word_len">
4004
+ <xsl:sort select="." data-type="number" order="descending"/>
4005
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4006
+ </xsl:for-each>
4007
+ </xsl:variable>
4008
+ <xsl:attribute name="width_min">
4009
+ <xsl:value-of select="$width_min"/>
4010
+ </xsl:attribute>
4011
+
4012
+ <xsl:if test="$width_min = 0">
4013
+ <xsl:attribute name="width_min">1</xsl:attribute>
4014
+ </xsl:if>
4015
+
4016
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
4017
+
4018
+ </xsl:copy>
4019
+ </xsl:template><xsl:template match="*[local-name()='thead']">
4020
+ <xsl:param name="cols-count"/>
4021
+ <fo:table-header>
4022
+
4023
+ <xsl:call-template name="table-header-title">
4024
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4025
+ </xsl:call-template>
4026
+
4027
+
4028
+ <xsl:apply-templates/>
4029
+ </fo:table-header>
4030
+ </xsl:template><xsl:template name="table-header-title">
4031
+ <xsl:param name="cols-count"/>
4032
+ <!-- row for title -->
4033
+ <fo:table-row>
4034
+ <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
4035
+
4036
+ <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
4037
+ <xsl:with-param name="continued">true</xsl:with-param>
4038
+ </xsl:apply-templates>
4039
+
4040
+
4041
+ <xsl:for-each select="ancestor::*[local-name()='table'][1]">
4042
+ <xsl:call-template name="table_name_fn_display"/>
4043
+ </xsl:for-each>
4044
+
4045
+ <fo:block text-align="right" font-style="italic">
4046
+ <xsl:text> </xsl:text>
4047
+ <fo:retrieve-table-marker retrieve-class-name="table_continued"/>
4048
+ </fo:block>
4049
+
4050
+
4051
+ </fo:table-cell>
4052
+ </fo:table-row>
4053
+ </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
4054
+ <fo:table-body>
4055
+ <xsl:apply-templates/>
4056
+ </fo:table-body>
4057
+ </xsl:template><xsl:template match="*[local-name()='tfoot']">
4058
+ <xsl:apply-templates/>
4059
+ </xsl:template><xsl:template name="insertTableFooter">
4060
+ <xsl:param name="cols-count"/>
4061
+ <xsl:if test="../*[local-name()='tfoot']">
4062
+ <fo:table-footer>
4063
+ <xsl:apply-templates select="../*[local-name()='tfoot']"/>
4064
+ </fo:table-footer>
4065
+ </xsl:if>
4066
+ </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
4067
+ <xsl:param name="table_attributes"/>
4068
+ <xsl:param name="colwidths"/>
4069
+ <xsl:param name="colgroup"/>
4070
+
4071
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4072
+
4073
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
4074
+
4075
+ </xsl:variable>
4076
+
4077
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
4078
+
4079
+ <xsl:variable name="cols-count">
4080
+ <xsl:choose>
4081
+ <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
4082
+ <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
3698
4083
  </xsl:when>
3699
4084
  <xsl:otherwise>
3700
4085
  <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/>
@@ -3728,16 +4113,10 @@
3728
4113
  </xsl:for-each>
3729
4114
  </xsl:when>
3730
4115
  <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>
4116
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
4117
+ <xsl:call-template name="insertTableColumnWidth">
4118
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4119
+ </xsl:call-template>
3741
4120
  </xsl:otherwise>
3742
4121
  </xsl:choose>
3743
4122
 
@@ -3859,6 +4238,52 @@
3859
4238
 
3860
4239
  </fo:table-body>
3861
4240
 
4241
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4242
+ <xsl:param name="table_or_dl">table</xsl:param>
4243
+ <xsl:apply-templates mode="process_table-if">
4244
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4245
+ </xsl:apply-templates>
4246
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4247
+ <xsl:param name="table_or_dl">table</xsl:param>
4248
+
4249
+ <fo:table-body>
4250
+ <xsl:for-each select="*[local-name() = 'tr']">
4251
+ <xsl:variable name="col_count" select="count(*)"/>
4252
+
4253
+ <!-- iteration for each tr/td -->
4254
+
4255
+ <xsl:choose>
4256
+ <xsl:when test="$table_or_dl = 'table'">
4257
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4258
+ <fo:table-row number-columns-spanned="{$col_count}">
4259
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4260
+ <xsl:call-template name="td"/>
4261
+ </fo:table-row>
4262
+ </xsl:for-each>
4263
+ </xsl:when>
4264
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4265
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4266
+ <xsl:variable name="is_dt" select="position() = 1"/>
4267
+
4268
+ <xsl:for-each select="*">
4269
+ <!-- <test><xsl:copy-of select="."/></test> -->
4270
+ <fo:table-row number-columns-spanned="{$col_count}">
4271
+ <xsl:choose>
4272
+ <xsl:when test="$is_dt">
4273
+ <xsl:call-template name="insert_dt_cell"/>
4274
+ </xsl:when>
4275
+ <xsl:otherwise>
4276
+ <xsl:call-template name="insert_dd_cell"/>
4277
+ </xsl:otherwise>
4278
+ </xsl:choose>
4279
+ </fo:table-row>
4280
+ </xsl:for-each>
4281
+ </xsl:for-each>
4282
+ </xsl:otherwise>
4283
+ </xsl:choose>
4284
+
4285
+ </xsl:for-each>
4286
+ </fo:table-body>
3862
4287
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3863
4288
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3864
4289
 
@@ -3956,7 +4381,7 @@
3956
4381
  </xsl:choose>
3957
4382
  </xsl:attribute>
3958
4383
  </xsl:if>
3959
- </xsl:template><xsl:template match="*[local-name()='td']">
4384
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
3960
4385
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
3961
4386
  <xsl:call-template name="setTextAlignment">
3962
4387
  <xsl:with-param name="default">left</xsl:with-param>
@@ -3997,11 +4422,24 @@
3997
4422
 
3998
4423
  <xsl:call-template name="setTableCellAttributes"/>
3999
4424
 
4425
+ <xsl:if test="$isGenerateTableIF = 'true'">
4426
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4427
+ <xsl:attribute name="text-align">left</xsl:attribute>
4428
+ </xsl:if>
4429
+
4000
4430
  <fo:block>
4001
4431
 
4432
+ <xsl:if test="$isGenerateTableIF = 'true'">
4433
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4434
+ </xsl:if>
4435
+
4436
+
4002
4437
 
4003
4438
 
4004
4439
  <xsl:apply-templates/>
4440
+
4441
+ <xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
4442
+
4005
4443
  </fo:block>
4006
4444
  </fo:table-cell>
4007
4445
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -4198,9 +4636,9 @@
4198
4636
  <!-- current hierarchy is 'figure' element -->
4199
4637
  <xsl:variable name="following_dl_colwidths">
4200
4638
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4201
- <xsl:variable name="html-table">
4202
- <xsl:variable name="doc_ns">
4203
-
4639
+ <xsl:variable name="simple-table">
4640
+ <!-- <xsl:variable name="doc_ns">
4641
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4204
4642
  </xsl:variable>
4205
4643
  <xsl:variable name="ns">
4206
4644
  <xsl:choose>
@@ -4211,7 +4649,7 @@
4211
4649
  <xsl:value-of select="substring-before(name(/*), '-')"/>
4212
4650
  </xsl:otherwise>
4213
4651
  </xsl:choose>
4214
- </xsl:variable>
4652
+ </xsl:variable> -->
4215
4653
 
4216
4654
  <xsl:for-each select="*[local-name() = 'dl'][1]">
4217
4655
  <tbody>
@@ -4222,7 +4660,7 @@
4222
4660
 
4223
4661
  <xsl:call-template name="calculate-column-widths">
4224
4662
  <xsl:with-param name="cols-count" select="2"/>
4225
- <xsl:with-param name="table" select="$html-table"/>
4663
+ <xsl:with-param name="table" select="$simple-table"/>
4226
4664
  </xsl:call-template>
4227
4665
 
4228
4666
  </xsl:if>
@@ -4348,8 +4786,10 @@
4348
4786
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4349
4787
  </xsl:variable>
4350
4788
 
4789
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
4790
+
4351
4791
  <xsl:choose>
4352
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
4792
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4353
4793
 
4354
4794
  <fo:block margin-bottom="12pt" text-align="left">
4355
4795
 
@@ -4366,7 +4806,7 @@
4366
4806
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4367
4807
  </fo:block>
4368
4808
 
4369
- </xsl:when>
4809
+ </xsl:when> <!-- END: only one component -->
4370
4810
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4371
4811
  <fo:block margin-bottom="12pt" text-align="left">
4372
4812
 
@@ -4382,8 +4822,8 @@
4382
4822
  </xsl:variable>
4383
4823
  <xsl:value-of select="$title-where"/>
4384
4824
  </fo:block>
4385
- </xsl:when>
4386
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
4825
+ </xsl:when> <!-- END: a few components -->
4826
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4387
4827
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4388
4828
 
4389
4829
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -4399,11 +4839,11 @@
4399
4839
  </xsl:variable>
4400
4840
  <xsl:value-of select="$title-key"/>
4401
4841
  </fo:block>
4402
- </xsl:when>
4842
+ </xsl:when> <!-- END: definition list in a figure -->
4403
4843
  </xsl:choose>
4404
4844
 
4405
4845
  <!-- a few components -->
4406
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
4846
+ <xsl:if test="$onlyOneComponent = 'false'">
4407
4847
  <fo:block>
4408
4848
 
4409
4849
  <xsl:if test="$parent = 'formula'">
@@ -4414,12 +4854,31 @@
4414
4854
 
4415
4855
 
4416
4856
 
4857
+
4858
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
4859
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4860
+ </xsl:if>
4861
+
4417
4862
  <fo:block>
4418
4863
 
4419
4864
 
4420
4865
 
4421
4866
 
4867
+ <xsl:apply-templates select="*[local-name() = 'name']">
4868
+ <xsl:with-param name="process">true</xsl:with-param>
4869
+ </xsl:apply-templates>
4870
+
4871
+ <xsl:if test="$isGenerateTableIF = 'true'">
4872
+ <!-- to determine start of table -->
4873
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
4874
+ </xsl:if>
4875
+
4422
4876
  <fo:table width="95%" table-layout="fixed">
4877
+
4878
+ <xsl:if test="$isGenerateTableIF = 'true'">
4879
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
4880
+ </xsl:if>
4881
+
4423
4882
 
4424
4883
  <xsl:choose>
4425
4884
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4428,61 +4887,178 @@
4428
4887
 
4429
4888
  </xsl:when>
4430
4889
  </xsl:choose>
4431
- <!-- create virtual html table for dl/[dt and dd] -->
4432
- <xsl:variable name="html-table">
4433
- <xsl:variable name="doc_ns">
4890
+
4891
+
4892
+
4893
+ <xsl:choose>
4894
+ <xsl:when test="$isGenerateTableIF = 'true'">
4895
+ <!-- generate IF for table widths -->
4896
+ <!-- example:
4897
+ <tr>
4898
+ <td valign="top" align="left" id="tab-symdu_1_1">
4899
+ <p>Symbol</p>
4900
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
4901
+ </td>
4902
+ <td valign="top" align="left" id="tab-symdu_1_2">
4903
+ <p>Description</p>
4904
+ <word id="tab-symdu_1_2_word_1">Description</word>
4905
+ </td>
4906
+ </tr>
4907
+ -->
4434
4908
 
4435
- </xsl:variable>
4436
- <xsl:variable name="ns">
4437
- <xsl:choose>
4438
- <xsl:when test="normalize-space($doc_ns) != ''">
4439
- <xsl:value-of select="normalize-space($doc_ns)"/>
4440
- </xsl:when>
4441
- <xsl:otherwise>
4442
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4443
- </xsl:otherwise>
4444
- </xsl:choose>
4445
- </xsl:variable>
4446
- <tbody>
4447
- <xsl:apply-templates mode="dl"/>
4448
- </tbody>
4449
- </xsl:variable>
4450
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4451
- <xsl:variable name="colwidths">
4452
- <xsl:call-template name="calculate-column-widths">
4453
- <xsl:with-param name="cols-count" select="2"/>
4454
- <xsl:with-param name="table" select="$html-table"/>
4455
- </xsl:call-template>
4456
- </xsl:variable>
4457
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4458
- <xsl:variable name="maxlength_dt">
4459
- <xsl:call-template name="getMaxLength_dt"/>
4460
- </xsl:variable>
4461
- <xsl:call-template name="setColumnWidth_dl">
4462
- <xsl:with-param name="colwidths" select="$colwidths"/>
4463
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4464
- </xsl:call-template>
4465
- <fo:table-body>
4466
- <xsl:apply-templates>
4467
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4468
- </xsl:apply-templates>
4469
- </fo:table-body>
4909
+ <!-- create virtual html table for dl/[dt and dd] -->
4910
+ <xsl:variable name="simple-table">
4911
+
4912
+ <xsl:variable name="dl_table">
4913
+ <tbody>
4914
+ <xsl:apply-templates mode="dl_if">
4915
+ <xsl:with-param name="id" select="@id"/>
4916
+ </xsl:apply-templates>
4917
+ </tbody>
4918
+ </xsl:variable>
4919
+
4920
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
4921
+
4922
+ <!-- Step: replace <br/> to <p>...</p> -->
4923
+ <xsl:variable name="table_without_br">
4924
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
4925
+ </xsl:variable>
4926
+
4927
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
4928
+
4929
+ <!-- Step: add id to each cell -->
4930
+ <!-- add <word>...</word> for each word, image, math -->
4931
+ <xsl:variable name="simple-table-id">
4932
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
4933
+ <xsl:with-param name="id" select="@id"/>
4934
+ </xsl:apply-templates>
4935
+ </xsl:variable>
4936
+
4937
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
4938
+
4939
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
4940
+
4941
+ </xsl:variable>
4942
+
4943
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
4944
+
4945
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
4946
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
4947
+ </xsl:apply-templates>
4948
+
4949
+ </xsl:when>
4950
+ <xsl:otherwise>
4951
+
4952
+ <xsl:variable name="simple-table">
4953
+
4954
+ <xsl:variable name="dl_table">
4955
+ <tbody>
4956
+ <xsl:apply-templates mode="dl">
4957
+ <xsl:with-param name="id" select="@id"/>
4958
+ </xsl:apply-templates>
4959
+ </tbody>
4960
+ </xsl:variable>
4961
+
4962
+ <xsl:copy-of select="$dl_table"/>
4963
+ </xsl:variable>
4964
+
4965
+ <xsl:variable name="colwidths">
4966
+ <xsl:call-template name="calculate-column-widths">
4967
+ <xsl:with-param name="cols-count" select="2"/>
4968
+ <xsl:with-param name="table" select="$simple-table"/>
4969
+ </xsl:call-template>
4970
+ </xsl:variable>
4971
+
4972
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
4973
+ DEBUG
4974
+ colwidths=<xsl:copy-of select="$colwidths"/>
4975
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
4976
+
4977
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4978
+
4979
+ <xsl:variable name="maxlength_dt">
4980
+ <xsl:call-template name="getMaxLength_dt"/>
4981
+ </xsl:variable>
4982
+
4983
+ <xsl:variable name="isContainsKeepTogetherTag_">
4984
+ false
4985
+ </xsl:variable>
4986
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4987
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4988
+
4989
+
4990
+ <xsl:call-template name="setColumnWidth_dl">
4991
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4992
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4993
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4994
+ </xsl:call-template>
4995
+
4996
+ <fo:table-body>
4997
+
4998
+ <!-- DEBUG -->
4999
+ <xsl:if test="$table_if_debug = 'true'">
5000
+ <fo:table-row>
5001
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
5002
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5003
+ </fo:table-cell>
5004
+ </fo:table-row>
5005
+ </xsl:if>
5006
+
5007
+ <xsl:apply-templates>
5008
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
5009
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
5010
+ </xsl:apply-templates>
5011
+
5012
+ </fo:table-body>
5013
+ </xsl:otherwise>
5014
+ </xsl:choose>
4470
5015
  </fo:table>
4471
5016
  </fo:block>
4472
5017
  </fo:block>
4473
- </xsl:if>
5018
+ </xsl:if> <!-- END: a few components -->
4474
5019
  </fo:block-container>
4475
5020
  </fo:block-container>
5021
+
5022
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
5023
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
5024
+ </xsl:if>
5025
+
5026
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
5027
+ <xsl:param name="process">false</xsl:param>
5028
+ <xsl:if test="$process = 'true'">
5029
+ <fo:block xsl:use-attribute-sets="dl-name-style">
5030
+ <xsl:apply-templates/>
5031
+ </fo:block>
5032
+ </xsl:if>
4476
5033
  </xsl:template><xsl:template name="setColumnWidth_dl">
4477
5034
  <xsl:param name="colwidths"/>
4478
5035
  <xsl:param name="maxlength_dt"/>
5036
+ <xsl:param name="isContainsKeepTogetherTag"/>
5037
+
5038
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
5039
+
4479
5040
  <xsl:choose>
5041
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5042
+ <xsl:call-template name="insertTableColumnWidth">
5043
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5044
+ </xsl:call-template>
5045
+ </xsl:when>
4480
5046
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4481
5047
  <fo:table-column column-width="50%"/>
4482
5048
  <fo:table-column column-width="50%"/>
4483
5049
  </xsl:when>
4484
5050
  <xsl:otherwise>
4485
5051
  <xsl:choose>
5052
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5053
+ <xsl:call-template name="insertTableColumnWidth">
5054
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5055
+ </xsl:call-template>
5056
+ </xsl:when>
5057
+ <xsl:when test="$isContainsKeepTogetherTag">
5058
+ <xsl:call-template name="insertTableColumnWidth">
5059
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5060
+ </xsl:call-template>
5061
+ </xsl:when>
4486
5062
  <!-- to set width check most wide chars like `W` -->
4487
5063
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
4488
5064
  <fo:table-column column-width="7%"/>
@@ -4513,20 +5089,31 @@
4513
5089
  <fo:table-column column-width="60%"/>
4514
5090
  </xsl:when>
4515
5091
  <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>
5092
+ <xsl:call-template name="insertTableColumnWidth">
5093
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5094
+ </xsl:call-template>
4526
5095
  </xsl:otherwise>
4527
5096
  </xsl:choose>
4528
5097
  </xsl:otherwise>
4529
5098
  </xsl:choose>
5099
+ </xsl:template><xsl:template name="insertTableColumnWidth">
5100
+ <xsl:param name="colwidths"/>
5101
+
5102
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
5103
+ <xsl:choose>
5104
+ <xsl:when test=". = 1 or . = 0">
5105
+ <fo:table-column column-width="proportional-column-width(2)"/>
5106
+ </xsl:when>
5107
+ <xsl:otherwise>
5108
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
5109
+ <xsl:variable name="divider">
5110
+ <xsl:value-of select="@divider"/>
5111
+ <xsl:if test="not(@divider)">1</xsl:if>
5112
+ </xsl:variable>
5113
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
5114
+ </xsl:otherwise>
5115
+ </xsl:choose>
5116
+ </xsl:for-each>
4530
5117
  </xsl:template><xsl:template name="getMaxLength_dt">
4531
5118
  <xsl:variable name="lengths">
4532
5119
  <xsl:for-each select="*[local-name()='dt']">
@@ -4550,7 +5137,6 @@
4550
5137
  <xsl:value-of select="$maxLength"/>
4551
5138
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4552
5139
  <xsl:param name="key_iso"/>
4553
-
4554
5140
  <!-- <tr>
4555
5141
  <td>NOTE</td>
4556
5142
  <td>
@@ -4558,27 +5144,47 @@
4558
5144
  </td>
4559
5145
  </tr>
4560
5146
  -->
4561
- <fo:table-row>
5147
+ <!-- OLD Variant -->
5148
+ <!-- <fo:table-row>
4562
5149
  <fo:table-cell>
4563
5150
  <fo:block margin-top="6pt">
4564
5151
  <xsl:if test="normalize-space($key_iso) = 'true'">
4565
5152
  <xsl:attribute name="margin-top">0</xsl:attribute>
4566
5153
  </xsl:if>
4567
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5154
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4568
5155
  </fo:block>
4569
5156
  </fo:table-cell>
4570
5157
  <fo:table-cell>
4571
5158
  <fo:block>
4572
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5159
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
5160
+ </fo:block>
5161
+ </fo:table-cell>
5162
+ </fo:table-row> -->
5163
+ <!-- <tr>
5164
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
5165
+ </tr>
5166
+ -->
5167
+ <fo:table-row>
5168
+ <fo:table-cell number-columns-spanned="2">
5169
+ <fo:block>
5170
+ <xsl:call-template name="note"/>
4573
5171
  </fo:block>
4574
5172
  </fo:table-cell>
4575
5173
  </fo:table-row>
4576
5174
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
5175
+ <xsl:param name="id"/>
5176
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4577
5177
  <tr>
4578
5178
  <td>
5179
+ <xsl:attribute name="id">
5180
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5181
+ </xsl:attribute>
4579
5182
  <xsl:apply-templates/>
4580
5183
  </td>
4581
5184
  <td>
5185
+ <xsl:attribute name="id">
5186
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5187
+ </xsl:attribute>
4582
5188
 
4583
5189
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4584
5190
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4589,50 +5195,134 @@
4589
5195
 
4590
5196
  </xsl:template><xsl:template match="*[local-name()='dt']">
4591
5197
  <xsl:param name="key_iso"/>
5198
+ <xsl:param name="split_keep-within-line"/>
4592
5199
 
4593
5200
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4594
- <fo:table-cell>
5201
+ <xsl:call-template name="insert_dt_cell">
5202
+ <xsl:with-param name="key_iso" select="$key_iso"/>
5203
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5204
+ </xsl:call-template>
5205
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
5206
+ <xsl:call-template name="insert_dd_cell">
5207
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5208
+ </xsl:call-template>
5209
+ </xsl:for-each>
5210
+ </fo:table-row>
5211
+ </xsl:template><xsl:template name="insert_dt_cell">
5212
+ <xsl:param name="key_iso"/>
5213
+ <xsl:param name="split_keep-within-line"/>
5214
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
5215
+
5216
+ <xsl:if test="$isGenerateTableIF = 'true'">
5217
+ <!-- border is mandatory, to calculate real width -->
5218
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5219
+ <xsl:attribute name="text-align">left</xsl:attribute>
5220
+ </xsl:if>
5221
+
5222
+
5223
+ <fo:block xsl:use-attribute-sets="dt-block-style">
5224
+ <xsl:copy-of select="@id"/>
5225
+
5226
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5227
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5228
+ </xsl:if>
5229
+
5230
+
5231
+
5232
+ <xsl:apply-templates>
5233
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5234
+ </xsl:apply-templates>
5235
+
5236
+ <xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
5237
+
5238
+ </fo:block>
5239
+ </fo:table-cell>
5240
+ </xsl:template><xsl:template name="insert_dd_cell">
5241
+ <xsl:param name="split_keep-within-line"/>
5242
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5243
+
5244
+ <xsl:if test="$isGenerateTableIF = 'true'">
5245
+ <!-- border is mandatory, to calculate real width -->
5246
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5247
+ </xsl:if>
5248
+
5249
+ <fo:block>
5250
+
5251
+ <xsl:if test="$isGenerateTableIF = 'true'">
5252
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5253
+ </xsl:if>
5254
+
4595
5255
 
4596
- <fo:block xsl:use-attribute-sets="dt-style">
4597
- <xsl:copy-of select="@id"/>
4598
-
4599
- <xsl:if test="normalize-space($key_iso) = 'true'">
4600
- <xsl:attribute name="margin-top">0</xsl:attribute>
4601
- </xsl:if>
4602
-
4603
-
4604
-
4605
- <xsl:apply-templates/>
4606
- </fo:block>
4607
- </fo:table-cell>
4608
- <fo:table-cell>
4609
- <fo:block>
4610
-
4611
5256
 
4612
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4613
- <xsl:with-param name="process">true</xsl:with-param>
4614
- </xsl:apply-templates>
4615
- </fo:block>
4616
- </fo:table-cell>
4617
- </fo:table-row>
5257
+ <xsl:choose>
5258
+ <xsl:when test="$isGenerateTableIF = 'true'">
5259
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5260
+ <xsl:with-param name="process">true</xsl:with-param>
5261
+ </xsl:apply-templates>
5262
+ </xsl:when>
5263
+ <xsl:otherwise>
5264
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5265
+ <xsl:with-param name="process">true</xsl:with-param>
5266
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5267
+ </xsl:apply-templates>
5268
+ </xsl:otherwise>
5269
+
5270
+ </xsl:choose>
5271
+
5272
+ <xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
5273
+
5274
+ </fo:block>
5275
+ </fo:table-cell>
4618
5276
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4619
5277
  <xsl:apply-templates/>
4620
5278
  </xsl:template><xsl:template match="*[local-name()='dd']">
4621
5279
  <xsl:param name="process">false</xsl:param>
5280
+ <xsl:param name="split_keep-within-line"/>
4622
5281
  <xsl:if test="$process = 'true'">
4623
5282
  <xsl:apply-templates select="@language"/>
4624
- <xsl:apply-templates/>
5283
+ <xsl:apply-templates>
5284
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5285
+ </xsl:apply-templates>
4625
5286
  </xsl:if>
4626
5287
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4627
5288
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4628
- </xsl:template><xsl:template match="*[local-name()='em']">
5289
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5290
+ <xsl:param name="id"/>
5291
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5292
+ <tr>
5293
+ <td>
5294
+ <xsl:copy-of select="node()"/>
5295
+ </td>
5296
+ <td>
5297
+
5298
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
5299
+
5300
+ <!-- get paragraphs from nested 'dl' -->
5301
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
5302
+
5303
+
5304
+ </td>
5305
+ </tr>
5306
+
5307
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
5308
+ <xsl:for-each select="*[local-name() = 'dt']">
5309
+ <p>
5310
+ <xsl:copy-of select="node()"/>
5311
+ <xsl:text> </xsl:text>
5312
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
5313
+ </p>
5314
+ </xsl:for-each>
5315
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
4629
5316
  <fo:inline font-style="italic">
4630
5317
  <xsl:apply-templates/>
4631
5318
  </fo:inline>
4632
5319
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5320
+ <xsl:param name="split_keep-within-line"/>
4633
5321
  <fo:inline font-weight="bold">
4634
5322
 
4635
- <xsl:apply-templates/>
5323
+ <xsl:apply-templates>
5324
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5325
+ </xsl:apply-templates>
4636
5326
  </fo:inline>
4637
5327
  </xsl:template><xsl:template match="*[local-name()='padding']">
4638
5328
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4653,7 +5343,7 @@
4653
5343
 
4654
5344
 
4655
5345
 
4656
-
5346
+ <!-- 10 -->
4657
5347
 
4658
5348
  10
4659
5349
 
@@ -4671,13 +5361,15 @@
4671
5361
  <xsl:choose>
4672
5362
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4673
5363
  <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>
5364
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4675
5365
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4676
5366
  </xsl:choose>
4677
5367
  </xsl:attribute>
4678
5368
  </xsl:if>
4679
5369
  <xsl:apply-templates/>
4680
5370
  </fo:inline>
5371
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
5372
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4681
5373
  </xsl:template><xsl:template match="*[local-name()='underline']">
4682
5374
  <fo:inline text-decoration="underline">
4683
5375
  <xsl:apply-templates/>
@@ -4825,54 +5517,120 @@
4825
5517
  <fo:block break-after="page"/>
4826
5518
  <fo:block> </fo:block>
4827
5519
  <fo:block break-after="page"/>
5520
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5521
+ <xsl:apply-templates/>
4828
5522
  </xsl:template><xsl:template name="tokenize">
4829
5523
  <xsl:param name="text"/>
4830
5524
  <xsl:param name="separator" select="' '"/>
4831
5525
  <xsl:choose>
5526
+
5527
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5528
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5529
+ </xsl:when>
4832
5530
  <xsl:when test="not(contains($text, $separator))">
4833
5531
  <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
5532
  <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
5533
  <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"/>
5534
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5535
+ <xsl:value-of select="$len_str_tmp"/>
4860
5536
  </xsl:when>
4861
5537
  <xsl:otherwise>
4862
- <xsl:value-of select="$len_str"/>
5538
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5539
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5540
+ <xsl:variable name="len_str">
5541
+ <xsl:choose>
5542
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5543
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5544
+ </xsl:when>
5545
+ <xsl:otherwise>
5546
+ <xsl:value-of select="$len_str_tmp"/>
5547
+ </xsl:otherwise>
5548
+ </xsl:choose>
5549
+ </xsl:variable>
5550
+
5551
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5552
+ <xsl:message>
5553
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5554
+ len_str=<xsl:value-of select="$len_str"/>
5555
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5556
+ </xsl:message>
5557
+ </xsl:if> -->
5558
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5559
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5560
+ <xsl:choose>
5561
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5562
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5563
+ </xsl:when>
5564
+ <xsl:otherwise>
5565
+ <xsl:value-of select="$len_str"/>
5566
+ </xsl:otherwise>
5567
+ </xsl:choose>
4863
5568
  </xsl:otherwise>
4864
5569
  </xsl:choose>
4865
5570
  </word>
4866
5571
  </xsl:when>
4867
5572
  <xsl:otherwise>
4868
5573
  <word>
4869
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5574
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5575
+ <xsl:choose>
5576
+ <xsl:when test="$isGenerateTableIF = 'true'">
5577
+ <xsl:value-of select="$word"/>
5578
+ </xsl:when>
5579
+ <xsl:otherwise>
5580
+ <xsl:value-of select="string-length($word)"/>
5581
+ </xsl:otherwise>
5582
+ </xsl:choose>
4870
5583
  </word>
4871
5584
  <xsl:call-template name="tokenize">
4872
5585
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
4873
5586
  </xsl:call-template>
4874
5587
  </xsl:otherwise>
4875
5588
  </xsl:choose>
5589
+ </xsl:template><xsl:template name="tokenize_with_tags">
5590
+ <xsl:param name="tags"/>
5591
+ <xsl:param name="text"/>
5592
+ <xsl:param name="separator" select="' '"/>
5593
+ <xsl:choose>
5594
+
5595
+ <xsl:when test="not(contains($text, $separator))">
5596
+ <word>
5597
+ <xsl:call-template name="enclose_text_in_tags">
5598
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5599
+ <xsl:with-param name="tags" select="$tags"/>
5600
+ </xsl:call-template>
5601
+ </word>
5602
+ </xsl:when>
5603
+ <xsl:otherwise>
5604
+ <word>
5605
+ <xsl:call-template name="enclose_text_in_tags">
5606
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5607
+ <xsl:with-param name="tags" select="$tags"/>
5608
+ </xsl:call-template>
5609
+ </word>
5610
+ <xsl:call-template name="tokenize_with_tags">
5611
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5612
+ </xsl:call-template>
5613
+ </xsl:otherwise>
5614
+ </xsl:choose>
5615
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5616
+ <xsl:param name="text"/>
5617
+ <xsl:param name="tags"/>
5618
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5619
+
5620
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5621
+
5622
+ <xsl:choose>
5623
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5624
+ <xsl:otherwise>
5625
+ <xsl:element name="{$tag_name}">
5626
+ <xsl:call-template name="enclose_text_in_tags">
5627
+ <xsl:with-param name="text" select="$text"/>
5628
+ <xsl:with-param name="tags" select="$tags"/>
5629
+ <xsl:with-param name="num" select="$num + 1"/>
5630
+ </xsl:call-template>
5631
+ </xsl:element>
5632
+ </xsl:otherwise>
5633
+ </xsl:choose>
4876
5634
  </xsl:template><xsl:template name="max_length">
4877
5635
  <xsl:param name="words"/>
4878
5636
  <xsl:for-each select="$words//word">
@@ -4973,12 +5731,19 @@
4973
5731
  </xsl:otherwise>
4974
5732
  </xsl:choose>
4975
5733
  </xsl:template><xsl:template name="getSimpleTable">
5734
+ <xsl:param name="id"/>
5735
+
4976
5736
  <xsl:variable name="simple-table">
4977
5737
 
5738
+ <!-- Step 0. replace <br/> to <p>...</p> -->
5739
+ <xsl:variable name="table_without_br">
5740
+ <xsl:apply-templates mode="table-without-br"/>
5741
+ </xsl:variable>
5742
+
4978
5743
  <!-- Step 1. colspan processing -->
4979
5744
  <xsl:variable name="simple-table-colspan">
4980
5745
  <tbody>
4981
- <xsl:apply-templates mode="simple-table-colspan"/>
5746
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
4982
5747
  </tbody>
4983
5748
  </xsl:variable>
4984
5749
 
@@ -4987,10 +5752,67 @@
4987
5752
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
4988
5753
  </xsl:variable>
4989
5754
 
4990
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
4991
-
5755
+ <!-- Step 3: add id to each cell -->
5756
+ <!-- add <word>...</word> for each word, image, math -->
5757
+ <xsl:variable name="simple-table-id">
5758
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
5759
+ <xsl:with-param name="id" select="$id"/>
5760
+ </xsl:apply-templates>
5761
+ </xsl:variable>
5762
+
5763
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5764
+
4992
5765
  </xsl:variable>
4993
5766
  <xsl:copy-of select="$simple-table"/>
5767
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
5768
+ <xsl:copy>
5769
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
5770
+ </xsl:copy>
5771
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p'])]" mode="table-without-br">
5772
+ <xsl:copy>
5773
+ <xsl:copy-of select="@*"/>
5774
+ <p>
5775
+ <xsl:copy-of select="node()"/>
5776
+ </p>
5777
+ </xsl:copy>
5778
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
5779
+ <xsl:copy>
5780
+ <xsl:copy-of select="@*"/>
5781
+ <xsl:for-each select="*[local-name()='br']">
5782
+ <xsl:variable name="current_id" select="generate-id()"/>
5783
+ <p>
5784
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5785
+ <xsl:copy-of select="."/>
5786
+ </xsl:for-each>
5787
+ </p>
5788
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5789
+ <p>
5790
+ <xsl:for-each select="following-sibling::node()">
5791
+ <xsl:copy-of select="."/>
5792
+ </xsl:for-each>
5793
+ </p>
5794
+ </xsl:if>
5795
+ </xsl:for-each>
5796
+ </xsl:copy>
5797
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
5798
+ <xsl:for-each select="*[local-name()='br']">
5799
+ <xsl:variable name="current_id" select="generate-id()"/>
5800
+ <p>
5801
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5802
+ <xsl:copy-of select="."/>
5803
+ </xsl:for-each>
5804
+ </p>
5805
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5806
+ <p>
5807
+ <xsl:for-each select="following-sibling::node()">
5808
+ <xsl:copy-of select="."/>
5809
+ </xsl:for-each>
5810
+ </p>
5811
+ </xsl:if>
5812
+ </xsl:for-each>
5813
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
5814
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
5815
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
4994
5816
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
4995
5817
  <xsl:apply-templates mode="simple-table-colspan"/>
4996
5818
  </xsl:template><xsl:template match="*[local-name()='fn']" mode="simple-table-colspan"/><xsl:template match="*[local-name()='th'] | *[local-name()='td']" mode="simple-table-colspan">
@@ -5068,18 +5890,138 @@
5068
5890
  </xsl:choose>
5069
5891
  </xsl:for-each>
5070
5892
  </xsl:variable>
5071
-
5072
- <xsl:variable name="newRow">
5073
- <xsl:copy>
5074
- <xsl:copy-of select="$currentRow/@*"/>
5075
- <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
5076
- </xsl:copy>
5893
+
5894
+ <xsl:variable name="newRow">
5895
+ <xsl:copy>
5896
+ <xsl:copy-of select="$currentRow/@*"/>
5897
+ <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
5898
+ </xsl:copy>
5899
+ </xsl:variable>
5900
+ <xsl:copy-of select="$newRow"/>
5901
+
5902
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5903
+ <xsl:with-param name="previousRow" select="$newRow"/>
5904
+ </xsl:apply-templates>
5905
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
5906
+ <xsl:param name="id"/>
5907
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
5908
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5909
+ <xsl:with-param name="id" select="$id_prefixed"/>
5910
+ </xsl:apply-templates>
5911
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
5912
+ <xsl:param name="id"/>
5913
+ <xsl:copy>
5914
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5915
+ <xsl:with-param name="id" select="$id"/>
5916
+ </xsl:apply-templates>
5917
+ </xsl:copy>
5918
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
5919
+ <xsl:param name="id"/>
5920
+ <xsl:copy>
5921
+ <xsl:copy-of select="@*"/>
5922
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
5923
+ <xsl:apply-templates select="node()" mode="simple-table-id">
5924
+ <xsl:with-param name="id" select="$id"/>
5925
+ </xsl:apply-templates>
5926
+ </xsl:copy>
5927
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
5928
+ <xsl:param name="id"/>
5929
+ <xsl:copy>
5930
+ <xsl:copy-of select="@*"/>
5931
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
5932
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
5933
+ <xsl:attribute name="id">
5934
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
5935
+ </xsl:attribute>
5936
+
5937
+ <xsl:for-each select="*[local-name() = 'p']">
5938
+ <xsl:copy>
5939
+ <xsl:copy-of select="@*"/>
5940
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
5941
+ <xsl:attribute name="id">
5942
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
5943
+ </xsl:attribute>
5944
+
5945
+ <xsl:copy-of select="node()"/>
5946
+ </xsl:copy>
5947
+ </xsl:for-each>
5948
+
5949
+
5950
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
5951
+
5952
+ <xsl:variable name="td_text">
5953
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
5954
+ </xsl:variable>
5955
+
5956
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
5957
+
5958
+ <xsl:variable name="words">
5959
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
5960
+ <word>
5961
+ <xsl:copy-of select="."/>
5962
+ </word>
5963
+ </xsl:for-each>
5964
+
5965
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
5966
+ <xsl:copy-of select="."/>
5967
+ </xsl:for-each>
5968
+
5969
+ </xsl:variable>
5970
+
5971
+ <xsl:for-each select="xalan:nodeset($words)/word">
5972
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
5973
+ <xsl:copy>
5974
+ <xsl:attribute name="id">
5975
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
5976
+ </xsl:attribute>
5977
+ <xsl:copy-of select="node()"/>
5978
+ </xsl:copy>
5979
+ </xsl:for-each>
5980
+ </xsl:if>
5981
+ </xsl:copy>
5982
+
5983
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
5984
+ <xsl:copy>
5985
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
5986
+ </xsl:copy>
5987
+ </xsl:template><xsl:template match="*[local-name() = 'stem' or local-name() = 'image']" mode="td_text_with_formatting"/><xsl:template match="*[local-name() = 'keep-together_within-line']/text()" mode="td_text_with_formatting">
5988
+ <xsl:variable name="formatting_tags">
5989
+ <xsl:call-template name="getFormattingTags"/>
5990
+ </xsl:variable>
5991
+ <word>
5992
+ <xsl:call-template name="enclose_text_in_tags">
5993
+ <xsl:with-param name="text" select="normalize-space(.)"/>
5994
+ <xsl:with-param name="tags" select="$formatting_tags"/>
5995
+ </xsl:call-template>
5996
+ </word>
5997
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
5998
+
5999
+ <xsl:variable name="td_text" select="."/>
6000
+
6001
+ <xsl:variable name="string_with_added_zerospaces">
6002
+ <xsl:call-template name="add-zero-spaces-java">
6003
+ <xsl:with-param name="text" select="$td_text"/>
6004
+ </xsl:call-template>
6005
+ </xsl:variable>
6006
+
6007
+ <xsl:variable name="formatting_tags">
6008
+ <xsl:call-template name="getFormattingTags"/>
5077
6009
  </xsl:variable>
5078
- <xsl:copy-of select="$newRow"/>
5079
-
5080
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5081
- <xsl:with-param name="previousRow" select="$newRow"/>
5082
- </xsl:apply-templates>
6010
+
6011
+ <!-- <word>text</word> -->
6012
+ <xsl:call-template name="tokenize_with_tags">
6013
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6014
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
6015
+ </xsl:call-template>
6016
+ </xsl:template><xsl:template name="getFormattingTags">
6017
+ <tags>
6018
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
6019
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
6020
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6021
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6022
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6023
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6024
+ </tags>
5083
6025
  </xsl:template><xsl:template name="getLang">
5084
6026
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5085
6027
  <xsl:variable name="language">
@@ -5134,6 +6076,9 @@
5134
6076
  <xsl:variable name="isDeleted" select="@deleted"/>
5135
6077
 
5136
6078
  <fo:inline xsl:use-attribute-sets="mathml-style">
6079
+
6080
+
6081
+
5137
6082
 
5138
6083
 
5139
6084
  <xsl:call-template name="setTrackChangesStyles">
@@ -5141,48 +6086,87 @@
5141
6086
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
5142
6087
  </xsl:call-template>
5143
6088
 
6089
+ <xsl:if test="$add_math_as_text = 'true'">
6090
+ <!-- insert helper tag -->
6091
+ <!-- set unique font-size (fiction) -->
6092
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
6093
+ <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 -->
6094
+ </xsl:if>
5144
6095
 
5145
-
5146
- <xsl:variable name="mathml">
5147
- <xsl:apply-templates select="." mode="mathml"/>
6096
+ <xsl:variable name="mathml_content">
6097
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
5148
6098
  </xsl:variable>
5149
- <fo:instream-foreign-object fox:alt-text="Math">
5150
6099
 
6100
+
6101
+ <xsl:call-template name="mathml_instream_object">
6102
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
6103
+ </xsl:call-template>
5151
6104
 
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>
6105
+
6106
+ </fo:inline>
6107
+ </xsl:template><xsl:template name="getMathml_comment_text">
6108
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
6109
+ <xsl:variable name="comment_text_">
6110
+ <xsl:choose>
6111
+ <xsl:when test="normalize-space($comment_text_following) != ''">
6112
+ <xsl:value-of select="$comment_text_following"/>
6113
+ </xsl:when>
6114
+ <xsl:otherwise>
6115
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
6116
+ </xsl:otherwise>
6117
+ </xsl:choose>
6118
+ </xsl:variable>
6119
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
6120
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
6121
+ <xsl:value-of select="$comment_text"/>
6122
+ </xsl:template><xsl:template name="mathml_instream_object">
6123
+ <xsl:param name="comment_text"/>
6124
+ <xsl:param name="mathml_content"/>
6125
+
6126
+ <xsl:variable name="comment_text_">
6127
+ <xsl:choose>
6128
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
6129
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
6130
+ </xsl:choose>
6131
+ </xsl:variable>
6132
+
6133
+ <xsl:variable name="mathml">
6134
+ <xsl:apply-templates select="." mode="mathml"/>
6135
+ </xsl:variable>
6136
+
6137
+ <fo:instream-foreign-object fox:alt-text="Math">
6138
+
6139
+
6140
+
6141
+
6142
+
6143
+
6144
+ <xsl:if test="local-name(../..) = 'formula' or (local-name(../..) = 'td' and count(../../*) = 1)">
6145
+ <xsl:attribute name="width">95%</xsl:attribute>
6146
+ <xsl:attribute name="content-height">100%</xsl:attribute>
6147
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6148
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5171
6149
  </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"/>
6150
+
6151
+
6152
+ <!-- put MathML in Actual Text -->
6153
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
6154
+ <xsl:attribute name="fox:actual-text">
6155
+ <xsl:value-of select="$mathml_content"/>
6156
+ </xsl:attribute>
6157
+
6158
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
6159
+ <xsl:if test="normalize-space($comment_text_) != ''">
6160
+ <!-- put Mathin Alternate Text -->
6161
+ <xsl:attribute name="fox:alt-text">
6162
+ <xsl:value-of select="$comment_text_"/>
5179
6163
  </xsl:attribute>
5180
-
5181
-
5182
-
5183
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
5184
- </fo:instream-foreign-object>
5185
- </fo:inline>
6164
+ </xsl:if>
6165
+ <!-- </xsl:if> -->
6166
+
6167
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
6168
+
6169
+ </fo:instream-foreign-object>
5186
6170
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
5187
6171
  <!-- <xsl:text>a+b</xsl:text> -->
5188
6172
  <xsl:text>&lt;</xsl:text>
@@ -5213,7 +6197,9 @@
5213
6197
  <!-- replace start and end spaces to non-break space -->
5214
6198
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
5215
6199
  </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">
6200
+ </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">
6201
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
6202
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5217
6203
  <xsl:variable name="target">
5218
6204
  <xsl:choose>
5219
6205
  <xsl:when test="@updatetype = 'true'">
@@ -5806,18 +6792,33 @@
5806
6792
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5807
6793
  <xsl:copy>
5808
6794
  <xsl:apply-templates select="@*" mode="svg_update"/>
5809
- <xsl:variable name="viewbox">
6795
+ <xsl:variable name="viewbox_">
5810
6796
  <xsl:call-template name="split">
5811
6797
  <xsl:with-param name="pText" select="@viewBox"/>
5812
6798
  <xsl:with-param name="sep" select="' '"/>
5813
6799
  </xsl:call-template>
5814
6800
  </xsl:variable>
6801
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
6802
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
6803
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
6804
+
5815
6805
  <xsl:attribute name="width">
5816
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
6806
+ <xsl:choose>
6807
+ <xsl:when test="$width != ''">
6808
+ <xsl:value-of select="round($width)"/>
6809
+ </xsl:when>
6810
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
6811
+ </xsl:choose>
5817
6812
  </xsl:attribute>
5818
6813
  <xsl:attribute name="height">
5819
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
6814
+ <xsl:choose>
6815
+ <xsl:when test="$height != ''">
6816
+ <xsl:value-of select="round($height)"/>
6817
+ </xsl:when>
6818
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
6819
+ </xsl:choose>
5820
6820
  </xsl:attribute>
6821
+
5821
6822
  <xsl:apply-templates mode="svg_update"/>
5822
6823
  </xsl:copy>
5823
6824
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -6012,7 +7013,11 @@
6012
7013
  <xsl:apply-templates mode="bookmarks"/>
6013
7014
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
6014
7015
  <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">
7016
+ </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">
7017
+ <xsl:apply-templates mode="contents"/>
7018
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
7019
+ <xsl:apply-templates mode="bookmarks"/>
7020
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
6016
7021
  <xsl:apply-templates mode="bookmarks"/>
6017
7022
  </xsl:template><xsl:template name="addBookmarks">
6018
7023
  <xsl:param name="contents"/>
@@ -6294,7 +7299,9 @@
6294
7299
  <xsl:apply-templates/>
6295
7300
  </xsl:otherwise>
6296
7301
  </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">
7302
+ </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">
7303
+ <xsl:value-of select="."/>
7304
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6298
7305
  <xsl:text> </xsl:text>
6299
7306
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6300
7307
  <xsl:copy>
@@ -6325,9 +7332,22 @@
6325
7332
  </xsl:when>
6326
7333
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6327
7334
  </xsl:choose>
7335
+ </xsl:template><xsl:template match="text()" mode="contents_item">
7336
+ <xsl:call-template name="keep_together_standard_number"/>
7337
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
7338
+ <xsl:apply-templates mode="contents_item"/>
6328
7339
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6329
7340
 
6330
7341
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7342
+
7343
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7344
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7345
+ </xsl:if>
7346
+
7347
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7348
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7349
+ </xsl:if>
7350
+
6331
7351
  <xsl:copy-of select="@id"/>
6332
7352
 
6333
7353
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6352,7 +7372,7 @@
6352
7372
 
6353
7373
 
6354
7374
 
6355
-
7375
+ <!-- 9 -->
6356
7376
 
6357
7377
  9
6358
7378
 
@@ -6436,7 +7456,7 @@
6436
7456
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6437
7457
  <xsl:choose>
6438
7458
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6439
- <xsl:call-template name="interspers">
7459
+ <xsl:call-template name="interspers-java">
6440
7460
  <xsl:with-param name="str" select="."/>
6441
7461
  </xsl:call-template>
6442
7462
  </xsl:when>
@@ -6486,6 +7506,10 @@
6486
7506
  <xsl:with-param name="char" select="$char"/>
6487
7507
  </xsl:call-template>
6488
7508
  </xsl:if>
7509
+ </xsl:template><xsl:template name="interspers-java">
7510
+ <xsl:param name="str"/>
7511
+ <xsl:param name="char" select="$zero_width_space"/>
7512
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
6489
7513
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6490
7514
  <xsl:apply-templates mode="syntax_highlight"/>
6491
7515
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6698,7 +7722,9 @@
6698
7722
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
6699
7723
  </xsl:if>
6700
7724
  <xsl:variable name="simple-table">
6701
- <xsl:call-template name="getSimpleTable"/>
7725
+ <xsl:call-template name="getSimpleTable">
7726
+ <xsl:with-param name="id" select="@id"/>
7727
+ </xsl:call-template>
6702
7728
  </xsl:variable>
6703
7729
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
6704
7730
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -6805,39 +7831,67 @@
6805
7831
  </xsl:otherwise>
6806
7832
  </xsl:choose>
6807
7833
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6808
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6809
-
7834
+
7835
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7836
+
6810
7837
 
7838
+
6811
7839
  <xsl:variable name="fo_element">
6812
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
7840
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6813
7841
  inline
6814
7842
  </xsl:variable>
6815
7843
 
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>
7844
+ <fo:block-container margin-left="0mm">
6820
7845
 
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')]">
7846
+ <xsl:choose>
7847
+
7848
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
7849
+
7850
+ <!-- display name 'EXAMPLE' in a separate block -->
7851
+ <fo:block>
7852
+ <xsl:apply-templates select="*[local-name()='name']">
6826
7853
  <xsl:with-param name="fo_element" select="$fo_element"/>
6827
7854
  </xsl:apply-templates>
7855
+ </fo:block>
7856
+
7857
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7858
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7859
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7860
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7861
+ </xsl:apply-templates>
7862
+ </fo:block-container>
6828
7863
  </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>
7864
+ </xsl:when> <!-- end block -->
7865
+
7866
+ <xsl:otherwise> <!-- inline -->
7867
+
7868
+ <!-- display 'EXAMPLE' and first element in the same line -->
7869
+ <fo:block>
7870
+ <xsl:apply-templates select="*[local-name()='name']">
7871
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7872
+ </xsl:apply-templates>
7873
+ <fo:inline>
7874
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
7875
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7876
+ </xsl:apply-templates>
7877
+ </fo:inline>
7878
+ </fo:block>
7879
+
7880
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
7881
+ <!-- display further elements in blocks -->
7882
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7883
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7884
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
7885
+ <xsl:with-param name="fo_element" select="'block'"/>
7886
+ </xsl:apply-templates>
7887
+ </fo:block-container>
7888
+ </fo:block-container>
7889
+ </xsl:if>
7890
+ </xsl:otherwise> <!-- end inline -->
7891
+
7892
+ </xsl:choose>
7893
+ </fo:block-container>
7894
+ </fo:block-container>
6841
7895
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6842
7896
  <xsl:param name="fo_element">block</xsl:param>
6843
7897
 
@@ -6874,10 +7928,16 @@
6874
7928
  </xsl:variable>
6875
7929
  <xsl:choose>
6876
7930
  <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>
7931
+ <fo:block-container>
7932
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
7933
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7934
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7935
+ </xsl:if>
7936
+ <fo:block xsl:use-attribute-sets="example-p-style">
7937
+
7938
+ <xsl:apply-templates/>
7939
+ </fo:block>
7940
+ </fo:block-container>
6881
7941
  </xsl:when>
6882
7942
  <xsl:otherwise>
6883
7943
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -7066,7 +8126,16 @@
7066
8126
  </fo:inline>
7067
8127
  </xsl:when>
7068
8128
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7069
- <fo:inline><xsl:apply-templates/></fo:inline>
8129
+
8130
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
8131
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
8132
+ <xsl:choose>
8133
+ <xsl:when test="$uri_src != ''">
8134
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
8135
+ </xsl:when>
8136
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
8137
+ </xsl:choose>
8138
+
7070
8139
  </xsl:otherwise>
7071
8140
  </xsl:choose>
7072
8141
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7246,10 +8315,24 @@
7246
8315
 
7247
8316
  </fo:block>
7248
8317
  <xsl:apply-templates/>
7249
- </xsl:template><xsl:template match="*[local-name() = 'review']">
8318
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7250
8319
  <!-- comment 2019-11-29 -->
7251
8320
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7252
8321
  <xsl:apply-templates /> -->
8322
+
8323
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
8324
+
8325
+ <xsl:choose>
8326
+ <!-- if there isn't the attribute '@from', then -->
8327
+ <xsl:when test="$id_from = ''">
8328
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8329
+ </xsl:when>
8330
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
8331
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
8332
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8333
+ </xsl:when>
8334
+ </xsl:choose>
8335
+
7253
8336
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7254
8337
  <!-- 0xA0 to space replacement -->
7255
8338
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7396,6 +8479,11 @@
7396
8479
  </xsl:otherwise>
7397
8480
  </xsl:choose>
7398
8481
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
8482
+
8483
+ <xsl:apply-templates select="*[local-name() = 'name']">
8484
+ <xsl:with-param name="process">true</xsl:with-param>
8485
+ </xsl:apply-templates>
8486
+
7399
8487
  <fo:list-block xsl:use-attribute-sets="list-style">
7400
8488
 
7401
8489
 
@@ -7406,12 +8494,23 @@
7406
8494
 
7407
8495
 
7408
8496
 
8497
+ <xsl:if test="*[local-name() = 'name']">
8498
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8499
+ </xsl:if>
8500
+
7409
8501
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7410
8502
  </fo:list-block>
7411
8503
  <!-- <xsl:for-each select="./iho:note">
7412
8504
  <xsl:call-template name="note"/>
7413
8505
  </xsl:for-each> -->
7414
8506
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
8507
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
8508
+ <xsl:param name="process">false</xsl:param>
8509
+ <xsl:if test="$process = 'true'">
8510
+ <fo:block xsl:use-attribute-sets="list-name-style">
8511
+ <xsl:apply-templates/>
8512
+ </fo:block>
8513
+ </xsl:if>
7415
8514
  </xsl:template><xsl:template match="*[local-name()='li']">
7416
8515
  <fo:list-item xsl:use-attribute-sets="list-item-style">
7417
8516
  <xsl:copy-of select="@id"/>
@@ -7608,7 +8707,10 @@
7608
8707
  <!-- to split by '_' and other chars -->
7609
8708
  <xsl:call-template name="add-zero-spaces-java"/>
7610
8709
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7611
- <fo:inline id="{@id}" font-size="1pt"/>
8710
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8711
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8712
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8713
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7612
8714
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7613
8715
  <!-- <row>
7614
8716
  <date>05-07-2013</date>
@@ -7712,32 +8814,14 @@
7712
8814
  <xsl:variable name="docidentifier">
7713
8815
  <xsl:choose>
7714
8816
  <xsl:when test="*[local-name()='docidentifier']/@type = 'metanorma'"/>
7715
- <xsl:otherwise><xsl:value-of select="*[local-name()='docidentifier'][not(@type = 'metanorma-ordinal')]"/></xsl:otherwise>
8817
+ <xsl:otherwise><xsl:value-of select="*[local-name()='docidentifier'][not(@type = 'metanorma-ordinal') and not(@type = 'BIPM')]"/></xsl:otherwise>
7716
8818
  </xsl:choose>
7717
8819
  </xsl:variable>
7718
8820
  <xsl:value-of select="$docidentifier"/>
7719
8821
 
7720
- <xsl:choose>
7721
- <xsl:when test="*[local-name()='formattedref']">
7722
- <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
7723
- <xsl:apply-templates select="*[local-name()='formattedref']"/>
7724
- </xsl:when>
7725
- <xsl:otherwise>
7726
- <xsl:apply-templates select="*[local-name()='note']"/>
7727
- <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
7728
- <xsl:choose>
7729
- <xsl:when test="*[local-name()='title'][@type = 'main' and @language = $lang]">
7730
- <xsl:apply-templates select="*[local-name()='title'][@type = 'main' and @language = $lang]"/>
7731
- </xsl:when>
7732
- <xsl:when test="*[local-name()='title'][@type = 'main' and @language = 'en']">
7733
- <xsl:apply-templates select="*[local-name()='title'][@type = 'main' and @language = 'en']"/>
7734
- </xsl:when>
7735
- <xsl:otherwise>
7736
- <xsl:apply-templates select="*[local-name()='title']"/>
7737
- </xsl:otherwise>
7738
- </xsl:choose>
7739
- </xsl:otherwise>
7740
- </xsl:choose>
8822
+ <xsl:if test="*[local-name()='formattedref'] and normalize-space($docidentifier) != ''">, </xsl:if>
8823
+ <xsl:apply-templates select="*[local-name()='formattedref']"/>
8824
+
7741
8825
  <!-- end JCGM bibitem processing -->
7742
8826
 
7743
8827
  </xsl:template><xsl:template name="processBibitemDocId">
@@ -8043,36 +9127,58 @@
8043
9127
 
8044
9128
 
8045
9129
 
9130
+ <xsl:if test="@type = 'editorial'">
9131
+ <xsl:attribute name="color">green</xsl:attribute>
9132
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
9133
+
9134
+ <!-- <xsl:variable name="note-style">
9135
+ <style xsl:use-attribute-sets="note-style"></style>
9136
+ </xsl:variable>
9137
+ <xsl:for-each select="xalan:nodeset($note-style)//style/@*">
9138
+ <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
9139
+ </xsl:for-each> -->
9140
+ </xsl:if>
9141
+
9142
+
8046
9143
 
8047
9144
 
8048
9145
 
8049
- <xsl:call-template name="displayAdmonitionName"/>
8050
- <xsl:text> — </xsl:text>
9146
+
9147
+ <xsl:call-template name="displayAdmonitionName">
9148
+ <xsl:with-param name="sep"> — </xsl:with-param>
9149
+ </xsl:call-template>
8051
9150
 
8052
9151
 
8053
9152
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8054
9153
  </fo:block>
8055
9154
 
8056
9155
  </xsl:template><xsl:template name="displayAdmonitionName">
8057
-
9156
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
9157
+ <!-- <xsl:choose>
9158
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
9159
+ <xsl:choose>
9160
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
9161
+ <xsl:otherwise>
9162
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
9163
+ </xsl:otherwise>
9164
+ </xsl:choose>
9165
+ </xsl:when>
9166
+ <xsl:otherwise>
8058
9167
  <xsl:apply-templates select="*[local-name() = 'name']"/>
8059
9168
  <xsl:if test="not(*[local-name() = 'name'])">
8060
9169
  <xsl:apply-templates select="@type"/>
8061
9170
  </xsl:if>
8062
-
8063
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8064
- <xsl:apply-templates/>
8065
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
8066
- <xsl:variable name="admonition_type_">
8067
- <xsl:call-template name="getLocalizedString">
8068
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
8069
- </xsl:call-template>
9171
+ </xsl:otherwise>
9172
+ </xsl:choose> -->
9173
+ <xsl:variable name="name">
9174
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8070
9175
  </xsl:variable>
8071
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
8072
- <xsl:value-of select="$admonition_type"/>
8073
- <xsl:if test="$admonition_type = ''">
8074
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
9176
+ <xsl:copy-of select="$name"/>
9177
+ <xsl:if test="normalize-space($name) != ''">
9178
+ <xsl:value-of select="$sep"/>
8075
9179
  </xsl:if>
9180
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
9181
+ <xsl:apply-templates/>
8076
9182
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
8077
9183
 
8078
9184
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -8154,6 +9260,120 @@
8154
9260
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8155
9261
  </xsl:for-each>
8156
9262
  </xsl:copy>
9263
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9264
+ <xsl:apply-templates mode="update_xml_step1"/>
9265
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9266
+ <xsl:copy>
9267
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
9268
+ </xsl:copy>
9269
+ </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">
9270
+
9271
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
9272
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9273
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9274
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9275
+ <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))"/>
9276
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9277
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9278
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9279
+ <xsl:with-param name="text" select="$text_"/>
9280
+ </xsl:call-template></text></xsl:variable>
9281
+
9282
+ <xsl:variable name="parent" select="local-name(..)"/>
9283
+
9284
+ <xsl:variable name="text2">
9285
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
9286
+ <xsl:copy-of select="."/>
9287
+ </xsl:for-each></text>
9288
+ </xsl:variable>
9289
+
9290
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9291
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
9292
+ <xsl:variable name="text3">
9293
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9294
+ <xsl:choose>
9295
+ <xsl:when test="self::text()">
9296
+ <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))"/>
9297
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
9298
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9299
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9300
+ <xsl:with-param name="text" select="$text_units_"/>
9301
+ </xsl:call-template></text></xsl:variable>
9302
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
9303
+ </xsl:when>
9304
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9305
+ </xsl:choose>
9306
+ </xsl:for-each></text>
9307
+ </xsl:variable>
9308
+
9309
+ <xsl:choose>
9310
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9311
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9312
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9313
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9314
+ <xsl:choose>
9315
+ <xsl:when test="self::text()">
9316
+ <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))"/>
9317
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
9318
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9319
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9320
+ <xsl:with-param name="text" select="$text_dots_"/>
9321
+ </xsl:call-template></text></xsl:variable>
9322
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
9323
+ </xsl:when>
9324
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9325
+ </xsl:choose>
9326
+ </xsl:for-each>
9327
+ </xsl:when>
9328
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
9329
+ </xsl:choose>
9330
+
9331
+ </xsl:template><xsl:template name="replace_text_tags">
9332
+ <xsl:param name="tag_open"/>
9333
+ <xsl:param name="tag_close"/>
9334
+ <xsl:param name="text"/>
9335
+ <xsl:choose>
9336
+ <xsl:when test="contains($text, $tag_open)">
9337
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
9338
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
9339
+
9340
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
9341
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
9342
+ </xsl:element>
9343
+
9344
+ <xsl:call-template name="replace_text_tags">
9345
+ <xsl:with-param name="tag_open" select="$tag_open"/>
9346
+ <xsl:with-param name="tag_close" select="$tag_close"/>
9347
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
9348
+ </xsl:call-template>
9349
+ </xsl:when>
9350
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
9351
+ </xsl:choose>
9352
+ </xsl:template><xsl:template name="printEdition">
9353
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
9354
+ <xsl:text> </xsl:text>
9355
+ <xsl:choose>
9356
+ <xsl:when test="$edition_i18n != ''">
9357
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
9358
+ <xsl:call-template name="capitalize">
9359
+ <xsl:with-param name="str" select="$edition_i18n"/>
9360
+ </xsl:call-template>
9361
+ </xsl:when>
9362
+ <xsl:otherwise>
9363
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
9364
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
9365
+ <xsl:call-template name="capitalize">
9366
+ <xsl:with-param name="str">
9367
+ <xsl:call-template name="getLocalizedString">
9368
+ <xsl:with-param name="key">edition</xsl:with-param>
9369
+ </xsl:call-template>
9370
+ </xsl:with-param>
9371
+ </xsl:call-template>
9372
+ <xsl:text> </xsl:text>
9373
+ <xsl:value-of select="$edition"/>
9374
+ </xsl:if>
9375
+ </xsl:otherwise>
9376
+ </xsl:choose>
8157
9377
  </xsl:template><xsl:template name="convertDate">
8158
9378
  <xsl:param name="date"/>
8159
9379
  <xsl:param name="format" select="'short'"/>
@@ -8838,4 +10058,40 @@
8838
10058
  <xsl:value-of select="$value"/>
8839
10059
  </xsl:otherwise>
8840
10060
  </xsl:choose>
10061
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
10062
+ <xsl:param name="level">0</xsl:param>
10063
+
10064
+ <fo:block margin-left="{2*$level}mm">
10065
+ <xsl:text>
10066
+ &lt;</xsl:text>
10067
+ <xsl:value-of select="local-name()"/>
10068
+ <xsl:for-each select="@*">
10069
+ <xsl:text> </xsl:text>
10070
+ <xsl:value-of select="local-name()"/>
10071
+ <xsl:text>="</xsl:text>
10072
+ <xsl:value-of select="."/>
10073
+ <xsl:text>"</xsl:text>
10074
+ </xsl:for-each>
10075
+ <xsl:text>&gt;</xsl:text>
10076
+
10077
+ <xsl:if test="not(*)">
10078
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
10079
+ <xsl:text>&lt;/</xsl:text>
10080
+ <xsl:value-of select="local-name()"/>
10081
+ <xsl:text>&gt;</xsl:text>
10082
+ </xsl:if>
10083
+ </fo:block>
10084
+
10085
+ <xsl:if test="*">
10086
+ <fo:block>
10087
+ <xsl:apply-templates mode="print_as_xml">
10088
+ <xsl:with-param name="level" select="$level + 1"/>
10089
+ </xsl:apply-templates>
10090
+ </fo:block>
10091
+ <fo:block margin-left="{2*$level}mm">
10092
+ <xsl:text>&lt;/</xsl:text>
10093
+ <xsl:value-of select="local-name()"/>
10094
+ <xsl:text>&gt;</xsl:text>
10095
+ </fo:block>
10096
+ </xsl:if>
8841
10097
  </xsl:template></xsl:stylesheet>