metanorma-ogc 2.0.8 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/ogc/biblio.rb +1 -134
  3. data/lib/isodoc/ogc/html/html_ogc_titlepage.html +2 -0
  4. data/lib/isodoc/ogc/html/word_ogc_intro.html +2 -3
  5. data/lib/isodoc/ogc/html/word_ogc_intro_wp.html +1 -2
  6. data/lib/isodoc/ogc/html/word_ogc_titlepage.html +20 -17
  7. data/lib/isodoc/ogc/html/word_ogc_titlepage_wp.html +3 -0
  8. data/lib/isodoc/ogc/init.rb +5 -6
  9. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +1501 -276
  10. data/lib/isodoc/ogc/ogc.best-practice.xsl +1501 -276
  11. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +1501 -276
  12. data/lib/isodoc/ogc/ogc.community-practice.xsl +1501 -276
  13. data/lib/isodoc/ogc/ogc.community-standard.xsl +1501 -276
  14. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +1501 -276
  15. data/lib/isodoc/ogc/ogc.engineering-report.xsl +1501 -276
  16. data/lib/isodoc/ogc/ogc.other.xsl +1501 -276
  17. data/lib/isodoc/ogc/ogc.policy.xsl +1501 -276
  18. data/lib/isodoc/ogc/ogc.reference-model.xsl +1501 -276
  19. data/lib/isodoc/ogc/ogc.release-notes.xsl +1501 -276
  20. data/lib/isodoc/ogc/ogc.standard.xsl +1501 -276
  21. data/lib/isodoc/ogc/ogc.test-suite.xsl +1501 -276
  22. data/lib/isodoc/ogc/ogc.user-guide.xsl +1501 -276
  23. data/lib/isodoc/ogc/ogc.white-paper.xsl +1506 -283
  24. data/lib/isodoc/ogc/presentation_xml_convert.rb +14 -10
  25. data/lib/isodoc/ogc/word_convert.rb +4 -4
  26. data/lib/isodoc/ogc/xref.rb +6 -2
  27. data/lib/metanorma/ogc/biblio.rng +37 -8
  28. data/lib/metanorma/ogc/isodoc.rng +56 -0
  29. data/lib/metanorma/ogc/version.rb +1 -1
  30. data/lib/relaton/render/config.yml +10 -0
  31. data/lib/relaton/render/date.rb +9 -0
  32. data/lib/relaton/render/fields.rb +23 -0
  33. data/lib/relaton/render/general.rb +25 -0
  34. data/lib/relaton/render/parse.rb +11 -0
  35. data/metanorma-ogc.gemspec +1 -1
  36. metadata +9 -4
@@ -295,7 +295,7 @@
295
295
 
296
296
  <fo:block-container absolute-position="fixed" left="16.5mm" top="204mm" height="60mm" width="180mm" display-align="after" font-size="10pt">
297
297
  <fo:block line-height="140%">
298
- <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibdata/ogc:edition"/>
298
+ <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibdata/ogc:edition[normalize-space(@language) = '']"/>
299
299
  <fo:block>
300
300
  <fo:inline font-weight="bold">Submission Date: </fo:inline>
301
301
  <xsl:choose>
@@ -799,12 +799,16 @@
799
799
 
800
800
  <xsl:template match="/ogc:ogc-standard/ogc:bibdata/ogc:edition">
801
801
  <fo:block>
802
- <xsl:variable name="title-edition">
803
- <xsl:call-template name="getTitle">
804
- <xsl:with-param name="name" select="'title-edition'"/>
802
+ <xsl:variable name="title-version">
803
+ <xsl:call-template name="capitalize">
804
+ <xsl:with-param name="str">
805
+ <xsl:call-template name="getLocalizedString">
806
+ <xsl:with-param name="key">version</xsl:with-param>
807
+ </xsl:call-template>
808
+ </xsl:with-param>
805
809
  </xsl:call-template>
806
810
  </xsl:variable>
807
- <fo:inline font-weight="bold"><xsl:value-of select="$title-edition"/><xsl:text>: </xsl:text></fo:inline>
811
+ <fo:inline font-weight="bold"><xsl:value-of select="$title-version"/><xsl:text>: </xsl:text></fo:inline>
808
812
  <xsl:value-of select="."/><xsl:text/>
809
813
  </fo:block>
810
814
  </xsl:template>
@@ -965,6 +969,7 @@
965
969
 
966
970
  <xsl:template match="ogc:p" name="paragraph">
967
971
  <xsl:param name="inline" select="'false'"/>
972
+ <xsl:param name="split_keep-within-line"/>
968
973
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
969
974
  <xsl:variable name="element-name">
970
975
  <xsl:choose>
@@ -995,7 +1000,9 @@
995
1000
  <xsl:attribute name="margin-bottom">4pt</xsl:attribute>
996
1001
  </xsl:if>
997
1002
 
998
- <xsl:apply-templates/>
1003
+ <xsl:apply-templates>
1004
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1005
+ </xsl:apply-templates>
999
1006
  </xsl:element>
1000
1007
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
1001
1008
  <fo:block margin-bottom="12pt">
@@ -1457,7 +1464,9 @@
1457
1464
  </fo:static-content>
1458
1465
  </xsl:template>
1459
1466
 
1460
- <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">
1467
+ <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_">
1468
+ false
1469
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
1461
1470
  <xsl:call-template name="getLang"/>
1462
1471
  </xsl:variable><xsl:variable name="pageWidth_">
1463
1472
  215.9
@@ -1472,20 +1481,7 @@
1472
1481
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1473
1482
  22.5
1474
1483
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1475
-
1476
- <title-edition lang="en">
1477
-
1478
- <xsl:text>Version</xsl:text>
1479
-
1480
- </title-edition>
1481
-
1482
- <title-edition lang="fr">
1483
- <xsl:text>Édition </xsl:text>
1484
- </title-edition>
1485
1484
 
1486
- <title-edition lang="ru">
1487
- <xsl:text>Издание </xsl:text>
1488
- </title-edition>
1489
1485
 
1490
1486
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1491
1487
  <title-toc lang="en">
@@ -1566,7 +1562,7 @@
1566
1562
  </xsl:variable><xsl:variable name="bibdata">
1567
1563
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1568
1564
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1569
- </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">
1565
+ </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">
1570
1566
  <xsl:param name="name"/>
1571
1567
  <xsl:param name="lang"/>
1572
1568
  <xsl:variable name="lang_">
@@ -1615,7 +1611,7 @@
1615
1611
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1616
1612
 
1617
1613
  <xsl:variable name="additional_fonts_">
1618
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
1614
+ <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']">
1619
1615
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1620
1616
  </xsl:for-each>
1621
1617
  </xsl:variable>
@@ -1713,7 +1709,6 @@
1713
1709
 
1714
1710
 
1715
1711
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1716
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
1717
1712
 
1718
1713
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
1719
1714
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -1838,6 +1833,7 @@
1838
1833
 
1839
1834
 
1840
1835
 
1836
+
1841
1837
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
1842
1838
 
1843
1839
 
@@ -1994,6 +1990,7 @@
1994
1990
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1995
1991
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1996
1992
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1993
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1997
1994
  <xsl:attribute name="display-align">center</xsl:attribute>
1998
1995
 
1999
1996
 
@@ -2014,6 +2011,7 @@
2014
2011
  <xsl:attribute name="display-align">center</xsl:attribute>
2015
2012
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2016
2013
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2014
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2017
2015
 
2018
2016
 
2019
2017
 
@@ -2106,7 +2104,8 @@
2106
2104
  <xsl:attribute name="min-height">8.5mm</xsl:attribute>
2107
2105
 
2108
2106
 
2109
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2107
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2108
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2110
2109
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2111
2110
 
2112
2111
 
@@ -2121,6 +2120,8 @@
2121
2120
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2122
2121
 
2123
2122
 
2123
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2124
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2124
2125
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2125
2126
 
2126
2127
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -2959,22 +2960,32 @@
2959
2960
  <xsl:sort select="@displayorder" data-type="number"/>
2960
2961
  <xsl:apply-templates select="."/>
2961
2962
  </xsl:for-each>
2962
- </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">
2963
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2964
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2965
- <xsl:call-template name="replace_fo_inline">
2966
- <xsl:with-param name="text" select="$text"/>
2967
- </xsl:call-template>
2968
- </xsl:template><xsl:template name="replace_fo_inline">
2963
+ </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">
2964
+
2965
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2966
+ <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))"/>
2967
+ <xsl:call-template name="replace_fo_inline_tags">
2968
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
2969
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
2970
+ <xsl:with-param name="text" select="$text"/>
2971
+ </xsl:call-template>
2972
+
2973
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
2974
+ <xsl:param name="tag_open"/>
2975
+ <xsl:param name="tag_close"/>
2969
2976
  <xsl:param name="text"/>
2970
2977
  <xsl:choose>
2971
2978
  <xsl:when test="contains($text, $tag_open)">
2972
2979
  <xsl:value-of select="substring-before($text, $tag_open)"/>
2973
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2980
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
2974
2981
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2975
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2976
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2977
- <xsl:call-template name="replace_fo_inline">
2982
+ <fo:inline keep-together.within-line="always">
2983
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2984
+ </fo:inline>
2985
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
2986
+ <xsl:call-template name="replace_fo_inline_tags">
2987
+ <xsl:with-param name="tag_open" select="$tag_open"/>
2988
+ <xsl:with-param name="tag_close" select="$tag_close"/>
2978
2989
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2979
2990
  </xsl:call-template>
2980
2991
  </xsl:when>
@@ -2982,6 +2993,39 @@
2982
2993
  </xsl:choose>
2983
2994
  </xsl:template><xsl:template match="*[local-name()='br']">
2984
2995
  <xsl:value-of select="$linebreak"/>
2996
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
2997
+ <xsl:param name="split_keep-within-line"/>
2998
+
2999
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3000
+ <xsl:choose>
3001
+
3002
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3003
+ <xsl:variable name="sep">_</xsl:variable>
3004
+ <xsl:variable name="items">
3005
+ <xsl:call-template name="split">
3006
+ <xsl:with-param name="pText" select="."/>
3007
+ <xsl:with-param name="sep" select="$sep"/>
3008
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3009
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3010
+ </xsl:call-template>
3011
+ </xsl:variable>
3012
+ <xsl:for-each select="xalan:nodeset($items)/item">
3013
+ <xsl:choose>
3014
+ <xsl:when test=". = $sep">
3015
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3016
+ </xsl:when>
3017
+ <xsl:otherwise>
3018
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3019
+ </xsl:otherwise>
3020
+ </xsl:choose>
3021
+ </xsl:for-each>
3022
+ </xsl:when>
3023
+
3024
+ <xsl:otherwise>
3025
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3026
+ </xsl:otherwise>
3027
+
3028
+ </xsl:choose>
2985
3029
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
2986
3030
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
2987
3031
  <xsl:apply-templates/>
@@ -3067,8 +3111,23 @@
3067
3111
  </fo:block>
3068
3112
 
