metanorma-iso 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1770,6 +1770,7 @@
1770
1770
 
1771
1771
  <xsl:template match="iso:p" name="paragraph">
1772
1772
  <xsl:param name="inline" select="'false'"/>
1773
+ <xsl:param name="split_keep-within-line"/>
1773
1774
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
1774
1775
  <xsl:variable name="element-name">
1775
1776
  <xsl:choose>
@@ -1799,7 +1800,9 @@
1799
1800
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
1800
1801
  <xsl:attribute name="line-height">0</xsl:attribute>
1801
1802
  </xsl:if>
1802
- <xsl:apply-templates/>
1803
+ <xsl:apply-templates>
1804
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1805
+ </xsl:apply-templates>
1803
1806
  </xsl:element>
1804
1807
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
1805
1808
  <fo:block margin-bottom="12pt">
@@ -2014,7 +2017,11 @@
2014
2017
  <xsl:text>iVBORw0KGgoAAAANSUhEUgAAAFEAAABHCAIAAADwYjznAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA66SURBVHhezZt5sM/VG8fNVH7JruxkSZKQ3TAYS7aGajKpFBnRxBjjkhrLrRgmYwm59hrGjC0miSmmIgoVZYu00GJtxkyMkV2/1+fzPh7nfr7fe33v/X6/9/d7/3HmOc/nLM/7PM95zjnfS6F//xc4f/786dOnXaXAUdCcjx071rt373vvvbdChQrNmzdfuXKl+1CAKFDOR44cqVWrVqFChf4T4vbbb7/zzjsnT57sPhcUCo7ztWvX2rRpc9tttxUtWvSuEAgwp/z0009dowJBwXGeM2dO4cKFRZWySJEikvF2o0aNrly54tqlHwXE+cyZM9WrV4czJMW5WLFixv+OO+6YPn26a5p+FBDnjIwM/Ak9AHMcm5mZyWY2TeXKlf/66y/XOs0oCM4HDh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mQJvPNAUSIlXBlw1xlSBux5wa+6CN38yqEoD0Bl+JAC/YQUruROYxV+jPP//UHzhDN7vbguQIctJHELdZrDIRDUhwUpBTS/T6BP8SJUrwjA32M9cj/d/zILuFV3MTBKua0qomhOoAvtJgn0yQbBogpcFpQ5jG9BEhUvpVARmO7dq141QOOF++fJk0Vq5cOb5pVf5PoLBMHvDiFtShQwf9EuzOZ3D06NFNmzbpfKI0KPUDyVZK8GUrfZjeBCsFk4MWubYJPnswvSFSFVBu3ryZJ5fj+e+//wVuVmgt0lkFPgAAAABJRU5ErkJggg==</xsl:text>
2015
2018
  </xsl:variable>
2016
2019
 
2017
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:param name="add_math_as_text">true</xsl:param><xsl:variable name="lang">
2020
+ <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:param name="table_if_debug">false</xsl:param><xsl:variable name="isGenerateTableIF_">
2021
+
2022
+ <xsl:value-of select="normalize-space($table_if) = 'true'"/>
2023
+
2024
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
2018
2025
  <xsl:call-template name="getLang"/>
2019
2026
  </xsl:variable><xsl:variable name="pageWidth_">
2020
2027
  210
@@ -2498,6 +2505,7 @@
2498
2505
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2499
2506
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2500
2507
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2508
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2501
2509
  <xsl:attribute name="display-align">center</xsl:attribute>
2502
2510
 
2503
2511
 
@@ -2518,6 +2526,7 @@
2518
2526
  <xsl:attribute name="display-align">center</xsl:attribute>
2519
2527
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2520
2528
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2529
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2521
2530
 
2522
2531
 
2523
2532
 
@@ -2612,7 +2621,8 @@
2612
2621
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
2613
2622
 
2614
2623
 
2615
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2624
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2625
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2616
2626
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2617
2627
 
2618
2628
 
@@ -2626,6 +2636,8 @@
2626
2636
 
2627
2637
 
2628
2638
 
2639
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2640
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2629
2641
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2630
2642
 
2631
2643
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -3462,7 +3474,38 @@
3462
3474
  </xsl:template><xsl:template match="*[local-name()='br']">
3463
3475
  <xsl:value-of select="$linebreak"/>
3464
3476
  </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3465
- <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3477
+ <xsl:param name="split_keep-within-line"/>
3478
+
3479
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3480
+ <xsl:choose>
3481
+
3482
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3483
+ <xsl:variable name="sep">_</xsl:variable>
3484
+ <xsl:variable name="items">
3485
+ <xsl:call-template name="split">
3486
+ <xsl:with-param name="pText" select="."/>
3487
+ <xsl:with-param name="sep" select="$sep"/>
3488
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3489
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3490
+ </xsl:call-template>
3491
+ </xsl:variable>
3492
+ <xsl:for-each select="xalan:nodeset($items)/item">
3493
+ <xsl:choose>
3494
+ <xsl:when test=". = $sep">
3495
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3496
+ </xsl:when>
3497
+ <xsl:otherwise>
3498
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3499
+ </xsl:otherwise>
3500
+ </xsl:choose>
3501
+ </xsl:for-each>
3502
+ </xsl:when>
3503
+
3504
+ <xsl:otherwise>
3505
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3506
+ </xsl:otherwise>
3507
+
3508
+ </xsl:choose>
3466
3509
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3467
3510
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3468
3511
  <xsl:apply-templates/>
@@ -3569,9 +3612,14 @@
3569
3612
 
3570
3613
  <xsl:variable name="table">
3571
3614
 
3572
- <xsl:variable name="simple-table">
3573
- <xsl:call-template name="getSimpleTable"/>
3615
+ <xsl:variable name="simple-table">
3616
+ <xsl:call-template name="getSimpleTable">
3617
+ <xsl:with-param name="id" select="@id"/>
3618
+ </xsl:call-template>
3574
3619
  </xsl:variable>
3620
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3621
+
3622
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3575
3623
 
3576
3624
 
3577
3625
  <!-- Display table's name before table as standalone block -->
@@ -3590,7 +3638,23 @@
3590
3638
  </xsl:call-template>
3591
3639
  </xsl:if>
3592
3640
  </xsl:variable>
3593
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3641
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3642
+
3643
+ <!-- DEBUG -->
3644
+ <xsl:if test="$table_if_debug = 'true'">
3645
+ <fo:block font-size="60%">
3646
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3647
+ </fo:block>
3648
+ </xsl:if>
3649
+
3650
+
3651
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3652
+
3653
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3654
+ DEBUG
3655
+ colwidths=<xsl:copy-of select="$colwidths"/>
3656
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3657
+
3594
3658
 
3595
3659
 
3596
3660
  <xsl:variable name="margin-side">
@@ -3659,9 +3723,17 @@
3659
3723
  </xsl:element>
3660
3724
  </xsl:variable>
3661
3725
 
3726
+ <xsl:if test="$isGenerateTableIF = 'true'">
3727
+ <!-- to determine start of table -->
3728
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3729
+ </xsl:if>
3662
3730
 
3663
3731
  <fo:table id="{@id}">
3664
3732
 
3733
+ <xsl:if test="$isGenerateTableIF = 'true'">
3734
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3735
+ </xsl:if>
3736
+
3665
3737
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3666
3738
  <xsl:attribute name="{local-name()}">
