metanorma-bipm 2.1.0 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -440,7 +440,7 @@
440
440
  </xsl:for-each>
441
441
  <xsl:for-each select="//*[contains(local-name(), '-standard')]">
442
442
  <fo:block break-after="page"/>
443
- <xsl:apply-templates select="./*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']"/>
443
+ <xsl:apply-templates select="./*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements' and local-name() != 'note' and local-name() != 'admonition']"/>
444
444
  </xsl:for-each>
445
445
  <xsl:for-each select="//*[contains(local-name(), '-standard')]">
446
446
  <fo:block break-after="page"/>
@@ -676,6 +676,7 @@
676
676
 
677
677
  <xsl:template match="*[local-name()='p']" name="paragraph">
678
678
  <xsl:param name="inline" select="'false'"/>
679
+ <xsl:param name="split_keep-within-line"/>
679
680
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
680
681
  <xsl:variable name="element-name">
681
682
  <xsl:choose>
@@ -701,7 +702,9 @@
701
702
  <xsl:attribute name="widows">1</xsl:attribute>
702
703
  <xsl:attribute name="orphans">1</xsl:attribute>
703
704
  </xsl:if>
704
- <xsl:apply-templates/>
705
+ <xsl:apply-templates>
706
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
707
+ </xsl:apply-templates>
705
708
  </xsl:element>
706
709
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
707
710
  <fo:block margin-bottom="12pt">
@@ -1721,12 +1724,41 @@
1721
1724
  </fo:block-container>
1722
1725
  </xsl:template>
1723
1726
 
1724
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:param name="add_math_as_text">true</xsl:param><xsl:variable name="lang">
1727
+ <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_">
1728
+ <xsl:for-each select="$table_widths_from_if//table">
1729
+ <xsl:copy>
1730
+ <xsl:copy-of select="@*"/>
1731
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
1732
+ </xsl:copy>
1733
+ </xsl:for-each>
1734
+ </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_">
1735
+ false
1736
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
1725
1737
  <xsl:call-template name="getLang"/>
1726
- </xsl:variable><xsl:variable name="pageWidth_">
1727
- 210
1738
+ </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_">
1739
+ <xsl:choose>
1740
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
1741
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
1742
+ </xsl:choose>
1743
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
1744
+ <xsl:choose>
1745
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
1746
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
1747
+ </xsl:choose>
1748
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
1749
+ <xsl:choose>
1750
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
1751
+ <xsl:otherwise>
1752
+ 210
1753
+ </xsl:otherwise>
1754
+ </xsl:choose>
1728
1755
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
1729
- 297
1756
+ <xsl:choose>
1757
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
1758
+ <xsl:otherwise>
1759
+ 297
1760
+ </xsl:otherwise>
1761
+ </xsl:choose>
1730
1762
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
1731
1763
  25
1732
1764
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -1838,9 +1870,10 @@
1838
1870
  <xsl:value-of select="$titles/*[local-name() = $name][@lang = 'en']"/>
1839
1871
  </xsl:otherwise>
1840
1872
  </xsl:choose>
1841
- </xsl:template><xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable><xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable><xsl:variable name="en_chars" select="concat($lower,$upper,',.`1234567890-=~!@#$%^*()_+[]{}\|?/')"/><xsl:attribute-set name="root-style">
1873
+ </xsl:template><xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable><xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable><xsl:variable name="en_chars" select="concat($lower,$upper,',.`1234567890-=~!@#$%^*()_+[]{}\|?/')"/><xsl:variable name="font_noto_sans">Noto Sans, Noto Sans HK, Noto Sans JP, Noto Sans KR, Noto Sans SC, Noto Sans TC</xsl:variable><xsl:variable name="font_noto_sans_mono">Noto Sans Mono, Noto Sans Mono CJK HK, Noto Sans Mono CJK JP, Noto Sans Mono CJK KR, Noto Sans Mono CJK SC, Noto Sans Mono CJK TC</xsl:variable><xsl:variable name="font_noto_serif">Noto Serif, Noto Serif HK, Noto Serif JP, Noto Serif KR, Noto Serif SC, Noto Serif TC</xsl:variable><xsl:attribute-set name="root-style">
1842
1874
 
1843
- <xsl:attribute name="font-family">Times New Roman, STIX Two Math, Source Han Sans</xsl:attribute>
1875
+ <xsl:attribute name="font-family">Times New Roman, STIX Two Math, <xsl:value-of select="$font_noto_serif"/></xsl:attribute>
1876
+ <xsl:attribute name="font-family-generic">Serif</xsl:attribute>
1844
1877
  <xsl:attribute name="font-size">10.5pt</xsl:attribute>
1845
1878
 
1846
1879
 
@@ -1858,6 +1891,7 @@
1858
1891
 
1859
1892
 
1860
1893
 
1894
+
1861
1895
  </xsl:attribute-set><xsl:template name="insertRootStyle">
1862
1896
  <xsl:param name="root-style"/>
1863
1897
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
@@ -1869,17 +1903,60 @@
1869
1903
  </xsl:variable>
1870
1904
  <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
1871
1905
 
1906
+ <xsl:variable name="font_family_generic" select="$root-style_/root-style/@font-family-generic"/>
1907
+
1872
1908
  <xsl:for-each select="$root-style_/root-style/@*">
1909
+
1873
1910
  <xsl:choose>
1874
- <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
1911
+ <xsl:when test="local-name() = 'font-family-generic'"><!-- skip, it's using for determine 'sans' or 'serif' --></xsl:when>
1912
+ <xsl:when test="local-name() = 'font-family'">
1913
+
1914
+ <xsl:variable name="font_regional_prefix">
1915
+ <xsl:choose>
1916
+ <xsl:when test="$font_family_generic = 'Sans'">Noto Sans</xsl:when>
1917
+ <xsl:otherwise>Noto Serif</xsl:otherwise>
1918
+ </xsl:choose>
1919
+ </xsl:variable>
1920
+
1875
1921
  <xsl:attribute name="{local-name()}">
1876
- <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
1922
+
1923
+ <xsl:variable name="font_extended">
1924
+ <xsl:choose>
1925
+ <xsl:when test="$lang = 'zh'"><xsl:value-of select="$font_regional_prefix"/> SC</xsl:when>
1926
+ <xsl:when test="$lang = 'hk'"><xsl:value-of select="$font_regional_prefix"/> HK</xsl:when>
1927
+ <xsl:when test="$lang = 'jp'"><xsl:value-of select="$font_regional_prefix"/> JP</xsl:when>
1928
+ <xsl:when test="$lang = 'kr'"><xsl:value-of select="$font_regional_prefix"/> KR</xsl:when>
1929
+ <xsl:when test="$lang = 'sc'"><xsl:value-of select="$font_regional_prefix"/> SC</xsl:when>
1930
+ <xsl:when test="$lang = 'tc'"><xsl:value-of select="$font_regional_prefix"/> TC</xsl:when>
1931
+ </xsl:choose>
1932
+ </xsl:variable>
1933
+ <xsl:if test="normalize-space($font_extended) != ''">
1934
+ <xsl:value-of select="$font_regional_prefix"/><xsl:text>, </xsl:text>
1935
+ <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
1936
+ </xsl:if>
1937
+
1938
+ <xsl:value-of select="."/>
1939
+
1940
+ <xsl:if test="$additional_fonts != ''">
1941
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1942
+ </xsl:if>
1877
1943
  </xsl:attribute>
1878
1944
  </xsl:when>
1879
1945
  <xsl:otherwise>
1880
1946
  <xsl:copy-of select="."/>
1881
1947
  </xsl:otherwise>
1882
1948
  </xsl:choose>
1949
+
1950
+ <!-- <xsl:choose>
1951
+ <xsl:when test="local-name() = 'font-family'">
1952
+ <xsl:attribute name="{local-name()}">
1953
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
1954
+ </xsl:attribute>
1955
+ </xsl:when>
1956
+ <xsl:otherwise>
1957
+ <xsl:copy-of select="."/>
1958
+ </xsl:otherwise>
1959
+ </xsl:choose> -->
1883
1960
  </xsl:for-each>
1884
1961
  </xsl:template><xsl:attribute-set name="copyright-statement-style">
1885
1962
 
@@ -1953,7 +2030,8 @@
1953
2030
 
1954
2031
 
1955
2032
 
1956
- <xsl:attribute name="font-family">Courier New</xsl:attribute>
2033
+
2034
+ <xsl:attribute name="font-family">Courier New, <xsl:value-of select="$font_noto_sans_mono"/></xsl:attribute>
1957
2035
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
1958
2036
 
1959
2037
 
@@ -1994,6 +2072,7 @@
1994
2072
 
1995
2073
 
1996
2074
 
2075
+
1997
2076
  <xsl:attribute name="font-size">10pt</xsl:attribute>
1998
2077
  <xsl:attribute name="margin-top">8pt</xsl:attribute>
1999
2078
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
@@ -2006,6 +2085,7 @@
2006
2085
 
2007
2086
 
2008
2087
 
2088
+
2009
2089
  <xsl:attribute name="font-size">10pt</xsl:attribute>
2010
2090
  <xsl:attribute name="margin-top">8pt</xsl:attribute>
2011
2091
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
@@ -2041,6 +2121,7 @@
2041
2121
 
2042
2122
 
2043
2123
 
2124
+
2044
2125
 
2045
2126
 
2046
2127
 
@@ -2077,6 +2158,7 @@
2077
2158
 
2078
2159
  </xsl:attribute-set><xsl:variable name="table-border_">
2079
2160
 
2161
+
2080
2162
  </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-container-style">
2081
2163
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
2082
2164
  <xsl:attribute name="margin-right">0mm</xsl:attribute>
@@ -2091,6 +2173,7 @@
2091
2173
 
2092
2174
 
2093
2175
 
2176
+
2094
2177
  <xsl:attribute name="font-size">10pt</xsl:attribute>
2095
2178
  <xsl:attribute name="margin-top">12pt</xsl:attribute>
2096
2179
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
@@ -2121,6 +2204,7 @@
2121
2204
 
2122
2205
 
2123
2206
 
2207
+
2124
2208
  <xsl:attribute name="border">1.5pt solid black</xsl:attribute>
2125
2209
 
2126
2210
 
@@ -2138,6 +2222,7 @@
2138
2222
 
2139
2223
 
2140
2224
 
2225
+
2141
2226
 
2142
2227
 
2143
2228
  <xsl:attribute name="font-size">11pt</xsl:attribute>
@@ -2187,6 +2272,7 @@
2187
2272
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2188
2273
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2189
2274
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2275
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2190
2276
  <xsl:attribute name="display-align">center</xsl:attribute>
2191
2277
 
2192
2278
 
@@ -2207,6 +2293,8 @@
2207
2293
  <xsl:attribute name="display-align">center</xsl:attribute>
2208
2294
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2209
2295
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2296
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2297
+
2210
2298
 
2211
2299
 
2212
2300
 
@@ -2234,7 +2322,7 @@
2234
2322
 
2235
2323
 
2236
2324
 
2237
-
2325
+
2238
2326
 
2239
2327
  <xsl:attribute name="border-top">solid black 0pt</xsl:attribute>
2240
2328
 
@@ -2250,6 +2338,7 @@
2250
2338
 
2251
2339
 
2252
2340
 