3069
3113
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3070
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3071
- <xsl:call-template name="add-zero-spaces-java"/>
3114
+ <xsl:choose>
3115
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3116
+ <xsl:value-of select="."/>
3117
+ </xsl:when>
3118
+ <xsl:otherwise>
3119
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3120
+ </xsl:otherwise>
3121
+ </xsl:choose>
3122
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3123
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3124
+ <!-- <xsl:copy-of select="$text"/> -->
3125
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3126
+ <xsl:choose>
3127
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3128
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3129
+ </xsl:choose>
3130
+ </xsl:for-each>
3072
3131
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3073
3132
 
3074
3133
  <xsl:variable name="table-preamble">
@@ -3080,9 +3139,14 @@
3080
3139
 
3081
3140
  <xsl:variable name="table">
3082
3141
 
3083
- <xsl:variable name="simple-table">
3084
- <xsl:call-template name="getSimpleTable"/>
3142
+ <xsl:variable name="simple-table">
3143
+ <xsl:call-template name="getSimpleTable">
3144
+ <xsl:with-param name="id" select="@id"/>
3145
+ </xsl:call-template>
3085
3146
  </xsl:variable>
3147
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3148
+
3149
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3086
3150
 
3087
3151
 
3088
3152
  <!-- Display table's name before table as standalone block -->
@@ -3105,7 +3169,23 @@
3105
3169
  </xsl:call-template>
3106
3170
  </xsl:if>
3107
3171
  </xsl:variable>
3108
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3172
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3173
+
3174
+ <!-- DEBUG -->
3175
+ <xsl:if test="$table_if_debug = 'true'">
3176
+ <fo:block font-size="60%">
3177
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3178
+ </fo:block>
3179
+ </xsl:if>
3180
+
3181
+
3182
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3183
+
3184
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3185
+ DEBUG
3186
+ colwidths=<xsl:copy-of select="$colwidths"/>
3187
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3188
+
3109
3189
 
3110
3190
 
3111
3191
  <xsl:variable name="margin-side">
@@ -3175,9 +3255,17 @@
3175
3255
  </xsl:element>
3176
3256
  </xsl:variable>
3177
3257
 
3258
+ <xsl:if test="$isGenerateTableIF = 'true'">
3259
+ <!-- to determine start of table -->
3260
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3261
+ </xsl:if>
3178
3262
 
3179
3263
  <fo:table id="{@id}">
3180
3264
 
3265
+ <xsl:if test="$isGenerateTableIF = 'true'">
3266
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3267
+ </xsl:if>
3268
+
3181
3269
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3182
3270
  <xsl:attribute name="{local-name()}">
3183
3271
  <xsl:value-of select="."/>
@@ -3191,31 +3279,47 @@
3191
3279
 
3192
3280
 
3193
3281
  <xsl:choose>
3194
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3195
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3196
- <fo:table-column column-width="{@width}"/>
3197
- </xsl:for-each>
3282
+ <xsl:when test="$isGenerateTableIF = 'true'">
3283
+ <!-- generate IF for table widths -->
3284
+ <!-- example:
3285
+ <tr>
3286
+ <td valign="top" align="left" id="tab-symdu_1_1">
3287
+ <p>Symbol</p>
3288
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3289
+ </td>
3290
+ <td valign="top" align="left" id="tab-symdu_1_2">
3291
+ <p>Description</p>
3292
+ <word id="tab-symdu_1_2_word_1">Description</word>
3293
+ </td>
3294
+ </tr>
3295
+ -->
3296
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3297
+
3198
3298
  </xsl:when>
3199
3299
  <xsl:otherwise>
3200
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3201
- <xsl:choose>
3202
- <xsl:when test=". = 1 or . = 0">
3203
- <fo:table-column column-width="proportional-column-width(2)"/>
3204
- </xsl:when>
3205
- <xsl:otherwise>
3206
- <fo:table-column column-width="proportional-column-width({.})"/>
3207
- </xsl:otherwise>
3208
- </xsl:choose>
3209
- </xsl:for-each>
3210
- </xsl:otherwise>
3211
- </xsl:choose>
3212
3300
 
3213
- <xsl:choose>
3214
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3215
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3216
- </xsl:when>
3217
- <xsl:otherwise>
3218
- <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 -->
3301
+ <xsl:choose>
3302
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3303
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3304
+ <fo:table-column column-width="{@width}"/>
3305
+ </xsl:for-each>
3306
+ </xsl:when>
3307
+ <xsl:otherwise>
3308
+ <xsl:call-template name="insertTableColumnWidth">
3309
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3310
+ </xsl:call-template>
3311
+ </xsl:otherwise>
3312
+ </xsl:choose>
3313
+
3314
+ <xsl:choose>
3315
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3316
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3317
+ </xsl:when>
3318
+ <xsl:otherwise>
3319
+ <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 -->
3320
+ </xsl:otherwise>
3321
+ </xsl:choose>
3322
+
3219
3323
  </xsl:otherwise>
3220
3324
  </xsl:choose>
3221
3325
 
@@ -3315,11 +3419,22 @@
3315
3419
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3316
3420
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3317
3421
  </xsl:template><xsl:template name="calculate-column-widths">
3422
+ <xsl:param name="table"/>
3423
+ <xsl:param name="cols-count"/>
3424
+
3425
+ <xsl:call-template name="calculate-column-widths-proportional">
3426
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3427
+ <xsl:with-param name="table" select="$table"/>
3428
+ </xsl:call-template>
3429
+
3430
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3318
3431
  <xsl:param name="table"/>
3319
3432
  <xsl:param name="cols-count"/>
3320
3433
  <xsl:param name="curr-col" select="1"/>
3321
3434
  <xsl:param name="width" select="0"/>
3322
3435
 
3436
+ <!-- table=<xsl:copy-of select="$table"/> -->
3437
+
3323
3438
  <xsl:if test="$curr-col &lt;= $cols-count">
3324
3439
  <xsl:variable name="widths">
3325
3440
  <xsl:choose>
@@ -3357,16 +3472,22 @@
3357
3472
  </xsl:for-each>
3358
3473
  </xsl:when>
3359
3474
  <xsl:otherwise>
3360
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3475
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3476
+
3477
+ <!-- <table><xsl:copy-of select="$table"/></table>
3478
+ -->
3479
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3361
3480
  <xsl:variable name="td_text">
3362
3481
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3363
3482
  </xsl:variable>
3483
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3364
3484
  <xsl:variable name="words">
3365
3485
  <xsl:variable name="string_with_added_zerospaces">
3366
3486
  <xsl:call-template name="add-zero-spaces-java">
3367
3487
  <xsl:with-param name="text" select="$td_text"/>
3368
3488
  </xsl:call-template>
3369
3489
  </xsl:variable>
3490
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3370
3491
  <xsl:call-template name="tokenize">
3371
3492
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3372
3493
  <!-- 2009 thinspace -->
@@ -3374,11 +3495,13 @@
3374
3495
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3375
3496
  </xsl:call-template>
3376
3497
  </xsl:variable>
3498
+ <!-- words=<xsl:copy-of select="$words"/> -->
3377
3499
  <xsl:variable name="max_length">
3378
3500
  <xsl:call-template name="max_length">
3379
3501
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3380
3502
  </xsl:call-template>
3381
3503
  </xsl:variable>
3504
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3382
3505
  <width>
3383
3506
  <xsl:variable name="divider">
3384
3507
  <xsl:choose>
@@ -3397,6 +3520,8 @@
3397
3520
  </xsl:choose>
3398
3521
  </xsl:variable>
3399
3522
 
3523
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3524
+
3400
3525
  <column>
3401
3526
  <xsl:for-each select="xalan:nodeset($widths)//width">
3402
3527
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3405,29 +3530,327 @@
3405
3530
  </xsl:if>
3406
3531
  </xsl:for-each>
3407
3532
  </column>
3408
- <xsl:call-template name="calculate-column-widths">
3533
+ <xsl:call-template name="calculate-column-widths-proportional">
3409
3534
  <xsl:with-param name="cols-count" select="$cols-count"/>
3410
3535
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3411
3536
  <xsl:with-param name="table" select="$table"/>
3412
3537
  </xsl:call-template>
3413
3538
  </xsl:if>
3539
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
3540
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3541
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3542
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3543
+
3544
+ <!-- if all capitals english letters or digits -->
3545
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
3546
+ <xsl:call-template name="repeat">
3547
+ <xsl:with-param name="char" select="'X'"/>
3548
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
3549
+ </xsl:call-template>
3550
+ </xsl:if>
3414
3551
  </xsl:template><xsl:template match="text()" mode="td_text">
3415
3552
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3416
3553
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3417
3554
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3418
3555
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3419
3556
  <xsl:value-of select="@target"/>
