metanorma-iec 2.0.8 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -936,14 +936,16 @@
936
936
  <fo:inline keep-together.within-line="always" font-size="25pt" font-weight="bold" color="{$color_gray}" border-bottom="0.5pt solid {$color_gray}" padding-bottom="3.5mm" baseline-shift="5.5mm"><fo:leader leader-pattern="space"/><xsl:value-of select="//iec:iec-standard/iec:bibdata/iec:docidentifier[@type = 'iso' or @type = 'ISO']"/></fo:inline>
937
937
  </fo:block>
938
938
  <fo:block font-size="10.5pt" text-align="right" margin-top="0.5mm">
939
- <xsl:variable name="title-edition">
940
- <xsl:call-template name="getTitle">
941
- <xsl:with-param name="name" select="'title-edition'"/>
942
- </xsl:call-template>
943
- </xsl:variable>
944
- <xsl:value-of select="$title-edition"/>
939
+ <xsl:call-template name="capitalize">
940
+ <xsl:with-param name="str">
941
+ <xsl:call-template name="getLocalizedString">
942
+ <xsl:with-param name="key">edition</xsl:with-param>
943
+ </xsl:call-template>
944
+ </xsl:with-param>
945
+ </xsl:call-template>
946
+ <xsl:text> </xsl:text>
945
947
  <fo:inline>
946
- <xsl:variable name="edition" select="//iec:iec-standard/iec:bibdata/iec:edition"/>
948
+ <xsl:variable name="edition" select="//iec:iec-standard/iec:bibdata/iec:edition[normalize-space(@language) = '']"/>
947
949
  <xsl:value-of select="$edition"/>
948
950
  <xsl:if test="not(contains($edition, '.'))">.0</xsl:if>
949
951
  </fo:inline>
@@ -1639,6 +1641,7 @@
1639
1641
 
1640
1642
  <xsl:template match="iec:p" name="paragraph">
1641
1643
  <xsl:param name="inline" select="'false'"/>
1644
+ <xsl:param name="split_keep-within-line"/>
1642
1645
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
1643
1646
  <xsl:variable name="element-name">
1644
1647
  <xsl:choose>
@@ -1681,11 +1684,15 @@
1681
1684
  </xsl:if>
1682
1685
 
1683
1686
  <xsl:apply-templates select="@language"/>
1684
- <xsl:apply-templates/>
1687
+ <xsl:apply-templates>
1688
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1689
+ </xsl:apply-templates>
1685
1690
  </xsl:element>
1686
1691
  </xsl:when>
1687
1692
  <xsl:otherwise>
1688
- <xsl:apply-templates/>
1693
+ <xsl:apply-templates>
1694
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1695
+ </xsl:apply-templates>
1689
1696
  </xsl:otherwise>
1690
1697
  </xsl:choose>
1691
1698
 
@@ -1928,12 +1935,41 @@
1928
1935
  </xsl:copy>
1929
1936
  </xsl:template> -->
1930
1937
 
1931
- <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">
1938
+ <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_">
1939
+ <xsl:for-each select="$table_widths_from_if//table">
1940
+ <xsl:copy>
1941
+ <xsl:copy-of select="@*"/>
1942
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
1943
+ </xsl:copy>
1944
+ </xsl:for-each>
1945
+ </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_">
1946
+ false
1947
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
1932
1948
  <xsl:call-template name="getLang"/>
1933
- </xsl:variable><xsl:variable name="pageWidth_">
1934
- 210
1949
+ </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_">
1950
+ <xsl:choose>
1951
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
1952
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
1953
+ </xsl:choose>
1954
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
1955
+ <xsl:choose>
1956
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
1957
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
1958
+ </xsl:choose>
1959
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
1960
+ <xsl:choose>
1961
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
1962
+ <xsl:otherwise>
1963
+ 210
1964
+ </xsl:otherwise>
1965
+ </xsl:choose>
1935
1966
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
1936
- 297
1967
+ <xsl:choose>
1968
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
1969
+ <xsl:otherwise>
1970
+ 297
1971
+ </xsl:otherwise>
1972
+ </xsl:choose>
1937
1973
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
1938
1974
  25
1939
1975
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -1943,20 +1979,7 @@
1943
1979
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1944
1980
  15
1945
1981
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1946
-
1947
- <title-edition lang="en">
1948
-
1949
- <xsl:text>Edition </xsl:text>
1950
-
1951
- </title-edition>
1952
-
1953
- <title-edition lang="fr">
1954
- <xsl:text>Édition </xsl:text>
1955
- </title-edition>
1956
1982
 
1957
- <title-edition lang="ru">
1958
- <xsl:text>Издание </xsl:text>
1959
- </title-edition>
1960
1983
 
1961
1984
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1962
1985
  <title-toc lang="en">
@@ -2041,7 +2064,7 @@
2041
2064
  </xsl:variable><xsl:variable name="bibdata">
2042
2065
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
2043
2066
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
2044
- </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">
2067
+ </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">
2045
2068
  <xsl:param name="name"/>
2046
2069
  <xsl:param name="lang"/>
2047
2070
  <xsl:variable name="lang_">
@@ -2089,7 +2112,7 @@
2089
2112
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
2090
2113
 
2091
2114
  <xsl:variable name="additional_fonts_">
2092
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
2115
+ <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']">
2093
2116
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
2094
2117
  </xsl:for-each>
2095
2118
  </xsl:variable>
@@ -2165,7 +2188,6 @@
2165
2188
 
2166
2189
 
2167
2190
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
2168
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2169
2191
 
2170
2192
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
2171
2193
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -2253,6 +2275,7 @@
2253
2275
  <xsl:attribute name="margin-left">10mm</xsl:attribute>
2254
2276
 
2255
2277
 
2278
+
2256
2279
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2257
2280
 
2258
2281
 
@@ -2411,6 +2434,7 @@
2411
2434
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2412
2435
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2413
2436
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2437
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2414
2438
  <xsl:attribute name="display-align">center</xsl:attribute>
2415
2439
 
2416
2440
 
@@ -2433,6 +2457,7 @@
2433
2457
  <xsl:attribute name="display-align">center</xsl:attribute>
2434
2458
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2435
2459
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2460
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2436
2461
 
2437
2462
 
2438
2463
 
@@ -2536,7 +2561,8 @@
2536
2561
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
2537
2562
 
2538
2563
 
2539
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2564
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2565
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2540
2566
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2541
2567
 
2542
2568
 
@@ -2550,6 +2576,27 @@
2550
2576
 
2551
2577
 
2552
2578
 
2579
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
2580
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2581
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2582
+
2583
+
2584
+
2585
+
2586
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2587
+
2588
+
2589
+
2590
+
2591
+
2592
+
2593
+
2594
+
2595
+
2596
+
2597
+
2598
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2599
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2553
2600
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2554
2601
 
2555
2602
 
@@ -2872,6 +2919,24 @@
2872
2919
 
2873
2920
 
2874
2921
 
2922
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
2923
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2924
+
2925
+
2926
+
2927
+
2928
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2929
+
2930
+
2931
+
2932
+
2933
+
2934
+
2935
+
2936
+
2937
+
2938
+
2939
+
2875
2940
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
2876
2941
 
2877
2942
 
@@ -3280,13 +3345,13 @@
3280
3345
 
3281
3346
  </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">
3282
3347
  <xsl:variable name="nodes_preface_">
3283
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3348
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3284
3349
  <node id="{@id}"/>
3285
3350
  </xsl:for-each>
3286
3351
  </xsl:variable>
3287
3352
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
3288
3353
 
3289
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3354
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3290
3355
  <xsl:sort select="@displayorder" data-type="number"/>
3291
3356
 
3292
3357
  <!-- process Section's title -->
@@ -3352,7 +3417,7 @@
3352
3417
  </xsl:for-each>
3353
3418
  </figures>
3354
3419
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3355
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3420
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3356
3421
  <xsl:sort select="@displayorder" data-type="number"/>
3357
3422
  <xsl:apply-templates select="."/>
3358
3423
  </xsl:for-each>
@@ -3372,22 +3437,32 @@
3372
3437
  <xsl:sort select="@displayorder" data-type="number"/>
3373
3438
  <xsl:apply-templates select="."/>
3374
3439
  </xsl:for-each>
3375
- </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">
3376
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3377
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3378
- <xsl:call-template name="replace_fo_inline">
3379
- <xsl:with-param name="text" select="$text"/>
3380
- </xsl:call-template>
3381
- </xsl:template><xsl:template name="replace_fo_inline">
3440
+ </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">
3441
+
3442
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3443
+ <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))"/>
3444
+ <xsl:call-template name="replace_fo_inline_tags">
3445
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3446
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3447
+ <xsl:with-param name="text" select="$text"/>
3448
+ </xsl:call-template>
3449
+
3450
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3451
+ <xsl:param name="tag_open"/>
3452
+ <xsl:param name="tag_close"/>
3382
3453
  <xsl:param name="text"/>
3383
3454
  <xsl:choose>
3384
3455
  <xsl:when test="contains($text, $tag_open)">
3385
3456
  <xsl:value-of select="substring-before($text, $tag_open)"/>
3386
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3457
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3387
3458
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3388
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3389
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3390
- <xsl:call-template name="replace_fo_inline">
3459
+ <fo:inline keep-together.within-line="always">
3460
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3461
+ </fo:inline>
3462
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3463
+ <xsl:call-template name="replace_fo_inline_tags">
3464
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3465
+ <xsl:with-param name="tag_close" select="$tag_close"/>
3391
3466
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3392
3467
  </xsl:call-template>
3393
3468
  </xsl:when>
@@ -3395,6 +3470,39 @@
3395
3470
  </xsl:choose>
3396
3471
  </xsl:template><xsl:template match="*[local-name()='br']">
3397
3472
  <xsl:value-of select="$linebreak"/>
3473
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3474
+ <xsl:param name="split_keep-within-line"/>
3475
+
3476
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3477
+ <xsl:choose>
3478
+
3479
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3480
+ <xsl:variable name="sep">_</xsl:variable>
3481
+ <xsl:variable name="items">
3482
+ <xsl:call-template name="split">
3483
+ <xsl:with-param name="pText" select="."/>
3484
+ <xsl:with-param name="sep" select="$sep"/>
3485
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3486
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3487
+ </xsl:call-template>
3488
+ </xsl:variable>
3489
+ <xsl:for-each select="xalan:nodeset($items)/item">
3490
+ <xsl:choose>
3491
+ <xsl:when test=". = $sep">
3492
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3493
+ </xsl:when>
3494
+ <xsl:otherwise>
3495
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3496
+ </xsl:otherwise>
3497
+ </xsl:choose>
3498
+ </xsl:for-each>
3499
+ </xsl:when>
3500
+
3501
+ <xsl:otherwise>
3502
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3503
+ </xsl:otherwise>
3504
+
3505
+ </xsl:choose>
3398
3506
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3399
3507
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3400
3508
  <xsl:apply-templates/>
@@ -3463,8 +3571,23 @@
3463
3571
  </fo:block>
3464
3572
 
3465
3573
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3466
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3467
- <xsl:call-template name="add-zero-spaces-java"/>
3574
+ <xsl:choose>
3575
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3576
+ <xsl:value-of select="."/>
3577
+ </xsl:when>
3578
+ <xsl:otherwise>
3579
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3580
+ </xsl:otherwise>
3581
+ </xsl:choose>
3582
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3583
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3584
+ <!-- <xsl:copy-of select="$text"/> -->
3585
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3586
+ <xsl:choose>
3587
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3588
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3589
+ </xsl:choose>
3590
+ </xsl:for-each>
3468
3591
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3469
3592
 
3470
3593
  <xsl:variable name="table-preamble">