2341
+
2253
2342
  <xsl:attribute name="font-size">9pt</xsl:attribute>
2254
2343
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2255
2344
 
@@ -2265,6 +2354,8 @@
2265
2354
 
2266
2355
 
2267
2356
 
2357
+
2358
+
2268
2359
  </xsl:attribute-set><xsl:attribute-set name="table-fn-number-style">
2269
2360
  <xsl:attribute name="font-size">80%</xsl:attribute>
2270
2361
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
@@ -2282,6 +2373,7 @@
2282
2373
 
2283
2374
 
2284
2375
 
2376
+
2285
2377
  </xsl:attribute-set><xsl:attribute-set name="fn-container-body-style">
2286
2378
  <xsl:attribute name="text-indent">0</xsl:attribute>
2287
2379
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -2301,7 +2393,8 @@
2301
2393
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
2302
2394
 
2303
2395
 
2304
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2396
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2397
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2305
2398
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2306
2399
 
2307
2400
 
@@ -2310,11 +2403,34 @@
2310
2403
 
2311
2404
 
2312
2405
 
2406
+
2313
2407
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
2314
2408
 
2315
2409
 
2316
2410
 
2317
2411
 
2412
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
2413
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2414
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2415
+
2416
+
2417
+
2418
+
2419
+
2420
+
2421
+
2422
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2423
+
2424
+
2425
+
2426
+
2427
+
2428
+
2429
+
2430
+
2431
+
2432
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2433
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2318
2434
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2319
2435
 
2320
2436
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -2354,6 +2470,7 @@
2354
2470
 
2355
2471
 
2356
2472
 
2473
+
2357
2474
 
2358
2475
 
2359
2476
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -2427,6 +2544,8 @@
2427
2544
 
2428
2545
 
2429
2546
 
2547
+ </xsl:attribute-set><xsl:attribute-set name="termnote-p-style">
2548
+
2430
2549
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
2431
2550
  <xsl:attribute name="margin-left">12mm</xsl:attribute>
2432
2551
  <xsl:attribute name="margin-right">12mm</xsl:attribute>
@@ -2475,6 +2594,7 @@
2475
2594
  </xsl:attribute-set><xsl:attribute-set name="figure-name-style">
2476
2595
 
2477
2596
 
2597
+
2478
2598
 
2479
2599
 
2480
2600
 
@@ -2517,6 +2637,7 @@
2517
2637
 
2518
2638
 
2519
2639
 
2640
+
2520
2641
  <xsl:attribute name="text-align">left</xsl:attribute>
2521
2642
  <xsl:attribute name="margin-left">25mm</xsl:attribute>
2522
2643
 
@@ -2543,20 +2664,20 @@
2543
2664
  </xsl:attribute-set><xsl:attribute-set name="figure-pseudocode-p-style">
2544
2665
 
2545
2666
  </xsl:attribute-set><xsl:attribute-set name="image-graphic-style">
2667
+ <xsl:attribute name="width">100%</xsl:attribute>
2668
+ <xsl:attribute name="content-height">100%</xsl:attribute>
2669
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
2546
2670
 
2547
2671
 
2548
- <xsl:attribute name="width">100%</xsl:attribute>
2549
2672
  <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
2550
- <xsl:attribute name="scaling">uniform</xsl:attribute>
2551
2673
 
2552
2674
 
2553
2675
 
2554
-
2555
-
2676
+
2556
2677
  </xsl:attribute-set><xsl:attribute-set name="tt-style">
2557
2678
 
2558
2679
 
2559
- <xsl:attribute name="font-family">Courier New</xsl:attribute>
2680
+ <xsl:attribute name="font-family">Courier New, <xsl:value-of select="$font_noto_sans_mono"/></xsl:attribute>
2560
2681
 
2561
2682
 
2562
2683
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-name-style">
@@ -2632,6 +2753,7 @@
2632
2753
 
2633
2754
 
2634
2755
 
2756
+
2635
2757
  <xsl:attribute name="provisional-distance-between-starts">7mm</xsl:attribute>
2636
2758
  <xsl:attribute name="margin-top">8pt</xsl:attribute>
2637
2759
 
@@ -2644,6 +2766,25 @@
2644
2766
 
2645
2767
 
2646
2768
 
2769
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
2770
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2771
+
2772
+
2773
+
2774
+
2775
+
2776
+
2777
+ <xsl:attribute name="margin-top">8pt</xsl:attribute>
2778
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2779
+
2780
+
2781
+
2782
+
2783
+
2784
+
2785
+
2786
+
2787
+
2647
2788
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
2648
2789
 
2649
2790
 
@@ -2691,6 +2832,7 @@
2691
2832
 
2692
2833
 
2693
2834
 
2835
+
2694
2836
  </xsl:attribute-set><xsl:attribute-set name="fn-body-style">
2695
2837
  <xsl:attribute name="font-weight">normal</xsl:attribute>
2696
2838
  <xsl:attribute name="font-style">normal</xsl:attribute>
@@ -2719,6 +2861,7 @@
2719
2861
 
2720
2862
 
2721
2863
 
2864
+
2722
2865
  </xsl:attribute-set><xsl:attribute-set name="fn-body-num-style">
2723
2866
  <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
2724
2867
 
@@ -2742,6 +2885,7 @@
2742
2885
 
2743
2886
 
2744
2887
 
2888
+
2745
2889
  </xsl:attribute-set><xsl:attribute-set name="admonition-style">
2746
2890
 
2747
2891
 
@@ -2751,6 +2895,7 @@
2751
2895
 
2752
2896
 
2753
2897
 
2898
+
2754
2899
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
2755
2900
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2756
2901
 
@@ -2761,6 +2906,9 @@
2761
2906
 
2762
2907
 
2763
2908
  </xsl:attribute-set><xsl:attribute-set name="admonition-container-style">
2909
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2910
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
2911
+
2764
2912
 
2765
2913
 
2766
2914
 
@@ -2798,6 +2946,7 @@
2798
2946
 
2799
2947
 
2800
2948
 
2949
+
2801
2950
  </xsl:attribute-set><xsl:attribute-set name="bibitem-normative-style">
2802
2951
 
2803
2952
 
@@ -2829,6 +2978,7 @@
2829
2978
 
2830
2979
 
2831
2980
 
2981
+
2832
2982
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2833
2983
 
2834
2984
 
@@ -2850,6 +3000,7 @@
2850
3000
 
2851
3001
 
2852
3002
 
3003
+
2853
3004
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2854
3005
 
2855
3006
 
@@ -2876,6 +3027,7 @@
2876
3027
 
2877
3028
 
2878
3029
 
3030
+
2879
3031
  <xsl:attribute name="font-size">8pt</xsl:attribute>
2880
3032
  <xsl:attribute name="baseline-shift">30%</xsl:attribute>
2881
3033
 
@@ -2897,6 +3049,7 @@
2897
3049
 
2898
3050
 
2899
3051
 
3052
+
2900
3053
  <xsl:attribute name="alignment-baseline">hanging</xsl:attribute>
2901
3054
  <xsl:attribute name="padding-right">3mm</xsl:attribute>
2902
3055
 
@@ -2918,6 +3071,7 @@
2918
3071
 
2919
3072
 
2920
3073
 
3074
+
2921
3075
  <xsl:attribute name="margin-bottom">4pt</xsl:attribute>
2922
3076
 
2923
3077
 
@@ -3040,13 +3194,13 @@
3040
3194
 
3041
3195
  </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">
3042
3196
  <xsl:variable name="nodes_preface_">
3043
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3197
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3044
3198
  <node id="{@id}"/>
3045
3199
  </xsl:for-each>
3046
3200
  </xsl:variable>
3047
3201
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
3048
3202
 
3049
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3203
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3050
3204
  <xsl:sort select="@displayorder" data-type="number"/>
3051
3205
 
3052
3206
  <!-- process Section's title -->
@@ -3112,7 +3266,7 @@
3112
3266
  </xsl:for-each>
3113
3267
  </figures>
3114
3268
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3115
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3269
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3116
3270
  <xsl:sort select="@displayorder" data-type="number"/>
3117
3271
  <xsl:apply-templates select="."/>
3118
3272
  </xsl:for-each>
@@ -3166,7 +3320,38 @@
3166
3320
  </xsl:template><xsl:template match="*[local-name()='br']">
3167
3321
  <xsl:value-of select="$linebreak"/>
3168
3322
  </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3169
- <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3323
+ <xsl:param name="split_keep-within-line"/>
3324
+
3325
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3326
+ <xsl:choose>
3327
+
3328
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3329
+ <xsl:variable name="sep">_</xsl:variable>
3330
+ <xsl:variable name="items">
3331
+ <xsl:call-template name="split">
3332
+ <xsl:with-param name="pText" select="."/>
3333
+ <xsl:with-param name="sep" select="$sep"/>
3334
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3335
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3336
+ </xsl:call-template>
3337
+ </xsl:variable>
3338
+ <xsl:for-each select="xalan:nodeset($items)/item">
3339
+ <xsl:choose>
3340
+ <xsl:when test=". = $sep">
3341
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3342
+ </xsl:when>
3343
+ <xsl:otherwise>
3344
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3345
+ </xsl:otherwise>
3346
+ </xsl:choose>
3347
+ </xsl:for-each>
3348
+ </xsl:when>
3349
+
3350
+ <xsl:otherwise>
3351
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3352
+ </xsl:otherwise>
3353
+
3354
+ </xsl:choose>
3170
3355
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3171
3356
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3172
3357
  <xsl:apply-templates/>
@@ -3258,9 +3443,14 @@
3258
3443
 
3259
3444
  <xsl:variable name="table">
3260
3445
 
3261
- <xsl:variable name="simple-table">
3262
- <xsl:call-template name="getSimpleTable"/>
3446
+ <xsl:variable name="simple-table">
3447
+ <xsl:call-template name="getSimpleTable">
3448
+ <xsl:with-param name="id" select="@id"/>
3449
+ </xsl:call-template>
3263
3450
  </xsl:variable>
3451
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3452
+
3453
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3264
3454
 
3265
3455
 
3266
3456
  <!-- Display table's name before table as standalone block -->
@@ -3279,7 +3469,23 @@
3279
3469
  </xsl:call-template>
3280
3470
  </xsl:if>
3281
3471
  </xsl:variable>
3282
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3472
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3473
+
3474
+ <!-- DEBUG -->
3475
+ <xsl:if test="$table_if_debug = 'true'">
3476
+ <fo:block font-size="60%">
3477
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3478
+ </fo:block>
3479
+ </xsl:if>
3480
+
3481
+
3482
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3483
+
3484
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3485
+ DEBUG
3486
+ colwidths=<xsl:copy-of select="$colwidths"/>
3487
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3488
+
3283
3489
 
3284
3490
 
3285
3491
  <xsl:variable name="margin-side">
@@ -3301,6 +3507,8 @@
3301
3507
 
3302
3508
 
3303
3509
 
3510
+
3511
+
3304
3512
 
3305
3513
 
3306
3514
 
@@ -3335,6 +3543,8 @@
3335
3543
 
3336
3544
 
3337
3545
 
3546
+
3547
+
3338
3548
  <xsl:if test="*[local-name()='thead']">
3339
3549
  <xsl:attribute name="border-top">1pt solid black</xsl:attribute>