3667
3739
  <xsl:value-of select="."/>
@@ -3675,24 +3747,47 @@
3675
3747
 
3676
3748
 
3677
3749
  <xsl:choose>
3678
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3679
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3680
- <fo:table-column column-width="{@width}"/>
3681
- </xsl:for-each>
3750
+ <xsl:when test="$isGenerateTableIF = 'true'">
3751
+ <!-- generate IF for table widths -->
3752
+ <!-- example:
3753
+ <tr>
3754
+ <td valign="top" align="left" id="tab-symdu_1_1">
3755
+ <p>Symbol</p>
3756
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3757
+ </td>
3758
+ <td valign="top" align="left" id="tab-symdu_1_2">
3759
+ <p>Description</p>
3760
+ <word id="tab-symdu_1_2_word_1">Description</word>
3761
+ </td>
3762
+ </tr>
3763
+ -->
3764
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3765
+
3682
3766
  </xsl:when>
3683
3767
  <xsl:otherwise>
3684
- <xsl:call-template name="insertTableColumnWidth">
3685
- <xsl:with-param name="colwidths" select="$colwidths"/>
3686
- </xsl:call-template>
3687
- </xsl:otherwise>
3688
- </xsl:choose>
3689
3768
 
3690
- <xsl:choose>
3691
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3692
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3693
- </xsl:when>
3694
- <xsl:otherwise>
3695
- <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 -->
3769
+ <xsl:choose>
3770
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3771
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3772
+ <fo:table-column column-width="{@width}"/>
3773
+ </xsl:for-each>
3774
+ </xsl:when>
3775
+ <xsl:otherwise>
3776
+ <xsl:call-template name="insertTableColumnWidth">
3777
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3778
+ </xsl:call-template>
3779
+ </xsl:otherwise>
3780
+ </xsl:choose>
3781
+
3782
+ <xsl:choose>
3783
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3784
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3785
+ </xsl:when>
3786
+ <xsl:otherwise>
3787
+ <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 -->
3788
+ </xsl:otherwise>
3789
+ </xsl:choose>
3790
+
3696
3791
  </xsl:otherwise>
3697
3792
  </xsl:choose>
3698
3793
 
@@ -3797,11 +3892,23 @@
3797
3892
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3798
3893
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3799
3894
  </xsl:template><xsl:template name="calculate-column-widths">
3895
+ <xsl:param name="table"/>
3896
+ <xsl:param name="cols-count"/>
3897
+
3898
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
3899
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3900
+ <xsl:with-param name="table" select="$table"/>
3901
+ <xsl:with-param name="if">true</xsl:with-param>
3902
+ </xsl:call-template>
3903
+
3904
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3800
3905
  <xsl:param name="table"/>
3801
3906
  <xsl:param name="cols-count"/>
3802
3907
  <xsl:param name="curr-col" select="1"/>
3803
3908
  <xsl:param name="width" select="0"/>
3804
3909
 
3910
+ <!-- table=<xsl:copy-of select="$table"/> -->
3911
+
3805
3912
  <xsl:if test="$curr-col &lt;= $cols-count">
3806
3913
  <xsl:variable name="widths">
3807
3914
  <xsl:choose>
@@ -3839,10 +3946,15 @@
3839
3946
  </xsl:for-each>
3840
3947
  </xsl:when>
3841
3948
  <xsl:otherwise>
3842
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3949
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3950
+
3951
+ <!-- <table><xsl:copy-of select="$table"/></table>
3952
+ -->
3953
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3843
3954
  <xsl:variable name="td_text">
3844
3955
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3845
3956
  </xsl:variable>
3957
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3846
3958
  <xsl:variable name="words">
3847
3959
  <xsl:variable name="string_with_added_zerospaces">
3848
3960
  <xsl:call-template name="add-zero-spaces-java">
@@ -3857,6 +3969,7 @@
3857
3969
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3858
3970
  </xsl:call-template>
3859
3971
  </xsl:variable>
3972
+ <!-- words=<xsl:copy-of select="$words"/> -->
3860
3973
  <xsl:variable name="max_length">
3861
3974
  <xsl:call-template name="max_length">
3862
3975
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
@@ -3881,6 +3994,8 @@
3881
3994
  </xsl:choose>
3882
3995
  </xsl:variable>
3883
3996
 
3997
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3998
+
3884
3999
  <column>
3885
4000
  <xsl:for-each select="xalan:nodeset($widths)//width">
3886
4001
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3889,33 +4004,327 @@
3889
4004
  </xsl:if>
3890
4005
  </xsl:for-each>
3891
4006
  </column>
3892
- <xsl:call-template name="calculate-column-widths">
4007
+ <xsl:call-template name="calculate-column-widths-proportional">
3893
4008
  <xsl:with-param name="cols-count" select="$cols-count"/>
3894
4009
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3895
4010
  <xsl:with-param name="table" select="$table"/>
3896
4011
  </xsl:call-template>
3897
4012
  </xsl:if>
3898
- </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
4013
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
3899
4014
  <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3900
4015
  <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3901
4016
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
4017
+
4018
+ <!-- if all capitals english letters or digits -->
4019
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
4020
+ <xsl:call-template name="repeat">
4021
+ <xsl:with-param name="char" select="'X'"/>
4022
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
4023
+ </xsl:call-template>
4024
+ </xsl:if>
3902
4025
  </xsl:template><xsl:template match="text()" mode="td_text">
3903
4026
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3904
4027
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3905
4028
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3906
4029
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3907
4030
  <xsl:value-of select="@target"/>