3420
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3421
- <xsl:variable name="mathml">
3422
- <xsl:for-each select="*">
3423
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3424
- <xsl:copy-of select="."/>
3557
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
3558
+ <xsl:if test="$isGenerateTableIF = 'false'">
3559
+ <xsl:variable name="mathml_">
3560
+ <xsl:for-each select="*">
3561
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3562
+ <xsl:copy-of select="."/>
3563
+ </xsl:if>
3564
+ </xsl:for-each>
3565
+ </xsl:variable>
3566
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
3567
+
3568
+ <xsl:variable name="math_text">
3569
+ <xsl:value-of select="normalize-space($mathml)"/>
3570
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
3571
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
3572
+ </xsl:variable>
3573
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3574
+ </xsl:if>
3575
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
3576
+ <xsl:param name="table"/>
3577
+ <xsl:param name="if">false</xsl:param> <!-- via intermediate format -->
3578
+
3579
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
3580
+
3581
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
3582
+
3583
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
3584
+
3585
+ <!-- get current table id -->
3586
+ <xsl:variable name="table_id" select="@id"/>
3587
+ <!-- find table by id in the file 'table_widths' -->
3588
+ <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
3589
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/>
3590
+
3591
+
3592
+ <!-- table='<xsl:copy-of select="$table"/>' -->
3593
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
3594
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
3595
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
3596
+
3597
+ <xsl:variable name="table_with_cell_widths_">
3598
+ <xsl:choose>
3599
+ <xsl:when test="$if = 'true' and normalize-space($table-if) != ''"> <!-- if we read column's width from IF and there is table in IF -->
3600
+
3601
+ <!-- Example: <column>10</column>
3602
+ <column>11</column>
3603
+ -->
3604
+ <xsl:apply-templates select="$table-if" mode="determine_cell_widths-if"/>
3605
+ </xsl:when>
3606
+ <xsl:otherwise>
3607
+ <xsl:apply-templates select="xalan:nodeset($table)" mode="determine_cell_widths"/>
3608
+ </xsl:otherwise>
3609
+ </xsl:choose>
3610
+ </xsl:variable>
3611
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
3612
+
3613
+ <xsl:if test="$table_if_debug = 'true'">
3614
+ <xsl:copy-of select="$table_with_cell_widths"/>
3615
+ </xsl:if>
3616
+
3617
+
3618
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
3619
+
3620
+ <xsl:variable name="column_widths_">
3621
+ <!-- iteration of columns -->
3622
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
3623
+ <xsl:variable name="pos" select="position()"/>
3624
+ <column>
3625
+ <xsl:attribute name="width_max">
3626
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
3627
+ <xsl:sort select="." data-type="number" order="descending"/>
3628
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3629
+ </xsl:for-each>
3630
+ </xsl:attribute>
3631
+ <xsl:attribute name="width_min">
3632
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
3633
+ <xsl:sort select="." data-type="number" order="descending"/>
3634
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3635
+ </xsl:for-each>
3636
+ </xsl:attribute>
3637
+ </column>
3638
+ </xsl:for-each>
3639
+ </xsl:variable>
3640
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
3641
+
3642
+ <!-- <column_widths>
3643
+ <xsl:copy-of select="$column_widths"/>
3644
+ </column_widths> -->
3645
+
3646
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
3647
+ <xsl:variable name="table_widths_">
3648
+ <table>
3649
+ <xsl:attribute name="width_max">
3650
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
3651
+ </xsl:attribute>
3652
+ <xsl:attribute name="width_min">
3653
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
3654
+ </xsl:attribute>
3655
+ </table>
3656
+ </xsl:variable>
3657
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
3658
+
3659
+ <xsl:variable name="page_width">
3660
+ <xsl:choose>
3661
+ <xsl:when test="$if = 'true'"><xsl:value-of select="$table-if/@page-width"/></xsl:when>
3662
+ <xsl:otherwise>75</xsl:otherwise>
3663
+ </xsl:choose>
3664
+ </xsl:variable>
3665
+
3666
+ <xsl:if test="$table_if_debug = 'true'">
3667
+ <table_width>
3668
+ <xsl:copy-of select="$table_widths"/>
3669
+ </table_width>
3670
+ <!-- <debug>$table_widths/@width_min=<xsl:value-of select="$table_widths/table/@width_min"/></debug>
3671
+ <debug>$table_widths/@width_max=<xsl:value-of select="$table_widths/table/@width_max"/></debug>
3672
+ -->
3673
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
3674
+ </xsl:if>
3675
+
3676
+
3677
+ <!-- There are three cases: -->
3678
+ <xsl:choose>
3679
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
3680
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
3681
+ <!-- call old algorithm -->
3682
+ <case1/>
3683
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
3684
+ <xsl:call-template name="calculate-column-widths-proportional">
3685
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3686
+ <xsl:with-param name="table" select="$table"/>
3687
+ </xsl:call-template>
3688
+ </xsl:when>
3689
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
3690
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
3691
+ <case2/>
3692
+ <autolayout/>
3693
+ <xsl:for-each select="$column_widths/column/@width_max">
3694
+ <column divider="100"><xsl:value-of select="."/></column>
3695
+ </xsl:for-each>
3696
+ </xsl:when>
3697
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
3698
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
3699
+ Lets also call D the difference between maximum and minimum width of the table.
3700
+ For each column, let d be the difference between maximum and minimum width of that column.
3701
+ Now set the column's width to the minimum width plus d times W over D.
3702
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
3703
+ <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)">
3704
+ <!-- difference between the available space and the minimum table width -->
3705
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
3706
+ <W><xsl:value-of select="$W"/></W>
3707
+ <!-- difference between maximum and minimum width of the table -->
3708
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
3709
+ <D><xsl:value-of select="$D"/></D>
3710
+ <case3/>
3711
+ <autolayout/>
3712
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
3713
+ <split_keep-within-line>true</split_keep-within-line>
3714
+ </xsl:if>
3715
+ <xsl:for-each select="$column_widths/column">
3716
+ <!-- difference between maximum and minimum width of that column. -->
3717
+ <xsl:variable name="d" select="@width_max - @width_min"/>
3718
+ <d><xsl:value-of select="$d"/></d>
3719
+ <width_min><xsl:value-of select="@width_min"/></width_min>
3720
+ <e><xsl:value-of select="$d * $W div $D"/></e>
3721
+ <!-- set the column's width to the minimum width plus d times W over D. -->
3722
+ <column divider="100">
3723
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3724
+ </column>
3725
+ </xsl:for-each>
3726
+
3727
+ </xsl:when>
3728
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
3729
+ </xsl:choose>
3730
+
3731
+
3732
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths">
3733
+ <xsl:copy>
3734
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths"/>
3735
+ </xsl:copy>
3736
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths">
3737
+ <xsl:copy>
3738
+ <xsl:copy-of select="@*"/>
3739
+
3740
+ <!-- The maximum width is given by the widest line. -->
3741
+ <xsl:variable name="widths_max">
3742
+ <xsl:for-each select=".//*[local-name() = 'p']">
3743
+ <xsl:call-template name="add_width"/>
3744
+ </xsl:for-each>
3745
+ <xsl:if test="not(*[local-name() = 'p'])">
3746
+ <xsl:call-template name="add_width"/>
3425
3747
  </xsl:if>
3748
+ </xsl:variable>
3749
+ <xsl:variable name="width_max">
3750
+ <xsl:for-each select="xalan:nodeset($widths_max)//width">
3751
+ <xsl:sort select="." data-type="number" order="descending"/>
3752
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3753
+ </xsl:for-each>
3754
+ </xsl:variable>
3755
+ <xsl:attribute name="width_max">
3756
+ <xsl:value-of select="$width_max"/>
3757
+ </xsl:attribute>
3758
+
3759
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
3760
+ <!-- To do: image width -->
3761
+ <xsl:variable name="td_text">
3762
+ <xsl:apply-templates select="." mode="td_text"/>
3763
+ </xsl:variable>
3764
+ <xsl:variable name="words">
3765
+ <xsl:variable name="string_with_added_zerospaces">
3766
+ <xsl:call-template name="add-zero-spaces-java">
3767
+ <xsl:with-param name="text" select="$td_text"/>
3768
+ </xsl:call-template>
3769
+ </xsl:variable>
3770
+ <xsl:call-template name="tokenize">
3771
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3772
+ </xsl:call-template>
3773
+ </xsl:variable>
3774
+
3775
+ <xsl:variable name="max_word_length">
3776
+ <xsl:call-template name="max_length">
3777
+ <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3778
+ </xsl:call-template>
3779
+ </xsl:variable>
3780
+ <xsl:variable name="width_min">
3781
+ <xsl:value-of select="$max_word_length"/>
3782
+ </xsl:variable>
3783
+ <xsl:attribute name="width_min">
3784
+ <xsl:value-of select="$width_min"/>
3785
+ </xsl:attribute>
3786
+ <!-- width_max="1" width_min="1.5"> --> <!-- see 'tokenize' template, multiply 1.5 for all latin capitals -->
3787
+ <xsl:if test="$width_min &gt; $width_max">
3788
+ <xsl:attribute name="width_max">
3789
+ <xsl:value-of select="$width_min"/>
3790
+ </xsl:attribute>
3791
+ </xsl:if>
3792
+ <xsl:if test="$width_min = 0">
3793
+ <xsl:attribute name="width_min">1</xsl:attribute>
3794
+ </xsl:if>
3795
+
3796
+ <xsl:apply-templates select="node()" mode="determine_cell_widths"/>
3797
+
3798
+ </xsl:copy>
3799
+ </xsl:template><xsl:template name="add_width">
3800
+ <xsl:variable name="p_text"><xsl:apply-templates select="." mode="td_text"/></xsl:variable>
3801
+ <xsl:variable name="p_text_len_" select="string-length(normalize-space($p_text))"/>
3802
+
3803
+ <xsl:variable name="p_text_len">
3804
+ <xsl:choose>
3805
+ <xsl:when test="normalize-space(translate($p_text, concat($upper,'0123456789'), '')) = ''"> <!-- english word in CAPITAL letters -->
3806
+ <xsl:value-of select="$p_text_len_ * 1.5"/>
3807
+ </xsl:when>
3808
+ <xsl:otherwise><xsl:value-of select="$p_text_len_"/></xsl:otherwise>
3809
+ </xsl:choose>
3810
+ </xsl:variable>
3811
+
3812
+ <xsl:variable name="math_addon_text">
3813
+ <xsl:for-each select=".//*[local-name() = 'math']">
3814
+ <xsl:apply-templates mode="td_text"/>
3426
3815
  </xsl:for-each>
3427
3816
  </xsl:variable>
3817
+ <xsl:variable name="math_addon_length" select="string-length(normalize-space($math_addon_text)) * 0.2"/> <!-- plus 20% -->
3428
3818
 
3429
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3430
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3819
+ <width><xsl:value-of select="$p_text_len + $math_addon_length"/></width>
3820
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
3821
+ <xsl:copy>
3822
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
3823
+ </xsl:copy>
3824
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
3825
+ <xsl:copy>
3826
+ <xsl:copy-of select="@*"/>
3827
+
3828
+ <!-- The maximum width is given by the widest line. -->
3829
+ <xsl:attribute name="width_max">
3830
+ <xsl:for-each select="p_len">
3831
+ <xsl:sort select="." data-type="number" order="descending"/>
3832
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3833
+ </xsl:for-each>
3834
+ </xsl:attribute>
3835
+
3836
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
3837
+ <xsl:variable name="width_min">
3838
+ <xsl:for-each select="word_len">
3839
+ <xsl:sort select="." data-type="number" order="descending"/>
3840
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3841
+ </xsl:for-each>
3842
+ </xsl:variable>
3843
+ <xsl:attribute name="width_min">
3844
+ <xsl:value-of select="$width_min"/>
3845
+ </xsl:attribute>
3846
+
3847
+ <xsl:if test="$width_min = 0">
3848
+ <xsl:attribute name="width_min">1</xsl:attribute>
3849
+ </xsl:if>
3850
+
3851
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
3852
+
3853
+ </xsl:copy>
3431
3854
  </xsl:template><xsl:template match="*[local-name()='thead']">
3432
3855
  <xsl:param name="cols-count"/>
3433
3856
  <fo:table-header>
@@ -3512,16 +3935,10 @@
3512
3935
  </xsl:for-each>
3513
3936
  </xsl:when>
3514
3937
  <xsl:otherwise>
3515
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3516
- <xsl:choose>
3517
- <xsl:when test=". = 1 or . = 0">
3518
- <fo:table-column column-width="proportional-column-width(2)"/>
3519
- </xsl:when>
3520
- <xsl:otherwise>
3521
- <fo:table-column column-width="proportional-column-width({.})"/>
3522
- </xsl:otherwise>
3523
- </xsl:choose>
3524
- </xsl:for-each>
3938
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
3939
+ <xsl:call-template name="insertTableColumnWidth">
3940
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3941
+ </xsl:call-template>
3525
3942
  </xsl:otherwise>
3526
3943
  </xsl:choose>
3527
3944
 
@@ -3598,6 +4015,52 @@
3598
4015
 
3599
4016
  </fo:table-body>
3600
4017
 