@@ -3474,9 +3597,14 @@
3474
3597
 
3475
3598
  <xsl:variable name="table">
3476
3599
 
3477
- <xsl:variable name="simple-table">
3478
- <xsl:call-template name="getSimpleTable"/>
3600
+ <xsl:variable name="simple-table">
3601
+ <xsl:call-template name="getSimpleTable">
3602
+ <xsl:with-param name="id" select="@id"/>
3603
+ </xsl:call-template>
3479
3604
  </xsl:variable>
3605
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3606
+
3607
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3480
3608
 
3481
3609
 
3482
3610
  <!-- Display table's name before table as standalone block -->
@@ -3499,7 +3627,23 @@
3499
3627
  </xsl:call-template>
3500
3628
  </xsl:if>
3501
3629
  </xsl:variable>
3502
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3630
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3631
+
3632
+ <!-- DEBUG -->
3633
+ <xsl:if test="$table_if_debug = 'true'">
3634
+ <fo:block font-size="60%">
3635
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3636
+ </fo:block>
3637
+ </xsl:if>
3638
+
3639
+
3640
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3641
+
3642
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3643
+ DEBUG
3644
+ colwidths=<xsl:copy-of select="$colwidths"/>
3645
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3646
+
3503
3647
 
3504
3648
 
3505
3649
  <xsl:variable name="margin-side">
@@ -3570,9 +3714,17 @@
3570
3714
  </xsl:element>
3571
3715
  </xsl:variable>
3572
3716
 
3717
+ <xsl:if test="$isGenerateTableIF = 'true'">
3718
+ <!-- to determine start of table -->
3719
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3720
+ </xsl:if>
3573
3721
 
3574
3722
  <fo:table id="{@id}">
3575
3723
 
3724
+ <xsl:if test="$isGenerateTableIF = 'true'">
3725
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3726
+ </xsl:if>
3727
+
3576
3728
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3577
3729
  <xsl:attribute name="{local-name()}">
3578
3730
  <xsl:value-of select="."/>
@@ -3586,31 +3738,47 @@
3586
3738
 
3587
3739
 
3588
3740
  <xsl:choose>
3589
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3590
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3591
- <fo:table-column column-width="{@width}"/>
3592
- </xsl:for-each>
3741
+ <xsl:when test="$isGenerateTableIF = 'true'">
3742
+ <!-- generate IF for table widths -->
3743
+ <!-- example:
3744
+ <tr>
3745
+ <td valign="top" align="left" id="tab-symdu_1_1">
3746
+ <p>Symbol</p>
3747
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3748
+ </td>
3749
+ <td valign="top" align="left" id="tab-symdu_1_2">
3750
+ <p>Description</p>
3751
+ <word id="tab-symdu_1_2_word_1">Description</word>
3752
+ </td>
3753
+ </tr>
3754
+ -->
3755
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3756
+
3593
3757
  </xsl:when>
3594
3758
  <xsl:otherwise>
3595
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3596
- <xsl:choose>
3597
- <xsl:when test=". = 1 or . = 0">
3598
- <fo:table-column column-width="proportional-column-width(2)"/>
3599
- </xsl:when>
3600
- <xsl:otherwise>
3601
- <fo:table-column column-width="proportional-column-width({.})"/>
3602
- </xsl:otherwise>
3603
- </xsl:choose>
3604
- </xsl:for-each>
3605
- </xsl:otherwise>
3606
- </xsl:choose>
3607
3759
 
3608
- <xsl:choose>
3609
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3610
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3611
- </xsl:when>
3612
- <xsl:otherwise>
3613
- <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 -->
3760
+ <xsl:choose>
3761
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3762
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3763
+ <fo:table-column column-width="{@width}"/>
3764
+ </xsl:for-each>
3765
+ </xsl:when>
3766
+ <xsl:otherwise>
3767
+ <xsl:call-template name="insertTableColumnWidth">
3768
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3769
+ </xsl:call-template>
3770
+ </xsl:otherwise>
3771
+ </xsl:choose>
3772
+
3773
+ <xsl:choose>
3774
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3775
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3776
+ </xsl:when>
3777
+ <xsl:otherwise>
3778
+ <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 -->
3779
+ </xsl:otherwise>
3780
+ </xsl:choose>
3781
+
3614
3782
  </xsl:otherwise>
3615
3783
  </xsl:choose>
3616
3784
 
@@ -3713,11 +3881,22 @@
3713
3881
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3714
3882
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3715
3883
  </xsl:template><xsl:template name="calculate-column-widths">
3884
+ <xsl:param name="table"/>
3885
+ <xsl:param name="cols-count"/>
3886
+
3887
+ <xsl:call-template name="calculate-column-widths-proportional">
3888
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3889
+ <xsl:with-param name="table" select="$table"/>
3890
+ </xsl:call-template>
3891
+
3892
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3716
3893
  <xsl:param name="table"/>
3717
3894
  <xsl:param name="cols-count"/>
3718
3895
  <xsl:param name="curr-col" select="1"/>
3719
3896
  <xsl:param name="width" select="0"/>
3720
3897
 
3898
+ <!-- table=<xsl:copy-of select="$table"/> -->
3899
+
3721
3900
  <xsl:if test="$curr-col &lt;= $cols-count">
3722
3901
  <xsl:variable name="widths">
3723
3902
  <xsl:choose>
@@ -3755,16 +3934,22 @@
3755
3934
  </xsl:for-each>
3756
3935
  </xsl:when>
3757
3936
  <xsl:otherwise>
3758
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3937
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3938
+
3939
+ <!-- <table><xsl:copy-of select="$table"/></table>
3940
+ -->
3941
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3759
3942
  <xsl:variable name="td_text">
3760
3943
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3761
3944
  </xsl:variable>
3945
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3762
3946
  <xsl:variable name="words">
3763
3947
  <xsl:variable name="string_with_added_zerospaces">
3764
3948
  <xsl:call-template name="add-zero-spaces-java">
3765
3949
  <xsl:with-param name="text" select="$td_text"/>
3766
3950
  </xsl:call-template>
3767
3951
  </xsl:variable>
3952
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3768
3953
  <xsl:call-template name="tokenize">
3769
3954
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3770
3955
  <!-- 2009 thinspace -->
@@ -3772,11 +3957,13 @@
3772
3957
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3773
3958
  </xsl:call-template>
3774
3959
  </xsl:variable>
3960
+ <!-- words=<xsl:copy-of select="$words"/> -->
3775
3961
  <xsl:variable name="max_length">
3776
3962
  <xsl:call-template name="max_length">
3777
3963
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3778
3964
  </xsl:call-template>
3779
3965
  </xsl:variable>
3966
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3780
3967
  <width>
3781
3968
  <xsl:variable name="divider">
3782
3969
  <xsl:choose>
@@ -3795,6 +3982,8 @@
3795
3982
  </xsl:choose>
3796
3983
  </xsl:variable>
3797
3984
 
3985
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3986
+
3798
3987
  <column>
3799
3988
  <xsl:for-each select="xalan:nodeset($widths)//width">
3800
3989
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3803,29 +3992,271 @@
3803
3992
  </xsl:if>
3804
3993
  </xsl:for-each>
3805
3994
  </column>
3806
- <xsl:call-template name="calculate-column-widths">
3995
+ <xsl:call-template name="calculate-column-widths-proportional">
3807
3996
  <xsl:with-param name="cols-count" select="$cols-count"/>
3808
3997
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3809
3998
  <xsl:with-param name="table" select="$table"/>
3810
3999
  </xsl:call-template>
3811
4000
  </xsl:if>
4001
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
4002
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
4003
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
4004
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
4005
+
4006
+ <!-- if all capitals english letters or digits -->
4007
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
4008
+ <xsl:call-template name="repeat">
4009
+ <xsl:with-param name="char" select="'X'"/>
4010
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
4011
+ </xsl:call-template>
4012
+ </xsl:if>
3812
4013
  </xsl:template><xsl:template match="text()" mode="td_text">
3813
4014
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3814
4015
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3815
4016
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3816
4017
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3817
4018
  <xsl:value-of select="@target"/>
3818
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3819
- <xsl:variable name="mathml">
3820
- <xsl:for-each select="*">
3821
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3822
- <xsl:copy-of select="."/>
3823
- </xsl:if>
4019
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
4020
+ <xsl:if test="$isGenerateTableIF = 'false'">
4021
+ <xsl:variable name="mathml_">
4022
+ <xsl:for-each select="*">
4023
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
4024
+ <xsl:copy-of select="."/>
4025
+ </xsl:if>
4026
+ </xsl:for-each>
4027
+ </xsl:variable>
4028
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
4029
+
4030
+ <xsl:variable name="math_text">
4031
+ <xsl:value-of select="normalize-space($mathml)"/>
4032
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
4033
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
4034
+ </xsl:variable>
4035
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4036
+ </xsl:if>
4037
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
4038
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
4039
+
4040
+ <!-- via intermediate format -->
4041
+
4042
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
4043
+
4044
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
4045
+
4046
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
4047
+
4048
+ <!-- get current table id -->
4049
+ <xsl:variable name="table_id" select="@id"/>
4050
+ <!-- find table by id in the file 'table_widths' -->
4051
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
4052
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
4053
+
4054
+ <!-- table='<xsl:copy-of select="$table"/>' -->
4055
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
4056
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
4057
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
4058
+
4059
+ <xsl:variable name="table_with_cell_widths_">
4060
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
4061
+ </xsl:variable>
4062
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
4063
+
4064
+ <!-- <xsl:if test="$table_if_debug = 'true'">
4065
+ <xsl:copy-of select="$table_with_cell_widths"/>
4066
+ </xsl:if> -->
4067
+
4068
+
4069
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
4070
+
4071
+ <xsl:variable name="column_widths_">
4072
+ <!-- iteration of columns -->
4073
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
4074
+ <xsl:variable name="pos" select="position()"/>
4075
+ <column>
4076
+ <xsl:attribute name="width_max">
4077
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
4078
+ <xsl:sort select="." data-type="number" order="descending"/>
4079
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4080
+ </xsl:for-each>
4081
+ </xsl:attribute>
4082
+ <xsl:attribute name="width_min">
4083
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
4084
+ <xsl:sort select="." data-type="number" order="descending"/>
4085
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4086
+ </xsl:for-each>
4087
+ </xsl:attribute>
4088
+ </column>
3824
4089
  </xsl:for-each>
3825
4090
  </xsl:variable>