3908
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3909
- <xsl:variable name="mathml">
3910
- <xsl:for-each select="*">
3911
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3912
- <xsl:copy-of select="."/>
4031
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
4032
+ <xsl:if test="$isGenerateTableIF = 'false'">
4033
+ <xsl:variable name="mathml_">
4034
+ <xsl:for-each select="*">
4035
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
4036
+ <xsl:copy-of select="."/>
4037
+ </xsl:if>
4038
+ </xsl:for-each>
4039
+ </xsl:variable>
4040
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
4041
+
4042
+ <xsl:variable name="math_text">
4043
+ <xsl:value-of select="normalize-space($mathml)"/>
4044
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
4045
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
4046
+ </xsl:variable>
4047
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4048
+ </xsl:if>
4049
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
4050
+ <xsl:param name="table"/>
4051
+ <xsl:param name="if">false</xsl:param> <!-- via intermediate format -->
4052
+
4053
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
4054
+
4055
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
4056
+
4057
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
4058
+
4059
+ <!-- get current table id -->
4060
+ <xsl:variable name="table_id" select="@id"/>
4061
+ <!-- find table by id in the file 'table_widths' -->
4062
+ <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
4063
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/>
4064
+
4065
+
4066
+ <!-- table='<xsl:copy-of select="$table"/>' -->
4067
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
4068
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
4069
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
4070
+
4071
+ <xsl:variable name="table_with_cell_widths_">
4072
+ <xsl:choose>
4073
+ <xsl:when test="$if = 'true' and normalize-space($table-if) != ''"> <!-- if we read column's width from IF and there is table in IF -->
4074
+
4075
+ <!-- Example: <column>10</column>
4076
+ <column>11</column>
4077
+ -->
4078
+ <xsl:apply-templates select="$table-if" mode="determine_cell_widths-if"/>
4079
+ </xsl:when>
4080
+ <xsl:otherwise>
4081
+ <xsl:apply-templates select="xalan:nodeset($table)" mode="determine_cell_widths"/>
4082
+ </xsl:otherwise>
4083
+ </xsl:choose>
4084
+ </xsl:variable>
4085
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
4086
+
4087
+ <xsl:if test="$table_if_debug = 'true'">
4088
+ <xsl:copy-of select="$table_with_cell_widths"/>
4089
+ </xsl:if>
4090
+
4091
+
4092
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
4093
+
4094
+ <xsl:variable name="column_widths_">
4095
+ <!-- iteration of columns -->
4096
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
4097
+ <xsl:variable name="pos" select="position()"/>
4098
+ <column>
4099
+ <xsl:attribute name="width_max">
4100
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
4101
+ <xsl:sort select="." data-type="number" order="descending"/>
4102
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4103
+ </xsl:for-each>
4104
+ </xsl:attribute>
4105
+ <xsl:attribute name="width_min">
4106
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
4107
+ <xsl:sort select="." data-type="number" order="descending"/>
4108
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4109
+ </xsl:for-each>
4110
+ </xsl:attribute>
4111
+ </column>
4112
+ </xsl:for-each>
4113
+ </xsl:variable>
4114
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
4115
+
4116
+ <!-- <column_widths>
4117
+ <xsl:copy-of select="$column_widths"/>
4118
+ </column_widths> -->
4119
+
4120
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
4121
+ <xsl:variable name="table_widths_">
4122
+ <table>
4123
+ <xsl:attribute name="width_max">
4124
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
4125
+ </xsl:attribute>
4126
+ <xsl:attribute name="width_min">
4127
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
4128
+ </xsl:attribute>
4129
+ </table>
4130
+ </xsl:variable>
4131
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
4132
+
4133
+ <xsl:variable name="page_width">
4134
+ <xsl:choose>
4135
+ <xsl:when test="$if = 'true'"><xsl:value-of select="$table-if/@page-width"/></xsl:when>
4136
+ <xsl:otherwise>75</xsl:otherwise>
4137
+ </xsl:choose>
4138
+ </xsl:variable>
4139
+
4140
+ <xsl:if test="$table_if_debug = 'true'">
4141
+ <table_width>
4142
+ <xsl:copy-of select="$table_widths"/>
4143
+ </table_width>
4144
+ <!-- <debug>$table_widths/@width_min=<xsl:value-of select="$table_widths/table/@width_min"/></debug>
4145
+ <debug>$table_widths/@width_max=<xsl:value-of select="$table_widths/table/@width_max"/></debug>
4146
+ -->
4147
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
4148
+ </xsl:if>
4149
+
4150
+
4151
+ <!-- There are three cases: -->
4152
+ <xsl:choose>
4153
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
4154
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
4155
+ <!-- call old algorithm -->
4156
+ <case1/>
4157
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
4158
+ <xsl:call-template name="calculate-column-widths-proportional">
4159
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4160
+ <xsl:with-param name="table" select="$table"/>
4161
+ </xsl:call-template>
4162
+ </xsl:when>
4163
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
4164
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
4165
+ <case2/>
4166
+ <autolayout/>
4167
+ <xsl:for-each select="$column_widths/column/@width_max">
4168
+ <column divider="100"><xsl:value-of select="."/></column>
4169
+ </xsl:for-each>
4170
+ </xsl:when>
4171
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
4172
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
4173
+ Lets also call D the difference between maximum and minimum width of the table.
4174
+ For each column, let d be the difference between maximum and minimum width of that column.
4175
+ Now set the column's width to the minimum width plus d times W over D.
4176
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
4177
+ <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)">
4178
+ <!-- difference between the available space and the minimum table width -->
4179
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
4180
+ <W><xsl:value-of select="$W"/></W>
4181
+ <!-- difference between maximum and minimum width of the table -->
4182
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
4183
+ <D><xsl:value-of select="$D"/></D>
4184
+ <case3/>
4185
+ <autolayout/>
4186
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
4187
+ <split_keep-within-line>true</split_keep-within-line>
3913
4188
  </xsl:if>
4189
+ <xsl:for-each select="$column_widths/column">
4190
+ <!-- difference between maximum and minimum width of that column. -->
4191
+ <xsl:variable name="d" select="@width_max - @width_min"/>
4192
+ <d><xsl:value-of select="$d"/></d>
4193
+ <width_min><xsl:value-of select="@width_min"/></width_min>
4194
+ <e><xsl:value-of select="$d * $W div $D"/></e>
4195
+ <!-- set the column's width to the minimum width plus d times W over D. -->
4196
+ <column divider="100">
4197
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4198
+ </column>
4199
+ </xsl:for-each>
4200
+
4201
+ </xsl:when>
4202
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
4203
+ </xsl:choose>
4204
+
4205
+
4206
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths">
4207
+ <xsl:copy>
4208
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths"/>
4209
+ </xsl:copy>
4210
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths">
4211
+ <xsl:copy>
4212
+ <xsl:copy-of select="@*"/>
4213
+
4214
+ <!-- The maximum width is given by the widest line. -->
4215
+ <xsl:variable name="widths_max">
4216
+ <xsl:for-each select=".//*[local-name() = 'p']">
4217
+ <xsl:call-template name="add_width"/>
4218
+ </xsl:for-each>
4219
+ <xsl:if test="not(*[local-name() = 'p'])">
4220
+ <xsl:call-template name="add_width"/>
4221
+ </xsl:if>
4222
+ </xsl:variable>
4223
+ <xsl:variable name="width_max">
4224
+ <xsl:for-each select="xalan:nodeset($widths_max)//width">
4225
+ <xsl:sort select="." data-type="number" order="descending"/>
4226
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4227
+ </xsl:for-each>
4228
+ </xsl:variable>
4229
+ <xsl:attribute name="width_max">
4230
+ <xsl:value-of select="$width_max"/>
4231
+ </xsl:attribute>
4232
+
4233
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4234
+ <!-- To do: image width -->
4235
+ <xsl:variable name="td_text">
4236
+ <xsl:apply-templates select="." mode="td_text"/>
4237
+ </xsl:variable>
4238
+ <xsl:variable name="words">
4239
+ <xsl:variable name="string_with_added_zerospaces">
4240
+ <xsl:call-template name="add-zero-spaces-java">
4241
+ <xsl:with-param name="text" select="$td_text"/>
4242
+ </xsl:call-template>
4243
+ </xsl:variable>
4244
+ <xsl:call-template name="tokenize">
4245
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
4246
+ </xsl:call-template>
4247
+ </xsl:variable>
4248
+
4249
+ <xsl:variable name="max_word_length">
4250
+ <xsl:call-template name="max_length">
4251
+ <xsl:with-param name="words" select="xalan:nodeset($words)"/>
4252
+ </xsl:call-template>
4253
+ </xsl:variable>
4254
+ <xsl:variable name="width_min">
4255
+ <xsl:value-of select="$max_word_length"/>
4256
+ </xsl:variable>
4257
+ <xsl:attribute name="width_min">
4258
+ <xsl:value-of select="$width_min"/>
4259
+ </xsl:attribute>
4260
+ <!-- width_max="1" width_min="1.5"> --> <!-- see 'tokenize' template, multiply 1.5 for all latin capitals -->
4261
+ <xsl:if test="$width_min &gt; $width_max">
4262
+ <xsl:attribute name="width_max">
4263
+ <xsl:value-of select="$width_min"/>
4264
+ </xsl:attribute>
4265
+ </xsl:if>
4266
+ <xsl:if test="$width_min = 0">
4267
+ <xsl:attribute name="width_min">1</xsl:attribute>
4268
+ </xsl:if>
4269
+
4270
+ <xsl:apply-templates select="node()" mode="determine_cell_widths"/>
4271
+
4272
+ </xsl:copy>
4273
+ </xsl:template><xsl:template name="add_width">
4274
+ <xsl:variable name="p_text"><xsl:apply-templates select="." mode="td_text"/></xsl:variable>
4275
+ <xsl:variable name="p_text_len_" select="string-length(normalize-space($p_text))"/>
4276
+
4277
+ <xsl:variable name="p_text_len">
4278
+ <xsl:choose>
4279
+ <xsl:when test="normalize-space(translate($p_text, concat($upper,'0123456789'), '')) = ''"> <!-- english word in CAPITAL letters -->
4280
+ <xsl:value-of select="$p_text_len_ * 1.5"/>
4281
+ </xsl:when>
4282
+ <xsl:otherwise><xsl:value-of select="$p_text_len_"/></xsl:otherwise>
4283
+ </xsl:choose>
4284
+ </xsl:variable>
4285
+
4286
+ <xsl:variable name="math_addon_text">
4287
+ <xsl:for-each select=".//*[local-name() = 'math']">
4288
+ <xsl:apply-templates mode="td_text"/>
3914
4289
  </xsl:for-each>
