metanorma-ribose 2.0.8 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,15 +41,21 @@
41
41
  <xsl:value-of select="/rsd:rsd-standard/rsd:bibdata/rsd:docidentifier[@type = 'rsd' or @type = 'Ribose']"/>
42
42
  <xsl:text>:</xsl:text>
43
43
  <xsl:value-of select="$copyright_year"/>
44
- <xsl:variable name="edition" select="normalize-space(/rsd:rsd-standard/rsd:bibdata/rsd:edition)"/>
44
+
45
+ <xsl:variable name="edition" select="normalize-space(/rsd:rsd-standard/rsd:bibdata/rsd:edition[normalize-space(@language) = ''])"/>
45
46
  <xsl:if test="$edition != ''">
46
- <xsl:variable name="title-edition">
47
- <xsl:call-template name="getTitle">
48
- <xsl:with-param name="name" select="'title-edition'"/>
47
+ <xsl:variable name="title-version">
48
+ <xsl:call-template name="capitalize">
49
+ <xsl:with-param name="str">
50
+ <xsl:call-template name="getLocalizedString">
51
+ <xsl:with-param name="key">version</xsl:with-param>
52
+ </xsl:call-template>
53
+ </xsl:with-param>
49
54
  </xsl:call-template>
50
55
  </xsl:variable>
51
- <xsl:text>, </xsl:text><xsl:value-of select="$title-edition"/><xsl:text> </xsl:text><xsl:value-of select="$edition"/>
56
+ <xsl:text>, </xsl:text><xsl:value-of select="$title-version"/><xsl:text> </xsl:text><xsl:value-of select="$edition"/>
52
57
  </xsl:if>
58
+
53
59
  </xsl:variable>
54
60
 
55
61
  <xsl:template match="/">
@@ -314,12 +320,13 @@
314
320
  <!-- background image -->
315
321
  <fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0">
316
322
  <fo:block>
317
- <fo:external-graphic src="{concat('data:image/png;base64,', normalize-space($Image-Cover-Background))}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
323
+ <!-- <fo:external-graphic src="{concat('data:image/png;base64,', normalize-space($Image-Cover-Background))}" width="{$pageWidth}mm" content-height="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/> -->
324
+ <fo:external-graphic src="{concat('data:image/png;base64,', normalize-space($Image-Cover-Background))}" height="{$pageHeight}mm" content-width="scale-to-fit" scaling="uniform" fox:alt-text="Image Front"/>
318
325
  </fo:block>
319
326
  </fo:block-container>
320
327
 
321
328
  <!-- Ribose logo -->
322
- <fo:block-container absolute-position="fixed" left="171mm" top="246mm" height="30mm" width="40mm">
329
+ <fo:block-container absolute-position="fixed" left="171mm" top="{$pageHeight - 33.4}mm" height="30mm" width="40mm"> <!-- top="246mm" -->
323
330
  <fo:block>
324
331
  <fo:instream-foreign-object content-width="32mm" fox:alt-text="Ribose Logo">
325
332
  <xsl:copy-of select="$Ribose-Logo"/>
@@ -327,7 +334,7 @@
327
334
  </fo:block>
328
335
  </fo:block-container>
329
336
 
330
- <fo:block-container absolute-position="fixed" left="0mm" top="227mm" height="41mm" display-align="after">
337
+ <fo:block-container absolute-position="fixed" left="0mm" top="{$pageHeight - 52.4}mm" height="41mm" display-align="after"> <!-- top="227mm" -->
331
338
  <fo:block font-size="10pt" line-height="1.4">
332
339
  <fo:table table-layout="fixed" width="100%">
333
340
  <fo:table-column column-width="proportional-column-width(13)"/>
@@ -386,7 +393,7 @@
386
393
  </fo:block-container>
387
394
 
388
395
  <!-- title and version -->
389
- <fo:block-container height="60mm" display-align="center">
396
+ <fo:block-container margin-top="{$pageHeight - 279.4}mm" height="60mm" display-align="center">
390
397
  <xsl:variable name="title" select="/rsd:rsd-standard/rsd:bibdata/rsd:title[@language = $lang]"/>
391
398
  <xsl:if test="string-length($title) &gt; 80">
392
399
  <xsl:attribute name="margin-right">-30mm</xsl:attribute>
@@ -614,18 +621,6 @@
614
621
  <!-- ============================= -->
615
622
  <!-- ============================= -->
616
623
 
617
- <xsl:template match="/rsd:rsd-standard/rsd:bibdata/rsd:edition">
618
- <fo:block margin-bottom="12pt">
619
- <xsl:variable name="title-edition">
620
- <xsl:call-template name="getTitle">
621
- <xsl:with-param name="name" select="'title-edition'"/>
622
- </xsl:call-template>
623
- </xsl:variable>
624
- <xsl:value-of select="$title-edition"/><xsl:text>: </xsl:text>
625
- <xsl:value-of select="."/><xsl:text> </xsl:text>
626
- </fo:block>
627
- </xsl:template>
628
-
629
624
 
630
625
  <xsl:template match="rsd:feedback-statement" priority="2">
631
626
  <fo:block-container border="1pt solid black" padding="1mm" padding-left="2mm">
@@ -783,6 +778,7 @@
783
778
 
784
779
  <xsl:template match="rsd:p" name="paragraph">
785
780
  <xsl:param name="inline" select="'false'"/>
781
+ <xsl:param name="split_keep-within-line"/>
786
782
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
787
783
  <xsl:variable name="element-name">
788
784
  <xsl:choose>
@@ -815,7 +811,9 @@
815
811
  </xsl:if>
816
812
 
817
813
  <!-- <xsl:attribute name="line-height">155%</xsl:attribute> -->
818
- <xsl:apply-templates/>
814
+ <xsl:apply-templates>
815
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
816
+ </xsl:apply-templates>
819
817
  </xsl:element>
820
818
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
821
819
  <fo:block margin-bottom="12pt">
@@ -1215,12 +1213,41 @@
1215
1213
 
1216
1214
 
1217
1215
 
1218
- <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">
1216
+ <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_">
1217
+ <xsl:for-each select="$table_widths_from_if//table">
1218
+ <xsl:copy>
1219
+ <xsl:copy-of select="@*"/>
1220
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
1221
+ </xsl:copy>
1222
+ </xsl:for-each>
1223
+ </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_">
1224
+ false
1225
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
1219
1226
  <xsl:call-template name="getLang"/>
1220
- </xsl:variable><xsl:variable name="pageWidth_">
1221
- 215.9
1227
+ </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_">
1228
+ <xsl:choose>
1229
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
1230
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
1231
+ </xsl:choose>
1232
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
1233
+ <xsl:choose>
1234
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
1235
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
1236
+ </xsl:choose>
1237
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
1238
+ <xsl:choose>
1239
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
1240
+ <xsl:otherwise>
1241
+ 215.9
1242
+ </xsl:otherwise>
1243
+ </xsl:choose>
1222
1244
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
1223
- 279.4
1245
+ <xsl:choose>
1246
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
1247
+ <xsl:otherwise>
1248
+ 279.4
1249
+ </xsl:otherwise>
1250
+ </xsl:choose>
1224
1251
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
1225
1252
  29
1226
1253
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -1230,20 +1257,7 @@
1230
1257
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1231
1258
  22
1232
1259
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1233
-
1234
- <title-edition lang="en">
1235
-
1236
- <xsl:text>Version</xsl:text>
1237
-
1238
- </title-edition>
1239
1260
 
1240
- <title-edition lang="fr">
1241
- <xsl:text>Édition </xsl:text>
1242
- </title-edition>
1243
-
1244
- <title-edition lang="ru">
1245
- <xsl:text>Издание </xsl:text>
1246
- </title-edition>
1247
1261
 
1248
1262
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
1249
1263
  <title-toc lang="en">
@@ -1322,7 +1336,7 @@
1322
1336
  </xsl:variable><xsl:variable name="bibdata">
1323
1337
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
1324
1338
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
1325
- </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">
1339
+ </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">
1326
1340
  <xsl:param name="name"/>
1327
1341
  <xsl:param name="lang"/>
1328
1342
  <xsl:variable name="lang_">
@@ -1372,7 +1386,7 @@
1372
1386
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
1373
1387
 
1374
1388
  <xsl:variable name="additional_fonts_">
1375
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
1389
+ <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']">
1376
1390
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
1377
1391
  </xsl:for-each>
1378
1392
  </xsl:variable>
@@ -1452,7 +1466,6 @@
1452
1466
 
1453
1467
 
1454
1468
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
1455
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
1456
1469
 
1457
1470
  <xsl:attribute name="space-after">12pt</xsl:attribute>
1458
1471
 
@@ -1540,6 +1553,7 @@
1540
1553
 
1541
1554
 
1542
1555
 
1556
+
1543
1557
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
1544
1558
 
1545
1559
 
@@ -1703,6 +1717,7 @@
1703
1717
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1704
1718
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1705
1719
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1720
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1706
1721
  <xsl:attribute name="display-align">center</xsl:attribute>
1707
1722
 
1708
1723
 
@@ -1724,6 +1739,7 @@
1724
1739
  <xsl:attribute name="display-align">center</xsl:attribute>
1725
1740
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1726
1741
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1742
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1727
1743
 
1728
1744
 
1729
1745
 
@@ -1815,7 +1831,8 @@
1815
1831
 
1816
1832
  <xsl:attribute name="min-height">7mm</xsl:attribute>
1817
1833
 
1818
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
1834
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
1835
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
1819
1836
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
1820
1837
 
1821
1838
 
@@ -1831,6 +1848,28 @@
1831
1848
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1832
1849
  <xsl:attribute name="color"><xsl:value-of select="$color_blue"/></xsl:attribute>
1833
1850
 
1851
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
1852
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
1853
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1854
+
1855
+
1856
+
1857
+
1858
+
1859
+
1860
+
1861
+
1862
+
1863
+
1864
+
1865
+
1866
+
1867
+
1868
+ <xsl:attribute name="font-weight">300</xsl:attribute>
1869
+ <xsl:attribute name="color">black</xsl:attribute>
1870
+
1871
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
1872
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
1834
1873
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1835
1874
 
1836
1875
 
@@ -2185,6 +2224,25 @@
2185
2224
 
2186
2225
 
2187
2226
 
2227
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
2228
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2229
+
2230
+
2231
+
2232
+
2233
+
2234
+
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+ <xsl:attribute name="font-weight">300</xsl:attribute>
2244
+ <xsl:attribute name="color">black</xsl:attribute>
2245
+
2188
2246
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
2189
2247
 
2190
2248
 
@@ -2603,13 +2661,13 @@
2603
2661
 
2604
2662
  </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">
2605
2663
  <xsl:variable name="nodes_preface_">
2606
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2664
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2607
2665
  <node id="{@id}"/>
2608
2666
  </xsl:for-each>
2609
2667
  </xsl:variable>
2610
2668
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2611
2669
 
2612
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2670
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2613
2671
  <xsl:sort select="@displayorder" data-type="number"/>
2614
2672
 
2615
2673
  <!-- process Section's title -->
@@ -2675,7 +2733,7 @@
2675
2733
  </xsl:for-each>
2676
2734
  </figures>
2677
2735
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2678
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2736
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2679
2737
  <xsl:sort select="@displayorder" data-type="number"/>
2680
2738
  <xsl:apply-templates select="."/>
2681
2739
  </xsl:for-each>
@@ -2695,22 +2753,32 @@
2695
2753
  <xsl:sort select="@displayorder" data-type="number"/>
2696
2754
  <xsl:apply-templates select="."/>
2697
2755
  </xsl:for-each>
2698
- </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">
2699
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2700
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2701
- <xsl:call-template name="replace_fo_inline">
2702
- <xsl:with-param name="text" select="$text"/>
2703
- </xsl:call-template>
2704
- </xsl:template><xsl:template name="replace_fo_inline">
2756
+ </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">
2757
+
2758
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2759
+ <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))"/>
2760
+ <xsl:call-template name="replace_fo_inline_tags">
2761
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
2762
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
2763
+ <xsl:with-param name="text" select="$text"/>
2764
+ </xsl:call-template>
2765
+
2766
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
2767
+ <xsl:param name="tag_open"/>
2768
+ <xsl:param name="tag_close"/>
2705
2769
  <xsl:param name="text"/>
2706
2770
  <xsl:choose>
2707
2771
  <xsl:when test="contains($text, $tag_open)">
2708
2772
  <xsl:value-of select="substring-before($text, $tag_open)"/>
