metanorma-ogc 2.0.8.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) 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/htmlstyle.css +6 -0
  5. data/lib/isodoc/ogc/html/htmlstyle.scss +2 -0
  6. data/lib/isodoc/ogc/html/ogc.css +18 -12
  7. data/lib/isodoc/ogc/html/ogc.scss +16 -9
  8. data/lib/isodoc/ogc/html/ogc_wp.css +18 -12
  9. data/lib/isodoc/ogc/html/ogc_wp.scss +16 -9
  10. data/lib/isodoc/ogc/html/word_ogc_intro.html +2 -3
  11. data/lib/isodoc/ogc/html/word_ogc_intro_wp.html +1 -2
  12. data/lib/isodoc/ogc/html/word_ogc_titlepage.html +20 -17
  13. data/lib/isodoc/ogc/html/word_ogc_titlepage_wp.html +3 -0
  14. data/lib/isodoc/ogc/i18n.rb +1 -1
  15. data/lib/isodoc/ogc/init.rb +5 -6
  16. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +1502 -401
  17. data/lib/isodoc/ogc/ogc.best-practice.xsl +1502 -401
  18. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +1502 -401
  19. data/lib/isodoc/ogc/ogc.community-practice.xsl +1502 -401
  20. data/lib/isodoc/ogc/ogc.community-standard.xsl +1502 -401
  21. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +1502 -401
  22. data/lib/isodoc/ogc/ogc.engineering-report.xsl +1502 -401
  23. data/lib/isodoc/ogc/ogc.other.xsl +1502 -401
  24. data/lib/isodoc/ogc/ogc.policy.xsl +1502 -401
  25. data/lib/isodoc/ogc/ogc.reference-model.xsl +1502 -401
  26. data/lib/isodoc/ogc/ogc.release-notes.xsl +1502 -401
  27. data/lib/isodoc/ogc/ogc.standard.xsl +1502 -401
  28. data/lib/isodoc/ogc/ogc.test-suite.xsl +1502 -401
  29. data/lib/isodoc/ogc/ogc.user-guide.xsl +1502 -401
  30. data/lib/isodoc/ogc/ogc.white-paper.xsl +1521 -420
  31. data/lib/isodoc/ogc/presentation_xml_convert.rb +14 -10
  32. data/lib/isodoc/ogc/word_convert.rb +3 -4
  33. data/lib/isodoc/ogc/xref.rb +6 -2
  34. data/lib/metanorma/ogc/biblio.rng +69 -42
  35. data/lib/metanorma/ogc/isodoc.rng +65 -0
  36. data/lib/metanorma/ogc/version.rb +1 -1
  37. data/lib/relaton/render/config.yml +10 -0
  38. data/lib/relaton/render/date.rb +9 -0
  39. data/lib/relaton/render/fields.rb +23 -0
  40. data/lib/relaton/render/general.rb +25 -0
  41. data/lib/relaton/render/parse.rb +11 -0
  42. data/metanorma-ogc.gemspec +1 -1
  43. metadata +10 -5
@@ -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>
@@ -576,7 +576,7 @@
576
576
  <fo:block line-height="125%">
577
577
  <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
578
578
 
579
- <xsl:for-each select="/*/*[local-name()='preface']/*">
579
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
580
580
  <xsl:sort select="@displayorder" data-type="number"/>
581
581
 
582
582
  <xsl:if test="local-name() = 'foreword' or (local-name() = 'clause' and @type = 'security') or (local-name() = 'clause' and @type = 'submitting_orgs') or local-name() = 'introduction'">
@@ -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,12 +1464,41 @@
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:param name="add_math_as_text">true</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:variable name="table_widths_from_if_calculated_">
1468
+ <xsl:for-each select="$table_widths_from_if//table">
1469
+ <xsl:copy>
1470
+ <xsl:copy-of select="@*"/>
1471
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
1472
+ </xsl:copy>
1473
+ </xsl:for-each>
1474
+ </xsl:variable><xsl:variable name="table_widths_from_if_calculated" select="xalan:nodeset($table_widths_from_if_calculated_)"/><xsl:param name="table_if_debug">false</xsl:param><xsl:variable name="isGenerateTableIF_">
1475
+ false
1476
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
1461
1477
  <xsl:call-template name="getLang"/>
1462
- </xsl:variable><xsl:variable name="pageWidth_">
1463
- 215.9
1478
+ </xsl:variable><xsl:variable name="papersize" select="java:toLowerCase(java:java.lang.String.new(normalize-space(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata']/*[local-name() = 'papersize'])))"/><xsl:variable name="papersize_width_">
1479
+ <xsl:choose>
1480
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
1481
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
1482
+ </xsl:choose>
1483
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
1484
+ <xsl:choose>
1485
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
1486
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
1487
+ </xsl:choose>
1488
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
1489
+ <xsl:choose>
1490
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
1491
+ <xsl:otherwise>
1492
+ 215.9
1493
+ </xsl:otherwise>
1494
+ </xsl:choose>
1464
1495
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
1465
- 279.4
1496
+ <xsl:choose>
1497
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
1498
+ <xsl:otherwise>
1499
+ 279.4
1500
+ </xsl:otherwise>
1501
+ </xsl:choose>
1466
1502
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
1467
1503
  35
1468
1504
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -1472,20 +1508,7 @@
1472
1508
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1473
1509
  22.5
1474
1510
  </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
1511
 
1486
- <title-edition lang="ru">
1487
- <xsl:text>Издание </xsl:text>
1488
- </title-edition>
1489
1512
 
1490
1513
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1491
1514
  <title-toc lang="en">
@@ -1566,7 +1589,7 @@
1566
1589
  </xsl:variable><xsl:variable name="bibdata">
1567
1590
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1568
1591
  <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">
1592
+ </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
1593
  <xsl:param name="name"/>
1571
1594
  <xsl:param name="lang"/>
1572
1595
  <xsl:variable name="lang_">
@@ -1615,7 +1638,7 @@
1615
1638
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1616
1639
 
1617
1640
  <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']">
1641
+ <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
1642
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1620
1643
  </xsl:for-each>
1621
1644
  </xsl:variable>
@@ -1713,7 +1736,6 @@
1713
1736
 
1714
1737
 
1715
1738
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1716
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
1717
1739
 
1718
1740
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
1719
1741
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -1838,6 +1860,7 @@
1838
1860
 
1839
1861
 
1840
1862
 
1863
+
1841
1864
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
1842
1865
 
1843
1866
 
@@ -1994,6 +2017,7 @@
1994
2017
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1995
2018
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1996
2019
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2020
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1997
2021
  <xsl:attribute name="display-align">center</xsl:attribute>
1998
2022
 
1999
2023
 
@@ -2014,6 +2038,7 @@
2014
2038
  <xsl:attribute name="display-align">center</xsl:attribute>
2015
2039
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2016
2040
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2041
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2017
2042
 
2018
2043
 
2019
2044
 
@@ -2106,7 +2131,8 @@
2106
2131
  <xsl:attribute name="min-height">8.5mm</xsl:attribute>
2107
2132
 
2108
2133
 
2109
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2134
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2135
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2110
2136
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2111
2137
 
2112
2138
 
@@ -2121,6 +2147,28 @@
2121
2147
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2122
2148
 
2123
2149
 
2150
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
2151
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2152
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2153
+
2154
+
2155
+
2156
+
2157
+
2158
+
2159
+
2160
+
2161
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
2162
+ <xsl:attribute name="color"><xsl:value-of select="$color_blue"/></xsl:attribute>
2163
+
2164
+
2165
+
2166
+
2167
+
2168
+
2169
+
2170
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2171
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2124
2172
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2125
2173
 
2126
2174
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -2453,6 +2501,25 @@
2453
2501
 
2454
2502
 
2455
2503
 
2504
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
2505
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
2515
+ <xsl:attribute name="color"><xsl:value-of select="$color_blue"/></xsl:attribute>
2516
+
2517
+
2518
+
2519
+
2520
+
2521
+
2522
+
2456
2523
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
2457
2524
 
2458
2525
 
@@ -2867,13 +2934,13 @@
2867
2934
 
2868
2935
  </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
2869
2936
  <xsl:variable name="nodes_preface_">
2870
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2937
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2871
2938
  <node id="{@id}"/>
2872
2939
  </xsl:for-each>
2873
2940
  </xsl:variable>
2874
2941
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2875
2942
 
2876
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2943
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2877
2944
  <xsl:sort select="@displayorder" data-type="number"/>
2878
2945
 
2879
2946
  <!-- process Section's title -->
@@ -2939,7 +3006,7 @@
2939
3006
  </xsl:for-each>
2940
3007
  </figures>
2941
3008
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2942
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3009
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2943
3010
  <xsl:sort select="@displayorder" data-type="number"/>
2944
3011
  <xsl:apply-templates select="."/>
2945
3012
  </xsl:for-each>
@@ -2959,22 +3026,32 @@
2959
3026
  <xsl:sort select="@displayorder" data-type="number"/>
2960
3027
  <xsl:apply-templates select="."/>
2961
3028
  </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">
3029
+ </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">
3030
+
3031
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3032
+ <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))"/>
3033
+ <xsl:call-template name="replace_fo_inline_tags">
3034
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3035
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3036
+ <xsl:with-param name="text" select="$text"/>
3037
+ </xsl:call-template>
3038
+
3039
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3040
+ <xsl:param name="tag_open"/>
3041
+ <xsl:param name="tag_close"/>
2969
3042
  <xsl:param name="text"/>
2970
3043
  <xsl:choose>
2971
3044
  <xsl:when test="contains($text, $tag_open)">
2972
3045
  <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>
3046
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
2974
3047
  <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">
3048
+ <fo:inline keep-together.within-line="always">
3049
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3050
+ </fo:inline>
3051
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3052
+ <xsl:call-template name="replace_fo_inline_tags">
3053
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3054
+ <xsl:with-param name="tag_close" select="$tag_close"/>
2978
3055
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2979
3056
  </xsl:call-template>
2980
3057
  </xsl:when>
@@ -2982,6 +3059,39 @@
2982
3059
  </xsl:choose>
2983
3060
  </xsl:template><xsl:template match="*[local-name()='br']">
2984
3061
  <xsl:value-of select="$linebreak"/>
3062
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3063
+ <xsl:param name="split_keep-within-line"/>
3064
+
3065
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3066
+ <xsl:choose>
3067
+
3068
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3069
+ <xsl:variable name="sep">_</xsl:variable>
3070
+ <xsl:variable name="items">
3071
+ <xsl:call-template name="split">
3072
+ <xsl:with-param name="pText" select="."/>
3073
+ <xsl:with-param name="sep" select="$sep"/>
3074
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3075
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3076
+ </xsl:call-template>
3077
+ </xsl:variable>
3078
+ <xsl:for-each select="xalan:nodeset($items)/item">
3079
+ <xsl:choose>
3080
+ <xsl:when test=". = $sep">
3081
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3082
+ </xsl:when>
3083
+ <xsl:otherwise>
3084
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3085
+ </xsl:otherwise>
3086
+ </xsl:choose>
3087
+ </xsl:for-each>
3088
+ </xsl:when>
3089
+
3090
+ <xsl:otherwise>
3091
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3092
+ </xsl:otherwise>
3093
+
3094
+ </xsl:choose>
2985
3095
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
2986
3096
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
2987
3097
  <xsl:apply-templates/>