3915
4290
  </xsl:variable>
4291
+ <xsl:variable name="math_addon_length" select="string-length(normalize-space($math_addon_text)) * 0.2"/> <!-- plus 20% -->
3916
4292
 
3917
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3918
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4293
+ <width><xsl:value-of select="$p_text_len + $math_addon_length"/></width>
4294
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
4295
+ <xsl:copy>
4296
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
4297
+ </xsl:copy>
4298
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
4299
+ <xsl:copy>
4300
+ <xsl:copy-of select="@*"/>
4301
+
4302
+ <!-- The maximum width is given by the widest line. -->
4303
+ <xsl:attribute name="width_max">
4304
+ <xsl:for-each select="p_len">
4305
+ <xsl:sort select="." data-type="number" order="descending"/>
4306
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4307
+ </xsl:for-each>
4308
+ </xsl:attribute>
4309
+
4310
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4311
+ <xsl:variable name="width_min">
4312
+ <xsl:for-each select="word_len">
4313
+ <xsl:sort select="." data-type="number" order="descending"/>
4314
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4315
+ </xsl:for-each>
4316
+ </xsl:variable>
4317
+ <xsl:attribute name="width_min">
4318
+ <xsl:value-of select="$width_min"/>
4319
+ </xsl:attribute>
4320
+
4321
+ <xsl:if test="$width_min = 0">
4322
+ <xsl:attribute name="width_min">1</xsl:attribute>
4323
+ </xsl:if>
4324
+
4325
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
4326
+
4327
+ </xsl:copy>
3919
4328
  </xsl:template><xsl:template match="*[local-name()='thead']">
3920
4329
  <xsl:param name="cols-count"/>
3921
4330
  <fo:table-header>
@@ -4013,6 +4422,7 @@
4013
4422
  </xsl:for-each>
4014
4423
  </xsl:when>
4015
4424
  <xsl:otherwise>
4425
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
4016
4426
  <xsl:call-template name="insertTableColumnWidth">
4017
4427
  <xsl:with-param name="colwidths" select="$colwidths"/>
4018
4428
  </xsl:call-template>
@@ -4137,6 +4547,52 @@
4137
4547
 
4138
4548
  </fo:table-body>
4139
4549
 
4550
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4551
+ <xsl:param name="table_or_dl">table</xsl:param>
4552
+ <xsl:apply-templates mode="process_table-if">
4553
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4554
+ </xsl:apply-templates>
4555
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4556
+ <xsl:param name="table_or_dl">table</xsl:param>
4557
+
4558
+ <fo:table-body>
4559
+ <xsl:for-each select="*[local-name() = 'tr']">
4560
+ <xsl:variable name="col_count" select="count(*)"/>
4561
+
4562
+ <!-- iteration for each tr/td -->
4563
+
4564
+ <xsl:choose>
4565
+ <xsl:when test="$table_or_dl = 'table'">
4566
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4567
+ <fo:table-row number-columns-spanned="{$col_count}">
4568
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4569
+ <xsl:call-template name="td"/>
4570
+ </fo:table-row>
4571
+ </xsl:for-each>
4572
+ </xsl:when>
4573
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4574
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4575
+ <xsl:variable name="is_dt" select="position() = 1"/>
4576
+
4577
+ <xsl:for-each select="*">
4578
+ <!-- <test><xsl:copy-of select="."/></test> -->
4579
+ <fo:table-row number-columns-spanned="{$col_count}">
4580
+ <xsl:choose>
4581
+ <xsl:when test="$is_dt">
4582
+ <xsl:call-template name="insert_dt_cell"/>
4583
+ </xsl:when>
4584
+ <xsl:otherwise>
4585
+ <xsl:call-template name="insert_dd_cell"/>
4586
+ </xsl:otherwise>
4587
+ </xsl:choose>
4588
+ </fo:table-row>
4589
+ </xsl:for-each>
4590
+ </xsl:for-each>
4591
+ </xsl:otherwise>
4592
+ </xsl:choose>
4593
+
4594
+ </xsl:for-each>
4595
+ </fo:table-body>
4140
4596
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4141
4597
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4142
4598
 
@@ -4234,7 +4690,7 @@
4234
4690
  </xsl:choose>
4235
4691
  </xsl:attribute>
4236
4692
  </xsl:if>
4237
- </xsl:template><xsl:template match="*[local-name()='td']">
4693
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
4238
4694
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
4239
4695
  <xsl:call-template name="setTextAlignment">
4240
4696
  <xsl:with-param name="default">left</xsl:with-param>
@@ -4272,11 +4728,24 @@
4272
4728
 
4273
4729
  <xsl:call-template name="setTableCellAttributes"/>
4274
4730
 
4731
+ <xsl:if test="$isGenerateTableIF = 'true'">
4732
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4733
+ <xsl:attribute name="text-align">left</xsl:attribute>
4734
+ </xsl:if>
4735
+
4275
4736
  <fo:block>
4276
4737
 
4738
+ <xsl:if test="$isGenerateTableIF = 'true'">
4739
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4740
+ </xsl:if>
4741
+
4742
+
4277
4743
 
4278
4744
 
4279
4745
  <xsl:apply-templates/>
4746
+
4747
+ <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"/> -->
4748
+
4280
4749
  </fo:block>
4281
4750
  </fo:table-cell>
4282
4751
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -4475,9 +4944,9 @@
4475
4944
  <!-- current hierarchy is 'figure' element -->