4091
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
4092
+
4093
+ <!-- <column_widths>
4094
+ <xsl:copy-of select="$column_widths"/>
4095
+ </column_widths> -->
4096
+
4097
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
4098
+ <xsl:variable name="table_widths_">
4099
+ <table>
4100
+ <xsl:attribute name="width_max">
4101
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
4102
+ </xsl:attribute>
4103
+ <xsl:attribute name="width_min">
4104
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
4105
+ </xsl:attribute>
4106
+ </table>
4107
+ </xsl:variable>
4108
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
4109
+
4110
+ <xsl:variable name="page_width">
4111
+ <xsl:choose>
4112
+ <xsl:when test="$parent_table_page-width != ''">
4113
+ <xsl:value-of select="$parent_table_page-width"/>
4114
+ </xsl:when>
4115
+ <xsl:otherwise>
4116
+ <xsl:value-of select="@page-width"/>
4117
+ </xsl:otherwise>
4118
+ </xsl:choose>
4119
+ </xsl:variable>
4120
+
4121
+ <xsl:if test="$table_if_debug = 'true'">
4122
+ <table_width>
4123
+ <xsl:copy-of select="$table_widths"/>
4124
+ </table_width>
4125
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
4126
+ </xsl:if>
4127
+
4128
+
4129
+ <!-- There are three cases: -->
4130
+ <xsl:choose>
4131
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
4132
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
4133
+ <!-- call old algorithm -->
4134
+ <case1/>
4135
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
4136
+ <xsl:call-template name="calculate-column-widths-proportional">
4137
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4138
+ <xsl:with-param name="table" select="$table"/>
4139
+ </xsl:call-template> -->
4140
+ </xsl:when>
4141
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
4142
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
4143
+ <case2/>
4144
+ <autolayout/>
4145
+ <xsl:for-each select="$column_widths/column/@width_max">
4146
+ <column divider="100"><xsl:value-of select="."/></column>
4147
+ </xsl:for-each>
4148
+ </xsl:when>
4149
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
4150
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
4151
+ Lets also call D the difference between maximum and minimum width of the table.
4152
+ For each column, let d be the difference between maximum and minimum width of that column.
4153
+ Now set the column's width to the minimum width plus d times W over D.
4154
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
4155
+ <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)">
4156
+ <!-- difference between the available space and the minimum table width -->
4157
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
4158
+ <W><xsl:value-of select="$W"/></W>
4159
+ <!-- difference between maximum and minimum width of the table -->
4160
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
4161
+ <D><xsl:value-of select="$D"/></D>
4162
+ <case3/>
4163
+ <autolayout/>
4164
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
4165
+ <split_keep-within-line>true</split_keep-within-line>
4166
+ </xsl:if>
4167
+ <xsl:for-each select="$column_widths/column">
4168
+ <!-- difference between maximum and minimum width of that column. -->
4169
+ <xsl:variable name="d" select="@width_max - @width_min"/>
4170
+ <d><xsl:value-of select="$d"/></d>
4171
+ <width_min><xsl:value-of select="@width_min"/></width_min>
4172
+ <e><xsl:value-of select="$d * $W div $D"/></e>
4173
+ <!-- set the column's width to the minimum width plus d times W over D. -->
4174
+ <column divider="100">
4175
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4176
+ </column>
4177
+ </xsl:for-each>
4178
+
4179
+ </xsl:when>
4180
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
4181
+ </xsl:choose>
4182
+
4183
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
4184
+
4185
+ <!-- if nested 'dl' or 'table' -->
4186
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
4187
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
4188
+
4189
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
4190
+
4191
+ <xsl:variable name="parent_table_page-width_">
4192
+ <xsl:if test="$parent_table_id != ''">
4193
+ <!-- determine column number in the parent table -->
4194
+ <xsl:variable name="parent_table_column_number">
4195
+ <xsl:choose>
4196
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
4197
+ <xsl:otherwise> <!-- parent is table -->
4198
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
4199
+ </xsl:otherwise>
4200
+ </xsl:choose>
4201
+ </xsl:variable>
4202
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
4203
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
4204
+ </xsl:if>
4205
+ </xsl:variable>
4206
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
4207
+
4208
+ <!-- get current table id -->
4209
+ <xsl:variable name="table_id" select="@id"/>
4210
+
4211
+ <xsl:choose>
4212
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
4213
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
4214
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
4215
+ </xsl:when>
4216
+ <xsl:otherwise>
4217
+ <!-- recalculate columns width based on parent table width -->
4218
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
4219
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
4220
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
4221
+ </xsl:call-template>
4222
+ </xsl:for-each>
4223
+ </xsl:otherwise>
4224
+ </xsl:choose>
3826
4225
 
3827
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3828
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4226
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
4227
+ <xsl:copy>
4228
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
4229
+ </xsl:copy>
4230
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
4231
+ <xsl:copy>
4232
+ <xsl:copy-of select="@*"/>
4233
+
4234
+ <!-- The maximum width is given by the widest line. -->
4235
+ <xsl:attribute name="width_max">
4236
+ <xsl:for-each select="p_len">
4237
+ <xsl:sort select="." data-type="number" order="descending"/>
4238
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4239
+ </xsl:for-each>
4240
+ </xsl:attribute>
4241
+
4242
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4243
+ <xsl:variable name="width_min">
4244
+ <xsl:for-each select="word_len">
4245
+ <xsl:sort select="." data-type="number" order="descending"/>
4246
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4247
+ </xsl:for-each>
4248
+ </xsl:variable>
4249
+ <xsl:attribute name="width_min">
4250
+ <xsl:value-of select="$width_min"/>
4251
+ </xsl:attribute>
4252
+
4253
+ <xsl:if test="$width_min = 0">
4254
+ <xsl:attribute name="width_min">1</xsl:attribute>
4255
+ </xsl:if>
4256
+
4257
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
4258
+
4259
+ </xsl:copy>
3829
4260
  </xsl:template><xsl:template match="*[local-name()='thead']">
3830
4261
  <xsl:param name="cols-count"/>
3831
4262
  <fo:table-header>
@@ -3910,16 +4341,10 @@
3910
4341
  </xsl:for-each>
3911
4342
  </xsl:when>
3912
4343
  <xsl:otherwise>
3913
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3914
- <xsl:choose>
3915
- <xsl:when test=". = 1 or . = 0">
3916
- <fo:table-column column-width="proportional-column-width(2)"/>
3917
- </xsl:when>
3918
- <xsl:otherwise>
3919
- <fo:table-column column-width="proportional-column-width({.})"/>
3920
- </xsl:otherwise>
3921
- </xsl:choose>
3922
- </xsl:for-each>
4344
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
4345
+ <xsl:call-template name="insertTableColumnWidth">
4346
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4347
+ </xsl:call-template>
3923
4348
  </xsl:otherwise>
3924
4349
  </xsl:choose>
3925
4350
 
@@ -4006,17 +4431,63 @@
4006
4431
 
4007
4432
  </fo:table-body>
4008
4433
 
4009
- </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4010
- <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4434
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4435
+ <xsl:param name="table_or_dl">table</xsl:param>
4436
+ <xsl:apply-templates mode="process_table-if">
4437
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4438
+ </xsl:apply-templates>
4439
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4440
+ <xsl:param name="table_or_dl">table</xsl:param>
4011
4441
 
4012
-
4013
-
4014
-
4442
+ <fo:table-body>
4443
+ <xsl:for-each select="*[local-name() = 'tr']">
4444
+ <xsl:variable name="col_count" select="count(*)"/>
4015
4445
 
4446
+ <!-- iteration for each tr/td -->
4447
+
4448
+ <xsl:choose>
4449
+ <xsl:when test="$table_or_dl = 'table'">
4450
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4451
+ <fo:table-row number-columns-spanned="{$col_count}">
4452
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4453
+ <xsl:call-template name="td"/>
4454
+ </fo:table-row>
4455
+ </xsl:for-each>
4456
+ </xsl:when>
4457
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4458
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4459
+ <xsl:variable name="is_dt" select="position() = 1"/>
4460
+
4461
+ <xsl:for-each select="*">
4462
+ <!-- <test><xsl:copy-of select="."/></test> -->
4463
+ <fo:table-row number-columns-spanned="{$col_count}">
4464
+ <xsl:choose>
4465
+ <xsl:when test="$is_dt">
4466
+ <xsl:call-template name="insert_dt_cell"/>
4467
+ </xsl:when>
4468
+ <xsl:otherwise>
4469
+ <xsl:call-template name="insert_dd_cell"/>
4470
+ </xsl:otherwise>
4471
+ </xsl:choose>
4472
+ </fo:table-row>
4473
+ </xsl:for-each>
4474
+ </xsl:for-each>
4475
+ </xsl:otherwise>
4476
+ </xsl:choose>
4477
+
4478
+ </xsl:for-each>
4479
+ </fo:table-body>
4480
+ </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4481
+ <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4482
+
4483
+
4484
+
4485
+
4486
+
4487
+
4488
+
4489
+ <xsl:call-template name="setTableRowAttributes"/>
4016
4490
 
4017
-
4018
- <xsl:call-template name="setTableRowAttributes"/>
4019
-
4020
4491
  <xsl:apply-templates/>
4021
4492
  </fo:table-row>
4022
4493
  </xsl:template><xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
@@ -4097,7 +4568,7 @@
4097
4568
  </xsl:choose>
4098
4569
  </xsl:attribute>
4099
4570
  </xsl:if>
4100
- </xsl:template><xsl:template match="*[local-name()='td']">
4571
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
4101
4572
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
4102
4573
  <xsl:call-template name="setTextAlignment">
4103
4574
  <xsl:with-param name="default">left</xsl:with-param>
@@ -4135,11 +4606,24 @@
4135
4606
 
4136
4607
  <xsl:call-template name="setTableCellAttributes"/>
4137
4608
 
4609
+ <xsl:if test="$isGenerateTableIF = 'true'">
4610
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4611
+ <xsl:attribute name="text-align">left</xsl:attribute>
4612
+ </xsl:if>
4613
+
4138
4614
  <fo:block>
4139
4615
 
4616
+ <xsl:if test="$isGenerateTableIF = 'true'">
4617
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4618
+ </xsl:if>
4619
+
4620
+
4140
4621
 
4141
4622
 
4142
4623
  <xsl:apply-templates/>
4624
+
4625
+ <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"/> -->
4626
+
4143
4627
  </fo:block>
4144
4628
  </fo:table-cell>
4145
4629
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -4336,9 +4820,9 @@
4336
4820
  <!-- current hierarchy is 'figure' element -->
4337
4821
  <xsl:variable name="following_dl_colwidths">
4338
4822
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4339
- <xsl:variable name="html-table">
4340
- <xsl:variable name="doc_ns">
4341
-
4823
+ <xsl:variable name="simple-table">
4824
+ <!-- <xsl:variable name="doc_ns">
4825
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4342
4826
  </xsl:variable>
4343
4827
  <xsl:variable name="ns">
4344
4828
  <xsl:choose>
@@ -4349,7 +4833,7 @@
4349
4833
  <xsl:value-of select="substring-before(name(/*), '-')"/>
4350
4834
  </xsl:otherwise>
4351
4835
  </xsl:choose>
4352
- </xsl:variable>
4836
+ </xsl:variable> -->
4353
4837
 
4354
4838
  <xsl:for-each select="*[local-name() = 'dl'][1]">
4355
4839
  <tbody>
@@ -4360,7 +4844,7 @@
4360
4844
 
4361
4845
  <xsl:call-template name="calculate-column-widths">
4362
4846
  <xsl:with-param name="cols-count" select="2"/>
4363
- <xsl:with-param name="table" select="$html-table"/>
4847
+ <xsl:with-param name="table" select="$simple-table"/>
4364
4848
  </xsl:call-template>
4365
4849
 
4366
4850
  </xsl:if>
@@ -4486,8 +4970,10 @@
4486
4970
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4487
4971
  </xsl:variable>
4488
4972
 
4973
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
4974
+
4489
4975
  <xsl:choose>
4490
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
4976
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4491
4977
 
4492
4978
  <fo:block text-align="left">
4493
4979
 
@@ -4509,7 +4995,7 @@
4509
4995
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4510
4996
  </fo:block>
4511
4997
 
4512
- </xsl:when>
4998
+ </xsl:when> <!-- END: only one component -->
4513
4999
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4514
5000
  <fo:block margin-bottom="12pt" text-align="left">
4515
5001
 
@@ -4525,8 +5011,8 @@
4525
5011
  </xsl:variable>
4526
5012
  <xsl:value-of select="$title-where"/>
4527
5013
  </fo:block>
4528
- </xsl:when>
4529
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
5014
+ </xsl:when> <!-- END: a few components -->
5015
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4530
5016
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4531
5017
 
4532
5018
 
@@ -4542,22 +5028,41 @@
4542
5028
  </xsl:variable>
4543
5029
  <xsl:value-of select="$title-key"/>