3340
3550
  </xsl:if>
@@ -3344,9 +3554,17 @@
3344
3554
  </xsl:element>
3345
3555
  </xsl:variable>
3346
3556
 
3557
+ <xsl:if test="$isGenerateTableIF = 'true'">
3558
+ <!-- to determine start of table -->
3559
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3560
+ </xsl:if>
3347
3561
 
3348
3562
  <fo:table id="{@id}">
3349
3563
 
3564
+ <xsl:if test="$isGenerateTableIF = 'true'">
3565
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3566
+ </xsl:if>
3567
+
3350
3568
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3351
3569
  <xsl:attribute name="{local-name()}">
3352
3570
  <xsl:value-of select="."/>
@@ -3360,24 +3578,47 @@
3360
3578
 
3361
3579
 
3362
3580
  <xsl:choose>
3363
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3364
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3365
- <fo:table-column column-width="{@width}"/>
3366
- </xsl:for-each>
3581
+ <xsl:when test="$isGenerateTableIF = 'true'">
3582
+ <!-- generate IF for table widths -->
3583
+ <!-- example:
3584
+ <tr>
3585
+ <td valign="top" align="left" id="tab-symdu_1_1">
3586
+ <p>Symbol</p>
3587
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3588
+ </td>
3589
+ <td valign="top" align="left" id="tab-symdu_1_2">
3590
+ <p>Description</p>
3591
+ <word id="tab-symdu_1_2_word_1">Description</word>
3592
+ </td>
3593
+ </tr>
3594
+ -->
3595
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3596
+
3367
3597
  </xsl:when>
3368
3598
  <xsl:otherwise>
3369
- <xsl:call-template name="insertTableColumnWidth">
3370
- <xsl:with-param name="colwidths" select="$colwidths"/>
3371
- </xsl:call-template>
3372
- </xsl:otherwise>
3373
- </xsl:choose>
3374
3599
 
3375
- <xsl:choose>
3376
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3377
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3378
- </xsl:when>
3379
- <xsl:otherwise>
3380
- <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 -->
3600
+ <xsl:choose>
3601
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3602
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3603
+ <fo:table-column column-width="{@width}"/>
3604
+ </xsl:for-each>
3605
+ </xsl:when>
3606
+ <xsl:otherwise>
3607
+ <xsl:call-template name="insertTableColumnWidth">
3608
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3609
+ </xsl:call-template>
3610
+ </xsl:otherwise>
3611
+ </xsl:choose>
3612
+
3613
+ <xsl:choose>
3614
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3615
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3616
+ </xsl:when>
3617
+ <xsl:otherwise>
3618
+ <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 -->
3619
+ </xsl:otherwise>
3620
+ </xsl:choose>
3621
+
3381
3622
  </xsl:otherwise>
3382
3623
  </xsl:choose>
3383
3624
 
@@ -3455,25 +3696,31 @@
3455
3696
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name() = 'name']">
3456
3697
  <xsl:param name="continued"/>
3457
3698
  <xsl:if test="normalize-space() != ''">
3458
- <fo:block xsl:use-attribute-sets="table-name-style">
3459
-
3460
-
3461
-
3462
-
3699
+
3700
+
3463
3701
 
3464
- <xsl:choose>
3465
- <xsl:when test="$continued = 'true'">
3702
+ <fo:block xsl:use-attribute-sets="table-name-style">
3703
+
3466
3704
 
3467
- <xsl:apply-templates/>
3468
3705
 
3469
- </xsl:when>
3470
- <xsl:otherwise>
3471
- <xsl:apply-templates/>
3472
- </xsl:otherwise>
3473
- </xsl:choose>
3474
-
3706
+
3707
+
3708
+ <xsl:choose>
3709
+ <xsl:when test="$continued = 'true'">
3710
+
3711
+ <xsl:apply-templates/>
3712
+
3713
+ </xsl:when>
3714
+ <xsl:otherwise>
3715
+ <xsl:apply-templates/>
3716
+ </xsl:otherwise>
3717
+ </xsl:choose>
3718
+
3719
+
3720
+ </fo:block>
3721
+
3475
3722
 
3476
- </fo:block>
3723
+
3477
3724
  </xsl:if>
3478
3725
  </xsl:template><xsl:template name="calculate-columns-numbers">
3479
3726
  <xsl:param name="table-row"/>
@@ -3482,11 +3729,22 @@
3482
3729
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3483
3730
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3484
3731
  </xsl:template><xsl:template name="calculate-column-widths">
3732
+ <xsl:param name="table"/>
3733
+ <xsl:param name="cols-count"/>
3734
+
3735
+ <xsl:call-template name="calculate-column-widths-proportional">
3736
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3737
+ <xsl:with-param name="table" select="$table"/>
3738
+ </xsl:call-template>
3739
+
3740
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3485
3741
  <xsl:param name="table"/>
3486
3742
  <xsl:param name="cols-count"/>
3487
3743
  <xsl:param name="curr-col" select="1"/>
3488
3744
  <xsl:param name="width" select="0"/>
3489
3745
 
3746
+ <!-- table=<xsl:copy-of select="$table"/> -->
3747
+
3490
3748
  <xsl:if test="$curr-col &lt;= $cols-count">
3491
3749
  <xsl:variable name="widths">
3492
3750
  <xsl:choose>
@@ -3524,10 +3782,15 @@
3524
3782
  </xsl:for-each>
3525
3783
  </xsl:when>
3526
3784
  <xsl:otherwise>
3527
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3785
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3786
+
3787
+ <!-- <table><xsl:copy-of select="$table"/></table>
3788
+ -->
3789
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3528
3790
  <xsl:variable name="td_text">
3529
3791
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3530
3792
  </xsl:variable>
3793
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3531
3794
  <xsl:variable name="words">
3532
3795
  <xsl:variable name="string_with_added_zerospaces">
3533
3796
  <xsl:call-template name="add-zero-spaces-java">
@@ -3542,6 +3805,7 @@
3542
3805
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3543
3806
  </xsl:call-template>
3544
3807
  </xsl:variable>
3808
+ <!-- words=<xsl:copy-of select="$words"/> -->
3545
3809
  <xsl:variable name="max_length">
3546
3810
  <xsl:call-template name="max_length">
3547
3811
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
@@ -3566,6 +3830,8 @@
3566
3830
  </xsl:choose>
3567
3831
  </xsl:variable>
3568
3832
 
3833
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3834
+
3569
3835
  <column>
3570
3836
  <xsl:for-each select="xalan:nodeset($widths)//width">
3571
3837
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3574,33 +3840,271 @@
3574
3840
  </xsl:if>
3575
3841
  </xsl:for-each>
3576
3842
  </column>
3577
- <xsl:call-template name="calculate-column-widths">
3843
+ <xsl:call-template name="calculate-column-widths-proportional">
3578
3844
  <xsl:with-param name="cols-count" select="$cols-count"/>
3579
3845
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3580
3846
  <xsl:with-param name="table" select="$table"/>
3581
3847
  </xsl:call-template>
3582
3848
  </xsl:if>
3583
- </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
3849
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
3584
3850
  <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
3585
3851
  <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
3586
3852
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3853
+
3854
+ <!-- if all capitals english letters or digits -->
3855
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
3856
+ <xsl:call-template name="repeat">
3857
+ <xsl:with-param name="char" select="'X'"/>
3858
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
3859
+ </xsl:call-template>
3860
+ </xsl:if>
3587
3861
  </xsl:template><xsl:template match="text()" mode="td_text">
3588
3862
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3589
3863
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3590
3864
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3591
3865
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3592
3866
  <xsl:value-of select="@target"/>
3593
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3594
- <xsl:variable name="mathml">
3595
- <xsl:for-each select="*">
3596
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3597
- <xsl:copy-of select="."/>
3598
- </xsl:if>
3867
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
3868
+ <xsl:if test="$isGenerateTableIF = 'false'">
3869
+ <xsl:variable name="mathml_">
3870
+ <xsl:for-each select="*">
3871
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3872
+ <xsl:copy-of select="."/>
3873
+ </xsl:if>
3874
+ </xsl:for-each>
3875
+ </xsl:variable>
3876
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
3877
+
3878
+ <xsl:variable name="math_text">
3879
+ <xsl:value-of select="normalize-space($mathml)"/>
3880
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
3881
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
3882
+ </xsl:variable>
3883
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3884
+ </xsl:if>
3885
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
3886
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
3887
+
3888
+ <!-- via intermediate format -->
3889
+
3890
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
3891
+
3892
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
3893
+
3894
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
3895
+
3896
+ <!-- get current table id -->
3897
+ <xsl:variable name="table_id" select="@id"/>
3898
+ <!-- find table by id in the file 'table_widths' -->
3899
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
3900
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
3901
+
3902
+ <!-- table='<xsl:copy-of select="$table"/>' -->
3903
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
3904
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
3905
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
3906
+
3907
+ <xsl:variable name="table_with_cell_widths_">
3908
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
3909
+ </xsl:variable>
3910
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
3911
+
3912
+ <!-- <xsl:if test="$table_if_debug = 'true'">
3913
+ <xsl:copy-of select="$table_with_cell_widths"/>
3914
+ </xsl:if> -->
3915
+
3916
+
3917
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
3918
+
3919
+ <xsl:variable name="column_widths_">
3920
+ <!-- iteration of columns -->
3921
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
3922
+ <xsl:variable name="pos" select="position()"/>
3923
+ <column>
3924
+ <xsl:attribute name="width_max">
3925
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
3926
+ <xsl:sort select="." data-type="number" order="descending"/>
3927
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3928
+ </xsl:for-each>
3929
+ </xsl:attribute>
3930
+ <xsl:attribute name="width_min">
3931
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
3932
+ <xsl:sort select="." data-type="number" order="descending"/>
3933
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3934
+ </xsl:for-each>
3935
+ </xsl:attribute>
3936
+ </column>
3599
3937
  </xsl:for-each>
3600
3938
  </xsl:variable>
3939
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
3601
3940
 