2709
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2773
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
2710
2774
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2711
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2712
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2713
- <xsl:call-template name="replace_fo_inline">
2775
+ <fo:inline keep-together.within-line="always">
2776
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2777
+ </fo:inline>
2778
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
2779
+ <xsl:call-template name="replace_fo_inline_tags">
2780
+ <xsl:with-param name="tag_open" select="$tag_open"/>
2781
+ <xsl:with-param name="tag_close" select="$tag_close"/>
2714
2782
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2715
2783
  </xsl:call-template>
2716
2784
  </xsl:when>
@@ -2718,6 +2786,39 @@
2718
2786
  </xsl:choose>
2719
2787
  </xsl:template><xsl:template match="*[local-name()='br']">
2720
2788
  <xsl:value-of select="$linebreak"/>
2789
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
2790
+ <xsl:param name="split_keep-within-line"/>
2791
+
2792
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
2793
+ <xsl:choose>
2794
+
2795
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
2796
+ <xsl:variable name="sep">_</xsl:variable>
2797
+ <xsl:variable name="items">
2798
+ <xsl:call-template name="split">
2799
+ <xsl:with-param name="pText" select="."/>
2800
+ <xsl:with-param name="sep" select="$sep"/>
2801
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
2802
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
2803
+ </xsl:call-template>
2804
+ </xsl:variable>
2805
+ <xsl:for-each select="xalan:nodeset($items)/item">
2806
+ <xsl:choose>
2807
+ <xsl:when test=". = $sep">
2808
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
2809
+ </xsl:when>
2810
+ <xsl:otherwise>
2811
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
2812
+ </xsl:otherwise>
2813
+ </xsl:choose>
2814
+ </xsl:for-each>
2815
+ </xsl:when>
2816
+
2817
+ <xsl:otherwise>
2818
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
2819
+ </xsl:otherwise>
2820
+
2821
+ </xsl:choose>
2721
2822
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
2722
2823
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
2723
2824
  <xsl:apply-templates/>
@@ -2788,8 +2889,23 @@
2788
2889
  </xsl:call-template>
2789
2890
 
2790
2891
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
2791
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
2792
- <xsl:call-template name="add-zero-spaces-java"/>
2892
+ <xsl:choose>
2893
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
2894
+ <xsl:value-of select="."/>
2895
+ </xsl:when>
2896
+ <xsl:otherwise>
2897
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
2898
+ </xsl:otherwise>
2899
+ </xsl:choose>
2900
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
2901
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
2902
+ <!-- <xsl:copy-of select="$text"/> -->
2903
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
2904
+ <xsl:choose>
2905
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
2906
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
2907
+ </xsl:choose>
2908
+ </xsl:for-each>
2793
2909
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
2794
2910
 
2795
2911
  <xsl:variable name="table-preamble">
@@ -2799,9 +2915,14 @@
2799
2915
 
2800
2916
  <xsl:variable name="table">
2801
2917
 
2802
- <xsl:variable name="simple-table">
2803
- <xsl:call-template name="getSimpleTable"/>
2918
+ <xsl:variable name="simple-table">
2919
+ <xsl:call-template name="getSimpleTable">
2920
+ <xsl:with-param name="id" select="@id"/>
2921
+ </xsl:call-template>
2804
2922
  </xsl:variable>
2923
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
2924
+
2925
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
2805
2926
 
2806
2927
 
2807
2928
  <!-- Display table's name before table as standalone block -->
@@ -2822,7 +2943,23 @@
2822
2943
  </xsl:call-template>
2823
2944
  </xsl:if>
2824
2945
  </xsl:variable>
2825
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2946
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
2947
+
2948
+ <!-- DEBUG -->
2949
+ <xsl:if test="$table_if_debug = 'true'">
2950
+ <fo:block font-size="60%">
2951
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
2952
+ </fo:block>
2953
+ </xsl:if>
2954
+
2955
+
2956
+ <!-- <xsl:copy-of select="$colwidths"/> -->
2957
+
2958
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
2959
+ DEBUG
2960
+ colwidths=<xsl:copy-of select="$colwidths"/>
2961
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
2962
+
2826
2963
 
2827
2964
 
2828
2965
  <xsl:variable name="margin-side">
@@ -2883,9 +3020,17 @@
2883
3020
  </xsl:element>
2884
3021
  </xsl:variable>
2885
3022
 
3023
+ <xsl:if test="$isGenerateTableIF = 'true'">
3024
+ <!-- to determine start of table -->
3025
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3026
+ </xsl:if>
2886
3027
 
2887
3028
  <fo:table id="{@id}">
2888
3029
 
3030
+ <xsl:if test="$isGenerateTableIF = 'true'">
3031
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3032
+ </xsl:if>
3033
+
2889
3034
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
2890
3035
  <xsl:attribute name="{local-name()}">
2891
3036
  <xsl:value-of select="."/>
@@ -2899,31 +3044,47 @@
2899
3044
 
2900
3045
 
2901
3046
  <xsl:choose>
2902
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
2903
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
2904
- <fo:table-column column-width="{@width}"/>
2905
- </xsl:for-each>
3047
+ <xsl:when test="$isGenerateTableIF = 'true'">
3048
+ <!-- generate IF for table widths -->
3049
+ <!-- example:
3050
+ <tr>
3051
+ <td valign="top" align="left" id="tab-symdu_1_1">
3052
+ <p>Symbol</p>
3053
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3054
+ </td>
3055
+ <td valign="top" align="left" id="tab-symdu_1_2">
3056
+ <p>Description</p>
3057
+ <word id="tab-symdu_1_2_word_1">Description</word>
3058
+ </td>
3059
+ </tr>
3060
+ -->
3061
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3062
+
2906
3063
  </xsl:when>
2907
3064
  <xsl:otherwise>
2908
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
2909
- <xsl:choose>
2910
- <xsl:when test=". = 1 or . = 0">
2911
- <fo:table-column column-width="proportional-column-width(2)"/>
2912
- </xsl:when>
2913
- <xsl:otherwise>
2914
- <fo:table-column column-width="proportional-column-width({.})"/>
2915
- </xsl:otherwise>
2916
- </xsl:choose>
2917
- </xsl:for-each>
2918
- </xsl:otherwise>
2919
- </xsl:choose>
2920
3065
 
2921
- <xsl:choose>
2922
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
2923
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2924
- </xsl:when>
2925
- <xsl:otherwise>
2926
- <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 -->
3066
+ <xsl:choose>
3067
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3068
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3069
+ <fo:table-column column-width="{@width}"/>
3070
+ </xsl:for-each>
3071
+ </xsl:when>
3072
+ <xsl:otherwise>
3073
+ <xsl:call-template name="insertTableColumnWidth">
3074
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3075
+ </xsl:call-template>
3076
+ </xsl:otherwise>
3077
+ </xsl:choose>
3078
+
3079
+ <xsl:choose>
3080
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3081
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3082
+ </xsl:when>
3083
+ <xsl:otherwise>
3084
+ <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 -->
3085
+ </xsl:otherwise>
3086
+ </xsl:choose>
3087
+
2927
3088
  </xsl:otherwise>
2928
3089
  </xsl:choose>
2929
3090
 
@@ -3026,11 +3187,22 @@
3026
3187
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3027
3188
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3028
3189
  </xsl:template><xsl:template name="calculate-column-widths">
3190
+ <xsl:param name="table"/>
3191
+ <xsl:param name="cols-count"/>
3192
+
3193
+ <xsl:call-template name="calculate-column-widths-proportional">
3194
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3195
+ <xsl:with-param name="table" select="$table"/>
3196
+ </xsl:call-template>
3197
+
3198
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3029
3199
  <xsl:param name="table"/>
3030
3200
  <xsl:param name="cols-count"/>
3031
3201
  <xsl:param name="curr-col" select="1"/>
3032
3202
  <xsl:param name="width" select="0"/>
3033
3203
 
3204
+ <!-- table=<xsl:copy-of select="$table"/> -->
3205
+
3034
3206
  <xsl:if test="$curr-col &lt;= $cols-count">
3035
3207
  <xsl:variable name="widths">
3036
3208
  <xsl:choose>
@@ -3068,16 +3240,22 @@
3068
3240
  </xsl:for-each>
3069
3241
  </xsl:when>
3070
3242
  <xsl:otherwise>
3071
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3243
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3244
+
3245
+ <!-- <table><xsl:copy-of select="$table"/></table>
3246
+ -->
3247
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3072
3248
  <xsl:variable name="td_text">
3073
3249
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3074
3250
  </xsl:variable>
3251
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3075
3252
  <xsl:variable name="words">
3076
3253
  <xsl:variable name="string_with_added_zerospaces">
3077
3254
  <xsl:call-template name="add-zero-spaces-java">
3078
3255
  <xsl:with-param name="text" select="$td_text"/>
3079
3256
  </xsl:call-template>
3080
3257
  </xsl:variable>
3258
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3081
3259
  <xsl:call-template name="tokenize">
3082
3260
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3083
3261
  <!-- 2009 thinspace -->
@@ -3085,11 +3263,13 @@
3085
3263
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3086
3264
  </xsl:call-template>
3087
3265
  </xsl:variable>
3266
+ <!-- words=<xsl:copy-of select="$words"/> -->
3088
3267
  <xsl:variable name="max_length">
3089
3268
  <xsl:call-template name="max_length">
3090
3269
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3091
3270
  </xsl:call-template>
3092
3271
  </xsl:variable>
3272
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3093
3273
  <width>
3094
3274
  <xsl:variable name="divider">
3095
3275
  <xsl:choose>
@@ -3108,6 +3288,8 @@
3108
3288
  </xsl:choose>
3109
3289
  </xsl:variable>
3110
3290
 
3291
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3292
+
3111
3293
  <column>
3112
3294
  <xsl:for-each select="xalan:nodeset($widths)//width">
3113
3295
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3116,29 +3298,271 @@
3116
3298
  </xsl:if>
3117
3299
  </xsl:for-each>
3118
3300
  </column>
3119
- <xsl:call-template name="calculate-column-widths">
3301
+ <xsl:call-template name="calculate-column-widths-proportional">
3120
3302
  <xsl:with-param name="cols-count" select="$cols-count"/>
3121
3303
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3122
3304
  <xsl:with-param name="table" select="$table"/>
3123
3305
  </xsl:call-template>
3124
3306
  </xsl:if>
3307
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
3308
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3309
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3310
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3311
+
3312
+ <!-- if all capitals english letters or digits -->
3313
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
3314
+ <xsl:call-template name="repeat">
3315
+ <xsl:with-param name="char" select="'X'"/>
3316
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
3317
+ </xsl:call-template>
3318
+ </xsl:if>
3125
3319
  </xsl:template><xsl:template match="text()" mode="td_text">
3126
3320
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3127
3321
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3128
3322
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3129
3323
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3130
3324
  <xsl:value-of select="@target"/>
3131
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3132
- <xsl:variable name="mathml">
3133
- <xsl:for-each select="*">
3134
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3135
- <xsl:copy-of select="."/>
3136
- </xsl:if>
3325
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
3326
+ <xsl:if test="$isGenerateTableIF = 'false'">
3327
+ <xsl:variable name="mathml_">
3328
+ <xsl:for-each select="*">
3329
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3330
+ <xsl:copy-of select="."/>
3331
+ </xsl:if>
3332
+ </xsl:for-each>
3333
+ </xsl:variable>
3334
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
3335
+
3336
+ <xsl:variable name="math_text">
3337
+ <xsl:value-of select="normalize-space($mathml)"/>
3338
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
3339
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
3340
+ </xsl:variable>
3341
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3342
+ </xsl:if>
3343
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
3344
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
3345
+
3346
+ <!-- via intermediate format -->
3347
+
3348
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
3349
+
3350
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
3351
+
3352
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
3353
+
3354
+ <!-- get current table id -->
3355
+ <xsl:variable name="table_id" select="@id"/>
3356
+ <!-- find table by id in the file 'table_widths' -->
3357
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
3358
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
3359
+
3360
+ <!-- table='<xsl:copy-of select="$table"/>' -->
3361
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
3362
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
3363
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
3364
+
3365
+ <xsl:variable name="table_with_cell_widths_">
3366
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
3367
+ </xsl:variable>
3368
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
3369
+
3370
+ <!-- <xsl:if test="$table_if_debug = 'true'">
3371
+ <xsl:copy-of select="$table_with_cell_widths"/>
3372
+ </xsl:if> -->
3373
+
3374
+
3375
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
3376
+
3377
+ <xsl:variable name="column_widths_">
3378
+ <!-- iteration of columns -->
3379
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
3380
+ <xsl:variable name="pos" select="position()"/>
3381
+ <column>
3382
+ <xsl:attribute name="width_max">
3383
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
3384
+ <xsl:sort select="." data-type="number" order="descending"/>
3385
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3386
+ </xsl:for-each>
3387
+ </xsl:attribute>
3388
+ <xsl:attribute name="width_min">
3389
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
3390
+ <xsl:sort select="." data-type="number" order="descending"/>
3391
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3392
+ </xsl:for-each>
3393
+ </xsl:attribute>
3394
+ </column>
3137
3395
  </xsl:for-each>