@@ -3066,11 +3176,24 @@
3066
3176
  <xsl:apply-templates/>
3067
3177
  </fo:block>
3068
3178
 
3069
- </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:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3070
-
3071
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3072
- <xsl:call-template name="add-zero-spaces-java"/>
3073
-
3179
+ </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3180
+ <xsl:choose>
3181
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3182
+ <xsl:value-of select="."/>
3183
+ </xsl:when>
3184
+ <xsl:otherwise>
3185
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3186
+ </xsl:otherwise>
3187
+ </xsl:choose>
3188
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3189
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3190
+ <!-- <xsl:copy-of select="$text"/> -->
3191
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3192
+ <xsl:choose>
3193
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3194
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3195
+ </xsl:choose>
3196
+ </xsl:for-each>
3074
3197
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3075
3198
 
3076
3199
  <xsl:variable name="table-preamble">
@@ -3082,9 +3205,14 @@
3082
3205
 
3083
3206
  <xsl:variable name="table">
3084
3207
 
3085
- <xsl:variable name="simple-table">
3086
- <xsl:call-template name="getSimpleTable"/>
3208
+ <xsl:variable name="simple-table">
3209
+ <xsl:call-template name="getSimpleTable">
3210
+ <xsl:with-param name="id" select="@id"/>
3211
+ </xsl:call-template>
3087
3212
  </xsl:variable>
3213
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3214
+
3215
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3088
3216
 
3089
3217
 
3090
3218
  <!-- Display table's name before table as standalone block -->
@@ -3107,7 +3235,23 @@
3107
3235
  </xsl:call-template>
3108
3236
  </xsl:if>
3109
3237
  </xsl:variable>
3110
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3238
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3239
+
3240
+ <!-- DEBUG -->
3241
+ <xsl:if test="$table_if_debug = 'true'">
3242
+ <fo:block font-size="60%">
3243
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3244
+ </fo:block>
3245
+ </xsl:if>
3246
+
3247
+
3248
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3249
+
3250
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3251
+ DEBUG
3252
+ colwidths=<xsl:copy-of select="$colwidths"/>
3253
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3254
+
3111
3255
 
3112
3256
 
3113
3257
  <xsl:variable name="margin-side">
@@ -3177,9 +3321,17 @@
3177
3321
  </xsl:element>
3178
3322
  </xsl:variable>
3179
3323
 
3324
+ <xsl:if test="$isGenerateTableIF = 'true'">
3325
+ <!-- to determine start of table -->
3326
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3327
+ </xsl:if>
3180
3328
 
3181
3329
  <fo:table id="{@id}">
3182
3330
 
3331
+ <xsl:if test="$isGenerateTableIF = 'true'">
3332
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3333
+ </xsl:if>
3334
+
3183
3335
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3184
3336
  <xsl:attribute name="{local-name()}">
3185
3337
  <xsl:value-of select="."/>
@@ -3193,24 +3345,47 @@
3193
3345
 
3194
3346
 
3195
3347
  <xsl:choose>
3196
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3197
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3198
- <fo:table-column column-width="{@width}"/>
3199
- </xsl:for-each>
3348
+ <xsl:when test="$isGenerateTableIF = 'true'">
3349
+ <!-- generate IF for table widths -->
3350
+ <!-- example:
3351
+ <tr>
3352
+ <td valign="top" align="left" id="tab-symdu_1_1">
3353
+ <p>Symbol</p>
3354
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3355
+ </td>
3356
+ <td valign="top" align="left" id="tab-symdu_1_2">
3357
+ <p>Description</p>
3358
+ <word id="tab-symdu_1_2_word_1">Description</word>
3359
+ </td>
3360
+ </tr>
3361
+ -->
3362
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3363
+
3200
3364
  </xsl:when>
3201
3365
  <xsl:otherwise>
3202
- <xsl:call-template name="insertTableColumnWidth">
3203
- <xsl:with-param name="colwidths" select="$colwidths"/>
3204
- </xsl:call-template>
3205
- </xsl:otherwise>
3206
- </xsl:choose>
3207
3366
 
3208
- <xsl:choose>
3209
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3210
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3211
- </xsl:when>
3212
- <xsl:otherwise>
3213
- <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 -->
3367
+ <xsl:choose>
3368
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3369
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3370
+ <fo:table-column column-width="{@width}"/>
3371
+ </xsl:for-each>
3372
+ </xsl:when>
3373
+ <xsl:otherwise>
3374
+ <xsl:call-template name="insertTableColumnWidth">
3375
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3376
+ </xsl:call-template>
3377
+ </xsl:otherwise>
3378
+ </xsl:choose>
3379
+
3380
+ <xsl:choose>
3381
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3382
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3383
+ </xsl:when>
3384
+ <xsl:otherwise>
3385
+ <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 -->
3386
+ </xsl:otherwise>
3387
+ </xsl:choose>
3388
+
3214
3389
  </xsl:otherwise>
3215
3390
  </xsl:choose>
3216
3391
 
@@ -3310,11 +3485,22 @@
3310
3485
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3311
3486
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3312
3487
  </xsl:template><xsl:template name="calculate-column-widths">
3488
+ <xsl:param name="table"/>
3489
+ <xsl:param name="cols-count"/>
3490
+
3491
+ <xsl:call-template name="calculate-column-widths-proportional">
3492
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3493
+ <xsl:with-param name="table" select="$table"/>
3494
+ </xsl:call-template>
3495
+
3496
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3313
3497
  <xsl:param name="table"/>
3314
3498
  <xsl:param name="cols-count"/>
3315
3499
  <xsl:param name="curr-col" select="1"/>
3316
3500
  <xsl:param name="width" select="0"/>
3317
3501
 
3502
+ <!-- table=<xsl:copy-of select="$table"/> -->
3503
+
3318
3504
  <xsl:if test="$curr-col &lt;= $cols-count">
3319
3505
  <xsl:variable name="widths">
3320
3506
  <xsl:choose>
@@ -3352,16 +3538,22 @@
3352
3538
  </xsl:for-each>
3353
3539
  </xsl:when>
3354
3540
  <xsl:otherwise>
3355
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3541
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3542
+
3543
+ <!-- <table><xsl:copy-of select="$table"/></table>
3544
+ -->
3545
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3356
3546
  <xsl:variable name="td_text">
3357
3547
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3358
3548
  </xsl:variable>
3549
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3359
3550
  <xsl:variable name="words">
3360
3551
  <xsl:variable name="string_with_added_zerospaces">
3361
3552
  <xsl:call-template name="add-zero-spaces-java">
3362
3553
  <xsl:with-param name="text" select="$td_text"/>
3363
3554
  </xsl:call-template>
3364
3555
  </xsl:variable>
3556
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3365
3557
  <xsl:call-template name="tokenize">
3366
3558
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3367
3559
  <!-- 2009 thinspace -->
@@ -3369,11 +3561,13 @@
3369
3561
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3370
3562
  </xsl:call-template>
3371
3563
  </xsl:variable>
3564
+ <!-- words=<xsl:copy-of select="$words"/> -->
3372
3565
  <xsl:variable name="max_length">
3373
3566
  <xsl:call-template name="max_length">
3374
3567
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3375
3568
  </xsl:call-template>
3376
3569
  </xsl:variable>
3570
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3377
3571
  <width>
3378
3572
  <xsl:variable name="divider">
3379
3573
  <xsl:choose>
@@ -3392,6 +3586,8 @@
3392
3586
  </xsl:choose>
3393
3587
  </xsl:variable>
3394
3588
 
3589
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3590
+
3395
3591
  <column>
3396
3592
  <xsl:for-each select="xalan:nodeset($widths)//width">
3397
3593
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3400,35 +3596,271 @@
3400
3596
  </xsl:if>
3401
3597
  </xsl:for-each>
3402
3598
  </column>
3403
- <xsl:call-template name="calculate-column-widths">
3599
+ <xsl:call-template name="calculate-column-widths-proportional">
3404
3600
  <xsl:with-param name="cols-count" select="$cols-count"/>
3405
3601
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3406
3602
  <xsl:with-param name="table" select="$table"/>
3407
3603
  </xsl:call-template>
3408
3604
  </xsl:if>
3409
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]" mode="td_text">
3410
- <xsl:apply-templates mode="td_text"/>
3411
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]/text()[translate(., $express_reference_characters, '') = '']" mode="td_text">
3605
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
3606
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3607
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3608
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3412
3609
 
3413
- <xsl:value-of select="."/>
3414
-
3610
+ <!-- if all capitals english letters or digits -->
3611
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
3612
+ <xsl:call-template name="repeat">
3613
+ <xsl:with-param name="char" select="'X'"/>
3614
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
3615
+ </xsl:call-template>
3616
+ </xsl:if>
3415
3617
  </xsl:template><xsl:template match="text()" mode="td_text">
3416
3618
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3417
3619
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3418
3620
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3419
3621
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3420
3622
  <xsl:value-of select="@target"/>
3421
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3422
- <xsl:variable name="mathml">
3423
- <xsl:for-each select="*">
3424
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3425
- <xsl:copy-of select="."/>
3426
- </xsl:if>
3623
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
3624
+ <xsl:if test="$isGenerateTableIF = 'false'">
3625
+ <xsl:variable name="mathml_">
3626
+ <xsl:for-each select="*">
3627
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3628
+ <xsl:copy-of select="."/>
3629
+ </xsl:if>
3630
+ </xsl:for-each>
3631
+ </xsl:variable>
3632
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
3633
+
3634
+ <xsl:variable name="math_text">
3635
+ <xsl:value-of select="normalize-space($mathml)"/>
3636
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
3637
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
3638
+ </xsl:variable>
3639
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3640
+ </xsl:if>
3641
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
3642
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
3643
+
3644
+ <!-- via intermediate format -->
3645
+
3646
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
3647
+
3648
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
3649
+
3650
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
3651
+
3652
+ <!-- get current table id -->
3653
+ <xsl:variable name="table_id" select="@id"/>
3654
+ <!-- find table by id in the file 'table_widths' -->
3655
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
3656
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
3657
+
3658
+ <!-- table='<xsl:copy-of select="$table"/>' -->
3659
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
3660
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
3661
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
3662
+
3663
+ <xsl:variable name="table_with_cell_widths_">
3664
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
3665
+ </xsl:variable>
3666
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
3667
+
3668
+ <!-- <xsl:if test="$table_if_debug = 'true'">
3669
+ <xsl:copy-of select="$table_with_cell_widths"/>
3670
+ </xsl:if> -->
3671
+
3672
+
3673
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
3674
+
3675
+ <xsl:variable name="column_widths_">
3676
+ <!-- iteration of columns -->
3677
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
3678
+ <xsl:variable name="pos" select="position()"/>
3679
+ <column>
3680
+ <xsl:attribute name="width_max">
3681
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
3682
+ <xsl:sort select="." data-type="number" order="descending"/>
3683
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3684
+ </xsl:for-each>
3685
+ </xsl:attribute>
3686
+ <xsl:attribute name="width_min">
3687
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
3688
+ <xsl:sort select="." data-type="number" order="descending"/>
3689
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3690
+ </xsl:for-each>
3691
+ </xsl:attribute>
3692
+ </column>
3427
3693
  </xsl:for-each>
3428
3694
  </xsl:variable>