3602
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3603
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3941
+ <!-- <column_widths>
3942
+ <xsl:copy-of select="$column_widths"/>
3943
+ </column_widths> -->
3944
+
3945
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
3946
+ <xsl:variable name="table_widths_">
3947
+ <table>
3948
+ <xsl:attribute name="width_max">
3949
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
3950
+ </xsl:attribute>
3951
+ <xsl:attribute name="width_min">
3952
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
3953
+ </xsl:attribute>
3954
+ </table>
3955
+ </xsl:variable>
3956
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
3957
+
3958
+ <xsl:variable name="page_width">
3959
+ <xsl:choose>
3960
+ <xsl:when test="$parent_table_page-width != ''">
3961
+ <xsl:value-of select="$parent_table_page-width"/>
3962
+ </xsl:when>
3963
+ <xsl:otherwise>
3964
+ <xsl:value-of select="@page-width"/>
3965
+ </xsl:otherwise>
3966
+ </xsl:choose>
3967
+ </xsl:variable>
3968
+
3969
+ <xsl:if test="$table_if_debug = 'true'">
3970
+ <table_width>
3971
+ <xsl:copy-of select="$table_widths"/>
3972
+ </table_width>
3973
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
3974
+ </xsl:if>
3975
+
3976
+
3977
+ <!-- There are three cases: -->
3978
+ <xsl:choose>
3979
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
3980
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
3981
+ <!-- call old algorithm -->
3982
+ <case1/>
3983
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
3984
+ <xsl:call-template name="calculate-column-widths-proportional">
3985
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3986
+ <xsl:with-param name="table" select="$table"/>
3987
+ </xsl:call-template> -->
3988
+ </xsl:when>
3989
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
3990
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
3991
+ <case2/>
3992
+ <autolayout/>
3993
+ <xsl:for-each select="$column_widths/column/@width_max">
3994
+ <column divider="100"><xsl:value-of select="."/></column>
3995
+ </xsl:for-each>
3996
+ </xsl:when>
3997
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
3998
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
3999
+ Lets also call D the difference between maximum and minimum width of the table.
4000
+ For each column, let d be the difference between maximum and minimum width of that column.
4001
+ Now set the column's width to the minimum width plus d times W over D.
4002
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
4003
+ <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)">
4004
+ <!-- difference between the available space and the minimum table width -->
4005
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
4006
+ <W><xsl:value-of select="$W"/></W>
4007
+ <!-- difference between maximum and minimum width of the table -->
4008
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
4009
+ <D><xsl:value-of select="$D"/></D>
4010
+ <case3/>
4011
+ <autolayout/>
4012
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
4013
+ <split_keep-within-line>true</split_keep-within-line>
4014
+ </xsl:if>
4015
+ <xsl:for-each select="$column_widths/column">
4016
+ <!-- difference between maximum and minimum width of that column. -->
4017
+ <xsl:variable name="d" select="@width_max - @width_min"/>
4018
+ <d><xsl:value-of select="$d"/></d>
4019
+ <width_min><xsl:value-of select="@width_min"/></width_min>
4020
+ <e><xsl:value-of select="$d * $W div $D"/></e>
4021
+ <!-- set the column's width to the minimum width plus d times W over D. -->
4022
+ <column divider="100">
4023
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4024
+ </column>
4025
+ </xsl:for-each>
4026
+
4027
+ </xsl:when>
4028
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
4029
+ </xsl:choose>
4030
+
4031
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
4032
+
4033
+ <!-- if nested 'dl' or 'table' -->
4034
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
4035
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
4036
+
4037
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
4038
+
4039
+ <xsl:variable name="parent_table_page-width_">
4040
+ <xsl:if test="$parent_table_id != ''">
4041
+ <!-- determine column number in the parent table -->
4042
+ <xsl:variable name="parent_table_column_number">
4043
+ <xsl:choose>
4044
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
4045
+ <xsl:otherwise> <!-- parent is table -->
4046
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
4047
+ </xsl:otherwise>
4048
+ </xsl:choose>
4049
+ </xsl:variable>
4050
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
4051
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
4052
+ </xsl:if>
4053
+ </xsl:variable>
4054
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
4055
+
4056
+ <!-- get current table id -->
4057
+ <xsl:variable name="table_id" select="@id"/>
4058
+
4059
+ <xsl:choose>
4060
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
4061
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
4062
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
4063
+ </xsl:when>
4064
+ <xsl:otherwise>
4065
+ <!-- recalculate columns width based on parent table width -->
4066
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
4067
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
4068
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
4069
+ </xsl:call-template>
4070
+ </xsl:for-each>
4071
+ </xsl:otherwise>
4072
+ </xsl:choose>
4073
+
4074
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
4075
+ <xsl:copy>
4076
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
4077
+ </xsl:copy>
4078
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
4079
+ <xsl:copy>
4080
+ <xsl:copy-of select="@*"/>
4081
+
4082
+ <!-- The maximum width is given by the widest line. -->
4083
+ <xsl:attribute name="width_max">
4084
+ <xsl:for-each select="p_len">
4085
+ <xsl:sort select="." data-type="number" order="descending"/>
4086
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4087
+ </xsl:for-each>
4088
+ </xsl:attribute>
4089
+
4090
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4091
+ <xsl:variable name="width_min">
4092
+ <xsl:for-each select="word_len">
4093
+ <xsl:sort select="." data-type="number" order="descending"/>
4094
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4095
+ </xsl:for-each>
4096
+ </xsl:variable>
4097
+ <xsl:attribute name="width_min">
4098
+ <xsl:value-of select="$width_min"/>
4099
+ </xsl:attribute>
4100
+
4101
+ <xsl:if test="$width_min = 0">
4102
+ <xsl:attribute name="width_min">1</xsl:attribute>
4103
+ </xsl:if>
4104
+
4105
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
4106
+
4107
+ </xsl:copy>
3604
4108
  </xsl:template><xsl:template match="*[local-name()='thead']">
3605
4109
  <xsl:param name="cols-count"/>
3606
4110
  <fo:table-header>
@@ -3618,19 +4122,25 @@
3618
4122
  <fo:table-row>
3619
4123
  <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
3620
4124
 
3621
- <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
3622
- <xsl:with-param name="continued">true</xsl:with-param>
3623
- </xsl:apply-templates>
3624
4125
 
3625
4126
 
3626
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
3627
- <xsl:call-template name="table_name_fn_display"/>
3628
- </xsl:for-each>
4127
+
4128
+ <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
4129
+ <xsl:with-param name="continued">true</xsl:with-param>
4130
+ </xsl:apply-templates>
4131
+
4132
+
4133
+ <xsl:for-each select="ancestor::*[local-name()='table'][1]">
4134
+ <xsl:call-template name="table_name_fn_display"/>
4135
+ </xsl:for-each>
3629
4136
 
3630
- <fo:block text-align="right" font-style="italic">
3631
- <xsl:text> </xsl:text>
3632
- <fo:retrieve-table-marker retrieve-class-name="table_continued"/>
3633
- </fo:block>
4137
+ <fo:block text-align="right" font-style="italic">
4138
+ <xsl:text> </xsl:text>
4139
+ <fo:retrieve-table-marker retrieve-class-name="table_continued"/>
4140
+ </fo:block>
4141
+
4142
+
4143
+
3634
4144
 
3635
4145
 
3636
4146
  </fo:table-cell>
@@ -3698,6 +4208,7 @@
3698
4208
  </xsl:for-each>
3699
4209
  </xsl:when>
3700
4210
  <xsl:otherwise>
4211
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
3701
4212
  <xsl:call-template name="insertTableColumnWidth">
3702
4213
  <xsl:with-param name="colwidths" select="$colwidths"/>
3703
4214
  </xsl:call-template>
@@ -3732,7 +4243,10 @@
3732
4243
 
3733
4244
 
3734
4245
  <!-- fn processing -->
3735
- <xsl:call-template name="table_fn_display"/>
4246
+
4247
+ <xsl:call-template name="table_fn_display"/>
4248
+
4249
+
3736
4250
 
3737
4251
  <!-- for PAS display Notes after footnotes -->
3738
4252
 
@@ -3742,6 +4256,9 @@
3742
4256
  </fo:table-body>
3743
4257
 
3744
4258
  </fo:table>
4259
+
4260
+
4261
+
3745
4262
  </xsl:if>
3746
4263
  </xsl:template><xsl:template match="*[local-name()='tbody']">
3747
4264
 
@@ -3822,6 +4339,52 @@
3822
4339
 
3823
4340
  </fo:table-body>
3824
4341
 
4342
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4343
+ <xsl:param name="table_or_dl">table</xsl:param>
4344
+ <xsl:apply-templates mode="process_table-if">
4345
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4346
+ </xsl:apply-templates>
4347
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4348
+ <xsl:param name="table_or_dl">table</xsl:param>
4349
+
4350
+ <fo:table-body>
4351
+ <xsl:for-each select="*[local-name() = 'tr']">
4352
+ <xsl:variable name="col_count" select="count(*)"/>
4353
+
4354
+ <!-- iteration for each tr/td -->
4355
+
4356
+ <xsl:choose>
4357
+ <xsl:when test="$table_or_dl = 'table'">
4358
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4359
+ <fo:table-row number-columns-spanned="{$col_count}">
4360
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4361
+ <xsl:call-template name="td"/>
4362
+ </fo:table-row>
4363
+ </xsl:for-each>
4364
+ </xsl:when>
4365
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4366
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4367
+ <xsl:variable name="is_dt" select="position() = 1"/>
4368
+
4369
+ <xsl:for-each select="*">
4370
+ <!-- <test><xsl:copy-of select="."/></test> -->
4371
+ <fo:table-row number-columns-spanned="{$col_count}">
4372
+ <xsl:choose>
4373
+ <xsl:when test="$is_dt">
4374
+ <xsl:call-template name="insert_dt_cell"/>
4375
+ </xsl:when>
4376
+ <xsl:otherwise>
4377
+ <xsl:call-template name="insert_dd_cell"/>
4378
+ </xsl:otherwise>
4379
+ </xsl:choose>
4380
+ </fo:table-row>
4381
+ </xsl:for-each>
4382
+ </xsl:for-each>
4383
+ </xsl:otherwise>
4384
+ </xsl:choose>
4385
+
4386
+ </xsl:for-each>
4387
+ </fo:table-body>
3825
4388
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3826
4389
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3827
4390
 
@@ -3840,6 +4403,9 @@
3840
4403
  </xsl:choose>
3841
4404
 
3842
4405
 
4406
+
4407
+
4408
+
3843
4409
 
3844
4410
 
3845
4411
  <xsl:call-template name="setTableRowAttributes"/>
@@ -3859,6 +4425,8 @@
3859
4425
 
3860
4426
 
3861
4427
 
4428
+
4429
+
3862
4430
  <xsl:call-template name="setTableRowAttributes"/>
3863
4431
  <xsl:apply-templates/>
3864
4432
  </fo:table-row>
@@ -3919,7 +4487,7 @@
3919
4487
  </xsl:choose>
3920
4488
  </xsl:attribute>
3921
4489
  </xsl:if>
3922
- </xsl:template><xsl:template match="*[local-name()='td']">
4490
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
3923
4491
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
3924
4492
  <xsl:call-template name="setTextAlignment">
3925
4493
  <xsl:with-param name="default">left</xsl:with-param>
@@ -3940,6 +4508,8 @@
3940
4508
 
3941
4509
 
3942
4510
 
4511
+
4512
+
3943
4513
 
3944
4514
 
3945
4515
  <xsl:if test="count(*) = 1 and (local-name(*[1]) = 'stem' or local-name(*[1]) = 'figure')">
@@ -3960,11 +4530,24 @@
3960
4530
 
3961
4531
  <xsl:call-template name="setTableCellAttributes"/>
3962
4532
 
4533
+ <xsl:if test="$isGenerateTableIF = 'true'">
4534
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4535
+ <xsl:attribute name="text-align">left</xsl:attribute>
4536
+ </xsl:if>
4537
+
3963
4538
  <fo:block>
3964
4539
 
4540
+ <xsl:if test="$isGenerateTableIF = 'true'">
4541
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4542
+ </xsl:if>
4543
+
4544
+
3965
4545
 
3966
4546
 
3967
4547
  <xsl:apply-templates/>
4548
+
4549
+ <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"/> -->
4550
+
3968
4551
  </fo:block>
3969
4552
  </fo:table-cell>
3970
4553
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -4005,7 +4588,11 @@
4005
4588
 
4006
4589
  <xsl:variable name="gen_id" select="generate-id(.)"/>
4007
4590
  <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