4018
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4019
+ <xsl:param name="table_or_dl">table</xsl:param>
4020
+ <xsl:apply-templates mode="process_table-if">
4021
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4022
+ </xsl:apply-templates>
4023
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4024
+ <xsl:param name="table_or_dl">table</xsl:param>
4025
+
4026
+ <fo:table-body>
4027
+ <xsl:for-each select="*[local-name() = 'tr']">
4028
+ <xsl:variable name="col_count" select="count(*)"/>
4029
+
4030
+ <!-- iteration for each tr/td -->
4031
+
4032
+ <xsl:choose>
4033
+ <xsl:when test="$table_or_dl = 'table'">
4034
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4035
+ <fo:table-row number-columns-spanned="{$col_count}">
4036
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4037
+ <xsl:call-template name="td"/>
4038
+ </fo:table-row>
4039
+ </xsl:for-each>
4040
+ </xsl:when>
4041
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4042
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4043
+ <xsl:variable name="is_dt" select="position() = 1"/>
4044
+
4045
+ <xsl:for-each select="*">
4046
+ <!-- <test><xsl:copy-of select="."/></test> -->
4047
+ <fo:table-row number-columns-spanned="{$col_count}">
4048
+ <xsl:choose>
4049
+ <xsl:when test="$is_dt">
4050
+ <xsl:call-template name="insert_dt_cell"/>
4051
+ </xsl:when>
4052
+ <xsl:otherwise>
4053
+ <xsl:call-template name="insert_dd_cell"/>
4054
+ </xsl:otherwise>
4055
+ </xsl:choose>
4056
+ </fo:table-row>
4057
+ </xsl:for-each>
4058
+ </xsl:for-each>
4059
+ </xsl:otherwise>
4060
+ </xsl:choose>
4061
+
4062
+ </xsl:for-each>
4063
+ </fo:table-body>
3601
4064
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3602
4065
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3603
4066
 
@@ -3689,7 +4152,7 @@
3689
4152
  </xsl:choose>
3690
4153
  </xsl:attribute>
3691
4154
  </xsl:if>
3692
- </xsl:template><xsl:template match="*[local-name()='td']">
4155
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
3693
4156
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
3694
4157
  <xsl:call-template name="setTextAlignment">
3695
4158
  <xsl:with-param name="default">left</xsl:with-param>
@@ -3723,11 +4186,24 @@
3723
4186
 
3724
4187
  <xsl:call-template name="setTableCellAttributes"/>
3725
4188
 
4189
+ <xsl:if test="$isGenerateTableIF = 'true'">
4190
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4191
+ <xsl:attribute name="text-align">left</xsl:attribute>
4192
+ </xsl:if>
4193
+
3726
4194
  <fo:block>
3727
4195
 
4196
+ <xsl:if test="$isGenerateTableIF = 'true'">
4197
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4198
+ </xsl:if>
4199
+
4200
+
3728
4201
 
3729
4202
 
3730
4203
  <xsl:apply-templates/>
4204
+
4205
+ <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"/> -->
4206
+
3731
4207
  </fo:block>
3732
4208
  </fo:table-cell>
3733
4209
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -3930,9 +4406,9 @@
3930
4406
  <!-- current hierarchy is 'figure' element -->
3931
4407
  <xsl:variable name="following_dl_colwidths">
3932
4408
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3933
- <xsl:variable name="html-table">
3934
- <xsl:variable name="doc_ns">
3935
-
4409
+ <xsl:variable name="simple-table">
4410
+ <!-- <xsl:variable name="doc_ns">
4411
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3936
4412
  </xsl:variable>
3937
4413
  <xsl:variable name="ns">
3938
4414
  <xsl:choose>
@@ -3943,7 +4419,7 @@
3943
4419
  <xsl:value-of select="substring-before(name(/*), '-')"/>
3944
4420
  </xsl:otherwise>
3945
4421
  </xsl:choose>
3946
- </xsl:variable>
4422
+ </xsl:variable> -->
3947
4423
 
3948
4424
  <xsl:for-each select="*[local-name() = 'dl'][1]">
3949
4425
  <tbody>
@@ -3954,7 +4430,7 @@
3954
4430
 
3955
4431
  <xsl:call-template name="calculate-column-widths">
3956
4432
  <xsl:with-param name="cols-count" select="2"/>
3957
- <xsl:with-param name="table" select="$html-table"/>
4433
+ <xsl:with-param name="table" select="$simple-table"/>
3958
4434
  </xsl:call-template>
3959
4435
 
3960
4436
  </xsl:if>
@@ -4078,8 +4554,10 @@
4078
4554
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4079
4555
  </xsl:variable>
4080
4556
 
4557
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
4558
+
4081
4559
  <xsl:choose>
4082
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
4560
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4083
4561
 
4084
4562
  <fo:block margin-bottom="12pt" text-align="left">
4085
4563
 
@@ -4094,7 +4572,7 @@
4094
4572
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4095
4573
  </fo:block>
4096
4574
 
4097
- </xsl:when>
4575
+ </xsl:when> <!-- END: only one component -->
4098
4576
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4099
4577
  <fo:block margin-bottom="12pt" text-align="left">
4100
4578
 
@@ -4108,8 +4586,8 @@
4108
4586
  </xsl:variable>
4109
4587
  <xsl:value-of select="$title-where"/>
4110
4588
  </fo:block>
4111
- </xsl:when>
4112
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
4589
+ </xsl:when> <!-- END: a few components -->
4590
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4113
4591
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4114
4592
 
4115
4593
 
@@ -4122,11 +4600,11 @@
4122
4600
  </xsl:variable>
4123
4601
  <xsl:value-of select="$title-key"/>
4124
4602
  </fo:block>
4125
- </xsl:when>
4603
+ </xsl:when> <!-- END: definition list in a figure -->
4126
4604
  </xsl:choose>
4127
4605
 
4128
4606
  <!-- a few components -->
4129
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
4607
+ <xsl:if test="$onlyOneComponent = 'false'">
4130
4608
  <fo:block>
4131
4609
 
4132
4610
 
@@ -4137,7 +4615,18 @@
4137
4615
 
4138
4616
 
4139
4617
 
4618
+
4619
+ <xsl:if test="$isGenerateTableIF = 'true'">
4620
+ <!-- to determine start of table -->
4621
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
4622
+ </xsl:if>
4623
+
4140
4624
  <fo:table width="95%" table-layout="fixed">
4625
+
4626
+ <xsl:if test="$isGenerateTableIF = 'true'">
4627
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
4628
+ </xsl:if>
4629
+
4141
4630
 
4142
4631
  <xsl:choose>
4143
4632
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4146,54 +4635,143 @@
4146
4635
 
4147
4636
  </xsl:when>
4148
4637
  </xsl:choose>
4149
- <!-- create virtual html table for dl/[dt and dd] -->
4150
- <xsl:variable name="html-table">
4151
- <xsl:variable name="doc_ns">
4638
+
4639
+
4640
+ <xsl:choose>
4641
+ <xsl:when test="$isGenerateTableIF = 'true'">
4642
+ <!-- generate IF for table widths -->
4643
+ <!-- example:
4644
+ <tr>
4645
+ <td valign="top" align="left" id="tab-symdu_1_1">
4646
+ <p>Symbol</p>
4647
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
4648
+ </td>
4649
+ <td valign="top" align="left" id="tab-symdu_1_2">
4650
+ <p>Description</p>
4651
+ <word id="tab-symdu_1_2_word_1">Description</word>
4652
+ </td>
4653
+ </tr>
4654
+ -->
4152
4655
 
4153
- </xsl:variable>
4154
- <xsl:variable name="ns">
4155
- <xsl:choose>
4156
- <xsl:when test="normalize-space($doc_ns) != ''">
4157
- <xsl:value-of select="normalize-space($doc_ns)"/>
4158
- </xsl:when>
4159
- <xsl:otherwise>
4160
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4161
- </xsl:otherwise>
4162
- </xsl:choose>
4163
- </xsl:variable>
4164
- <tbody>
4165
- <xsl:apply-templates mode="dl"/>
4166
- </tbody>
4167
- </xsl:variable>
4168
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4169
- <xsl:variable name="colwidths">
4170
- <xsl:call-template name="calculate-column-widths">
4171
- <xsl:with-param name="cols-count" select="2"/>
4172
- <xsl:with-param name="table" select="$html-table"/>
4173
- </xsl:call-template>
4174
- </xsl:variable>
4175
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4176
- <xsl:variable name="maxlength_dt">
4177
- <xsl:call-template name="getMaxLength_dt"/>
4178
- </xsl:variable>
4179
- <xsl:call-template name="setColumnWidth_dl">
4180
- <xsl:with-param name="colwidths" select="$colwidths"/>
4181
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4182
- </xsl:call-template>
4183
- <fo:table-body>
4184
- <xsl:apply-templates>
4185
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4186
- </xsl:apply-templates>
4187
- </fo:table-body>
4656
+ <!-- create virtual html table for dl/[dt and dd] -->
4657
+ <xsl:variable name="simple-table">
4658
+
4659
+ <xsl:variable name="dl_table">
4660
+ <tbody>
4661
+ <xsl:apply-templates mode="dl_if">
4662
+ <xsl:with-param name="id" select="@id"/>
4663
+ </xsl:apply-templates>
4664
+ </tbody>
4665
+ </xsl:variable>
4666
+
4667
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
4668
+
4669
+ <!-- Step: replace <br/> to <p>...</p> -->
4670
+ <xsl:variable name="table_without_br">
4671
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
4672
+ </xsl:variable>
4673
+
4674
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
4675
+
4676
+ <!-- Step: add id to each cell -->
4677
+ <!-- add <word>...</word> for each word, image, math -->
4678
+ <xsl:variable name="simple-table-id">
4679
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
4680
+ <xsl:with-param name="id" select="@id"/>
4681
+ </xsl:apply-templates>
4682
+ </xsl:variable>
4683
+
4684
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
4685
+
4686
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
4687
+
4688
+ </xsl:variable>
4689
+
4690
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
4691
+
4692
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
4693
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
4694
+ </xsl:apply-templates>
4695
+
4696
+ </xsl:when>
4697
+ <xsl:otherwise>
4698
+
4699
+ <xsl:variable name="simple-table">
4700
+
4701
+ <xsl:variable name="dl_table">
4702
+ <tbody>
4703
+ <xsl:apply-templates mode="dl">
4704
+ <xsl:with-param name="id" select="@id"/>
4705
+ </xsl:apply-templates>
4706
+ </tbody>
4707
+ </xsl:variable>
4708
+
4709
+ <xsl:copy-of select="$dl_table"/>
4710
+ </xsl:variable>
4711
+
4712
+ <xsl:variable name="colwidths">
4713
+ <xsl:call-template name="calculate-column-widths">
4714
+ <xsl:with-param name="cols-count" select="2"/>
4715
+ <xsl:with-param name="table" select="$simple-table"/>
4716
+ </xsl:call-template>
4717
+ </xsl:variable>
4718
+
4719
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
4720
+ DEBUG
4721
+ colwidths=<xsl:copy-of select="$colwidths"/>
4722
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
4723
+
4724
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4725
+
4726
+ <xsl:variable name="maxlength_dt">
4727
+ <xsl:call-template name="getMaxLength_dt"/>
4728
+ </xsl:variable>
4729
+
4730
+ <xsl:variable name="isContainsKeepTogetherTag_">
4731
+ false
4732
+ </xsl:variable>
4733
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4734
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4735
+
4736
+
4737
+ <xsl:call-template name="setColumnWidth_dl">
4738
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4739
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4740
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4741
+ </xsl:call-template>
4742
+
4743
+ <fo:table-body>
4744
+
4745
+ <!-- DEBUG -->
4746
+ <xsl:if test="$table_if_debug = 'true'">
4747
+ <fo:table-row>
4748
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
4749
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
4750
+ </fo:table-cell>
4751
+ </fo:table-row>
4752
+ </xsl:if>
4753
+
4754
+ <xsl:apply-templates>
4755
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4756
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
4757
+ </xsl:apply-templates>
4758
+
4759
+ </fo:table-body>
4760
+ </xsl:otherwise>
4761
+ </xsl:choose>
4188
4762
  </fo:table>