3695
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
3696
+
3697
+ <!-- <column_widths>
3698
+ <xsl:copy-of select="$column_widths"/>
3699
+ </column_widths> -->
3700
+
3701
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
3702
+ <xsl:variable name="table_widths_">
3703
+ <table>
3704
+ <xsl:attribute name="width_max">
3705
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
3706
+ </xsl:attribute>
3707
+ <xsl:attribute name="width_min">
3708
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
3709
+ </xsl:attribute>
3710
+ </table>
3711
+ </xsl:variable>
3712
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
3713
+
3714
+ <xsl:variable name="page_width">
3715
+ <xsl:choose>
3716
+ <xsl:when test="$parent_table_page-width != ''">
3717
+ <xsl:value-of select="$parent_table_page-width"/>
3718
+ </xsl:when>
3719
+ <xsl:otherwise>
3720
+ <xsl:value-of select="@page-width"/>
3721
+ </xsl:otherwise>
3722
+ </xsl:choose>
3723
+ </xsl:variable>
3724
+
3725
+ <xsl:if test="$table_if_debug = 'true'">
3726
+ <table_width>
3727
+ <xsl:copy-of select="$table_widths"/>
3728
+ </table_width>
3729
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
3730
+ </xsl:if>
3731
+
3732
+
3733
+ <!-- There are three cases: -->
3734
+ <xsl:choose>
3735
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
3736
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
3737
+ <!-- call old algorithm -->
3738
+ <case1/>
3739
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
3740
+ <xsl:call-template name="calculate-column-widths-proportional">
3741
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3742
+ <xsl:with-param name="table" select="$table"/>
3743
+ </xsl:call-template> -->
3744
+ </xsl:when>
3745
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
3746
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
3747
+ <case2/>
3748
+ <autolayout/>
3749
+ <xsl:for-each select="$column_widths/column/@width_max">
3750
+ <column divider="100"><xsl:value-of select="."/></column>
3751
+ </xsl:for-each>
3752
+ </xsl:when>
3753
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
3754
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
3755
+ Lets also call D the difference between maximum and minimum width of the table.
3756
+ For each column, let d be the difference between maximum and minimum width of that column.
3757
+ Now set the column's width to the minimum width plus d times W over D.
3758
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
3759
+ <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)">
3760
+ <!-- difference between the available space and the minimum table width -->
3761
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
3762
+ <W><xsl:value-of select="$W"/></W>
3763
+ <!-- difference between maximum and minimum width of the table -->
3764
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
3765
+ <D><xsl:value-of select="$D"/></D>
3766
+ <case3/>
3767
+ <autolayout/>
3768
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
3769
+ <split_keep-within-line>true</split_keep-within-line>
3770
+ </xsl:if>
3771
+ <xsl:for-each select="$column_widths/column">
3772
+ <!-- difference between maximum and minimum width of that column. -->
3773
+ <xsl:variable name="d" select="@width_max - @width_min"/>
3774
+ <d><xsl:value-of select="$d"/></d>
3775
+ <width_min><xsl:value-of select="@width_min"/></width_min>
3776
+ <e><xsl:value-of select="$d * $W div $D"/></e>
3777
+ <!-- set the column's width to the minimum width plus d times W over D. -->
3778
+ <column divider="100">
3779
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3780
+ </column>
3781
+ </xsl:for-each>
3782
+
3783
+ </xsl:when>
3784
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
3785
+ </xsl:choose>
3786
+
3787
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
3788
+
3789
+ <!-- if nested 'dl' or 'table' -->
3790
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
3791
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
3792
+
3793
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
3794
+
3795
+ <xsl:variable name="parent_table_page-width_">
3796
+ <xsl:if test="$parent_table_id != ''">
3797
+ <!-- determine column number in the parent table -->
3798
+ <xsl:variable name="parent_table_column_number">
3799
+ <xsl:choose>
3800
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
3801
+ <xsl:otherwise> <!-- parent is table -->
3802
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
3803
+ </xsl:otherwise>
3804
+ </xsl:choose>
3805
+ </xsl:variable>
3806
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
3807
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
3808
+ </xsl:if>
3809
+ </xsl:variable>
3810
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
3811
+
3812
+ <!-- get current table id -->
3813
+ <xsl:variable name="table_id" select="@id"/>
3814
+
3815
+ <xsl:choose>
3816
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
3817
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
3818
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
3819
+ </xsl:when>
3820
+ <xsl:otherwise>
3821
+ <!-- recalculate columns width based on parent table width -->
3822
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
3823
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
3824
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
3825
+ </xsl:call-template>
3826
+ </xsl:for-each>
3827
+ </xsl:otherwise>
3828
+ </xsl:choose>
3429
3829
 
3430
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3431
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3830
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
3831
+ <xsl:copy>
3832
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
3833
+ </xsl:copy>
3834
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
3835
+ <xsl:copy>
3836
+ <xsl:copy-of select="@*"/>
3837
+
3838
+ <!-- The maximum width is given by the widest line. -->
3839
+ <xsl:attribute name="width_max">
3840
+ <xsl:for-each select="p_len">
3841
+ <xsl:sort select="." data-type="number" order="descending"/>
3842
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3843
+ </xsl:for-each>
3844
+ </xsl:attribute>
3845
+
3846
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
3847
+ <xsl:variable name="width_min">
3848
+ <xsl:for-each select="word_len">
3849
+ <xsl:sort select="." data-type="number" order="descending"/>
3850
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3851
+ </xsl:for-each>
3852
+ </xsl:variable>
3853
+ <xsl:attribute name="width_min">
3854
+ <xsl:value-of select="$width_min"/>
3855
+ </xsl:attribute>
3856
+
3857
+ <xsl:if test="$width_min = 0">
3858
+ <xsl:attribute name="width_min">1</xsl:attribute>
3859
+ </xsl:if>
3860
+
3861
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
3862
+
3863
+ </xsl:copy>
3432
3864
  </xsl:template><xsl:template match="*[local-name()='thead']">
3433
3865
  <xsl:param name="cols-count"/>
3434
3866
  <fo:table-header>
@@ -3513,6 +3945,7 @@
3513
3945
  </xsl:for-each>
3514
3946
  </xsl:when>
3515
3947
  <xsl:otherwise>
3948
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
3516
3949
  <xsl:call-template name="insertTableColumnWidth">
3517
3950
  <xsl:with-param name="colwidths" select="$colwidths"/>
3518
3951
  </xsl:call-template>
@@ -3592,6 +4025,52 @@
3592
4025
 
3593
4026
  </fo:table-body>
3594
4027
 
4028
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4029
+ <xsl:param name="table_or_dl">table</xsl:param>
4030
+ <xsl:apply-templates mode="process_table-if">
4031
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4032
+ </xsl:apply-templates>
4033
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4034
+ <xsl:param name="table_or_dl">table</xsl:param>
4035
+
4036
+ <fo:table-body>
4037
+ <xsl:for-each select="*[local-name() = 'tr']">
4038
+ <xsl:variable name="col_count" select="count(*)"/>
4039
+
4040
+ <!-- iteration for each tr/td -->
4041
+
4042
+ <xsl:choose>
4043
+ <xsl:when test="$table_or_dl = 'table'">
4044
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4045
+ <fo:table-row number-columns-spanned="{$col_count}">
4046
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4047
+ <xsl:call-template name="td"/>
4048
+ </fo:table-row>
4049
+ </xsl:for-each>
4050
+ </xsl:when>
4051
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4052
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4053
+ <xsl:variable name="is_dt" select="position() = 1"/>
4054
+
4055
+ <xsl:for-each select="*">
4056
+ <!-- <test><xsl:copy-of select="."/></test> -->
4057
+ <fo:table-row number-columns-spanned="{$col_count}">
4058
+ <xsl:choose>
4059
+ <xsl:when test="$is_dt">
4060
+ <xsl:call-template name="insert_dt_cell"/>
4061
+ </xsl:when>
4062
+ <xsl:otherwise>
4063
+ <xsl:call-template name="insert_dd_cell"/>
4064
+ </xsl:otherwise>
4065
+ </xsl:choose>
4066
+ </fo:table-row>
4067
+ </xsl:for-each>
4068
+ </xsl:for-each>
4069
+ </xsl:otherwise>
4070
+ </xsl:choose>
4071
+
4072
+ </xsl:for-each>
4073
+ </fo:table-body>
3595
4074
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3596
4075
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3597
4076
 
@@ -3683,7 +4162,7 @@
3683
4162
  </xsl:choose>
3684
4163
  </xsl:attribute>
3685
4164
  </xsl:if>
3686
- </xsl:template><xsl:template match="*[local-name()='td']">
4165
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
3687
4166
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
3688
4167
  <xsl:call-template name="setTextAlignment">
3689
4168
  <xsl:with-param name="default">left</xsl:with-param>
@@ -3717,11 +4196,24 @@
3717
4196
 
3718
4197
  <xsl:call-template name="setTableCellAttributes"/>
3719
4198
 
4199
+ <xsl:if test="$isGenerateTableIF = 'true'">
4200
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4201
+ <xsl:attribute name="text-align">left</xsl:attribute>
4202
+ </xsl:if>
4203
+
3720
4204
  <fo:block>
3721
4205
 
4206
+ <xsl:if test="$isGenerateTableIF = 'true'">
4207
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4208
+ </xsl:if>
4209
+
4210
+
4211
+
3722
4212
 
3723
-
3724
4213
  <xsl:apply-templates/>
4214
+
4215
+ <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"/> -->
4216
+
3725
4217
  </fo:block>
3726
4218
  </fo:table-cell>
3727
4219
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -3924,9 +4416,9 @@
3924
4416
  <!-- current hierarchy is 'figure' element -->
3925
4417
  <xsl:variable name="following_dl_colwidths">
3926
4418
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3927
- <xsl:variable name="html-table">
3928
- <xsl:variable name="doc_ns">
3929
-
4419
+ <xsl:variable name="simple-table">
4420
+ <!-- <xsl:variable name="doc_ns">
4421
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3930
4422
  </xsl:variable>
3931
4423
  <xsl:variable name="ns">
3932
4424
  <xsl:choose>
@@ -3937,7 +4429,7 @@
3937
4429
  <xsl:value-of select="substring-before(name(/*), '-')"/>
3938
4430
  </xsl:otherwise>
3939
4431
  </xsl:choose>
3940
- </xsl:variable>
4432
+ </xsl:variable> -->
3941
4433
 
3942
4434
  <xsl:for-each select="*[local-name() = 'dl'][1]">
3943
4435
  <tbody>
@@ -3948,7 +4440,7 @@
3948
4440
 
3949
4441
  <xsl:call-template name="calculate-column-widths">
3950
4442
  <xsl:with-param name="cols-count" select="2"/>
3951
- <xsl:with-param name="table" select="$html-table"/>
4443
+ <xsl:with-param name="table" select="$simple-table"/>
3952
4444
  </xsl:call-template>
3953
4445
 
3954
4446
  </xsl:if>
@@ -4072,8 +4564,10 @@
4072
4564
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4073
4565
  </xsl:variable>
4074
4566
 
4567
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
4568
+
4075
4569
  <xsl:choose>
4076
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
4570
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4077
4571
 
4078
4572
  <fo:block margin-bottom="12pt" text-align="left">
4079
4573
 
@@ -4088,7 +4582,7 @@
4088
4582
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4089
4583
  </fo:block>