3138
3396
  </xsl:variable>
3397
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
3398
+
3399
+ <!-- <column_widths>
3400
+ <xsl:copy-of select="$column_widths"/>
3401
+ </column_widths> -->
3402
+
3403
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
3404
+ <xsl:variable name="table_widths_">
3405
+ <table>
3406
+ <xsl:attribute name="width_max">
3407
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
3408
+ </xsl:attribute>
3409
+ <xsl:attribute name="width_min">
3410
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
3411
+ </xsl:attribute>
3412
+ </table>
3413
+ </xsl:variable>
3414
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
3415
+
3416
+ <xsl:variable name="page_width">
3417
+ <xsl:choose>
3418
+ <xsl:when test="$parent_table_page-width != ''">
3419
+ <xsl:value-of select="$parent_table_page-width"/>
3420
+ </xsl:when>
3421
+ <xsl:otherwise>
3422
+ <xsl:value-of select="@page-width"/>
3423
+ </xsl:otherwise>
3424
+ </xsl:choose>
3425
+ </xsl:variable>
3426
+
3427
+ <xsl:if test="$table_if_debug = 'true'">
3428
+ <table_width>
3429
+ <xsl:copy-of select="$table_widths"/>
3430
+ </table_width>
3431
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
3432
+ </xsl:if>
3433
+
3434
+
3435
+ <!-- There are three cases: -->
3436
+ <xsl:choose>
3437
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
3438
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
3439
+ <!-- call old algorithm -->
3440
+ <case1/>
3441
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
3442
+ <xsl:call-template name="calculate-column-widths-proportional">
3443
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3444
+ <xsl:with-param name="table" select="$table"/>
3445
+ </xsl:call-template> -->
3446
+ </xsl:when>
3447
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
3448
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
3449
+ <case2/>
3450
+ <autolayout/>
3451
+ <xsl:for-each select="$column_widths/column/@width_max">
3452
+ <column divider="100"><xsl:value-of select="."/></column>
3453
+ </xsl:for-each>
3454
+ </xsl:when>
3455
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
3456
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
3457
+ Lets also call D the difference between maximum and minimum width of the table.
3458
+ For each column, let d be the difference between maximum and minimum width of that column.
3459
+ Now set the column's width to the minimum width plus d times W over D.
3460
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
3461
+ <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)">
3462
+ <!-- difference between the available space and the minimum table width -->
3463
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
3464
+ <W><xsl:value-of select="$W"/></W>
3465
+ <!-- difference between maximum and minimum width of the table -->
3466
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
3467
+ <D><xsl:value-of select="$D"/></D>
3468
+ <case3/>
3469
+ <autolayout/>
3470
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
3471
+ <split_keep-within-line>true</split_keep-within-line>
3472
+ </xsl:if>
3473
+ <xsl:for-each select="$column_widths/column">
3474
+ <!-- difference between maximum and minimum width of that column. -->
3475
+ <xsl:variable name="d" select="@width_max - @width_min"/>
3476
+ <d><xsl:value-of select="$d"/></d>
3477
+ <width_min><xsl:value-of select="@width_min"/></width_min>
3478
+ <e><xsl:value-of select="$d * $W div $D"/></e>
3479
+ <!-- set the column's width to the minimum width plus d times W over D. -->
3480
+ <column divider="100">
3481
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
3482
+ </column>
3483
+ </xsl:for-each>
3484
+
3485
+ </xsl:when>
3486
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
3487
+ </xsl:choose>
3488
+
3489
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
3490
+
3491
+ <!-- if nested 'dl' or 'table' -->
3492
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
3493
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
3494
+
3495
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
3496
+
3497
+ <xsl:variable name="parent_table_page-width_">
3498
+ <xsl:if test="$parent_table_id != ''">
3499
+ <!-- determine column number in the parent table -->
3500
+ <xsl:variable name="parent_table_column_number">
3501
+ <xsl:choose>
3502
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
3503
+ <xsl:otherwise> <!-- parent is table -->
3504
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
3505
+ </xsl:otherwise>
3506
+ </xsl:choose>
3507
+ </xsl:variable>
3508
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
3509
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
3510
+ </xsl:if>
3511
+ </xsl:variable>
3512
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
3513
+
3514
+ <!-- get current table id -->
3515
+ <xsl:variable name="table_id" select="@id"/>
3516
+
3517
+ <xsl:choose>
3518
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
3519
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
3520
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
3521
+ </xsl:when>
3522
+ <xsl:otherwise>
3523
+ <!-- recalculate columns width based on parent table width -->
3524
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
3525
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
3526
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
3527
+ </xsl:call-template>
3528
+ </xsl:for-each>
3529
+ </xsl:otherwise>
3530
+ </xsl:choose>
3139
3531
 
3140
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3141
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3532
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
3533
+ <xsl:copy>
3534
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
3535
+ </xsl:copy>
3536
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
3537
+ <xsl:copy>
3538
+ <xsl:copy-of select="@*"/>
3539
+
3540
+ <!-- The maximum width is given by the widest line. -->
3541
+ <xsl:attribute name="width_max">
3542
+ <xsl:for-each select="p_len">
3543
+ <xsl:sort select="." data-type="number" order="descending"/>
3544
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3545
+ </xsl:for-each>
3546
+ </xsl:attribute>
3547
+
3548
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
3549
+ <xsl:variable name="width_min">
3550
+ <xsl:for-each select="word_len">
3551
+ <xsl:sort select="." data-type="number" order="descending"/>
3552
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3553
+ </xsl:for-each>
3554
+ </xsl:variable>
3555
+ <xsl:attribute name="width_min">
3556
+ <xsl:value-of select="$width_min"/>
3557
+ </xsl:attribute>
3558
+
3559
+ <xsl:if test="$width_min = 0">
3560
+ <xsl:attribute name="width_min">1</xsl:attribute>
3561
+ </xsl:if>
3562
+
3563
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
3564
+
3565
+ </xsl:copy>
3142
3566
  </xsl:template><xsl:template match="*[local-name()='thead']">
3143
3567
  <xsl:param name="cols-count"/>
3144
3568
  <fo:table-header>
@@ -3223,16 +3647,10 @@
3223
3647
  </xsl:for-each>
3224
3648
  </xsl:when>
3225
3649
  <xsl:otherwise>
3226
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3227
- <xsl:choose>
3228
- <xsl:when test=". = 1 or . = 0">
3229
- <fo:table-column column-width="proportional-column-width(2)"/>
3230
- </xsl:when>
3231
- <xsl:otherwise>
3232
- <fo:table-column column-width="proportional-column-width({.})"/>
3233
- </xsl:otherwise>
3234
- </xsl:choose>
3235
- </xsl:for-each>
3650
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
3651
+ <xsl:call-template name="insertTableColumnWidth">
3652
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3653
+ </xsl:call-template>
3236
3654
  </xsl:otherwise>
3237
3655
  </xsl:choose>
3238
3656
 
@@ -3309,15 +3727,61 @@
3309
3727
 
3310
3728
  </fo:table-body>
3311
3729
 
3312
- </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3313
- <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3730
+ </xsl:template><xsl:template match="/" mode="process_table-if">
3731
+ <xsl:param name="table_or_dl">table</xsl:param>
3732
+ <xsl:apply-templates mode="process_table-if">
3733
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
3734
+ </xsl:apply-templates>
3735
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
3736
+ <xsl:param name="table_or_dl">table</xsl:param>
3314
3737
 
3315
-
3316
-
3317
-
3738
+ <fo:table-body>
3739
+ <xsl:for-each select="*[local-name() = 'tr']">
3740
+ <xsl:variable name="col_count" select="count(*)"/>
3318
3741
 
3742
+ <!-- iteration for each tr/td -->
3743
+
3744
+ <xsl:choose>
3745
+ <xsl:when test="$table_or_dl = 'table'">
3746
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
3747
+ <fo:table-row number-columns-spanned="{$col_count}">
3748
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
3749
+ <xsl:call-template name="td"/>
3750
+ </fo:table-row>
3751
+ </xsl:for-each>
3752
+ </xsl:when>
3753
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
3754
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
3755
+ <xsl:variable name="is_dt" select="position() = 1"/>
3756
+
3757
+ <xsl:for-each select="*">
3758
+ <!-- <test><xsl:copy-of select="."/></test> -->
3759
+ <fo:table-row number-columns-spanned="{$col_count}">
3760
+ <xsl:choose>
3761
+ <xsl:when test="$is_dt">
3762
+ <xsl:call-template name="insert_dt_cell"/>
3763
+ </xsl:when>
3764
+ <xsl:otherwise>
3765
+ <xsl:call-template name="insert_dd_cell"/>
3766
+ </xsl:otherwise>
3767
+ </xsl:choose>
3768
+ </fo:table-row>
3769
+ </xsl:for-each>
3770
+ </xsl:for-each>
3771
+ </xsl:otherwise>
3772
+ </xsl:choose>
3773
+
3774
+ </xsl:for-each>
3775
+ </fo:table-body>
3776
+ </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3777
+ <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3778
+
3779
+
3780
+
3781
+
3782
+
3783
+
3319
3784
 
3320
-
3321
3785
  <xsl:call-template name="setTableRowAttributes"/>
3322
3786
 
3323
3787
  <xsl:apply-templates/>
@@ -3400,7 +3864,7 @@
3400
3864
  </xsl:choose>
3401
3865
  </xsl:attribute>
3402
3866
  </xsl:if>
3403
- </xsl:template><xsl:template match="*[local-name()='td']">
3867
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
3404
3868
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
3405
3869
  <xsl:call-template name="setTextAlignment">
3406
3870
  <xsl:with-param name="default">left</xsl:with-param>
@@ -3434,11 +3898,24 @@
3434
3898
 
3435
3899
  <xsl:call-template name="setTableCellAttributes"/>
3436
3900
 
3901
+ <xsl:if test="$isGenerateTableIF = 'true'">
3902
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
3903
+ <xsl:attribute name="text-align">left</xsl:attribute>
3904
+ </xsl:if>
3905
+
3437
3906
  <fo:block>
3438
3907
 
3908
+ <xsl:if test="$isGenerateTableIF = 'true'">
3909
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
3910
+ </xsl:if>
3911
+
3912
+
3439
3913
 
3440
3914
 
3441
3915
  <xsl:apply-templates/>
3916
+
3917
+ <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"/> -->
3918
+
3442
3919
  </fo:block>
3443
3920
  </fo:table-cell>
3444
3921
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -3635,9 +4112,9 @@
3635
4112
  <!-- current hierarchy is 'figure' element -->
3636
4113
  <xsl:variable name="following_dl_colwidths">
3637
4114
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3638
- <xsl:variable name="html-table">
3639
- <xsl:variable name="doc_ns">
3640
-
4115
+ <xsl:variable name="simple-table">
4116
+ <!-- <xsl:variable name="doc_ns">
4117
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3641
4118
  </xsl:variable>
3642
4119
  <xsl:variable name="ns">
3643
4120
  <xsl:choose>
@@ -3648,7 +4125,7 @@
3648
4125
  <xsl:value-of select="substring-before(name(/*), '-')"/>
3649
4126
  </xsl:otherwise>
3650
4127
  </xsl:choose>
3651
- </xsl:variable>
4128
+ </xsl:variable> -->
3652
4129
 
3653
4130
  <xsl:for-each select="*[local-name() = 'dl'][1]">
3654
4131
  <tbody>
@@ -3659,7 +4136,7 @@
3659
4136
 
3660
4137
  <xsl:call-template name="calculate-column-widths">
3661
4138
  <xsl:with-param name="cols-count" select="2"/>
3662
- <xsl:with-param name="table" select="$html-table"/>
4139
+ <xsl:with-param name="table" select="$simple-table"/>
3663
4140
  </xsl:call-template>
3664
4141
 
3665
4142
  </xsl:if>
@@ -3778,8 +4255,10 @@
3778
4255
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
3779
4256
  </xsl:variable>