4544
5030
  </fo:block>
4545
- </xsl:when>
5031
+ </xsl:when> <!-- END: definition list in a figure -->
4546
5032
  </xsl:choose>
4547
5033
 
4548
5034
  <!-- a few components -->
4549
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
5035
+ <xsl:if test="$onlyOneComponent = 'false'">
4550
5036
  <fo:block>
4551
5037
 
4552
5038
 
4553
5039
 
4554
5040
 
5041
+
5042
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
5043
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5044
+ </xsl:if>
5045
+
4555
5046
  <fo:block>
4556
5047
 
4557
5048
 
4558
5049
 
4559
5050
 
5051
+ <xsl:apply-templates select="*[local-name() = 'name']">
5052
+ <xsl:with-param name="process">true</xsl:with-param>
5053
+ </xsl:apply-templates>
5054
+
5055
+ <xsl:if test="$isGenerateTableIF = 'true'">
5056
+ <!-- to determine start of table -->
5057
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
5058
+ </xsl:if>
5059
+
4560
5060
  <fo:table width="95%" table-layout="fixed">
5061
+
5062
+ <xsl:if test="$isGenerateTableIF = 'true'">
5063
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
5064
+ </xsl:if>
5065
+
4561
5066
 
4562
5067
  <xsl:choose>
4563
5068
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4568,61 +5073,178 @@
4568
5073
 
4569
5074
  </xsl:when>
4570
5075
  </xsl:choose>
4571
- <!-- create virtual html table for dl/[dt and dd] -->
4572
- <xsl:variable name="html-table">
4573
- <xsl:variable name="doc_ns">
5076
+
5077
+
5078
+
5079
+ <xsl:choose>
5080
+ <xsl:when test="$isGenerateTableIF = 'true'">
5081
+ <!-- generate IF for table widths -->
5082
+ <!-- example:
5083
+ <tr>
5084
+ <td valign="top" align="left" id="tab-symdu_1_1">
5085
+ <p>Symbol</p>
5086
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
5087
+ </td>
5088
+ <td valign="top" align="left" id="tab-symdu_1_2">
5089
+ <p>Description</p>
5090
+ <word id="tab-symdu_1_2_word_1">Description</word>
5091
+ </td>
5092
+ </tr>
5093
+ -->
4574
5094
 
4575
- </xsl:variable>
4576
- <xsl:variable name="ns">
4577
- <xsl:choose>
4578
- <xsl:when test="normalize-space($doc_ns) != ''">
4579
- <xsl:value-of select="normalize-space($doc_ns)"/>
4580
- </xsl:when>
4581
- <xsl:otherwise>
4582
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4583
- </xsl:otherwise>
4584
- </xsl:choose>
4585
- </xsl:variable>
4586
- <tbody>
4587
- <xsl:apply-templates mode="dl"/>
4588
- </tbody>
4589
- </xsl:variable>
4590
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4591
- <xsl:variable name="colwidths">
4592
- <xsl:call-template name="calculate-column-widths">
4593
- <xsl:with-param name="cols-count" select="2"/>
4594
- <xsl:with-param name="table" select="$html-table"/>
4595
- </xsl:call-template>
4596
- </xsl:variable>
4597
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4598
- <xsl:variable name="maxlength_dt">
4599
- <xsl:call-template name="getMaxLength_dt"/>
4600
- </xsl:variable>
4601
- <xsl:call-template name="setColumnWidth_dl">
4602
- <xsl:with-param name="colwidths" select="$colwidths"/>
4603
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4604
- </xsl:call-template>
4605
- <fo:table-body>
4606
- <xsl:apply-templates>
4607
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4608
- </xsl:apply-templates>
4609
- </fo:table-body>
5095
+ <!-- create virtual html table for dl/[dt and dd] -->
5096
+ <xsl:variable name="simple-table">
5097
+
5098
+ <xsl:variable name="dl_table">
5099
+ <tbody>
5100
+ <xsl:apply-templates mode="dl_if">
5101
+ <xsl:with-param name="id" select="@id"/>
5102
+ </xsl:apply-templates>
5103
+ </tbody>
5104
+ </xsl:variable>
5105
+
5106
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
5107
+
5108
+ <!-- Step: replace <br/> to <p>...</p> -->
5109
+ <xsl:variable name="table_without_br">
5110
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
5111
+ </xsl:variable>
5112
+
5113
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
5114
+
5115
+ <!-- Step: add id to each cell -->
5116
+ <!-- add <word>...</word> for each word, image, math -->
5117
+ <xsl:variable name="simple-table-id">
5118
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
5119
+ <xsl:with-param name="id" select="@id"/>
5120
+ </xsl:apply-templates>
5121
+ </xsl:variable>
5122
+
5123
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
5124
+
5125
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5126
+
5127
+ </xsl:variable>
5128
+
5129
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
5130
+
5131
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
5132
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
5133
+ </xsl:apply-templates>
5134
+
5135
+ </xsl:when>
5136
+ <xsl:otherwise>
5137
+
5138
+ <xsl:variable name="simple-table">
5139
+
5140
+ <xsl:variable name="dl_table">
5141
+ <tbody>
5142
+ <xsl:apply-templates mode="dl">
5143
+ <xsl:with-param name="id" select="@id"/>
5144
+ </xsl:apply-templates>
5145
+ </tbody>
5146
+ </xsl:variable>
5147
+
5148
+ <xsl:copy-of select="$dl_table"/>
5149
+ </xsl:variable>
5150
+
5151
+ <xsl:variable name="colwidths">
5152
+ <xsl:call-template name="calculate-column-widths">
5153
+ <xsl:with-param name="cols-count" select="2"/>
5154
+ <xsl:with-param name="table" select="$simple-table"/>
5155
+ </xsl:call-template>
5156
+ </xsl:variable>
5157
+
5158
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
5159
+ DEBUG
5160
+ colwidths=<xsl:copy-of select="$colwidths"/>
5161
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
5162
+
5163
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
5164
+
5165
+ <xsl:variable name="maxlength_dt">
5166
+ <xsl:call-template name="getMaxLength_dt"/>
5167
+ </xsl:variable>
5168
+
5169
+ <xsl:variable name="isContainsKeepTogetherTag_">
5170
+ false
5171
+ </xsl:variable>
5172
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
5173
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
5174
+
5175
+
5176
+ <xsl:call-template name="setColumnWidth_dl">
5177
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5178
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5179
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
5180
+ </xsl:call-template>
5181
+
5182
+ <fo:table-body>
5183
+
5184
+ <!-- DEBUG -->
5185
+ <xsl:if test="$table_if_debug = 'true'">
5186
+ <fo:table-row>
5187
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
5188
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5189
+ </fo:table-cell>
5190
+ </fo:table-row>
5191
+ </xsl:if>
5192
+
5193
+ <xsl:apply-templates>
5194
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
5195
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
5196
+ </xsl:apply-templates>
5197
+
5198
+ </fo:table-body>
5199
+ </xsl:otherwise>
5200
+ </xsl:choose>
4610
5201
  </fo:table>
4611
5202
  </fo:block>
4612
5203
  </fo:block>
4613
- </xsl:if>
5204
+ </xsl:if> <!-- END: a few components -->
4614
5205
  </fo:block-container>
4615
5206
  </fo:block-container>
5207
+
5208
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
5209
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
5210
+ </xsl:if>
5211
+
5212
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
5213
+ <xsl:param name="process">false</xsl:param>
5214
+ <xsl:if test="$process = 'true'">
5215
+ <fo:block xsl:use-attribute-sets="dl-name-style">
5216
+ <xsl:apply-templates/>
5217
+ </fo:block>
5218
+ </xsl:if>
4616
5219
  </xsl:template><xsl:template name="setColumnWidth_dl">
4617
5220
  <xsl:param name="colwidths"/>
4618
5221
  <xsl:param name="maxlength_dt"/>
5222
+ <xsl:param name="isContainsKeepTogetherTag"/>
5223
+
5224
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
5225
+
4619
5226
  <xsl:choose>
5227
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5228
+ <xsl:call-template name="insertTableColumnWidth">
5229
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5230
+ </xsl:call-template>
5231
+ </xsl:when>
4620
5232
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4621
5233
  <fo:table-column column-width="50%"/>
4622
5234
  <fo:table-column column-width="50%"/>
4623
5235
  </xsl:when>
4624
5236
  <xsl:otherwise>
4625
5237
  <xsl:choose>
5238
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5239
+ <xsl:call-template name="insertTableColumnWidth">
5240
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5241
+ </xsl:call-template>
5242
+ </xsl:when>
5243
+ <xsl:when test="$isContainsKeepTogetherTag">
5244
+ <xsl:call-template name="insertTableColumnWidth">
5245
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5246
+ </xsl:call-template>
5247
+ </xsl:when>
4626
5248
  <!-- to set width check most wide chars like `W` -->
4627
5249
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
4628
5250
  <fo:table-column column-width="7%"/>
@@ -4653,20 +5275,31 @@
4653
5275
  <fo:table-column column-width="60%"/>
4654
5276
  </xsl:when>
4655
5277
  <xsl:otherwise>
4656
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
4657
- <xsl:choose>
4658
- <xsl:when test=". = 1 or . = 0">
4659
- <fo:table-column column-width="proportional-column-width(2)"/>
4660
- </xsl:when>
4661
- <xsl:otherwise>
4662
- <fo:table-column column-width="proportional-column-width({.})"/>
4663
- </xsl:otherwise>
4664
- </xsl:choose>
4665
- </xsl:for-each>
5278
+ <xsl:call-template name="insertTableColumnWidth">
5279
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5280
+ </xsl:call-template>
4666
5281
  </xsl:otherwise>
4667
5282
  </xsl:choose>
4668
5283
  </xsl:otherwise>
4669
5284
  </xsl:choose>
5285
+ </xsl:template><xsl:template name="insertTableColumnWidth">
5286
+ <xsl:param name="colwidths"/>
5287
+
5288
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
5289
+ <xsl:choose>
5290
+ <xsl:when test=". = 1 or . = 0">
5291
+ <fo:table-column column-width="proportional-column-width(2)"/>
5292
+ </xsl:when>
5293
+ <xsl:otherwise>
5294
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
5295
+ <xsl:variable name="divider">
5296
+ <xsl:value-of select="@divider"/>
5297
+ <xsl:if test="not(@divider)">1</xsl:if>
5298
+ </xsl:variable>
5299
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
5300
+ </xsl:otherwise>
5301
+ </xsl:choose>
5302
+ </xsl:for-each>
4670
5303
  </xsl:template><xsl:template name="getMaxLength_dt">
4671
5304
  <xsl:variable name="lengths">
4672
5305
  <xsl:for-each select="*[local-name()='dt']">
@@ -4690,7 +5323,6 @@
4690
5323
  <xsl:value-of select="$maxLength"/>
4691
5324
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4692
5325
  <xsl:param name="key_iso"/>
4693
-
4694
5326
  <!-- <tr>
4695
5327
  <td>NOTE</td>
4696
5328
  <td>
@@ -4698,27 +5330,47 @@
4698
5330
  </td>
4699
5331
  </tr>
4700
5332
  -->
4701
- <fo:table-row>
5333
+ <!-- OLD Variant -->
5334
+ <!-- <fo:table-row>
4702
5335
  <fo:table-cell>
4703
5336
  <fo:block margin-top="6pt">
4704
5337
  <xsl:if test="normalize-space($key_iso) = 'true'">
4705
5338
  <xsl:attribute name="margin-top">0</xsl:attribute>
4706
5339
  </xsl:if>
4707
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5340
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4708
5341
  </fo:block>
4709
5342
  </fo:table-cell>
4710
5343
  <fo:table-cell>
4711
5344
  <fo:block>