4090
4584
 
4091
- </xsl:when>
4585
+ </xsl:when> <!-- END: only one component -->
4092
4586
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4093
4587
  <fo:block margin-bottom="12pt" text-align="left">
4094
4588
 
@@ -4102,8 +4596,8 @@
4102
4596
  </xsl:variable>
4103
4597
  <xsl:value-of select="$title-where"/>
4104
4598
  </fo:block>
4105
- </xsl:when>
4106
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
4599
+ </xsl:when> <!-- END: a few components -->
4600
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4107
4601
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4108
4602
 
4109
4603
 
@@ -4116,22 +4610,41 @@
4116
4610
  </xsl:variable>
4117
4611
  <xsl:value-of select="$title-key"/>
4118
4612
  </fo:block>
4119
- </xsl:when>
4613
+ </xsl:when> <!-- END: definition list in a figure -->
4120
4614
  </xsl:choose>
4121
4615
 
4122
4616
  <!-- a few components -->
4123
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
4617
+ <xsl:if test="$onlyOneComponent = 'false'">
4124
4618
  <fo:block>
4125
4619
 
4126
4620
 
4127
4621
 
4128
4622
 
4623
+
4624
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
4625
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4626
+ </xsl:if>
4627
+
4129
4628
  <fo:block>
4130
4629
 
4131
4630
 
4132
4631
 
4133
4632
 
4633
+ <xsl:apply-templates select="*[local-name() = 'name']">
4634
+ <xsl:with-param name="process">true</xsl:with-param>
4635
+ </xsl:apply-templates>
4636
+
4637
+ <xsl:if test="$isGenerateTableIF = 'true'">
4638
+ <!-- to determine start of table -->
4639
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
4640
+ </xsl:if>
4641
+
4134
4642
  <fo:table width="95%" table-layout="fixed">
4643
+
4644
+ <xsl:if test="$isGenerateTableIF = 'true'">
4645
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
4646
+ </xsl:if>
4647
+
4135
4648
 
4136
4649
  <xsl:choose>
4137
4650
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4140,69 +4653,174 @@
4140
4653
 
4141
4654
  </xsl:when>
4142
4655
  </xsl:choose>
4143
- <!-- create virtual html table for dl/[dt and dd] -->
4144
- <xsl:variable name="html-table">
4145
- <xsl:variable name="doc_ns">
4656
+
4657
+
4658
+
4659
+ <xsl:choose>
4660
+ <xsl:when test="$isGenerateTableIF = 'true'">
4661
+ <!-- generate IF for table widths -->
4662
+ <!-- example:
4663
+ <tr>
4664
+ <td valign="top" align="left" id="tab-symdu_1_1">
4665
+ <p>Symbol</p>
4666
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
4667
+ </td>
4668
+ <td valign="top" align="left" id="tab-symdu_1_2">
4669
+ <p>Description</p>
4670
+ <word id="tab-symdu_1_2_word_1">Description</word>
4671
+ </td>
4672
+ </tr>
4673
+ -->
4146
4674
 
4147
- </xsl:variable>
4148
- <xsl:variable name="ns">
4149
- <xsl:choose>
4150
- <xsl:when test="normalize-space($doc_ns) != ''">
4151
- <xsl:value-of select="normalize-space($doc_ns)"/>
4152
- </xsl:when>
4153
- <xsl:otherwise>
4154
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4155
- </xsl:otherwise>
4156
- </xsl:choose>
4157
- </xsl:variable>
4158
- <tbody>
4159
- <xsl:apply-templates mode="dl"/>
4160
- </tbody>
4161
- </xsl:variable>
4162
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4163
- <xsl:variable name="colwidths">
4164
- <xsl:call-template name="calculate-column-widths">
4165
- <xsl:with-param name="cols-count" select="2"/>
4166
- <xsl:with-param name="table" select="$html-table"/>
4167
- </xsl:call-template>
4168
- </xsl:variable>
4169
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4170
- <xsl:variable name="maxlength_dt">
4171
- <xsl:call-template name="getMaxLength_dt"/>
4172
- </xsl:variable>
4173
- <xsl:variable name="isContainsExpressReference_">
4174
- false
4175
- </xsl:variable>
4176
- <xsl:variable name="isContainsExpressReference" select="normalize-space($isContainsExpressReference_)"/>
4177
- <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4178
- <xsl:call-template name="setColumnWidth_dl">
4179
- <xsl:with-param name="colwidths" select="$colwidths"/>
4180
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4181
- <xsl:with-param name="isContainsExpressReference" select="$isContainsExpressReference"/>
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>
4675
+ <!-- create virtual html table for dl/[dt and dd] -->
4676
+ <xsl:variable name="simple-table">
4677
+
4678
+ <xsl:variable name="dl_table">
4679
+ <tbody>
4680
+ <xsl:apply-templates mode="dl_if">
4681
+ <xsl:with-param name="id" select="@id"/>
4682
+ </xsl:apply-templates>
4683
+ </tbody>
4684
+ </xsl:variable>
4685
+
4686
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
4687
+
4688
+ <!-- Step: replace <br/> to <p>...</p> -->
4689
+ <xsl:variable name="table_without_br">
4690
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
4691
+ </xsl:variable>
4692
+
4693
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
4694
+
4695
+ <!-- Step: add id to each cell -->
4696
+ <!-- add <word>...</word> for each word, image, math -->
4697
+ <xsl:variable name="simple-table-id">
4698
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
4699
+ <xsl:with-param name="id" select="@id"/>
4700
+ </xsl:apply-templates>
4701
+ </xsl:variable>
4702
+
4703
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
4704
+
4705
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
4706
+
4707
+ </xsl:variable>
4708
+
4709
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
4710
+
4711
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
4712
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
4713
+ </xsl:apply-templates>
4714
+
4715
+ </xsl:when>
4716
+ <xsl:otherwise>
4717
+
4718
+ <xsl:variable name="simple-table">
4719
+
4720
+ <xsl:variable name="dl_table">
4721
+ <tbody>
4722
+ <xsl:apply-templates mode="dl">
4723
+ <xsl:with-param name="id" select="@id"/>
4724
+ </xsl:apply-templates>
4725
+ </tbody>
4726
+ </xsl:variable>
4727
+
4728
+ <xsl:copy-of select="$dl_table"/>
4729
+ </xsl:variable>
4730
+
4731
+ <xsl:variable name="colwidths">
4732
+ <xsl:call-template name="calculate-column-widths">
4733
+ <xsl:with-param name="cols-count" select="2"/>
4734
+ <xsl:with-param name="table" select="$simple-table"/>
4735
+ </xsl:call-template>
4736
+ </xsl:variable>
4737
+
4738
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
4739
+ DEBUG
4740
+ colwidths=<xsl:copy-of select="$colwidths"/>
4741
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
4742
+
4743
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4744
+
4745
+ <xsl:variable name="maxlength_dt">
4746
+ <xsl:call-template name="getMaxLength_dt"/>
4747
+ </xsl:variable>
4748
+
4749
+ <xsl:variable name="isContainsKeepTogetherTag_">
4750
+ false
4751
+ </xsl:variable>
4752
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4753
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4754
+
4755
+
4756
+ <xsl:call-template name="setColumnWidth_dl">
4757
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4758
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4759
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4760
+ </xsl:call-template>
4761
+
4762
+ <fo:table-body>
4763
+
4764
+ <!-- DEBUG -->
4765
+ <xsl:if test="$table_if_debug = 'true'">
4766
+ <fo:table-row>
4767
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
4768
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
4769
+ </fo:table-cell>
4770
+ </fo:table-row>
4771
+ </xsl:if>
4772
+
4773
+ <xsl:apply-templates>
4774
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4775
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
4776
+ </xsl:apply-templates>
4777
+
4778
+ </fo:table-body>
4779
+ </xsl:otherwise>
4780
+ </xsl:choose>
4188
4781
  </fo:table>
4189
4782
  </fo:block>
4190
4783
  </fo:block>
4191
- </xsl:if>
4784
+ </xsl:if> <!-- END: a few components -->
4192
4785
  </fo:block-container>
4193
4786
  </fo:block-container>
4787
+
4788
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
4789
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
4790
+ </xsl:if>
4791
+
4792
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
4793
+ <xsl:param name="process">false</xsl:param>
4794
+ <xsl:if test="$process = 'true'">
4795
+ <fo:block xsl:use-attribute-sets="dl-name-style">
4796
+ <xsl:apply-templates/>
4797
+ </fo:block>
4798
+ </xsl:if>
4194
4799
  </xsl:template><xsl:template name="setColumnWidth_dl">
4195
4800
  <xsl:param name="colwidths"/>
4196
4801
  <xsl:param name="maxlength_dt"/>
4197
- <xsl:param name="isContainsExpressReference"/>
4802
+ <xsl:param name="isContainsKeepTogetherTag"/>
4803
+
4804
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
4805
+
4198
4806
  <xsl:choose>
4807
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
4808
+ <xsl:call-template name="insertTableColumnWidth">
4809
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4810
+ </xsl:call-template>
4811
+ </xsl:when>
4199
4812
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4200
4813
  <fo:table-column column-width="50%"/>
4201
4814
  <fo:table-column column-width="50%"/>
4202
4815
  </xsl:when>
4203
4816
  <xsl:otherwise>
4204
4817
  <xsl:choose>
4205
- <xsl:when test="$isContainsExpressReference">
4818
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
4819
+ <xsl:call-template name="insertTableColumnWidth">
4820
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4821
+ </xsl:call-template>
4822
+ </xsl:when>
4823
+ <xsl:when test="$isContainsKeepTogetherTag">
4206
4824
  <xsl:call-template name="insertTableColumnWidth">
4207
4825
  <xsl:with-param name="colwidths" select="$colwidths"/>
4208
4826
  </xsl:call-template>
@@ -4246,13 +4864,19 @@
4246
4864
  </xsl:choose>
4247
4865
  </xsl:template><xsl:template name="insertTableColumnWidth">
4248
4866
  <xsl:param name="colwidths"/>
4867
+
4249
4868
  <xsl:for-each select="xalan:nodeset($colwidths)//column">
4250
4869
  <xsl:choose>
4251
4870
  <xsl:when test=". = 1 or . = 0">
4252
4871
  <fo:table-column column-width="proportional-column-width(2)"/>
4253
4872
  </xsl:when>
4254
4873
  <xsl:otherwise>
4255
- <fo:table-column column-width="proportional-column-width({.})"/>
4874
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
4875
+ <xsl:variable name="divider">
4876
+ <xsl:value-of select="@divider"/>
4877
+ <xsl:if test="not(@divider)">1</xsl:if>
4878
+ </xsl:variable>
4879
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4256
4880
  </xsl:otherwise>
4257
4881
  </xsl:choose>
4258
4882
  </xsl:for-each>
@@ -4279,7 +4903,6 @@
4279
4903
  <xsl:value-of select="$maxLength"/>
4280
4904
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4281
4905
  <xsl:param name="key_iso"/>
4282
-
4283
4906
  <!-- <tr>
4284
4907
  <td>NOTE</td>
4285
4908
  <td>
@@ -4287,27 +4910,47 @@
4287
4910
  </td>
4288
4911
  </tr>
4289
4912
  -->