3780
4257
 
4258
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
4259
+
3781
4260
  <xsl:choose>
3782
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
4261
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
3783
4262
 
3784
4263
  <fo:block margin-bottom="12pt" text-align="left">
3785
4264
 
@@ -3794,7 +4273,7 @@
3794
4273
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3795
4274
  </fo:block>
3796
4275
 
3797
- </xsl:when>
4276
+ </xsl:when> <!-- END: only one component -->
3798
4277
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3799
4278
  <fo:block margin-bottom="12pt" text-align="left">
3800
4279
 
@@ -3808,8 +4287,8 @@
3808
4287
  </xsl:variable>
3809
4288
  <xsl:value-of select="$title-where"/>
3810
4289
  </fo:block>
3811
- </xsl:when>
3812
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
4290
+ </xsl:when> <!-- END: a few components -->
4291
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
3813
4292
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
3814
4293
 
3815
4294
 
@@ -3825,22 +4304,41 @@
3825
4304
  </xsl:variable>
3826
4305
  <xsl:value-of select="$title-key"/>
3827
4306
  </fo:block>
3828
- </xsl:when>
4307
+ </xsl:when> <!-- END: definition list in a figure -->
3829
4308
  </xsl:choose>
3830
4309
 
3831
4310
  <!-- a few components -->
3832
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
4311
+ <xsl:if test="$onlyOneComponent = 'false'">
3833
4312
  <fo:block>
3834
4313
 
3835
4314
 
3836
4315
 
3837
4316
 
4317
+
4318
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
4319
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4320
+ </xsl:if>
4321
+
3838
4322
  <fo:block>
3839
4323
 
3840
4324
 
3841
4325
 
3842
4326
 
4327
+ <xsl:apply-templates select="*[local-name() = 'name']">
4328
+ <xsl:with-param name="process">true</xsl:with-param>
4329
+ </xsl:apply-templates>
4330
+
4331
+ <xsl:if test="$isGenerateTableIF = 'true'">
4332
+ <!-- to determine start of table -->
4333
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
4334
+ </xsl:if>
4335
+
3843
4336
  <fo:table width="95%" table-layout="fixed">
4337
+
4338
+ <xsl:if test="$isGenerateTableIF = 'true'">
4339
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
4340
+ </xsl:if>
4341
+
3844
4342
 
3845
4343
  <xsl:choose>
3846
4344
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -3849,61 +4347,178 @@
3849
4347
 
3850
4348
  </xsl:when>
3851
4349
  </xsl:choose>
3852
- <!-- create virtual html table for dl/[dt and dd] -->
3853
- <xsl:variable name="html-table">
3854
- <xsl:variable name="doc_ns">
4350
+
4351
+
4352
+
4353
+ <xsl:choose>
4354
+ <xsl:when test="$isGenerateTableIF = 'true'">
4355
+ <!-- generate IF for table widths -->
4356
+ <!-- example:
4357
+ <tr>
4358
+ <td valign="top" align="left" id="tab-symdu_1_1">
4359
+ <p>Symbol</p>
4360
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
4361
+ </td>
4362
+ <td valign="top" align="left" id="tab-symdu_1_2">
4363
+ <p>Description</p>
4364
+ <word id="tab-symdu_1_2_word_1">Description</word>
4365
+ </td>
4366
+ </tr>
4367
+ -->
3855
4368
 
3856
- </xsl:variable>
3857
- <xsl:variable name="ns">
3858
- <xsl:choose>
3859
- <xsl:when test="normalize-space($doc_ns) != ''">
3860
- <xsl:value-of select="normalize-space($doc_ns)"/>
3861
- </xsl:when>
3862
- <xsl:otherwise>
3863
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3864
- </xsl:otherwise>
3865
- </xsl:choose>
3866
- </xsl:variable>
3867
- <tbody>
3868
- <xsl:apply-templates mode="dl"/>
3869
- </tbody>
3870
- </xsl:variable>
3871
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
3872
- <xsl:variable name="colwidths">
3873
- <xsl:call-template name="calculate-column-widths">
3874
- <xsl:with-param name="cols-count" select="2"/>
3875
- <xsl:with-param name="table" select="$html-table"/>
3876
- </xsl:call-template>
3877
- </xsl:variable>
3878
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3879
- <xsl:variable name="maxlength_dt">
3880
- <xsl:call-template name="getMaxLength_dt"/>
3881
- </xsl:variable>
3882
- <xsl:call-template name="setColumnWidth_dl">
3883
- <xsl:with-param name="colwidths" select="$colwidths"/>
3884
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3885
- </xsl:call-template>
3886
- <fo:table-body>
3887
- <xsl:apply-templates>
3888
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
3889
- </xsl:apply-templates>
3890
- </fo:table-body>
4369
+ <!-- create virtual html table for dl/[dt and dd] -->
4370
+ <xsl:variable name="simple-table">
4371
+
4372
+ <xsl:variable name="dl_table">
4373
+ <tbody>
4374
+ <xsl:apply-templates mode="dl_if">
4375
+ <xsl:with-param name="id" select="@id"/>
4376
+ </xsl:apply-templates>
4377
+ </tbody>
4378
+ </xsl:variable>
4379
+
4380
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
4381
+
4382
+ <!-- Step: replace <br/> to <p>...</p> -->
4383
+ <xsl:variable name="table_without_br">
4384
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
4385
+ </xsl:variable>
4386
+
4387
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
4388
+
4389
+ <!-- Step: add id to each cell -->
4390
+ <!-- add <word>...</word> for each word, image, math -->
4391
+ <xsl:variable name="simple-table-id">
4392
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
4393
+ <xsl:with-param name="id" select="@id"/>
4394
+ </xsl:apply-templates>
4395
+ </xsl:variable>
4396
+
4397
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
4398
+
4399
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
4400
+
4401
+ </xsl:variable>
4402
+
4403
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
4404
+
4405
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
4406
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
4407
+ </xsl:apply-templates>
4408
+
4409
+ </xsl:when>
4410
+ <xsl:otherwise>
4411
+
4412
+ <xsl:variable name="simple-table">
4413
+
4414
+ <xsl:variable name="dl_table">
4415
+ <tbody>
4416
+ <xsl:apply-templates mode="dl">
4417
+ <xsl:with-param name="id" select="@id"/>
4418
+ </xsl:apply-templates>
4419
+ </tbody>
4420
+ </xsl:variable>
4421
+
4422
+ <xsl:copy-of select="$dl_table"/>
4423
+ </xsl:variable>
4424
+
4425
+ <xsl:variable name="colwidths">
4426
+ <xsl:call-template name="calculate-column-widths">
4427
+ <xsl:with-param name="cols-count" select="2"/>
4428
+ <xsl:with-param name="table" select="$simple-table"/>
4429
+ </xsl:call-template>
4430
+ </xsl:variable>
4431
+
4432
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
4433
+ DEBUG
4434
+ colwidths=<xsl:copy-of select="$colwidths"/>
4435
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
4436
+
4437
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4438
+
4439
+ <xsl:variable name="maxlength_dt">
4440
+ <xsl:call-template name="getMaxLength_dt"/>
4441
+ </xsl:variable>
4442
+
4443
+ <xsl:variable name="isContainsKeepTogetherTag_">
4444
+ false
4445
+ </xsl:variable>
4446
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4447
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4448
+
4449
+
4450
+ <xsl:call-template name="setColumnWidth_dl">
4451
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4452
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4453
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4454
+ </xsl:call-template>
4455
+
4456
+ <fo:table-body>
4457
+
4458
+ <!-- DEBUG -->
4459
+ <xsl:if test="$table_if_debug = 'true'">
4460
+ <fo:table-row>
4461
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
4462
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
4463
+ </fo:table-cell>
4464
+ </fo:table-row>
4465
+ </xsl:if>
4466
+
4467
+ <xsl:apply-templates>
4468
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4469
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
4470
+ </xsl:apply-templates>
4471
+
4472
+ </fo:table-body>
4473
+ </xsl:otherwise>
4474
+ </xsl:choose>
3891
4475
  </fo:table>
3892
4476
  </fo:block>
3893
4477
  </fo:block>
3894
- </xsl:if>
4478
+ </xsl:if> <!-- END: a few components -->
3895
4479
  </fo:block-container>
3896
4480
  </fo:block-container>
4481
+
4482
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
4483
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
4484
+ </xsl:if>
4485
+
4486
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
4487
+ <xsl:param name="process">false</xsl:param>
4488
+ <xsl:if test="$process = 'true'">
4489
+ <fo:block xsl:use-attribute-sets="dl-name-style">
4490
+ <xsl:apply-templates/>
4491
+ </fo:block>
4492
+ </xsl:if>
3897
4493
  </xsl:template><xsl:template name="setColumnWidth_dl">
3898
4494
  <xsl:param name="colwidths"/>
3899
4495
  <xsl:param name="maxlength_dt"/>
4496
+ <xsl:param name="isContainsKeepTogetherTag"/>
4497
+
4498
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
4499
+
3900
4500
  <xsl:choose>
4501
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
4502
+ <xsl:call-template name="insertTableColumnWidth">
4503
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4504
+ </xsl:call-template>
4505
+ </xsl:when>
3901
4506
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
3902
4507
  <fo:table-column column-width="50%"/>
3903
4508
  <fo:table-column column-width="50%"/>
3904
4509
  </xsl:when>
3905
4510
  <xsl:otherwise>
3906
4511
  <xsl:choose>
4512
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
4513
+ <xsl:call-template name="insertTableColumnWidth">
4514
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4515
+ </xsl:call-template>
4516
+ </xsl:when>
4517
+ <xsl:when test="$isContainsKeepTogetherTag">
4518
+ <xsl:call-template name="insertTableColumnWidth">
4519
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4520
+ </xsl:call-template>
4521
+ </xsl:when>
3907
4522
  <!-- to set width check most wide chars like `W` -->
3908
4523
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
3909
4524
  <fo:table-column column-width="7%"/>
@@ -3934,20 +4549,31 @@
3934
4549
  <fo:table-column column-width="60%"/>
3935
4550
  </xsl:when>
3936
4551
  <xsl:otherwise>
3937
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3938
- <xsl:choose>
3939
- <xsl:when test=". = 1 or . = 0">
3940
- <fo:table-column column-width="proportional-column-width(2)"/>
3941
- </xsl:when>
3942
- <xsl:otherwise>
3943
- <fo:table-column column-width="proportional-column-width({.})"/>
3944
- </xsl:otherwise>
3945
- </xsl:choose>
3946
- </xsl:for-each>
4552
+ <xsl:call-template name="insertTableColumnWidth">
4553
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4554
+ </xsl:call-template>
3947
4555
  </xsl:otherwise>
3948
4556
  </xsl:choose>
3949
4557
  </xsl:otherwise>
3950
4558
  </xsl:choose>
4559
+ </xsl:template><xsl:template name="insertTableColumnWidth">
4560
+ <xsl:param name="colwidths"/>
4561
+
4562
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
4563
+ <xsl:choose>
4564
+ <xsl:when test=". = 1 or . = 0">
4565
+ <fo:table-column column-width="proportional-column-width(2)"/>
4566
+ </xsl:when>
4567
+ <xsl:otherwise>
4568
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
4569
+ <xsl:variable name="divider">
4570
+ <xsl:value-of select="@divider"/>
4571
+ <xsl:if test="not(@divider)">1</xsl:if>
4572
+ </xsl:variable>
4573
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4574
+ </xsl:otherwise>
4575
+ </xsl:choose>
4576
+ </xsl:for-each>
3951
4577
  </xsl:template><xsl:template name="getMaxLength_dt">
3952
4578
  <xsl:variable name="lengths">
3953
4579
  <xsl:for-each select="*[local-name()='dt']">
@@ -3971,7 +4597,6 @@
3971
4597
  <xsl:value-of select="$maxLength"/>
3972
4598
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
3973
4599
  <xsl:param name="key_iso"/>
3974
-
3975
4600
  <!-- <tr>
3976
4601
  <td>NOTE</td>
3977
4602
  <td>
@@ -3979,27 +4604,47 @@
3979
4604
  </td>
3980
4605
  </tr>
3981
4606
  -->
3982
- <fo:table-row>
4607
+ <!-- OLD Variant -->
4608
+ <!-- <fo:table-row>
3983
4609
  <fo:table-cell>
3984
4610
  <fo:block margin-top="6pt">
3985
4611
  <xsl:if test="normalize-space($key_iso) = 'true'">
3986
4612
  <xsl:attribute name="margin-top">0</xsl:attribute>
