metanorma-un 0.8.8 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@
14
14
  <contents>
15
15
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
16
16
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
17
- <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']" mode="contents"/>
17
+ <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements' and local-name() != 'note' and local-name() != 'admonition']" mode="contents"/>
18
18
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']" mode="contents"/>
19
19
 
20
20
  <xsl:apply-templates select="/un:un-standard/un:sections/*" mode="contents"/>
@@ -289,10 +289,10 @@
289
289
  </xsl:if>
290
290
 
291
291
  <!-- Preface Pages (except Abstract, that showed in Summary on cover page`) -->
292
- <xsl:if test="/un:un-standard/un:preface/*[not(local-name() = 'abstract')]">
292
+ <xsl:if test="/un:un-standard/un:preface/*[not(local-name() = 'abstract' or local-name() != 'note' or local-name() != 'admonition')]">
293
293
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
294
294
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']"/>
295
- <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']"/>
295
+ <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements' and local-name() != 'note' and local-name() != 'admonition']"/>
296
296
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']"/>
297
297
  <fo:block break-after="page"/>
298
298
  </xsl:if>
@@ -481,6 +481,7 @@
481
481
  </xsl:template>
482
482
 
483
483
  <xsl:template match="un:p" name="paragraph">
484
+ <xsl:param name="split_keep-within-line"/>
484
485
  <fo:block margin-bottom="6pt" line-height="122%">
485
486
  <xsl:if test="following-sibling::*">
486
487
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
@@ -491,7 +492,9 @@
491
492
  <xsl:otherwise>justify</xsl:otherwise>
492
493
  </xsl:choose>
493
494
  </xsl:attribute>
494
- <xsl:apply-templates/>
495
+ <xsl:apply-templates>
496
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
497
+ </xsl:apply-templates>
495
498
  </fo:block>
496
499
  </xsl:template>
497
500
 
@@ -679,86 +682,8 @@
679
682
  </fo:block-container>
680
683
  </xsl:template>
681
684
 
682
- <!-- Examples:
683
- [b-ASM] b-ASM, http://www.eecs.umich.edu/gasm/ (accessed 20 March 2018).
684
- [b-Börger & Stärk] b-Börger & Stärk, Börger, E., and Stärk, R. S. (2003), Abstract State Machines: A Method for High-Level System Design and Analysis, Springer-Verlag.
685
- -->
686
- <xsl:template match="un:annex//un:bibitem">
687
- <fo:block id="{@id}" margin-top="6pt" margin-left="12mm" text-indent="-12mm">
688
- <xsl:if test="un:formattedref">
689
- <xsl:choose>
690
- <xsl:when test="un:docidentifier[@type = 'metanorma']">
691
- <xsl:attribute name="margin-left">0</xsl:attribute>
692
- <xsl:attribute name="text-indent">0</xsl:attribute>
693
- <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
694
- <!-- create list -->
695
- <fo:list-block>
696
- <fo:list-item>
697
- <fo:list-item-label end-indent="label-end()">
698
- <fo:block>
699
- <xsl:apply-templates select="un:docidentifier[@type = 'metanorma']" mode="process"/>
700
- </fo:block>
701
- </fo:list-item-label>
702
- <fo:list-item-body start-indent="body-start()">
703
- <fo:block margin-left="3mm">
704
- <xsl:apply-templates select="un:formattedref"/>
705
- </fo:block>
706
- </fo:list-item-body>
707
- </fo:list-item>
708
- </fo:list-block>
709
- </xsl:when>
710
- <xsl:otherwise>
711
- <xsl:apply-templates select="un:formattedref"/>
712
- <xsl:apply-templates select="un:docidentifier[(@type != 'metanorma' and @type != 'metanorma-ordinal') or not(@type)]" mode="process"/>
713
- </xsl:otherwise>
714
- </xsl:choose>
715
- </xsl:if>
716
- <xsl:if test="un:title">
717
- <xsl:for-each select="un:contributor">
718
- <xsl:value-of select="un:organization/un:name"/>
719
- <xsl:if test="position() != last()">, </xsl:if>
720
- </xsl:for-each>
721
- <xsl:text> (</xsl:text>
722
- <xsl:variable name="date">
723
- <xsl:choose>
724
- <xsl:when test="un:date[@type='issued']">
725
- <xsl:value-of select="un:date[@type='issued']/un:on"/>
726
- </xsl:when>
727
- <xsl:otherwise>
728
- <xsl:value-of select="un:date/un:on"/>
729
- </xsl:otherwise>
730
- </xsl:choose>
731
- </xsl:variable>
732
- <xsl:value-of select="$date"/>
733
- <xsl:text>) </xsl:text>
734
- <fo:inline font-style="italic"><xsl:value-of select="un:title"/></fo:inline>
735
- <xsl:if test="un:contributor[un:role/@type='publisher']/un:organization/un:name">
736
- <xsl:text> (</xsl:text><xsl:value-of select="un:contributor[un:role/@type='publisher']/un:organization/un:name"/><xsl:text>)</xsl:text>
737
- </xsl:if>
738
- <xsl:text>, </xsl:text>
739
- <xsl:value-of select="$date"/>
740
- <xsl:text>. </xsl:text>
741
- <xsl:value-of select="un:docidentifier"/>
742
- <xsl:value-of select="$linebreak"/>
743
- <xsl:value-of select="un:uri"/>
744
- </xsl:if>
745
- </fo:block>
746
- </xsl:template>
747
-
748
- <xsl:template match="un:annex//un:bibitem//un:formattedref">
749
- <xsl:apply-templates/>
750
- </xsl:template>
751
-
752
- <xsl:template match="un:docidentifier[@type = 'metanorma' or @type = 'metanorma-ordinal']" mode="process">
753
- <xsl:apply-templates/>
754
- </xsl:template>
755
- <xsl:template match="un:docidentifier[(@type != 'metanorma' and @type != 'metanorma-ordinal') or not(@type)]" mode="process">
756
- <xsl:text> [</xsl:text><xsl:apply-templates/><xsl:text>]</xsl:text>
757
- </xsl:template>
758
- <xsl:template match="un:docidentifier"/>
759
685
 
760
686
 
761
-
762
687
  <xsl:template match="un:dl" priority="2">
763
688
  <fo:block-container margin-left="0mm">
764
689
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -833,12 +758,41 @@
833
758
  <xsl:text>iVBORw0KGgoAAAANSUhEUgAAAJkAAAAmCAYAAADXwDkaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA+lpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDE0IDc5LjE1Njc5NywgMjAxNC8wOC8yMC0wOTo1MzowMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJNaWNyb3NvZnTCriBXb3JkIDIwMTYiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MzM0NUVBQ0U2RUMzMTFFQUIzQjg4RDg3OEE1NEI2QzAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MzM0NUVBQ0Y2RUMzMTFFQUIzQjg4RDg3OEE1NEI2QzAiPiA8ZGM6Y3JlYXRvcj4gPHJkZjpTZXE+IDxyZGY6bGk+RGhhbmplZTwvcmRmOmxpPiA8L3JkZjpTZXE+IDwvZGM6Y3JlYXRvcj4gPGRjOnRpdGxlPiA8cmRmOkFsdD4gPHJkZjpsaSB4bWw6bGFuZz0ieC1kZWZhdWx0Ij4xODAxNzYzPC9yZGY6bGk+IDwvcmRmOkFsdD4gPC9kYzp0aXRsZT4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVm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</xsl:text>
834
759
  </xsl:variable>
835
760
 
836
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
761
+ <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_">
762
+ <xsl:for-each select="$table_widths_from_if//table">
763
+ <xsl:copy>
764
+ <xsl:copy-of select="@*"/>
765
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
766
+ </xsl:copy>
767
+ </xsl:for-each>
768
+ </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_">
769
+ false
770
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
837
771
  <xsl:call-template name="getLang"/>
838
- </xsl:variable><xsl:variable name="pageWidth_">
839
- 210
772
+ </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_">
773
+ <xsl:choose>
774
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
775
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
776
+ </xsl:choose>
777
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
778
+ <xsl:choose>
779
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
780
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
781
+ </xsl:choose>
782
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
783
+ <xsl:choose>
784
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
785
+ <xsl:otherwise>
786
+ 210
787
+ </xsl:otherwise>
788
+ </xsl:choose>
840
789
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
841
- 297
790
+ <xsl:choose>
791
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
792
+ <xsl:otherwise>
793
+ 297
794
+ </xsl:otherwise>
795
+ </xsl:choose>
842
796
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
843
797
  40
844
798
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -848,20 +802,7 @@
848
802
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
849
803
  40
850
804
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
851
-
852
- <title-edition lang="en">
853
-
854
- <xsl:text>Edition </xsl:text>
855
-
856
- </title-edition>
857
-
858
- <title-edition lang="fr">
859
- <xsl:text>Édition </xsl:text>
860
- </title-edition>
861
805
 
862
- <title-edition lang="ru">
863
- <xsl:text>Издание </xsl:text>
864
- </title-edition>
865
806
 
866
807
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
867
808
  <title-toc lang="en">
@@ -940,7 +881,7 @@
940
881
  </xsl:variable><xsl:variable name="bibdata">
941
882
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
942
883
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
943
- </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">
884
+ </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">
944
885
  <xsl:param name="name"/>
945
886
  <xsl:param name="lang"/>
946
887
  <xsl:variable name="lang_">
@@ -988,7 +929,7 @@
988
929
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
989
930
 
990
931
  <xsl:variable name="additional_fonts_">
991
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
932
+ <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']">
992
933
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
993
934
  </xsl:for-each>
994
935
  </xsl:variable>
@@ -1060,7 +1001,6 @@
1060
1001
 
1061
1002
 
1062
1003
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1063
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
1064
1004
 
1065
1005
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
1066
1006
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -1140,6 +1080,7 @@
1140
1080
 
1141
1081
 
1142
1082
 
1083
+
1143
1084
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
1144
1085
 
1145
1086
 
@@ -1297,6 +1238,7 @@
1297
1238
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1298
1239
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1299
1240
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1241
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1300
1242
  <xsl:attribute name="display-align">center</xsl:attribute>
1301
1243
 
1302
1244
 
@@ -1325,6 +1267,7 @@
1325
1267
  <xsl:attribute name="display-align">center</xsl:attribute>
1326
1268
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1327
1269
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1270
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1328
1271
 
1329
1272
 
1330
1273
 
@@ -1419,7 +1362,8 @@
1419
1362
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
1420
1363
 
1421
1364
 
1422
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
1365
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
1366
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
1423
1367
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
1424
1368
 
1425
1369
 
@@ -1431,6 +1375,27 @@
1431
1375
 
1432
1376
 
1433
1377
 
1378
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
1379
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
1380
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1381
+
1382
+
1383
+
1384
+
1385
+
1386
+
1387
+
1388
+
1389
+
1390
+
1391
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
1392
+
1393
+
1394
+
1395
+
1396
+
1397
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
1398
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
1434
1399
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1435
1400
 
1436
1401
 
@@ -1725,6 +1690,24 @@
1725
1690
  <xsl:attribute name="margin-left">-8mm</xsl:attribute>
1726
1691
 
1727
1692
 
1693
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
1694
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
1695
+
1696
+
1697
+
1698
+
1699
+
1700
+
1701
+
1702
+
1703
+
1704
+
1705
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
1706
+
1707
+
1708
+
1709
+
1710
+
1728
1711
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
1729
1712
 
1730
1713
 
@@ -2125,13 +2108,13 @@
2125
2108
 
2126
2109
  </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">
2127
2110
  <xsl:variable name="nodes_preface_">
2128
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2111
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2129
2112
  <node id="{@id}"/>
2130
2113
  </xsl:for-each>
2131
2114
  </xsl:variable>
2132
2115
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2133
2116
 
2134
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2117
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2135
2118
  <xsl:sort select="@displayorder" data-type="number"/>
2136
2119
 
2137
2120
  <!-- process Section's title -->
@@ -2197,7 +2180,7 @@
2197
2180
  </xsl:for-each>
2198
2181
  </figures>
2199
2182
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2200
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2183
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2201
2184
  <xsl:sort select="@displayorder" data-type="number"/>
2202
2185
  <xsl:apply-templates select="."/>
2203
2186
  </xsl:for-each>
@@ -2217,22 +2200,32 @@
2217
2200
  <xsl:sort select="@displayorder" data-type="number"/>
2218
2201
  <xsl:apply-templates select="."/>
2219
2202
  </xsl:for-each>
2220
- </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">
2221
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2222
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2223
- <xsl:call-template name="replace_fo_inline">
2224
- <xsl:with-param name="text" select="$text"/>
2225
- </xsl:call-template>
2226
- </xsl:template><xsl:template name="replace_fo_inline">
2203
+ </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">
2204
+
2205
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2206
+ <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))"/>
2207
+ <xsl:call-template name="replace_fo_inline_tags">
2208
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
2209
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
2210
+ <xsl:with-param name="text" select="$text"/>
2211
+ </xsl:call-template>
2212
+
2213
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
2214
+ <xsl:param name="tag_open"/>
2215
+ <xsl:param name="tag_close"/>
2227
2216
  <xsl:param name="text"/>
2228
2217
  <xsl:choose>
2229
2218
  <xsl:when test="contains($text, $tag_open)">
2230
2219
  <xsl:value-of select="substring-before($text, $tag_open)"/>
2231
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2220
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
2232
2221
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2233
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2234
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2235
- <xsl:call-template name="replace_fo_inline">
2222
+ <fo:inline keep-together.within-line="always">
2223
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2224
+ </fo:inline>
2225
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
2226
+ <xsl:call-template name="replace_fo_inline_tags">
2227
+ <xsl:with-param name="tag_open" select="$tag_open"/>
2228
+ <xsl:with-param name="tag_close" select="$tag_close"/>
2236
2229
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2237
2230
  </xsl:call-template>
2238
2231
  </xsl:when>
@@ -2240,6 +2233,39 @@
2240
2233
  </xsl:choose>
2241
2234
  </xsl:template><xsl:template match="*[local-name()='br']">
2242
2235
  <xsl:value-of select="$linebreak"/>
2236
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
2237
+ <xsl:param name="split_keep-within-line"/>
2238
+
2239
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
2240
+ <xsl:choose>
2241
+
2242
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
2243
+ <xsl:variable name="sep">_</xsl:variable>
2244
+ <xsl:variable name="items">
2245
+ <xsl:call-template name="split">
2246
+ <xsl:with-param name="pText" select="."/>
2247
+ <xsl:with-param name="sep" select="$sep"/>
2248
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
2249
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
2250
+ </xsl:call-template>
2251
+ </xsl:variable>
2252
+ <xsl:for-each select="xalan:nodeset($items)/item">
2253
+ <xsl:choose>
2254
+ <xsl:when test=". = $sep">
2255
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
2256
+ </xsl:when>
2257
+ <xsl:otherwise>
2258
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
2259
+ </xsl:otherwise>
2260
+ </xsl:choose>
2261
+ </xsl:for-each>
2262
+ </xsl:when>
2263
+
2264
+ <xsl:otherwise>
2265
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
2266
+ </xsl:otherwise>
2267
+
2268
+ </xsl:choose>
2243
2269
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
2244
2270
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
2245
2271
  <xsl:apply-templates/>
@@ -2305,8 +2331,23 @@
2305
2331
  </xsl:call-template>
2306
2332
 
2307
2333
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
2308
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
2309
- <xsl:call-template name="add-zero-spaces-java"/>
2334
+ <xsl:choose>
2335
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
2336
+ <xsl:value-of select="."/>
2337
+ </xsl:when>
2338
+ <xsl:otherwise>
2339
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
2340
+ </xsl:otherwise>
2341
+ </xsl:choose>
2342
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
2343
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
2344
+ <!-- <xsl:copy-of select="$text"/> -->
2345
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
2346
+ <xsl:choose>
2347
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
2348
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
2349
+ </xsl:choose>
2350
+ </xsl:for-each>
2310
2351
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
2311
2352
 
2312
2353
  <xsl:variable name="table-preamble">
@@ -2316,9 +2357,14 @@
2316
2357
 
2317
2358
  <xsl:variable name="table">
2318
2359
 
2319
- <xsl:variable name="simple-table">
2320
- <xsl:call-template name="getSimpleTable"/>
2360
+ <xsl:variable name="simple-table">
2361
+ <xsl:call-template name="getSimpleTable">
2362
+ <xsl:with-param name="id" select="@id"/>
2363
+ </xsl:call-template>
2321
2364
  </xsl:variable>
2365
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
2366
+
2367
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
2322
2368
 
2323
2369
 
2324
2370
  <!-- Display table's name before table as standalone block -->
@@ -2341,7 +2387,23 @@
2341
2387
  </xsl:call-template>
2342
2388
  </xsl:if>
2343
2389
  </xsl:variable>
2344
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2390
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
2391
+
2392
+ <!-- DEBUG -->
2393
+ <xsl:if test="$table_if_debug = 'true'">
2394
+ <fo:block font-size="60%">
2395
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
2396
+ </fo:block>
2397
+ </xsl:if>
2398
+
2399
+
2400
+ <!-- <xsl:copy-of select="$colwidths"/> -->
2401
+
2402
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
2403
+ DEBUG
2404
+ colwidths=<xsl:copy-of select="$colwidths"/>
2405
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
2406
+
2345
2407
 
2346
2408
 
2347
2409
  <xsl:variable name="margin-side">
@@ -2413,9 +2475,17 @@
2413
2475
  </xsl:element>
2414
2476
  </xsl:variable>
2415
2477
 
2478
+ <xsl:if test="$isGenerateTableIF = 'true'">
2479
+ <!-- to determine start of table -->
2480
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
2481
+ </xsl:if>
2416
2482
 
2417
2483
  <fo:table id="{@id}">
2418
2484
 
2485
+ <xsl:if test="$isGenerateTableIF = 'true'">
2486
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
2487
+ </xsl:if>
2488
+
2419
2489
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
2420
2490
  <xsl:attribute name="{local-name()}">
2421
2491
  <xsl:value-of select="."/>
@@ -2429,31 +2499,47 @@
2429
2499
 
2430
2500
 
2431
2501
  <xsl:choose>
2432
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
2433
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
2434
- <fo:table-column column-width="{@width}"/>
2435
- </xsl:for-each>
2502
+ <xsl:when test="$isGenerateTableIF = 'true'">
2503
+ <!-- generate IF for table widths -->
2504
+ <!-- example:
2505
+ <tr>
2506
+ <td valign="top" align="left" id="tab-symdu_1_1">
2507
+ <p>Symbol</p>
2508
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
2509
+ </td>
2510
+ <td valign="top" align="left" id="tab-symdu_1_2">
2511
+ <p>Description</p>
2512
+ <word id="tab-symdu_1_2_word_1">Description</word>
2513
+ </td>
2514
+ </tr>
2515
+ -->
2516
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
2517
+
2436
2518
  </xsl:when>
2437
2519
  <xsl:otherwise>
2438
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2439
- <xsl:choose>
2440
- <xsl:when test=". = 1 or . = 0">
2441
- <fo:table-column column-width="proportional-column-width(2)"/>
2442
- </xsl:when>
2443
- <xsl:otherwise>
2444
- <fo:table-column column-width="proportional-column-width({.})"/>
2445
- </xsl:otherwise>
2446
- </xsl:choose>
2447
- </xsl:for-each>
2448
- </xsl:otherwise>
2449
- </xsl:choose>
2450
2520
 
2451
- <xsl:choose>
2452
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
2453
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2454
- </xsl:when>
2455
- <xsl:otherwise>
2456
- <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 -->
2521
+ <xsl:choose>
2522
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
2523
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
2524
+ <fo:table-column column-width="{@width}"/>
2525
+ </xsl:for-each>
2526
+ </xsl:when>
2527
+ <xsl:otherwise>
2528
+ <xsl:call-template name="insertTableColumnWidth">
2529
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2530
+ </xsl:call-template>
2531
+ </xsl:otherwise>
2532
+ </xsl:choose>
2533
+
2534
+ <xsl:choose>
2535
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
2536
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2537
+ </xsl:when>
2538
+ <xsl:otherwise>
2539
+ <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 -->
2540
+ </xsl:otherwise>
2541
+ </xsl:choose>
2542
+
2457
2543
  </xsl:otherwise>
2458
2544
  </xsl:choose>
2459
2545
 
@@ -2553,11 +2639,22 @@
2553
2639
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
2554
2640
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
2555
2641
  </xsl:template><xsl:template name="calculate-column-widths">
2642
+ <xsl:param name="table"/>
2643
+ <xsl:param name="cols-count"/>
2644
+
2645
+ <xsl:call-template name="calculate-column-widths-proportional">
2646
+ <xsl:with-param name="cols-count" select="$cols-count"/>
2647
+ <xsl:with-param name="table" select="$table"/>
2648
+ </xsl:call-template>
2649
+
2650
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
2556
2651
  <xsl:param name="table"/>
2557
2652
  <xsl:param name="cols-count"/>
2558
2653
  <xsl:param name="curr-col" select="1"/>
2559
2654
  <xsl:param name="width" select="0"/>
2560
2655
 
2656
+ <!-- table=<xsl:copy-of select="$table"/> -->
2657
+
2561
2658
  <xsl:if test="$curr-col &lt;= $cols-count">
2562
2659
  <xsl:variable name="widths">
2563
2660
  <xsl:choose>
@@ -2595,16 +2692,22 @@
2595
2692
  </xsl:for-each>
2596
2693
  </xsl:when>
2597
2694
  <xsl:otherwise>
2598
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
2695
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
2696
+
2697
+ <!-- <table><xsl:copy-of select="$table"/></table>
2698
+ -->
2699
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
2599
2700
  <xsl:variable name="td_text">
2600
2701
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
2601
2702
  </xsl:variable>
2703
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
2602
2704
  <xsl:variable name="words">
2603
2705
  <xsl:variable name="string_with_added_zerospaces">
2604
2706
  <xsl:call-template name="add-zero-spaces-java">
2605
2707
  <xsl:with-param name="text" select="$td_text"/>
2606
2708
  </xsl:call-template>
2607
2709
  </xsl:variable>
2710
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
2608
2711
  <xsl:call-template name="tokenize">
2609
2712
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2610
2713
  <!-- 2009 thinspace -->
@@ -2612,11 +2715,13 @@
2612
2715
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2613
2716
  </xsl:call-template>
2614
2717
  </xsl:variable>
2718
+ <!-- words=<xsl:copy-of select="$words"/> -->
2615
2719
  <xsl:variable name="max_length">
2616
2720
  <xsl:call-template name="max_length">
2617
2721
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
2618
2722
  </xsl:call-template>
2619
2723
  </xsl:variable>
2724
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
2620
2725
  <width>
2621
2726
  <xsl:variable name="divider">
2622
2727
  <xsl:choose>
@@ -2635,6 +2740,8 @@
2635
2740
  </xsl:choose>
2636
2741
  </xsl:variable>
2637
2742
 
2743
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
2744
+
2638
2745
  <column>
2639
2746
  <xsl:for-each select="xalan:nodeset($widths)//width">
2640
2747
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -2643,86 +2750,328 @@
2643
2750
  </xsl:if>
2644
2751
  </xsl:for-each>
2645
2752
  </column>
2646
- <xsl:call-template name="calculate-column-widths">
2753
+ <xsl:call-template name="calculate-column-widths-proportional">
2647
2754
  <xsl:with-param name="cols-count" select="$cols-count"/>
2648
2755
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
2649
2756
  <xsl:with-param name="table" select="$table"/>
2650
2757
  </xsl:call-template>
2651
2758
  </xsl:if>
2759
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
2760
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
2761
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
2762
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
2763
+
2764
+ <!-- if all capitals english letters or digits -->
2765
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
2766
+ <xsl:call-template name="repeat">
2767
+ <xsl:with-param name="char" select="'X'"/>
2768
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
2769
+ </xsl:call-template>
2770
+ </xsl:if>
2652
2771
  </xsl:template><xsl:template match="text()" mode="td_text">
2653
2772
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
2654
2773
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
2655
2774
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
2656
2775
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
2657
2776
  <xsl:value-of select="@target"/>
2658
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
2659
- <xsl:variable name="mathml">
2660
- <xsl:for-each select="*">
2661
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
2662
- <xsl:copy-of select="."/>
2663
- </xsl:if>
2777
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
2778
+ <xsl:if test="$isGenerateTableIF = 'false'">
2779
+ <xsl:variable name="mathml_">
2780
+ <xsl:for-each select="*">
2781
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
2782
+ <xsl:copy-of select="."/>
2783
+ </xsl:if>
2784
+ </xsl:for-each>
2785
+ </xsl:variable>
2786
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
2787
+
2788
+ <xsl:variable name="math_text">
2789
+ <xsl:value-of select="normalize-space($mathml)"/>
2790
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
2791
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
2792
+ </xsl:variable>
2793
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
2794
+ </xsl:if>
2795
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
2796
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
2797
+
2798
+ <!-- via intermediate format -->
2799
+
2800
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
2801
+
2802
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
2803
+
2804
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
2805
+
2806
+ <!-- get current table id -->
2807
+ <xsl:variable name="table_id" select="@id"/>
2808
+ <!-- find table by id in the file 'table_widths' -->
2809
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
2810
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
2811
+
2812
+ <!-- table='<xsl:copy-of select="$table"/>' -->
2813
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
2814
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
2815
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
2816
+
2817
+ <xsl:variable name="table_with_cell_widths_">
2818
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
2819
+ </xsl:variable>
2820
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
2821
+
2822
+ <!-- <xsl:if test="$table_if_debug = 'true'">
2823
+ <xsl:copy-of select="$table_with_cell_widths"/>
2824
+ </xsl:if> -->
2825
+
2826
+
2827
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
2828
+
2829
+ <xsl:variable name="column_widths_">
2830
+ <!-- iteration of columns -->
2831
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
2832
+ <xsl:variable name="pos" select="position()"/>
2833
+ <column>
2834
+ <xsl:attribute name="width_max">
2835
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
2836
+ <xsl:sort select="." data-type="number" order="descending"/>
2837
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
2838
+ </xsl:for-each>
2839
+ </xsl:attribute>
2840
+ <xsl:attribute name="width_min">
2841
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
2842
+ <xsl:sort select="." data-type="number" order="descending"/>
2843
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
2844
+ </xsl:for-each>
2845
+ </xsl:attribute>
2846
+ </column>
2664
2847
  </xsl:for-each>
2665
2848
  </xsl:variable>
2849
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
2666
2850
 
2667
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
2668
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
2669
- </xsl:template><xsl:template match="*[local-name()='thead']">
2670
- <xsl:param name="cols-count"/>
2671
- <fo:table-header>
2672
-
2673
-
2674
- <xsl:apply-templates/>
2675
- </fo:table-header>
2676
- </xsl:template><xsl:template name="table-header-title">
2677
- <xsl:param name="cols-count"/>
2678
- <!-- row for title -->
2679
- <fo:table-row>
2680
- <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
2681
-
2682
- <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
2683
- <xsl:with-param name="continued">true</xsl:with-param>
2684
- </xsl:apply-templates>
2685
-
2686
-
2687
-
2688
- </fo:table-cell>
2689
- </fo:table-row>
2690
- </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
2691
- <fo:table-body>
2692
- <xsl:apply-templates/>
2693
- </fo:table-body>
2694
- </xsl:template><xsl:template match="*[local-name()='tfoot']">
2695
- <xsl:apply-templates/>
2696
- </xsl:template><xsl:template name="insertTableFooter">
2697
- <xsl:param name="cols-count"/>
2698
- <xsl:if test="../*[local-name()='tfoot']">
2699
- <fo:table-footer>
2700
- <xsl:apply-templates select="../*[local-name()='tfoot']"/>
2701
- </fo:table-footer>
2702
- </xsl:if>
2703
- </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
2704
- <xsl:param name="table_attributes"/>
2705
- <xsl:param name="colwidths"/>
2706
- <xsl:param name="colgroup"/>
2851
+ <!-- <column_widths>
2852
+ <xsl:copy-of select="$column_widths"/>
2853
+ </column_widths> -->
2707
2854
 
2708
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
2855
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
2856
+ <xsl:variable name="table_widths_">
2857
+ <table>
2858
+ <xsl:attribute name="width_max">
2859
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
2860
+ </xsl:attribute>
2861
+ <xsl:attribute name="width_min">
2862
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
2863
+ </xsl:attribute>
2864
+ </table>
2865
+ </xsl:variable>
2866
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
2709
2867
 
2710
- <xsl:variable name="isNoteOrFnExistShowAfterTable">
2711
-
2868
+ <xsl:variable name="page_width">
2869
+ <xsl:choose>
2870
+ <xsl:when test="$parent_table_page-width != ''">
2871
+ <xsl:value-of select="$parent_table_page-width"/>
2872
+ </xsl:when>
2873
+ <xsl:otherwise>
2874
+ <xsl:value-of select="@page-width"/>
2875
+ </xsl:otherwise>
2876
+ </xsl:choose>
2712
2877
  </xsl:variable>
2713
2878
 
2714
- <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
2879
+ <xsl:if test="$table_if_debug = 'true'">
2880
+ <table_width>
2881
+ <xsl:copy-of select="$table_widths"/>
2882
+ </table_width>
2883
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
2884
+ </xsl:if>
2715
2885
 
2716
- <xsl:variable name="cols-count">
2717
- <xsl:choose>
2718
- <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2719
- <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
2720
- </xsl:when>
2721
- <xsl:otherwise>
2722
- <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/>
2723
- </xsl:otherwise>
2724
- </xsl:choose>
2725
- </xsl:variable>
2886
+
2887
+ <!-- There are three cases: -->
2888
+ <xsl:choose>
2889
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
2890
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
2891
+ <!-- call old algorithm -->
2892
+ <case1/>
2893
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
2894
+ <xsl:call-template name="calculate-column-widths-proportional">
2895
+ <xsl:with-param name="cols-count" select="$cols-count"/>
2896
+ <xsl:with-param name="table" select="$table"/>
2897
+ </xsl:call-template> -->
2898
+ </xsl:when>
2899
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
2900
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
2901
+ <case2/>
2902
+ <autolayout/>
2903
+ <xsl:for-each select="$column_widths/column/@width_max">
2904
+ <column divider="100"><xsl:value-of select="."/></column>
2905
+ </xsl:for-each>
2906
+ </xsl:when>
2907
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
2908
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
2909
+ Lets also call D the difference between maximum and minimum width of the table.
2910
+ For each column, let d be the difference between maximum and minimum width of that column.
2911
+ Now set the column's width to the minimum width plus d times W over D.
2912
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
2913
+ <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)">
2914
+ <!-- difference between the available space and the minimum table width -->
2915
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
2916
+ <W><xsl:value-of select="$W"/></W>
2917
+ <!-- difference between maximum and minimum width of the table -->
2918
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
2919
+ <D><xsl:value-of select="$D"/></D>
2920
+ <case3/>
2921
+ <autolayout/>
2922
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
2923
+ <split_keep-within-line>true</split_keep-within-line>
2924
+ </xsl:if>
2925
+ <xsl:for-each select="$column_widths/column">
2926
+ <!-- difference between maximum and minimum width of that column. -->
2927
+ <xsl:variable name="d" select="@width_max - @width_min"/>
2928
+ <d><xsl:value-of select="$d"/></d>
2929
+ <width_min><xsl:value-of select="@width_min"/></width_min>
2930
+ <e><xsl:value-of select="$d * $W div $D"/></e>
2931
+ <!-- set the column's width to the minimum width plus d times W over D. -->
2932
+ <column divider="100">
2933
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
2934
+ </column>
2935
+ </xsl:for-each>
2936
+
2937
+ </xsl:when>
2938
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
2939
+ </xsl:choose>
2940
+
2941
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
2942
+
2943
+ <!-- if nested 'dl' or 'table' -->
2944
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
2945
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
2946
+
2947
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
2948
+
2949
+ <xsl:variable name="parent_table_page-width_">
2950
+ <xsl:if test="$parent_table_id != ''">
2951
+ <!-- determine column number in the parent table -->
2952
+ <xsl:variable name="parent_table_column_number">
2953
+ <xsl:choose>
2954
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
2955
+ <xsl:otherwise> <!-- parent is table -->
2956
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
2957
+ </xsl:otherwise>
2958
+ </xsl:choose>
2959
+ </xsl:variable>
2960
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
2961
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
2962
+ </xsl:if>
2963
+ </xsl:variable>
2964
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
2965
+
2966
+ <!-- get current table id -->
2967
+ <xsl:variable name="table_id" select="@id"/>
2968
+
2969
+ <xsl:choose>
2970
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
2971
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
2972
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
2973
+ </xsl:when>
2974
+ <xsl:otherwise>
2975
+ <!-- recalculate columns width based on parent table width -->
2976
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
2977
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
2978
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
2979
+ </xsl:call-template>
2980
+ </xsl:for-each>
2981
+ </xsl:otherwise>
2982
+ </xsl:choose>
2983
+
2984
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
2985
+ <xsl:copy>
2986
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
2987
+ </xsl:copy>
2988
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
2989
+ <xsl:copy>
2990
+ <xsl:copy-of select="@*"/>
2991
+
2992
+ <!-- The maximum width is given by the widest line. -->
2993
+ <xsl:attribute name="width_max">
2994
+ <xsl:for-each select="p_len">
2995
+ <xsl:sort select="." data-type="number" order="descending"/>
2996
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
2997
+ </xsl:for-each>
2998
+ </xsl:attribute>
2999
+
3000
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
3001
+ <xsl:variable name="width_min">
3002
+ <xsl:for-each select="word_len">
3003
+ <xsl:sort select="." data-type="number" order="descending"/>
3004
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3005
+ </xsl:for-each>
3006
+ </xsl:variable>
3007
+ <xsl:attribute name="width_min">
3008
+ <xsl:value-of select="$width_min"/>
3009
+ </xsl:attribute>
3010
+
3011
+ <xsl:if test="$width_min = 0">
3012
+ <xsl:attribute name="width_min">1</xsl:attribute>
3013
+ </xsl:if>
3014
+
3015
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
3016
+
3017
+ </xsl:copy>
3018
+ </xsl:template><xsl:template match="*[local-name()='thead']">
3019
+ <xsl:param name="cols-count"/>
3020
+ <fo:table-header>
3021
+
3022
+
3023
+ <xsl:apply-templates/>
3024
+ </fo:table-header>
3025
+ </xsl:template><xsl:template name="table-header-title">
3026
+ <xsl:param name="cols-count"/>
3027
+ <!-- row for title -->
3028
+ <fo:table-row>
3029
+ <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
3030
+
3031
+ <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
3032
+ <xsl:with-param name="continued">true</xsl:with-param>
3033
+ </xsl:apply-templates>
3034
+
3035
+
3036
+
3037
+ </fo:table-cell>
3038
+ </fo:table-row>
3039
+ </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
3040
+ <fo:table-body>
3041
+ <xsl:apply-templates/>
3042
+ </fo:table-body>
3043
+ </xsl:template><xsl:template match="*[local-name()='tfoot']">
3044
+ <xsl:apply-templates/>
3045
+ </xsl:template><xsl:template name="insertTableFooter">
3046
+ <xsl:param name="cols-count"/>
3047
+ <xsl:if test="../*[local-name()='tfoot']">
3048
+ <fo:table-footer>
3049
+ <xsl:apply-templates select="../*[local-name()='tfoot']"/>
3050
+ </fo:table-footer>
3051
+ </xsl:if>
3052
+ </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
3053
+ <xsl:param name="table_attributes"/>
3054
+ <xsl:param name="colwidths"/>
3055
+ <xsl:param name="colgroup"/>
3056
+
3057
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3058
+
3059
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
3060
+
3061
+ </xsl:variable>
3062
+
3063
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
3064
+
3065
+ <xsl:variable name="cols-count">
3066
+ <xsl:choose>
3067
+ <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
3068
+ <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
3069
+ </xsl:when>
3070
+ <xsl:otherwise>
3071
+ <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/>
3072
+ </xsl:otherwise>
3073
+ </xsl:choose>
3074
+ </xsl:variable>
2726
3075
 
2727
3076
  <fo:table keep-with-previous="always">
2728
3077
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
@@ -2750,16 +3099,10 @@
2750
3099
  </xsl:for-each>
2751
3100
  </xsl:when>
2752
3101
  <xsl:otherwise>
2753
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2754
- <xsl:choose>
2755
- <xsl:when test=". = 1 or . = 0">
2756
- <fo:table-column column-width="proportional-column-width(2)"/>
2757
- </xsl:when>
2758
- <xsl:otherwise>
2759
- <fo:table-column column-width="proportional-column-width({.})"/>
2760
- </xsl:otherwise>
2761
- </xsl:choose>
2762
- </xsl:for-each>
3102
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
3103
+ <xsl:call-template name="insertTableColumnWidth">
3104
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3105
+ </xsl:call-template>
2763
3106
  </xsl:otherwise>
2764
3107
  </xsl:choose>
2765
3108
 
@@ -2836,6 +3179,52 @@
2836
3179
 
2837
3180
  </fo:table-body>
2838
3181
 
3182
+ </xsl:template><xsl:template match="/" mode="process_table-if">
3183
+ <xsl:param name="table_or_dl">table</xsl:param>
3184
+ <xsl:apply-templates mode="process_table-if">
3185
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
3186
+ </xsl:apply-templates>
3187
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
3188
+ <xsl:param name="table_or_dl">table</xsl:param>
3189
+
3190
+ <fo:table-body>
3191
+ <xsl:for-each select="*[local-name() = 'tr']">
3192
+ <xsl:variable name="col_count" select="count(*)"/>
3193
+
3194
+ <!-- iteration for each tr/td -->
3195
+
3196
+ <xsl:choose>
3197
+ <xsl:when test="$table_or_dl = 'table'">
3198
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
3199
+ <fo:table-row number-columns-spanned="{$col_count}">
3200
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
3201
+ <xsl:call-template name="td"/>
3202
+ </fo:table-row>
3203
+ </xsl:for-each>
3204
+ </xsl:when>
3205
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
3206
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
3207
+ <xsl:variable name="is_dt" select="position() = 1"/>
3208
+
3209
+ <xsl:for-each select="*">
3210
+ <!-- <test><xsl:copy-of select="."/></test> -->
3211
+ <fo:table-row number-columns-spanned="{$col_count}">
3212
+ <xsl:choose>
3213
+ <xsl:when test="$is_dt">
3214
+ <xsl:call-template name="insert_dt_cell"/>
3215
+ </xsl:when>
3216
+ <xsl:otherwise>
3217
+ <xsl:call-template name="insert_dd_cell"/>
3218
+ </xsl:otherwise>
3219
+ </xsl:choose>
3220
+ </fo:table-row>
3221
+ </xsl:for-each>
3222
+ </xsl:for-each>
3223
+ </xsl:otherwise>
3224
+ </xsl:choose>
3225
+
3226
+ </xsl:for-each>
3227
+ </fo:table-body>
2839
3228
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
2840
3229
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
2841
3230
 
@@ -2926,7 +3315,7 @@
2926
3315
  </xsl:choose>
2927
3316
  </xsl:attribute>
2928
3317
  </xsl:if>
2929
- </xsl:template><xsl:template match="*[local-name()='td']">
3318
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
2930
3319
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
2931
3320
  <xsl:call-template name="setTextAlignment">
2932
3321
  <xsl:with-param name="default">left</xsl:with-param>
@@ -2960,11 +3349,24 @@
2960
3349
 
2961
3350
  <xsl:call-template name="setTableCellAttributes"/>
2962
3351
 
3352
+ <xsl:if test="$isGenerateTableIF = 'true'">
3353
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
3354
+ <xsl:attribute name="text-align">left</xsl:attribute>
3355
+ </xsl:if>
3356
+
2963
3357
  <fo:block>
2964
3358
 
3359
+ <xsl:if test="$isGenerateTableIF = 'true'">
3360
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
3361
+ </xsl:if>
3362
+
3363
+
2965
3364
 
2966
3365
 
2967
3366
  <xsl:apply-templates/>
3367
+
3368
+ <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"/> -->
3369
+
2968
3370
  </fo:block>
2969
3371
  </fo:table-cell>
2970
3372
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -3165,9 +3567,9 @@
3165
3567
  <!-- current hierarchy is 'figure' element -->
3166
3568
  <xsl:variable name="following_dl_colwidths">
3167
3569
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3168
- <xsl:variable name="html-table">
3169
- <xsl:variable name="doc_ns">
3170
-
3570
+ <xsl:variable name="simple-table">
3571
+ <!-- <xsl:variable name="doc_ns">
3572
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3171
3573
  </xsl:variable>
3172
3574
  <xsl:variable name="ns">
3173
3575
  <xsl:choose>
@@ -3178,7 +3580,7 @@
3178
3580
  <xsl:value-of select="substring-before(name(/*), '-')"/>
3179
3581
  </xsl:otherwise>
3180
3582
  </xsl:choose>
3181
- </xsl:variable>
3583
+ </xsl:variable> -->
3182
3584
 
3183
3585
  <xsl:for-each select="*[local-name() = 'dl'][1]">
3184
3586
  <tbody>
@@ -3189,7 +3591,7 @@
3189
3591
 
3190
3592
  <xsl:call-template name="calculate-column-widths">
3191
3593
  <xsl:with-param name="cols-count" select="2"/>
3192
- <xsl:with-param name="table" select="$html-table"/>
3594
+ <xsl:with-param name="table" select="$simple-table"/>
3193
3595
  </xsl:call-template>
3194
3596
 
3195
3597
  </xsl:if>
@@ -3308,8 +3710,10 @@
3308
3710
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
3309
3711
  </xsl:variable>
3310
3712
 
3713
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
3714
+
3311
3715
  <xsl:choose>
3312
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
3716
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
3313
3717
 
3314
3718
  <fo:block margin-bottom="12pt" text-align="left">
3315
3719
 
@@ -3324,7 +3728,7 @@
3324
3728
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3325
3729
  </fo:block>
3326
3730
 
3327
- </xsl:when>
3731
+ </xsl:when> <!-- END: only one component -->
3328
3732
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3329
3733
  <fo:block margin-bottom="12pt" text-align="left">
3330
3734
 
@@ -3338,8 +3742,8 @@
3338
3742
  </xsl:variable>
3339
3743
  <xsl:value-of select="$title-where"/>
3340
3744
  </fo:block>
3341
- </xsl:when>
3342
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
3745
+ </xsl:when> <!-- END: a few components -->
3746
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
3343
3747
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
3344
3748
 
3345
3749
 
@@ -3352,22 +3756,41 @@
3352
3756
  </xsl:variable>
3353
3757
  <xsl:value-of select="$title-key"/>
3354
3758
  </fo:block>
3355
- </xsl:when>
3759
+ </xsl:when> <!-- END: definition list in a figure -->
3356
3760
  </xsl:choose>
3357
3761
 
3358
3762
  <!-- a few components -->
3359
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
3763
+ <xsl:if test="$onlyOneComponent = 'false'">
3360
3764
  <fo:block>
3361
3765
 
3362
3766
 
3363
3767
 
3364
3768
 
3769
+
3770
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
3771
+ <xsl:attribute name="margin-top">0</xsl:attribute>
3772
+ </xsl:if>
3773
+
3365
3774
  <fo:block>
3366
3775
 
3367
3776
 
3368
3777
 
3369
3778
 
3779
+ <xsl:apply-templates select="*[local-name() = 'name']">
3780
+ <xsl:with-param name="process">true</xsl:with-param>
3781
+ </xsl:apply-templates>
3782
+
3783
+ <xsl:if test="$isGenerateTableIF = 'true'">
3784
+ <!-- to determine start of table -->
3785
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3786
+ </xsl:if>
3787
+
3370
3788
  <fo:table width="95%" table-layout="fixed">
3789
+
3790
+ <xsl:if test="$isGenerateTableIF = 'true'">
3791
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3792
+ </xsl:if>
3793
+
3371
3794
 
3372
3795
  <xsl:choose>
3373
3796
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -3376,61 +3799,178 @@
3376
3799
 
3377
3800
  </xsl:when>
3378
3801
  </xsl:choose>
3379
- <!-- create virtual html table for dl/[dt and dd] -->
3380
- <xsl:variable name="html-table">
3381
- <xsl:variable name="doc_ns">
3802
+
3803
+
3804
+
3805
+ <xsl:choose>
3806
+ <xsl:when test="$isGenerateTableIF = 'true'">
3807
+ <!-- generate IF for table widths -->
3808
+ <!-- example:
3809
+ <tr>
3810
+ <td valign="top" align="left" id="tab-symdu_1_1">
3811
+ <p>Symbol</p>
3812
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3813
+ </td>
3814
+ <td valign="top" align="left" id="tab-symdu_1_2">
3815
+ <p>Description</p>
3816
+ <word id="tab-symdu_1_2_word_1">Description</word>
3817
+ </td>
3818
+ </tr>
3819
+ -->
3382
3820
 
3383
- </xsl:variable>
3384
- <xsl:variable name="ns">
3385
- <xsl:choose>
3386
- <xsl:when test="normalize-space($doc_ns) != ''">
3387
- <xsl:value-of select="normalize-space($doc_ns)"/>
3388
- </xsl:when>
3389
- <xsl:otherwise>
3390
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3391
- </xsl:otherwise>
3392
- </xsl:choose>
3393
- </xsl:variable>
3394
- <tbody>
3395
- <xsl:apply-templates mode="dl"/>
3396
- </tbody>
3397
- </xsl:variable>
3398
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
3399
- <xsl:variable name="colwidths">
3400
- <xsl:call-template name="calculate-column-widths">
3401
- <xsl:with-param name="cols-count" select="2"/>
3402
- <xsl:with-param name="table" select="$html-table"/>
3403
- </xsl:call-template>
3404
- </xsl:variable>
3405
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3406
- <xsl:variable name="maxlength_dt">
3407
- <xsl:call-template name="getMaxLength_dt"/>
3408
- </xsl:variable>
3409
- <xsl:call-template name="setColumnWidth_dl">
3410
- <xsl:with-param name="colwidths" select="$colwidths"/>
3411
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3412
- </xsl:call-template>
3413
- <fo:table-body>
3414
- <xsl:apply-templates>
3415
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
3416
- </xsl:apply-templates>
3417
- </fo:table-body>
3821
+ <!-- create virtual html table for dl/[dt and dd] -->
3822
+ <xsl:variable name="simple-table">
3823
+
3824
+ <xsl:variable name="dl_table">
3825
+ <tbody>
3826
+ <xsl:apply-templates mode="dl_if">
3827
+ <xsl:with-param name="id" select="@id"/>
3828
+ </xsl:apply-templates>
3829
+ </tbody>
3830
+ </xsl:variable>
3831
+
3832
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
3833
+
3834
+ <!-- Step: replace <br/> to <p>...</p> -->
3835
+ <xsl:variable name="table_without_br">
3836
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
3837
+ </xsl:variable>
3838
+
3839
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
3840
+
3841
+ <!-- Step: add id to each cell -->
3842
+ <!-- add <word>...</word> for each word, image, math -->
3843
+ <xsl:variable name="simple-table-id">
3844
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
3845
+ <xsl:with-param name="id" select="@id"/>
3846
+ </xsl:apply-templates>
3847
+ </xsl:variable>
3848
+
3849
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
3850
+
3851
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
3852
+
3853
+ </xsl:variable>
3854
+
3855
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
3856
+
3857
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
3858
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
3859
+ </xsl:apply-templates>
3860
+
3861
+ </xsl:when>
3862
+ <xsl:otherwise>
3863
+
3864
+ <xsl:variable name="simple-table">
3865
+
3866
+ <xsl:variable name="dl_table">
3867
+ <tbody>
3868
+ <xsl:apply-templates mode="dl">
3869
+ <xsl:with-param name="id" select="@id"/>
3870
+ </xsl:apply-templates>
3871
+ </tbody>
3872
+ </xsl:variable>
3873
+
3874
+ <xsl:copy-of select="$dl_table"/>
3875
+ </xsl:variable>
3876
+
3877
+ <xsl:variable name="colwidths">
3878
+ <xsl:call-template name="calculate-column-widths">
3879
+ <xsl:with-param name="cols-count" select="2"/>
3880
+ <xsl:with-param name="table" select="$simple-table"/>
3881
+ </xsl:call-template>
3882
+ </xsl:variable>
3883
+
3884
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3885
+ DEBUG
3886
+ colwidths=<xsl:copy-of select="$colwidths"/>
3887
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3888
+
3889
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3890
+
3891
+ <xsl:variable name="maxlength_dt">
3892
+ <xsl:call-template name="getMaxLength_dt"/>
3893
+ </xsl:variable>
3894
+
3895
+ <xsl:variable name="isContainsKeepTogetherTag_">
3896
+ false
3897
+ </xsl:variable>
3898
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
3899
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
3900
+
3901
+
3902
+ <xsl:call-template name="setColumnWidth_dl">
3903
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3904
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3905
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
3906
+ </xsl:call-template>
3907
+
3908
+ <fo:table-body>
3909
+
3910
+ <!-- DEBUG -->
3911
+ <xsl:if test="$table_if_debug = 'true'">
3912
+ <fo:table-row>
3913
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
3914
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3915
+ </fo:table-cell>
3916
+ </fo:table-row>
3917
+ </xsl:if>
3918
+
3919
+ <xsl:apply-templates>
3920
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
3921
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
3922
+ </xsl:apply-templates>
3923
+
3924
+ </fo:table-body>
3925
+ </xsl:otherwise>
3926
+ </xsl:choose>
3418
3927
  </fo:table>
3419
3928
  </fo:block>
3420
3929
  </fo:block>
3421
- </xsl:if>
3930
+ </xsl:if> <!-- END: a few components -->
3422
3931
  </fo:block-container>
3423
3932
  </fo:block-container>
3933
+
3934
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
3935
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
3936
+ </xsl:if>
3937
+
3938
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3939
+ <xsl:param name="process">false</xsl:param>
3940
+ <xsl:if test="$process = 'true'">
3941
+ <fo:block xsl:use-attribute-sets="dl-name-style">
3942
+ <xsl:apply-templates/>
3943
+ </fo:block>
3944
+ </xsl:if>
3424
3945
  </xsl:template><xsl:template name="setColumnWidth_dl">
3425
3946
  <xsl:param name="colwidths"/>
3426
3947
  <xsl:param name="maxlength_dt"/>
3948
+ <xsl:param name="isContainsKeepTogetherTag"/>
3949
+
3950
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
3951
+
3427
3952
  <xsl:choose>
3953
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
3954
+ <xsl:call-template name="insertTableColumnWidth">
3955
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3956
+ </xsl:call-template>
3957
+ </xsl:when>
3428
3958
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
3429
3959
  <fo:table-column column-width="50%"/>
3430
3960
  <fo:table-column column-width="50%"/>
3431
3961
  </xsl:when>
3432
3962
  <xsl:otherwise>
3433
3963
  <xsl:choose>
3964
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
3965
+ <xsl:call-template name="insertTableColumnWidth">
3966
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3967
+ </xsl:call-template>
3968
+ </xsl:when>
3969
+ <xsl:when test="$isContainsKeepTogetherTag">
3970
+ <xsl:call-template name="insertTableColumnWidth">
3971
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3972
+ </xsl:call-template>
3973
+ </xsl:when>
3434
3974
  <!-- to set width check most wide chars like `W` -->
3435
3975
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
3436
3976
  <fo:table-column column-width="7%"/>
@@ -3461,20 +4001,31 @@
3461
4001
  <fo:table-column column-width="60%"/>
3462
4002
  </xsl:when>
3463
4003
  <xsl:otherwise>
3464
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3465
- <xsl:choose>
3466
- <xsl:when test=". = 1 or . = 0">
3467
- <fo:table-column column-width="proportional-column-width(2)"/>
3468
- </xsl:when>
3469
- <xsl:otherwise>
3470
- <fo:table-column column-width="proportional-column-width({.})"/>
3471
- </xsl:otherwise>
3472
- </xsl:choose>
3473
- </xsl:for-each>
4004
+ <xsl:call-template name="insertTableColumnWidth">
4005
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4006
+ </xsl:call-template>
3474
4007
  </xsl:otherwise>
3475
4008
  </xsl:choose>
3476
4009
  </xsl:otherwise>
3477
4010
  </xsl:choose>
4011
+ </xsl:template><xsl:template name="insertTableColumnWidth">
4012
+ <xsl:param name="colwidths"/>
4013
+
4014
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
4015
+ <xsl:choose>
4016
+ <xsl:when test=". = 1 or . = 0">
4017
+ <fo:table-column column-width="proportional-column-width(2)"/>
4018
+ </xsl:when>
4019
+ <xsl:otherwise>
4020
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
4021
+ <xsl:variable name="divider">
4022
+ <xsl:value-of select="@divider"/>
4023
+ <xsl:if test="not(@divider)">1</xsl:if>
4024
+ </xsl:variable>
4025
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4026
+ </xsl:otherwise>
4027
+ </xsl:choose>
4028
+ </xsl:for-each>
3478
4029
  </xsl:template><xsl:template name="getMaxLength_dt">
3479
4030
  <xsl:variable name="lengths">
3480
4031
  <xsl:for-each select="*[local-name()='dt']">
@@ -3498,7 +4049,6 @@
3498
4049
  <xsl:value-of select="$maxLength"/>
3499
4050
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
3500
4051
  <xsl:param name="key_iso"/>
3501
-
3502
4052
  <!-- <tr>
3503
4053
  <td>NOTE</td>
3504
4054
  <td>
@@ -3506,27 +4056,47 @@
3506
4056
  </td>
3507
4057
  </tr>
3508
4058
  -->
3509
- <fo:table-row>
4059
+ <!-- OLD Variant -->
4060
+ <!-- <fo:table-row>
3510
4061
  <fo:table-cell>
3511
4062
  <fo:block margin-top="6pt">
3512
4063
  <xsl:if test="normalize-space($key_iso) = 'true'">
3513
4064
  <xsl:attribute name="margin-top">0</xsl:attribute>
3514
4065
  </xsl:if>
3515
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4066
+ <xsl:apply-templates select="*[local-name() = 'name']" />
3516
4067
  </fo:block>
3517
4068
  </fo:table-cell>
3518
4069
  <fo:table-cell>
3519
4070
  <fo:block>
3520
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4071
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4072
+ </fo:block>
4073
+ </fo:table-cell>
4074
+ </fo:table-row> -->
4075
+ <!-- <tr>
4076
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4077
+ </tr>
4078
+ -->
4079
+ <fo:table-row>
4080
+ <fo:table-cell number-columns-spanned="2">
4081
+ <fo:block>
4082
+ <xsl:call-template name="note"/>
3521
4083
  </fo:block>
3522
4084
  </fo:table-cell>
3523
4085
  </fo:table-row>
3524
4086
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
4087
+ <xsl:param name="id"/>
4088
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
3525
4089
  <tr>
3526
4090
  <td>
4091
+ <xsl:attribute name="id">
4092
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
4093
+ </xsl:attribute>
3527
4094
  <xsl:apply-templates/>
3528
4095
  </td>
3529
4096
  <td>
4097
+ <xsl:attribute name="id">
4098
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
4099
+ </xsl:attribute>
3530
4100
 
3531
4101
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
3532
4102
  <xsl:with-param name="process">true</xsl:with-param>
@@ -3537,50 +4107,134 @@
3537
4107
 
3538
4108
  </xsl:template><xsl:template match="*[local-name()='dt']">
3539
4109
  <xsl:param name="key_iso"/>
4110
+ <xsl:param name="split_keep-within-line"/>
3540
4111
 
3541
4112
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
3542
- <fo:table-cell>
4113
+ <xsl:call-template name="insert_dt_cell">
4114
+ <xsl:with-param name="key_iso" select="$key_iso"/>
4115
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4116
+ </xsl:call-template>
4117
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
4118
+ <xsl:call-template name="insert_dd_cell">
4119
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4120
+ </xsl:call-template>
4121
+ </xsl:for-each>
4122
+ </fo:table-row>
4123
+ </xsl:template><xsl:template name="insert_dt_cell">
4124
+ <xsl:param name="key_iso"/>
4125
+ <xsl:param name="split_keep-within-line"/>
4126
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
4127
+
4128
+ <xsl:if test="$isGenerateTableIF = 'true'">
4129
+ <!-- border is mandatory, to calculate real width -->
4130
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4131
+ <xsl:attribute name="text-align">left</xsl:attribute>
4132
+ </xsl:if>
4133
+
4134
+
4135
+ <fo:block xsl:use-attribute-sets="dt-block-style">
4136
+ <xsl:copy-of select="@id"/>
4137
+
4138
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4139
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4140
+ </xsl:if>
4141
+
4142
+
4143
+
4144
+ <xsl:apply-templates>
4145
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4146
+ </xsl:apply-templates>
4147
+
4148
+ <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"/> -->
4149
+
4150
+ </fo:block>
4151
+ </fo:table-cell>
4152
+ </xsl:template><xsl:template name="insert_dd_cell">
4153
+ <xsl:param name="split_keep-within-line"/>
4154
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
4155
+
4156
+ <xsl:if test="$isGenerateTableIF = 'true'">
4157
+ <!-- border is mandatory, to calculate real width -->
4158
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4159
+ </xsl:if>
4160
+
4161
+ <fo:block>
4162
+
4163
+ <xsl:if test="$isGenerateTableIF = 'true'">
4164
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4165
+ </xsl:if>
4166
+
3543
4167
 
3544
- <fo:block xsl:use-attribute-sets="dt-style">
3545
- <xsl:copy-of select="@id"/>
3546
-
3547
- <xsl:if test="normalize-space($key_iso) = 'true'">
3548
- <xsl:attribute name="margin-top">0</xsl:attribute>
3549
- </xsl:if>
3550
-
3551
-
3552
-
3553
- <xsl:apply-templates/>
3554
- </fo:block>
3555
- </fo:table-cell>
3556
- <fo:table-cell>
3557
- <fo:block>
3558
-
3559
4168
 
3560
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
3561
- <xsl:with-param name="process">true</xsl:with-param>
3562
- </xsl:apply-templates>
3563
- </fo:block>
3564
- </fo:table-cell>
3565
- </fo:table-row>
4169
+ <xsl:choose>
4170
+ <xsl:when test="$isGenerateTableIF = 'true'">
4171
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
4172
+ <xsl:with-param name="process">true</xsl:with-param>
4173
+ </xsl:apply-templates>
4174
+ </xsl:when>
4175
+ <xsl:otherwise>
4176
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
4177
+ <xsl:with-param name="process">true</xsl:with-param>
4178
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4179
+ </xsl:apply-templates>
4180
+ </xsl:otherwise>
4181
+
4182
+ </xsl:choose>
4183
+
4184
+ <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"/> -->
4185
+
4186
+ </fo:block>
4187
+ </fo:table-cell>
3566
4188
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
3567
4189
  <xsl:apply-templates/>
3568
4190
  </xsl:template><xsl:template match="*[local-name()='dd']">
3569
4191
  <xsl:param name="process">false</xsl:param>
4192
+ <xsl:param name="split_keep-within-line"/>
3570
4193
  <xsl:if test="$process = 'true'">
3571
4194
  <xsl:apply-templates select="@language"/>
3572
- <xsl:apply-templates/>
4195
+ <xsl:apply-templates>
4196
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4197
+ </xsl:apply-templates>
3573
4198
  </xsl:if>
3574
4199
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
3575
4200
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
3576
- </xsl:template><xsl:template match="*[local-name()='em']">
4201
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
4202
+ <xsl:param name="id"/>
4203
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4204
+ <tr>
4205
+ <td>
4206
+ <xsl:copy-of select="node()"/>
4207
+ </td>
4208
+ <td>
4209
+
4210
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
4211
+
4212
+ <!-- get paragraphs from nested 'dl' -->
4213
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
4214
+
4215
+
4216
+ </td>
4217
+ </tr>
4218
+
4219
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
4220
+ <xsl:for-each select="*[local-name() = 'dt']">
4221
+ <p>
4222
+ <xsl:copy-of select="node()"/>
4223
+ <xsl:text> </xsl:text>
4224
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
4225
+ </p>
4226
+ </xsl:for-each>
4227
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
3577
4228
  <fo:inline font-style="italic">
3578
4229
  <xsl:apply-templates/>
3579
4230
  </fo:inline>
3580
4231
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
4232
+ <xsl:param name="split_keep-within-line"/>
3581
4233
  <fo:inline font-weight="bold">
3582
4234
 
3583
- <xsl:apply-templates/>
4235
+ <xsl:apply-templates>
4236
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4237
+ </xsl:apply-templates>
3584
4238
  </fo:inline>
3585
4239
  </xsl:template><xsl:template match="*[local-name()='padding']">
3586
4240
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -3601,7 +4255,7 @@
3601
4255
 
3602
4256
 
3603
4257
 
3604
-
4258
+ <!-- 10 -->
3605
4259
 
3606
4260
 
3607
4261
 
@@ -3619,13 +4273,15 @@
3619
4273
  <xsl:choose>
3620
4274
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
3621
4275
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
3622
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4276
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
3623
4277
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
3624
4278
  </xsl:choose>
3625
4279
  </xsl:attribute>
3626
4280
  </xsl:if>
3627
4281
  <xsl:apply-templates/>
3628
4282
  </fo:inline>
4283
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
4284
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
3629
4285
  </xsl:template><xsl:template match="*[local-name()='underline']">
3630
4286
  <fo:inline text-decoration="underline">
3631
4287
  <xsl:apply-templates/>
@@ -3773,54 +4429,120 @@
3773
4429
  <fo:block break-after="page"/>
3774
4430
  <fo:block> </fo:block>
3775
4431
  <fo:block break-after="page"/>
4432
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
4433
+ <xsl:apply-templates/>
3776
4434
  </xsl:template><xsl:template name="tokenize">
3777
4435
  <xsl:param name="text"/>
3778
4436
  <xsl:param name="separator" select="' '"/>
3779
4437
  <xsl:choose>
4438
+
4439
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
4440
+ <word><xsl:value-of select="normalize-space($text)"/></word>
4441
+ </xsl:when>
3780
4442
  <xsl:when test="not(contains($text, $separator))">
3781
4443
  <word>
3782
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
3783
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
3784
4444
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
3785
- <xsl:variable name="len_str">
3786
- <xsl:choose>
3787
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
3788
- <xsl:value-of select="$len_str_tmp * 1.5"/>
3789
- </xsl:when>
3790
- <xsl:otherwise>
3791
- <xsl:value-of select="$len_str_tmp"/>
3792
- </xsl:otherwise>
3793
- </xsl:choose>
3794
- </xsl:variable>
3795
-
3796
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
3797
- <xsl:message>
3798
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
3799
- len_str=<xsl:value-of select="$len_str"/>
3800
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
3801
- </xsl:message>
3802
- </xsl:if> -->
3803
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
3804
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
3805
4445
  <xsl:choose>
3806
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
3807
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4446
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
4447
+ <xsl:value-of select="$len_str_tmp"/>
3808
4448
  </xsl:when>
3809
4449
  <xsl:otherwise>
3810
- <xsl:value-of select="$len_str"/>
4450
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4451
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4452
+ <xsl:variable name="len_str">
4453
+ <xsl:choose>
4454
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4455
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
4456
+ </xsl:when>
4457
+ <xsl:otherwise>
4458
+ <xsl:value-of select="$len_str_tmp"/>
4459
+ </xsl:otherwise>
4460
+ </xsl:choose>
4461
+ </xsl:variable>
4462
+
4463
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4464
+ <xsl:message>
4465
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4466
+ len_str=<xsl:value-of select="$len_str"/>
4467
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4468
+ </xsl:message>
4469
+ </xsl:if> -->
4470
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4471
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
4472
+ <xsl:choose>
4473
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4474
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4475
+ </xsl:when>
4476
+ <xsl:otherwise>
4477
+ <xsl:value-of select="$len_str"/>
4478
+ </xsl:otherwise>
4479
+ </xsl:choose>
3811
4480
  </xsl:otherwise>
3812
4481
  </xsl:choose>
3813
4482
  </word>
3814
4483
  </xsl:when>
3815
4484
  <xsl:otherwise>
3816
4485
  <word>
3817
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
4486
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
4487
+ <xsl:choose>
4488
+ <xsl:when test="$isGenerateTableIF = 'true'">
4489
+ <xsl:value-of select="$word"/>
4490
+ </xsl:when>
4491
+ <xsl:otherwise>
4492
+ <xsl:value-of select="string-length($word)"/>
4493
+ </xsl:otherwise>
4494
+ </xsl:choose>
3818
4495
  </word>
3819
4496
  <xsl:call-template name="tokenize">
3820
4497
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
3821
4498
  </xsl:call-template>
3822
4499
  </xsl:otherwise>
3823
4500
  </xsl:choose>
4501
+ </xsl:template><xsl:template name="tokenize_with_tags">
4502
+ <xsl:param name="tags"/>
4503
+ <xsl:param name="text"/>
4504
+ <xsl:param name="separator" select="' '"/>
4505
+ <xsl:choose>
4506
+
4507
+ <xsl:when test="not(contains($text, $separator))">
4508
+ <word>
4509
+ <xsl:call-template name="enclose_text_in_tags">
4510
+ <xsl:with-param name="text" select="normalize-space($text)"/>
4511
+ <xsl:with-param name="tags" select="$tags"/>
4512
+ </xsl:call-template>
4513
+ </word>
4514
+ </xsl:when>
4515
+ <xsl:otherwise>
4516
+ <word>
4517
+ <xsl:call-template name="enclose_text_in_tags">
4518
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
4519
+ <xsl:with-param name="tags" select="$tags"/>
4520
+ </xsl:call-template>
4521
+ </word>
4522
+ <xsl:call-template name="tokenize_with_tags">
4523
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
4524
+ </xsl:call-template>
4525
+ </xsl:otherwise>
4526
+ </xsl:choose>
4527
+ </xsl:template><xsl:template name="enclose_text_in_tags">
4528
+ <xsl:param name="text"/>
4529
+ <xsl:param name="tags"/>
4530
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
4531
+
4532
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
4533
+
4534
+ <xsl:choose>
4535
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
4536
+ <xsl:otherwise>
4537
+ <xsl:element name="{$tag_name}">
4538
+ <xsl:call-template name="enclose_text_in_tags">
4539
+ <xsl:with-param name="text" select="$text"/>
4540
+ <xsl:with-param name="tags" select="$tags"/>
4541
+ <xsl:with-param name="num" select="$num + 1"/>
4542
+ </xsl:call-template>
4543
+ </xsl:element>
4544
+ </xsl:otherwise>
4545
+ </xsl:choose>
3824
4546
  </xsl:template><xsl:template name="max_length">
3825
4547
  <xsl:param name="words"/>
3826
4548
  <xsl:for-each select="$words//word">
@@ -3921,12 +4643,19 @@
3921
4643
  </xsl:otherwise>
3922
4644
  </xsl:choose>
3923
4645
  </xsl:template><xsl:template name="getSimpleTable">
4646
+ <xsl:param name="id"/>
4647
+
3924
4648
  <xsl:variable name="simple-table">
3925
4649
 
4650
+ <!-- Step 0. replace <br/> to <p>...</p> -->
4651
+ <xsl:variable name="table_without_br">
4652
+ <xsl:apply-templates mode="table-without-br"/>
4653
+ </xsl:variable>
4654
+
3926
4655
  <!-- Step 1. colspan processing -->
3927
4656
  <xsl:variable name="simple-table-colspan">
3928
4657
  <tbody>
3929
- <xsl:apply-templates mode="simple-table-colspan"/>
4658
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
3930
4659
  </tbody>
3931
4660
  </xsl:variable>
3932
4661
 
@@ -3935,10 +4664,67 @@
3935
4664
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
3936
4665
  </xsl:variable>
3937
4666
 
3938
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
3939
-
4667
+ <!-- Step 3: add id to each cell -->
4668
+ <!-- add <word>...</word> for each word, image, math -->
4669
+ <xsl:variable name="simple-table-id">
4670
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
4671
+ <xsl:with-param name="id" select="$id"/>
4672
+ </xsl:apply-templates>
4673
+ </xsl:variable>
4674
+
4675
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
4676
+
3940
4677
  </xsl:variable>
3941
4678
  <xsl:copy-of select="$simple-table"/>
4679
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
4680
+ <xsl:copy>
4681
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
4682
+ </xsl:copy>
4683
+ </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">
4684
+ <xsl:copy>
4685
+ <xsl:copy-of select="@*"/>
4686
+ <p>
4687
+ <xsl:copy-of select="node()"/>
4688
+ </p>
4689
+ </xsl:copy>
4690
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
4691
+ <xsl:copy>
4692
+ <xsl:copy-of select="@*"/>
4693
+ <xsl:for-each select="*[local-name()='br']">
4694
+ <xsl:variable name="current_id" select="generate-id()"/>
4695
+ <p>
4696
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
4697
+ <xsl:copy-of select="."/>
4698
+ </xsl:for-each>
4699
+ </p>
4700
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
4701
+ <p>
4702
+ <xsl:for-each select="following-sibling::node()">
4703
+ <xsl:copy-of select="."/>
4704
+ </xsl:for-each>
4705
+ </p>
4706
+ </xsl:if>
4707
+ </xsl:for-each>
4708
+ </xsl:copy>
4709
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
4710
+ <xsl:for-each select="*[local-name()='br']">
4711
+ <xsl:variable name="current_id" select="generate-id()"/>
4712
+ <p>
4713
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
4714
+ <xsl:copy-of select="."/>
4715
+ </xsl:for-each>
4716
+ </p>
4717
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
4718
+ <p>
4719
+ <xsl:for-each select="following-sibling::node()">
4720
+ <xsl:copy-of select="."/>
4721
+ </xsl:for-each>
4722
+ </p>
4723
+ </xsl:if>
4724
+ </xsl:for-each>
4725
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
4726
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
4727
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
3942
4728
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
3943
4729
  <xsl:apply-templates mode="simple-table-colspan"/>
3944
4730
  </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">
@@ -4016,18 +4802,138 @@
4016
4802
  </xsl:choose>
4017
4803
  </xsl:for-each>
4018
4804
  </xsl:variable>
4019
-
4020
- <xsl:variable name="newRow">
4021
- <xsl:copy>
4022
- <xsl:copy-of select="$currentRow/@*"/>
4023
- <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
4024
- </xsl:copy>
4805
+
4806
+ <xsl:variable name="newRow">
4807
+ <xsl:copy>
4808
+ <xsl:copy-of select="$currentRow/@*"/>
4809
+ <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
4810
+ </xsl:copy>
4811
+ </xsl:variable>
4812
+ <xsl:copy-of select="$newRow"/>
4813
+
4814
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
4815
+ <xsl:with-param name="previousRow" select="$newRow"/>
4816
+ </xsl:apply-templates>
4817
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
4818
+ <xsl:param name="id"/>
4819
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
4820
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
4821
+ <xsl:with-param name="id" select="$id_prefixed"/>
4822
+ </xsl:apply-templates>
4823
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
4824
+ <xsl:param name="id"/>
4825
+ <xsl:copy>
4826
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
4827
+ <xsl:with-param name="id" select="$id"/>
4828
+ </xsl:apply-templates>
4829
+ </xsl:copy>
4830
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
4831
+ <xsl:param name="id"/>
4832
+ <xsl:copy>
4833
+ <xsl:copy-of select="@*"/>
4834
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4835
+ <xsl:apply-templates select="node()" mode="simple-table-id">
4836
+ <xsl:with-param name="id" select="$id"/>
4837
+ </xsl:apply-templates>
4838
+ </xsl:copy>
4839
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
4840
+ <xsl:param name="id"/>
4841
+ <xsl:copy>
4842
+ <xsl:copy-of select="@*"/>
4843
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
4844
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
4845
+ <xsl:attribute name="id">
4846
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
4847
+ </xsl:attribute>
4848
+
4849
+ <xsl:for-each select="*[local-name() = 'p']">
4850
+ <xsl:copy>
4851
+ <xsl:copy-of select="@*"/>
4852
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
4853
+ <xsl:attribute name="id">
4854
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
4855
+ </xsl:attribute>
4856
+
4857
+ <xsl:copy-of select="node()"/>
4858
+ </xsl:copy>
4859
+ </xsl:for-each>
4860
+
4861
+
4862
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
4863
+
4864
+ <xsl:variable name="td_text">
4865
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
4866
+ </xsl:variable>
4867
+
4868
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
4869
+
4870
+ <xsl:variable name="words">
4871
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
4872
+ <word>
4873
+ <xsl:copy-of select="."/>
4874
+ </word>
4875
+ </xsl:for-each>
4876
+
4877
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
4878
+ <xsl:copy-of select="."/>
4879
+ </xsl:for-each>
4880
+
4881
+ </xsl:variable>
4882
+
4883
+ <xsl:for-each select="xalan:nodeset($words)/word">
4884
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
4885
+ <xsl:copy>
4886
+ <xsl:attribute name="id">
4887
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
4888
+ </xsl:attribute>
4889
+ <xsl:copy-of select="node()"/>
4890
+ </xsl:copy>
4891
+ </xsl:for-each>
4892
+ </xsl:if>
4893
+ </xsl:copy>
4894
+
4895
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
4896
+ <xsl:copy>
4897
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
4898
+ </xsl:copy>
4899
+ </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">
4900
+ <xsl:variable name="formatting_tags">
4901
+ <xsl:call-template name="getFormattingTags"/>
4902
+ </xsl:variable>
4903
+ <word>
4904
+ <xsl:call-template name="enclose_text_in_tags">
4905
+ <xsl:with-param name="text" select="normalize-space(.)"/>
4906
+ <xsl:with-param name="tags" select="$formatting_tags"/>
4907
+ </xsl:call-template>
4908
+ </word>
4909
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
4910
+
4911
+ <xsl:variable name="td_text" select="."/>
4912
+
4913
+ <xsl:variable name="string_with_added_zerospaces">
4914
+ <xsl:call-template name="add-zero-spaces-java">
4915
+ <xsl:with-param name="text" select="$td_text"/>
4916
+ </xsl:call-template>
4025
4917
  </xsl:variable>
4026
- <xsl:copy-of select="$newRow"/>
4027
-
4028
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
4029
- <xsl:with-param name="previousRow" select="$newRow"/>
4030
- </xsl:apply-templates>
4918
+
4919
+ <xsl:variable name="formatting_tags">
4920
+ <xsl:call-template name="getFormattingTags"/>
4921
+ </xsl:variable>
4922
+
4923
+ <!-- <word>text</word> -->
4924
+ <xsl:call-template name="tokenize_with_tags">
4925
+ <xsl:with-param name="tags" select="$formatting_tags"/>
4926
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
4927
+ </xsl:call-template>
4928
+ </xsl:template><xsl:template name="getFormattingTags">
4929
+ <tags>
4930
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
4931
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
4932
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
4933
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
4934
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
4935
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
4936
+ </tags>
4031
4937
  </xsl:template><xsl:template name="getLang">
4032
4938
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
4033
4939
  <xsl:variable name="language">
@@ -4082,6 +4988,9 @@
4082
4988
  <xsl:variable name="isDeleted" select="@deleted"/>
4083
4989
 
4084
4990
  <fo:inline xsl:use-attribute-sets="mathml-style">
4991
+
4992
+
4993
+
4085
4994
 
4086
4995
 
4087
4996
  <xsl:call-template name="setTrackChangesStyles">
@@ -4089,48 +4998,80 @@
4089
4998
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
4090
4999
  </xsl:call-template>
4091
5000
 
5001
+ <xsl:if test="$add_math_as_text = 'true'">
5002
+ <!-- insert helper tag -->
5003
+ <!-- set unique font-size (fiction) -->
5004
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
5005
+ <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal"><xsl:value-of select="$zero_width_space"/></fo:inline> <!-- zero width space -->
5006
+ </xsl:if>
4092
5007
 
4093
-
4094
- <xsl:variable name="mathml">
4095
- <xsl:apply-templates select="." mode="mathml"/>
5008
+ <xsl:variable name="mathml_content">
5009
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
4096
5010
  </xsl:variable>
4097
- <fo:instream-foreign-object fox:alt-text="Math">
4098
5011
 
5012
+
5013
+ <xsl:call-template name="mathml_instream_object">
5014
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
5015
+ </xsl:call-template>
4099
5016
 
4100
-
4101
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
4102
- <xsl:variable name="comment_text_">
4103
- <xsl:choose>
4104
- <xsl:when test="normalize-space($comment_text_following) != ''">
4105
- <xsl:value-of select="$comment_text_following"/>
4106
- </xsl:when>
4107
- <xsl:otherwise>
4108
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
4109
- </xsl:otherwise>
4110
- </xsl:choose>
4111
- </xsl:variable>
4112
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
4113
-
4114
- <xsl:if test="normalize-space($comment_text) != ''">
4115
- <!-- put Mathin Alternate Text -->
4116
- <xsl:attribute name="fox:alt-text">
4117
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
4118
- </xsl:attribute>
4119
- </xsl:if>
4120
-
4121
- <xsl:variable name="mathml_content">
4122
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
4123
- </xsl:variable>
4124
- <!-- put MathML in Actual Text -->
4125
- <xsl:attribute name="fox:actual-text">
4126
- <xsl:value-of select="$mathml_content"/>
4127
- </xsl:attribute>
4128
-
4129
-
4130
-
4131
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
4132
- </fo:instream-foreign-object>
5017
+
4133
5018
  </fo:inline>
5019
+ </xsl:template><xsl:template name="getMathml_comment_text">
5020
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5021
+ <xsl:variable name="comment_text_">
5022
+ <xsl:choose>
5023
+ <xsl:when test="normalize-space($comment_text_following) != ''">
5024
+ <xsl:value-of select="$comment_text_following"/>
5025
+ </xsl:when>
5026
+ <xsl:otherwise>
5027
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5028
+ </xsl:otherwise>
5029
+ </xsl:choose>
5030
+ </xsl:variable>
5031
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5032
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
5033
+ <xsl:value-of select="$comment_text"/>
5034
+ </xsl:template><xsl:template name="mathml_instream_object">
5035
+ <xsl:param name="comment_text"/>
5036
+ <xsl:param name="mathml_content"/>
5037
+
5038
+ <xsl:variable name="comment_text_">
5039
+ <xsl:choose>
5040
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
5041
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
5042
+ </xsl:choose>
5043
+ </xsl:variable>
5044
+
5045
+ <xsl:variable name="mathml">
5046
+ <xsl:apply-templates select="." mode="mathml"/>
5047
+ </xsl:variable>
5048
+
5049
+ <fo:instream-foreign-object fox:alt-text="Math">
5050
+
5051
+
5052
+
5053
+
5054
+
5055
+
5056
+
5057
+ <!-- put MathML in Actual Text -->
5058
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
5059
+ <xsl:attribute name="fox:actual-text">
5060
+ <xsl:value-of select="$mathml_content"/>
5061
+ </xsl:attribute>
5062
+
5063
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
5064
+ <xsl:if test="normalize-space($comment_text_) != ''">
5065
+ <!-- put Mathin Alternate Text -->
5066
+ <xsl:attribute name="fox:alt-text">
5067
+ <xsl:value-of select="$comment_text_"/>
5068
+ </xsl:attribute>
5069
+ </xsl:if>
5070
+ <!-- </xsl:if> -->
5071
+
5072
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
5073
+
5074
+ </fo:instream-foreign-object>
4134
5075
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
4135
5076
  <!-- <xsl:text>a+b</xsl:text> -->
4136
5077
  <xsl:text>&lt;</xsl:text>
@@ -4161,7 +5102,9 @@
4161
5102
  <!-- replace start and end spaces to non-break space -->
4162
5103
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4163
5104
  </xsl:copy>
4164
- </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">
5105
+ </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">
5106
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5107
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
4165
5108
  <xsl:variable name="target">
4166
5109
  <xsl:choose>
4167
5110
  <xsl:when test="@updatetype = 'true'">
@@ -4770,18 +5713,33 @@
4770
5713
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4771
5714
  <xsl:copy>
4772
5715
  <xsl:apply-templates select="@*" mode="svg_update"/>
4773
- <xsl:variable name="viewbox">
5716
+ <xsl:variable name="viewbox_">
4774
5717
  <xsl:call-template name="split">
4775
5718
  <xsl:with-param name="pText" select="@viewBox"/>
4776
5719
  <xsl:with-param name="sep" select="' '"/>
4777
5720
  </xsl:call-template>
4778
5721
  </xsl:variable>
5722
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
5723
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
5724
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
5725
+
4779
5726
  <xsl:attribute name="width">
4780
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
5727
+ <xsl:choose>
5728
+ <xsl:when test="$width != ''">
5729
+ <xsl:value-of select="round($width)"/>
5730
+ </xsl:when>
5731
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
5732
+ </xsl:choose>
4781
5733
  </xsl:attribute>
4782
5734
  <xsl:attribute name="height">
4783
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
5735
+ <xsl:choose>
5736
+ <xsl:when test="$height != ''">
5737
+ <xsl:value-of select="round($height)"/>
5738
+ </xsl:when>
5739
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
5740
+ </xsl:choose>
4784
5741
  </xsl:attribute>
5742
+
4785
5743
  <xsl:apply-templates mode="svg_update"/>
4786
5744
  </xsl:copy>
4787
5745
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -4976,7 +5934,11 @@
4976
5934
  <xsl:apply-templates mode="bookmarks"/>
4977
5935
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
4978
5936
  <xsl:apply-templates select="."/>
4979
- </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">
5937
+ </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">
5938
+ <xsl:apply-templates mode="contents"/>
5939
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
5940
+ <xsl:apply-templates mode="bookmarks"/>
5941
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
4980
5942
  <xsl:apply-templates mode="bookmarks"/>
4981
5943
  </xsl:template><xsl:template name="addBookmarks">
4982
5944
  <xsl:param name="contents"/>
@@ -5258,7 +6220,9 @@
5258
6220
  <xsl:apply-templates/>
5259
6221
  </xsl:otherwise>
5260
6222
  </xsl:choose>
5261
- </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">
6223
+ </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">
6224
+ <xsl:value-of select="."/>
6225
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
5262
6226
  <xsl:text> </xsl:text>
5263
6227
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
5264
6228
  <xsl:copy>
@@ -5289,9 +6253,22 @@
5289
6253
  </xsl:when>
5290
6254
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
5291
6255
  </xsl:choose>
6256
+ </xsl:template><xsl:template match="text()" mode="contents_item">
6257
+ <xsl:call-template name="keep_together_standard_number"/>
6258
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
6259
+ <xsl:apply-templates mode="contents_item"/>
5292
6260
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
5293
6261
 
5294
6262
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
6263
+
6264
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
6265
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6266
+ </xsl:if>
6267
+
6268
+ <xsl:if test="ancestor::*[local-name() = 'example']">
6269
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6270
+ </xsl:if>
6271
+
5295
6272
  <xsl:copy-of select="@id"/>
5296
6273
 
5297
6274
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -5316,7 +6293,7 @@
5316
6293
 
5317
6294
 
5318
6295
 
5319
-
6296
+ <!-- 9 -->
5320
6297
 
5321
6298
 
5322
6299
 
@@ -5400,7 +6377,7 @@
5400
6377
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
5401
6378
  <xsl:choose>
5402
6379
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5403
- <xsl:call-template name="interspers">
6380
+ <xsl:call-template name="interspers-java">
5404
6381
  <xsl:with-param name="str" select="."/>
5405
6382
  </xsl:call-template>
5406
6383
  </xsl:when>
@@ -5450,6 +6427,10 @@
5450
6427
  <xsl:with-param name="char" select="$char"/>
5451
6428
  </xsl:call-template>
5452
6429
  </xsl:if>
6430
+ </xsl:template><xsl:template name="interspers-java">
6431
+ <xsl:param name="str"/>
6432
+ <xsl:param name="char" select="$zero_width_space"/>
6433
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
5453
6434
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5454
6435
  <xsl:apply-templates mode="syntax_highlight"/>
5455
6436
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5662,7 +6643,9 @@
5662
6643
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
5663
6644
  </xsl:if>
5664
6645
  <xsl:variable name="simple-table">
5665
- <xsl:call-template name="getSimpleTable"/>
6646
+ <xsl:call-template name="getSimpleTable">
6647
+ <xsl:with-param name="id" select="@id"/>
6648
+ </xsl:call-template>
5666
6649
  </xsl:variable>
5667
6650
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
5668
6651
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -5769,39 +6752,67 @@
5769
6752
  </xsl:otherwise>
5770
6753
  </xsl:choose>
5771
6754
  </xsl:template><xsl:template match="*[local-name() = 'example']">
5772
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
5773
-
6755
+
6756
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
6757
+
5774
6758
 
6759
+
5775
6760
  <xsl:variable name="fo_element">
5776
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
6761
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
5777
6762
  block
5778
6763
  </xsl:variable>
5779
6764
 
5780
- <!-- display 'EXAMPLE' -->
5781
- <xsl:apply-templates select="*[local-name()='name']">
5782
- <xsl:with-param name="fo_element" select="$fo_element"/>
5783
- </xsl:apply-templates>
6765
+ <fo:block-container margin-left="0mm">
5784
6766
 
5785
- <xsl:choose>
5786
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
5787
- <fo:block-container xsl:use-attribute-sets="example-body-style">
5788
- <fo:block-container margin-left="0mm" margin-right="0mm">
5789
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6767
+ <xsl:choose>
6768
+
6769
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
6770
+
6771
+ <!-- display name 'EXAMPLE' in a separate block -->
6772
+ <fo:block>
6773
+ <xsl:apply-templates select="*[local-name()='name']">
5790
6774
  <xsl:with-param name="fo_element" select="$fo_element"/>
5791
6775
  </xsl:apply-templates>
6776
+ </fo:block>
6777
+
6778
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6779
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6780
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6781
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6782
+ </xsl:apply-templates>
6783
+ </fo:block-container>
5792
6784
  </fo:block-container>
5793
- </fo:block-container>
5794
- </xsl:when>
5795
- <xsl:otherwise>
5796
- <fo:inline>
5797
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5798
- <xsl:with-param name="fo_element" select="$fo_element"/>
5799
- </xsl:apply-templates>
5800
- </fo:inline>
5801
- </xsl:otherwise>
5802
- </xsl:choose>
5803
-
5804
- </fo:block>
6785
+ </xsl:when> <!-- end block -->
6786
+
6787
+ <xsl:otherwise> <!-- inline -->
6788
+
6789
+ <!-- display 'EXAMPLE' and first element in the same line -->
6790
+ <fo:block>
6791
+ <xsl:apply-templates select="*[local-name()='name']">
6792
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6793
+ </xsl:apply-templates>
6794
+ <fo:inline>
6795
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
6796
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6797
+ </xsl:apply-templates>
6798
+ </fo:inline>
6799
+ </fo:block>
6800
+
6801
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
6802
+ <!-- display further elements in blocks -->
6803
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6804
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6805
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
6806
+ <xsl:with-param name="fo_element" select="'block'"/>
6807
+ </xsl:apply-templates>
6808
+ </fo:block-container>
6809
+ </fo:block-container>
6810
+ </xsl:if>
6811
+ </xsl:otherwise> <!-- end inline -->
6812
+
6813
+ </xsl:choose>
6814
+ </fo:block-container>
6815
+ </fo:block-container>
5805
6816
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
5806
6817
  <xsl:param name="fo_element">block</xsl:param>
5807
6818
 
@@ -5833,14 +6844,20 @@
5833
6844
  </xsl:variable>
5834
6845
  <xsl:choose>
5835
6846
  <xsl:when test="starts-with(normalize-space($element), 'block')">
5836
- <fo:block xsl:use-attribute-sets="example-p-style">
5837
-
5838
- <xsl:if test="$num = 1">
5839
- <xsl:attribute name="margin-left">5mm</xsl:attribute>
5840
- </xsl:if>
5841
-
5842
- <xsl:apply-templates/>
5843
- </fo:block>
6847
+ <fo:block-container>
6848
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
6849
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6850
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6851
+ </xsl:if>
6852
+ <fo:block xsl:use-attribute-sets="example-p-style">
6853
+
6854
+ <xsl:if test="$num = 1">
6855
+ <xsl:attribute name="margin-left">5mm</xsl:attribute>
6856
+ </xsl:if>
6857
+
6858
+ <xsl:apply-templates/>
6859
+ </fo:block>
6860
+ </fo:block-container>
5844
6861
  </xsl:when>
5845
6862
  <xsl:otherwise>
5846
6863
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -6021,7 +7038,16 @@
6021
7038
  </fo:inline>
6022
7039
  </xsl:when>
6023
7040
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6024
- <fo:inline><xsl:apply-templates/></fo:inline>
7041
+
7042
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
7043
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
7044
+ <xsl:choose>
7045
+ <xsl:when test="$uri_src != ''">
7046
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
7047
+ </xsl:when>
7048
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
7049
+ </xsl:choose>
7050
+
6025
7051
  </xsl:otherwise>
6026
7052
  </xsl:choose>
6027
7053
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -6202,10 +7228,24 @@
6202
7228
 
6203
7229
  </fo:block>
6204
7230
  <xsl:apply-templates/>
6205
- </xsl:template><xsl:template match="*[local-name() = 'review']">
7231
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
6206
7232
  <!-- comment 2019-11-29 -->
6207
7233
  <!-- <fo:block font-weight="bold">Review:</fo:block>
6208
7234
  <xsl:apply-templates /> -->
7235
+
7236
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
7237
+
7238
+ <xsl:choose>
7239
+ <!-- if there isn't the attribute '@from', then -->
7240
+ <xsl:when test="$id_from = ''">
7241
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7242
+ </xsl:when>
7243
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
7244
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
7245
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7246
+ </xsl:when>
7247
+ </xsl:choose>
7248
+
6209
7249
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
6210
7250
  <!-- 0xA0 to space replacement -->
6211
7251
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -6350,6 +7390,11 @@
6350
7390
  </xsl:otherwise>
6351
7391
  </xsl:choose>
6352
7392
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
7393
+
7394
+ <xsl:apply-templates select="*[local-name() = 'name']">
7395
+ <xsl:with-param name="process">true</xsl:with-param>
7396
+ </xsl:apply-templates>
7397
+
6353
7398
  <fo:list-block xsl:use-attribute-sets="list-style">
6354
7399
 
6355
7400
 
@@ -6360,12 +7405,23 @@
6360
7405
 
6361
7406
 
6362
7407
 
7408
+ <xsl:if test="*[local-name() = 'name']">
7409
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
7410
+ </xsl:if>
7411
+
6363
7412
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6364
7413
  </fo:list-block>
6365
7414
  <!-- <xsl:for-each select="./iho:note">
6366
7415
  <xsl:call-template name="note"/>
6367
7416
  </xsl:for-each> -->
6368
7417
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
7418
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
7419
+ <xsl:param name="process">false</xsl:param>
7420
+ <xsl:if test="$process = 'true'">
7421
+ <fo:block xsl:use-attribute-sets="list-name-style">
7422
+ <xsl:apply-templates/>
7423
+ </fo:block>
7424
+ </xsl:if>
6369
7425
  </xsl:template><xsl:template match="*[local-name()='li']">
6370
7426
  <fo:list-item xsl:use-attribute-sets="list-item-style">
6371
7427
  <xsl:copy-of select="@id"/>
@@ -6562,7 +7618,10 @@
6562
7618
  <!-- to split by '_' and other chars -->
6563
7619
  <xsl:call-template name="add-zero-spaces-java"/>
6564
7620
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
6565
- <fo:inline id="{@id}" font-size="1pt"/>
7621
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
7622
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
7623
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
7624
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
6566
7625
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
6567
7626
  <!-- <row>
6568
7627
  <date>05-07-2013</date>
@@ -6640,22 +7699,11 @@
6640
7699
  </xsl:template><xsl:template name="processBibitem">
6641
7700
 
6642
7701
 
7702
+ <!-- start UNECE bibitem processing -->
6643
7703
  <fo:inline padding-right="5mm">[<xsl:value-of select="un:docidentifier"/>]</fo:inline><xsl:value-of select="un:docidentifier"/>
6644
- <xsl:if test="un:title">
6645
- <fo:inline font-style="italic">
6646
- <xsl:text>, </xsl:text>
6647
- <xsl:choose>
6648
- <xsl:when test="un:title[@type = 'main' and @language = 'en']">
6649
- <xsl:apply-templates select="un:title[@type = 'main' and @language = 'en']"/>
6650
- </xsl:when>
6651
- <xsl:otherwise>
6652
- <xsl:apply-templates select="un:title"/>
6653
- </xsl:otherwise>
6654
- </xsl:choose>
6655
- </fo:inline>
6656
- </xsl:if>
7704
+ <xsl:text> </xsl:text>
6657
7705
  <xsl:apply-templates select="un:formattedref"/>
6658
-
7706
+ <!-- END UNECE bibitem processing -->
6659
7707
 
6660
7708
  </xsl:template><xsl:template name="processBibitemDocId">
6661
7709
  <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/>
@@ -6980,25 +8028,32 @@
6980
8028
  </fo:block-container>
6981
8029
 
6982
8030
  </xsl:template><xsl:template name="displayAdmonitionName">
6983
-
8031
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
8032
+ <!-- <xsl:choose>
8033
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
8034
+ <xsl:choose>
8035
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
8036
+ <xsl:otherwise>
8037
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8038
+ </xsl:otherwise>
8039
+ </xsl:choose>
8040
+ </xsl:when>
8041
+ <xsl:otherwise>
6984
8042
  <xsl:apply-templates select="*[local-name() = 'name']"/>
6985
8043
  <xsl:if test="not(*[local-name() = 'name'])">
6986
8044
  <xsl:apply-templates select="@type"/>
6987
8045
  </xsl:if>
6988
-
6989
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
6990
- <xsl:apply-templates/>
6991
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
6992
- <xsl:variable name="admonition_type_">
6993
- <xsl:call-template name="getLocalizedString">
6994
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
6995
- </xsl:call-template>
8046
+ </xsl:otherwise>
8047
+ </xsl:choose> -->
8048
+ <xsl:variable name="name">
8049
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
6996
8050
  </xsl:variable>
6997
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
6998
- <xsl:value-of select="$admonition_type"/>
6999
- <xsl:if test="$admonition_type = ''">
7000
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
8051
+ <xsl:copy-of select="$name"/>
8052
+ <xsl:if test="normalize-space($name) != ''">
8053
+ <xsl:value-of select="$sep"/>
7001
8054
  </xsl:if>
8055
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8056
+ <xsl:apply-templates/>
7002
8057
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
7003
8058
 
7004
8059
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -7080,6 +8135,120 @@
7080
8135
  <xsl:apply-templates select="." mode="update_xml_step1"/>
7081
8136
  </xsl:for-each>
7082
8137
  </xsl:copy>
8138
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
8139
+ <xsl:apply-templates mode="update_xml_step1"/>
8140
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
8141
+ <xsl:copy>
8142
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
8143
+ </xsl:copy>
8144
+ </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">
8145
+
8146
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
8147
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
8148
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8149
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8150
+ <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))"/>
8151
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
8152
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8153
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8154
+ <xsl:with-param name="text" select="$text_"/>
8155
+ </xsl:call-template></text></xsl:variable>
8156
+
8157
+ <xsl:variable name="parent" select="local-name(..)"/>
8158
+
8159
+ <xsl:variable name="text2">
8160
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
8161
+ <xsl:copy-of select="."/>
8162
+ </xsl:for-each></text>
8163
+ </xsl:variable>
8164
+
8165
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
8166
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
8167
+ <xsl:variable name="text3">
8168
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
8169
+ <xsl:choose>
8170
+ <xsl:when test="self::text()">
8171
+ <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))"/>
8172
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
8173
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8174
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8175
+ <xsl:with-param name="text" select="$text_units_"/>
8176
+ </xsl:call-template></text></xsl:variable>
8177
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
8178
+ </xsl:when>
8179
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8180
+ </xsl:choose>
8181
+ </xsl:for-each></text>
8182
+ </xsl:variable>
8183
+
8184
+ <xsl:choose>
8185
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
8186
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
8187
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
8188
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
8189
+ <xsl:choose>
8190
+ <xsl:when test="self::text()">
8191
+ <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))"/>
8192
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
8193
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8194
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8195
+ <xsl:with-param name="text" select="$text_dots_"/>
8196
+ </xsl:call-template></text></xsl:variable>
8197
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
8198
+ </xsl:when>
8199
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8200
+ </xsl:choose>
8201
+ </xsl:for-each>
8202
+ </xsl:when>
8203
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
8204
+ </xsl:choose>
8205
+
8206
+ </xsl:template><xsl:template name="replace_text_tags">
8207
+ <xsl:param name="tag_open"/>
8208
+ <xsl:param name="tag_close"/>
8209
+ <xsl:param name="text"/>
8210
+ <xsl:choose>
8211
+ <xsl:when test="contains($text, $tag_open)">
8212
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
8213
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
8214
+
8215
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
8216
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
8217
+ </xsl:element>
8218
+
8219
+ <xsl:call-template name="replace_text_tags">
8220
+ <xsl:with-param name="tag_open" select="$tag_open"/>
8221
+ <xsl:with-param name="tag_close" select="$tag_close"/>
8222
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
8223
+ </xsl:call-template>
8224
+ </xsl:when>
8225
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8226
+ </xsl:choose>
8227
+ </xsl:template><xsl:template name="printEdition">
8228
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
8229
+ <xsl:text> </xsl:text>
8230
+ <xsl:choose>
8231
+ <xsl:when test="$edition_i18n != ''">
8232
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
8233
+ <xsl:call-template name="capitalize">
8234
+ <xsl:with-param name="str" select="$edition_i18n"/>
8235
+ </xsl:call-template>
8236
+ </xsl:when>
8237
+ <xsl:otherwise>
8238
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
8239
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
8240
+ <xsl:call-template name="capitalize">
8241
+ <xsl:with-param name="str">
8242
+ <xsl:call-template name="getLocalizedString">
8243
+ <xsl:with-param name="key">edition</xsl:with-param>
8244
+ </xsl:call-template>
8245
+ </xsl:with-param>
8246
+ </xsl:call-template>
8247
+ <xsl:text> </xsl:text>
8248
+ <xsl:value-of select="$edition"/>
8249
+ </xsl:if>
8250
+ </xsl:otherwise>
8251
+ </xsl:choose>
7083
8252
  </xsl:template><xsl:template name="convertDate">
7084
8253
  <xsl:param name="date"/>
7085
8254
  <xsl:param name="format" select="'short'"/>
@@ -7767,4 +8936,40 @@
7767
8936
  <xsl:value-of select="$value"/>
7768
8937
  </xsl:otherwise>
7769
8938
  </xsl:choose>
8939
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
8940
+ <xsl:param name="level">0</xsl:param>
8941
+
8942
+ <fo:block margin-left="{2*$level}mm">
8943
+ <xsl:text>
8944
+ &lt;</xsl:text>
8945
+ <xsl:value-of select="local-name()"/>
8946
+ <xsl:for-each select="@*">
8947
+ <xsl:text> </xsl:text>
8948
+ <xsl:value-of select="local-name()"/>
8949
+ <xsl:text>="</xsl:text>
8950
+ <xsl:value-of select="."/>
8951
+ <xsl:text>"</xsl:text>
8952
+ </xsl:for-each>
8953
+ <xsl:text>&gt;</xsl:text>
8954
+
8955
+ <xsl:if test="not(*)">
8956
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
8957
+ <xsl:text>&lt;/</xsl:text>
8958
+ <xsl:value-of select="local-name()"/>
8959
+ <xsl:text>&gt;</xsl:text>
8960
+ </xsl:if>
8961
+ </fo:block>
8962
+
8963
+ <xsl:if test="*">
8964
+ <fo:block>
8965
+ <xsl:apply-templates mode="print_as_xml">
8966
+ <xsl:with-param name="level" select="$level + 1"/>
8967
+ </xsl:apply-templates>
8968
+ </fo:block>
8969
+ <fo:block margin-left="{2*$level}mm">
8970
+ <xsl:text>&lt;/</xsl:text>
8971
+ <xsl:value-of select="local-name()"/>
8972
+ <xsl:text>&gt;</xsl:text>
8973
+ </fo:block>
8974
+ </xsl:if>
7770
8975
  </xsl:template></xsl:stylesheet>