4290
- <fo:table-row>
4913
+ <!-- OLD Variant -->
4914
+ <!-- <fo:table-row>
4291
4915
  <fo:table-cell>
4292
4916
  <fo:block margin-top="6pt">
4293
4917
  <xsl:if test="normalize-space($key_iso) = 'true'">
4294
4918
  <xsl:attribute name="margin-top">0</xsl:attribute>
4295
4919
  </xsl:if>
4296
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4920
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4297
4921
  </fo:block>
4298
4922
  </fo:table-cell>
4299
4923
  <fo:table-cell>
4300
4924
  <fo:block>
4301
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4925
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4926
+ </fo:block>
4927
+ </fo:table-cell>
4928
+ </fo:table-row> -->
4929
+ <!-- <tr>
4930
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4931
+ </tr>
4932
+ -->
4933
+ <fo:table-row>
4934
+ <fo:table-cell number-columns-spanned="2">
4935
+ <fo:block>
4936
+ <xsl:call-template name="note"/>
4302
4937
  </fo:block>
4303
4938
  </fo:table-cell>
4304
4939
  </fo:table-row>
4305
4940
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
4941
+ <xsl:param name="id"/>
4942
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4306
4943
  <tr>
4307
4944
  <td>
4945
+ <xsl:attribute name="id">
4946
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
4947
+ </xsl:attribute>
4308
4948
  <xsl:apply-templates/>
4309
4949
  </td>
4310
4950
  <td>
4951
+ <xsl:attribute name="id">
4952
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
4953
+ </xsl:attribute>
4311
4954
 
4312
4955
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4313
4956
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4318,50 +4961,134 @@
4318
4961
 
4319
4962
  </xsl:template><xsl:template match="*[local-name()='dt']">
4320
4963
  <xsl:param name="key_iso"/>
4964
+ <xsl:param name="split_keep-within-line"/>
4321
4965
 
4322
4966
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4323
- <fo:table-cell>
4967
+ <xsl:call-template name="insert_dt_cell">
4968
+ <xsl:with-param name="key_iso" select="$key_iso"/>
4969
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4970
+ </xsl:call-template>
4971
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
4972
+ <xsl:call-template name="insert_dd_cell">
4973
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4974
+ </xsl:call-template>
4975
+ </xsl:for-each>
4976
+ </fo:table-row>
4977
+ </xsl:template><xsl:template name="insert_dt_cell">
4978
+ <xsl:param name="key_iso"/>
4979
+ <xsl:param name="split_keep-within-line"/>
4980
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
4981
+
4982
+ <xsl:if test="$isGenerateTableIF = 'true'">
4983
+ <!-- border is mandatory, to calculate real width -->
4984
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4985
+ <xsl:attribute name="text-align">left</xsl:attribute>
4986
+ </xsl:if>
4987
+
4988
+
4989
+ <fo:block xsl:use-attribute-sets="dt-block-style">
4990
+ <xsl:copy-of select="@id"/>
4991
+
4992
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4993
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4994
+ </xsl:if>
4995
+
4996
+
4997
+
4998
+ <xsl:apply-templates>
4999
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5000
+ </xsl:apply-templates>
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>
5006
+ </xsl:template><xsl:template name="insert_dd_cell">
5007
+ <xsl:param name="split_keep-within-line"/>
5008
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5009
+
5010
+ <xsl:if test="$isGenerateTableIF = 'true'">
5011
+ <!-- border is mandatory, to calculate real width -->
5012
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5013
+ </xsl:if>
5014
+
5015
+ <fo:block>
5016
+
5017
+ <xsl:if test="$isGenerateTableIF = 'true'">
5018
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5019
+ </xsl:if>
5020
+
4324
5021
 
4325
- <fo:block xsl:use-attribute-sets="dt-style">
4326
- <xsl:copy-of select="@id"/>
4327
-
4328
- <xsl:if test="normalize-space($key_iso) = 'true'">
4329
- <xsl:attribute name="margin-top">0</xsl:attribute>
4330
- </xsl:if>
4331
-
4332
-
4333
-
4334
- <xsl:apply-templates/>
4335
- </fo:block>
4336
- </fo:table-cell>
4337
- <fo:table-cell>
4338
- <fo:block>
4339
-
4340
5022
 
4341
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4342
- <xsl:with-param name="process">true</xsl:with-param>
4343
- </xsl:apply-templates>
4344
- </fo:block>
4345
- </fo:table-cell>
4346
- </fo:table-row>
5023
+ <xsl:choose>
5024
+ <xsl:when test="$isGenerateTableIF = 'true'">
5025
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5026
+ <xsl:with-param name="process">true</xsl:with-param>
5027
+ </xsl:apply-templates>
5028
+ </xsl:when>
5029
+ <xsl:otherwise>
5030
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5031
+ <xsl:with-param name="process">true</xsl:with-param>
5032
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5033
+ </xsl:apply-templates>
5034
+ </xsl:otherwise>
5035
+
5036
+ </xsl:choose>
5037
+
5038
+ <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"/> -->
5039
+
5040
+ </fo:block>
5041
+ </fo:table-cell>
4347
5042
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4348
5043
  <xsl:apply-templates/>
4349
5044
  </xsl:template><xsl:template match="*[local-name()='dd']">
4350
5045
  <xsl:param name="process">false</xsl:param>
5046
+ <xsl:param name="split_keep-within-line"/>
4351
5047
  <xsl:if test="$process = 'true'">
4352
5048
  <xsl:apply-templates select="@language"/>
4353
- <xsl:apply-templates/>
5049
+ <xsl:apply-templates>
5050
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5051
+ </xsl:apply-templates>
4354
5052
  </xsl:if>
4355
5053
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4356
5054
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4357
- </xsl:template><xsl:template match="*[local-name()='em']">
5055
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5056
+ <xsl:param name="id"/>
5057
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5058
+ <tr>
5059
+ <td>
5060
+ <xsl:copy-of select="node()"/>
5061
+ </td>
5062
+ <td>
5063
+
5064
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
5065
+
5066
+ <!-- get paragraphs from nested 'dl' -->
5067
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
5068
+
5069
+
5070
+ </td>
5071
+ </tr>
5072
+
5073
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
5074
+ <xsl:for-each select="*[local-name() = 'dt']">
5075
+ <p>
5076
+ <xsl:copy-of select="node()"/>
5077
+ <xsl:text> </xsl:text>
5078
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
5079
+ </p>
5080
+ </xsl:for-each>
5081
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
4358
5082
  <fo:inline font-style="italic">
4359
5083
  <xsl:apply-templates/>
4360
5084
  </fo:inline>
4361
5085
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5086
+ <xsl:param name="split_keep-within-line"/>
4362
5087
  <fo:inline font-weight="bold">
4363
5088
 
4364
- <xsl:apply-templates/>
5089
+ <xsl:apply-templates>
5090
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5091
+ </xsl:apply-templates>
4365
5092
  </fo:inline>
4366
5093
  </xsl:template><xsl:template match="*[local-name()='padding']">
4367
5094
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4382,7 +5109,7 @@
4382
5109
 
4383
5110
 
4384
5111
 
4385
-
5112
+ <!-- 10 -->
4386
5113
 
4387
5114
 
4388
5115
 
@@ -4400,13 +5127,15 @@
4400
5127
  <xsl:choose>
4401
5128
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4402
5129
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4403
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5130
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4404
5131
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4405
5132
  </xsl:choose>
4406
5133
  </xsl:attribute>
4407
5134
  </xsl:if>
4408
5135
  <xsl:apply-templates/>
4409
5136
  </fo:inline>
5137
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
5138
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4410
5139
  </xsl:template><xsl:template match="*[local-name()='underline']">
4411
5140
  <fo:inline text-decoration="underline">
4412
5141
  <xsl:apply-templates/>
@@ -4554,54 +5283,120 @@
4554
5283
  <fo:block break-after="page"/>
4555
5284
  <fo:block> </fo:block>
4556
5285
  <fo:block break-after="page"/>
5286
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5287
+ <xsl:apply-templates/>
4557
5288
  </xsl:template><xsl:template name="tokenize">
4558
5289
  <xsl:param name="text"/>
4559
5290
  <xsl:param name="separator" select="' '"/>
4560
5291
  <xsl:choose>
5292
+
5293
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5294
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5295
+ </xsl:when>
4561
5296
  <xsl:when test="not(contains($text, $separator))">
4562
5297
  <word>
4563
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4564
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4565
5298
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4566
- <xsl:variable name="len_str">
4567
- <xsl:choose>
4568
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4569
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4570
- </xsl:when>
4571
- <xsl:otherwise>
4572
- <xsl:value-of select="$len_str_tmp"/>
4573
- </xsl:otherwise>
4574
- </xsl:choose>
4575
- </xsl:variable>
4576
-
4577
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4578
- <xsl:message>
4579
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4580
- len_str=<xsl:value-of select="$len_str"/>
4581
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4582
- </xsl:message>
4583
- </xsl:if> -->
4584
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4585
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4586
5299
  <xsl:choose>
4587
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4588
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5300
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5301
+ <xsl:value-of select="$len_str_tmp"/>
4589
5302
  </xsl:when>
4590
5303
  <xsl:otherwise>
4591
- <xsl:value-of select="$len_str"/>
5304
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5305
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5306
+ <xsl:variable name="len_str">
5307
+ <xsl:choose>
5308
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5309
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5310
+ </xsl:when>
5311
+ <xsl:otherwise>
5312
+ <xsl:value-of select="$len_str_tmp"/>
5313
+ </xsl:otherwise>
5314
+ </xsl:choose>
5315
+ </xsl:variable>
5316
+
5317
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5318
+ <xsl:message>
5319
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5320
+ len_str=<xsl:value-of select="$len_str"/>
5321
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5322
+ </xsl:message>
5323
+ </xsl:if> -->
5324
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5325
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5326
+ <xsl:choose>
5327
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5328
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5329
+ </xsl:when>
5330
+ <xsl:otherwise>
5331
+ <xsl:value-of select="$len_str"/>
5332
+ </xsl:otherwise>
5333
+ </xsl:choose>
4592
5334
  </xsl:otherwise>
4593
5335
  </xsl:choose>
4594
5336
  </word>
4595
5337
  </xsl:when>
4596
5338
  <xsl:otherwise>
4597
5339
  <word>
4598
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5340
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5341
+ <xsl:choose>
5342
+ <xsl:when test="$isGenerateTableIF = 'true'">
5343
+ <xsl:value-of select="$word"/>
5344
+ </xsl:when>
5345
+ <xsl:otherwise>
5346
+ <xsl:value-of select="string-length($word)"/>
5347
+ </xsl:otherwise>
5348
+ </xsl:choose>
4599
5349
  </word>
4600
5350
  <xsl:call-template name="tokenize">
4601
5351
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
4602
5352
  </xsl:call-template>
4603
5353
  </xsl:otherwise>
4604
5354
  </xsl:choose>