4189
4763
  </fo:block>
4190
4764
  </fo:block>
4191
- </xsl:if>
4765
+ </xsl:if> <!-- END: a few components -->
4192
4766
  </fo:block-container>
4193
4767
  </fo:block-container>
4194
4768
  </xsl:template><xsl:template name="setColumnWidth_dl">
4195
4769
  <xsl:param name="colwidths"/>
4196
4770
  <xsl:param name="maxlength_dt"/>
4771
+ <xsl:param name="isContainsKeepTogetherTag"/>
4772
+
4773
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
4774
+
4197
4775
  <xsl:choose>
4198
4776
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4199
4777
  <fo:table-column column-width="50%"/>
@@ -4201,6 +4779,16 @@
4201
4779
  </xsl:when>
4202
4780
  <xsl:otherwise>
4203
4781
  <xsl:choose>
4782
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
4783
+ <xsl:call-template name="insertTableColumnWidth">
4784
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4785
+ </xsl:call-template>
4786
+ </xsl:when>
4787
+ <xsl:when test="$isContainsKeepTogetherTag">
4788
+ <xsl:call-template name="insertTableColumnWidth">
4789
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4790
+ </xsl:call-template>
4791
+ </xsl:when>
4204
4792
  <!-- to set width check most wide chars like `W` -->
4205
4793
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
4206
4794
  <fo:table-column column-width="7%"/>
@@ -4231,20 +4819,31 @@
4231
4819
  <fo:table-column column-width="60%"/>
4232
4820
  </xsl:when>
4233
4821
  <xsl:otherwise>
4234
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
4235
- <xsl:choose>
4236
- <xsl:when test=". = 1 or . = 0">
4237
- <fo:table-column column-width="proportional-column-width(2)"/>
4238
- </xsl:when>
4239
- <xsl:otherwise>
4240
- <fo:table-column column-width="proportional-column-width({.})"/>
4241
- </xsl:otherwise>
4242
- </xsl:choose>
4243
- </xsl:for-each>
4822
+ <xsl:call-template name="insertTableColumnWidth">
4823
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4824
+ </xsl:call-template>
4244
4825
  </xsl:otherwise>
4245
4826
  </xsl:choose>
4246
4827
  </xsl:otherwise>
4247
4828
  </xsl:choose>
4829
+ </xsl:template><xsl:template name="insertTableColumnWidth">
4830
+ <xsl:param name="colwidths"/>
4831
+
4832
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
4833
+ <xsl:choose>
4834
+ <xsl:when test=". = 1 or . = 0">
4835
+ <fo:table-column column-width="proportional-column-width(2)"/>
4836
+ </xsl:when>
4837
+ <xsl:otherwise>
4838
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
4839
+ <xsl:variable name="divider">
4840
+ <xsl:value-of select="@divider"/>
4841
+ <xsl:if test="not(@divider)">1</xsl:if>
4842
+ </xsl:variable>
4843
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4844
+ </xsl:otherwise>
4845
+ </xsl:choose>
4846
+ </xsl:for-each>
4248
4847
  </xsl:template><xsl:template name="getMaxLength_dt">
4249
4848
  <xsl:variable name="lengths">
4250
4849
  <xsl:for-each select="*[local-name()='dt']">
@@ -4268,7 +4867,6 @@
4268
4867
  <xsl:value-of select="$maxLength"/>
4269
4868
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4270
4869
  <xsl:param name="key_iso"/>
4271
-
4272
4870
  <!-- <tr>
4273
4871
  <td>NOTE</td>
4274
4872
  <td>
@@ -4276,27 +4874,47 @@
4276
4874
  </td>
4277
4875
  </tr>
4278
4876
  -->
4279
- <fo:table-row>
4877
+ <!-- OLD Variant -->
4878
+ <!-- <fo:table-row>
4280
4879
  <fo:table-cell>
4281
4880
  <fo:block margin-top="6pt">
4282
4881
  <xsl:if test="normalize-space($key_iso) = 'true'">
4283
4882
  <xsl:attribute name="margin-top">0</xsl:attribute>
4284
4883
  </xsl:if>
4285
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4884
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4286
4885
  </fo:block>
4287
4886
  </fo:table-cell>
4288
4887
  <fo:table-cell>
4289
4888
  <fo:block>
4290
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4889
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4890
+ </fo:block>
4891
+ </fo:table-cell>
4892
+ </fo:table-row> -->
4893
+ <!-- <tr>
4894
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4895
+ </tr>
4896
+ -->
4897
+ <fo:table-row>
4898
+ <fo:table-cell number-columns-spanned="2">
4899
+ <fo:block>
4900
+ <xsl:call-template name="note"/>
4291
4901
  </fo:block>
4292
4902
  </fo:table-cell>
4293
4903
  </fo:table-row>
4294
4904
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
4905
+ <xsl:param name="id"/>
4906
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4295
4907
  <tr>
4296
4908
  <td>
4909
+ <xsl:attribute name="id">
4910
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
4911
+ </xsl:attribute>
4297
4912
  <xsl:apply-templates/>
4298
4913
  </td>
4299
4914
  <td>
4915
+ <xsl:attribute name="id">
4916
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
4917
+ </xsl:attribute>
4300
4918
 
4301
4919
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4302
4920
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4307,50 +4925,122 @@
4307
4925
 
4308
4926
  </xsl:template><xsl:template match="*[local-name()='dt']">
4309
4927
  <xsl:param name="key_iso"/>
4928
+ <xsl:param name="split_keep-within-line"/>
4310
4929
 
4311
4930
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4312
- <fo:table-cell>
4931
+ <xsl:call-template name="insert_dt_cell">
4932
+ <xsl:with-param name="key_iso" select="$key_iso"/>
4933
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4934
+ </xsl:call-template>
4935
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
4936
+ <xsl:call-template name="insert_dd_cell">
4937
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4938
+ </xsl:call-template>
4939
+ </xsl:for-each>
4940
+ </fo:table-row>
4941
+ </xsl:template><xsl:template name="insert_dt_cell">
4942
+ <xsl:param name="key_iso"/>
4943
+ <xsl:param name="split_keep-within-line"/>
4944
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
4945
+
4946
+ <xsl:if test="$isGenerateTableIF = 'true'">
4947
+ <!-- border is mandatory, to calculate real width -->
4948
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4949
+ <xsl:attribute name="text-align">left</xsl:attribute>
4950
+ </xsl:if>
4951
+
4952
+
4953
+ <fo:block xsl:use-attribute-sets="dt-block-style">
4954
+ <xsl:copy-of select="@id"/>
4955
+
4956
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4957
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4958
+ </xsl:if>
4959
+
4960
+
4961
+
4962
+ <xsl:apply-templates>
4963
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4964
+ </xsl:apply-templates>
4965
+
4966
+ <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"/> -->
4967
+
4968
+ </fo:block>
4969
+ </fo:table-cell>
4970
+ </xsl:template><xsl:template name="insert_dd_cell">
4971
+ <xsl:param name="split_keep-within-line"/>
4972
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
4973
+
4974
+ <xsl:if test="$isGenerateTableIF = 'true'">
4975
+ <!-- border is mandatory, to calculate real width -->
4976
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4977
+ </xsl:if>
4978
+
4979
+ <fo:block>
4980
+
4981
+ <xsl:if test="$isGenerateTableIF = 'true'">
4982
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4983
+ </xsl:if>
4984
+
4313
4985
 
4314
- <fo:block xsl:use-attribute-sets="dt-style">
4315
- <xsl:copy-of select="@id"/>
4316
-
4317
- <xsl:if test="normalize-space($key_iso) = 'true'">
4318
- <xsl:attribute name="margin-top">0</xsl:attribute>
4319
- </xsl:if>
4320
-
4321
-
4322
-
4323
- <xsl:apply-templates/>
4324
- </fo:block>
4325
- </fo:table-cell>
4326
- <fo:table-cell>
4327
- <fo:block>
4328
-
4329
4986
 
4330
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4331
- <xsl:with-param name="process">true</xsl:with-param>
4332
- </xsl:apply-templates>
4333
- </fo:block>
4334
- </fo:table-cell>
4335
- </fo:table-row>
4987
+ <xsl:choose>
4988
+ <xsl:when test="$isGenerateTableIF = 'true'">
4989
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
4990
+ <xsl:with-param name="process">true</xsl:with-param>
4991
+ </xsl:apply-templates>
4992
+ </xsl:when>
4993
+ <xsl:otherwise>
4994
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
4995
+ <xsl:with-param name="process">true</xsl:with-param>
4996
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4997
+ </xsl:apply-templates>
4998
+ </xsl:otherwise>
4999
+
5000
+ </xsl:choose>
5001
+
5002
+ <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"/> -->
5003
+
5004
+ </fo:block>
5005
+ </fo:table-cell>
4336
5006
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4337
5007
  <xsl:apply-templates/>
4338
5008
  </xsl:template><xsl:template match="*[local-name()='dd']">
4339
5009
  <xsl:param name="process">false</xsl:param>
5010
+ <xsl:param name="split_keep-within-line"/>
4340
5011
  <xsl:if test="$process = 'true'">
4341
5012
  <xsl:apply-templates select="@language"/>
4342
- <xsl:apply-templates/>
5013
+ <xsl:apply-templates>
5014
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5015
+ </xsl:apply-templates>
4343
5016
  </xsl:if>
4344
5017
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4345
5018
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4346
- </xsl:template><xsl:template match="*[local-name()='em']">
5019
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5020
+ <xsl:param name="id"/>
5021
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5022
+ <tr>
5023
+ <td>
5024
+ <xsl:copy-of select="node()"/>
5025
+ </td>
5026
+ <td>
5027
+
5028
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()"/>
5029
+
5030
+ </td>
5031
+ </tr>
5032
+
5033
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='em']">
4347
5034
  <fo:inline font-style="italic">
4348
5035
  <xsl:apply-templates/>
4349
5036
  </fo:inline>
4350
5037
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5038
+ <xsl:param name="split_keep-within-line"/>
4351
5039
  <fo:inline font-weight="bold">