4008
- <xsl:variable name="reference" select="@reference"/>
4591
+ <xsl:variable name="reference_">
4592
+ <xsl:value-of select="@reference"/>
4593
+ <xsl:if test="normalize-space(@reference) = ''"><xsl:value-of select="$gen_id"/></xsl:if>
4594
+ </xsl:variable>
4595
+ <xsl:variable name="reference" select="normalize-space($reference_)"/>
4009
4596
  <!-- fn sequence number in document -->
4010
4597
  <xsl:variable name="current_fn_number">
4011
4598
  <xsl:choose>
@@ -4080,7 +4667,7 @@
4080
4667
  <xsl:copy-of select="node()"/>
4081
4668
  </fn>
4082
4669
  </xsl:for-each>
4083
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
4670
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
4084
4671
  <xsl:sort select="@displayorder" data-type="number"/>
4085
4672
  <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4086
4673
  <!-- copy unique fn -->
@@ -4161,9 +4748,9 @@
4161
4748
  <!-- current hierarchy is 'figure' element -->
4162
4749
  <xsl:variable name="following_dl_colwidths">
4163
4750
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4164
- <xsl:variable name="html-table">
4165
- <xsl:variable name="doc_ns">
4166
-
4751
+ <xsl:variable name="simple-table">
4752
+ <!-- <xsl:variable name="doc_ns">
4753
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4167
4754
  </xsl:variable>
4168
4755
  <xsl:variable name="ns">
4169
4756
  <xsl:choose>
@@ -4174,7 +4761,7 @@
4174
4761
  <xsl:value-of select="substring-before(name(/*), '-')"/>
4175
4762
  </xsl:otherwise>
4176
4763
  </xsl:choose>
4177
- </xsl:variable>
4764
+ </xsl:variable> -->
4178
4765
 
4179
4766
  <xsl:for-each select="*[local-name() = 'dl'][1]">
4180
4767
  <tbody>
@@ -4185,7 +4772,7 @@
4185
4772
 
4186
4773
  <xsl:call-template name="calculate-column-widths">
4187
4774
  <xsl:with-param name="cols-count" select="2"/>
4188
- <xsl:with-param name="table" select="$html-table"/>
4775
+ <xsl:with-param name="table" select="$simple-table"/>
4189
4776
  </xsl:call-template>
4190
4777
 
4191
4778
  </xsl:if>
@@ -4379,12 +4966,31 @@
4379
4966
 
4380
4967
 
4381
4968
 
4969
+
4970
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
4971
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4972
+ </xsl:if>
4973
+
4382
4974
  <fo:block>
4383
4975
 
4384
4976
 
4385
4977
 
4386
4978
 
4979
+ <xsl:apply-templates select="*[local-name() = 'name']">
4980
+ <xsl:with-param name="process">true</xsl:with-param>
4981
+ </xsl:apply-templates>
4982
+
4983
+ <xsl:if test="$isGenerateTableIF = 'true'">
4984
+ <!-- to determine start of table -->
4985
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
4986
+ </xsl:if>
4987
+
4387
4988
  <fo:table width="95%" table-layout="fixed">
4989
+
4990
+ <xsl:if test="$isGenerateTableIF = 'true'">
4991
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
4992
+ </xsl:if>
4993
+
4388
4994
 
4389
4995
  <xsl:choose>
4390
4996
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4393,69 +4999,173 @@
4393
4999
 
4394
5000
  </xsl:when>
4395
5001
  </xsl:choose>
4396
- <!-- create virtual html table for dl/[dt and dd] -->
4397
- <xsl:variable name="html-table">
4398
- <xsl:variable name="doc_ns">
5002
+
5003
+
5004
+
5005
+ <xsl:choose>
5006
+ <xsl:when test="$isGenerateTableIF = 'true'">
5007
+ <!-- generate IF for table widths -->
5008
+ <!-- example:
5009
+ <tr>
5010
+ <td valign="top" align="left" id="tab-symdu_1_1">
5011
+ <p>Symbol</p>
5012
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
5013
+ </td>
5014
+ <td valign="top" align="left" id="tab-symdu_1_2">
5015
+ <p>Description</p>
5016
+ <word id="tab-symdu_1_2_word_1">Description</word>
5017
+ </td>
5018
+ </tr>
5019
+ -->
4399
5020
 
4400
- </xsl:variable>
4401
- <xsl:variable name="ns">
4402
- <xsl:choose>
4403
- <xsl:when test="normalize-space($doc_ns) != ''">
4404
- <xsl:value-of select="normalize-space($doc_ns)"/>
4405
- </xsl:when>
4406
- <xsl:otherwise>
4407
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4408
- </xsl:otherwise>
4409
- </xsl:choose>
4410
- </xsl:variable>
4411
- <tbody>
4412
- <xsl:apply-templates mode="dl"/>
4413
- </tbody>
4414
- </xsl:variable>
4415
- <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
4416
- <xsl:variable name="colwidths">
4417
- <xsl:call-template name="calculate-column-widths">
4418
- <xsl:with-param name="cols-count" select="2"/>
4419
- <xsl:with-param name="table" select="$html-table"/>
4420
- </xsl:call-template>
4421
- </xsl:variable>
4422
- <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
4423
- <xsl:variable name="maxlength_dt">
4424
- <xsl:call-template name="getMaxLength_dt"/>
4425
- </xsl:variable>
4426
- <xsl:variable name="isContainsKeepTogetherTag_">
4427
- false
4428
- </xsl:variable>
4429
- <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
4430
- <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4431
- <xsl:call-template name="setColumnWidth_dl">
4432
- <xsl:with-param name="colwidths" select="$colwidths"/>
4433
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4434
- <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
4435
- </xsl:call-template>
5021
+ <!-- create virtual html table for dl/[dt and dd] -->
5022
+ <xsl:variable name="simple-table">
5023
+
5024
+ <xsl:variable name="dl_table">
5025
+ <tbody>
5026
+ <xsl:apply-templates mode="dl_if">
5027
+ <xsl:with-param name="id" select="@id"/>
5028
+ </xsl:apply-templates>
5029
+ </tbody>
5030
+ </xsl:variable>
5031
+
5032
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
5033
+
5034
+ <!-- Step: replace <br/> to <p>...</p> -->
5035
+ <xsl:variable name="table_without_br">
5036
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
5037
+ </xsl:variable>
5038
+
5039
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
5040
+
5041
+ <!-- Step: add id to each cell -->
5042
+ <!-- add <word>...</word> for each word, image, math -->
5043
+ <xsl:variable name="simple-table-id">
5044
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
5045
+ <xsl:with-param name="id" select="@id"/>
5046
+ </xsl:apply-templates>
5047
+ </xsl:variable>
5048
+
5049
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
5050
+
5051
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5052
+
5053
+ </xsl:variable>
5054
+
5055
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
5056
+
5057
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
5058
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
5059
+ </xsl:apply-templates>
5060
+
5061
+ </xsl:when>
5062
+ <xsl:otherwise>
4436
5063
 
4437
- <fo:table-body>
4438
- <xsl:apply-templates>
4439
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4440
- </xsl:apply-templates>
4441
- </fo:table-body>
5064
+ <xsl:variable name="simple-table">
5065
+
5066
+ <xsl:variable name="dl_table">
5067
+ <tbody>
5068
+ <xsl:apply-templates mode="dl">
5069
+ <xsl:with-param name="id" select="@id"/>
5070
+ </xsl:apply-templates>
5071
+ </tbody>
5072
+ </xsl:variable>
5073
+
5074
+ <xsl:copy-of select="$dl_table"/>
5075
+ </xsl:variable>
5076
+
5077
+ <xsl:variable name="colwidths">
5078
+ <xsl:call-template name="calculate-column-widths">
5079
+ <xsl:with-param name="cols-count" select="2"/>
5080
+ <xsl:with-param name="table" select="$simple-table"/>
5081
+ </xsl:call-template>
5082
+ </xsl:variable>
5083
+
5084
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
5085
+ DEBUG
5086
+ colwidths=<xsl:copy-of select="$colwidths"/>
5087
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
5088
+
5089
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
5090
+
5091
+ <xsl:variable name="maxlength_dt">
5092
+ <xsl:call-template name="getMaxLength_dt"/>
5093
+ </xsl:variable>
5094
+
5095
+ <xsl:variable name="isContainsKeepTogetherTag_">
5096
+ false
5097
+ </xsl:variable>
5098
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
5099
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
5100
+
5101
+
5102
+ <xsl:call-template name="setColumnWidth_dl">
5103
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5104
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5105
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
5106
+ </xsl:call-template>
5107
+
5108
+ <fo:table-body>
5109
+
5110
+ <!-- DEBUG -->
5111
+ <xsl:if test="$table_if_debug = 'true'">
5112
+ <fo:table-row>
5113
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
5114
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5115
+ </fo:table-cell>
5116
+ </fo:table-row>
5117
+ </xsl:if>
5118
+
5119
+ <xsl:apply-templates>
5120
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
5121
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
5122
+ </xsl:apply-templates>
5123
+
5124
+ </fo:table-body>
5125
+ </xsl:otherwise>
5126
+ </xsl:choose>
4442
5127
  </fo:table>
4443
5128
  </fo:block>
4444
5129
  </fo:block>
4445
5130
  </xsl:if> <!-- END: a few components -->
4446
5131
  </fo:block-container>
4447
5132
  </fo:block-container>
5133
+
5134
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
5135
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
5136
+ </xsl:if>
5137
+
5138
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
5139
+ <xsl:param name="process">false</xsl:param>
5140
+ <xsl:if test="$process = 'true'">
5141
+ <fo:block xsl:use-attribute-sets="dl-name-style">
5142
+ <xsl:apply-templates/>
5143
+ </fo:block>
5144
+ </xsl:if>
4448
5145
  </xsl:template><xsl:template name="setColumnWidth_dl">
4449
5146
  <xsl:param name="colwidths"/>
4450
5147
  <xsl:param name="maxlength_dt"/>
4451
5148
  <xsl:param name="isContainsKeepTogetherTag"/>
5149
+
5150
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
5151
+
4452
5152
  <xsl:choose>
5153
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5154
+ <xsl:call-template name="insertTableColumnWidth">
5155
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5156
+ </xsl:call-template>
5157
+ </xsl:when>
4453
5158
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4454
5159
  <fo:table-column column-width="50%"/>
4455
5160
  <fo:table-column column-width="50%"/>
4456
5161
  </xsl:when>
4457
5162
  <xsl:otherwise>
4458
5163
  <xsl:choose>
5164
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5165
+ <xsl:call-template name="insertTableColumnWidth">
5166
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5167
+ </xsl:call-template>
5168
+ </xsl:when>
4459
5169
  <xsl:when test="$isContainsKeepTogetherTag">
4460
5170
  <xsl:call-template name="insertTableColumnWidth">
4461
5171
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4500,13 +5210,19 @@
4500
5210
  </xsl:choose>
4501
5211
  </xsl:template><xsl:template name="insertTableColumnWidth">
4502
5212
  <xsl:param name="colwidths"/>
5213
+
4503
5214
  <xsl:for-each select="xalan:nodeset($colwidths)//column">
4504
5215
  <xsl:choose>
4505
5216
  <xsl:when test=". = 1 or . = 0">
4506
5217
  <fo:table-column column-width="proportional-column-width(2)"/>