4476
4945
  <xsl:variable name="following_dl_colwidths">
4477
4946
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4478
- <xsl:variable name="html-table">
4479
- <xsl:variable name="doc_ns">
4480
-
4947
+ <xsl:variable name="simple-table">
4948
+ <!-- <xsl:variable name="doc_ns">
4949
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4481
4950
  </xsl:variable>
4482
4951
  <xsl:variable name="ns">
4483
4952
  <xsl:choose>
@@ -4488,7 +4957,7 @@
4488
4957
  <xsl:value-of select="substring-before(name(/*), '-')"/>
4489
4958
  </xsl:otherwise>
4490
4959
  </xsl:choose>
4491
- </xsl:variable>
4960
+ </xsl:variable> -->
4492
4961
 
4493
4962
  <xsl:for-each select="*[local-name() = 'dl'][1]">
4494
4963
  <tbody>
@@ -4499,7 +4968,7 @@
4499
4968
 
4500
4969
  <xsl:call-template name="calculate-column-widths">
4501
4970
  <xsl:with-param name="cols-count" select="2"/>
4502
- <xsl:with-param name="table" select="$html-table"/>
4971
+ <xsl:with-param name="table" select="$simple-table"/>
4503
4972
  </xsl:call-template>
4504
4973
 
4505
4974
  </xsl:if>
@@ -4698,7 +5167,18 @@
4698
5167
 
4699
5168
 
4700
5169
 
5170
+
5171
+ <xsl:if test="$isGenerateTableIF = 'true'">
5172
+ <!-- to determine start of table -->
5173
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
5174
+ </xsl:if>
5175
+
4701
5176
  <fo:table width="95%" table-layout="fixed">
5177
+
5178
+ <xsl:if test="$isGenerateTableIF = 'true'">
5179
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
5180
+ </xsl:if>
5181
+
4702
5182
 
4703
5183
  <xsl:choose>
4704
5184
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4707,55 +5187,132 @@
4707
5187
 
4708
5188
  </xsl:when>
4709
5189
  </xsl:choose>
4710
- <!-- create virtual html table for dl/[dt and dd] -->
4711
- <xsl:variable name="html-table">
4712
- <xsl:variable name="doc_ns">
5190
+
5191
+
5192
+ <xsl:choose>
5193
+ <xsl:when test="$isGenerateTableIF = 'true'">
5194
+ <!-- generate IF for table widths -->
5195
+ <!-- example:
5196
+ <tr>
5197
+ <td valign="top" align="left" id="tab-symdu_1_1">
5198
+ <p>Symbol</p>
5199
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
5200
+ </td>
5201
+ <td valign="top" align="left" id="tab-symdu_1_2">
5202
+ <p>Description</p>
5203
+ <word id="tab-symdu_1_2_word_1">Description</word>
5204
+ </td>
5205
+ </tr>
5206
+ -->
4713
5207
 
4714
- </xsl:variable>
4715
- <xsl:variable name="ns">
4716
- <xsl:choose>
4717
- <xsl:when test="normalize-space($doc_ns) != ''">
4718
- <xsl:value-of select="normalize-space($doc_ns)"/>
4719
- </xsl:when>
4720
- <xsl:otherwise>
4721
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4722
- </xsl:otherwise>
4723
- </xsl:choose>
4724
- </xsl:variable>
4725
- <tbody>
4726
- <xsl:apply-templates mode="dl"/>
4727
- </tbody>
4728
- </xsl:variable>
4729
- <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
4730
- <xsl:variable name="colwidths">
4731
- <xsl:call-template name="calculate-column-widths">
4732
- <xsl:with-param name="cols-count" select="2"/>
4733
- <xsl:with-param name="table" select="$html-table"/>
4734
- </xsl:call-template>
4735
- </xsl:variable>
4736
- <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
4737
- <xsl:variable name="maxlength_dt">
4738
- <xsl:call-template name="getMaxLength_dt"/>
4739
- </xsl:variable>
4740
- <xsl:variable name="isContainsKeepTogetherTag_">
4741
-
4742
- <!-- <xsl:value-of select="count(.//*[local-name() = 'strong'][translate(., $express_reference_characters, '') = '']) &gt; 0"/> -->
4743
- <xsl:value-of select="count(.//*[local-name() = $element_name_keep-together_within-line]) &gt; 0"/>
5208
+ <!-- create virtual html table for dl/[dt and dd] -->
5209
+ <xsl:variable name="simple-table">
5210
+
5211
+ <xsl:variable name="dl_table">
5212
+ <tbody>
5213
+ <xsl:apply-templates mode="dl_if">
5214
+ <xsl:with-param name="id" select="@id"/>
5215
+ </xsl:apply-templates>
5216
+ </tbody>
5217
+ </xsl:variable>
5218
+
5219
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
5220
+
5221
+ <!-- Step: replace <br/> to <p>...</p> -->
5222
+ <xsl:variable name="table_without_br">
5223
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
5224
+ </xsl:variable>
5225
+
5226
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
5227
+
5228
+ <!-- Step: add id to each cell -->
5229
+ <!-- add <word>...</word> for each word, image, math -->
5230
+ <xsl:variable name="simple-table-id">
5231
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
5232
+ <xsl:with-param name="id" select="@id"/>
5233
+ </xsl:apply-templates>
5234
+ </xsl:variable>
5235
+
5236
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
5237
+
5238
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5239
+
5240
+ </xsl:variable>
4744
5241
 
4745
- </xsl:variable>
4746
- <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4747
- <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4748
- <xsl:call-template name="setColumnWidth_dl">
4749
- <xsl:with-param name="colwidths" select="$colwidths"/>
4750
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4751
- <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4752
- </xsl:call-template>
5242
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
5243
+
5244
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
5245
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
5246
+ </xsl:apply-templates>
5247
+
5248
+ </xsl:when>
5249
+ <xsl:otherwise>
4753
5250
 
4754
- <fo:table-body>
4755
- <xsl:apply-templates>
4756
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4757
- </xsl:apply-templates>
4758
- </fo:table-body>
5251
+ <xsl:variable name="simple-table">
5252
+
5253
+ <xsl:variable name="dl_table">
5254
+ <tbody>
5255
+ <xsl:apply-templates mode="dl">
5256
+ <xsl:with-param name="id" select="@id"/>
5257
+ </xsl:apply-templates>
5258
+ </tbody>
5259
+ </xsl:variable>
5260
+
5261
+ <xsl:copy-of select="$dl_table"/>
5262
+ </xsl:variable>
5263
+
5264
+ <xsl:variable name="colwidths">
5265
+ <xsl:call-template name="calculate-column-widths">
5266
+ <xsl:with-param name="cols-count" select="2"/>
5267
+ <xsl:with-param name="table" select="$simple-table"/>
5268
+ </xsl:call-template>
5269
+ </xsl:variable>
5270
+
5271
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
5272
+ DEBUG
5273
+ colwidths=<xsl:copy-of select="$colwidths"/>
5274
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
5275
+
5276
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
5277
+
5278
+ <xsl:variable name="maxlength_dt">
5279
+ <xsl:call-template name="getMaxLength_dt"/>
5280
+ </xsl:variable>
5281
+
5282
+ <xsl:variable name="isContainsKeepTogetherTag_">
5283
+
5284
+ <xsl:value-of select="count(.//*[local-name() = $element_name_keep-together_within-line]) &gt; 0"/>
5285
+
5286
+ </xsl:variable>
5287
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
5288
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
5289
+
5290
+
5291
+ <xsl:call-template name="setColumnWidth_dl">
5292
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5293
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5294
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
5295
+ </xsl:call-template>
5296
+
5297
+ <fo:table-body>
5298
+
5299
+ <!-- DEBUG -->
5300
+ <xsl:if test="$table_if_debug = 'true'">
5301
+ <fo:table-row>
5302
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
5303
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5304
+ </fo:table-cell>
5305
+ </fo:table-row>
5306
+ </xsl:if>
5307
+
5308
+ <xsl:apply-templates>
5309
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
5310
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
5311
+ </xsl:apply-templates>
5312
+
5313
+ </fo:table-body>
5314
+ </xsl:otherwise>
5315
+ </xsl:choose>
4759
5316
  </fo:table>