4352
5040
 
4353
- <xsl:apply-templates/>
5041
+ <xsl:apply-templates>
5042
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5043
+ </xsl:apply-templates>
4354
5044
  </fo:inline>
4355
5045
  </xsl:template><xsl:template match="*[local-name()='padding']">
4356
5046
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4389,13 +5079,15 @@
4389
5079
  <xsl:choose>
4390
5080
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4391
5081
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4392
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5082
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4393
5083
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4394
5084
  </xsl:choose>
4395
5085
  </xsl:attribute>
4396
5086
  </xsl:if>
4397
5087
  <xsl:apply-templates/>
4398
5088
  </fo:inline>
5089
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
5090
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4399
5091
  </xsl:template><xsl:template match="*[local-name()='underline']">
4400
5092
  <fo:inline text-decoration="underline">
4401
5093
  <xsl:apply-templates/>
@@ -4543,54 +5235,120 @@
4543
5235
  <fo:block break-after="page"/>
4544
5236
  <fo:block> </fo:block>
4545
5237
  <fo:block break-after="page"/>
5238
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5239
+ <xsl:apply-templates/>
4546
5240
  </xsl:template><xsl:template name="tokenize">
4547
5241
  <xsl:param name="text"/>
4548
5242
  <xsl:param name="separator" select="' '"/>
4549
5243
  <xsl:choose>
5244
+
5245
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5246
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5247
+ </xsl:when>
4550
5248
  <xsl:when test="not(contains($text, $separator))">
4551
5249
  <word>
4552
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4553
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4554
5250
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4555
- <xsl:variable name="len_str">
4556
- <xsl:choose>
4557
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4558
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4559
- </xsl:when>
4560
- <xsl:otherwise>
4561
- <xsl:value-of select="$len_str_tmp"/>
4562
- </xsl:otherwise>
4563
- </xsl:choose>
4564
- </xsl:variable>
4565
-
4566
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4567
- <xsl:message>
4568
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4569
- len_str=<xsl:value-of select="$len_str"/>
4570
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4571
- </xsl:message>
4572
- </xsl:if> -->
4573
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4574
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4575
5251
  <xsl:choose>
4576
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4577
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5252
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5253
+ <xsl:value-of select="$len_str_tmp"/>
4578
5254
  </xsl:when>
4579
5255
  <xsl:otherwise>
4580
- <xsl:value-of select="$len_str"/>
5256
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5257
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5258
+ <xsl:variable name="len_str">
5259
+ <xsl:choose>
5260
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5261
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5262
+ </xsl:when>
5263
+ <xsl:otherwise>
5264
+ <xsl:value-of select="$len_str_tmp"/>
5265
+ </xsl:otherwise>
5266
+ </xsl:choose>
5267
+ </xsl:variable>
5268
+
5269
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5270
+ <xsl:message>
5271
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5272
+ len_str=<xsl:value-of select="$len_str"/>
5273
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5274
+ </xsl:message>
5275
+ </xsl:if> -->
5276
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5277
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5278
+ <xsl:choose>
5279
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5280
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5281
+ </xsl:when>
5282
+ <xsl:otherwise>
5283
+ <xsl:value-of select="$len_str"/>
5284
+ </xsl:otherwise>
5285
+ </xsl:choose>
4581
5286
  </xsl:otherwise>
4582
5287
  </xsl:choose>
4583
5288
  </word>
4584
5289
  </xsl:when>
4585
5290
  <xsl:otherwise>
4586
5291
  <word>
4587
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5292
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5293
+ <xsl:choose>
5294
+ <xsl:when test="$isGenerateTableIF = 'true'">
5295
+ <xsl:value-of select="$word"/>
5296
+ </xsl:when>
5297
+ <xsl:otherwise>
5298
+ <xsl:value-of select="string-length($word)"/>
5299
+ </xsl:otherwise>
5300
+ </xsl:choose>
4588
5301
  </word>
4589
5302
  <xsl:call-template name="tokenize">
4590
5303
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
4591
5304
  </xsl:call-template>
4592
5305
  </xsl:otherwise>
4593
5306
  </xsl:choose>
5307
+ </xsl:template><xsl:template name="tokenize_with_tags">
5308
+ <xsl:param name="tags"/>
5309
+ <xsl:param name="text"/>
5310
+ <xsl:param name="separator" select="' '"/>
5311
+ <xsl:choose>
5312
+
5313
+ <xsl:when test="not(contains($text, $separator))">
5314
+ <word>
5315
+ <xsl:call-template name="enclose_text_in_tags">
5316
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5317
+ <xsl:with-param name="tags" select="$tags"/>
5318
+ </xsl:call-template>
5319
+ </word>
5320
+ </xsl:when>
5321
+ <xsl:otherwise>
5322
+ <word>
5323
+ <xsl:call-template name="enclose_text_in_tags">
5324
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5325
+ <xsl:with-param name="tags" select="$tags"/>
5326
+ </xsl:call-template>
5327
+ </word>
5328
+ <xsl:call-template name="tokenize_with_tags">
5329
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5330
+ </xsl:call-template>
5331
+ </xsl:otherwise>
5332
+ </xsl:choose>
5333
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5334
+ <xsl:param name="text"/>
5335
+ <xsl:param name="tags"/>
5336
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5337
+
5338
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5339
+
5340
+ <xsl:choose>
5341
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5342
+ <xsl:otherwise>
5343
+ <xsl:element name="{$tag_name}">
5344
+ <xsl:call-template name="enclose_text_in_tags">
5345
+ <xsl:with-param name="text" select="$text"/>
5346
+ <xsl:with-param name="tags" select="$tags"/>
5347
+ <xsl:with-param name="num" select="$num + 1"/>
5348
+ </xsl:call-template>
5349
+ </xsl:element>
5350
+ </xsl:otherwise>
5351
+ </xsl:choose>
4594
5352
  </xsl:template><xsl:template name="max_length">
4595
5353
  <xsl:param name="words"/>
4596
5354
  <xsl:for-each select="$words//word">
@@ -4691,12 +5449,19 @@
4691
5449
  </xsl:otherwise>
4692
5450
  </xsl:choose>
4693
5451
  </xsl:template><xsl:template name="getSimpleTable">
5452
+ <xsl:param name="id"/>
5453
+
4694
5454
  <xsl:variable name="simple-table">
4695
5455
 
5456
+ <!-- Step 0. replace <br/> to <p>...</p> -->
5457
+ <xsl:variable name="table_without_br">
5458
+ <xsl:apply-templates mode="table-without-br"/>
5459
+ </xsl:variable>
5460
+
4696
5461
  <!-- Step 1. colspan processing -->
4697
5462
  <xsl:variable name="simple-table-colspan">
4698
5463
  <tbody>
4699
- <xsl:apply-templates mode="simple-table-colspan"/>
5464
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
4700
5465
  </tbody>
4701
5466
  </xsl:variable>
4702
5467
 
@@ -4705,10 +5470,67 @@
4705
5470
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
4706
5471
  </xsl:variable>
4707
5472
 
4708
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
4709
-
5473
+ <!-- Step 3: add id to each cell -->
5474
+ <!-- add <word>...</word> for each word, image, math -->
5475
+ <xsl:variable name="simple-table-id">
5476
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
5477
+ <xsl:with-param name="id" select="$id"/>
5478
+ </xsl:apply-templates>
5479
+ </xsl:variable>
5480
+
5481
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5482
+
4710
5483
  </xsl:variable>
4711
5484
  <xsl:copy-of select="$simple-table"/>
5485
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
5486
+ <xsl:copy>
5487
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
5488
+ </xsl:copy>
5489
+ </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">
5490
+ <xsl:copy>
5491
+ <xsl:copy-of select="@*"/>
5492
+ <p>
5493
+ <xsl:copy-of select="node()"/>
5494
+ </p>
5495
+ </xsl:copy>
5496
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
5497
+ <xsl:copy>
5498
+ <xsl:copy-of select="@*"/>
5499
+ <xsl:for-each select="*[local-name()='br']">
5500
+ <xsl:variable name="current_id" select="generate-id()"/>
5501
+ <p>
5502
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5503
+ <xsl:copy-of select="."/>
5504
+ </xsl:for-each>
5505
+ </p>
5506
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5507
+ <p>
5508
+ <xsl:for-each select="following-sibling::node()">
5509
+ <xsl:copy-of select="."/>
5510
+ </xsl:for-each>
5511
+ </p>
5512
+ </xsl:if>
5513
+ </xsl:for-each>
5514
+ </xsl:copy>
5515
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
5516
+ <xsl:for-each select="*[local-name()='br']">
5517
+ <xsl:variable name="current_id" select="generate-id()"/>
5518
+ <p>
5519
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5520
+ <xsl:copy-of select="."/>
5521
+ </xsl:for-each>
5522
+ </p>
5523
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5524
+ <p>
5525
+ <xsl:for-each select="following-sibling::node()">
5526
+ <xsl:copy-of select="."/>
5527
+ </xsl:for-each>
5528
+ </p>
5529
+ </xsl:if>
5530
+ </xsl:for-each>
5531
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
5532
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
5533
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
4712
5534
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
4713
5535
  <xsl:apply-templates mode="simple-table-colspan"/>
4714
5536
  </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">
@@ -4798,6 +5620,126 @@
4798
5620
  <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
4799
5621
  <xsl:with-param name="previousRow" select="$newRow"/>
4800
5622
  </xsl:apply-templates>