3987
4613
  </xsl:if>
3988
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4614
+ <xsl:apply-templates select="*[local-name() = 'name']" />
3989
4615
  </fo:block>
3990
4616
  </fo:table-cell>
3991
4617
  <fo:table-cell>
3992
4618
  <fo:block>
3993
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4619
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4620
+ </fo:block>
4621
+ </fo:table-cell>
4622
+ </fo:table-row> -->
4623
+ <!-- <tr>
4624
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4625
+ </tr>
4626
+ -->
4627
+ <fo:table-row>
4628
+ <fo:table-cell number-columns-spanned="2">
4629
+ <fo:block>
4630
+ <xsl:call-template name="note"/>
3994
4631
  </fo:block>
3995
4632
  </fo:table-cell>
3996
4633
  </fo:table-row>
3997
4634
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
4635
+ <xsl:param name="id"/>
4636
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
3998
4637
  <tr>
3999
4638
  <td>
4639
+ <xsl:attribute name="id">
4640
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
4641
+ </xsl:attribute>
4000
4642
  <xsl:apply-templates/>
4001
4643
  </td>
4002
4644
  <td>
4645
+ <xsl:attribute name="id">
4646
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
4647
+ </xsl:attribute>
4003
4648
 
4004
4649
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4005
4650
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4010,47 +4655,129 @@
4010
4655
 
4011
4656
  </xsl:template><xsl:template match="*[local-name()='dt']">
4012
4657
  <xsl:param name="key_iso"/>
4658
+ <xsl:param name="split_keep-within-line"/>
4013
4659
 
4014
4660
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4015
- <fo:table-cell>
4661
+ <xsl:call-template name="insert_dt_cell">
4662
+ <xsl:with-param name="key_iso" select="$key_iso"/>
4663
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4664
+ </xsl:call-template>
4665
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
4666
+ <xsl:call-template name="insert_dd_cell">
4667
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4668
+ </xsl:call-template>
4669
+ </xsl:for-each>
4670
+ </fo:table-row>
4671
+ </xsl:template><xsl:template name="insert_dt_cell">
4672
+ <xsl:param name="key_iso"/>
4673
+ <xsl:param name="split_keep-within-line"/>
4674
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
4675
+
4676
+ <xsl:if test="$isGenerateTableIF = 'true'">
4677
+ <!-- border is mandatory, to calculate real width -->
4678
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4679
+ <xsl:attribute name="text-align">left</xsl:attribute>
4680
+ </xsl:if>
4681
+
4682
+
4683
+ <fo:block xsl:use-attribute-sets="dt-block-style">
4684
+ <xsl:copy-of select="@id"/>
4685
+
4686
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4687
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4688
+ </xsl:if>
4689
+
4690
+
4691
+
4692
+ <xsl:apply-templates>
4693
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4694
+ </xsl:apply-templates>
4695
+
4696
+ <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"/> -->
4697
+
4698
+ </fo:block>
4699
+ </fo:table-cell>
4700
+ </xsl:template><xsl:template name="insert_dd_cell">
4701
+ <xsl:param name="split_keep-within-line"/>
4702
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
4703
+
4704
+ <xsl:if test="$isGenerateTableIF = 'true'">
4705
+ <!-- border is mandatory, to calculate real width -->
4706
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4707
+ </xsl:if>
4708
+
4709
+ <fo:block>
4710
+
4711
+ <xsl:if test="$isGenerateTableIF = 'true'">
4712
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4713
+ </xsl:if>
4714
+
4016
4715
 
4017
- <fo:block xsl:use-attribute-sets="dt-style">
4018
- <xsl:copy-of select="@id"/>
4019
-
4020
- <xsl:if test="normalize-space($key_iso) = 'true'">
4021
- <xsl:attribute name="margin-top">0</xsl:attribute>
4022
- </xsl:if>
4023
-
4024
-
4025
-
4026
- <xsl:apply-templates/>
4027
- </fo:block>
4028
- </fo:table-cell>
4029
- <fo:table-cell>
4030
- <fo:block>
4031
-
4032
4716
 
4033
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4034
- <xsl:with-param name="process">true</xsl:with-param>
4035
- </xsl:apply-templates>
4036
- </fo:block>
4037
- </fo:table-cell>
4038
- </fo:table-row>
4717
+ <xsl:choose>
4718
+ <xsl:when test="$isGenerateTableIF = 'true'">
4719
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
4720
+ <xsl:with-param name="process">true</xsl:with-param>
4721
+ </xsl:apply-templates>
4722
+ </xsl:when>
4723
+ <xsl:otherwise>
4724
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
4725
+ <xsl:with-param name="process">true</xsl:with-param>
4726
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4727
+ </xsl:apply-templates>
4728
+ </xsl:otherwise>
4729
+
4730
+ </xsl:choose>
4731
+
4732
+ <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"/> -->
4733
+
4734
+ </fo:block>
4735
+ </fo:table-cell>
4039
4736
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4040
4737
  <xsl:apply-templates/>
4041
4738
  </xsl:template><xsl:template match="*[local-name()='dd']">
4042
4739
  <xsl:param name="process">false</xsl:param>
4740
+ <xsl:param name="split_keep-within-line"/>
4043
4741
  <xsl:if test="$process = 'true'">
4044
4742
  <xsl:apply-templates select="@language"/>
4045
- <xsl:apply-templates/>
4743
+ <xsl:apply-templates>
4744
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4745
+ </xsl:apply-templates>
4046
4746
  </xsl:if>
4047
4747
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4048
4748
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4049
- </xsl:template><xsl:template match="*[local-name()='em']">
4749
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
4750
+ <xsl:param name="id"/>
4751
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4752
+ <tr>
4753
+ <td>
4754
+ <xsl:copy-of select="node()"/>
4755
+ </td>
4756
+ <td>
4757
+
4758
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
4759
+
4760
+ <!-- get paragraphs from nested 'dl' -->
4761
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
4762
+
4763
+
4764
+ </td>
4765
+ </tr>
4766
+
4767
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
4768
+ <xsl:for-each select="*[local-name() = 'dt']">
4769
+ <p>
4770
+ <xsl:copy-of select="node()"/>
4771
+ <xsl:text> </xsl:text>
4772
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
4773
+ </p>
4774
+ </xsl:for-each>
4775
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
4050
4776
  <fo:inline font-style="italic">
4051
4777
  <xsl:apply-templates/>
4052
4778
  </fo:inline>
4053
4779
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
4780
+ <xsl:param name="split_keep-within-line"/>
4054
4781
  <fo:inline font-weight="bold">
4055
4782
 
4056
4783
  <xsl:if test="not(parent::*[local-name() = 'termsource'])">
@@ -4058,7 +4785,9 @@
4058
4785
  <xsl:attribute name="color">black</xsl:attribute>
4059
4786
  </xsl:if>
4060
4787
 
4061
- <xsl:apply-templates/>
4788
+ <xsl:apply-templates>
4789
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4790
+ </xsl:apply-templates>
4062
4791
  </fo:inline>
4063
4792
  </xsl:template><xsl:template match="*[local-name()='padding']">
4064
4793
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4079,7 +4808,7 @@
4079
4808
 
4080
4809
 
4081
4810
 
4082
-
4811
+ <!-- 10 -->
4083
4812
 
4084
4813
 
4085
4814
 
@@ -4102,13 +4831,15 @@
4102
4831
  <xsl:choose>
4103
4832
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4104
4833
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4105
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4834
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4106
4835
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4107
4836
  </xsl:choose>
4108
4837
  </xsl:attribute>
4109
4838
  </xsl:if>
4110
4839
  <xsl:apply-templates/>
4111
4840
  </fo:inline>
4841
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
4842
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4112
4843
  </xsl:template><xsl:template match="*[local-name()='underline']">
4113
4844
  <fo:inline text-decoration="underline">
4114
4845
  <xsl:apply-templates/>
@@ -4256,54 +4987,120 @@
4256
4987
  <fo:block break-after="page"/>
4257
4988
  <fo:block> </fo:block>
4258
4989
  <fo:block break-after="page"/>
4990
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
4991
+ <xsl:apply-templates/>
4259
4992
  </xsl:template><xsl:template name="tokenize">
4260
4993
  <xsl:param name="text"/>
4261
4994
  <xsl:param name="separator" select="' '"/>
4262
4995
  <xsl:choose>
4996
+
4997
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
4998
+ <word><xsl:value-of select="normalize-space($text)"/></word>
4999
+ </xsl:when>
4263
5000
  <xsl:when test="not(contains($text, $separator))">
4264
5001
  <word>
4265
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4266
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4267
5002
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
4268
- <xsl:variable name="len_str">
4269
- <xsl:choose>
4270
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4271
- <xsl:value-of select="$len_str_tmp * 1.5"/>
4272
- </xsl:when>
4273
- <xsl:otherwise>
4274
- <xsl:value-of select="$len_str_tmp"/>
4275
- </xsl:otherwise>
4276
- </xsl:choose>
4277
- </xsl:variable>
4278
-
4279
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4280
- <xsl:message>
4281
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4282
- len_str=<xsl:value-of select="$len_str"/>
4283
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4284
- </xsl:message>
4285
- </xsl:if> -->
4286
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4287
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
4288
5003
  <xsl:choose>
4289
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4290
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5004
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5005
+ <xsl:value-of select="$len_str_tmp"/>
4291
5006
  </xsl:when>
4292
5007
  <xsl:otherwise>
4293
- <xsl:value-of select="$len_str"/>
5008
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5009
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5010
+ <xsl:variable name="len_str">
5011
+ <xsl:choose>
5012
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5013
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5014
+ </xsl:when>
5015
+ <xsl:otherwise>
5016
+ <xsl:value-of select="$len_str_tmp"/>
5017
+ </xsl:otherwise>
5018
+ </xsl:choose>
5019
+ </xsl:variable>
5020
+
5021
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5022
+ <xsl:message>
5023
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5024
+ len_str=<xsl:value-of select="$len_str"/>
5025
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5026
+ </xsl:message>
5027
+ </xsl:if> -->
5028
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5029
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5030
+ <xsl:choose>
5031
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5032
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5033
+ </xsl:when>
5034
+ <xsl:otherwise>
5035
+ <xsl:value-of select="$len_str"/>
5036
+ </xsl:otherwise>
5037
+ </xsl:choose>
4294
5038
  </xsl:otherwise>
4295
5039
  </xsl:choose>
4296
5040
  </word>
4297
5041
  </xsl:when>
4298
5042
  <xsl:otherwise>
4299
5043
  <word>
4300
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5044
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5045
+ <xsl:choose>
5046
+ <xsl:when test="$isGenerateTableIF = 'true'">
5047
+ <xsl:value-of select="$word"/>
5048
+ </xsl:when>
5049
+ <xsl:otherwise>
5050
+ <xsl:value-of select="string-length($word)"/>
5051
+ </xsl:otherwise>
5052
+ </xsl:choose>
4301
5053
  </word>
4302
5054
  <xsl:call-template name="tokenize">
4303
5055
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
4304
5056
  </xsl:call-template>
4305
5057
  </xsl:otherwise>
4306
5058
  </xsl:choose>
5059
+ </xsl:template><xsl:template name="tokenize_with_tags">
5060
+ <xsl:param name="tags"/>
5061
+ <xsl:param name="text"/>
5062
+ <xsl:param name="separator" select="' '"/>
5063
+ <xsl:choose>
5064
+
5065
+ <xsl:when test="not(contains($text, $separator))">
5066
+ <word>
5067
+ <xsl:call-template name="enclose_text_in_tags">
5068
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5069
+ <xsl:with-param name="tags" select="$tags"/>
5070
+ </xsl:call-template>
5071
+ </word>
5072
+ </xsl:when>
5073
+ <xsl:otherwise>
5074
+ <word>
5075
+ <xsl:call-template name="enclose_text_in_tags">
5076
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5077
+ <xsl:with-param name="tags" select="$tags"/>
5078
+ </xsl:call-template>
5079
+ </word>
5080
+ <xsl:call-template name="tokenize_with_tags">
5081
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5082
+ </xsl:call-template>
5083
+ </xsl:otherwise>
5084
+ </xsl:choose>
5085
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5086
+ <xsl:param name="text"/>
5087
+ <xsl:param name="tags"/>
5088
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5089
+
5090
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5091
+
5092
+ <xsl:choose>
5093
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5094
+ <xsl:otherwise>
5095
+ <xsl:element name="{$tag_name}">
5096
+ <xsl:call-template name="enclose_text_in_tags">
5097
+ <xsl:with-param name="text" select="$text"/>
5098
+ <xsl:with-param name="tags" select="$tags"/>
5099
+ <xsl:with-param name="num" select="$num + 1"/>
5100
+ </xsl:call-template>
5101
+ </xsl:element>
5102
+ </xsl:otherwise>
5103
+ </xsl:choose>
4307
5104
  </xsl:template><xsl:template name="max_length">