4712
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5345
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
5346
+ </fo:block>
5347
+ </fo:table-cell>
5348
+ </fo:table-row> -->
5349
+ <!-- <tr>
5350
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
5351
+ </tr>
5352
+ -->
5353
+ <fo:table-row>
5354
+ <fo:table-cell number-columns-spanned="2">
5355
+ <fo:block>
5356
+ <xsl:call-template name="note"/>
4713
5357
  </fo:block>
4714
5358
  </fo:table-cell>
4715
5359
  </fo:table-row>
4716
5360
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
5361
+ <xsl:param name="id"/>
5362
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4717
5363
  <tr>
4718
5364
  <td>
5365
+ <xsl:attribute name="id">
5366
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5367
+ </xsl:attribute>
4719
5368
  <xsl:apply-templates/>
4720
5369
  </td>
4721
5370
  <td>
5371
+ <xsl:attribute name="id">
5372
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5373
+ </xsl:attribute>
4722
5374
 
4723
5375
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4724
5376
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4729,50 +5381,134 @@
4729
5381
 
4730
5382
  </xsl:template><xsl:template match="*[local-name()='dt']">
4731
5383
  <xsl:param name="key_iso"/>
5384
+ <xsl:param name="split_keep-within-line"/>
4732
5385
 
4733
5386
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4734
- <fo:table-cell>
5387
+ <xsl:call-template name="insert_dt_cell">
5388
+ <xsl:with-param name="key_iso" select="$key_iso"/>
5389
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5390
+ </xsl:call-template>
5391
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
5392
+ <xsl:call-template name="insert_dd_cell">
5393
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5394
+ </xsl:call-template>
5395
+ </xsl:for-each>
5396
+ </fo:table-row>
5397
+ </xsl:template><xsl:template name="insert_dt_cell">
5398
+ <xsl:param name="key_iso"/>
5399
+ <xsl:param name="split_keep-within-line"/>
5400
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
5401
+
5402
+ <xsl:if test="$isGenerateTableIF = 'true'">
5403
+ <!-- border is mandatory, to calculate real width -->
5404
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5405
+ <xsl:attribute name="text-align">left</xsl:attribute>
5406
+ </xsl:if>
5407
+
5408
+
5409
+ <fo:block xsl:use-attribute-sets="dt-block-style">
5410
+ <xsl:copy-of select="@id"/>
5411
+
5412
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5413
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5414
+ </xsl:if>
5415
+
5416
+
5417
+
5418
+ <xsl:apply-templates>
5419
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5420
+ </xsl:apply-templates>
5421
+
5422
+ <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"/> -->
5423
+
5424
+ </fo:block>
5425
+ </fo:table-cell>
5426
+ </xsl:template><xsl:template name="insert_dd_cell">
5427
+ <xsl:param name="split_keep-within-line"/>
5428
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5429
+
5430
+ <xsl:if test="$isGenerateTableIF = 'true'">
5431
+ <!-- border is mandatory, to calculate real width -->
5432
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5433
+ </xsl:if>
5434
+
5435
+ <fo:block>
5436
+
5437
+ <xsl:if test="$isGenerateTableIF = 'true'">
5438
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5439
+ </xsl:if>
5440
+
4735
5441
 
4736
- <fo:block xsl:use-attribute-sets="dt-style">
4737
- <xsl:copy-of select="@id"/>
4738
-
4739
- <xsl:if test="normalize-space($key_iso) = 'true'">
4740
- <xsl:attribute name="margin-top">0</xsl:attribute>
4741
- </xsl:if>
4742
-
4743
-
4744
-
4745
- <xsl:apply-templates/>
4746
- </fo:block>
4747
- </fo:table-cell>
4748
- <fo:table-cell>
4749
- <fo:block>
4750
-
4751
5442
 
4752
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4753
- <xsl:with-param name="process">true</xsl:with-param>
4754
- </xsl:apply-templates>
4755
- </fo:block>
4756
- </fo:table-cell>
4757
- </fo:table-row>
5443
+ <xsl:choose>
5444
+ <xsl:when test="$isGenerateTableIF = 'true'">
5445
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5446
+ <xsl:with-param name="process">true</xsl:with-param>
5447
+ </xsl:apply-templates>
5448
+ </xsl:when>
5449
+ <xsl:otherwise>
5450
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5451
+ <xsl:with-param name="process">true</xsl:with-param>
5452
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5453
+ </xsl:apply-templates>
5454
+ </xsl:otherwise>
5455
+
5456
+ </xsl:choose>
5457
+
5458
+ <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"/> -->
5459
+
5460
+ </fo:block>
5461
+ </fo:table-cell>
4758
5462
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4759
5463
  <xsl:apply-templates/>
4760
5464
  </xsl:template><xsl:template match="*[local-name()='dd']">
4761
5465
  <xsl:param name="process">false</xsl:param>
5466
+ <xsl:param name="split_keep-within-line"/>
4762
5467
  <xsl:if test="$process = 'true'">
4763
5468
  <xsl:apply-templates select="@language"/>
4764
- <xsl:apply-templates/>
5469
+ <xsl:apply-templates>
5470
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5471
+ </xsl:apply-templates>
4765
5472
  </xsl:if>
4766
5473
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4767
5474
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4768
- </xsl:template><xsl:template match="*[local-name()='em']">
5475
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5476
+ <xsl:param name="id"/>
5477
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5478
+ <tr>
5479
+ <td>
5480
+ <xsl:copy-of select="node()"/>
5481
+ </td>
5482
+ <td>
5483
+
5484
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
5485
+
5486
+ <!-- get paragraphs from nested 'dl' -->
5487
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
5488
+
5489
+
5490
+ </td>
5491
+ </tr>
5492
+
5493
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
5494
+ <xsl:for-each select="*[local-name() = 'dt']">
5495
+ <p>
5496
+ <xsl:copy-of select="node()"/>
5497
+ <xsl:text> </xsl:text>
5498
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
5499
+ </p>
5500
+ </xsl:for-each>
5501
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
4769
5502
  <fo:inline font-style="italic">
4770
5503
  <xsl:apply-templates/>
4771
5504
  </fo:inline>
4772
5505
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5506
+ <xsl:param name="split_keep-within-line"/>
4773
5507
  <fo:inline font-weight="bold">
4774
5508
 
4775
- <xsl:apply-templates/>
5509
+ <xsl:apply-templates>
5510
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5511
+ </xsl:apply-templates>
4776
5512
  </fo:inline>
4777
5513
  </xsl:template><xsl:template match="*[local-name()='padding']">
4778
5514
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4793,7 +5529,7 @@
4793
5529
 
4794
5530
  10
4795
5531
 
4796
-
5532
+ <!-- 10 -->
4797
5533
 
4798
5534
 
4799
5535
 
@@ -4811,13 +5547,15 @@
4811
5547
  <xsl:choose>
4812
5548
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4813
5549
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4814
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5550
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4815
5551
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4816
5552
  </xsl:choose>
4817
5553
  </xsl:attribute>
4818
5554
  </xsl:if>
4819
5555
  <xsl:apply-templates/>
4820
5556
  </fo:inline>
5557
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
5558
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4821
5559
  </xsl:template><xsl:template match="*[local-name()='underline']">
4822
5560
  <fo:inline text-decoration="underline">
4823
5561
  <xsl:apply-templates/>
@@ -4965,54 +5703,120 @@
4965
5703
  <fo:block break-after="page"/>
4966
5704
  <fo:block> </fo:block>
4967
5705
  <fo:block break-after="page"/>
5706
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5707
+ <xsl:apply-templates/>
4968
5708
  </xsl:template><xsl:template name="tokenize">
4969
5709
  <xsl:param name="text"/>
4970
5710
  <xsl:param name="separator" select="' '"/>
4971
5711
  <xsl:choose>
5712
+
5713
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5714
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5715
+ </xsl:when>
4972
5716
  <xsl:when test="not(contains($text, $separator))">
4973
5717
  <word>
4974
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4975
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4976
5718
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4977
- <xsl:variable name="len_str">
4978
- <xsl:choose>
4979
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4980
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4981
- </xsl:when>
4982
- <xsl:otherwise>
4983
- <xsl:value-of select="$len_str_tmp"/>
4984
- </xsl:otherwise>
4985
- </xsl:choose>
4986
- </xsl:variable>
4987
-
4988
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4989
- <xsl:message>
4990
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4991
- len_str=<xsl:value-of select="$len_str"/>
4992
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4993
- </xsl:message>
4994
- </xsl:if> -->
4995
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4996
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4997
5719
  <xsl:choose>
4998
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4999
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5720
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5721
+ <xsl:value-of select="$len_str_tmp"/>
5000
5722
  </xsl:when>
5001
5723
  <xsl:otherwise>
5002
- <xsl:value-of select="$len_str"/>
5724
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5725
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5726
+ <xsl:variable name="len_str">
5727
+ <xsl:choose>
5728
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5729
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5730
+ </xsl:when>
5731
+ <xsl:otherwise>
5732
+ <xsl:value-of select="$len_str_tmp"/>
5733
+ </xsl:otherwise>
5734
+ </xsl:choose>
5735
+ </xsl:variable>
5736
+
5737
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5738
+ <xsl:message>
5739
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5740
+ len_str=<xsl:value-of select="$len_str"/>
5741
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5742
+ </xsl:message>
5743
+ </xsl:if> -->
5744
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5745
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5746
+ <xsl:choose>
5747
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5748
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5749
+ </xsl:when>
5750
+ <xsl:otherwise>
5751
+ <xsl:value-of select="$len_str"/>
5752
+ </xsl:otherwise>
5753
+ </xsl:choose>
5003
5754
  </xsl:otherwise>
5004
5755
  </xsl:choose>
5005
5756
  </word>
5006
5757
  </xsl:when>
5007
5758
  <xsl:otherwise>
5008
5759
  <word>
5009
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5760
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5761
+ <xsl:choose>
5762
+ <xsl:when test="$isGenerateTableIF = 'true'">
5763
+ <xsl:value-of select="$word"/>
5764
+ </xsl:when>
5765
+ <xsl:otherwise>
5766
+ <xsl:value-of select="string-length($word)"/>
5767
+ </xsl:otherwise>
5768
+ </xsl:choose>
5010
5769
  </word>
5011
5770
  <xsl:call-template name="tokenize">
5012
5771
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5013
5772
  </xsl:call-template>
5014
5773
  </xsl:otherwise>
5015
5774
  </xsl:choose>
5775
+ </xsl:template><xsl:template name="tokenize_with_tags">
5776
+ <xsl:param name="tags"/>
5777
+ <xsl:param name="text"/>
5778
+ <xsl:param name="separator" select="' '"/>
5779
+ <xsl:choose>
5780
+
5781
+ <xsl:when test="not(contains($text, $separator))">
5782
+ <word>
5783
+ <xsl:call-template name="enclose_text_in_tags">
5784
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5785
+ <xsl:with-param name="tags" select="$tags"/>
5786
+ </xsl:call-template>
5787
+ </word>
5788
+ </xsl:when>
5789
+ <xsl:otherwise>
5790
+ <word>
5791
+ <xsl:call-template name="enclose_text_in_tags">
5792
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5793
+ <xsl:with-param name="tags" select="$tags"/>
5794
+ </xsl:call-template>
5795
+ </word>
5796
+ <xsl:call-template name="tokenize_with_tags">
5797
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5798
+ </xsl:call-template>
5799
+ </xsl:otherwise>
5800
+ </xsl:choose>
5801
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5802
+ <xsl:param name="text"/>
5803
+ <xsl:param name="tags"/>
5804
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5805
+
5806
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5807
+
5808
+ <xsl:choose>
5809
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5810
+ <xsl:otherwise>
5811
+ <xsl:element name="{$tag_name}">
5812
+ <xsl:call-template name="enclose_text_in_tags">
5813
+ <xsl:with-param name="text" select="$text"/>
5814
+ <xsl:with-param name="tags" select="$tags"/>
5815
+ <xsl:with-param name="num" select="$num + 1"/>
5816
+ </xsl:call-template>
5817
+ </xsl:element>
5818
+ </xsl:otherwise>
5819
+ </xsl:choose>
5016
5820
  </xsl:template><xsl:template name="max_length">