5623
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
5624
+ <xsl:param name="id"/>
5625
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
5626
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5627
+ <xsl:with-param name="id" select="$id_prefixed"/>
5628
+ </xsl:apply-templates>
5629
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
5630
+ <xsl:param name="id"/>
5631
+ <xsl:copy>
5632
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5633
+ <xsl:with-param name="id" select="$id"/>
5634
+ </xsl:apply-templates>
5635
+ </xsl:copy>
5636
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
5637
+ <xsl:param name="id"/>
5638
+ <xsl:copy>
5639
+ <xsl:copy-of select="@*"/>
5640
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
5641
+ <xsl:apply-templates select="node()" mode="simple-table-id">
5642
+ <xsl:with-param name="id" select="$id"/>
5643
+ </xsl:apply-templates>
5644
+ </xsl:copy>
5645
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
5646
+ <xsl:param name="id"/>
5647
+ <xsl:copy>
5648
+ <xsl:copy-of select="@*"/>
5649
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
5650
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
5651
+ <xsl:attribute name="id">
5652
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
5653
+ </xsl:attribute>
5654
+
5655
+ <xsl:for-each select="*[local-name() = 'p']">
5656
+ <xsl:copy>
5657
+ <xsl:copy-of select="@*"/>
5658
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
5659
+ <xsl:attribute name="id">
5660
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
5661
+ </xsl:attribute>
5662
+
5663
+ <xsl:copy-of select="node()"/>
5664
+ </xsl:copy>
5665
+ </xsl:for-each>
5666
+
5667
+
5668
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
5669
+
5670
+ <xsl:variable name="td_text">
5671
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
5672
+ </xsl:variable>
5673
+
5674
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
5675
+
5676
+ <xsl:variable name="words">
5677
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
5678
+ <word>
5679
+ <xsl:copy-of select="."/>
5680
+ </word>
5681
+ </xsl:for-each>
5682
+
5683
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
5684
+ <xsl:copy-of select="."/>
5685
+ </xsl:for-each>
5686
+
5687
+ </xsl:variable>
5688
+
5689
+ <xsl:for-each select="xalan:nodeset($words)/word">
5690
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
5691
+ <xsl:copy>
5692
+ <xsl:attribute name="id">
5693
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
5694
+ </xsl:attribute>
5695
+ <xsl:copy-of select="node()"/>
5696
+ </xsl:copy>
5697
+ </xsl:for-each>
5698
+ </xsl:if>
5699
+ </xsl:copy>
5700
+
5701
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
5702
+ <xsl:copy>
5703
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
5704
+ </xsl:copy>
5705
+ </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">
5706
+ <xsl:variable name="formatting_tags">
5707
+ <xsl:call-template name="getFormattingTags"/>
5708
+ </xsl:variable>
5709
+ <word>
5710
+ <xsl:call-template name="enclose_text_in_tags">
5711
+ <xsl:with-param name="text" select="normalize-space(.)"/>
5712
+ <xsl:with-param name="tags" select="$formatting_tags"/>
5713
+ </xsl:call-template>
5714
+ </word>
5715
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
5716
+
5717
+ <xsl:variable name="td_text" select="."/>
5718
+
5719
+ <xsl:variable name="string_with_added_zerospaces">
5720
+ <xsl:call-template name="add-zero-spaces-java">
5721
+ <xsl:with-param name="text" select="$td_text"/>
5722
+ </xsl:call-template>
5723
+ </xsl:variable>
5724
+
5725
+ <xsl:variable name="formatting_tags">
5726
+ <xsl:call-template name="getFormattingTags"/>
5727
+ </xsl:variable>
5728
+
5729
+ <!-- <word>text</word> -->
5730
+ <xsl:call-template name="tokenize_with_tags">
5731
+ <xsl:with-param name="tags" select="$formatting_tags"/>
5732
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
5733
+ </xsl:call-template>
5734
+ </xsl:template><xsl:template name="getFormattingTags">
5735
+ <tags>
5736
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
5737
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
5738
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
5739
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
5740
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
5741
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
5742
+ </tags>
4801
5743
  </xsl:template><xsl:template name="getLang">
4802
5744
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
4803
5745
  <xsl:variable name="language">
@@ -4852,6 +5794,9 @@
4852
5794
  <xsl:variable name="isDeleted" select="@deleted"/>
4853
5795
 
4854
5796
  <fo:inline xsl:use-attribute-sets="mathml-style">
5797
+
5798
+
5799
+
4855
5800
 
4856
5801
 
4857
5802
  <xsl:call-template name="setTrackChangesStyles">
@@ -4859,48 +5804,80 @@
4859
5804
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
4860
5805
  </xsl:call-template>
4861
5806
 
5807
+ <xsl:if test="$add_math_as_text = 'true'">
5808
+ <!-- insert helper tag -->
5809
+ <!-- set unique font-size (fiction) -->
5810
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
5811
+ <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 -->
5812
+ </xsl:if>
4862
5813
 
4863
-
4864
- <xsl:variable name="mathml">
4865
- <xsl:apply-templates select="." mode="mathml"/>
5814
+ <xsl:variable name="mathml_content">
5815
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
4866
5816
  </xsl:variable>
4867
- <fo:instream-foreign-object fox:alt-text="Math">
4868
5817
 
5818
+
5819
+ <xsl:call-template name="mathml_instream_object">
5820
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
5821
+ </xsl:call-template>
4869
5822
 
4870
-
4871
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
4872
- <xsl:variable name="comment_text_">
4873
- <xsl:choose>
4874
- <xsl:when test="normalize-space($comment_text_following) != ''">
4875
- <xsl:value-of select="$comment_text_following"/>
4876
- </xsl:when>
4877
- <xsl:otherwise>
4878
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
4879
- </xsl:otherwise>
4880
- </xsl:choose>
4881
- </xsl:variable>
4882
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
4883
-
4884
- <xsl:if test="normalize-space($comment_text) != ''">
4885
- <!-- put Mathin Alternate Text -->
4886
- <xsl:attribute name="fox:alt-text">
4887
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
4888
- </xsl:attribute>
4889
- </xsl:if>
4890
-
4891
- <xsl:variable name="mathml_content">
4892
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
4893
- </xsl:variable>
4894
- <!-- put MathML in Actual Text -->
4895
- <xsl:attribute name="fox:actual-text">
4896
- <xsl:value-of select="$mathml_content"/>
4897
- </xsl:attribute>
4898
-
4899
-
4900
-
4901
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
4902
- </fo:instream-foreign-object>
5823
+
4903
5824
  </fo:inline>
5825
+ </xsl:template><xsl:template name="getMathml_comment_text">
5826
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5827
+ <xsl:variable name="comment_text_">
5828
+ <xsl:choose>
5829
+ <xsl:when test="normalize-space($comment_text_following) != ''">
5830
+ <xsl:value-of select="$comment_text_following"/>
5831
+ </xsl:when>
5832
+ <xsl:otherwise>
5833
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5834
+ </xsl:otherwise>
5835
+ </xsl:choose>
5836
+ </xsl:variable>
5837
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5838
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
5839
+ <xsl:value-of select="$comment_text"/>
5840
+ </xsl:template><xsl:template name="mathml_instream_object">
5841
+ <xsl:param name="comment_text"/>
5842
+ <xsl:param name="mathml_content"/>
5843
+
5844
+ <xsl:variable name="comment_text_">
5845
+ <xsl:choose>
5846
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
5847
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
5848
+ </xsl:choose>
5849
+ </xsl:variable>
5850
+
5851
+ <xsl:variable name="mathml">
5852
+ <xsl:apply-templates select="." mode="mathml"/>
5853
+ </xsl:variable>
5854
+
5855
+ <fo:instream-foreign-object fox:alt-text="Math">
5856
+
5857
+
5858
+
5859
+
5860
+
5861
+
5862
+
5863
+ <!-- put MathML in Actual Text -->
5864
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
5865
+ <xsl:attribute name="fox:actual-text">
5866
+ <xsl:value-of select="$mathml_content"/>
5867
+ </xsl:attribute>
5868
+
5869
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
5870
+ <xsl:if test="normalize-space($comment_text_) != ''">
5871
+ <!-- put Mathin Alternate Text -->
5872
+ <xsl:attribute name="fox:alt-text">
5873
+ <xsl:value-of select="$comment_text_"/>
5874
+ </xsl:attribute>
5875
+ </xsl:if>
5876
+ <!-- </xsl:if> -->
5877
+
5878
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
5879
+
5880
+ </fo:instream-foreign-object>
4904
5881
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
4905
5882
  <!-- <xsl:text>a+b</xsl:text> -->
4906
5883
  <xsl:text>&lt;</xsl:text>
@@ -4931,7 +5908,9 @@
4931
5908
  <!-- replace start and end spaces to non-break space -->
4932
5909
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4933
5910
  </xsl:copy>
4934
- </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">
5911
+ </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">
5912
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5913
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
4935
5914
  <xsl:variable name="target">
4936
5915
  <xsl:choose>
4937
5916
  <xsl:when test="@updatetype = 'true'">
@@ -5532,18 +6511,33 @@
5532
6511
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5533
6512
  <xsl:copy>
5534
6513
  <xsl:apply-templates select="@*" mode="svg_update"/>
5535
- <xsl:variable name="viewbox">
6514
+ <xsl:variable name="viewbox_">
5536
6515
  <xsl:call-template name="split">
5537
6516
  <xsl:with-param name="pText" select="@viewBox"/>
5538
6517
  <xsl:with-param name="sep" select="' '"/>
5539
6518
  </xsl:call-template>
5540
6519
  </xsl:variable>
6520
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
6521
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
6522
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
6523
+
5541
6524
  <xsl:attribute name="width">
5542
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
6525
+ <xsl:choose>
6526
+ <xsl:when test="$width != ''">
6527
+ <xsl:value-of select="round($width)"/>
6528
+ </xsl:when>
6529
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
6530
+ </xsl:choose>
5543
6531
  </xsl:attribute>
5544
6532
  <xsl:attribute name="height">
5545
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
6533
+ <xsl:choose>
6534
+ <xsl:when test="$height != ''">
6535
+ <xsl:value-of select="round($height)"/>
6536
+ </xsl:when>
6537
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
6538
+ </xsl:choose>
5546
6539
  </xsl:attribute>
6540
+
5547
6541
  <xsl:apply-templates mode="svg_update"/>
5548
6542
  </xsl:copy>
5549
6543
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -5738,7 +6732,11 @@
5738
6732
  <xsl:apply-templates mode="bookmarks"/>
5739
6733
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
5740
6734
  <xsl:apply-templates select="."/>
5741
- </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">
6735
+ </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">
6736
+ <xsl:apply-templates mode="contents"/>
6737
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
6738
+ <xsl:apply-templates mode="bookmarks"/>
6739
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
5742
6740
  <xsl:apply-templates mode="bookmarks"/>
5743
6741
  </xsl:template><xsl:template name="addBookmarks">
5744
6742
  <xsl:param name="contents"/>
@@ -6033,7 +7031,9 @@
6033
7031
  <xsl:apply-templates/>
6034
7032
  </xsl:otherwise>
6035
7033
  </xsl:choose>
6036
- </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">
7034
+ </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">
7035
+ <xsl:value-of select="."/>
7036
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6037
7037
  <xsl:text> </xsl:text>
6038
7038
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6039
7039
  <xsl:copy>
@@ -6064,9 +7064,22 @@
6064
7064
  </xsl:when>
6065
7065
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6066
7066
  </xsl:choose>
7067
+ </xsl:template><xsl:template match="text()" mode="contents_item">
7068
+ <xsl:call-template name="keep_together_standard_number"/>
7069
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
7070
+ <xsl:apply-templates mode="contents_item"/>
6067
7071
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6068
7072
 
6069
7073
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7074
+
7075
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7076
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7077
+ </xsl:if>
7078
+
7079
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7080
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7081
+ </xsl:if>
7082
+
6070
7083
  <xsl:copy-of select="@id"/>
6071
7084
 
6072
7085
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6457,7 +7470,9 @@
6457
7470
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
6458
7471
  </xsl:if>
6459
7472
  <xsl:variable name="simple-table">
6460
- <xsl:call-template name="getSimpleTable"/>
7473
+ <xsl:call-template name="getSimpleTable">
7474
+ <xsl:with-param name="id" select="@id"/>
7475
+ </xsl:call-template>
6461
7476
  </xsl:variable>
6462
7477
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
6463
7478
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -6566,39 +7581,67 @@
6566
7581
  </xsl:otherwise>
6567
7582
  </xsl:choose>
6568
7583
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6569
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6570
-
7584
+
7585
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7586
+
6571
7587
 