4760
5317
  </fo:block>
4761
5318
  </fo:block>
@@ -4766,6 +5323,9 @@
4766
5323
  <xsl:param name="colwidths"/>
4767
5324
  <xsl:param name="maxlength_dt"/>
4768
5325
  <xsl:param name="isContainsKeepTogetherTag"/>
5326
+
5327
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
5328
+
4769
5329
  <xsl:choose>
4770
5330
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4771
5331
  <fo:table-column column-width="50%"/>
@@ -4773,6 +5333,11 @@
4773
5333
  </xsl:when>
4774
5334
  <xsl:otherwise>
4775
5335
  <xsl:choose>
5336
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5337
+ <xsl:call-template name="insertTableColumnWidth">
5338
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5339
+ </xsl:call-template>
5340
+ </xsl:when>
4776
5341
  <xsl:when test="$isContainsKeepTogetherTag">
4777
5342
  <xsl:call-template name="insertTableColumnWidth">
4778
5343
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4817,13 +5382,19 @@
4817
5382
  </xsl:choose>
4818
5383
  </xsl:template><xsl:template name="insertTableColumnWidth">
4819
5384
  <xsl:param name="colwidths"/>
5385
+
4820
5386
  <xsl:for-each select="xalan:nodeset($colwidths)//column">
4821
5387
  <xsl:choose>
4822
5388
  <xsl:when test=". = 1 or . = 0">
4823
5389
  <fo:table-column column-width="proportional-column-width(2)"/>
4824
5390
  </xsl:when>
4825
5391
  <xsl:otherwise>
4826
- <fo:table-column column-width="proportional-column-width({.})"/>
5392
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
5393
+ <xsl:variable name="divider">
5394
+ <xsl:value-of select="@divider"/>
5395
+ <xsl:if test="not(@divider)">1</xsl:if>
5396
+ </xsl:variable>
5397
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4827
5398
  </xsl:otherwise>
4828
5399
  </xsl:choose>
4829
5400
  </xsl:for-each>
@@ -4885,11 +5456,19 @@
4885
5456
  </fo:table-cell>
4886
5457
  </fo:table-row>
4887
5458
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
5459
+ <xsl:param name="id"/>
5460
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4888
5461
  <tr>
4889
5462
  <td>
5463
+ <xsl:attribute name="id">
5464
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5465
+ </xsl:attribute>
4890
5466
  <xsl:apply-templates/>
4891
5467
  </td>
4892
5468
  <td>
5469
+ <xsl:attribute name="id">
5470
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5471
+ </xsl:attribute>
4893
5472
 
4894
5473
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4895
5474
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4900,50 +5479,122 @@
4900
5479
 
4901
5480
  </xsl:template><xsl:template match="*[local-name()='dt']">
4902
5481
  <xsl:param name="key_iso"/>
5482
+ <xsl:param name="split_keep-within-line"/>
4903
5483
 
4904
5484
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4905
- <fo:table-cell>
5485
+ <xsl:call-template name="insert_dt_cell">
5486
+ <xsl:with-param name="key_iso" select="$key_iso"/>
5487
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5488
+ </xsl:call-template>
5489
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
5490
+ <xsl:call-template name="insert_dd_cell">
5491
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5492
+ </xsl:call-template>
5493
+ </xsl:for-each>
5494
+ </fo:table-row>
5495
+ </xsl:template><xsl:template name="insert_dt_cell">
5496
+ <xsl:param name="key_iso"/>
5497
+ <xsl:param name="split_keep-within-line"/>
5498
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
5499
+
5500
+ <xsl:if test="$isGenerateTableIF = 'true'">
5501
+ <!-- border is mandatory, to calculate real width -->
5502
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5503
+ <xsl:attribute name="text-align">left</xsl:attribute>
5504
+ </xsl:if>
5505
+
5506
+
5507
+ <fo:block xsl:use-attribute-sets="dt-block-style">
5508
+ <xsl:copy-of select="@id"/>
5509
+
5510
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5511
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5512
+ </xsl:if>
5513
+
5514
+
5515
+
5516
+ <xsl:apply-templates>
5517
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5518
+ </xsl:apply-templates>
5519
+
5520
+ <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"/> -->
5521
+
5522
+ </fo:block>
5523
+ </fo:table-cell>
5524
+ </xsl:template><xsl:template name="insert_dd_cell">
5525
+ <xsl:param name="split_keep-within-line"/>
5526
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5527
+
5528
+ <xsl:if test="$isGenerateTableIF = 'true'">
5529
+ <!-- border is mandatory, to calculate real width -->
5530
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5531
+ </xsl:if>
5532
+
5533
+ <fo:block>
5534
+
5535
+ <xsl:if test="$isGenerateTableIF = 'true'">
5536
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5537
+ </xsl:if>
5538
+
4906
5539
 
4907
- <fo:block xsl:use-attribute-sets="dt-style">
4908
- <xsl:copy-of select="@id"/>
4909
-
4910
- <xsl:if test="normalize-space($key_iso) = 'true'">
4911
- <xsl:attribute name="margin-top">0</xsl:attribute>
4912
- </xsl:if>
4913
-
4914
-
4915
-
4916
- <xsl:apply-templates/>
4917
- </fo:block>
4918
- </fo:table-cell>
4919
- <fo:table-cell>
4920
- <fo:block>
4921
-
4922
5540
 
4923
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4924
- <xsl:with-param name="process">true</xsl:with-param>
4925
- </xsl:apply-templates>
4926
- </fo:block>
4927
- </fo:table-cell>
4928
- </fo:table-row>
5541
+ <xsl:choose>
5542
+ <xsl:when test="$isGenerateTableIF = 'true'">
5543
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5544
+ <xsl:with-param name="process">true</xsl:with-param>
5545
+ </xsl:apply-templates>
5546
+ </xsl:when>
5547
+ <xsl:otherwise>
5548
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5549
+ <xsl:with-param name="process">true</xsl:with-param>
5550
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5551
+ </xsl:apply-templates>
5552
+ </xsl:otherwise>
5553
+
5554
+ </xsl:choose>
5555
+
5556
+ <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"/> -->
5557
+
5558
+ </fo:block>
5559
+ </fo:table-cell>
4929
5560
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4930
5561
  <xsl:apply-templates/>
4931
5562
  </xsl:template><xsl:template match="*[local-name()='dd']">