4507
5218
  </xsl:when>
4508
5219
  <xsl:otherwise>
4509
- <fo:table-column column-width="proportional-column-width({.})"/>
5220
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
5221
+ <xsl:variable name="divider">
5222
+ <xsl:value-of select="@divider"/>
5223
+ <xsl:if test="not(@divider)">1</xsl:if>
5224
+ </xsl:variable>
5225
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4510
5226
  </xsl:otherwise>
4511
5227
  </xsl:choose>
4512
5228
  </xsl:for-each>
@@ -4568,65 +5284,157 @@
4568
5284
  </fo:table-cell>
4569
5285
  </fo:table-row>
4570
5286
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
5287
+ <xsl:param name="id"/>
5288
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4571
5289
  <tr>
4572
5290
  <td>
5291
+ <xsl:attribute name="id">
5292
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5293
+ </xsl:attribute>
4573
5294
  <xsl:apply-templates/>
4574
5295
  </td>
4575
5296
  <td>
5297
+ <xsl:attribute name="id">
5298
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5299
+ </xsl:attribute>
4576
5300
 
4577
5301
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4578
5302
  <xsl:with-param name="process">true</xsl:with-param>
4579
5303
  </xsl:apply-templates>
4580
-
4581
- </td>
4582
- </tr>
4583
-
4584
- </xsl:template><xsl:template match="*[local-name()='dt']">
4585
- <xsl:param name="key_iso"/>
4586
-
4587
- <fo:table-row xsl:use-attribute-sets="dt-row-style">
4588
- <fo:table-cell>
5304
+
5305
+ </td>
5306
+ </tr>
5307
+
5308
+ </xsl:template><xsl:template match="*[local-name()='dt']">
5309
+ <xsl:param name="key_iso"/>
5310
+ <xsl:param name="split_keep-within-line"/>
5311
+
5312
+ <fo:table-row xsl:use-attribute-sets="dt-row-style">
5313
+ <xsl:call-template name="insert_dt_cell">
5314
+ <xsl:with-param name="key_iso" select="$key_iso"/>
5315
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5316
+ </xsl:call-template>
5317
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
5318
+ <xsl:call-template name="insert_dd_cell">
5319
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5320
+ </xsl:call-template>
5321
+ </xsl:for-each>
5322
+ </fo:table-row>
5323
+ </xsl:template><xsl:template name="insert_dt_cell">
5324
+ <xsl:param name="key_iso"/>
5325
+ <xsl:param name="split_keep-within-line"/>
5326
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
5327
+
5328
+ <xsl:if test="$isGenerateTableIF = 'true'">
5329
+ <!-- border is mandatory, to calculate real width -->
5330
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5331
+ <xsl:attribute name="text-align">left</xsl:attribute>
5332
+ </xsl:if>
5333
+
5334
+
5335
+ <fo:block xsl:use-attribute-sets="dt-block-style">
5336
+ <xsl:copy-of select="@id"/>
5337
+
5338
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5339
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5340
+ </xsl:if>
5341
+
5342
+
5343
+
5344
+ <xsl:apply-templates>
5345
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5346
+ </xsl:apply-templates>
5347
+
5348
+ <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"/> -->
5349
+
5350
+ </fo:block>
5351
+ </fo:table-cell>
5352
+ </xsl:template><xsl:template name="insert_dd_cell">
5353
+ <xsl:param name="split_keep-within-line"/>
5354
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5355
+
5356
+ <xsl:if test="$isGenerateTableIF = 'true'">
5357
+ <!-- border is mandatory, to calculate real width -->
5358
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5359
+ </xsl:if>
5360
+
5361
+ <fo:block>
5362
+
5363
+ <xsl:if test="$isGenerateTableIF = 'true'">
5364
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5365
+ </xsl:if>
5366
+
5367
+
5368
+
5369
+ <xsl:choose>
5370
+ <xsl:when test="$isGenerateTableIF = 'true'">
5371
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5372
+ <xsl:with-param name="process">true</xsl:with-param>
5373
+ </xsl:apply-templates>
5374
+ </xsl:when>
5375
+ <xsl:otherwise>
5376
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5377
+ <xsl:with-param name="process">true</xsl:with-param>
5378
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5379
+ </xsl:apply-templates>
5380
+ </xsl:otherwise>
4589
5381
 
4590
- <fo:block xsl:use-attribute-sets="dt-style">
4591
- <xsl:copy-of select="@id"/>
4592
-
4593
- <xsl:if test="normalize-space($key_iso) = 'true'">
4594
- <xsl:attribute name="margin-top">0</xsl:attribute>
4595
- </xsl:if>
4596
-
4597
-
4598
-
4599
- <xsl:apply-templates/>
4600
- </fo:block>
4601
- </fo:table-cell>
4602
- <fo:table-cell>
4603
- <fo:block>
4604
-
4605
-
4606
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4607
- <xsl:with-param name="process">true</xsl:with-param>
4608
- </xsl:apply-templates>
4609
- </fo:block>
4610
- </fo:table-cell>
4611
- </fo:table-row>
5382
+ </xsl:choose>
5383
+
5384
+ <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"/> -->
5385
+
5386
+ </fo:block>
5387
+ </fo:table-cell>
4612
5388
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4613
5389
  <xsl:apply-templates/>
4614
5390
  </xsl:template><xsl:template match="*[local-name()='dd']">
4615
5391
  <xsl:param name="process">false</xsl:param>
5392
+ <xsl:param name="split_keep-within-line"/>
4616
5393
  <xsl:if test="$process = 'true'">
4617
5394
  <xsl:apply-templates select="@language"/>
4618
- <xsl:apply-templates/>
5395
+ <xsl:apply-templates>
5396
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5397
+ </xsl:apply-templates>
4619
5398
  </xsl:if>
4620
5399
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4621
5400
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4622
- </xsl:template><xsl:template match="*[local-name()='em']">
5401
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5402
+ <xsl:param name="id"/>
5403
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5404
+ <tr>
5405
+ <td>
5406
+ <xsl:copy-of select="node()"/>
5407
+ </td>
5408
+ <td>
5409
+
5410
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
5411
+
5412
+ <!-- get paragraphs from nested 'dl' -->
5413
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
5414
+
5415
+
5416
+ </td>
5417
+ </tr>
5418
+
5419
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
5420
+ <xsl:for-each select="*[local-name() = 'dt']">
5421
+ <p>
5422
+ <xsl:copy-of select="node()"/>
5423
+ <xsl:text> </xsl:text>
5424
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
5425
+ </p>
5426
+ </xsl:for-each>
5427
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
4623
5428
  <fo:inline font-style="italic">
4624
5429
  <xsl:apply-templates/>
4625
5430
  </fo:inline>
4626
5431
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5432
+ <xsl:param name="split_keep-within-line"/>
4627
5433
  <fo:inline font-weight="bold">
4628
5434
 
4629
- <xsl:apply-templates/>
5435
+ <xsl:apply-templates>
5436
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5437
+ </xsl:apply-templates>
4630
5438
  </fo:inline>
4631
5439
  </xsl:template><xsl:template match="*[local-name()='padding']">
4632
5440
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4647,7 +5455,7 @@
4647
5455
 
4648
5456
 
4649
5457
 
4650
-
5458
+ <!-- 10 -->
4651
5459
 
4652
5460
  10
4653
5461
 
@@ -4827,6 +5635,10 @@
4827
5635
  <xsl:param name="text"/>
4828
5636
  <xsl:param name="separator" select="' '"/>
4829
5637
  <xsl:choose>
5638
+
5639
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5640
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5641
+ </xsl:when>
4830
5642
  <xsl:when test="not(contains($text, $separator))">
4831
5643
  <word>
4832
5644
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
@@ -4871,13 +5683,66 @@
4871
5683
  </xsl:when>
4872
5684
  <xsl:otherwise>
4873
5685
  <word>
4874
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5686
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5687
+ <xsl:choose>
5688
+ <xsl:when test="$isGenerateTableIF = 'true'">
5689
+ <xsl:value-of select="$word"/>
5690
+ </xsl:when>
5691
+ <xsl:otherwise>
5692
+ <xsl:value-of select="string-length($word)"/>
5693
+ </xsl:otherwise>
5694
+ </xsl:choose>
4875
5695
  </word>
4876
5696
  <xsl:call-template name="tokenize">
4877
5697
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
4878
5698
  </xsl:call-template>
4879
5699
  </xsl:otherwise>
4880
5700
  </xsl:choose>
5701
+ </xsl:template><xsl:template name="tokenize_with_tags">
5702
+ <xsl:param name="tags"/>
5703
+ <xsl:param name="text"/>
5704
+ <xsl:param name="separator" select="' '"/>
5705
+ <xsl:choose>
5706
+
5707
+ <xsl:when test="not(contains($text, $separator))">
5708
+ <word>
5709
+ <xsl:call-template name="enclose_text_in_tags">
5710
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5711
+ <xsl:with-param name="tags" select="$tags"/>
5712
+ </xsl:call-template>
5713
+ </word>
5714
+ </xsl:when>
5715
+ <xsl:otherwise>
5716
+ <word>
5717
+ <xsl:call-template name="enclose_text_in_tags">
5718
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5719
+ <xsl:with-param name="tags" select="$tags"/>
5720
+ </xsl:call-template>
5721
+ </word>
5722
+ <xsl:call-template name="tokenize_with_tags">
5723
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5724
+ </xsl:call-template>
5725
+ </xsl:otherwise>
5726
+ </xsl:choose>
5727
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5728
+ <xsl:param name="text"/>
5729
+ <xsl:param name="tags"/>
5730
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5731
+
5732
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5733
+
5734
+ <xsl:choose>
5735
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5736
+ <xsl:otherwise>
5737
+ <xsl:element name="{$tag_name}">
5738
+ <xsl:call-template name="enclose_text_in_tags">
5739
+ <xsl:with-param name="text" select="$text"/>
5740
+ <xsl:with-param name="tags" select="$tags"/>
5741
+ <xsl:with-param name="num" select="$num + 1"/>
5742
+ </xsl:call-template>
5743
+ </xsl:element>
5744
+ </xsl:otherwise>
5745
+ </xsl:choose>
4881
5746
  </xsl:template><xsl:template name="max_length">
4882
5747
  <xsl:param name="words"/>
4883
5748
  <xsl:for-each select="$words//word">
@@ -4978,12 +5843,19 @@
4978
5843
  </xsl:otherwise>
4979
5844
  </xsl:choose>
4980
5845
  </xsl:template><xsl:template name="getSimpleTable">
5846
+ <xsl:param name="id"/>
5847
+
4981
5848
  <xsl:variable name="simple-table">
4982
5849
 
5850
+ <!-- Step 0. replace <br/> to <p>...</p> -->
5851
+ <xsl:variable name="table_without_br">
5852
+ <xsl:apply-templates mode="table-without-br"/>
5853
+ </xsl:variable>
5854
+
4983
5855
  <!-- Step 1. colspan processing -->
4984
5856
  <xsl:variable name="simple-table-colspan">
4985
5857
  <tbody>
4986
- <xsl:apply-templates mode="simple-table-colspan"/>
5858
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
4987
5859
  </tbody>
4988
5860
  </xsl:variable>
4989
5861
 