7588
+
6572
7589
  <xsl:variable name="fo_element">
6573
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
7590
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6574
7591
  inline
6575
7592
  </xsl:variable>
6576
7593
 
6577
- <!-- display 'EXAMPLE' -->
6578
- <xsl:apply-templates select="*[local-name()='name']">
6579
- <xsl:with-param name="fo_element" select="$fo_element"/>
6580
- </xsl:apply-templates>
7594
+ <fo:block-container margin-left="0mm">
6581
7595
 
6582
- <xsl:choose>
6583
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6584
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6585
- <fo:block-container margin-left="0mm" margin-right="0mm">
6586
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7596
+ <xsl:choose>
7597
+
7598
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
7599
+
7600
+ <!-- display name 'EXAMPLE' in a separate block -->
7601
+ <fo:block>
7602
+ <xsl:apply-templates select="*[local-name()='name']">
6587
7603
  <xsl:with-param name="fo_element" select="$fo_element"/>
6588
7604
  </xsl:apply-templates>
7605
+ </fo:block>
7606
+
7607
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7608
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7609
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7610
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7611
+ </xsl:apply-templates>
7612
+ </fo:block-container>
6589
7613
  </fo:block-container>
6590
- </fo:block-container>
6591
- </xsl:when>
6592
- <xsl:otherwise>
6593
- <fo:inline>
6594
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6595
- <xsl:with-param name="fo_element" select="$fo_element"/>
6596
- </xsl:apply-templates>
6597
- </fo:inline>
6598
- </xsl:otherwise>
6599
- </xsl:choose>
6600
-
6601
- </fo:block>
7614
+ </xsl:when> <!-- end block -->
7615
+
7616
+ <xsl:otherwise> <!-- inline -->
7617
+
7618
+ <!-- display 'EXAMPLE' and first element in the same line -->
7619
+ <fo:block>
7620
+ <xsl:apply-templates select="*[local-name()='name']">
7621
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7622
+ </xsl:apply-templates>
7623
+ <fo:inline>
7624
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
7625
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7626
+ </xsl:apply-templates>
7627
+ </fo:inline>
7628
+ </fo:block>
7629
+
7630
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
7631
+ <!-- display further elements in blocks -->
7632
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7633
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7634
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
7635
+ <xsl:with-param name="fo_element" select="'block'"/>
7636
+ </xsl:apply-templates>
7637
+ </fo:block-container>
7638
+ </fo:block-container>
7639
+ </xsl:if>
7640
+ </xsl:otherwise> <!-- end inline -->
7641
+
7642
+ </xsl:choose>
7643
+ </fo:block-container>
7644
+ </fo:block-container>
6602
7645
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6603
7646
  <xsl:param name="fo_element">block</xsl:param>
6604
7647
 
@@ -6630,10 +7673,16 @@
6630
7673
  </xsl:variable>
6631
7674
  <xsl:choose>
6632
7675
  <xsl:when test="starts-with(normalize-space($element), 'block')">
6633
- <fo:block xsl:use-attribute-sets="example-p-style">
6634
-
6635
- <xsl:apply-templates/>
6636
- </fo:block>
7676
+ <fo:block-container>
7677
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
7678
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7679
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7680
+ </xsl:if>
7681
+ <fo:block xsl:use-attribute-sets="example-p-style">
7682
+
7683
+ <xsl:apply-templates/>
7684
+ </fo:block>
7685
+ </fo:block-container>
6637
7686
  </xsl:when>
6638
7687
  <xsl:otherwise>
6639
7688
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -6812,7 +7861,16 @@
6812
7861
  </fo:inline>
6813
7862
  </xsl:when>
6814
7863
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6815
- <fo:inline><xsl:apply-templates/></fo:inline>
7864
+
7865
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
7866
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
7867
+ <xsl:choose>
7868
+ <xsl:when test="$uri_src != ''">
7869
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
7870
+ </xsl:when>
7871
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
7872
+ </xsl:choose>
7873
+
6816
7874
  </xsl:otherwise>
6817
7875
  </xsl:choose>
6818
7876
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -6988,10 +8046,24 @@
6988
8046
 
6989
8047
  </fo:block>
6990
8048
  <xsl:apply-templates/>
6991
- </xsl:template><xsl:template match="*[local-name() = 'review']">
8049
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
6992
8050
  <!-- comment 2019-11-29 -->
6993
8051
  <!-- <fo:block font-weight="bold">Review:</fo:block>
6994
8052
  <xsl:apply-templates /> -->
8053
+
8054
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
8055
+
8056
+ <xsl:choose>
8057
+ <!-- if there isn't the attribute '@from', then -->
8058
+ <xsl:when test="$id_from = ''">
8059
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8060
+ </xsl:when>
8061
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
8062
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
8063
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8064
+ </xsl:when>
8065
+ </xsl:choose>
8066
+
6995
8067
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
6996
8068
  <!-- 0xA0 to space replacement -->
6997
8069
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7356,7 +8428,10 @@
7356
8428
  <!-- to split by '_' and other chars -->
7357
8429
  <xsl:call-template name="add-zero-spaces-java"/>
7358
8430
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7359
- <fo:inline id="{@id}" font-size="1pt"/>
8431
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8432
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8433
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8434
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7360
8435
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7361
8436
  <!-- <row>
7362
8437
  <date>05-07-2013</date>
@@ -8023,6 +9098,120 @@
8023
9098
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8024
9099
  </xsl:for-each>
8025
9100
  </xsl:copy>
9101
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9102
+ <xsl:apply-templates mode="update_xml_step1"/>
9103
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9104
+ <xsl:copy>
9105
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
9106
+ </xsl:copy>
9107
+ </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">
9108
+
9109
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
9110
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9111
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9112
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9113
+ <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))"/>
9114
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9115
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9116
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9117
+ <xsl:with-param name="text" select="$text_"/>
9118
+ </xsl:call-template></text></xsl:variable>
9119
+
9120
+ <xsl:variable name="parent" select="local-name(..)"/>
9121
+
9122
+ <xsl:variable name="text2">
9123
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
9124
+ <xsl:copy-of select="."/>
9125
+ </xsl:for-each></text>
9126
+ </xsl:variable>
9127
+
9128
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9129
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
9130
+ <xsl:variable name="text3">
9131
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9132
+ <xsl:choose>
9133
+ <xsl:when test="self::text()">
9134
+ <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))"/>
9135
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
9136
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9137
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9138
+ <xsl:with-param name="text" select="$text_units_"/>
9139
+ </xsl:call-template></text></xsl:variable>
9140
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
9141
+ </xsl:when>
9142
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9143
+ </xsl:choose>
9144
+ </xsl:for-each></text>
9145
+ </xsl:variable>
9146
+
9147
+ <xsl:choose>
9148
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9149
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9150
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9151
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9152
+ <xsl:choose>
9153
+ <xsl:when test="self::text()">
9154
+ <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))"/>
9155
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
9156
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9157
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9158
+ <xsl:with-param name="text" select="$text_dots_"/>
9159
+ </xsl:call-template></text></xsl:variable>
9160
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
9161
+ </xsl:when>
9162
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9163
+ </xsl:choose>
9164
+ </xsl:for-each>
9165
+ </xsl:when>
9166
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
9167
+ </xsl:choose>
9168
+
9169
+ </xsl:template><xsl:template name="replace_text_tags">
9170
+ <xsl:param name="tag_open"/>
9171
+ <xsl:param name="tag_close"/>
9172
+ <xsl:param name="text"/>
9173
+ <xsl:choose>
9174
+ <xsl:when test="contains($text, $tag_open)">
9175
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
9176
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
9177
+
9178
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
9179
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
9180
+ </xsl:element>
9181
+
9182
+ <xsl:call-template name="replace_text_tags">
9183
+ <xsl:with-param name="tag_open" select="$tag_open"/>
9184
+ <xsl:with-param name="tag_close" select="$tag_close"/>
9185
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
9186
+ </xsl:call-template>
9187
+ </xsl:when>
9188
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
9189
+ </xsl:choose>
9190
+ </xsl:template><xsl:template name="printEdition">
9191
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
9192
+ <xsl:text> </xsl:text>
9193
+ <xsl:choose>
9194
+ <xsl:when test="$edition_i18n != ''">
9195
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
9196
+ <xsl:call-template name="capitalize">
9197
+ <xsl:with-param name="str" select="$edition_i18n"/>
9198
+ </xsl:call-template>
9199
+ </xsl:when>
9200
+ <xsl:otherwise>
9201
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
9202
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
9203
+ <xsl:call-template name="capitalize">
9204
+ <xsl:with-param name="str">
9205
+ <xsl:call-template name="getLocalizedString">
9206
+ <xsl:with-param name="key">edition</xsl:with-param>
9207
+ </xsl:call-template>
9208
+ </xsl:with-param>
9209
+ </xsl:call-template>
9210
+ <xsl:text> </xsl:text>
9211
+ <xsl:value-of select="$edition"/>
9212
+ </xsl:if>
9213
+ </xsl:otherwise>
9214
+ </xsl:choose>
8026
9215
  </xsl:template><xsl:template name="convertDate">
8027
9216
  <xsl:param name="date"/>
8028
9217
  <xsl:param name="format" select="'short'"/>
@@ -8710,4 +9899,40 @@
8710
9899
  <xsl:value-of select="$value"/>
8711
9900
  </xsl:otherwise>
8712
9901
  </xsl:choose>
9902
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
9903
+ <xsl:param name="level">0</xsl:param>
9904
+
9905
+ <fo:block margin-left="{2*$level}mm">
9906
+ <xsl:text>
9907
+ &lt;</xsl:text>
9908
+ <xsl:value-of select="local-name()"/>
9909
+ <xsl:for-each select="@*">
9910
+ <xsl:text> </xsl:text>
9911
+ <xsl:value-of select="local-name()"/>
9912
+ <xsl:text>="</xsl:text>
9913
+ <xsl:value-of select="."/>
9914
+ <xsl:text>"</xsl:text>
9915
+ </xsl:for-each>
9916
+ <xsl:text>&gt;</xsl:text>
9917
+
9918
+ <xsl:if test="not(*)">
9919
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
9920
+ <xsl:text>&lt;/</xsl:text>
9921
+ <xsl:value-of select="local-name()"/>
9922
+ <xsl:text>&gt;</xsl:text>
9923
+ </xsl:if>
9924
+ </fo:block>
9925
+
9926
+ <xsl:if test="*">
9927
+ <fo:block>
9928
+ <xsl:apply-templates mode="print_as_xml">
9929
+ <xsl:with-param name="level" select="$level + 1"/>
9930
+ </xsl:apply-templates>
9931
+ </fo:block>
9932
+ <fo:block margin-left="{2*$level}mm">
9933
+ <xsl:text>&lt;/</xsl:text>
9934
+ <xsl:value-of select="local-name()"/>
9935
+ <xsl:text>&gt;</xsl:text>
9936
+ </fo:block>
9937
+ </xsl:if>
8713
9938
  </xsl:template></xsl:stylesheet>