4932
5563
  <xsl:param name="process">false</xsl:param>
5564
+ <xsl:param name="split_keep-within-line"/>
4933
5565
  <xsl:if test="$process = 'true'">
4934
5566
  <xsl:apply-templates select="@language"/>
4935
- <xsl:apply-templates/>
5567
+ <xsl:apply-templates>
5568
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5569
+ </xsl:apply-templates>
4936
5570
  </xsl:if>
4937
5571
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4938
5572
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4939
- </xsl:template><xsl:template match="*[local-name()='em']">
5573
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5574
+ <xsl:param name="id"/>
5575
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5576
+ <tr>
5577
+ <td>
5578
+ <xsl:copy-of select="node()"/>
5579
+ </td>
5580
+ <td>
5581
+
5582
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()"/>
5583
+
5584
+ </td>
5585
+ </tr>
5586
+
5587
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='em']">
4940
5588
  <fo:inline font-style="italic">
4941
5589
  <xsl:apply-templates/>
4942
5590
  </fo:inline>
4943
5591
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5592
+ <xsl:param name="split_keep-within-line"/>
4944
5593
  <fo:inline font-weight="bold">
4945
5594
 
4946
- <xsl:apply-templates/>
5595
+ <xsl:apply-templates>
5596
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5597
+ </xsl:apply-templates>
4947
5598
  </fo:inline>
4948
5599
  </xsl:template><xsl:template match="*[local-name()='padding']">
4949
5600
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -5144,6 +5795,10 @@
5144
5795
  <xsl:param name="text"/>
5145
5796
  <xsl:param name="separator" select="' '"/>
5146
5797
  <xsl:choose>
5798
+
5799
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5800
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5801
+ </xsl:when>
5147
5802
  <xsl:when test="not(contains($text, $separator))">
5148
5803
  <word>
5149
5804
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
@@ -5188,13 +5843,66 @@
5188
5843
  </xsl:when>
5189
5844
  <xsl:otherwise>
5190
5845
  <word>
5191
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5846
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5847
+ <xsl:choose>
5848
+ <xsl:when test="$isGenerateTableIF = 'true'">
5849
+ <xsl:value-of select="$word"/>
5850
+ </xsl:when>
5851
+ <xsl:otherwise>
5852
+ <xsl:value-of select="string-length($word)"/>
5853
+ </xsl:otherwise>
5854
+ </xsl:choose>
5192
5855
  </word>
5193
5856
  <xsl:call-template name="tokenize">
5194
5857
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5195
5858
  </xsl:call-template>
5196
5859
  </xsl:otherwise>
5197
5860
  </xsl:choose>
5861
+ </xsl:template><xsl:template name="tokenize_with_tags">
5862
+ <xsl:param name="tags"/>
5863
+ <xsl:param name="text"/>
5864
+ <xsl:param name="separator" select="' '"/>
5865
+ <xsl:choose>
5866
+
5867
+ <xsl:when test="not(contains($text, $separator))">
5868
+ <word>
5869
+ <xsl:call-template name="enclose_text_in_tags">
5870
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5871
+ <xsl:with-param name="tags" select="$tags"/>
5872
+ </xsl:call-template>
5873
+ </word>
5874
+ </xsl:when>
5875
+ <xsl:otherwise>
5876
+ <word>
5877
+ <xsl:call-template name="enclose_text_in_tags">
5878
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5879
+ <xsl:with-param name="tags" select="$tags"/>
5880
+ </xsl:call-template>
5881
+ </word>
5882
+ <xsl:call-template name="tokenize_with_tags">
5883
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5884
+ </xsl:call-template>
5885
+ </xsl:otherwise>
5886
+ </xsl:choose>
5887
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5888
+ <xsl:param name="text"/>
5889
+ <xsl:param name="tags"/>
5890
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5891
+
5892
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5893
+
5894
+ <xsl:choose>
5895
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5896
+ <xsl:otherwise>
5897
+ <xsl:element name="{$tag_name}">
5898
+ <xsl:call-template name="enclose_text_in_tags">
5899
+ <xsl:with-param name="text" select="$text"/>
5900
+ <xsl:with-param name="tags" select="$tags"/>
5901
+ <xsl:with-param name="num" select="$num + 1"/>
5902
+ </xsl:call-template>
5903
+ </xsl:element>
5904
+ </xsl:otherwise>
5905
+ </xsl:choose>
5198
5906
  </xsl:template><xsl:template name="max_length">
5199
5907
  <xsl:param name="words"/>
5200
5908
  <xsl:for-each select="$words//word">
@@ -5295,12 +6003,19 @@
5295
6003
  </xsl:otherwise>
5296
6004
  </xsl:choose>
5297
6005
  </xsl:template><xsl:template name="getSimpleTable">
6006
+ <xsl:param name="id"/>
6007
+
5298
6008
  <xsl:variable name="simple-table">
5299
6009
 
6010
+ <!-- Step 0. replace <br/> to <p>...</p> -->
6011
+ <xsl:variable name="table_without_br">
6012
+ <xsl:apply-templates mode="table-without-br"/>
6013
+ </xsl:variable>
6014
+
5300
6015
  <!-- Step 1. colspan processing -->
5301
6016
  <xsl:variable name="simple-table-colspan">
5302
6017
  <tbody>
5303
- <xsl:apply-templates mode="simple-table-colspan"/>
6018
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
5304
6019
  </tbody>
5305
6020
  </xsl:variable>
5306
6021
 
@@ -5309,10 +6024,67 @@
5309
6024
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
5310
6025
  </xsl:variable>
5311
6026
 
5312
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
5313
-
6027
+ <!-- Step 3: add id to each cell -->
6028
+ <!-- add <word>...</word> for each word, image, math -->
6029
+ <xsl:variable name="simple-table-id">
6030
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
6031
+ <xsl:with-param name="id" select="$id"/>
6032
+ </xsl:apply-templates>
6033
+ </xsl:variable>
6034
+
6035
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
6036
+
5314
6037
  </xsl:variable>
5315
6038
  <xsl:copy-of select="$simple-table"/>
6039
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
6040
+ <xsl:copy>
6041
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
6042
+ </xsl:copy>
6043
+ </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">
6044
+ <xsl:copy>
6045
+ <xsl:copy-of select="@*"/>
6046
+ <p>
6047
+ <xsl:copy-of select="node()"/>
6048
+ </p>
6049
+ </xsl:copy>
6050
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
6051
+ <xsl:copy>
6052
+ <xsl:copy-of select="@*"/>
6053
+ <xsl:for-each select="*[local-name()='br']">
6054
+ <xsl:variable name="current_id" select="generate-id()"/>
6055
+ <p>
6056
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6057
+ <xsl:copy-of select="."/>
6058
+ </xsl:for-each>
6059
+ </p>
6060
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6061
+ <p>
6062
+ <xsl:for-each select="following-sibling::node()">
6063
+ <xsl:copy-of select="."/>
6064
+ </xsl:for-each>
6065
+ </p>
6066
+ </xsl:if>
6067
+ </xsl:for-each>
6068
+ </xsl:copy>
6069
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
6070
+ <xsl:for-each select="*[local-name()='br']">
6071
+ <xsl:variable name="current_id" select="generate-id()"/>
6072
+ <p>
6073
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6074
+ <xsl:copy-of select="."/>
6075
+ </xsl:for-each>
6076
+ </p>
6077
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6078
+ <p>
6079
+ <xsl:for-each select="following-sibling::node()">
6080
+ <xsl:copy-of select="."/>
6081
+ </xsl:for-each>
6082
+ </p>
6083
+ </xsl:if>
6084
+ </xsl:for-each>
6085
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
6086
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
6087
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
5316
6088
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
5317
6089
  <xsl:apply-templates mode="simple-table-colspan"/>