5017
5821
  <xsl:param name="words"/>
5018
5822
  <xsl:for-each select="$words//word">
@@ -5113,12 +5917,19 @@
5113
5917
  </xsl:otherwise>
5114
5918
  </xsl:choose>
5115
5919
  </xsl:template><xsl:template name="getSimpleTable">
5920
+ <xsl:param name="id"/>
5921
+
5116
5922
  <xsl:variable name="simple-table">
5117
5923
 
5924
+ <!-- Step 0. replace <br/> to <p>...</p> -->
5925
+ <xsl:variable name="table_without_br">
5926
+ <xsl:apply-templates mode="table-without-br"/>
5927
+ </xsl:variable>
5928
+
5118
5929
  <!-- Step 1. colspan processing -->
5119
5930
  <xsl:variable name="simple-table-colspan">
5120
5931
  <tbody>
5121
- <xsl:apply-templates mode="simple-table-colspan"/>
5932
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
5122
5933
  </tbody>
5123
5934
  </xsl:variable>
5124
5935
 
@@ -5127,10 +5938,67 @@
5127
5938
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
5128
5939
  </xsl:variable>
5129
5940
 
5130
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
5131
-
5941
+ <!-- Step 3: add id to each cell -->
5942
+ <!-- add <word>...</word> for each word, image, math -->
5943
+ <xsl:variable name="simple-table-id">
5944
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
5945
+ <xsl:with-param name="id" select="$id"/>
5946
+ </xsl:apply-templates>
5947
+ </xsl:variable>
5948
+
5949
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5950
+
5132
5951
  </xsl:variable>
5133
5952
  <xsl:copy-of select="$simple-table"/>
5953
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
5954
+ <xsl:copy>
5955
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
5956
+ </xsl:copy>
5957
+ </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">
5958
+ <xsl:copy>
5959
+ <xsl:copy-of select="@*"/>
5960
+ <p>
5961
+ <xsl:copy-of select="node()"/>
5962
+ </p>
5963
+ </xsl:copy>
5964
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
5965
+ <xsl:copy>
5966
+ <xsl:copy-of select="@*"/>
5967
+ <xsl:for-each select="*[local-name()='br']">
5968
+ <xsl:variable name="current_id" select="generate-id()"/>
5969
+ <p>
5970
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5971
+ <xsl:copy-of select="."/>
5972
+ </xsl:for-each>
5973
+ </p>
5974
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5975
+ <p>
5976
+ <xsl:for-each select="following-sibling::node()">
5977
+ <xsl:copy-of select="."/>
5978
+ </xsl:for-each>
5979
+ </p>
5980
+ </xsl:if>
5981
+ </xsl:for-each>
5982
+ </xsl:copy>
5983
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
5984
+ <xsl:for-each select="*[local-name()='br']">
5985
+ <xsl:variable name="current_id" select="generate-id()"/>
5986
+ <p>
5987
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5988
+ <xsl:copy-of select="."/>
5989
+ </xsl:for-each>
5990
+ </p>
5991
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5992
+ <p>
5993
+ <xsl:for-each select="following-sibling::node()">
5994
+ <xsl:copy-of select="."/>
5995
+ </xsl:for-each>
5996
+ </p>
5997
+ </xsl:if>
5998
+ </xsl:for-each>
5999
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
6000
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
6001
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
5134
6002
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
5135
6003
  <xsl:apply-templates mode="simple-table-colspan"/>
5136
6004
  </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">
@@ -5208,18 +6076,138 @@
5208
6076
  </xsl:choose>
5209
6077
  </xsl:for-each>
5210
6078
  </xsl:variable>
5211
-
5212
- <xsl:variable name="newRow">
5213
- <xsl:copy>
5214
- <xsl:copy-of select="$currentRow/@*"/>
5215
- <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
5216
- </xsl:copy>
6079
+
6080
+ <xsl:variable name="newRow">
6081
+ <xsl:copy>
6082
+ <xsl:copy-of select="$currentRow/@*"/>
6083
+ <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
6084
+ </xsl:copy>
6085
+ </xsl:variable>
6086
+ <xsl:copy-of select="$newRow"/>
6087
+
6088
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6089
+ <xsl:with-param name="previousRow" select="$newRow"/>
6090
+ </xsl:apply-templates>
6091
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
6092
+ <xsl:param name="id"/>
6093
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
6094
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6095
+ <xsl:with-param name="id" select="$id_prefixed"/>
6096
+ </xsl:apply-templates>
6097
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
6098
+ <xsl:param name="id"/>
6099
+ <xsl:copy>
6100
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6101
+ <xsl:with-param name="id" select="$id"/>
6102
+ </xsl:apply-templates>
6103
+ </xsl:copy>
6104
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
6105
+ <xsl:param name="id"/>
6106
+ <xsl:copy>
6107
+ <xsl:copy-of select="@*"/>
6108
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
6109
+ <xsl:apply-templates select="node()" mode="simple-table-id">
6110
+ <xsl:with-param name="id" select="$id"/>
6111
+ </xsl:apply-templates>
6112
+ </xsl:copy>
6113
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
6114
+ <xsl:param name="id"/>
6115
+ <xsl:copy>
6116
+ <xsl:copy-of select="@*"/>
6117
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
6118
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
6119
+ <xsl:attribute name="id">
6120
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
6121
+ </xsl:attribute>
6122
+
6123
+ <xsl:for-each select="*[local-name() = 'p']">
6124
+ <xsl:copy>
6125
+ <xsl:copy-of select="@*"/>
6126
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
6127
+ <xsl:attribute name="id">
6128
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
6129
+ </xsl:attribute>
6130
+
6131
+ <xsl:copy-of select="node()"/>
6132
+ </xsl:copy>
6133
+ </xsl:for-each>
6134
+
6135
+
6136
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
6137
+
6138
+ <xsl:variable name="td_text">
6139
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
6140
+ </xsl:variable>
6141
+
6142
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
6143
+
6144
+ <xsl:variable name="words">
6145
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
6146
+ <word>
6147
+ <xsl:copy-of select="."/>
6148
+ </word>
6149
+ </xsl:for-each>
6150
+
6151
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
6152
+ <xsl:copy-of select="."/>
6153
+ </xsl:for-each>
6154
+
6155
+ </xsl:variable>
6156
+
6157
+ <xsl:for-each select="xalan:nodeset($words)/word">
6158
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
6159
+ <xsl:copy>
6160
+ <xsl:attribute name="id">
6161
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
6162
+ </xsl:attribute>
6163
+ <xsl:copy-of select="node()"/>
6164
+ </xsl:copy>
6165
+ </xsl:for-each>
6166
+ </xsl:if>
6167
+ </xsl:copy>
6168
+
6169
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
6170
+ <xsl:copy>
6171
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
6172
+ </xsl:copy>
6173
+ </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">
6174
+ <xsl:variable name="formatting_tags">
6175
+ <xsl:call-template name="getFormattingTags"/>
6176
+ </xsl:variable>
6177
+ <word>
6178
+ <xsl:call-template name="enclose_text_in_tags">
6179
+ <xsl:with-param name="text" select="normalize-space(.)"/>
6180
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6181
+ </xsl:call-template>
6182
+ </word>
6183
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
6184
+
6185
+ <xsl:variable name="td_text" select="."/>
6186
+
6187
+ <xsl:variable name="string_with_added_zerospaces">
6188
+ <xsl:call-template name="add-zero-spaces-java">
6189
+ <xsl:with-param name="text" select="$td_text"/>
6190
+ </xsl:call-template>
5217
6191
  </xsl:variable>
5218
- <xsl:copy-of select="$newRow"/>
5219
-
5220
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5221
- <xsl:with-param name="previousRow" select="$newRow"/>
5222
- </xsl:apply-templates>
6192
+
6193
+ <xsl:variable name="formatting_tags">
6194
+ <xsl:call-template name="getFormattingTags"/>
6195
+ </xsl:variable>
6196
+
6197
+ <!-- <word>text</word> -->
6198
+ <xsl:call-template name="tokenize_with_tags">
6199
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6200
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
6201
+ </xsl:call-template>
6202
+ </xsl:template><xsl:template name="getFormattingTags">
6203
+ <tags>
6204
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
6205
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
6206
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6207
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6208
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6209
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6210
+ </tags>
5223
6211
  </xsl:template><xsl:template name="getLang">
5224
6212
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5225
6213
  <xsl:variable name="language">
@@ -5274,6 +6262,9 @@
5274
6262
  <xsl:variable name="isDeleted" select="@deleted"/>
5275
6263
 
5276
6264
  <fo:inline xsl:use-attribute-sets="mathml-style">
6265
+
6266
+
6267
+
5277
6268
 
5278
6269
 
5279
6270
  <xsl:call-template name="setTrackChangesStyles">
@@ -5281,48 +6272,80 @@
5281
6272
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
5282
6273
  </xsl:call-template>
5283
6274
 
6275
+ <xsl:if test="$add_math_as_text = 'true'">
6276
+ <!-- insert helper tag -->
6277
+ <!-- set unique font-size (fiction) -->
6278
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
6279
+ <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 -->
6280
+ </xsl:if>
5284
6281
 
5285
-
5286
- <xsl:variable name="mathml">
5287
- <xsl:apply-templates select="." mode="mathml"/>
6282
+ <xsl:variable name="mathml_content">
6283
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
5288
6284
  </xsl:variable>
5289
- <fo:instream-foreign-object fox:alt-text="Math">
5290
6285
 
6286
+
6287
+ <xsl:call-template name="mathml_instream_object">
6288
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
6289
+ </xsl:call-template>
5291
6290
 
5292
-
5293
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5294
- <xsl:variable name="comment_text_">
5295
- <xsl:choose>
5296
- <xsl:when test="normalize-space($comment_text_following) != ''">
5297
- <xsl:value-of select="$comment_text_following"/>
5298
- </xsl:when>
5299
- <xsl:otherwise>
5300
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5301
- </xsl:otherwise>
5302
- </xsl:choose>
5303
- </xsl:variable>
5304
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5305
-
5306
- <xsl:if test="normalize-space($comment_text) != ''">
5307
- <!-- put Mathin Alternate Text -->
5308
- <xsl:attribute name="fox:alt-text">
5309
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
5310
- </xsl:attribute>
5311
- </xsl:if>
5312
-
5313
- <xsl:variable name="mathml_content">
5314
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
5315
- </xsl:variable>
5316
- <!-- put MathML in Actual Text -->
5317
- <xsl:attribute name="fox:actual-text">
5318
- <xsl:value-of select="$mathml_content"/>
5319
- </xsl:attribute>
5320
-
5321
-
5322
-
5323
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
5324
- </fo:instream-foreign-object>
6291
+
5325
6292
  </fo:inline>