5355
+ </xsl:template><xsl:template name="tokenize_with_tags">
5356
+ <xsl:param name="tags"/>
5357
+ <xsl:param name="text"/>
5358
+ <xsl:param name="separator" select="' '"/>
5359
+ <xsl:choose>
5360
+
5361
+ <xsl:when test="not(contains($text, $separator))">
5362
+ <word>
5363
+ <xsl:call-template name="enclose_text_in_tags">
5364
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5365
+ <xsl:with-param name="tags" select="$tags"/>
5366
+ </xsl:call-template>
5367
+ </word>
5368
+ </xsl:when>
5369
+ <xsl:otherwise>
5370
+ <word>
5371
+ <xsl:call-template name="enclose_text_in_tags">
5372
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5373
+ <xsl:with-param name="tags" select="$tags"/>
5374
+ </xsl:call-template>
5375
+ </word>
5376
+ <xsl:call-template name="tokenize_with_tags">
5377
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5378
+ </xsl:call-template>
5379
+ </xsl:otherwise>
5380
+ </xsl:choose>
5381
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5382
+ <xsl:param name="text"/>
5383
+ <xsl:param name="tags"/>
5384
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5385
+
5386
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5387
+
5388
+ <xsl:choose>
5389
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5390
+ <xsl:otherwise>
5391
+ <xsl:element name="{$tag_name}">
5392
+ <xsl:call-template name="enclose_text_in_tags">
5393
+ <xsl:with-param name="text" select="$text"/>
5394
+ <xsl:with-param name="tags" select="$tags"/>
5395
+ <xsl:with-param name="num" select="$num + 1"/>
5396
+ </xsl:call-template>
5397
+ </xsl:element>
5398
+ </xsl:otherwise>
5399
+ </xsl:choose>
4605
5400
  </xsl:template><xsl:template name="max_length">
4606
5401
  <xsl:param name="words"/>
4607
5402
  <xsl:for-each select="$words//word">
@@ -4702,12 +5497,19 @@
4702
5497
  </xsl:otherwise>
4703
5498
  </xsl:choose>
4704
5499
  </xsl:template><xsl:template name="getSimpleTable">
5500
+ <xsl:param name="id"/>
5501
+
4705
5502
  <xsl:variable name="simple-table">
4706
5503
 
5504
+ <!-- Step 0. replace <br/> to <p>...</p> -->
5505
+ <xsl:variable name="table_without_br">
5506
+ <xsl:apply-templates mode="table-without-br"/>
5507
+ </xsl:variable>
5508
+
4707
5509
  <!-- Step 1. colspan processing -->
4708
5510
  <xsl:variable name="simple-table-colspan">
4709
5511
  <tbody>
4710
- <xsl:apply-templates mode="simple-table-colspan"/>
5512
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
4711
5513
  </tbody>
4712
5514
  </xsl:variable>
4713
5515
 
@@ -4716,10 +5518,67 @@
4716
5518
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
4717
5519
  </xsl:variable>
4718
5520
 
4719
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
4720
-
5521
+ <!-- Step 3: add id to each cell -->
5522
+ <!-- add <word>...</word> for each word, image, math -->
5523
+ <xsl:variable name="simple-table-id">
5524
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
5525
+ <xsl:with-param name="id" select="$id"/>
5526
+ </xsl:apply-templates>
5527
+ </xsl:variable>
5528
+
5529
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5530
+
4721
5531
  </xsl:variable>
4722
5532
  <xsl:copy-of select="$simple-table"/>
5533
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
5534
+ <xsl:copy>
5535
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
5536
+ </xsl:copy>
5537
+ </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">
5538
+ <xsl:copy>
5539
+ <xsl:copy-of select="@*"/>
5540
+ <p>
5541
+ <xsl:copy-of select="node()"/>
5542
+ </p>
5543
+ </xsl:copy>
5544
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
5545
+ <xsl:copy>
5546
+ <xsl:copy-of select="@*"/>
5547
+ <xsl:for-each select="*[local-name()='br']">
5548
+ <xsl:variable name="current_id" select="generate-id()"/>
5549
+ <p>
5550
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5551
+ <xsl:copy-of select="."/>
5552
+ </xsl:for-each>
5553
+ </p>
5554
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5555
+ <p>
5556
+ <xsl:for-each select="following-sibling::node()">
5557
+ <xsl:copy-of select="."/>
5558
+ </xsl:for-each>
5559
+ </p>
5560
+ </xsl:if>
5561
+ </xsl:for-each>
5562
+ </xsl:copy>
5563
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
5564
+ <xsl:for-each select="*[local-name()='br']">
5565
+ <xsl:variable name="current_id" select="generate-id()"/>
5566
+ <p>
5567
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5568
+ <xsl:copy-of select="."/>
5569
+ </xsl:for-each>
5570
+ </p>
5571
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5572
+ <p>
5573
+ <xsl:for-each select="following-sibling::node()">
5574
+ <xsl:copy-of select="."/>
5575
+ </xsl:for-each>
5576
+ </p>
5577
+ </xsl:if>
5578
+ </xsl:for-each>
5579
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
5580
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
5581
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
4723
5582
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
4724
5583
  <xsl:apply-templates mode="simple-table-colspan"/>
4725
5584
  </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">
@@ -4797,18 +5656,138 @@
4797
5656
  </xsl:choose>
4798
5657
  </xsl:for-each>
4799
5658
  </xsl:variable>
4800
-
4801
- <xsl:variable name="newRow">
4802
- <xsl:copy>
4803
- <xsl:copy-of select="$currentRow/@*"/>
4804
- <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
4805
- </xsl:copy>
5659
+
5660
+ <xsl:variable name="newRow">
5661
+ <xsl:copy>
5662
+ <xsl:copy-of select="$currentRow/@*"/>
5663
+ <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
5664
+ </xsl:copy>
5665
+ </xsl:variable>
5666
+ <xsl:copy-of select="$newRow"/>
5667
+
5668
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5669
+ <xsl:with-param name="previousRow" select="$newRow"/>
5670
+ </xsl:apply-templates>
5671
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
5672
+ <xsl:param name="id"/>
5673
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
5674
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5675
+ <xsl:with-param name="id" select="$id_prefixed"/>
5676
+ </xsl:apply-templates>
5677
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
5678
+ <xsl:param name="id"/>
5679
+ <xsl:copy>
5680
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5681
+ <xsl:with-param name="id" select="$id"/>
5682
+ </xsl:apply-templates>
5683
+ </xsl:copy>
5684
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
5685
+ <xsl:param name="id"/>
5686
+ <xsl:copy>
5687
+ <xsl:copy-of select="@*"/>
5688
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
5689
+ <xsl:apply-templates select="node()" mode="simple-table-id">
5690
+ <xsl:with-param name="id" select="$id"/>
5691
+ </xsl:apply-templates>
5692
+ </xsl:copy>
5693
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
5694
+ <xsl:param name="id"/>
5695
+ <xsl:copy>
5696
+ <xsl:copy-of select="@*"/>
5697
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
5698
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
5699
+ <xsl:attribute name="id">
5700
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
5701
+ </xsl:attribute>
5702
+
5703
+ <xsl:for-each select="*[local-name() = 'p']">
5704
+ <xsl:copy>
5705
+ <xsl:copy-of select="@*"/>
5706
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
5707
+ <xsl:attribute name="id">
5708
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
5709
+ </xsl:attribute>
5710
+
5711
+ <xsl:copy-of select="node()"/>
5712
+ </xsl:copy>
5713
+ </xsl:for-each>
5714
+
5715
+
5716
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
5717
+
5718
+ <xsl:variable name="td_text">
5719
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
5720
+ </xsl:variable>
5721
+
5722
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
5723
+
5724
+ <xsl:variable name="words">
5725
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
5726
+ <word>
5727
+ <xsl:copy-of select="."/>
5728
+ </word>
5729
+ </xsl:for-each>
5730
+
5731
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
5732
+ <xsl:copy-of select="."/>
5733
+ </xsl:for-each>
5734
+
5735
+ </xsl:variable>
5736
+
5737
+ <xsl:for-each select="xalan:nodeset($words)/word">
5738
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
5739
+ <xsl:copy>
5740
+ <xsl:attribute name="id">
5741
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
5742
+ </xsl:attribute>
5743
+ <xsl:copy-of select="node()"/>
5744
+ </xsl:copy>
5745
+ </xsl:for-each>
5746
+ </xsl:if>
5747
+ </xsl:copy>
5748
+
5749
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
5750
+ <xsl:copy>
5751
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
5752
+ </xsl:copy>
5753
+ </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">
5754
+ <xsl:variable name="formatting_tags">
5755
+ <xsl:call-template name="getFormattingTags"/>
5756
+ </xsl:variable>
5757
+ <word>
5758
+ <xsl:call-template name="enclose_text_in_tags">
5759
+ <xsl:with-param name="text" select="normalize-space(.)"/>
5760
+ <xsl:with-param name="tags" select="$formatting_tags"/>
5761
+ </xsl:call-template>
5762
+ </word>
5763
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
5764
+
5765
+ <xsl:variable name="td_text" select="."/>
5766
+
5767
+ <xsl:variable name="string_with_added_zerospaces">
5768
+ <xsl:call-template name="add-zero-spaces-java">
5769
+ <xsl:with-param name="text" select="$td_text"/>
5770
+ </xsl:call-template>
4806
5771
  </xsl:variable>
4807
- <xsl:copy-of select="$newRow"/>
4808
-
4809
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
4810
- <xsl:with-param name="previousRow" select="$newRow"/>
4811
- </xsl:apply-templates>
5772
+
5773
+ <xsl:variable name="formatting_tags">
5774
+ <xsl:call-template name="getFormattingTags"/>
5775
+ </xsl:variable>
5776
+
5777
+ <!-- <word>text</word> -->
5778
+ <xsl:call-template name="tokenize_with_tags">
5779
+ <xsl:with-param name="tags" select="$formatting_tags"/>
5780
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
5781
+ </xsl:call-template>
5782
+ </xsl:template><xsl:template name="getFormattingTags">
5783
+ <tags>
5784
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
5785
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
5786
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
5787
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
5788
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
5789
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
5790
+ </tags>
4812
5791
  </xsl:template><xsl:template name="getLang">
4813
5792
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
4814
5793
  <xsl:variable name="language">
@@ -4977,7 +5956,9 @@
4977
5956
  <!-- replace start and end spaces to non-break space -->
4978
5957
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4979
5958
  </xsl:copy>
4980
- </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">
5959
+ </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">
5960
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5961
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
4981
5962
  <xsl:variable name="target">
4982
5963
  <xsl:choose>
4983
5964
  <xsl:when test="@updatetype = 'true'">
@@ -5799,7 +6780,11 @@
5799
6780
  <xsl:apply-templates mode="bookmarks"/>
5800
6781
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
5801
6782
  <xsl:apply-templates select="."/>
5802
- </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">
6783
+ </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">
6784
+ <xsl:apply-templates mode="contents"/>
6785
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
6786
+ <xsl:apply-templates mode="bookmarks"/>
6787
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
5803
6788
  <xsl:apply-templates mode="bookmarks"/>
5804
6789
  </xsl:template><xsl:template name="addBookmarks">
5805
6790
  <xsl:param name="contents"/>
@@ -6094,7 +7079,9 @@
6094
7079
  <xsl:apply-templates/>
6095
7080
  </xsl:otherwise>
6096
7081
  </xsl:choose>
6097
- </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">
7082
+ </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">
7083
+ <xsl:value-of select="."/>
7084
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6098
7085
  <xsl:text> </xsl:text>
6099
7086
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6100
7087
  <xsl:copy>
@@ -6125,9 +7112,22 @@
6125
7112
  </xsl:when>
6126
7113
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6127
7114
  </xsl:choose>