5318
6090
  </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">
@@ -5402,6 +6174,126 @@
5402
6174
  <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5403
6175
  <xsl:with-param name="previousRow" select="$newRow"/>
5404
6176
  </xsl:apply-templates>
6177
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
6178
+ <xsl:param name="id"/>
6179
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
6180
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6181
+ <xsl:with-param name="id" select="$id_prefixed"/>
6182
+ </xsl:apply-templates>
6183
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
6184
+ <xsl:param name="id"/>
6185
+ <xsl:copy>
6186
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6187
+ <xsl:with-param name="id" select="$id"/>
6188
+ </xsl:apply-templates>
6189
+ </xsl:copy>
6190
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
6191
+ <xsl:param name="id"/>
6192
+ <xsl:copy>
6193
+ <xsl:copy-of select="@*"/>
6194
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
6195
+ <xsl:apply-templates select="node()" mode="simple-table-id">
6196
+ <xsl:with-param name="id" select="$id"/>
6197
+ </xsl:apply-templates>
6198
+ </xsl:copy>
6199
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
6200
+ <xsl:param name="id"/>
6201
+ <xsl:copy>
6202
+ <xsl:copy-of select="@*"/>
6203
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
6204
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
6205
+ <xsl:attribute name="id">
6206
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
6207
+ </xsl:attribute>
6208
+
6209
+ <xsl:for-each select="*[local-name() = 'p']">
6210
+ <xsl:copy>
6211
+ <xsl:copy-of select="@*"/>
6212
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
6213
+ <xsl:attribute name="id">
6214
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
6215
+ </xsl:attribute>
6216
+
6217
+ <xsl:copy-of select="node()"/>
6218
+ </xsl:copy>
6219
+ </xsl:for-each>
6220
+
6221
+
6222
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
6223
+
6224
+ <xsl:variable name="td_text">
6225
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
6226
+ </xsl:variable>
6227
+
6228
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
6229
+
6230
+ <xsl:variable name="words">
6231
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
6232
+ <word>
6233
+ <xsl:copy-of select="."/>
6234
+ </word>
6235
+ </xsl:for-each>
6236
+
6237
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
6238
+ <xsl:copy-of select="."/>
6239
+ </xsl:for-each>
6240
+
6241
+ </xsl:variable>
6242
+
6243
+ <xsl:for-each select="xalan:nodeset($words)/word">
6244
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
6245
+ <xsl:copy>
6246
+ <xsl:attribute name="id">
6247
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
6248
+ </xsl:attribute>
6249
+ <xsl:copy-of select="node()"/>
6250
+ </xsl:copy>
6251
+ </xsl:for-each>
6252
+ </xsl:if>
6253
+ </xsl:copy>
6254
+
6255
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
6256
+ <xsl:copy>
6257
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
6258
+ </xsl:copy>
6259
+ </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">
6260
+ <xsl:variable name="formatting_tags">
6261
+ <xsl:call-template name="getFormattingTags"/>
6262
+ </xsl:variable>
6263
+ <word>
6264
+ <xsl:call-template name="enclose_text_in_tags">
6265
+ <xsl:with-param name="text" select="normalize-space(.)"/>
6266
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6267
+ </xsl:call-template>
6268
+ </word>
6269
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
6270
+
6271
+ <xsl:variable name="td_text" select="."/>
6272
+
6273
+ <xsl:variable name="string_with_added_zerospaces">
6274
+ <xsl:call-template name="add-zero-spaces-java">
6275
+ <xsl:with-param name="text" select="$td_text"/>
6276
+ </xsl:call-template>
6277
+ </xsl:variable>
6278
+
6279
+ <xsl:variable name="formatting_tags">
6280
+ <xsl:call-template name="getFormattingTags"/>
6281
+ </xsl:variable>
6282
+
6283
+ <!-- <word>text</word> -->
6284
+ <xsl:call-template name="tokenize_with_tags">
6285
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6286
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
6287
+ </xsl:call-template>
6288
+ </xsl:template><xsl:template name="getFormattingTags">
6289
+ <tags>
6290
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
6291
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
6292
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6293
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6294
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6295
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6296
+ </tags>
5405
6297
  </xsl:template><xsl:template name="getLang">
5406
6298
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5407
6299
  <xsl:variable name="language">
@@ -7100,7 +7992,9 @@
7100
7992
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
7101
7993
  </xsl:if>
7102
7994
  <xsl:variable name="simple-table">
7103
- <xsl:call-template name="getSimpleTable"/>
7995
+ <xsl:call-template name="getSimpleTable">
7996
+ <xsl:with-param name="id" select="@id"/>
7997
+ </xsl:call-template>
7104
7998
  </xsl:variable>
7105
7999
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
7106
8000
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -8054,7 +8948,7 @@
8054
8948
  <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8055
8949
  <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8056
8950
  <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8057
- <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
8951
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
8058
8952
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
8059
8953
  <!-- <row>
8060
8954
  <date>05-07-2013</date>
@@ -9461,4 +10355,40 @@
9461
10355
  <xsl:value-of select="$value"/>
9462
10356
  </xsl:otherwise>
9463
10357
  </xsl:choose>
10358
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
10359
+ <xsl:param name="level">0</xsl:param>
10360
+
10361
+ <fo:block margin-left="{2*$level}mm">
10362
+ <xsl:text>
10363
+ &lt;</xsl:text>
10364
+ <xsl:value-of select="local-name()"/>
10365
+ <xsl:for-each select="@*">
10366
+ <xsl:text> </xsl:text>
10367
+ <xsl:value-of select="local-name()"/>
10368
+ <xsl:text>="</xsl:text>
10369
+ <xsl:value-of select="."/>
10370
+ <xsl:text>"</xsl:text>
10371
+ </xsl:for-each>
10372
+ <xsl:text>&gt;</xsl:text>
10373
+
10374
+ <xsl:if test="not(*)">
10375
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
10376
+ <xsl:text>&lt;/</xsl:text>
10377
+ <xsl:value-of select="local-name()"/>
10378
+ <xsl:text>&gt;</xsl:text>
10379
+ </xsl:if>
10380
+ </fo:block>
10381
+
10382
+ <xsl:if test="*">
10383
+ <fo:block>
10384
+ <xsl:apply-templates mode="print_as_xml">
10385
+ <xsl:with-param name="level" select="$level + 1"/>
10386
+ </xsl:apply-templates>
10387
+ </fo:block>
10388
+ <fo:block margin-left="{2*$level}mm">
10389
+ <xsl:text>&lt;/</xsl:text>
10390
+ <xsl:value-of select="local-name()"/>
10391
+ <xsl:text>&gt;</xsl:text>
10392
+ </fo:block>
10393
+ </xsl:if>
9464
10394
  </xsl:template></xsl:stylesheet>