6293
+ </xsl:template><xsl:template name="getMathml_comment_text">
6294
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
6295
+ <xsl:variable name="comment_text_">
6296
+ <xsl:choose>
6297
+ <xsl:when test="normalize-space($comment_text_following) != ''">
6298
+ <xsl:value-of select="$comment_text_following"/>
6299
+ </xsl:when>
6300
+ <xsl:otherwise>
6301
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
6302
+ </xsl:otherwise>
6303
+ </xsl:choose>
6304
+ </xsl:variable>
6305
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
6306
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
6307
+ <xsl:value-of select="$comment_text"/>
6308
+ </xsl:template><xsl:template name="mathml_instream_object">
6309
+ <xsl:param name="comment_text"/>
6310
+ <xsl:param name="mathml_content"/>
6311
+
6312
+ <xsl:variable name="comment_text_">
6313
+ <xsl:choose>
6314
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
6315
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
6316
+ </xsl:choose>
6317
+ </xsl:variable>
6318
+
6319
+ <xsl:variable name="mathml">
6320
+ <xsl:apply-templates select="." mode="mathml"/>
6321
+ </xsl:variable>
6322
+
6323
+ <fo:instream-foreign-object fox:alt-text="Math">
6324
+
6325
+
6326
+
6327
+
6328
+
6329
+
6330
+
6331
+ <!-- put MathML in Actual Text -->
6332
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
6333
+ <xsl:attribute name="fox:actual-text">
6334
+ <xsl:value-of select="$mathml_content"/>
6335
+ </xsl:attribute>
6336
+
6337
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
6338
+ <xsl:if test="normalize-space($comment_text_) != ''">
6339
+ <!-- put Mathin Alternate Text -->
6340
+ <xsl:attribute name="fox:alt-text">
6341
+ <xsl:value-of select="$comment_text_"/>
6342
+ </xsl:attribute>
6343
+ </xsl:if>
6344
+ <!-- </xsl:if> -->
6345
+
6346
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
6347
+
6348
+ </fo:instream-foreign-object>
5326
6349
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
5327
6350
  <!-- <xsl:text>a+b</xsl:text> -->
5328
6351
  <xsl:text>&lt;</xsl:text>
@@ -5353,7 +6376,9 @@
5353
6376
  <!-- replace start and end spaces to non-break space -->
5354
6377
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
5355
6378
  </xsl:copy>
5356
- </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">
6379
+ </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">
6380
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
6381
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5357
6382
  <xsl:variable name="target">
5358
6383
  <xsl:choose>
5359
6384
  <xsl:when test="@updatetype = 'true'">
@@ -5950,18 +6975,33 @@
5950
6975
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5951
6976
  <xsl:copy>
5952
6977
  <xsl:apply-templates select="@*" mode="svg_update"/>
5953
- <xsl:variable name="viewbox">
6978
+ <xsl:variable name="viewbox_">
5954
6979
  <xsl:call-template name="split">
5955
6980
  <xsl:with-param name="pText" select="@viewBox"/>
5956
6981
  <xsl:with-param name="sep" select="' '"/>
5957
6982
  </xsl:call-template>
5958
6983
  </xsl:variable>
6984
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
6985
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
6986
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
6987
+
5959
6988
  <xsl:attribute name="width">
5960
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
6989
+ <xsl:choose>
6990
+ <xsl:when test="$width != ''">
6991
+ <xsl:value-of select="round($width)"/>
6992
+ </xsl:when>
6993
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
6994
+ </xsl:choose>
5961
6995
  </xsl:attribute>
5962
6996
  <xsl:attribute name="height">
5963
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
6997
+ <xsl:choose>
6998
+ <xsl:when test="$height != ''">
6999
+ <xsl:value-of select="round($height)"/>
7000
+ </xsl:when>
7001
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
7002
+ </xsl:choose>
5964
7003
  </xsl:attribute>
7004
+
5965
7005
  <xsl:apply-templates mode="svg_update"/>
5966
7006
  </xsl:copy>
5967
7007
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -6156,7 +7196,11 @@
6156
7196
  <xsl:apply-templates mode="bookmarks"/>
6157
7197
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
6158
7198
  <xsl:apply-templates select="."/>
6159
- </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">
7199
+ </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">
7200
+ <xsl:apply-templates mode="contents"/>
7201
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
7202
+ <xsl:apply-templates mode="bookmarks"/>
7203
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
6160
7204
  <xsl:apply-templates mode="bookmarks"/>
6161
7205
  </xsl:template><xsl:template name="addBookmarks">
6162
7206
  <xsl:param name="contents"/>
@@ -6447,7 +7491,9 @@
6447
7491
  <xsl:apply-templates/>
6448
7492
  </xsl:otherwise>
6449
7493
  </xsl:choose>
6450
- </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">
7494
+ </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">
7495
+ <xsl:value-of select="."/>
7496
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6451
7497
  <xsl:text> </xsl:text>
6452
7498
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6453
7499
  <xsl:copy>
@@ -6478,9 +7524,22 @@
6478
7524
  </xsl:when>
6479
7525
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6480
7526
  </xsl:choose>
7527
+ </xsl:template><xsl:template match="text()" mode="contents_item">
7528
+ <xsl:call-template name="keep_together_standard_number"/>
7529
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
7530
+ <xsl:apply-templates mode="contents_item"/>
6481
7531
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6482
7532
 
6483
7533
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7534
+
7535
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7536
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7537
+ </xsl:if>
7538
+
7539
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7540
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7541
+ </xsl:if>
7542
+
6484
7543
  <xsl:copy-of select="@id"/>
6485
7544
 
6486
7545
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6505,7 +7564,7 @@
6505
7564
 
6506
7565
  9
6507
7566
 
6508
-
7567
+ <!-- 9 -->
6509
7568
 
6510
7569
 
6511
7570
 
@@ -6589,7 +7648,7 @@
6589
7648
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6590
7649
  <xsl:choose>
6591
7650
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6592
- <xsl:call-template name="interspers">
7651
+ <xsl:call-template name="interspers-java">
6593
7652
  <xsl:with-param name="str" select="."/>
6594
7653
  </xsl:call-template>
6595
7654
  </xsl:when>
@@ -6639,6 +7698,10 @@
6639
7698
  <xsl:with-param name="char" select="$char"/>
6640
7699
  </xsl:call-template>
6641
7700
  </xsl:if>
7701
+ </xsl:template><xsl:template name="interspers-java">
7702
+ <xsl:param name="str"/>
7703
+ <xsl:param name="char" select="$zero_width_space"/>
7704
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
6642
7705
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6643
7706
  <xsl:apply-templates mode="syntax_highlight"/>
6644
7707
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6851,7 +7914,9 @@
6851
7914
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
6852
7915
  </xsl:if>
6853
7916
  <xsl:variable name="simple-table">
6854
- <xsl:call-template name="getSimpleTable"/>
7917
+ <xsl:call-template name="getSimpleTable">
7918
+ <xsl:with-param name="id" select="@id"/>
7919
+ </xsl:call-template>
6855
7920
  </xsl:variable>
6856
7921
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
6857
7922
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -6958,11 +8023,13 @@
6958
8023
  </xsl:otherwise>
6959
8024
  </xsl:choose>
6960
8025
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6961
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6962
-
8026
+
8027
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
8028
+
6963
8029
 
8030
+
6964
8031
  <xsl:variable name="fo_element">
6965
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
8032
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6966
8033
 
6967
8034
  <xsl:choose>
6968
8035
  <!-- if example contains only one (except 'name') element (paragraph for example), then display it on the same line as EXAMPLE title -->
@@ -6972,31 +8039,57 @@
6972
8039
 
6973
8040
  </xsl:variable>
6974
8041
 
6975
- <!-- display 'EXAMPLE' -->
6976
- <xsl:apply-templates select="*[local-name()='name']">
6977
- <xsl:with-param name="fo_element" select="$fo_element"/>
6978
- </xsl:apply-templates>
8042
+ <fo:block-container margin-left="0mm">
6979
8043
 
6980
- <xsl:choose>
6981
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6982
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6983
- <fo:block-container margin-left="0mm" margin-right="0mm">
6984
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8044
+ <xsl:choose>
8045
+
8046
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
8047
+
8048
+ <!-- display name 'EXAMPLE' in a separate block -->
8049
+ <fo:block>
8050
+ <xsl:apply-templates select="*[local-name()='name']">
6985
8051
  <xsl:with-param name="fo_element" select="$fo_element"/>
6986
8052
  </xsl:apply-templates>
8053
+ </fo:block>
8054
+
8055
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8056
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8057
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8058
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8059
+ </xsl:apply-templates>
8060
+ </fo:block-container>
6987
8061
  </fo:block-container>
6988
- </fo:block-container>
6989
- </xsl:when>
6990
- <xsl:otherwise>
6991
- <fo:inline>
6992
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6993
- <xsl:with-param name="fo_element" select="$fo_element"/>
6994
- </xsl:apply-templates>
6995
- </fo:inline>
6996
- </xsl:otherwise>
6997
- </xsl:choose>
6998
-
6999
- </fo:block>
8062
+ </xsl:when> <!-- end block -->
8063
+
8064
+ <xsl:otherwise> <!-- inline -->
8065
+
8066
+ <!-- display 'EXAMPLE' and first element in the same line -->
8067
+ <fo:block>
8068
+ <xsl:apply-templates select="*[local-name()='name']">
8069
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8070
+ </xsl:apply-templates>
8071
+ <fo:inline>
8072
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
8073
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8074
+ </xsl:apply-templates>
8075
+ </fo:inline>
8076
+ </fo:block>
8077
+
8078
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
8079
+ <!-- display further elements in blocks -->
8080
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8081
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8082
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
8083
+ <xsl:with-param name="fo_element" select="'block'"/>
8084
+ </xsl:apply-templates>
8085
+ </fo:block-container>
8086
+ </fo:block-container>
8087
+ </xsl:if>
8088
+ </xsl:otherwise> <!-- end inline -->
8089
+
8090
+ </xsl:choose>
8091
+ </fo:block-container>
8092
+ </fo:block-container>
7000
8093
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
7001
8094
  <xsl:param name="fo_element">block</xsl:param>
7002
8095
 
@@ -7028,10 +8121,16 @@
7028
8121
  </xsl:variable>
7029
8122
  <xsl:choose>
7030
8123
  <xsl:when test="starts-with(normalize-space($element), 'block')">
7031
- <fo:block xsl:use-attribute-sets="example-p-style">
7032
-
7033
- <xsl:apply-templates/>
7034
- </fo:block>
8124
+ <fo:block-container>
8125
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
8126
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
8127
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
8128
+ </xsl:if>
8129
+ <fo:block xsl:use-attribute-sets="example-p-style">
8130
+
8131
+ <xsl:apply-templates/>
8132
+ </fo:block>
8133
+ </fo:block-container>
7035
8134
  </xsl:when>
7036
8135
  <xsl:otherwise>
7037
8136
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -7210,7 +8309,16 @@
7210
8309
  </fo:inline>
7211
8310
  </xsl:when>
7212
8311
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7213
- <fo:inline><xsl:apply-templates/></fo:inline>
8312
+
8313
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
8314
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
8315
+ <xsl:choose>
8316
+ <xsl:when test="$uri_src != ''">
8317
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
8318
+ </xsl:when>
8319
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
8320
+ </xsl:choose>
8321
+
7214
8322
  </xsl:otherwise>
7215
8323
  </xsl:choose>
7216
8324
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7387,10 +8495,24 @@
7387
8495
 
7388
8496
  </fo:block>
7389
8497
  <xsl:apply-templates/>
7390
- </xsl:template><xsl:template match="*[local-name() = 'review']">
8498
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7391
8499
  <!-- comment 2019-11-29 -->
7392
8500
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7393
8501
  <xsl:apply-templates /> -->
8502
+
8503
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
8504
+
8505
+ <xsl:choose>
8506
+ <!-- if there isn't the attribute '@from', then -->
8507
+ <xsl:when test="$id_from = ''">
8508
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8509
+ </xsl:when>
8510
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
8511
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
8512
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8513
+ </xsl:when>
8514
+ </xsl:choose>
8515
+
7394
8516
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7395
8517
  <!-- 0xA0 to space replacement -->