7115
+ </xsl:template><xsl:template match="text()" mode="contents_item">
7116
+ <xsl:call-template name="keep_together_standard_number"/>
7117
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
7118
+ <xsl:apply-templates mode="contents_item"/>
6128
7119
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6129
7120
 
6130
7121
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7122
+
7123
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7124
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7125
+ </xsl:if>
7126
+
7127
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7128
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7129
+ </xsl:if>
7130
+
6131
7131
  <xsl:copy-of select="@id"/>
6132
7132
 
6133
7133
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6156,7 +7156,7 @@
6156
7156
 
6157
7157
 
6158
7158
 
6159
-
7159
+ <!-- 9 -->
6160
7160
 
6161
7161
 
6162
7162
 
@@ -6248,7 +7248,7 @@
6248
7248
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6249
7249
  <xsl:choose>
6250
7250
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6251
- <xsl:call-template name="interspers">
7251
+ <xsl:call-template name="interspers-java">
6252
7252
  <xsl:with-param name="str" select="."/>
6253
7253
  </xsl:call-template>
6254
7254
  </xsl:when>
@@ -6298,6 +7298,10 @@
6298
7298
  <xsl:with-param name="char" select="$char"/>
6299
7299
  </xsl:call-template>
6300
7300
  </xsl:if>
7301
+ </xsl:template><xsl:template name="interspers-java">
7302
+ <xsl:param name="str"/>
7303
+ <xsl:param name="char" select="$zero_width_space"/>
7304
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
6301
7305
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6302
7306
  <xsl:apply-templates mode="syntax_highlight"/>
6303
7307
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6518,7 +7522,9 @@
6518
7522
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
6519
7523
  </xsl:if>
6520
7524
  <xsl:variable name="simple-table">
6521
- <xsl:call-template name="getSimpleTable"/>
7525
+ <xsl:call-template name="getSimpleTable">
7526
+ <xsl:with-param name="id" select="@id"/>
7527
+ </xsl:call-template>
6522
7528
  </xsl:variable>
6523
7529
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
6524
7530
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -6627,39 +7633,67 @@
6627
7633
  </xsl:otherwise>
6628
7634
  </xsl:choose>
6629
7635
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6630
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6631
-
7636
+
7637
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7638
+
6632
7639
 
7640
+
6633
7641
  <xsl:variable name="fo_element">
6634
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
7642
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6635
7643
  inline
6636
7644
  </xsl:variable>
6637
7645
 
6638
- <!-- display 'EXAMPLE' -->
6639
- <xsl:apply-templates select="*[local-name()='name']">
6640
- <xsl:with-param name="fo_element" select="$fo_element"/>
6641
- </xsl:apply-templates>
7646
+ <fo:block-container margin-left="0mm">
6642
7647
 
6643
- <xsl:choose>
6644
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6645
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6646
- <fo:block-container margin-left="0mm" margin-right="0mm">
6647
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7648
+ <xsl:choose>
7649
+
7650
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
7651
+
7652
+ <!-- display name 'EXAMPLE' in a separate block -->
7653
+ <fo:block>
7654
+ <xsl:apply-templates select="*[local-name()='name']">
6648
7655
  <xsl:with-param name="fo_element" select="$fo_element"/>
6649
7656
  </xsl:apply-templates>
7657
+ </fo:block>
7658
+
7659
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7660
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7661
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7662
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7663
+ </xsl:apply-templates>
7664
+ </fo:block-container>
6650
7665
  </fo:block-container>
6651
- </fo:block-container>
6652
- </xsl:when>
6653
- <xsl:otherwise>
6654
- <fo:inline>
6655
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6656
- <xsl:with-param name="fo_element" select="$fo_element"/>
6657
- </xsl:apply-templates>
6658
- </fo:inline>
6659
- </xsl:otherwise>
6660
- </xsl:choose>
6661
-
6662
- </fo:block>
7666
+ </xsl:when> <!-- end block -->
7667
+
7668
+ <xsl:otherwise> <!-- inline -->
7669
+
7670
+ <!-- display 'EXAMPLE' and first element in the same line -->
7671
+ <fo:block>
7672
+ <xsl:apply-templates select="*[local-name()='name']">
7673
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7674
+ </xsl:apply-templates>
7675
+ <fo:inline>
7676
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
7677
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7678
+ </xsl:apply-templates>
7679
+ </fo:inline>
7680
+ </fo:block>
7681
+
7682
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
7683
+ <!-- display further elements in blocks -->
7684
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7685
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7686
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
7687
+ <xsl:with-param name="fo_element" select="'block'"/>
7688
+ </xsl:apply-templates>
7689
+ </fo:block-container>
7690
+ </fo:block-container>
7691
+ </xsl:if>
7692
+ </xsl:otherwise> <!-- end inline -->
7693
+
7694
+ </xsl:choose>
7695
+ </fo:block-container>
7696
+ </fo:block-container>
6663
7697
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6664
7698
  <xsl:param name="fo_element">block</xsl:param>
6665
7699
 
@@ -6691,10 +7725,16 @@
6691
7725
  </xsl:variable>
6692
7726
  <xsl:choose>
6693
7727
  <xsl:when test="starts-with(normalize-space($element), 'block')">
6694
- <fo:block xsl:use-attribute-sets="example-p-style">
6695
-
6696
- <xsl:apply-templates/>
6697
- </fo:block>
7728
+ <fo:block-container>
7729
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
7730
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7731
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7732
+ </xsl:if>
7733
+ <fo:block xsl:use-attribute-sets="example-p-style">
7734
+
7735
+ <xsl:apply-templates/>
7736
+ </fo:block>
7737
+ </fo:block-container>
6698
7738
  </xsl:when>
6699
7739
  <xsl:otherwise>
6700
7740
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -6873,7 +7913,16 @@
6873
7913
  </fo:inline>
6874
7914
  </xsl:when>
6875
7915
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6876
- <fo:inline><xsl:apply-templates/></fo:inline>
7916
+
7917
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
7918
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
7919
+ <xsl:choose>
7920
+ <xsl:when test="$uri_src != ''">
7921
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
7922
+ </xsl:when>
7923
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
7924
+ </xsl:choose>
7925
+
6877
7926
  </xsl:otherwise>
6878
7927
  </xsl:choose>
6879
7928
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7049,10 +8098,24 @@
7049
8098
 
7050
8099
  </fo:block>
7051
8100
  <xsl:apply-templates/>
7052
- </xsl:template><xsl:template match="*[local-name() = 'review']">
8101
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7053
8102
  <!-- comment 2019-11-29 -->
7054
8103
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7055
8104
  <xsl:apply-templates /> -->
8105
+
8106
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
8107
+
8108
+ <xsl:choose>
8109
+ <!-- if there isn't the attribute '@from', then -->
8110
+ <xsl:when test="$id_from = ''">
8111
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8112
+ </xsl:when>
8113
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
8114
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
8115
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8116
+ </xsl:when>
8117
+ </xsl:choose>
8118
+
7056
8119
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7057
8120
  <!-- 0xA0 to space replacement -->
7058
8121
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7197,6 +8260,11 @@
7197
8260
  </xsl:otherwise>
7198
8261
  </xsl:choose>
7199
8262
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
8263
+
8264
+ <xsl:apply-templates select="*[local-name() = 'name']">
8265
+ <xsl:with-param name="process">true</xsl:with-param>
8266
+ </xsl:apply-templates>
8267
+
7200
8268
  <fo:list-block xsl:use-attribute-sets="list-style">
7201
8269
 
7202
8270
 
@@ -7207,12 +8275,23 @@
7207
8275
 
7208
8276
 
7209
8277
 
8278
+ <xsl:if test="*[local-name() = 'name']">
8279
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8280
+ </xsl:if>
8281
+
7210
8282
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7211
8283
  </fo:list-block>
7212
8284
  <!-- <xsl:for-each select="./iho:note">
7213
8285
  <xsl:call-template name="note"/>
7214
8286
  </xsl:for-each> -->
7215
8287
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
8288
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
8289
+ <xsl:param name="process">false</xsl:param>
8290
+ <xsl:if test="$process = 'true'">
8291
+ <fo:block xsl:use-attribute-sets="list-name-style">
8292
+ <xsl:apply-templates/>
8293
+ </fo:block>
8294
+ </xsl:if>
7216
8295
  </xsl:template><xsl:template match="*[local-name()='li']">
7217
8296
  <fo:list-item xsl:use-attribute-sets="list-item-style">
7218
8297
  <xsl:copy-of select="@id"/>
@@ -7417,7 +8496,10 @@
7417
8496
  <!-- to split by '_' and other chars -->
7418
8497
  <xsl:call-template name="add-zero-spaces-java"/>
7419
8498
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7420
- <fo:inline id="{@id}" font-size="1pt"/>
8499
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8500
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8501
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8502
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7421
8503
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7422
8504
  <!-- <row>
7423
8505
  <date>05-07-2013</date>
@@ -7518,145 +8600,7 @@
7518
8600
  <xsl:if test=".//ogc:fn">
7519
8601
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
7520
8602
  </xsl:if>