4308
5105
  <xsl:param name="words"/>
4309
5106
  <xsl:for-each select="$words//word">
@@ -4404,12 +5201,19 @@
4404
5201
  </xsl:otherwise>
4405
5202
  </xsl:choose>
4406
5203
  </xsl:template><xsl:template name="getSimpleTable">
5204
+ <xsl:param name="id"/>
5205
+
4407
5206
  <xsl:variable name="simple-table">
4408
5207
 
5208
+ <!-- Step 0. replace <br/> to <p>...</p> -->
5209
+ <xsl:variable name="table_without_br">
5210
+ <xsl:apply-templates mode="table-without-br"/>
5211
+ </xsl:variable>
5212
+
4409
5213
  <!-- Step 1. colspan processing -->
4410
5214
  <xsl:variable name="simple-table-colspan">
4411
5215
  <tbody>
4412
- <xsl:apply-templates mode="simple-table-colspan"/>
5216
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
4413
5217
  </tbody>
4414
5218
  </xsl:variable>
4415
5219
 
@@ -4418,10 +5222,67 @@
4418
5222
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
4419
5223
  </xsl:variable>
4420
5224
 
4421
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
4422
-
5225
+ <!-- Step 3: add id to each cell -->
5226
+ <!-- add <word>...</word> for each word, image, math -->
5227
+ <xsl:variable name="simple-table-id">
5228
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
5229
+ <xsl:with-param name="id" select="$id"/>
5230
+ </xsl:apply-templates>
5231
+ </xsl:variable>
5232
+
5233
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5234
+
4423
5235
  </xsl:variable>
4424
5236
  <xsl:copy-of select="$simple-table"/>
5237
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
5238
+ <xsl:copy>
5239
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
5240
+ </xsl:copy>
5241
+ </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">
5242
+ <xsl:copy>
5243
+ <xsl:copy-of select="@*"/>
5244
+ <p>
5245
+ <xsl:copy-of select="node()"/>
5246
+ </p>
5247
+ </xsl:copy>
5248
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
5249
+ <xsl:copy>
5250
+ <xsl:copy-of select="@*"/>
5251
+ <xsl:for-each select="*[local-name()='br']">
5252
+ <xsl:variable name="current_id" select="generate-id()"/>
5253
+ <p>
5254
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5255
+ <xsl:copy-of select="."/>
5256
+ </xsl:for-each>
5257
+ </p>
5258
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5259
+ <p>
5260
+ <xsl:for-each select="following-sibling::node()">
5261
+ <xsl:copy-of select="."/>
5262
+ </xsl:for-each>
5263
+ </p>
5264
+ </xsl:if>
5265
+ </xsl:for-each>
5266
+ </xsl:copy>
5267
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
5268
+ <xsl:for-each select="*[local-name()='br']">
5269
+ <xsl:variable name="current_id" select="generate-id()"/>
5270
+ <p>
5271
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5272
+ <xsl:copy-of select="."/>
5273
+ </xsl:for-each>
5274
+ </p>
5275
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5276
+ <p>
5277
+ <xsl:for-each select="following-sibling::node()">
5278
+ <xsl:copy-of select="."/>
5279
+ </xsl:for-each>
5280
+ </p>
5281
+ </xsl:if>
5282
+ </xsl:for-each>
5283
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
5284
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
5285
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
4425
5286
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
4426
5287
  <xsl:apply-templates mode="simple-table-colspan"/>
4427
5288
  </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">
@@ -4499,18 +5360,138 @@
4499
5360
  </xsl:choose>
4500
5361
  </xsl:for-each>
4501
5362
  </xsl:variable>
4502
-
4503
- <xsl:variable name="newRow">
4504
- <xsl:copy>
4505
- <xsl:copy-of select="$currentRow/@*"/>
4506
- <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
4507
- </xsl:copy>
5363
+
5364
+ <xsl:variable name="newRow">
5365
+ <xsl:copy>
5366
+ <xsl:copy-of select="$currentRow/@*"/>
5367
+ <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
5368
+ </xsl:copy>
5369
+ </xsl:variable>
5370
+ <xsl:copy-of select="$newRow"/>
5371
+
5372
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5373
+ <xsl:with-param name="previousRow" select="$newRow"/>
5374
+ </xsl:apply-templates>
5375
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
5376
+ <xsl:param name="id"/>
5377
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
5378
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5379
+ <xsl:with-param name="id" select="$id_prefixed"/>
5380
+ </xsl:apply-templates>
5381
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
5382
+ <xsl:param name="id"/>
5383
+ <xsl:copy>
5384
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
5385
+ <xsl:with-param name="id" select="$id"/>
5386
+ </xsl:apply-templates>
5387
+ </xsl:copy>
5388
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
5389
+ <xsl:param name="id"/>
5390
+ <xsl:copy>
5391
+ <xsl:copy-of select="@*"/>
5392
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
5393
+ <xsl:apply-templates select="node()" mode="simple-table-id">
5394
+ <xsl:with-param name="id" select="$id"/>
5395
+ </xsl:apply-templates>
5396
+ </xsl:copy>
5397
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
5398
+ <xsl:param name="id"/>
5399
+ <xsl:copy>
5400
+ <xsl:copy-of select="@*"/>
5401
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
5402
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
5403
+ <xsl:attribute name="id">
5404
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
5405
+ </xsl:attribute>
5406
+
5407
+ <xsl:for-each select="*[local-name() = 'p']">
5408
+ <xsl:copy>
5409
+ <xsl:copy-of select="@*"/>
5410
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
5411
+ <xsl:attribute name="id">
5412
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
5413
+ </xsl:attribute>
5414
+
5415
+ <xsl:copy-of select="node()"/>
5416
+ </xsl:copy>
5417
+ </xsl:for-each>
5418
+
5419
+
5420
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
5421
+
5422
+ <xsl:variable name="td_text">
5423
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
5424
+ </xsl:variable>
5425
+
5426
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
5427
+
5428
+ <xsl:variable name="words">
5429
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
5430
+ <word>
5431
+ <xsl:copy-of select="."/>
5432
+ </word>
5433
+ </xsl:for-each>
5434
+
5435
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
5436
+ <xsl:copy-of select="."/>
5437
+ </xsl:for-each>
5438
+
5439
+ </xsl:variable>
5440
+
5441
+ <xsl:for-each select="xalan:nodeset($words)/word">
5442
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
5443
+ <xsl:copy>
5444
+ <xsl:attribute name="id">
5445
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
5446
+ </xsl:attribute>
5447
+ <xsl:copy-of select="node()"/>
5448
+ </xsl:copy>
5449
+ </xsl:for-each>
5450
+ </xsl:if>
5451
+ </xsl:copy>
5452
+
5453
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
5454
+ <xsl:copy>
5455
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
5456
+ </xsl:copy>
5457
+ </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">
5458
+ <xsl:variable name="formatting_tags">
5459
+ <xsl:call-template name="getFormattingTags"/>
5460
+ </xsl:variable>
5461
+ <word>
5462
+ <xsl:call-template name="enclose_text_in_tags">
5463
+ <xsl:with-param name="text" select="normalize-space(.)"/>
5464
+ <xsl:with-param name="tags" select="$formatting_tags"/>
5465
+ </xsl:call-template>
5466
+ </word>
5467
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
5468
+
5469
+ <xsl:variable name="td_text" select="."/>
5470
+
5471
+ <xsl:variable name="string_with_added_zerospaces">
5472
+ <xsl:call-template name="add-zero-spaces-java">
5473
+ <xsl:with-param name="text" select="$td_text"/>
5474
+ </xsl:call-template>
5475
+ </xsl:variable>
5476
+
5477
+ <xsl:variable name="formatting_tags">
5478
+ <xsl:call-template name="getFormattingTags"/>
4508
5479
  </xsl:variable>
4509
- <xsl:copy-of select="$newRow"/>
4510
-
4511
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
4512
- <xsl:with-param name="previousRow" select="$newRow"/>
4513
- </xsl:apply-templates>
5480
+
5481
+ <!-- <word>text</word> -->
5482
+ <xsl:call-template name="tokenize_with_tags">
5483
+ <xsl:with-param name="tags" select="$formatting_tags"/>
5484
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
5485
+ </xsl:call-template>
5486
+ </xsl:template><xsl:template name="getFormattingTags">
5487
+ <tags>
5488
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
5489
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
5490
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
5491
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
5492
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
5493
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
5494
+ </tags>
4514
5495
  </xsl:template><xsl:template name="getLang">
4515
5496
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
4516
5497
  <xsl:variable name="language">
@@ -4565,6 +5546,9 @@
4565
5546
  <xsl:variable name="isDeleted" select="@deleted"/>
4566
5547
 
4567
5548
  <fo:inline xsl:use-attribute-sets="mathml-style">
5549
+
5550
+
5551
+
4568
5552
 
4569
5553
 
4570
5554
  <xsl:call-template name="setTrackChangesStyles">
@@ -4572,48 +5556,80 @@
4572
5556
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
4573
5557
  </xsl:call-template>
4574
5558
 
5559
+ <xsl:if test="$add_math_as_text = 'true'">
5560
+ <!-- insert helper tag -->
5561
+ <!-- set unique font-size (fiction) -->
5562
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
5563
+ <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 -->
5564
+ </xsl:if>
4575
5565
 
4576
-
4577
- <xsl:variable name="mathml">
4578
- <xsl:apply-templates select="." mode="mathml"/>
5566
+ <xsl:variable name="mathml_content">
5567
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
4579
5568
  </xsl:variable>
4580
- <fo:instream-foreign-object fox:alt-text="Math">
4581
5569
 
5570
+
5571
+ <xsl:call-template name="mathml_instream_object">
5572
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
5573
+ </xsl:call-template>
4582
5574
 
4583
-
4584
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
4585
- <xsl:variable name="comment_text_">
4586
- <xsl:choose>
4587
- <xsl:when test="normalize-space($comment_text_following) != ''">
4588
- <xsl:value-of select="$comment_text_following"/>
4589
- </xsl:when>
4590
- <xsl:otherwise>
4591
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
4592
- </xsl:otherwise>
4593
- </xsl:choose>
4594
- </xsl:variable>
4595
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
4596
-
4597
- <xsl:if test="normalize-space($comment_text) != ''">
4598
- <!-- put Mathin Alternate Text -->
4599
- <xsl:attribute name="fox:alt-text">
4600
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
4601
- </xsl:attribute>
4602
- </xsl:if>
4603
-
4604
- <xsl:variable name="mathml_content">
4605
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
4606
- </xsl:variable>
4607
- <!-- put MathML in Actual Text -->
4608
- <xsl:attribute name="fox:actual-text">
4609
- <xsl:value-of select="$mathml_content"/>
4610
- </xsl:attribute>
4611
-
4612
-
4613
-
4614
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
4615
- </fo:instream-foreign-object>
5575
+
4616
5576
  </fo:inline>
5577
+ </xsl:template><xsl:template name="getMathml_comment_text">
5578
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5579
+ <xsl:variable name="comment_text_">
5580
+ <xsl:choose>
5581
+ <xsl:when test="normalize-space($comment_text_following) != ''">
5582
+ <xsl:value-of select="$comment_text_following"/>
5583
+ </xsl:when>
5584
+ <xsl:otherwise>
5585
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5586
+ </xsl:otherwise>
5587
+ </xsl:choose>
5588
+ </xsl:variable>
5589
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5590
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
5591
+ <xsl:value-of select="$comment_text"/>
5592
+ </xsl:template><xsl:template name="mathml_instream_object">
5593
+ <xsl:param name="comment_text"/>
5594
+ <xsl:param name="mathml_content"/>
5595
+
5596
+ <xsl:variable name="comment_text_">
5597
+ <xsl:choose>
5598
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
5599
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
5600
+ </xsl:choose>
5601
+ </xsl:variable>
5602
+
5603
+ <xsl:variable name="mathml">
5604
+ <xsl:apply-templates select="." mode="mathml"/>
5605
+ </xsl:variable>
5606
+
5607
+ <fo:instream-foreign-object fox:alt-text="Math">
5608
+
5609
+
5610
+
5611
+
5612
+
5613
+
5614
+
5615
+ <!-- put MathML in Actual Text -->
5616
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
5617
+ <xsl:attribute name="fox:actual-text">
5618
+ <xsl:value-of select="$mathml_content"/>
5619
+ </xsl:attribute>
5620
+
5621
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
5622
+ <xsl:if test="normalize-space($comment_text_) != ''">
5623
+ <!-- put Mathin Alternate Text -->
5624
+ <xsl:attribute name="fox:alt-text">
5625
+ <xsl:value-of select="$comment_text_"/>
5626
+ </xsl:attribute>
5627
+ </xsl:if>
5628
+ <!-- </xsl:if> -->
5629
+
5630
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
5631
+
5632
+ </fo:instream-foreign-object>
4617
5633
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
4618
5634
  <!-- <xsl:text>a+b</xsl:text> -->