7396
8518
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7537,6 +8659,11 @@
7537
8659
  </xsl:otherwise>
7538
8660
  </xsl:choose>
7539
8661
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
8662
+
8663
+ <xsl:apply-templates select="*[local-name() = 'name']">
8664
+ <xsl:with-param name="process">true</xsl:with-param>
8665
+ </xsl:apply-templates>
8666
+
7540
8667
  <fo:list-block xsl:use-attribute-sets="list-style">
7541
8668
 
7542
8669
 
@@ -7554,12 +8681,23 @@
7554
8681
 
7555
8682
 
7556
8683
 
8684
+ <xsl:if test="*[local-name() = 'name']">
8685
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8686
+ </xsl:if>
8687
+
7557
8688
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7558
8689
  </fo:list-block>
7559
8690
  <!-- <xsl:for-each select="./iho:note">
7560
8691
  <xsl:call-template name="note"/>
7561
8692
  </xsl:for-each> -->
7562
8693
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
8694
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
8695
+ <xsl:param name="process">false</xsl:param>
8696
+ <xsl:if test="$process = 'true'">
8697
+ <fo:block xsl:use-attribute-sets="list-name-style">
8698
+ <xsl:apply-templates/>
8699
+ </fo:block>
8700
+ </xsl:if>
7563
8701
  </xsl:template><xsl:template match="*[local-name()='li']">
7564
8702
  <fo:list-item xsl:use-attribute-sets="list-item-style">
7565
8703
  <xsl:copy-of select="@id"/>
@@ -7756,7 +8894,10 @@
7756
8894
  <!-- to split by '_' and other chars -->
7757
8895
  <xsl:call-template name="add-zero-spaces-java"/>
7758
8896
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7759
- <fo:inline id="{@id}" font-size="1pt"/>
8897
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8898
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8899
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8900
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7760
8901
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7761
8902
  <!-- <row>
7762
8903
  <date>05-07-2013</date>
@@ -7865,26 +9006,23 @@
7865
9006
  <xsl:if test=".//*[local-name() = 'fn']">
7866
9007
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
7867
9008
  </xsl:if>
9009
+
9010
+ <!-- display document identifier, not number [1] -->
7868
9011
  <xsl:variable name="docidentifier">
7869
9012
  <xsl:choose>
7870
9013
  <xsl:when test="*[local-name() = 'docidentifier']/@type = 'metanorma'"/>
7871
9014
  <xsl:otherwise><xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma-ordinal')]"/></xsl:otherwise>
7872
9015
  </xsl:choose>
7873
9016
  </xsl:variable>
7874
- <fo:inline><xsl:value-of select="$docidentifier"/></fo:inline>
9017
+ <xsl:value-of select="$docidentifier"/>
9018
+
7875
9019
  <xsl:apply-templates select="*[local-name() = 'note']"/>
7876
- <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
7877
- <xsl:choose>
7878
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = $lang]">
7879
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = $lang]"/>
7880
- </xsl:when>
7881
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = 'en']">
7882
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = 'en']"/>
7883
- </xsl:when>
7884
- <xsl:otherwise>
7885
- <xsl:apply-templates select="*[local-name() = 'title']"/>
7886
- </xsl:otherwise>
7887
- </xsl:choose>
9020
+
9021
+ <xsl:if test="normalize-space($docidentifier) != '' and *[local-name() = 'formattedref']">
9022
+ <xsl:text>,</xsl:text>
9023
+ <xsl:text> </xsl:text>
9024
+ </xsl:if>
9025
+
7888
9026
  <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
7889
9027
  <!-- end bibitem processing -->
7890
9028
 
@@ -8196,8 +9334,9 @@
8196
9334
 
8197
9335
  <fo:block text-align="justify">
8198
9336
  <fo:inline>
8199
- <xsl:call-template name="displayAdmonitionName"/>
8200
- <xsl:text> – </xsl:text>
9337
+ <xsl:call-template name="displayAdmonitionName">
9338
+ <xsl:with-param name="sep"> – </xsl:with-param>
9339
+ </xsl:call-template>
8201
9340
  </fo:inline>
8202
9341
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8203
9342
  </fo:block>
@@ -8207,25 +9346,32 @@
8207
9346
  </fo:block-container>
8208
9347
 
8209
9348
  </xsl:template><xsl:template name="displayAdmonitionName">
8210
-
9349
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
9350
+ <!-- <xsl:choose>
9351
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
9352
+ <xsl:choose>
9353
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
9354
+ <xsl:otherwise>
9355
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
9356
+ </xsl:otherwise>
9357
+ </xsl:choose>
9358
+ </xsl:when>
9359
+ <xsl:otherwise>
8211
9360
  <xsl:apply-templates select="*[local-name() = 'name']"/>
8212
9361
  <xsl:if test="not(*[local-name() = 'name'])">
8213
9362
  <xsl:apply-templates select="@type"/>
8214
9363
  </xsl:if>
8215
-
8216
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8217
- <xsl:apply-templates/>
8218
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
8219
- <xsl:variable name="admonition_type_">
8220
- <xsl:call-template name="getLocalizedString">
8221
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
8222
- </xsl:call-template>
9364
+ </xsl:otherwise>
9365
+ </xsl:choose> -->
9366
+ <xsl:variable name="name">
9367
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8223
9368
  </xsl:variable>
8224
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
8225
- <xsl:value-of select="$admonition_type"/>
8226
- <xsl:if test="$admonition_type = ''">
8227
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
9369
+ <xsl:copy-of select="$name"/>
9370
+ <xsl:if test="normalize-space($name) != ''">
9371
+ <xsl:value-of select="$sep"/>
8228
9372
  </xsl:if>
9373
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
9374
+ <xsl:apply-templates/>
8229
9375
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
8230
9376
  <!-- processing for admonition/p found in the template for 'p' -->
8231
9377
  <xsl:call-template name="paragraph"/>
@@ -8302,6 +9448,120 @@
8302
9448
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8303
9449
  </xsl:for-each>
8304
9450
  </xsl:copy>
9451
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9452
+ <xsl:apply-templates mode="update_xml_step1"/>
9453
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9454
+ <xsl:copy>
9455
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
9456
+ </xsl:copy>
9457
+ </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">
9458
+
9459
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
9460
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9461
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9462
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9463
+ <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))"/>
9464
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9465
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9466
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9467
+ <xsl:with-param name="text" select="$text_"/>
9468
+ </xsl:call-template></text></xsl:variable>
9469
+
9470
+ <xsl:variable name="parent" select="local-name(..)"/>
9471
+
9472
+ <xsl:variable name="text2">
9473
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
9474
+ <xsl:copy-of select="."/>
9475
+ </xsl:for-each></text>
9476
+ </xsl:variable>
9477
+
9478
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9479
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
9480
+ <xsl:variable name="text3">
9481
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9482
+ <xsl:choose>
9483
+ <xsl:when test="self::text()">
9484
+ <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))"/>
9485
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
9486
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9487
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9488
+ <xsl:with-param name="text" select="$text_units_"/>
9489
+ </xsl:call-template></text></xsl:variable>
9490
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
9491
+ </xsl:when>
9492
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9493
+ </xsl:choose>
9494
+ </xsl:for-each></text>
9495
+ </xsl:variable>
9496
+
9497
+ <xsl:choose>
9498
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9499
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9500
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9501
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9502
+ <xsl:choose>
9503
+ <xsl:when test="self::text()">
9504
+ <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))"/>
9505
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
9506
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9507
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9508
+ <xsl:with-param name="text" select="$text_dots_"/>
9509
+ </xsl:call-template></text></xsl:variable>
9510
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
9511
+ </xsl:when>
9512
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9513
+ </xsl:choose>
9514
+ </xsl:for-each>
9515
+ </xsl:when>
9516
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
9517
+ </xsl:choose>
9518
+
9519
+ </xsl:template><xsl:template name="replace_text_tags">
9520
+ <xsl:param name="tag_open"/>
9521
+ <xsl:param name="tag_close"/>
9522
+ <xsl:param name="text"/>
9523
+ <xsl:choose>
9524
+ <xsl:when test="contains($text, $tag_open)">
9525
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
9526
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
9527
+
9528
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
9529
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
9530
+ </xsl:element>
9531
+
9532
+ <xsl:call-template name="replace_text_tags">
9533
+ <xsl:with-param name="tag_open" select="$tag_open"/>
9534
+ <xsl:with-param name="tag_close" select="$tag_close"/>
9535
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
9536
+ </xsl:call-template>
9537
+ </xsl:when>
9538
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
9539
+ </xsl:choose>
9540
+ </xsl:template><xsl:template name="printEdition">
9541
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
9542
+ <xsl:text> </xsl:text>
9543
+ <xsl:choose>
9544
+ <xsl:when test="$edition_i18n != ''">
9545
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
9546
+ <xsl:call-template name="capitalize">
9547
+ <xsl:with-param name="str" select="$edition_i18n"/>
9548
+ </xsl:call-template>
9549
+ </xsl:when>
9550
+ <xsl:otherwise>
9551
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
9552
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
9553
+ <xsl:call-template name="capitalize">
9554
+ <xsl:with-param name="str">
9555
+ <xsl:call-template name="getLocalizedString">
9556
+ <xsl:with-param name="key">edition</xsl:with-param>
9557
+ </xsl:call-template>
9558
+ </xsl:with-param>
9559
+ </xsl:call-template>
9560
+ <xsl:text> </xsl:text>
9561
+ <xsl:value-of select="$edition"/>
9562
+ </xsl:if>
9563
+ </xsl:otherwise>
9564
+ </xsl:choose>
8305
9565
  </xsl:template><xsl:template name="convertDate">
8306
9566
  <xsl:param name="date"/>
8307
9567
  <xsl:param name="format" select="'short'"/>
@@ -8989,4 +10249,40 @@
8989
10249
  <xsl:value-of select="$value"/>
8990
10250
  </xsl:otherwise>
8991
10251
  </xsl:choose>
10252
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
10253
+ <xsl:param name="level">0</xsl:param>
10254
+
10255
+ <fo:block margin-left="{2*$level}mm">
10256
+ <xsl:text>
10257
+ &lt;</xsl:text>
10258
+ <xsl:value-of select="local-name()"/>
10259
+ <xsl:for-each select="@*">
10260
+ <xsl:text> </xsl:text>
10261
+ <xsl:value-of select="local-name()"/>
10262
+ <xsl:text>="</xsl:text>
10263
+ <xsl:value-of select="."/>
10264
+ <xsl:text>"</xsl:text>
10265
+ </xsl:for-each>
10266
+ <xsl:text>&gt;</xsl:text>
10267
+
10268
+ <xsl:if test="not(*)">
10269
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
10270
+ <xsl:text>&lt;/</xsl:text>
10271
+ <xsl:value-of select="local-name()"/>
10272
+ <xsl:text>&gt;</xsl:text>
10273
+ </xsl:if>
10274
+ </fo:block>
10275
+
10276
+ <xsl:if test="*">
10277
+ <fo:block>
10278
+ <xsl:apply-templates mode="print_as_xml">
10279
+ <xsl:with-param name="level" select="$level + 1"/>
10280
+ </xsl:apply-templates>
10281
+ </fo:block>
10282
+ <fo:block margin-left="{2*$level}mm">
10283
+ <xsl:text>&lt;/</xsl:text>
10284
+ <xsl:value-of select="local-name()"/>
10285
+ <xsl:text>&gt;</xsl:text>
10286
+ </fo:block>
10287
+ </xsl:if>
8992
10288
  </xsl:template></xsl:stylesheet>