@@ -4992,10 +5864,67 @@
4992
5864
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
4993
5865
  </xsl:variable>
4994
5866
 
4995
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
4996
-
5867
+ <!-- Step 3: add id to each cell -->
5868
+ <!-- add <word>...</word> for each word, image, math -->
5869
+ <xsl:variable name="simple-table-id">
5870
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
5871
+ <xsl:with-param name="id" select="$id"/>
5872
+ </xsl:apply-templates>
5873
+ </xsl:variable>
5874
+
5875
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5876
+
4997
5877
  </xsl:variable>
4998
5878
  <xsl:copy-of select="$simple-table"/>
5879
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
5880
+ <xsl:copy>
5881
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
5882
+ </xsl:copy>
5883
+ </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">
5884
+ <xsl:copy>
5885
+ <xsl:copy-of select="@*"/>
5886
+ <p>
5887
+ <xsl:copy-of select="node()"/>
5888
+ </p>
5889
+ </xsl:copy>
5890
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
5891
+ <xsl:copy>
5892
+ <xsl:copy-of select="@*"/>
5893
+ <xsl:for-each select="*[local-name()='br']">
5894
+ <xsl:variable name="current_id" select="generate-id()"/>
5895
+ <p>
5896
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5897
+ <xsl:copy-of select="."/>
5898
+ </xsl:for-each>
5899
+ </p>
5900
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5901
+ <p>
5902
+ <xsl:for-each select="following-sibling::node()">
5903
+ <xsl:copy-of select="."/>
5904
+ </xsl:for-each>
5905
+ </p>
5906
+ </xsl:if>
5907
+ </xsl:for-each>
5908
+ </xsl:copy>
5909
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
5910
+ <xsl:for-each select="*[local-name()='br']">
5911
+ <xsl:variable name="current_id" select="generate-id()"/>
5912
+ <p>
5913
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
5914
+ <xsl:copy-of select="."/>
5915
+ </xsl:for-each>
5916
+ </p>
5917
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
5918
+ <p>
5919
+ <xsl:for-each select="following-sibling::node()">
5920
+ <xsl:copy-of select="."/>
5921
+ </xsl:for-each>
5922
+ </p>
5923
+ </xsl:if>
5924
+ </xsl:for-each>
5925
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
5926
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
5927
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
4999
5928
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
5000
5929
  <xsl:apply-templates mode="simple-table-colspan"/>
5001
5930
  </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">
@@ -5085,6 +6014,126 @@
5085
6014
  <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5086
6015
  <xsl:with-param name="previousRow" select="$newRow"/>
5087
6016
  </xsl:apply-templates>
6017
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
6018
+ <xsl:param name="id"/>
6019
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
6020
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6021
+ <xsl:with-param name="id" select="$id_prefixed"/>
6022
+ </xsl:apply-templates>
6023
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
6024
+ <xsl:param name="id"/>
6025
+ <xsl:copy>
6026
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6027
+ <xsl:with-param name="id" select="$id"/>
6028
+ </xsl:apply-templates>
6029
+ </xsl:copy>
6030
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
6031
+ <xsl:param name="id"/>
6032
+ <xsl:copy>
6033
+ <xsl:copy-of select="@*"/>
6034
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
6035
+ <xsl:apply-templates select="node()" mode="simple-table-id">
6036
+ <xsl:with-param name="id" select="$id"/>
6037
+ </xsl:apply-templates>
6038
+ </xsl:copy>
6039
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
6040
+ <xsl:param name="id"/>
6041
+ <xsl:copy>
6042
+ <xsl:copy-of select="@*"/>
6043
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
6044
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
6045
+ <xsl:attribute name="id">
6046
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
6047
+ </xsl:attribute>
6048
+
6049
+ <xsl:for-each select="*[local-name() = 'p']">
6050
+ <xsl:copy>
6051
+ <xsl:copy-of select="@*"/>
6052
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
6053
+ <xsl:attribute name="id">
6054
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
6055
+ </xsl:attribute>
6056
+
6057
+ <xsl:copy-of select="node()"/>
6058
+ </xsl:copy>
6059
+ </xsl:for-each>
6060
+
6061
+
6062
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
6063
+
6064
+ <xsl:variable name="td_text">
6065
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
6066
+ </xsl:variable>
6067
+
6068
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
6069
+
6070
+ <xsl:variable name="words">
6071
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
6072
+ <word>
6073
+ <xsl:copy-of select="."/>
6074
+ </word>
6075
+ </xsl:for-each>
6076
+
6077
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
6078
+ <xsl:copy-of select="."/>
6079
+ </xsl:for-each>
6080
+
6081
+ </xsl:variable>
6082
+
6083
+ <xsl:for-each select="xalan:nodeset($words)/word">
6084
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
6085
+ <xsl:copy>
6086
+ <xsl:attribute name="id">
6087
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
6088
+ </xsl:attribute>
6089
+ <xsl:copy-of select="node()"/>
6090
+ </xsl:copy>
6091
+ </xsl:for-each>
6092
+ </xsl:if>
6093
+ </xsl:copy>
6094
+
6095
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
6096
+ <xsl:copy>
6097
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
6098
+ </xsl:copy>
6099
+ </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">
6100
+ <xsl:variable name="formatting_tags">
6101
+ <xsl:call-template name="getFormattingTags"/>
6102
+ </xsl:variable>
6103
+ <word>
6104
+ <xsl:call-template name="enclose_text_in_tags">
6105
+ <xsl:with-param name="text" select="normalize-space(.)"/>
6106
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6107
+ </xsl:call-template>
6108
+ </word>
6109
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
6110
+
6111
+ <xsl:variable name="td_text" select="."/>
6112
+
6113
+ <xsl:variable name="string_with_added_zerospaces">
6114
+ <xsl:call-template name="add-zero-spaces-java">
6115
+ <xsl:with-param name="text" select="$td_text"/>
6116
+ </xsl:call-template>
6117
+ </xsl:variable>
6118
+
6119
+ <xsl:variable name="formatting_tags">
6120
+ <xsl:call-template name="getFormattingTags"/>
6121
+ </xsl:variable>
6122
+
6123
+ <!-- <word>text</word> -->
6124
+ <xsl:call-template name="tokenize_with_tags">
6125
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6126
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
6127
+ </xsl:call-template>
6128
+ </xsl:template><xsl:template name="getFormattingTags">
6129
+ <tags>
6130
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
6131
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
6132
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6133
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6134
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6135
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6136
+ </tags>
5088
6137
  </xsl:template><xsl:template name="getLang">
5089
6138
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5090
6139
  <xsl:variable name="language">
@@ -5285,6 +6334,11 @@
5285
6334
  </xsl:variable>
5286
6335
  <fo:inline xsl:use-attribute-sets="link-style">
5287
6336
 
6337
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
6338
+ <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
6339
+ </xsl:if>
6340
+
6341
+
5288
6342
 
5289
6343
 
5290
6344
 
@@ -5547,7 +6601,19 @@
5547
6601
  <xsl:value-of select="$suffix"/>
5548
6602
  </xsl:if>
5549
6603
  </xsl:template><xsl:template match="*[local-name() = 'termnote']/*[local-name() = 'p']">
5550
- <fo:inline><xsl:apply-templates/></fo:inline>
6604
+ <xsl:variable name="num"><xsl:number/></xsl:variable>
6605
+ <xsl:choose>
6606
+ <xsl:when test="$num = 1"> <!-- first paragraph renders in the same line as titlenote name -->
6607
+ <fo:inline xsl:use-attribute-sets="termnote-p-style">
6608
+ <xsl:apply-templates/>
6609
+ </fo:inline>
6610
+ </xsl:when>
6611
+ <xsl:otherwise>
6612
+ <fo:block xsl:use-attribute-sets="termnote-p-style">
6613
+ <xsl:apply-templates/>
6614
+ </fo:block>
6615
+ </xsl:otherwise>
6616
+ </xsl:choose>
5551
6617
  </xsl:template><xsl:template match="*[local-name() = 'terms']">
5552
6618
  <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
5553
6619
  <fo:block id="{@id}">
@@ -6364,7 +7430,7 @@
6364
7430
  </xsl:choose>
6365
7431
  </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">
6366
7432
  <xsl:value-of select="."/>
6367
- </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
7433
+ </xsl:template><xsl:template match="*[local-name() = 'review']" mode="contents_item"/><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6368
7434
  <xsl:text> </xsl:text>
6369
7435
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6370
7436
  <xsl:copy>
@@ -6435,7 +7501,7 @@
6435
7501
 
6436
7502
 
6437
7503
 
6438
-
7504
+ <!-- 9 -->
6439
7505
 
6440
7506
  9
6441
7507
 
@@ -6519,7 +7585,7 @@
6519
7585
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6520
7586
  <xsl:choose>
6521
7587
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6522
- <xsl:call-template name="interspers">
7588
+ <xsl:call-template name="interspers-java">
6523
7589
  <xsl:with-param name="str" select="."/>
6524
7590
  </xsl:call-template>
6525
7591
  </xsl:when>
@@ -6569,6 +7635,10 @@
6569
7635
  <xsl:with-param name="char" select="$char"/>
6570
7636
  </xsl:call-template>
6571
7637
  </xsl:if>
7638
+ </xsl:template><xsl:template name="interspers-java">
7639
+ <xsl:param name="str"/>
7640
+ <xsl:param name="char" select="$zero_width_space"/>
7641
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
6572
7642
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6573
7643
  <xsl:apply-templates mode="syntax_highlight"/>
6574
7644
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -6781,7 +7851,9 @@
6781
7851
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
6782
7852
  </xsl:if>
6783
7853
  <xsl:variable name="simple-table">
6784
- <xsl:call-template name="getSimpleTable"/>
7854
+ <xsl:call-template name="getSimpleTable">
7855
+ <xsl:with-param name="id" select="@id"/>
7856
+ </xsl:call-template>
6785
7857
  </xsl:variable>
6786
7858
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
6787
7859
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -7211,6 +8283,7 @@
7211
8283
 
7212
8284
 
7213
8285
 
8286
+
7214
8287
  <xsl:choose>
7215
8288
  <xsl:when test="$depth = 2">3</xsl:when>
7216
8289
  <xsl:otherwise>4</xsl:otherwise>
@@ -7536,6 +8609,11 @@
7536
8609
  </xsl:otherwise>
7537
8610
  </xsl:choose>
7538
8611
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
8612
+
8613
+ <xsl:apply-templates select="*[local-name() = 'name']">
8614
+ <xsl:with-param name="process">true</xsl:with-param>
8615
+ </xsl:apply-templates>
8616
+
7539
8617
  <fo:list-block xsl:use-attribute-sets="list-style">
7540
8618
 
7541
8619
 
@@ -7546,12 +8624,23 @@
7546
8624
 
7547
8625
 
7548
8626
 
8627
+ <xsl:if test="*[local-name() = 'name']">
8628
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8629
+ </xsl:if>
8630
+
7549
8631
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7550
8632
  </fo:list-block>
7551
8633
  <!-- <xsl:for-each select="./iho:note">
7552
8634
  <xsl:call-template name="note"/>
7553
8635
  </xsl:for-each> -->