7521
- <xsl:choose>
7522
- <xsl:when test="*[local-name() = 'formattedref']">
7523
- <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
7524
- </xsl:when>
7525
- <xsl:otherwise>
7526
- <xsl:variable name="personalAuthors">
7527
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']/*[local-name() = 'person']">
7528
- <xsl:call-template name="processPersonalAuthor"/>
7529
- </xsl:for-each>
7530
- <xsl:if test="not(*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']/*[local-name() = 'person'])">
7531
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='editor']/*[local-name() = 'person']">
7532
- <xsl:call-template name="processPersonalAuthor"/>
7533
- </xsl:for-each>
7534
- </xsl:if>
7535
- </xsl:variable>
7536
-
7537
- <xsl:variable name="city" select="*[local-name() = 'place']"/>
7538
- <xsl:variable name="year">
7539
- <xsl:choose>
7540
- <xsl:when test="*[local-name() = 'date'][@type = 'published']">
7541
- <xsl:for-each select="*[local-name() = 'date'][@type = 'published']">
7542
- <xsl:call-template name="renderDate"/>
7543
- </xsl:for-each>
7544
- </xsl:when>
7545
- <xsl:when test="*[local-name() = 'date'][@type = 'issued']">
7546
- <xsl:for-each select="*[local-name() = 'date'][@type = 'issued']">
7547
- <xsl:call-template name="renderDate"/>
7548
- </xsl:for-each>
7549
- </xsl:when>
7550
- <xsl:when test="*[local-name() = 'date'][@type = 'circulated']">
7551
- <xsl:for-each select="*[local-name() = 'date'][@type = 'circulated']">
7552
- <xsl:call-template name="renderDate"/>
7553
- </xsl:for-each>
7554
- </xsl:when>
7555
- <xsl:otherwise>
7556
- <xsl:for-each select="*[local-name() = 'date']">
7557
- <xsl:call-template name="renderDate"/>
7558
- </xsl:for-each>
7559
- </xsl:otherwise>
7560
- </xsl:choose>
7561
- </xsl:variable>
7562
-
7563
- <xsl:variable name="uri" select="*[local-name() = 'uri']"/>
7564
-
7565
-
7566
- <!-- citation structure:
7567
- {personal names | organisation}: {document identifier}, {title}. {publisher}, {city} ({year})
7568
- -->
7569
-
7570
- <!-- Author(s) -->
7571
- <xsl:choose>
7572
- <xsl:when test="xalan:nodeset($personalAuthors)//author">
7573
- <xsl:for-each select="xalan:nodeset($personalAuthors)//author">
7574
- <xsl:apply-templates/>
7575
- <xsl:if test="position() != last()">, </xsl:if>
7576
- </xsl:for-each>
7577
- <xsl:text>: </xsl:text>
7578
- </xsl:when>
7579
- <xsl:when test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'abbreviation']">
7580
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'abbreviation']">
7581
- <xsl:value-of select="."/>
7582
- <xsl:if test="position() != last()">/</xsl:if>
7583
- </xsl:for-each>
7584
- <xsl:text>: </xsl:text>
7585
- </xsl:when>
7586
- <xsl:when test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
7587
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
7588
- <xsl:value-of select="."/>
7589
- <xsl:if test="position() != last()">, </xsl:if>
7590
- </xsl:for-each>
7591
- <xsl:text>: </xsl:text>
7592
- </xsl:when>
7593
- </xsl:choose>
7594
-
7595
-
7596
- <xsl:variable name="document_identifier">
7597
- <xsl:call-template name="processBibitemDocId"/>
7598
- </xsl:variable>
7599
-
7600
- <xsl:value-of select="$document_identifier"/>
7601
-
7602
- <xsl:apply-templates select="*[local-name() = 'note']"/>
7603
-
7604
- <xsl:variable name="isDraft">
7605
- <xsl:variable name="stage" select="normalize-space(*[local-name() = 'status']/*[local-name() = 'stage'])"/>
7606
- <xsl:if test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization'][*[local-name() = 'name']/text() = 'Open Geospatial Consortium'] and $stage != '' and $stage != 'published' and $stage != 'deprecated' and $stage != 'retired'">true</xsl:if>
7607
- </xsl:variable>
7608
-
7609
- <xsl:if test="$isDraft = 'true'">
7610
- <xsl:text> (Draft)</xsl:text>
7611
- </xsl:if>
7612
-
7613
- <xsl:text>, </xsl:text>
7614
-
7615
- <xsl:choose>
7616
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = 'en']">
7617
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = 'en']"/>
7618
- </xsl:when>
7619
- <xsl:otherwise>
7620
- <xsl:apply-templates select="*[local-name() = 'title']"/>
7621
- </xsl:otherwise>
7622
- </xsl:choose>
7623
-
7624
- <xsl:text>. </xsl:text>
7625
-
7626
- <xsl:if test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
7627
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
7628
- <xsl:value-of select="."/>
7629
- <xsl:if test="position() != last()">, </xsl:if>
7630
- </xsl:for-each>
7631
- <xsl:if test="normalize-space($city) != ''">, </xsl:if>
7632
- </xsl:if>
7633
-
7634
- <xsl:value-of select="$city"/>
7635
-
7636
- <xsl:if test="(*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name'] or normalize-space($city) != '') and normalize-space($year) != ''">
7637
- <xsl:text> </xsl:text>
7638
- </xsl:if>
7639
-
7640
- <xsl:if test="normalize-space($year) != ''">
7641
- <xsl:text>(</xsl:text>
7642
- <xsl:value-of select="$year"/>
7643
- <xsl:text>). </xsl:text>
7644
- </xsl:if>
7645
-
7646
- <xsl:if test="normalize-space($uri) != ''">
7647
- <fo:inline>
7648
-
7649
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
7650
-
7651
- <xsl:text> </xsl:text>
7652
- <fo:basic-link external-destination="{$uri}" fox:alt-text="{$uri}">
7653
- <xsl:value-of select="$uri"/>
7654
- </fo:basic-link>
7655
- </fo:inline>
7656
- </xsl:if>
7657
-
7658
- </xsl:otherwise>
7659
- </xsl:choose>
8603
+ <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
7660
8604
  <!-- end OGC bibitem processing-->
7661
8605
 
7662
8606
  </xsl:template><xsl:template name="processBibitemDocId">
@@ -7984,25 +8928,32 @@
7984
8928
  </fo:block-container>
7985
8929
 
7986
8930
  </xsl:template><xsl:template name="displayAdmonitionName">
7987
-
8931
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
8932
+ <!-- <xsl:choose>
8933
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
8934
+ <xsl:choose>
8935
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
8936
+ <xsl:otherwise>
8937
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8938
+ </xsl:otherwise>
8939
+ </xsl:choose>
8940
+ </xsl:when>
8941
+ <xsl:otherwise>
7988
8942
  <xsl:apply-templates select="*[local-name() = 'name']"/>
7989
8943
  <xsl:if test="not(*[local-name() = 'name'])">
7990
8944
  <xsl:apply-templates select="@type"/>
7991
8945
  </xsl:if>
7992
-
7993
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
7994
- <xsl:apply-templates/>
7995
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
7996
- <xsl:variable name="admonition_type_">
7997
- <xsl:call-template name="getLocalizedString">
7998
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
7999
- </xsl:call-template>
8946
+ </xsl:otherwise>
8947
+ </xsl:choose> -->
8948
+ <xsl:variable name="name">
8949
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8000
8950
  </xsl:variable>
8001
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
8002
- <xsl:value-of select="$admonition_type"/>
8003
- <xsl:if test="$admonition_type = ''">
8004
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
8951
+ <xsl:copy-of select="$name"/>
8952
+ <xsl:if test="normalize-space($name) != ''">
8953
+ <xsl:value-of select="$sep"/>
8005
8954
  </xsl:if>
8955
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8956
+ <xsl:apply-templates/>
8006
8957
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
8007
8958
 
8008
8959
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -8084,6 +9035,120 @@
8084
9035
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8085
9036
  </xsl:for-each>
8086
9037
  </xsl:copy>
9038
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9039
+ <xsl:apply-templates mode="update_xml_step1"/>
9040
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9041
+ <xsl:copy>
9042
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
9043
+ </xsl:copy>
9044
+ </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">
9045
+
9046
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
9047
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9048
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9049
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9050
+ <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))"/>
9051
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9052
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9053
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9054
+ <xsl:with-param name="text" select="$text_"/>
9055
+ </xsl:call-template></text></xsl:variable>
9056
+
9057
+ <xsl:variable name="parent" select="local-name(..)"/>
9058
+
9059
+ <xsl:variable name="text2">
9060
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
9061
+ <xsl:copy-of select="."/>
9062
+ </xsl:for-each></text>
9063
+ </xsl:variable>
9064
+
9065
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9066
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
9067
+ <xsl:variable name="text3">
9068
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9069
+ <xsl:choose>
9070
+ <xsl:when test="self::text()">
9071
+ <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))"/>
9072
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
9073
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9074
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9075
+ <xsl:with-param name="text" select="$text_units_"/>
9076
+ </xsl:call-template></text></xsl:variable>
9077
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
9078
+ </xsl:when>
9079
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9080
+ </xsl:choose>
9081
+ </xsl:for-each></text>
9082
+ </xsl:variable>
9083
+
9084
+ <xsl:choose>
9085
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9086
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9087
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9088
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9089
+ <xsl:choose>
9090
+ <xsl:when test="self::text()">
9091
+ <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))"/>
9092
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
9093
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9094
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9095
+ <xsl:with-param name="text" select="$text_dots_"/>
9096
+ </xsl:call-template></text></xsl:variable>
9097
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
9098
+ </xsl:when>
9099
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9100
+ </xsl:choose>
9101
+ </xsl:for-each>
9102
+ </xsl:when>
9103
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
9104
+ </xsl:choose>
9105
+
9106
+ </xsl:template><xsl:template name="replace_text_tags">
9107
+ <xsl:param name="tag_open"/>
9108
+ <xsl:param name="tag_close"/>
9109
+ <xsl:param name="text"/>
9110
+ <xsl:choose>
9111
+ <xsl:when test="contains($text, $tag_open)">
9112
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
9113
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
9114
+
9115
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
9116
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
9117
+ </xsl:element>
9118
+
9119
+ <xsl:call-template name="replace_text_tags">
9120
+ <xsl:with-param name="tag_open" select="$tag_open"/>
9121
+ <xsl:with-param name="tag_close" select="$tag_close"/>
9122
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
9123
+ </xsl:call-template>
9124
+ </xsl:when>
9125
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
9126
+ </xsl:choose>
9127
+ </xsl:template><xsl:template name="printEdition">
9128
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
9129
+ <xsl:text> </xsl:text>
9130
+ <xsl:choose>
9131
+ <xsl:when test="$edition_i18n != ''">
9132
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
9133
+ <xsl:call-template name="capitalize">
9134
+ <xsl:with-param name="str" select="$edition_i18n"/>
9135
+ </xsl:call-template>
9136
+ </xsl:when>
9137
+ <xsl:otherwise>
9138
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
9139
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
9140
+ <xsl:call-template name="capitalize">
9141
+ <xsl:with-param name="str">
9142
+ <xsl:call-template name="getLocalizedString">
9143
+ <xsl:with-param name="key">edition</xsl:with-param>
9144
+ </xsl:call-template>
9145
+ </xsl:with-param>
9146
+ </xsl:call-template>
9147
+ <xsl:text> </xsl:text>
9148
+ <xsl:value-of select="$edition"/>
9149
+ </xsl:if>
9150
+ </xsl:otherwise>
9151
+ </xsl:choose>
8087
9152
  </xsl:template><xsl:template name="convertDate">
8088
9153
  <xsl:param name="date"/>
8089
9154
  <xsl:param name="format" select="'short'"/>
@@ -8771,4 +9836,40 @@
8771
9836
  <xsl:value-of select="$value"/>
8772
9837
  </xsl:otherwise>
8773
9838
  </xsl:choose>
9839
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
9840
+ <xsl:param name="level">0</xsl:param>
9841
+
9842
+ <fo:block margin-left="{2*$level}mm">
9843
+ <xsl:text>
9844
+ &lt;</xsl:text>
9845
+ <xsl:value-of select="local-name()"/>
9846
+ <xsl:for-each select="@*">
9847
+ <xsl:text> </xsl:text>
9848
+ <xsl:value-of select="local-name()"/>
9849
+ <xsl:text>="</xsl:text>
9850
+ <xsl:value-of select="."/>
9851
+ <xsl:text>"</xsl:text>
9852
+ </xsl:for-each>
9853
+ <xsl:text>&gt;</xsl:text>
9854
+
9855
+ <xsl:if test="not(*)">
9856
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
9857
+ <xsl:text>&lt;/</xsl:text>
9858
+ <xsl:value-of select="local-name()"/>
9859
+ <xsl:text>&gt;</xsl:text>
9860
+ </xsl:if>
9861
+ </fo:block>
9862
+
9863
+ <xsl:if test="*">
9864
+ <fo:block>
9865
+ <xsl:apply-templates mode="print_as_xml">
9866
+ <xsl:with-param name="level" select="$level + 1"/>
9867
+ </xsl:apply-templates>
9868
+ </fo:block>
9869
+ <fo:block margin-left="{2*$level}mm">
9870
+ <xsl:text>&lt;/</xsl:text>
9871
+ <xsl:value-of select="local-name()"/>
9872
+ <xsl:text>&gt;</xsl:text>
9873
+ </fo:block>
9874
+ </xsl:if>
8774
9875
  </xsl:template></xsl:stylesheet>