4619
5635
  <xsl:text>&lt;</xsl:text>
@@ -4644,7 +5660,9 @@
4644
5660
  <!-- replace start and end spaces to non-break space -->
4645
5661
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4646
5662
  </xsl:copy>
4647
- </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">
5663
+ </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">
5664
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5665
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
4648
5666
  <xsl:variable name="target">
4649
5667
  <xsl:choose>
4650
5668
  <xsl:when test="@updatetype = 'true'">
@@ -5250,18 +6268,33 @@
5250
6268
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5251
6269
  <xsl:copy>
5252
6270
  <xsl:apply-templates select="@*" mode="svg_update"/>
5253
- <xsl:variable name="viewbox">
6271
+ <xsl:variable name="viewbox_">
5254
6272
  <xsl:call-template name="split">
5255
6273
  <xsl:with-param name="pText" select="@viewBox"/>
5256
6274
  <xsl:with-param name="sep" select="' '"/>
5257
6275
  </xsl:call-template>
5258
6276
  </xsl:variable>
6277
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
6278
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
6279
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
6280
+
5259
6281
  <xsl:attribute name="width">
5260
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
6282
+ <xsl:choose>
6283
+ <xsl:when test="$width != ''">
6284
+ <xsl:value-of select="round($width)"/>
6285
+ </xsl:when>
6286
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
6287
+ </xsl:choose>
5261
6288
  </xsl:attribute>
5262
6289
  <xsl:attribute name="height">
5263
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
6290
+ <xsl:choose>
6291
+ <xsl:when test="$height != ''">
6292
+ <xsl:value-of select="round($height)"/>
6293
+ </xsl:when>
6294
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
6295
+ </xsl:choose>
5264
6296
  </xsl:attribute>
6297
+
5265
6298
  <xsl:apply-templates mode="svg_update"/>
5266
6299
  </xsl:copy>
5267
6300
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -5456,7 +6489,11 @@
5456
6489
  <xsl:apply-templates mode="bookmarks"/>
5457
6490
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
5458
6491
  <xsl:apply-templates select="."/>
5459
- </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">
6492
+ </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">
6493
+ <xsl:apply-templates mode="contents"/>
6494
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
6495
+ <xsl:apply-templates mode="bookmarks"/>
6496
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
5460
6497
  <xsl:apply-templates mode="bookmarks"/>
5461
6498
  </xsl:template><xsl:template name="addBookmarks">
5462
6499
  <xsl:param name="contents"/>
@@ -5738,7 +6775,9 @@
5738
6775
  <xsl:apply-templates/>
5739
6776
  </xsl:otherwise>
5740
6777
  </xsl:choose>
5741
- </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">
6778
+ </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">
6779
+ <xsl:value-of select="."/>
6780
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
5742
6781
  <xsl:text> </xsl:text>
5743
6782
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
5744
6783
  <xsl:copy>
@@ -5769,9 +6808,22 @@
5769
6808
  </xsl:when>
5770
6809
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
5771
6810
  </xsl:choose>
6811
+ </xsl:template><xsl:template match="text()" mode="contents_item">
6812
+ <xsl:call-template name="keep_together_standard_number"/>
6813
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
6814
+ <xsl:apply-templates mode="contents_item"/>
5772
6815
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
5773
6816
 
5774
6817
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
6818
+
6819
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
6820
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6821
+ </xsl:if>
6822
+
6823
+ <xsl:if test="ancestor::*[local-name() = 'example']">
6824
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6825
+ </xsl:if>
6826
+
5775
6827
  <xsl:copy-of select="@id"/>
5776
6828
 
5777
6829
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -5798,7 +6850,7 @@
5798
6850
 
5799
6851
 
5800
6852
 
5801
-
6853
+ <!-- 9 -->
5802
6854
 
5803
6855
 
5804
6856
 
@@ -5898,7 +6950,7 @@
5898
6950
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
5899
6951
  <xsl:choose>
5900
6952
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5901
- <xsl:call-template name="interspers">
6953
+ <xsl:call-template name="interspers-java">
5902
6954
  <xsl:with-param name="str" select="."/>
5903
6955
  </xsl:call-template>
5904
6956
  </xsl:when>
@@ -5948,6 +7000,10 @@
5948
7000
  <xsl:with-param name="char" select="$char"/>
5949
7001
  </xsl:call-template>
5950
7002
  </xsl:if>
7003
+ </xsl:template><xsl:template name="interspers-java">
7004
+ <xsl:param name="str"/>
7005
+ <xsl:param name="char" select="$zero_width_space"/>
7006
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
5951
7007
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5952
7008
  <xsl:apply-templates mode="syntax_highlight"/>
5953
7009
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6160,7 +7216,9 @@
6160
7216
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
6161
7217
  </xsl:if>
6162
7218
  <xsl:variable name="simple-table">
6163
- <xsl:call-template name="getSimpleTable"/>
7219
+ <xsl:call-template name="getSimpleTable">
7220
+ <xsl:with-param name="id" select="@id"/>
7221
+ </xsl:call-template>
6164
7222
  </xsl:variable>
6165
7223
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
6166
7224
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -6267,44 +7325,72 @@
6267
7325
  </xsl:otherwise>
6268
7326
  </xsl:choose>
6269
7327
  </xsl:template><xsl:template match="*[local-name() = 'example']">
6270
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
7328
+
7329
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7330
+
6271
7331
 
6272
7332
  <xsl:if test="ancestor::rsd:ul or ancestor::rsd:ol">
6273
7333
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
6274
7334
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
6275
7335
  </xsl:if>
6276
7336
 
6277
-
7337
+
6278
7338
  <xsl:variable name="fo_element">
6279
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
7339
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
6280
7340
  inline
6281
7341
  </xsl:variable>
6282
7342
 
6283
- <!-- display 'EXAMPLE' -->
6284
- <xsl:apply-templates select="*[local-name()='name']">
6285
- <xsl:with-param name="fo_element" select="$fo_element"/>
6286
- </xsl:apply-templates>
7343
+ <fo:block-container margin-left="0mm">
6287
7344
 
6288
- <xsl:choose>
6289
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
6290
- <fo:block-container xsl:use-attribute-sets="example-body-style">
6291
- <fo:block-container margin-left="0mm" margin-right="0mm">
6292
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7345
+ <xsl:choose>
7346
+
7347
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
7348
+
7349
+ <!-- display name 'EXAMPLE' in a separate block -->
7350
+ <fo:block>
7351
+ <xsl:apply-templates select="*[local-name()='name']">
6293
7352
  <xsl:with-param name="fo_element" select="$fo_element"/>
6294
7353
  </xsl:apply-templates>
7354
+ </fo:block>
7355
+
7356
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7357
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7358
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7359
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7360
+ </xsl:apply-templates>
7361
+ </fo:block-container>
6295
7362
  </fo:block-container>
6296
- </fo:block-container>
6297
- </xsl:when>
6298
- <xsl:otherwise>
6299
- <fo:inline>
6300
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6301
- <xsl:with-param name="fo_element" select="$fo_element"/>
6302
- </xsl:apply-templates>
6303
- </fo:inline>
6304
- </xsl:otherwise>
6305
- </xsl:choose>
6306
-
6307
- </fo:block>
7363
+ </xsl:when> <!-- end block -->
7364
+
7365
+ <xsl:otherwise> <!-- inline -->
7366
+
7367
+ <!-- display 'EXAMPLE' and first element in the same line -->
7368
+ <fo:block>
7369
+ <xsl:apply-templates select="*[local-name()='name']">
7370
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7371
+ </xsl:apply-templates>
7372
+ <fo:inline>
7373
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
7374
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7375
+ </xsl:apply-templates>
7376
+ </fo:inline>
7377
+ </fo:block>
7378
+
7379
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
7380
+ <!-- display further elements in blocks -->
7381
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
7382
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7383
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
7384
+ <xsl:with-param name="fo_element" select="'block'"/>
7385
+ </xsl:apply-templates>
7386
+ </fo:block-container>
7387
+ </fo:block-container>
7388
+ </xsl:if>
7389
+ </xsl:otherwise> <!-- end inline -->
7390
+
7391
+ </xsl:choose>
7392
+ </fo:block-container>
7393
+ </fo:block-container>
6308
7394
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6309
7395
  <xsl:param name="fo_element">block</xsl:param>
6310
7396
 
@@ -6341,10 +7427,16 @@
6341
7427
  </xsl:variable>
6342
7428
  <xsl:choose>
6343
7429
  <xsl:when test="starts-with(normalize-space($element), 'block')">
6344
- <fo:block xsl:use-attribute-sets="example-p-style">
6345
-
6346
- <xsl:apply-templates/>
6347
- </fo:block>
7430
+ <fo:block-container>
7431
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
7432
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7433
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7434
+ </xsl:if>
7435
+ <fo:block xsl:use-attribute-sets="example-p-style">
7436
+
7437
+ <xsl:apply-templates/>
7438
+ </fo:block>
7439
+ </fo:block-container>
6348
7440
  </xsl:when>
6349
7441
  <xsl:otherwise>
6350
7442
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -6523,7 +7615,16 @@
6523
7615
  </fo:inline>
6524
7616
  </xsl:when>
6525
7617
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6526
- <fo:inline><xsl:apply-templates/></fo:inline>
7618
+
7619
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
7620
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
7621
+ <xsl:choose>
7622
+ <xsl:when test="$uri_src != ''">
7623
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
7624
+ </xsl:when>
7625
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
7626
+ </xsl:choose>
7627
+
6527
7628
  </xsl:otherwise>
6528
7629
  </xsl:choose>
6529
7630
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -6694,10 +7795,24 @@
6694
7795
 
6695
7796
  </fo:block>
6696
7797
  <xsl:apply-templates/>
6697
- </xsl:template><xsl:template match="*[local-name() = 'review']">
7798
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
6698
7799
  <!-- comment 2019-11-29 -->
6699
7800
  <!-- <fo:block font-weight="bold">Review:</fo:block>
6700
7801
  <xsl:apply-templates /> -->
7802
+
7803
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
7804
+
7805
+ <xsl:choose>
7806
+ <!-- if there isn't the attribute '@from', then -->
7807
+ <xsl:when test="$id_from = ''">
7808
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7809
+ </xsl:when>
7810
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
7811
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
7812
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7813
+ </xsl:when>
7814
+ </xsl:choose>
7815
+
6701
7816
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
6702
7817
  <!-- 0xA0 to space replacement -->
6703
7818
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -6844,6 +7959,11 @@
6844
7959
  </xsl:otherwise>
6845
7960
  </xsl:choose>
6846
7961
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
7962
+
7963
+ <xsl:apply-templates select="*[local-name() = 'name']">
7964
+ <xsl:with-param name="process">true</xsl:with-param>
7965
+ </xsl:apply-templates>
7966
+
6847
7967
  <fo:list-block xsl:use-attribute-sets="list-style">
6848
7968
 
6849
7969
 
@@ -6854,12 +7974,23 @@
6854
7974
 
6855
7975
 
6856
7976
 
7977
+ <xsl:if test="*[local-name() = 'name']">
7978
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
7979
+ </xsl:if>
7980
+
6857
7981
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6858
7982
  </fo:list-block>
6859
7983
  <!-- <xsl:for-each select="./iho:note">
6860
7984
  <xsl:call-template name="note"/>
6861
7985
  </xsl:for-each> -->
6862
7986
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
7987
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
7988
+ <xsl:param name="process">false</xsl:param>
7989
+ <xsl:if test="$process = 'true'">
7990
+ <fo:block xsl:use-attribute-sets="list-name-style">
7991
+ <xsl:apply-templates/>
7992
+ </fo:block>
7993
+ </xsl:if>
6863
7994
  </xsl:template><xsl:template match="*[local-name()='li']">