7554
8636
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
8637
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
8638
+ <xsl:param name="process">false</xsl:param>
8639
+ <xsl:if test="$process = 'true'">
8640
+ <fo:block xsl:use-attribute-sets="list-name-style">
8641
+ <xsl:apply-templates/>
8642
+ </fo:block>
8643
+ </xsl:if>
7555
8644
  </xsl:template><xsl:template match="*[local-name()='li']">
7556
8645
  <fo:list-item xsl:use-attribute-sets="list-item-style">
7557
8646
  <xsl:copy-of select="@id"/>
@@ -7751,7 +8840,7 @@
7751
8840
  <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
7752
8841
  <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
7753
8842
  <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
7754
- <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
8843
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7755
8844
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7756
8845
  <!-- <row>
7757
8846
  <date>05-07-2013</date>
@@ -7822,7 +8911,7 @@
7822
8911
 
7823
8912
  </xsl:template><xsl:template match="*[local-name() = 'references'][not(@normative='true')]/*[local-name() = 'bibitem']" priority="2">
7824
8913
 
7825
- <!-- $namespace = 'csd' or $namespace = 'gb' or $namespace = 'iec' or $namespace = 'iso' or $namespace = 'jcgm' or $namespace = 'm3d' or
8914
+ <!-- $namespace = 'csd' or $namespace = 'gb' or $namespace = 'iec' or $namespace = 'ieee' or $namespace = 'iso' or $namespace = 'jcgm' or $namespace = 'm3d' or
7826
8915
  $namespace = 'mpfd' or $namespace = 'ogc' or $namespace = 'ogc-white-paper' -->
7827
8916
  <!-- Example: [1] ISO 9:1995, Information and documentation – Transliteration of Cyrillic characters into Latin characters – Slavic and non-Slavic languages -->
7828
8917
  <fo:list-block id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-style">
@@ -7833,7 +8922,9 @@
7833
8922
 
7834
8923
  <xsl:value-of select="*[local-name()='docidentifier'][@type = 'metanorma-ordinal']"/>
7835
8924
  <xsl:if test="not(*[local-name()='docidentifier'][@type = 'metanorma-ordinal'])">
7836
- <xsl:number format="[1]"/>
8925
+
8926
+ <xsl:number format="[1]" count="*[local-name()='bibitem'][not(@hidden = 'true')]"/>
8927
+
7837
8928
  </xsl:if>
7838
8929
 
7839
8930
  </fo:inline>
@@ -7855,32 +8946,14 @@
7855
8946
  <xsl:variable name="docidentifier">
7856
8947
  <xsl:choose>
7857
8948
  <xsl:when test="*[local-name()='docidentifier']/@type = 'metanorma'"/>
7858
- <xsl:otherwise><xsl:value-of select="*[local-name()='docidentifier'][not(@type = 'metanorma-ordinal')]"/></xsl:otherwise>
8949
+ <xsl:otherwise><xsl:value-of select="*[local-name()='docidentifier'][not(@type = 'metanorma-ordinal') and not(@type = 'BIPM')]"/></xsl:otherwise>
7859
8950
  </xsl:choose>
7860
8951
  </xsl:variable>
7861
8952
  <xsl:value-of select="$docidentifier"/>
7862
8953
 
7863
- <xsl:choose>
7864
- <xsl:when test="*[local-name()='formattedref']">
7865
- <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
7866
- <xsl:apply-templates select="*[local-name()='formattedref']"/>
7867
- </xsl:when>
7868
- <xsl:otherwise>
7869
- <xsl:apply-templates select="*[local-name()='note']"/>
7870
- <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
7871
- <xsl:choose>
7872
- <xsl:when test="*[local-name()='title'][@type = 'main' and @language = $lang]">
7873
- <xsl:apply-templates select="*[local-name()='title'][@type = 'main' and @language = $lang]"/>
7874
- </xsl:when>
7875
- <xsl:when test="*[local-name()='title'][@type = 'main' and @language = 'en']">
7876
- <xsl:apply-templates select="*[local-name()='title'][@type = 'main' and @language = 'en']"/>
7877
- </xsl:when>
7878
- <xsl:otherwise>
7879
- <xsl:apply-templates select="*[local-name()='title']"/>
7880
- </xsl:otherwise>
7881
- </xsl:choose>
7882
- </xsl:otherwise>
7883
- </xsl:choose>
8954
+ <xsl:if test="*[local-name()='formattedref'] and normalize-space($docidentifier) != ''">, </xsl:if>
8955
+ <xsl:apply-templates select="*[local-name()='formattedref']"/>
8956
+
7884
8957
  <!-- end JCGM bibitem processing -->
7885
8958
 
7886
8959
  </xsl:template><xsl:template name="processBibitemDocId">
@@ -8186,36 +9259,58 @@
8186
9259
 
8187
9260
 
8188
9261
 
9262
+ <xsl:if test="@type = 'editorial'">
9263
+ <xsl:attribute name="color">green</xsl:attribute>
9264
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
9265
+
9266
+ <!-- <xsl:variable name="note-style">
9267
+ <style xsl:use-attribute-sets="note-style"></style>
9268
+ </xsl:variable>
9269
+ <xsl:for-each select="xalan:nodeset($note-style)//style/@*">
9270
+ <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
9271
+ </xsl:for-each> -->
9272
+ </xsl:if>
9273
+
9274
+
8189
9275
 
8190
9276
 
8191
9277
 
8192
- <xsl:call-template name="displayAdmonitionName"/>
8193
- <xsl:text> — </xsl:text>
9278
+
9279
+ <xsl:call-template name="displayAdmonitionName">
9280
+ <xsl:with-param name="sep"> — </xsl:with-param>
9281
+ </xsl:call-template>
8194
9282
 
8195
9283
 
8196
9284
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8197
9285
  </fo:block>
8198
9286
 
8199
9287
  </xsl:template><xsl:template name="displayAdmonitionName">
8200
-
9288
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
9289
+ <!-- <xsl:choose>
9290
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
9291
+ <xsl:choose>
9292
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
9293
+ <xsl:otherwise>
9294
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
9295
+ </xsl:otherwise>
9296
+ </xsl:choose>
9297
+ </xsl:when>
9298
+ <xsl:otherwise>
8201
9299
  <xsl:apply-templates select="*[local-name() = 'name']"/>
8202
9300
  <xsl:if test="not(*[local-name() = 'name'])">
8203
9301
  <xsl:apply-templates select="@type"/>
8204
9302
  </xsl:if>
8205
-
8206
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8207
- <xsl:apply-templates/>
8208
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
8209
- <xsl:variable name="admonition_type_">
8210
- <xsl:call-template name="getLocalizedString">
8211
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
8212
- </xsl:call-template>
9303
+ </xsl:otherwise>
9304
+ </xsl:choose> -->
9305
+ <xsl:variable name="name">
9306
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8213
9307
  </xsl:variable>
8214
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
8215
- <xsl:value-of select="$admonition_type"/>
8216
- <xsl:if test="$admonition_type = ''">
8217
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
9308
+ <xsl:copy-of select="$name"/>
9309
+ <xsl:if test="normalize-space($name) != ''">
9310
+ <xsl:value-of select="$sep"/>
8218
9311
  </xsl:if>
9312
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
9313
+ <xsl:apply-templates/>
8219
9314
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
8220
9315
 
8221
9316
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -8386,6 +9481,8 @@
8386
9481
  </xsl:when>
8387
9482
  <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8388
9483
  </xsl:choose>
9484
+ </xsl:template><xsl:template match="*[local-name() = 'lang_none']">
9485
+ <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
8389
9486
  </xsl:template><xsl:template name="printEdition">
8390
9487
  <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
8391
9488
  <xsl:text> </xsl:text>
@@ -8492,6 +9589,27 @@
8492
9589
  </xsl:when>
8493
9590
  <xsl:otherwise><xsl:value-of select="$monthStr_"/></xsl:otherwise>
8494
9591
  </xsl:choose>
9592
+ </xsl:template><xsl:template name="getMonthLocalizedByNum">
9593
+ <xsl:param name="num"/>
9594
+ <xsl:variable name="monthStr">
9595
+ <xsl:choose>
9596
+ <xsl:when test="$num = '01'">january</xsl:when>
9597
+ <xsl:when test="$num = '02'">february</xsl:when>
9598
+ <xsl:when test="$num = '03'">march</xsl:when>
9599
+ <xsl:when test="$num = '04'">april</xsl:when>
9600
+ <xsl:when test="$num = '05'">may</xsl:when>
9601
+ <xsl:when test="$num = '06'">june</xsl:when>
9602
+ <xsl:when test="$num = '07'">july</xsl:when>
9603
+ <xsl:when test="$num = '08'">august</xsl:when>
9604
+ <xsl:when test="$num = '09'">september</xsl:when>
9605
+ <xsl:when test="$num = '10'">october</xsl:when>
9606
+ <xsl:when test="$num = '11'">november</xsl:when>
9607
+ <xsl:when test="$num = '12'">december</xsl:when>
9608
+ </xsl:choose>
9609
+ </xsl:variable>
9610
+ <xsl:call-template name="getLocalizedString">
9611
+ <xsl:with-param name="key">month_<xsl:value-of select="$monthStr"/></xsl:with-param>
9612
+ </xsl:call-template>
8495
9613
  </xsl:template><xsl:template name="insertKeywords">
8496
9614
  <xsl:param name="sorting" select="'true'"/>
8497
9615
  <xsl:param name="charAtEnd" select="'.'"/>
@@ -8688,6 +9806,7 @@
8688
9806
 
8689
9807
 
8690
9808
 
9809
+
8691
9810
 
8692
9811
 
8693
9812
 
@@ -9095,4 +10214,40 @@
9095
10214
  <xsl:value-of select="$value"/>
9096
10215
  </xsl:otherwise>
9097
10216
  </xsl:choose>
10217
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
10218
+ <xsl:param name="level">0</xsl:param>
10219
+
10220
+ <fo:block margin-left="{2*$level}mm">
10221
+ <xsl:text>
10222
+ &lt;</xsl:text>
10223
+ <xsl:value-of select="local-name()"/>
10224
+ <xsl:for-each select="@*">
10225
+ <xsl:text> </xsl:text>
10226
+ <xsl:value-of select="local-name()"/>
10227
+ <xsl:text>="</xsl:text>
10228
+ <xsl:value-of select="."/>
10229
+ <xsl:text>"</xsl:text>
10230
+ </xsl:for-each>
10231
+ <xsl:text>&gt;</xsl:text>
10232
+
10233
+ <xsl:if test="not(*)">
10234
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
10235
+ <xsl:text>&lt;/</xsl:text>
10236
+ <xsl:value-of select="local-name()"/>
10237
+ <xsl:text>&gt;</xsl:text>
10238
+ </xsl:if>
10239
+ </fo:block>
10240
+
10241
+ <xsl:if test="*">
10242
+ <fo:block>
10243
+ <xsl:apply-templates mode="print_as_xml">
10244
+ <xsl:with-param name="level" select="$level + 1"/>
10245
+ </xsl:apply-templates>
10246
+ </fo:block>
10247
+ <fo:block margin-left="{2*$level}mm">
10248
+ <xsl:text>&lt;/</xsl:text>
10249
+ <xsl:value-of select="local-name()"/>
10250
+ <xsl:text>&gt;</xsl:text>
10251
+ </fo:block>
10252
+ </xsl:if>
9098
10253
  </xsl:template></xsl:stylesheet>