6864
7995
  <fo:list-item xsl:use-attribute-sets="list-item-style">
6865
7996
  <xsl:copy-of select="@id"/>
@@ -7056,7 +8187,10 @@
7056
8187
  <!-- to split by '_' and other chars -->
7057
8188
  <xsl:call-template name="add-zero-spaces-java"/>
7058
8189
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7059
- <fo:inline id="{@id}" font-size="1pt"/>
8190
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8191
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8192
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8193
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7060
8194
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7061
8195
  <!-- <row>
7062
8196
  <date>05-07-2013</date>
@@ -7141,20 +8275,18 @@
7141
8275
  </fo:list-item-label>
7142
8276
  <fo:list-item-body start-indent="body-start()">
7143
8277
  <fo:block>
7144
- <xsl:if test="rsd:docidentifier">
8278
+ <xsl:variable name="docidentifier">
7145
8279
  <xsl:choose>
7146
8280
  <xsl:when test="rsd:docidentifier/@type = 'metanorma'"/>
7147
- <xsl:otherwise><fo:inline><xsl:value-of select="rsd:docidentifier[not(@type = 'metanorma-ordinal')]"/>, </fo:inline></xsl:otherwise>
8281
+ <xsl:otherwise>
8282
+ <xsl:value-of select="rsd:docidentifier[not(@type = 'metanorma-ordinal')]"/>
8283
+ </xsl:otherwise>
7148
8284
  </xsl:choose>
8285
+ </xsl:variable>
8286
+ <xsl:value-of select="$docidentifier"/>
8287
+ <xsl:if test="normalize-space($docidentifier) != '' and rsd:formattedref">
8288
+ <xsl:text>, </xsl:text>
7149
8289
  </xsl:if>
7150
- <xsl:choose>
7151
- <xsl:when test="rsd:title[@type = 'main' and @language = 'en']">
7152
- <xsl:apply-templates select="rsd:title[@type = 'main' and @language = 'en']"/>
7153
- </xsl:when>
7154
- <xsl:otherwise>
7155
- <xsl:apply-templates select="rsd:title"/>
7156
- </xsl:otherwise>
7157
- </xsl:choose>
7158
8290
  <xsl:apply-templates select="rsd:formattedref"/>
7159
8291
  </fo:block>
7160
8292
  </fo:list-item-body>
@@ -7165,42 +8297,16 @@
7165
8297
  </xsl:template><xsl:template name="processBibitem">
7166
8298
 
7167
8299
 
8300
+ <!-- start RSD bibitem processing -->
7168
8301
  <xsl:if test=".//rsd:fn">
7169
8302
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
7170
8303
  </xsl:if>
7171
- <xsl:value-of select="rsd:docidentifier"/>
8304
+ <xsl:variable name="docidentifier" select="rsd:docidentifier"/>
8305
+ <xsl:value-of select="$docidentifier"/>
7172
8306
  <xsl:apply-templates select="rsd:note"/>
7173
- <xsl:if test="rsd:docidentifier">, </xsl:if>
7174
- <xsl:choose>
7175
- <xsl:when test="rsd:formattedref">
7176
- <xsl:apply-templates select="rsd:formattedref"/>
7177
- </xsl:when>
7178
- <xsl:otherwise>
7179
- <xsl:for-each select="rsd:contributor[rsd:role/@type='publisher']/rsd:organization/rsd:name">
7180
- <xsl:apply-templates/>
7181
- <xsl:if test="position() != last()">, </xsl:if>
7182
- <xsl:if test="position() = last()">: </xsl:if>
7183
- </xsl:for-each>
7184
- <!-- rsd:docidentifier -->
7185
-
7186
- <xsl:choose>
7187
- <xsl:when test="rsd:title[@type = 'main' and @language = 'en']">
7188
- <fo:inline><xsl:apply-templates select="rsd:title[@type = 'main' and @language = 'en']"/><xsl:text>. </xsl:text></fo:inline>
7189
- </xsl:when>
7190
- <xsl:otherwise>
7191
- <fo:inline><xsl:apply-templates select="rsd:title"/><xsl:text>. </xsl:text></fo:inline>
7192
- </xsl:otherwise>
7193
- </xsl:choose>
7194
-
7195
- <xsl:for-each select="rsd:contributor[rsd:role/@type='publisher']/rsd:organization/rsd:name">
7196
- <xsl:apply-templates/>
7197
- <xsl:if test="position() != last()">, </xsl:if>
7198
- </xsl:for-each>
7199
- <xsl:if test="rsd:date[@type='published']/rsd:on">
7200
- <xsl:text> (</xsl:text><xsl:value-of select="rsd:date[@type='published']/rsd:on"/><xsl:text>)</xsl:text>
7201
- </xsl:if>
7202
- </xsl:otherwise>
7203
- </xsl:choose>
8307
+ <xsl:if test="normalize-space($docidentifier) != '' and rsd:formattedref">, </xsl:if>
8308
+ <xsl:apply-templates select="rsd:formattedref"/>
8309
+ <!-- END RSD bibitem processing -->
7204
8310
 
7205
8311
  </xsl:template><xsl:template name="processBibitemDocId">
7206
8312
  <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')]"/>
@@ -7527,25 +8633,32 @@
7527
8633
  </fo:block-container>
7528
8634
 
7529
8635
  </xsl:template><xsl:template name="displayAdmonitionName">
7530
-
8636
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
8637
+ <!-- <xsl:choose>
8638
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
8639
+ <xsl:choose>
8640
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
8641
+ <xsl:otherwise>
8642
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8643
+ </xsl:otherwise>
8644
+ </xsl:choose>
8645
+ </xsl:when>
8646
+ <xsl:otherwise>
7531
8647
  <xsl:apply-templates select="*[local-name() = 'name']"/>
7532
8648
  <xsl:if test="not(*[local-name() = 'name'])">
7533
8649
  <xsl:apply-templates select="@type"/>
7534
8650
  </xsl:if>
7535
-
7536
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
7537
- <xsl:apply-templates/>
7538
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
7539
- <xsl:variable name="admonition_type_">
7540
- <xsl:call-template name="getLocalizedString">
7541
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
7542
- </xsl:call-template>
8651
+ </xsl:otherwise>
8652
+ </xsl:choose> -->
8653
+ <xsl:variable name="name">
8654
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
7543
8655
  </xsl:variable>
7544
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
7545
- <xsl:value-of select="$admonition_type"/>
7546
- <xsl:if test="$admonition_type = ''">
7547
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
8656
+ <xsl:copy-of select="$name"/>
8657
+ <xsl:if test="normalize-space($name) != ''">
8658
+ <xsl:value-of select="$sep"/>
7548
8659
  </xsl:if>
8660
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8661
+ <xsl:apply-templates/>
7549
8662
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
7550
8663
 
7551
8664
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -7627,6 +8740,120 @@
7627
8740
  <xsl:apply-templates select="." mode="update_xml_step1"/>
7628
8741
  </xsl:for-each>
7629
8742
  </xsl:copy>
8743
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
8744
+ <xsl:apply-templates mode="update_xml_step1"/>
8745
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
8746
+ <xsl:copy>
8747
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
8748
+ </xsl:copy>
8749
+ </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">
8750
+
8751
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
8752
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
8753
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8754
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8755
+ <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))"/>
8756
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
8757
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8758
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8759
+ <xsl:with-param name="text" select="$text_"/>
8760
+ </xsl:call-template></text></xsl:variable>
8761
+
8762
+ <xsl:variable name="parent" select="local-name(..)"/>
8763
+
8764
+ <xsl:variable name="text2">
8765
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
8766
+ <xsl:copy-of select="."/>
8767
+ </xsl:for-each></text>
8768
+ </xsl:variable>
8769
+
8770
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
8771
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
8772
+ <xsl:variable name="text3">
8773
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
8774
+ <xsl:choose>
8775
+ <xsl:when test="self::text()">
8776
+ <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))"/>
8777
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
8778
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8779
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8780
+ <xsl:with-param name="text" select="$text_units_"/>
8781
+ </xsl:call-template></text></xsl:variable>
8782
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
8783
+ </xsl:when>
8784
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8785
+ </xsl:choose>
8786
+ </xsl:for-each></text>
8787
+ </xsl:variable>
8788
+
8789
+ <xsl:choose>
8790
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
8791
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
8792
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
8793
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
8794
+ <xsl:choose>
8795
+ <xsl:when test="self::text()">
8796
+ <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))"/>
8797
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
8798
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8799
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8800
+ <xsl:with-param name="text" select="$text_dots_"/>
8801
+ </xsl:call-template></text></xsl:variable>
8802
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
8803
+ </xsl:when>
8804
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8805
+ </xsl:choose>
8806
+ </xsl:for-each>
8807
+ </xsl:when>
8808
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
8809
+ </xsl:choose>
8810
+
8811
+ </xsl:template><xsl:template name="replace_text_tags">
8812
+ <xsl:param name="tag_open"/>
8813
+ <xsl:param name="tag_close"/>
8814
+ <xsl:param name="text"/>
8815
+ <xsl:choose>
8816
+ <xsl:when test="contains($text, $tag_open)">
8817
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
8818
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
8819
+
8820
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
8821
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
8822
+ </xsl:element>
8823
+
8824
+ <xsl:call-template name="replace_text_tags">
8825
+ <xsl:with-param name="tag_open" select="$tag_open"/>
8826
+ <xsl:with-param name="tag_close" select="$tag_close"/>
8827
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
8828
+ </xsl:call-template>
8829
+ </xsl:when>
8830
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8831
+ </xsl:choose>
8832
+ </xsl:template><xsl:template name="printEdition">
8833
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
8834
+ <xsl:text> </xsl:text>
8835
+ <xsl:choose>
8836
+ <xsl:when test="$edition_i18n != ''">
8837
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
8838
+ <xsl:call-template name="capitalize">
8839
+ <xsl:with-param name="str" select="$edition_i18n"/>
8840
+ </xsl:call-template>
8841
+ </xsl:when>
8842
+ <xsl:otherwise>
8843
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
8844
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
8845
+ <xsl:call-template name="capitalize">
8846
+ <xsl:with-param name="str">
8847
+ <xsl:call-template name="getLocalizedString">
8848
+ <xsl:with-param name="key">edition</xsl:with-param>
8849
+ </xsl:call-template>
8850
+ </xsl:with-param>
8851
+ </xsl:call-template>
8852
+ <xsl:text> </xsl:text>
8853
+ <xsl:value-of select="$edition"/>
8854
+ </xsl:if>
8855
+ </xsl:otherwise>
8856
+ </xsl:choose>
7630
8857
  </xsl:template><xsl:template name="convertDate">
7631
8858
  <xsl:param name="date"/>
7632
8859
  <xsl:param name="format" select="'short'"/>
@@ -8314,4 +9541,40 @@
8314
9541
  <xsl:value-of select="$value"/>
8315
9542
  </xsl:otherwise>
8316
9543
  </xsl:choose>
9544
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
9545
+ <xsl:param name="level">0</xsl:param>
9546
+
9547
+ <fo:block margin-left="{2*$level}mm">
9548
+ <xsl:text>
9549
+ &lt;</xsl:text>
9550
+ <xsl:value-of select="local-name()"/>
9551
+ <xsl:for-each select="@*">
9552
+ <xsl:text> </xsl:text>
9553
+ <xsl:value-of select="local-name()"/>
9554
+ <xsl:text>="</xsl:text>
9555
+ <xsl:value-of select="."/>
9556
+ <xsl:text>"</xsl:text>
9557
+ </xsl:for-each>
9558
+ <xsl:text>&gt;</xsl:text>
9559
+
9560
+ <xsl:if test="not(*)">
9561
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
9562
+ <xsl:text>&lt;/</xsl:text>
9563
+ <xsl:value-of select="local-name()"/>
9564
+ <xsl:text>&gt;</xsl:text>
9565
+ </xsl:if>
9566
+ </fo:block>
9567
+
9568
+ <xsl:if test="*">
9569
+ <fo:block>
9570
+ <xsl:apply-templates mode="print_as_xml">
9571
+ <xsl:with-param name="level" select="$level + 1"/>
9572
+ </xsl:apply-templates>
9573
+ </fo:block>
9574
+ <fo:block margin-left="{2*$level}mm">
9575
+ <xsl:text>&lt;/</xsl:text>
9576
+ <xsl:value-of select="local-name()"/>
9577
+ <xsl:text>&gt;</xsl:text>
9578
+ </fo:block>
9579
+ </xsl:if>
8317
9580
  </xsl:template></xsl:stylesheet>