metanorma-itu 2.0.8.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/itu/base_convert.rb +1 -1
  3. data/lib/isodoc/itu/cleanup.rb +1 -1
  4. data/lib/isodoc/itu/html/html_itu_titlepage.html +1 -0
  5. data/lib/isodoc/itu/html/htmlstyle.css +6 -0
  6. data/lib/isodoc/itu/html/htmlstyle.scss +2 -0
  7. data/lib/isodoc/itu/html/itu.css +17 -9
  8. data/lib/isodoc/itu/html/itu.scss +18 -8
  9. data/lib/isodoc/itu/html/word_itu_intro.html +40 -41
  10. data/lib/isodoc/itu/html/word_itu_titlepage.html +1 -0
  11. data/lib/isodoc/itu/html/word_itu_titlepage_sp.html +1 -1
  12. data/lib/isodoc/itu/html_convert.rb +16 -11
  13. data/lib/isodoc/itu/i18n.rb +1 -1
  14. data/lib/isodoc/itu/init.rb +1 -1
  15. data/lib/isodoc/itu/itu.implementers-guide.xsl +1496 -304
  16. data/lib/isodoc/itu/itu.in-force.xsl +1496 -304
  17. data/lib/isodoc/itu/itu.recommendation-annex.xsl +1496 -304
  18. data/lib/isodoc/itu/itu.recommendation-supplement.xsl +1496 -304
  19. data/lib/isodoc/itu/itu.recommendation.xsl +1496 -304
  20. data/lib/isodoc/itu/itu.resolution.xsl +1496 -304
  21. data/lib/isodoc/itu/itu.service-publication.xsl +1496 -304
  22. data/lib/isodoc/itu/itu.technical-paper.xsl +1496 -304
  23. data/lib/isodoc/itu/itu.technical-report.xsl +1496 -304
  24. data/lib/isodoc/itu/presentation_xml_convert.rb +16 -0
  25. data/lib/isodoc/itu/ref.rb +20 -32
  26. data/lib/isodoc/itu/terms.rb +1 -1
  27. data/lib/isodoc/itu/word_cleanup.rb +10 -9
  28. data/lib/isodoc/itu/word_convert.rb +1 -1
  29. data/lib/isodoc/itu/xref.rb +42 -27
  30. data/lib/isodoc/itu/xref_section.rb +0 -15
  31. data/lib/metanorma/itu/biblio.rng +69 -42
  32. data/lib/metanorma/itu/converter.rb +2 -1
  33. data/lib/metanorma/itu/isodoc.rng +65 -0
  34. data/lib/metanorma/itu/itu.rng +3 -0
  35. data/lib/metanorma/itu/version.rb +1 -1
  36. data/lib/relaton/render/config.yml +3 -0
  37. data/lib/relaton/render/general.rb +13 -0
  38. data/metanorma-itu.gemspec +1 -1
  39. metadata +7 -5
@@ -1352,6 +1352,7 @@
1352
1352
  <!-- PARAGRAPHS -->
1353
1353
  <!-- ============================= -->
1354
1354
  <xsl:template match="itu:p | itu:sections/itu:p" name="paragraph">
1355
+ <xsl:param name="split_keep-within-line"/>
1355
1356
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
1356
1357
  <xsl:variable name="element-name">
1357
1358
  <xsl:choose>
@@ -1404,7 +1405,9 @@
1404
1405
  </fo:inline>
1405
1406
  </xsl:if>
1406
1407
 
1407
- <xsl:apply-templates/>
1408
+ <xsl:apply-templates>
1409
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1410
+ </xsl:apply-templates>
1408
1411
  </xsl:element>
1409
1412
  <xsl:if test="$element-name = 'fo:inline'">
1410
1413
  <fo:block><xsl:value-of select="$linebreak"/></fo:block>
@@ -1696,27 +1699,6 @@
1696
1699
  </xsl:element>
1697
1700
  </xsl:template>
1698
1701
 
1699
-
1700
-
1701
- <!-- Examples:
1702
- [b-ASM] b-ASM, http://www.eecs.umich.edu/gasm/ (accessed 20 March 2018).
1703
- [b-Börger & Stärk] b-Börger & Stärk, Börger, E., and Stärk, R. S. (2003), Abstract State Machines: A Method for High-Level System Design and Analysis, Springer-Verlag.
1704
- -->
1705
- <xsl:template match="itu:annex//itu:bibitem" priority="3">
1706
- <fo:block margin-top="6pt" margin-left="10mm" text-indent="-10mm">
1707
- <fo:inline id="{@id}" padding-right="5mm">[<xsl:value-of select="itu:docidentifier[not(@type = 'metanorma-ordinal')]"/>]</fo:inline>
1708
- <xsl:text> </xsl:text>
1709
- <xsl:apply-templates select="itu:docidentifier[not(@type = 'metanorma-ordinal')]" mode="content"/>
1710
- <xsl:if test="node()[local-name(.) != current()/itu:docidentifier]">, </xsl:if>
1711
- <xsl:apply-templates/>
1712
- </fo:block>
1713
- </xsl:template>
1714
-
1715
- <xsl:template match="itu:docidentifier" mode="content">
1716
- <xsl:apply-templates/>
1717
- </xsl:template>
1718
- <xsl:template match="itu:docidentifier"/>
1719
-
1720
1702
 
1721
1703
  <xsl:template match="itu:ul | itu:ol | itu:sections/itu:ul | itu:sections/itu:ol" mode="list" priority="2">
1722
1704
  <xsl:if test="preceding-sibling::*[1][local-name() = 'title'] and $doctype != 'service-publication'">
@@ -2068,12 +2050,41 @@
2068
2050
  </xsl:if>
2069
2051
  </xsl:template>
2070
2052
 
2071
- <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">
2053
+ <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_">
2054
+ <xsl:for-each select="$table_widths_from_if//table">
2055
+ <xsl:copy>
2056
+ <xsl:copy-of select="@*"/>
2057
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
2058
+ </xsl:copy>
2059
+ </xsl:for-each>
2060
+ </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_">
2061
+ false
2062
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
2072
2063
  <xsl:call-template name="getLang"/>
2073
- </xsl:variable><xsl:variable name="pageWidth_">
2074
- 210
2064
+ </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_">
2065
+ <xsl:choose>
2066
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
2067
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
2068
+ </xsl:choose>
2069
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
2070
+ <xsl:choose>
2071
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
2072
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
2073
+ </xsl:choose>
2074
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
2075
+ <xsl:choose>
2076
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
2077
+ <xsl:otherwise>
2078
+ 210
2079
+ </xsl:otherwise>
2080
+ </xsl:choose>
2075
2081
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
2076
- 297
2082
+ <xsl:choose>
2083
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
2084
+ <xsl:otherwise>
2085
+ 297
2086
+ </xsl:otherwise>
2087
+ </xsl:choose>
2077
2088
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
2078
2089
  20
2079
2090
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -2083,20 +2094,7 @@
2083
2094
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
2084
2095
  20
2085
2096
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
2086
-
2087
- <title-edition lang="en">
2088
-
2089
- <xsl:text>Edition </xsl:text>
2090
-
2091
- </title-edition>
2092
2097
 
2093
- <title-edition lang="fr">
2094
- <xsl:text>Édition </xsl:text>
2095
- </title-edition>
2096
-
2097
- <title-edition lang="ru">
2098
- <xsl:text>Издание </xsl:text>
2099
- </title-edition>
2100
2098
 
2101
2099
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
2102
2100
  <title-toc lang="en">
@@ -2175,7 +2173,7 @@
2175
2173
  </xsl:variable><xsl:variable name="bibdata">
2176
2174
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
2177
2175
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
2178
- </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
2176
+ </xsl:variable><xsl:variable name="linebreak">&#8232;</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space">​</xsl:variable><xsl:variable name="hair_space"> </xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
2179
2177
  <xsl:param name="name"/>
2180
2178
  <xsl:param name="lang"/>
2181
2179
  <xsl:variable name="lang_">
@@ -2223,7 +2221,7 @@
2223
2221
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
2224
2222
 
2225
2223
  <xsl:variable name="additional_fonts_">
2226
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
2224
+ <xsl:for-each select="//*[contains(local-name(), '-standard')][1]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value'] | //*[contains(local-name(), '-standard')][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
2227
2225
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
2228
2226
  </xsl:for-each>
2229
2227
  </xsl:variable>
@@ -2301,7 +2299,6 @@
2301
2299
 
2302
2300
 
2303
2301
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
2304
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2305
2302
 
2306
2303
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
2307
2304
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -2384,6 +2381,7 @@
2384
2381
 
2385
2382
 
2386
2383
 
2384
+
2387
2385
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2388
2386
 
2389
2387
 
@@ -2533,6 +2531,7 @@
2533
2531
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2534
2532
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2535
2533
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2534
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2536
2535
  <xsl:attribute name="display-align">center</xsl:attribute>
2537
2536
 
2538
2537
 
@@ -2551,6 +2550,7 @@
2551
2550
  <xsl:attribute name="display-align">center</xsl:attribute>
2552
2551
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2553
2552
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2553
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2554
2554
 
2555
2555
 
2556
2556
 
@@ -2644,7 +2644,8 @@
2644
2644
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
2645
2645
 
2646
2646
 
2647
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2647
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2648
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2648
2649
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2649
2650
 
2650
2651
 
@@ -2656,6 +2657,27 @@
2656
2657
 
2657
2658
 
2658
2659
 
2660
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
2661
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2662
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2663
+
2664
+
2665
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2680
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2659
2681
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2660
2682
 
2661
2683
 
@@ -2963,6 +2985,24 @@
2963
2985
 
2964
2986
 
2965
2987
 
2988
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
2989
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2990
+
2991
+
2992
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2993
+
2994
+
2995
+
2996
+
2997
+
2998
+
2999
+
3000
+
3001
+
3002
+
3003
+
3004
+
3005
+
2966
3006
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
2967
3007
 
2968
3008
 
@@ -3362,13 +3402,13 @@
3362
3402
 
3363
3403
  </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">
3364
3404
  <xsl:variable name="nodes_preface_">
3365
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3405
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3366
3406
  <node id="{@id}"/>
3367
3407
  </xsl:for-each>
3368
3408
  </xsl:variable>
3369
3409
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
3370
3410
 
3371
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3411
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3372
3412
  <xsl:sort select="@displayorder" data-type="number"/>
3373
3413
 
3374
3414
  <!-- process Section's title -->
@@ -3434,7 +3474,7 @@
3434
3474
  </xsl:for-each>
3435
3475
  </figures>
3436
3476
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3437
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3477
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3438
3478
  <xsl:sort select="@displayorder" data-type="number"/>
3439
3479
  <xsl:apply-templates select="."/>
3440
3480
  </xsl:for-each>
@@ -3454,22 +3494,32 @@
3454
3494
  <xsl:sort select="@displayorder" data-type="number"/>
3455
3495
  <xsl:apply-templates select="."/>
3456
3496
  </xsl:for-each>
3457
- </xsl:template><xsl:variable name="tag_open">###fo:inline###</xsl:variable><xsl:variable name="tag_close">###/fo:inline###</xsl:variable><xsl:template match="text()" name="text">
3458
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3459
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3460
- <xsl:call-template name="replace_fo_inline">
3461
- <xsl:with-param name="text" select="$text"/>
3462
- </xsl:call-template>
3463
- </xsl:template><xsl:template name="replace_fo_inline">
3497
+ </xsl:template><xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable><xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable><xsl:template match="text()" name="text">
3498
+
3499
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3500
+ <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_fo_inline_keep-together_within-line_open,'$1',$tag_fo_inline_keep-together_within-line_close))"/>
3501
+ <xsl:call-template name="replace_fo_inline_tags">
3502
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
3503
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
3504
+ <xsl:with-param name="text" select="$text"/>
3505
+ </xsl:call-template>
3506
+
3507
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3508
+ <xsl:param name="tag_open"/>
3509
+ <xsl:param name="tag_close"/>
3464
3510
  <xsl:param name="text"/>
3465
3511
  <xsl:choose>
3466
3512
  <xsl:when test="contains($text, $tag_open)">
3467
3513
  <xsl:value-of select="substring-before($text, $tag_open)"/>
3468
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3514
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3469
3515
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3470
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3471
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3472
- <xsl:call-template name="replace_fo_inline">
3516
+ <fo:inline keep-together.within-line="always">
3517
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3518
+ </fo:inline>
3519
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3520
+ <xsl:call-template name="replace_fo_inline_tags">
3521
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3522
+ <xsl:with-param name="tag_close" select="$tag_close"/>
3473
3523
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3474
3524
  </xsl:call-template>
3475
3525
  </xsl:when>
@@ -3477,6 +3527,39 @@
3477
3527
  </xsl:choose>
3478
3528
  </xsl:template><xsl:template match="*[local-name()='br']">
3479
3529
  <xsl:value-of select="$linebreak"/>
3530
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3531
+ <xsl:param name="split_keep-within-line"/>
3532
+
3533
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3534
+ <xsl:choose>
3535
+
3536
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3537
+ <xsl:variable name="sep">_</xsl:variable>
3538
+ <xsl:variable name="items">
3539
+ <xsl:call-template name="split">
3540
+ <xsl:with-param name="pText" select="."/>
3541
+ <xsl:with-param name="sep" select="$sep"/>
3542
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3543
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3544
+ </xsl:call-template>
3545
+ </xsl:variable>
3546
+ <xsl:for-each select="xalan:nodeset($items)/item">
3547
+ <xsl:choose>
3548
+ <xsl:when test=". = $sep">
3549
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3550
+ </xsl:when>
3551
+ <xsl:otherwise>
3552
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3553
+ </xsl:otherwise>
3554
+ </xsl:choose>
3555
+ </xsl:for-each>
3556
+ </xsl:when>
3557
+
3558
+ <xsl:otherwise>
3559
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3560
+ </xsl:otherwise>
3561
+
3562
+ </xsl:choose>
3480
3563
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3481
3564
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3482
3565
  <xsl:apply-templates/>
@@ -3550,11 +3633,24 @@
3550
3633
  <xsl:with-param name="margin" select="$margin"/>
3551
3634
  </xsl:call-template>
3552
3635
 
3553
- </xsl:template><xsl:variable name="express_reference_separators">_.\</xsl:variable><xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3554
-
3555
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3556
- <xsl:call-template name="add-zero-spaces-java"/>
3557
-
3636
+ </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3637
+ <xsl:choose>
3638
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3639
+ <xsl:value-of select="."/>
3640
+ </xsl:when>
3641
+ <xsl:otherwise>
3642
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3643
+ </xsl:otherwise>
3644
+ </xsl:choose>
3645
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3646
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3647
+ <!-- <xsl:copy-of select="$text"/> -->
3648
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3649
+ <xsl:choose>
3650
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3651
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3652
+ </xsl:choose>
3653
+ </xsl:for-each>
3558
3654
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3559
3655
 
3560
3656
  <xsl:variable name="table-preamble">
@@ -3568,9 +3664,14 @@
3568
3664
 
3569
3665
  <xsl:variable name="table">
3570
3666
 
3571
- <xsl:variable name="simple-table">
3572
- <xsl:call-template name="getSimpleTable"/>
3667
+ <xsl:variable name="simple-table">
3668
+ <xsl:call-template name="getSimpleTable">
3669
+ <xsl:with-param name="id" select="@id"/>
3670
+ </xsl:call-template>
3573
3671
  </xsl:variable>
3672
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3673
+
3674
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3574
3675
 
3575
3676
 
3576
3677
  <!-- Display table's name before table as standalone block -->
@@ -3593,7 +3694,23 @@
3593
3694
  </xsl:call-template>
3594
3695
  </xsl:if>
3595
3696
  </xsl:variable>
3596
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3697
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3698
+
3699
+ <!-- DEBUG -->
3700
+ <xsl:if test="$table_if_debug = 'true'">
3701
+ <fo:block font-size="60%">
3702
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3703
+ </fo:block>
3704
+ </xsl:if>
3705
+
3706
+
3707
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3708
+
3709
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3710
+ DEBUG
3711
+ colwidths=<xsl:copy-of select="$colwidths"/>
3712
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3713
+
3597
3714
 
3598
3715
 
3599
3716
  <xsl:variable name="margin-side">
@@ -3662,9 +3779,17 @@
3662
3779
  </xsl:element>
3663
3780
  </xsl:variable>
3664
3781
 
3782
+ <xsl:if test="$isGenerateTableIF = 'true'">
3783
+ <!-- to determine start of table -->
3784
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3785
+ </xsl:if>
3665
3786
 
3666
3787
  <fo:table id="{@id}">
3667
3788
 
3789
+ <xsl:if test="$isGenerateTableIF = 'true'">
3790
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3791
+ </xsl:if>
3792
+
3668
3793
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3669
3794
  <xsl:attribute name="{local-name()}">
3670
3795
  <xsl:value-of select="."/>
@@ -3678,24 +3803,47 @@
3678
3803
 
3679
3804
 
3680
3805
  <xsl:choose>
3681
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3682
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3683
- <fo:table-column column-width="{@width}"/>
3684
- </xsl:for-each>
3806
+ <xsl:when test="$isGenerateTableIF = 'true'">
3807
+ <!-- generate IF for table widths -->
3808
+ <!-- example:
3809
+ <tr>
3810
+ <td valign="top" align="left" id="tab-symdu_1_1">
3811
+ <p>Symbol</p>
3812
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3813
+ </td>
3814
+ <td valign="top" align="left" id="tab-symdu_1_2">
3815
+ <p>Description</p>
3816
+ <word id="tab-symdu_1_2_word_1">Description</word>
3817
+ </td>
3818
+ </tr>
3819
+ -->
3820
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3821
+
3685
3822
  </xsl:when>
3686
3823
  <xsl:otherwise>
3687
- <xsl:call-template name="insertTableColumnWidth">
3688
- <xsl:with-param name="colwidths" select="$colwidths"/>
3689
- </xsl:call-template>
3690
- </xsl:otherwise>
3691
- </xsl:choose>
3692
3824
 
3693
- <xsl:choose>
3694
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3695
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3696
- </xsl:when>
3697
- <xsl:otherwise>
3698
- <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 -->
3825
+ <xsl:choose>
3826
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3827
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3828
+ <fo:table-column column-width="{@width}"/>
3829
+ </xsl:for-each>
3830
+ </xsl:when>
3831
+ <xsl:otherwise>
3832
+ <xsl:call-template name="insertTableColumnWidth">
3833
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3834
+ </xsl:call-template>
3835
+ </xsl:otherwise>
3836
+ </xsl:choose>
3837
+
3838
+ <xsl:choose>
3839
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3840
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3841
+ </xsl:when>
3842
+ <xsl:otherwise>
3843
+ <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 -->
3844
+ </xsl:otherwise>
3845
+ </xsl:choose>
3846
+
3699
3847
  </xsl:otherwise>
3700
3848
  </xsl:choose>
3701
3849
 
@@ -3798,11 +3946,22 @@
3798
3946
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3799
3947
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3800
3948
  </xsl:template><xsl:template name="calculate-column-widths">
3949
+ <xsl:param name="table"/>
3950
+ <xsl:param name="cols-count"/>
3951
+
3952
+ <xsl:call-template name="calculate-column-widths-proportional">
3953
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3954
+ <xsl:with-param name="table" select="$table"/>
3955
+ </xsl:call-template>
3956
+
3957
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3801
3958
  <xsl:param name="table"/>
3802
3959
  <xsl:param name="cols-count"/>
3803
3960
  <xsl:param name="curr-col" select="1"/>
3804
3961
  <xsl:param name="width" select="0"/>
3805
3962
 
3963
+ <!-- table=<xsl:copy-of select="$table"/> -->
3964
+
3806
3965
  <xsl:if test="$curr-col &lt;= $cols-count">
3807
3966
  <xsl:variable name="widths">
3808
3967
  <xsl:choose>
@@ -3840,16 +3999,22 @@
3840
3999
  </xsl:for-each>
3841
4000
  </xsl:when>
3842
4001
  <xsl:otherwise>
3843
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
4002
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
4003
+
4004
+ <!-- <table><xsl:copy-of select="$table"/></table>
4005
+ -->
4006
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3844
4007
  <xsl:variable name="td_text">
3845
4008
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3846
4009
  </xsl:variable>
4010
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3847
4011
  <xsl:variable name="words">
3848
4012
  <xsl:variable name="string_with_added_zerospaces">
3849
4013
  <xsl:call-template name="add-zero-spaces-java">
3850
4014
  <xsl:with-param name="text" select="$td_text"/>
3851
4015
  </xsl:call-template>
3852
4016
  </xsl:variable>
4017
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3853
4018
  <xsl:call-template name="tokenize">
3854
4019
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3855
4020
  <!-- 2009 thinspace -->
@@ -3857,11 +4022,13 @@
3857
4022
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3858
4023
  </xsl:call-template>
3859
4024
  </xsl:variable>
4025
+ <!-- words=<xsl:copy-of select="$words"/> -->
3860
4026
  <xsl:variable name="max_length">
3861
4027
  <xsl:call-template name="max_length">
3862
4028
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3863
4029
  </xsl:call-template>
3864
4030
  </xsl:variable>
4031
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3865
4032
  <width>
3866
4033
  <xsl:variable name="divider">
3867
4034
  <xsl:choose>
@@ -3880,6 +4047,8 @@
3880
4047
  </xsl:choose>
3881
4048
  </xsl:variable>
3882
4049
 
4050
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
4051
+
3883
4052
  <column>
3884
4053
  <xsl:for-each select="xalan:nodeset($widths)//width">
3885
4054
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3888,35 +4057,271 @@
3888
4057
  </xsl:if>
3889
4058
  </xsl:for-each>
3890
4059
  </column>
3891
- <xsl:call-template name="calculate-column-widths">
4060
+ <xsl:call-template name="calculate-column-widths-proportional">
3892
4061
  <xsl:with-param name="cols-count" select="$cols-count"/>
3893
4062
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3894
4063
  <xsl:with-param name="table" select="$table"/>
3895
4064
  </xsl:call-template>
3896
4065
  </xsl:if>
3897
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]" mode="td_text">
3898
- <xsl:apply-templates mode="td_text"/>
3899
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]/text()[translate(., $express_reference_characters, '') = '']" mode="td_text">
4066
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
4067
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
4068
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
4069
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3900
4070
 
3901
- <xsl:value-of select="."/>
3902
-
4071
+ <!-- if all capitals english letters or digits -->
4072
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
4073
+ <xsl:call-template name="repeat">
4074
+ <xsl:with-param name="char" select="'X'"/>
4075
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
4076
+ </xsl:call-template>
4077
+ </xsl:if>
3903
4078
  </xsl:template><xsl:template match="text()" mode="td_text">
3904
4079
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3905
4080
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3906
4081
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3907
4082
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3908
4083
  <xsl:value-of select="@target"/>
3909
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3910
- <xsl:variable name="mathml">
3911
- <xsl:for-each select="*">
3912
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3913
- <xsl:copy-of select="."/>
3914
- </xsl:if>
4084
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
4085
+ <xsl:if test="$isGenerateTableIF = 'false'">
4086
+ <xsl:variable name="mathml_">
4087
+ <xsl:for-each select="*">
4088
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
4089
+ <xsl:copy-of select="."/>
4090
+ </xsl:if>
4091
+ </xsl:for-each>
4092
+ </xsl:variable>
4093
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
4094
+
4095
+ <xsl:variable name="math_text">
4096
+ <xsl:value-of select="normalize-space($mathml)"/>
4097
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
4098
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
4099
+ </xsl:variable>
4100
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4101
+ </xsl:if>
4102
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
4103
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
4104
+
4105
+ <!-- via intermediate format -->
4106
+
4107
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
4108
+
4109
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
4110
+
4111
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
4112
+
4113
+ <!-- get current table id -->
4114
+ <xsl:variable name="table_id" select="@id"/>
4115
+ <!-- find table by id in the file 'table_widths' -->
4116
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
4117
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
4118
+
4119
+ <!-- table='<xsl:copy-of select="$table"/>' -->
4120
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
4121
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
4122
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
4123
+
4124
+ <xsl:variable name="table_with_cell_widths_">
4125
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
4126
+ </xsl:variable>
4127
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
4128
+
4129
+ <!-- <xsl:if test="$table_if_debug = 'true'">
4130
+ <xsl:copy-of select="$table_with_cell_widths"/>
4131
+ </xsl:if> -->
4132
+
4133
+
4134
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
4135
+
4136
+ <xsl:variable name="column_widths_">
4137
+ <!-- iteration of columns -->
4138
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
4139
+ <xsl:variable name="pos" select="position()"/>
4140
+ <column>
4141
+ <xsl:attribute name="width_max">
4142
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
4143
+ <xsl:sort select="." data-type="number" order="descending"/>
4144
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4145
+ </xsl:for-each>
4146
+ </xsl:attribute>
4147
+ <xsl:attribute name="width_min">
4148
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
4149
+ <xsl:sort select="." data-type="number" order="descending"/>
4150
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4151
+ </xsl:for-each>
4152
+ </xsl:attribute>
4153
+ </column>
3915
4154
  </xsl:for-each>
3916
4155
  </xsl:variable>
4156
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
4157
+
4158
+ <!-- <column_widths>
4159
+ <xsl:copy-of select="$column_widths"/>
4160
+ </column_widths> -->
4161
+
4162
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
4163
+ <xsl:variable name="table_widths_">
4164
+ <table>
4165
+ <xsl:attribute name="width_max">
4166
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
4167
+ </xsl:attribute>
4168
+ <xsl:attribute name="width_min">
4169
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
4170
+ </xsl:attribute>
4171
+ </table>
4172
+ </xsl:variable>
4173
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
4174
+
4175
+ <xsl:variable name="page_width">
4176
+ <xsl:choose>
4177
+ <xsl:when test="$parent_table_page-width != ''">
4178
+ <xsl:value-of select="$parent_table_page-width"/>
4179
+ </xsl:when>
4180
+ <xsl:otherwise>
4181
+ <xsl:value-of select="@page-width"/>
4182
+ </xsl:otherwise>
4183
+ </xsl:choose>
4184
+ </xsl:variable>
4185
+
4186
+ <xsl:if test="$table_if_debug = 'true'">
4187
+ <table_width>
4188
+ <xsl:copy-of select="$table_widths"/>
4189
+ </table_width>
4190
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
4191
+ </xsl:if>
4192
+
4193
+
4194
+ <!-- There are three cases: -->
4195
+ <xsl:choose>
4196
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
4197
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
4198
+ <!-- call old algorithm -->
4199
+ <case1/>
4200
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
4201
+ <xsl:call-template name="calculate-column-widths-proportional">
4202
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4203
+ <xsl:with-param name="table" select="$table"/>
4204
+ </xsl:call-template> -->
4205
+ </xsl:when>
4206
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
4207
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
4208
+ <case2/>
4209
+ <autolayout/>
4210
+ <xsl:for-each select="$column_widths/column/@width_max">
4211
+ <column divider="100"><xsl:value-of select="."/></column>
4212
+ </xsl:for-each>
4213
+ </xsl:when>
4214
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
4215
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
4216
+ Lets also call D the difference between maximum and minimum width of the table.
4217
+ For each column, let d be the difference between maximum and minimum width of that column.
4218
+ Now set the column's width to the minimum width plus d times W over D.
4219
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
4220
+ <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)">
4221
+ <!-- difference between the available space and the minimum table width -->
4222
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
4223
+ <W><xsl:value-of select="$W"/></W>
4224
+ <!-- difference between maximum and minimum width of the table -->
4225
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
4226
+ <D><xsl:value-of select="$D"/></D>
4227
+ <case3/>
4228
+ <autolayout/>
4229
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
4230
+ <split_keep-within-line>true</split_keep-within-line>
4231
+ </xsl:if>
4232
+ <xsl:for-each select="$column_widths/column">
4233
+ <!-- difference between maximum and minimum width of that column. -->
4234
+ <xsl:variable name="d" select="@width_max - @width_min"/>
4235
+ <d><xsl:value-of select="$d"/></d>
4236
+ <width_min><xsl:value-of select="@width_min"/></width_min>
4237
+ <e><xsl:value-of select="$d * $W div $D"/></e>
4238
+ <!-- set the column's width to the minimum width plus d times W over D. -->
4239
+ <column divider="100">
4240
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4241
+ </column>
4242
+ </xsl:for-each>
4243
+
4244
+ </xsl:when>
4245
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
4246
+ </xsl:choose>
4247
+
4248
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
4249
+
4250
+ <!-- if nested 'dl' or 'table' -->
4251
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
4252
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
4253
+
4254
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
4255
+
4256
+ <xsl:variable name="parent_table_page-width_">
4257
+ <xsl:if test="$parent_table_id != ''">
4258
+ <!-- determine column number in the parent table -->
4259
+ <xsl:variable name="parent_table_column_number">
4260
+ <xsl:choose>
4261
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
4262
+ <xsl:otherwise> <!-- parent is table -->
4263
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
4264
+ </xsl:otherwise>
4265
+ </xsl:choose>
4266
+ </xsl:variable>
4267
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
4268
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
4269
+ </xsl:if>
4270
+ </xsl:variable>
4271
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
4272
+
4273
+ <!-- get current table id -->
4274
+ <xsl:variable name="table_id" select="@id"/>
4275
+
4276
+ <xsl:choose>
4277
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
4278
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
4279
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
4280
+ </xsl:when>
4281
+ <xsl:otherwise>
4282
+ <!-- recalculate columns width based on parent table width -->
4283
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
4284
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
4285
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
4286
+ </xsl:call-template>
4287
+ </xsl:for-each>
4288
+ </xsl:otherwise>
4289
+ </xsl:choose>
3917
4290
 
3918
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3919
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4291
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
4292
+ <xsl:copy>
4293
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
4294
+ </xsl:copy>
4295
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
4296
+ <xsl:copy>
4297
+ <xsl:copy-of select="@*"/>
4298
+
4299
+ <!-- The maximum width is given by the widest line. -->
4300
+ <xsl:attribute name="width_max">
4301
+ <xsl:for-each select="p_len">
4302
+ <xsl:sort select="." data-type="number" order="descending"/>
4303
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4304
+ </xsl:for-each>
4305
+ </xsl:attribute>
4306
+
4307
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4308
+ <xsl:variable name="width_min">
4309
+ <xsl:for-each select="word_len">
4310
+ <xsl:sort select="." data-type="number" order="descending"/>
4311
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4312
+ </xsl:for-each>
4313
+ </xsl:variable>
4314
+ <xsl:attribute name="width_min">
4315
+ <xsl:value-of select="$width_min"/>
4316
+ </xsl:attribute>
4317
+
4318
+ <xsl:if test="$width_min = 0">
4319
+ <xsl:attribute name="width_min">1</xsl:attribute>
4320
+ </xsl:if>
4321
+
4322
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
4323
+
4324
+ </xsl:copy>
3920
4325
  </xsl:template><xsl:template match="*[local-name()='thead']">
3921
4326
  <xsl:param name="cols-count"/>
3922
4327
  <fo:table-header>
@@ -4007,6 +4412,7 @@
4007
4412
  </xsl:for-each>
4008
4413
  </xsl:when>
4009
4414
  <xsl:otherwise>
4415
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
4010
4416
  <xsl:call-template name="insertTableColumnWidth">
4011
4417
  <xsl:with-param name="colwidths" select="$colwidths"/>
4012
4418
  </xsl:call-template>
@@ -4099,6 +4505,52 @@
4099
4505
 
4100
4506
  </fo:table-body>
4101
4507
 
4508
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4509
+ <xsl:param name="table_or_dl">table</xsl:param>
4510
+ <xsl:apply-templates mode="process_table-if">
4511
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4512
+ </xsl:apply-templates>
4513
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4514
+ <xsl:param name="table_or_dl">table</xsl:param>
4515
+
4516
+ <fo:table-body>
4517
+ <xsl:for-each select="*[local-name() = 'tr']">
4518
+ <xsl:variable name="col_count" select="count(*)"/>
4519
+
4520
+ <!-- iteration for each tr/td -->
4521
+
4522
+ <xsl:choose>
4523
+ <xsl:when test="$table_or_dl = 'table'">
4524
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4525
+ <fo:table-row number-columns-spanned="{$col_count}">
4526
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4527
+ <xsl:call-template name="td"/>
4528
+ </fo:table-row>
4529
+ </xsl:for-each>
4530
+ </xsl:when>
4531
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4532
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4533
+ <xsl:variable name="is_dt" select="position() = 1"/>
4534
+
4535
+ <xsl:for-each select="*">
4536
+ <!-- <test><xsl:copy-of select="."/></test> -->
4537
+ <fo:table-row number-columns-spanned="{$col_count}">
4538
+ <xsl:choose>
4539
+ <xsl:when test="$is_dt">
4540
+ <xsl:call-template name="insert_dt_cell"/>
4541
+ </xsl:when>
4542
+ <xsl:otherwise>
4543
+ <xsl:call-template name="insert_dd_cell"/>
4544
+ </xsl:otherwise>
4545
+ </xsl:choose>
4546
+ </fo:table-row>
4547
+ </xsl:for-each>
4548
+ </xsl:for-each>
4549
+ </xsl:otherwise>
4550
+ </xsl:choose>
4551
+
4552
+ </xsl:for-each>
4553
+ </fo:table-body>
4102
4554
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4103
4555
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4104
4556
 
@@ -4204,7 +4656,7 @@
4204
4656
  </xsl:choose>
4205
4657
  </xsl:attribute>
4206
4658
  </xsl:if>
4207
- </xsl:template><xsl:template match="*[local-name()='td']">
4659
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
4208
4660
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
4209
4661
  <xsl:call-template name="setTextAlignment">
4210
4662
  <xsl:with-param name="default">left</xsl:with-param>
@@ -4246,11 +4698,24 @@
4246
4698
 
4247
4699
  <xsl:call-template name="setTableCellAttributes"/>
4248
4700
 
4701
+ <xsl:if test="$isGenerateTableIF = 'true'">
4702
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4703
+ <xsl:attribute name="text-align">left</xsl:attribute>
4704
+ </xsl:if>
4705
+
4249
4706
  <fo:block>
4250
4707
 
4708
+ <xsl:if test="$isGenerateTableIF = 'true'">
4709
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4710
+ </xsl:if>
4711
+
4712
+
4251
4713
 
4252
4714
 
4253
4715
  <xsl:apply-templates/>
4716
+
4717
+ <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"/> -->
4718
+
4254
4719
  </fo:block>
4255
4720
  </fo:table-cell>
4256
4721
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -4457,9 +4922,9 @@
4457
4922
  <!-- current hierarchy is 'figure' element -->
4458
4923
  <xsl:variable name="following_dl_colwidths">
4459
4924
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4460
- <xsl:variable name="html-table">
4461
- <xsl:variable name="doc_ns">
4462
-
4925
+ <xsl:variable name="simple-table">
4926
+ <!-- <xsl:variable name="doc_ns">
4927
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4463
4928
  </xsl:variable>
4464
4929
  <xsl:variable name="ns">
4465
4930
  <xsl:choose>
@@ -4470,7 +4935,7 @@
4470
4935
  <xsl:value-of select="substring-before(name(/*), '-')"/>
4471
4936
  </xsl:otherwise>
4472
4937
  </xsl:choose>
4473
- </xsl:variable>
4938
+ </xsl:variable> -->
4474
4939
 
4475
4940
  <xsl:for-each select="*[local-name() = 'dl'][1]">
4476
4941
  <tbody>
@@ -4481,7 +4946,7 @@
4481
4946
 
4482
4947
  <xsl:call-template name="calculate-column-widths">
4483
4948
  <xsl:with-param name="cols-count" select="2"/>
4484
- <xsl:with-param name="table" select="$html-table"/>
4949
+ <xsl:with-param name="table" select="$simple-table"/>
4485
4950
  </xsl:call-template>
4486
4951
 
4487
4952
  </xsl:if>
@@ -4600,8 +5065,10 @@
4600
5065
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4601
5066
  </xsl:variable>
4602
5067
 
5068
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
5069
+
4603
5070
  <xsl:choose>
4604
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
5071
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4605
5072
 
4606
5073
  <fo:block margin-bottom="12pt" text-align="left">
4607
5074
 
@@ -4616,7 +5083,7 @@
4616
5083
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4617
5084
  </fo:block>
4618
5085
 
4619
- </xsl:when>
5086
+ </xsl:when> <!-- END: only one component -->
4620
5087
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4621
5088
  <fo:block margin-bottom="12pt" text-align="left">
4622
5089
 
@@ -4632,8 +5099,8 @@
4632
5099
  </xsl:variable>
4633
5100
  <xsl:value-of select="$title-where"/>:
4634
5101
  </fo:block>
4635
- </xsl:when>
4636
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
5102
+ </xsl:when> <!-- END: a few components -->
5103
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4637
5104
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4638
5105
 
4639
5106
 
@@ -4646,11 +5113,11 @@
4646
5113
  </xsl:variable>
4647
5114
  <xsl:value-of select="$title-key"/>
4648
5115
  </fo:block>
4649
- </xsl:when>
5116
+ </xsl:when> <!-- END: definition list in a figure -->
4650
5117
  </xsl:choose>
4651
5118
 
4652
5119
  <!-- a few components -->
4653
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
5120
+ <xsl:if test="$onlyOneComponent = 'false'">
4654
5121
  <fo:block>
4655
5122
 
4656
5123
 
@@ -4660,12 +5127,31 @@
4660
5127
 
4661
5128
 
4662
5129
 
5130
+
5131
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
5132
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5133
+ </xsl:if>
5134
+
4663
5135
  <fo:block>
4664
5136
 
4665
5137
 
4666
5138
 
4667
5139
 
5140
+ <xsl:apply-templates select="*[local-name() = 'name']">
5141
+ <xsl:with-param name="process">true</xsl:with-param>
5142
+ </xsl:apply-templates>
5143
+
5144
+ <xsl:if test="$isGenerateTableIF = 'true'">
5145
+ <!-- to determine start of table -->
5146
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
5147
+ </xsl:if>
5148
+
4668
5149
  <fo:table width="95%" table-layout="fixed">
5150
+
5151
+ <xsl:if test="$isGenerateTableIF = 'true'">
5152
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
5153
+ </xsl:if>
5154
+
4669
5155
 
4670
5156
  <xsl:choose>
4671
5157
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4674,69 +5160,174 @@
4674
5160
 
4675
5161
  </xsl:when>
4676
5162
  </xsl:choose>
4677
- <!-- create virtual html table for dl/[dt and dd] -->
4678
- <xsl:variable name="html-table">
4679
- <xsl:variable name="doc_ns">
5163
+
5164
+
5165
+
5166
+ <xsl:choose>
5167
+ <xsl:when test="$isGenerateTableIF = 'true'">
5168
+ <!-- generate IF for table widths -->
5169
+ <!-- example:
5170
+ <tr>
5171
+ <td valign="top" align="left" id="tab-symdu_1_1">
5172
+ <p>Symbol</p>
5173
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
5174
+ </td>
5175
+ <td valign="top" align="left" id="tab-symdu_1_2">
5176
+ <p>Description</p>
5177
+ <word id="tab-symdu_1_2_word_1">Description</word>
5178
+ </td>
5179
+ </tr>
5180
+ -->
4680
5181
 
4681
- </xsl:variable>
4682
- <xsl:variable name="ns">
4683
- <xsl:choose>
4684
- <xsl:when test="normalize-space($doc_ns) != ''">
4685
- <xsl:value-of select="normalize-space($doc_ns)"/>
4686
- </xsl:when>
4687
- <xsl:otherwise>
4688
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4689
- </xsl:otherwise>
4690
- </xsl:choose>
4691
- </xsl:variable>
4692
- <tbody>
4693
- <xsl:apply-templates mode="dl"/>
4694
- </tbody>
4695
- </xsl:variable>
4696
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4697
- <xsl:variable name="colwidths">
4698
- <xsl:call-template name="calculate-column-widths">
4699
- <xsl:with-param name="cols-count" select="2"/>
4700
- <xsl:with-param name="table" select="$html-table"/>
4701
- </xsl:call-template>
4702
- </xsl:variable>
4703
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4704
- <xsl:variable name="maxlength_dt">
4705
- <xsl:call-template name="getMaxLength_dt"/>
4706
- </xsl:variable>
4707
- <xsl:variable name="isContainsExpressReference_">
4708
- false
4709
- </xsl:variable>
4710
- <xsl:variable name="isContainsExpressReference" select="normalize-space($isContainsExpressReference_)"/>
4711
- <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4712
- <xsl:call-template name="setColumnWidth_dl">
4713
- <xsl:with-param name="colwidths" select="$colwidths"/>
4714
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4715
- <xsl:with-param name="isContainsExpressReference" select="$isContainsExpressReference"/>
4716
- </xsl:call-template>
4717
- <fo:table-body>
4718
- <xsl:apply-templates>
4719
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4720
- </xsl:apply-templates>
4721
- </fo:table-body>
5182
+ <!-- create virtual html table for dl/[dt and dd] -->
5183
+ <xsl:variable name="simple-table">
5184
+
5185
+ <xsl:variable name="dl_table">
5186
+ <tbody>
5187
+ <xsl:apply-templates mode="dl_if">
5188
+ <xsl:with-param name="id" select="@id"/>
5189
+ </xsl:apply-templates>
5190
+ </tbody>
5191
+ </xsl:variable>
5192
+
5193
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
5194
+
5195
+ <!-- Step: replace <br/> to <p>...</p> -->
5196
+ <xsl:variable name="table_without_br">
5197
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
5198
+ </xsl:variable>
5199
+
5200
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
5201
+
5202
+ <!-- Step: add id to each cell -->
5203
+ <!-- add <word>...</word> for each word, image, math -->
5204
+ <xsl:variable name="simple-table-id">
5205
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
5206
+ <xsl:with-param name="id" select="@id"/>
5207
+ </xsl:apply-templates>
5208
+ </xsl:variable>
5209
+
5210
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
5211
+
5212
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5213
+
5214
+ </xsl:variable>
5215
+
5216
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
5217
+
5218
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
5219
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
5220
+ </xsl:apply-templates>
5221
+
5222
+ </xsl:when>
5223
+ <xsl:otherwise>
5224
+
5225
+ <xsl:variable name="simple-table">
5226
+
5227
+ <xsl:variable name="dl_table">
5228
+ <tbody>
5229
+ <xsl:apply-templates mode="dl">
5230
+ <xsl:with-param name="id" select="@id"/>
5231
+ </xsl:apply-templates>
5232
+ </tbody>
5233
+ </xsl:variable>
5234
+
5235
+ <xsl:copy-of select="$dl_table"/>
5236
+ </xsl:variable>
5237
+
5238
+ <xsl:variable name="colwidths">
5239
+ <xsl:call-template name="calculate-column-widths">
5240
+ <xsl:with-param name="cols-count" select="2"/>
5241
+ <xsl:with-param name="table" select="$simple-table"/>
5242
+ </xsl:call-template>
5243
+ </xsl:variable>
5244
+
5245
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
5246
+ DEBUG
5247
+ colwidths=<xsl:copy-of select="$colwidths"/>
5248
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
5249
+
5250
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
5251
+
5252
+ <xsl:variable name="maxlength_dt">
5253
+ <xsl:call-template name="getMaxLength_dt"/>
5254
+ </xsl:variable>
5255
+
5256
+ <xsl:variable name="isContainsKeepTogetherTag_">
5257
+ false
5258
+ </xsl:variable>
5259
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
5260
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
5261
+
5262
+
5263
+ <xsl:call-template name="setColumnWidth_dl">
5264
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5265
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5266
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
5267
+ </xsl:call-template>
5268
+
5269
+ <fo:table-body>
5270
+
5271
+ <!-- DEBUG -->
5272
+ <xsl:if test="$table_if_debug = 'true'">
5273
+ <fo:table-row>
5274
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
5275
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5276
+ </fo:table-cell>
5277
+ </fo:table-row>
5278
+ </xsl:if>
5279
+
5280
+ <xsl:apply-templates>
5281
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
5282
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
5283
+ </xsl:apply-templates>
5284
+
5285
+ </fo:table-body>
5286
+ </xsl:otherwise>
5287
+ </xsl:choose>
4722
5288
  </fo:table>
4723
5289
  </fo:block>
4724
5290
  </fo:block>
4725
- </xsl:if>
5291
+ </xsl:if> <!-- END: a few components -->
4726
5292
  </fo:block-container>
4727
5293
  </fo:block-container>
5294
+
5295
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
5296
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
5297
+ </xsl:if>
5298
+
5299
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
5300
+ <xsl:param name="process">false</xsl:param>
5301
+ <xsl:if test="$process = 'true'">
5302
+ <fo:block xsl:use-attribute-sets="dl-name-style">
5303
+ <xsl:apply-templates/>
5304
+ </fo:block>
5305
+ </xsl:if>
4728
5306
  </xsl:template><xsl:template name="setColumnWidth_dl">
4729
5307
  <xsl:param name="colwidths"/>
4730
5308
  <xsl:param name="maxlength_dt"/>
4731
- <xsl:param name="isContainsExpressReference"/>
5309
+ <xsl:param name="isContainsKeepTogetherTag"/>
5310
+
5311
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
5312
+
4732
5313
  <xsl:choose>
5314
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5315
+ <xsl:call-template name="insertTableColumnWidth">
5316
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5317
+ </xsl:call-template>
5318
+ </xsl:when>
4733
5319
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4734
5320
  <fo:table-column column-width="50%"/>
4735
5321
  <fo:table-column column-width="50%"/>
4736
5322
  </xsl:when>
4737
5323
  <xsl:otherwise>
4738
5324
  <xsl:choose>
4739
- <xsl:when test="$isContainsExpressReference">
5325
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5326
+ <xsl:call-template name="insertTableColumnWidth">
5327
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5328
+ </xsl:call-template>
5329
+ </xsl:when>
5330
+ <xsl:when test="$isContainsKeepTogetherTag">
4740
5331
  <xsl:call-template name="insertTableColumnWidth">
4741
5332
  <xsl:with-param name="colwidths" select="$colwidths"/>
4742
5333
  </xsl:call-template>
@@ -4780,13 +5371,19 @@
4780
5371
  </xsl:choose>
4781
5372
  </xsl:template><xsl:template name="insertTableColumnWidth">
4782
5373
  <xsl:param name="colwidths"/>
5374
+
4783
5375
  <xsl:for-each select="xalan:nodeset($colwidths)//column">
4784
5376
  <xsl:choose>
4785
5377
  <xsl:when test=". = 1 or . = 0">
4786
5378
  <fo:table-column column-width="proportional-column-width(2)"/>
4787
5379
  </xsl:when>
4788
5380
  <xsl:otherwise>
4789
- <fo:table-column column-width="proportional-column-width({.})"/>
5381
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
5382
+ <xsl:variable name="divider">
5383
+ <xsl:value-of select="@divider"/>
5384
+ <xsl:if test="not(@divider)">1</xsl:if>
5385
+ </xsl:variable>
5386
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4790
5387
  </xsl:otherwise>
4791
5388
  </xsl:choose>
4792
5389
  </xsl:for-each>
@@ -4813,7 +5410,6 @@
4813
5410
  <xsl:value-of select="$maxLength"/>
4814
5411
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4815
5412
  <xsl:param name="key_iso"/>
4816
-
4817
5413
  <!-- <tr>
4818
5414
  <td>NOTE</td>
4819
5415
  <td>
@@ -4821,27 +5417,47 @@
4821
5417
  </td>
4822
5418
  </tr>
4823
5419
  -->
4824
- <fo:table-row>
5420
+ <!-- OLD Variant -->
5421
+ <!-- <fo:table-row>
4825
5422
  <fo:table-cell>
4826
5423
  <fo:block margin-top="6pt">
4827
5424
  <xsl:if test="normalize-space($key_iso) = 'true'">
4828
5425
  <xsl:attribute name="margin-top">0</xsl:attribute>
4829
5426
  </xsl:if>
4830
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5427
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4831
5428
  </fo:block>
4832
5429
  </fo:table-cell>
4833
5430
  <fo:table-cell>
4834
5431
  <fo:block>
4835
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5432
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
5433
+ </fo:block>
5434
+ </fo:table-cell>
5435
+ </fo:table-row> -->
5436
+ <!-- <tr>
5437
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
5438
+ </tr>
5439
+ -->
5440
+ <fo:table-row>
5441
+ <fo:table-cell number-columns-spanned="2">
5442
+ <fo:block>
5443
+ <xsl:call-template name="note"/>
4836
5444
  </fo:block>
4837
5445
  </fo:table-cell>
4838
5446
  </fo:table-row>
4839
5447
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
5448
+ <xsl:param name="id"/>
5449
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4840
5450
  <tr>
4841
5451
  <td>
5452
+ <xsl:attribute name="id">
5453
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5454
+ </xsl:attribute>
4842
5455
  <xsl:apply-templates/>
4843
5456
  </td>
4844
5457
  <td>
5458
+ <xsl:attribute name="id">
5459
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5460
+ </xsl:attribute>
4845
5461
 
4846
5462
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4847
5463
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4852,60 +5468,144 @@
4852
5468
 
4853
5469
  </xsl:template><xsl:template match="*[local-name()='dt']">
4854
5470
  <xsl:param name="key_iso"/>
5471
+ <xsl:param name="split_keep-within-line"/>
4855
5472
 
4856
5473
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4857
- <fo:table-cell>
5474
+ <xsl:call-template name="insert_dt_cell">
5475
+ <xsl:with-param name="key_iso" select="$key_iso"/>
5476
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5477
+ </xsl:call-template>
5478
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
5479
+ <xsl:call-template name="insert_dd_cell">
5480
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5481
+ </xsl:call-template>
5482
+ </xsl:for-each>
5483
+ </fo:table-row>
5484
+ </xsl:template><xsl:template name="insert_dt_cell">
5485
+ <xsl:param name="key_iso"/>
5486
+ <xsl:param name="split_keep-within-line"/>
5487
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
5488
+
5489
+ <xsl:if test="$isGenerateTableIF = 'true'">
5490
+ <!-- border is mandatory, to calculate real width -->
5491
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5492
+ <xsl:attribute name="text-align">left</xsl:attribute>
5493
+ </xsl:if>
5494
+
5495
+
5496
+ <xsl:if test="ancestor::*[1][local-name() = 'dl']/preceding-sibling::*[1][local-name() = 'formula']">
5497
+ <xsl:attribute name="padding-right">3mm</xsl:attribute>
5498
+ </xsl:if>
5499
+
5500
+ <fo:block xsl:use-attribute-sets="dt-block-style">
5501
+ <xsl:copy-of select="@id"/>
4858
5502
 
4859
- <xsl:if test="ancestor::*[1][local-name() = 'dl']/preceding-sibling::*[1][local-name() = 'formula']">
4860
- <xsl:attribute name="padding-right">3mm</xsl:attribute>
4861
- </xsl:if>
5503
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5504
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5505
+ </xsl:if>
4862
5506
 
4863
- <fo:block xsl:use-attribute-sets="dt-style">
4864
- <xsl:copy-of select="@id"/>
4865
-
4866
- <xsl:if test="normalize-space($key_iso) = 'true'">
4867
- <xsl:attribute name="margin-top">0</xsl:attribute>
5507
+
5508
+ <xsl:if test="ancestor::*[1][local-name() = 'dl']/preceding-sibling::*[1][local-name() = 'formula']">
5509
+ <xsl:attribute name="text-align">right</xsl:attribute>
4868
5510
  </xsl:if>
4869
-
4870
-
4871
- <xsl:if test="ancestor::*[1][local-name() = 'dl']/preceding-sibling::*[1][local-name() = 'formula']">
4872
- <xsl:attribute name="text-align">right</xsl:attribute>
4873
- </xsl:if>
4874
-
4875
-
4876
- <xsl:apply-templates/>
4877
- </fo:block>
4878
- </fo:table-cell>
4879
- <fo:table-cell>
4880
- <fo:block>
4881
-
4882
- <xsl:attribute name="text-align">justify</xsl:attribute>
4883
-
5511
+
5512
+
5513
+ <xsl:apply-templates>
5514
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5515
+ </xsl:apply-templates>
5516
+
5517
+ <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"/> -->
5518
+
5519
+ </fo:block>
5520
+ </fo:table-cell>
5521
+ </xsl:template><xsl:template name="insert_dd_cell">
5522
+ <xsl:param name="split_keep-within-line"/>
5523
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5524
+
5525
+ <xsl:if test="$isGenerateTableIF = 'true'">
5526
+ <!-- border is mandatory, to calculate real width -->
5527
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5528
+ </xsl:if>
5529
+
5530
+ <fo:block>
5531
+
5532
+ <xsl:if test="$isGenerateTableIF = 'true'">
5533
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5534
+ </xsl:if>
5535
+
5536
+
5537
+ <xsl:attribute name="text-align">justify</xsl:attribute>
5538
+
4884
5539
 
4885
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4886
- <xsl:with-param name="process">true</xsl:with-param>
4887
- </xsl:apply-templates>
4888
- </fo:block>
4889
- </fo:table-cell>
4890
- </fo:table-row>
5540
+ <xsl:choose>
5541
+ <xsl:when test="$isGenerateTableIF = 'true'">
5542
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5543
+ <xsl:with-param name="process">true</xsl:with-param>
5544
+ </xsl:apply-templates>
5545
+ </xsl:when>
5546
+ <xsl:otherwise>
5547
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5548
+ <xsl:with-param name="process">true</xsl:with-param>
5549
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5550
+ </xsl:apply-templates>
5551
+ </xsl:otherwise>
5552
+
5553
+ </xsl:choose>
5554
+
5555
+ <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"/> -->
5556
+
5557
+ </fo:block>
5558
+ </fo:table-cell>
4891
5559
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4892
5560
  <xsl:apply-templates/>
4893
5561
  </xsl:template><xsl:template match="*[local-name()='dd']">
4894
5562
  <xsl:param name="process">false</xsl:param>
5563
+ <xsl:param name="split_keep-within-line"/>
4895
5564
  <xsl:if test="$process = 'true'">
4896
5565
  <xsl:apply-templates select="@language"/>
4897
- <xsl:apply-templates/>
5566
+ <xsl:apply-templates>
5567
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5568
+ </xsl:apply-templates>
4898
5569
  </xsl:if>
4899
5570
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4900
5571
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4901
- </xsl:template><xsl:template match="*[local-name()='em']">
5572
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5573
+ <xsl:param name="id"/>
5574
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5575
+ <tr>
5576
+ <td>
5577
+ <xsl:copy-of select="node()"/>
5578
+ </td>
5579
+ <td>
5580
+
5581
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
5582
+
5583
+ <!-- get paragraphs from nested 'dl' -->
5584
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
5585
+
5586
+
5587
+ </td>
5588
+ </tr>
5589
+
5590
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
5591
+ <xsl:for-each select="*[local-name() = 'dt']">
5592
+ <p>
5593
+ <xsl:copy-of select="node()"/>
5594
+ <xsl:text> </xsl:text>
5595
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
5596
+ </p>
5597
+ </xsl:for-each>
5598
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
4902
5599
  <fo:inline font-style="italic">
4903
5600
  <xsl:apply-templates/>
4904
5601
  </fo:inline>
4905
5602
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5603
+ <xsl:param name="split_keep-within-line"/>
4906
5604
  <fo:inline font-weight="bold">
4907
5605
 
4908
- <xsl:apply-templates/>
5606
+ <xsl:apply-templates>
5607
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5608
+ </xsl:apply-templates>
4909
5609
  </fo:inline>
4910
5610
  </xsl:template><xsl:template match="*[local-name()='padding']">
4911
5611
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4926,7 +5626,7 @@
4926
5626
 
4927
5627
 
4928
5628
 
4929
-
5629
+ <!-- 10 -->
4930
5630
 
4931
5631
 
4932
5632
 
@@ -4944,13 +5644,15 @@
4944
5644
  <xsl:choose>
4945
5645
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4946
5646
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4947
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5647
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4948
5648
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4949
5649
  </xsl:choose>
4950
5650
  </xsl:attribute>
4951
5651
  </xsl:if>
4952
5652
  <xsl:apply-templates/>
4953
5653
  </fo:inline>
5654
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
5655
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4954
5656
  </xsl:template><xsl:template match="*[local-name()='underline']">
4955
5657
  <fo:inline text-decoration="underline">
4956
5658
  <xsl:apply-templates/>
@@ -5098,54 +5800,120 @@
5098
5800
  <fo:block break-after="page"/>
5099
5801
  <fo:block> </fo:block>
5100
5802
  <fo:block break-after="page"/>
5803
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5804
+ <xsl:apply-templates/>
5101
5805
  </xsl:template><xsl:template name="tokenize">
5102
5806
  <xsl:param name="text"/>
5103
5807
  <xsl:param name="separator" select="' '"/>
5104
5808
  <xsl:choose>
5809
+
5810
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5811
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5812
+ </xsl:when>
5105
5813
  <xsl:when test="not(contains($text, $separator))">
5106
5814
  <word>
5107
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5108
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5109
5815
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
5110
- <xsl:variable name="len_str">
5111
- <xsl:choose>
5112
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5113
- <xsl:value-of select="$len_str_tmp * 1.5"/>
5114
- </xsl:when>
5115
- <xsl:otherwise>
5116
- <xsl:value-of select="$len_str_tmp"/>
5117
- </xsl:otherwise>
5118
- </xsl:choose>
5119
- </xsl:variable>
5120
-
5121
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5122
- <xsl:message>
5123
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5124
- len_str=<xsl:value-of select="$len_str"/>
5125
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5126
- </xsl:message>
5127
- </xsl:if> -->
5128
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5129
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
5130
5816
  <xsl:choose>
5131
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5132
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5817
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5818
+ <xsl:value-of select="$len_str_tmp"/>
5133
5819
  </xsl:when>
5134
5820
  <xsl:otherwise>
5135
- <xsl:value-of select="$len_str"/>
5821
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5822
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5823
+ <xsl:variable name="len_str">
5824
+ <xsl:choose>
5825
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5826
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5827
+ </xsl:when>
5828
+ <xsl:otherwise>
5829
+ <xsl:value-of select="$len_str_tmp"/>
5830
+ </xsl:otherwise>
5831
+ </xsl:choose>
5832
+ </xsl:variable>
5833
+
5834
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5835
+ <xsl:message>
5836
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5837
+ len_str=<xsl:value-of select="$len_str"/>
5838
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5839
+ </xsl:message>
5840
+ </xsl:if> -->
5841
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5842
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5843
+ <xsl:choose>
5844
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5845
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5846
+ </xsl:when>
5847
+ <xsl:otherwise>
5848
+ <xsl:value-of select="$len_str"/>
5849
+ </xsl:otherwise>
5850
+ </xsl:choose>
5136
5851
  </xsl:otherwise>
5137
5852
  </xsl:choose>
5138
5853
  </word>
5139
5854
  </xsl:when>
5140
5855
  <xsl:otherwise>
5141
5856
  <word>
5142
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5857
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5858
+ <xsl:choose>
5859
+ <xsl:when test="$isGenerateTableIF = 'true'">
5860
+ <xsl:value-of select="$word"/>
5861
+ </xsl:when>
5862
+ <xsl:otherwise>
5863
+ <xsl:value-of select="string-length($word)"/>
5864
+ </xsl:otherwise>
5865
+ </xsl:choose>
5143
5866
  </word>
5144
5867
  <xsl:call-template name="tokenize">
5145
5868
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5146
5869
  </xsl:call-template>
5147
5870
  </xsl:otherwise>
5148
5871
  </xsl:choose>
5872
+ </xsl:template><xsl:template name="tokenize_with_tags">
5873
+ <xsl:param name="tags"/>
5874
+ <xsl:param name="text"/>
5875
+ <xsl:param name="separator" select="' '"/>
5876
+ <xsl:choose>
5877
+
5878
+ <xsl:when test="not(contains($text, $separator))">
5879
+ <word>
5880
+ <xsl:call-template name="enclose_text_in_tags">
5881
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5882
+ <xsl:with-param name="tags" select="$tags"/>
5883
+ </xsl:call-template>
5884
+ </word>
5885
+ </xsl:when>
5886
+ <xsl:otherwise>
5887
+ <word>
5888
+ <xsl:call-template name="enclose_text_in_tags">
5889
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5890
+ <xsl:with-param name="tags" select="$tags"/>
5891
+ </xsl:call-template>
5892
+ </word>
5893
+ <xsl:call-template name="tokenize_with_tags">
5894
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5895
+ </xsl:call-template>
5896
+ </xsl:otherwise>
5897
+ </xsl:choose>
5898
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5899
+ <xsl:param name="text"/>
5900
+ <xsl:param name="tags"/>
5901
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5902
+
5903
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5904
+
5905
+ <xsl:choose>
5906
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5907
+ <xsl:otherwise>
5908
+ <xsl:element name="{$tag_name}">
5909
+ <xsl:call-template name="enclose_text_in_tags">
5910
+ <xsl:with-param name="text" select="$text"/>
5911
+ <xsl:with-param name="tags" select="$tags"/>
5912
+ <xsl:with-param name="num" select="$num + 1"/>
5913
+ </xsl:call-template>
5914
+ </xsl:element>
5915
+ </xsl:otherwise>
5916
+ </xsl:choose>
5149
5917
  </xsl:template><xsl:template name="max_length">
5150
5918
  <xsl:param name="words"/>
5151
5919
  <xsl:for-each select="$words//word">
@@ -5246,12 +6014,19 @@
5246
6014
  </xsl:otherwise>
5247
6015
  </xsl:choose>
5248
6016
  </xsl:template><xsl:template name="getSimpleTable">
6017
+ <xsl:param name="id"/>
6018
+
5249
6019
  <xsl:variable name="simple-table">
5250
6020
 
6021
+ <!-- Step 0. replace <br/> to <p>...</p> -->
6022
+ <xsl:variable name="table_without_br">
6023
+ <xsl:apply-templates mode="table-without-br"/>
6024
+ </xsl:variable>
6025
+
5251
6026
  <!-- Step 1. colspan processing -->
5252
6027
  <xsl:variable name="simple-table-colspan">
5253
6028
  <tbody>
5254
- <xsl:apply-templates mode="simple-table-colspan"/>
6029
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
5255
6030
  </tbody>
5256
6031
  </xsl:variable>
5257
6032
 
@@ -5260,10 +6035,67 @@
5260
6035
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
5261
6036
  </xsl:variable>
5262
6037
 
5263
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
5264
-
6038
+ <!-- Step 3: add id to each cell -->
6039
+ <!-- add <word>...</word> for each word, image, math -->
6040
+ <xsl:variable name="simple-table-id">
6041
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
6042
+ <xsl:with-param name="id" select="$id"/>
6043
+ </xsl:apply-templates>
6044
+ </xsl:variable>
6045
+
6046
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
6047
+
5265
6048
  </xsl:variable>
5266
6049
  <xsl:copy-of select="$simple-table"/>
6050
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
6051
+ <xsl:copy>
6052
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
6053
+ </xsl:copy>
6054
+ </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">
6055
+ <xsl:copy>
6056
+ <xsl:copy-of select="@*"/>
6057
+ <p>
6058
+ <xsl:copy-of select="node()"/>
6059
+ </p>
6060
+ </xsl:copy>
6061
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
6062
+ <xsl:copy>
6063
+ <xsl:copy-of select="@*"/>
6064
+ <xsl:for-each select="*[local-name()='br']">
6065
+ <xsl:variable name="current_id" select="generate-id()"/>
6066
+ <p>
6067
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6068
+ <xsl:copy-of select="."/>
6069
+ </xsl:for-each>
6070
+ </p>
6071
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6072
+ <p>
6073
+ <xsl:for-each select="following-sibling::node()">
6074
+ <xsl:copy-of select="."/>
6075
+ </xsl:for-each>
6076
+ </p>
6077
+ </xsl:if>
6078
+ </xsl:for-each>
6079
+ </xsl:copy>
6080
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
6081
+ <xsl:for-each select="*[local-name()='br']">
6082
+ <xsl:variable name="current_id" select="generate-id()"/>
6083
+ <p>
6084
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6085
+ <xsl:copy-of select="."/>
6086
+ </xsl:for-each>
6087
+ </p>
6088
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6089
+ <p>
6090
+ <xsl:for-each select="following-sibling::node()">
6091
+ <xsl:copy-of select="."/>
6092
+ </xsl:for-each>
6093
+ </p>
6094
+ </xsl:if>
6095
+ </xsl:for-each>
6096
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
6097
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
6098
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
5267
6099
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
5268
6100
  <xsl:apply-templates mode="simple-table-colspan"/>
5269
6101
  </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">
@@ -5353,6 +6185,126 @@
5353
6185
  <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5354
6186
  <xsl:with-param name="previousRow" select="$newRow"/>
5355
6187
  </xsl:apply-templates>
6188
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
6189
+ <xsl:param name="id"/>
6190
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
6191
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6192
+ <xsl:with-param name="id" select="$id_prefixed"/>
6193
+ </xsl:apply-templates>
6194
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
6195
+ <xsl:param name="id"/>
6196
+ <xsl:copy>
6197
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6198
+ <xsl:with-param name="id" select="$id"/>
6199
+ </xsl:apply-templates>
6200
+ </xsl:copy>
6201
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
6202
+ <xsl:param name="id"/>
6203
+ <xsl:copy>
6204
+ <xsl:copy-of select="@*"/>
6205
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
6206
+ <xsl:apply-templates select="node()" mode="simple-table-id">
6207
+ <xsl:with-param name="id" select="$id"/>
6208
+ </xsl:apply-templates>
6209
+ </xsl:copy>
6210
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
6211
+ <xsl:param name="id"/>
6212
+ <xsl:copy>
6213
+ <xsl:copy-of select="@*"/>
6214
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
6215
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
6216
+ <xsl:attribute name="id">
6217
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
6218
+ </xsl:attribute>
6219
+
6220
+ <xsl:for-each select="*[local-name() = 'p']">
6221
+ <xsl:copy>
6222
+ <xsl:copy-of select="@*"/>
6223
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
6224
+ <xsl:attribute name="id">
6225
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
6226
+ </xsl:attribute>
6227
+
6228
+ <xsl:copy-of select="node()"/>
6229
+ </xsl:copy>
6230
+ </xsl:for-each>
6231
+
6232
+
6233
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
6234
+
6235
+ <xsl:variable name="td_text">
6236
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
6237
+ </xsl:variable>
6238
+
6239
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
6240
+
6241
+ <xsl:variable name="words">
6242
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
6243
+ <word>
6244
+ <xsl:copy-of select="."/>
6245
+ </word>
6246
+ </xsl:for-each>
6247
+
6248
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
6249
+ <xsl:copy-of select="."/>
6250
+ </xsl:for-each>
6251
+
6252
+ </xsl:variable>
6253
+
6254
+ <xsl:for-each select="xalan:nodeset($words)/word">
6255
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
6256
+ <xsl:copy>
6257
+ <xsl:attribute name="id">
6258
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
6259
+ </xsl:attribute>
6260
+ <xsl:copy-of select="node()"/>
6261
+ </xsl:copy>
6262
+ </xsl:for-each>
6263
+ </xsl:if>
6264
+ </xsl:copy>
6265
+
6266
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
6267
+ <xsl:copy>
6268
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
6269
+ </xsl:copy>
6270
+ </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">
6271
+ <xsl:variable name="formatting_tags">
6272
+ <xsl:call-template name="getFormattingTags"/>
6273
+ </xsl:variable>
6274
+ <word>
6275
+ <xsl:call-template name="enclose_text_in_tags">
6276
+ <xsl:with-param name="text" select="normalize-space(.)"/>
6277
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6278
+ </xsl:call-template>
6279
+ </word>
6280
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
6281
+
6282
+ <xsl:variable name="td_text" select="."/>
6283
+
6284
+ <xsl:variable name="string_with_added_zerospaces">
6285
+ <xsl:call-template name="add-zero-spaces-java">
6286
+ <xsl:with-param name="text" select="$td_text"/>
6287
+ </xsl:call-template>
6288
+ </xsl:variable>
6289
+
6290
+ <xsl:variable name="formatting_tags">
6291
+ <xsl:call-template name="getFormattingTags"/>
6292
+ </xsl:variable>
6293
+
6294
+ <!-- <word>text</word> -->
6295
+ <xsl:call-template name="tokenize_with_tags">
6296
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6297
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
6298
+ </xsl:call-template>
6299
+ </xsl:template><xsl:template name="getFormattingTags">
6300
+ <tags>
6301
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
6302
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
6303
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6304
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6305
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6306
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6307
+ </tags>
5356
6308
  </xsl:template><xsl:template name="getLang">
5357
6309
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5358
6310
  <xsl:variable name="language">
@@ -5521,7 +6473,9 @@
5521
6473
  <!-- replace start and end spaces to non-break space -->
5522
6474
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
5523
6475
  </xsl:copy>
5524
- </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
6476
+ </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="mathml:mtd/mathml:mo/text()[. = '/']" mode="mathml">
6477
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
6478
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5525
6479
  <xsl:variable name="target">
5526
6480
  <xsl:choose>
5527
6481
  <xsl:when test="@updatetype = 'true'">
@@ -6341,7 +7295,11 @@
6341
7295
  <xsl:apply-templates mode="bookmarks"/>
6342
7296
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
6343
7297
  <xsl:apply-templates select="."/>
6344
- </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
7298
+ </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'span']" mode="contents">
7299
+ <xsl:apply-templates mode="contents"/>
7300
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
7301
+ <xsl:apply-templates mode="bookmarks"/>
7302
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
6345
7303
  <xsl:apply-templates mode="bookmarks"/>
6346
7304
  </xsl:template><xsl:template name="addBookmarks">
6347
7305
  <xsl:param name="contents"/>
@@ -6623,7 +7581,9 @@
6623
7581
  <xsl:apply-templates/>
6624
7582
  </xsl:otherwise>
6625
7583
  </xsl:choose>
6626
- </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
7584
+ </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">
7585
+ <xsl:value-of select="."/>
7586
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6627
7587
  <xsl:text> </xsl:text>
6628
7588
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6629
7589
  <xsl:copy>
@@ -6654,9 +7614,22 @@
6654
7614
  </xsl:when>
6655
7615
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6656
7616
  </xsl:choose>
7617
+ </xsl:template><xsl:template match="text()" mode="contents_item">
7618
+ <xsl:call-template name="keep_together_standard_number"/>
7619
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
7620
+ <xsl:apply-templates mode="contents_item"/>
6657
7621
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6658
7622
 
6659
7623
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7624
+
7625
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7626
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7627
+ </xsl:if>
7628
+
7629
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7630
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7631
+ </xsl:if>
7632
+
6660
7633
  <xsl:copy-of select="@id"/>
6661
7634
 
6662
7635
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6681,7 +7654,7 @@
6681
7654
 
6682
7655
 
6683
7656
 
6684
-
7657
+ <!-- 9 -->
6685
7658
 
6686
7659
 
6687
7660
  10
@@ -6765,7 +7738,7 @@
6765
7738
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6766
7739
  <xsl:choose>
6767
7740
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6768
- <xsl:call-template name="interspers">
7741
+ <xsl:call-template name="interspers-java">
6769
7742
  <xsl:with-param name="str" select="."/>
6770
7743
  </xsl:call-template>
6771
7744
  </xsl:when>
@@ -6815,6 +7788,10 @@
6815
7788
  <xsl:with-param name="char" select="$char"/>
6816
7789
  </xsl:call-template>
6817
7790
  </xsl:if>
7791
+ </xsl:template><xsl:template name="interspers-java">
7792
+ <xsl:param name="str"/>
7793
+ <xsl:param name="char" select="$zero_width_space"/>
7794
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
6818
7795
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6819
7796
  <xsl:apply-templates mode="syntax_highlight"/>
6820
7797
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -7027,7 +8004,9 @@
7027
8004
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
7028
8005
  </xsl:if>
7029
8006
  <xsl:variable name="simple-table">
7030
- <xsl:call-template name="getSimpleTable"/>
8007
+ <xsl:call-template name="getSimpleTable">
8008
+ <xsl:with-param name="id" select="@id"/>
8009
+ </xsl:call-template>
7031
8010
  </xsl:variable>
7032
8011
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
7033
8012
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -7134,39 +8113,67 @@
7134
8113
  </xsl:otherwise>
7135
8114
  </xsl:choose>
7136
8115
  </xsl:template><xsl:template match="*[local-name() = 'example']">
7137
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
7138
-
8116
+
8117
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
8118
+
7139
8119
 
8120
+
7140
8121
  <xsl:variable name="fo_element">
7141
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
8122
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
7142
8123
  block
7143
8124
  </xsl:variable>
7144
8125
 
7145
- <!-- display 'EXAMPLE' -->
7146
- <xsl:apply-templates select="*[local-name()='name']">
7147
- <xsl:with-param name="fo_element" select="$fo_element"/>
7148
- </xsl:apply-templates>
8126
+ <fo:block-container margin-left="0mm">
7149
8127
 
7150
- <xsl:choose>
7151
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
7152
- <fo:block-container xsl:use-attribute-sets="example-body-style">
7153
- <fo:block-container margin-left="0mm" margin-right="0mm">
7154
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8128
+ <xsl:choose>
8129
+
8130
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
8131
+
8132
+ <!-- display name 'EXAMPLE' in a separate block -->
8133
+ <fo:block>
8134
+ <xsl:apply-templates select="*[local-name()='name']">
7155
8135
  <xsl:with-param name="fo_element" select="$fo_element"/>
7156
8136
  </xsl:apply-templates>
8137
+ </fo:block>
8138
+
8139
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8140
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8141
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8142
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8143
+ </xsl:apply-templates>
8144
+ </fo:block-container>
7157
8145
  </fo:block-container>
7158
- </fo:block-container>
7159
- </xsl:when>
7160
- <xsl:otherwise>
7161
- <fo:inline>
7162
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7163
- <xsl:with-param name="fo_element" select="$fo_element"/>
7164
- </xsl:apply-templates>
7165
- </fo:inline>
7166
- </xsl:otherwise>
7167
- </xsl:choose>
7168
-
7169
- </fo:block>
8146
+ </xsl:when> <!-- end block -->
8147
+
8148
+ <xsl:otherwise> <!-- inline -->
8149
+
8150
+ <!-- display 'EXAMPLE' and first element in the same line -->
8151
+ <fo:block>
8152
+ <xsl:apply-templates select="*[local-name()='name']">
8153
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8154
+ </xsl:apply-templates>
8155
+ <fo:inline>
8156
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
8157
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8158
+ </xsl:apply-templates>
8159
+ </fo:inline>
8160
+ </fo:block>
8161
+
8162
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
8163
+ <!-- display further elements in blocks -->
8164
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8165
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8166
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
8167
+ <xsl:with-param name="fo_element" select="'block'"/>
8168
+ </xsl:apply-templates>
8169
+ </fo:block-container>
8170
+ </fo:block-container>
8171
+ </xsl:if>
8172
+ </xsl:otherwise> <!-- end inline -->
8173
+
8174
+ </xsl:choose>
8175
+ </fo:block-container>
8176
+ </fo:block-container>
7170
8177
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
7171
8178
  <xsl:param name="fo_element">block</xsl:param>
7172
8179
 
@@ -7198,10 +8205,16 @@
7198
8205
  </xsl:variable>
7199
8206
  <xsl:choose>
7200
8207
  <xsl:when test="starts-with(normalize-space($element), 'block')">
7201
- <fo:block xsl:use-attribute-sets="example-p-style">
7202
-
7203
- <xsl:apply-templates/>
7204
- </fo:block>
8208
+ <fo:block-container>
8209
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
8210
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
8211
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
8212
+ </xsl:if>
8213
+ <fo:block xsl:use-attribute-sets="example-p-style">
8214
+
8215
+ <xsl:apply-templates/>
8216
+ </fo:block>
8217
+ </fo:block-container>
7205
8218
  </xsl:when>
7206
8219
  <xsl:otherwise>
7207
8220
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -7380,7 +8393,16 @@
7380
8393
  </fo:inline>
7381
8394
  </xsl:when>
7382
8395
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7383
- <fo:inline><xsl:apply-templates/></fo:inline>
8396
+
8397
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
8398
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
8399
+ <xsl:choose>
8400
+ <xsl:when test="$uri_src != ''">
8401
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
8402
+ </xsl:when>
8403
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
8404
+ </xsl:choose>
8405
+
7384
8406
  </xsl:otherwise>
7385
8407
  </xsl:choose>
7386
8408
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7565,10 +8587,24 @@
7565
8587
 
7566
8588
  </fo:block>
7567
8589
  <xsl:apply-templates/>
7568
- </xsl:template><xsl:template match="*[local-name() = 'review']">
8590
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7569
8591
  <!-- comment 2019-11-29 -->
7570
8592
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7571
8593
  <xsl:apply-templates /> -->
8594
+
8595
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
8596
+
8597
+ <xsl:choose>
8598
+ <!-- if there isn't the attribute '@from', then -->
8599
+ <xsl:when test="$id_from = ''">
8600
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8601
+ </xsl:when>
8602
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
8603
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
8604
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8605
+ </xsl:when>
8606
+ </xsl:choose>
8607
+
7572
8608
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7573
8609
  <!-- 0xA0 to space replacement -->
7574
8610
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7715,6 +8751,11 @@
7715
8751
  </xsl:otherwise>
7716
8752
  </xsl:choose>
7717
8753
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
8754
+
8755
+ <xsl:apply-templates select="*[local-name() = 'name']">
8756
+ <xsl:with-param name="process">true</xsl:with-param>
8757
+ </xsl:apply-templates>
8758
+
7718
8759
  <fo:list-block xsl:use-attribute-sets="list-style">
7719
8760
 
7720
8761
 
@@ -7725,12 +8766,23 @@
7725
8766
 
7726
8767
 
7727
8768
 
8769
+ <xsl:if test="*[local-name() = 'name']">
8770
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8771
+ </xsl:if>
8772
+
7728
8773
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7729
8774
  </fo:list-block>
7730
8775
  <!-- <xsl:for-each select="./iho:note">
7731
8776
  <xsl:call-template name="note"/>
7732
8777
  </xsl:for-each> -->
7733
8778
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
8779
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
8780
+ <xsl:param name="process">false</xsl:param>
8781
+ <xsl:if test="$process = 'true'">
8782
+ <fo:block xsl:use-attribute-sets="list-name-style">
8783
+ <xsl:apply-templates/>
8784
+ </fo:block>
8785
+ </xsl:if>
7734
8786
  </xsl:template><xsl:template match="*[local-name()='li']">
7735
8787
  <fo:list-item xsl:use-attribute-sets="list-item-style">
7736
8788
  <xsl:copy-of select="@id"/>
@@ -7927,7 +8979,10 @@
7927
8979
  <!-- to split by '_' and other chars -->
7928
8980
  <xsl:call-template name="add-zero-spaces-java"/>
7929
8981
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7930
- <fo:inline id="{@id}" font-size="1pt"/>
8982
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8983
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8984
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8985
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7931
8986
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7932
8987
  <!-- <row>
7933
8988
  <date>05-07-2013</date>
@@ -8007,7 +9062,7 @@
8007
9062
  </xsl:template><xsl:template name="processBibitem">
8008
9063
 
8009
9064
 
8010
-
9065
+
8011
9066
  <!-- Example: [ITU-T A.23] ITU-T A.23, Recommendation ITU-T A.23, Annex A (2014), Guide for ITU-T and ISO/IEC JTC 1 cooperation. -->
8012
9067
  <xsl:if test="$doctype = 'implementers-guide'">
8013
9068
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
@@ -8015,46 +9070,26 @@
8015
9070
  </xsl:if>
8016
9071
 
8017
9072
  <xsl:variable name="bibitem_label">
8018
- <xsl:choose>
8019
- <xsl:when test="itu:docidentifier[@type = 'metanorma']">
8020
- <xsl:value-of select="itu:docidentifier[@type = 'metanorma']"/>
8021
- </xsl:when>
8022
- <xsl:otherwise>
8023
- <fo:inline padding-right="5mm">
8024
- <xsl:text>[</xsl:text>
8025
- <xsl:value-of select="itu:docidentifier[not(@type = 'metanorma-ordinal')]"/>
8026
- <xsl:text>] </xsl:text>
8027
- </fo:inline>
8028
- </xsl:otherwise>
8029
- </xsl:choose>
9073
+ <xsl:value-of select="itu:docidentifier[@type = 'metanorma']"/>
9074
+ <xsl:if test="not(itu:docidentifier[@type = 'metanorma'])">
9075
+ <fo:inline padding-right="5mm">
9076
+ <xsl:text>[</xsl:text>
9077
+ <xsl:value-of select="itu:docidentifier[not(@type = 'metanorma-ordinal')]"/>
9078
+ <xsl:text>] </xsl:text>
9079
+ </fo:inline>
9080
+ </xsl:if>
8030
9081
  </xsl:variable>
8031
9082
 
8032
9083
  <xsl:variable name="bibitem_body">
8033
9084
  <xsl:text> </xsl:text>
8034
9085
  <xsl:choose>
8035
9086
  <xsl:when test="itu:docidentifier[@type = 'metanorma']">
8036
- <xsl:if test="itu:docidentifier[not(@type) or not(@type = 'metanorma' or @type = 'metanorma-ordinal')]">
8037
- <xsl:value-of select="itu:docidentifier[not(@type) or not(@type = 'metanorma' or @type = 'metanorma-ordinal')]"/>
8038
- <xsl:text>, </xsl:text>
8039
- </xsl:if>
9087
+ <xsl:value-of select="itu:docidentifier[not(@type) or not(@type = 'metanorma' or @type = 'metanorma-ordinal')]"/>
8040
9088
  </xsl:when>
8041
9089
  <xsl:otherwise>
8042
9090
  <xsl:value-of select="itu:docidentifier[not(@type = 'metanorma-ordinal')]"/>
8043
- <xsl:if test="itu:title">
8044
- <xsl:text>, </xsl:text>
8045
- </xsl:if>
8046
9091
  </xsl:otherwise>
8047
9092
  </xsl:choose>
8048
- <xsl:if test="itu:title">
8049
- <xsl:choose>
8050
- <xsl:when test="itu:title[@type = 'main' and @language = 'en']">
8051
- <xsl:apply-templates select="itu:title[@type = 'main' and @language = 'en']"/>
8052
- </xsl:when>
8053
- <xsl:otherwise>
8054
- <xsl:apply-templates select="itu:title"/>
8055
- </xsl:otherwise>
8056
- </xsl:choose>
8057
- </xsl:if>
8058
9093
  <xsl:if test="itu:formattedref and not(itu:docidentifier[@type = 'metanorma'])">, </xsl:if>
8059
9094
  <xsl:apply-templates select="itu:formattedref"/>
8060
9095
  </xsl:variable>
@@ -8071,7 +9106,7 @@
8071
9106
  </fo:table-row>
8072
9107
  </fo:table-body>
8073
9108
  </fo:table>
8074
- </xsl:when>
9109
+ </xsl:when> <!-- $doctype = 'implementers-guide' -->
8075
9110
  <xsl:otherwise>
8076
9111
  <xsl:copy-of select="$bibitem_label"/>
8077
9112
  <xsl:copy-of select="$bibitem_body"/>
@@ -8396,25 +9431,32 @@
8396
9431
  </fo:block-container>
8397
9432
 
8398
9433
  </xsl:template><xsl:template name="displayAdmonitionName">
8399
-
9434
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
9435
+ <!-- <xsl:choose>
9436
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
9437
+ <xsl:choose>
9438
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
9439
+ <xsl:otherwise>
9440
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
9441
+ </xsl:otherwise>
9442
+ </xsl:choose>
9443
+ </xsl:when>
9444
+ <xsl:otherwise>
8400
9445
  <xsl:apply-templates select="*[local-name() = 'name']"/>
8401
9446
  <xsl:if test="not(*[local-name() = 'name'])">
8402
9447
  <xsl:apply-templates select="@type"/>
8403
9448
  </xsl:if>
8404
-
8405
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8406
- <xsl:apply-templates/>
8407
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
8408
- <xsl:variable name="admonition_type_">
8409
- <xsl:call-template name="getLocalizedString">
8410
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
8411
- </xsl:call-template>
9449
+ </xsl:otherwise>
9450
+ </xsl:choose> -->
9451
+ <xsl:variable name="name">
9452
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8412
9453
  </xsl:variable>
8413
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
8414
- <xsl:value-of select="$admonition_type"/>
8415
- <xsl:if test="$admonition_type = ''">
8416
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
9454
+ <xsl:copy-of select="$name"/>
9455
+ <xsl:if test="normalize-space($name) != ''">
9456
+ <xsl:value-of select="$sep"/>
8417
9457
  </xsl:if>
9458
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
9459
+ <xsl:apply-templates/>
8418
9460
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
8419
9461
 
8420
9462
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -8496,6 +9538,120 @@
8496
9538
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8497
9539
  </xsl:for-each>
8498
9540
  </xsl:copy>
9541
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9542
+ <xsl:apply-templates mode="update_xml_step1"/>
9543
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9544
+ <xsl:copy>
9545
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
9546
+ </xsl:copy>
9547
+ </xsl:template><xsl:variable name="express_reference_separators">_.\</xsl:variable><xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/><xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable><xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'])]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
9548
+
9549
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
9550
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9551
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9552
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9553
+ <xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
9554
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9555
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9556
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9557
+ <xsl:with-param name="text" select="$text_"/>
9558
+ </xsl:call-template></text></xsl:variable>
9559
+
9560
+ <xsl:variable name="parent" select="local-name(..)"/>
9561
+
9562
+ <xsl:variable name="text2">
9563
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
9564
+ <xsl:copy-of select="."/>
9565
+ </xsl:for-each></text>
9566
+ </xsl:variable>
9567
+
9568
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9569
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
9570
+ <xsl:variable name="text3">
9571
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9572
+ <xsl:choose>
9573
+ <xsl:when test="self::text()">
9574
+ <xsl:variable name="text_units_" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
9575
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
9576
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9577
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9578
+ <xsl:with-param name="text" select="$text_units_"/>
9579
+ </xsl:call-template></text></xsl:variable>
9580
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
9581
+ </xsl:when>
9582
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9583
+ </xsl:choose>
9584
+ </xsl:for-each></text>
9585
+ </xsl:variable>
9586
+
9587
+ <xsl:choose>
9588
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9589
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9590
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9591
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9592
+ <xsl:choose>
9593
+ <xsl:when test="self::text()">
9594
+ <xsl:variable name="text_dots_" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
9595
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
9596
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9597
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9598
+ <xsl:with-param name="text" select="$text_dots_"/>
9599
+ </xsl:call-template></text></xsl:variable>
9600
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
9601
+ </xsl:when>
9602
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9603
+ </xsl:choose>
9604
+ </xsl:for-each>
9605
+ </xsl:when>
9606
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
9607
+ </xsl:choose>
9608
+
9609
+ </xsl:template><xsl:template name="replace_text_tags">
9610
+ <xsl:param name="tag_open"/>
9611
+ <xsl:param name="tag_close"/>
9612
+ <xsl:param name="text"/>
9613
+ <xsl:choose>
9614
+ <xsl:when test="contains($text, $tag_open)">
9615
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
9616
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
9617
+
9618
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
9619
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
9620
+ </xsl:element>
9621
+
9622
+ <xsl:call-template name="replace_text_tags">
9623
+ <xsl:with-param name="tag_open" select="$tag_open"/>
9624
+ <xsl:with-param name="tag_close" select="$tag_close"/>
9625
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
9626
+ </xsl:call-template>
9627
+ </xsl:when>
9628
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
9629
+ </xsl:choose>
9630
+ </xsl:template><xsl:template name="printEdition">
9631
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
9632
+ <xsl:text> </xsl:text>
9633
+ <xsl:choose>
9634
+ <xsl:when test="$edition_i18n != ''">
9635
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
9636
+ <xsl:call-template name="capitalize">
9637
+ <xsl:with-param name="str" select="$edition_i18n"/>
9638
+ </xsl:call-template>
9639
+ </xsl:when>
9640
+ <xsl:otherwise>
9641
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
9642
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
9643
+ <xsl:call-template name="capitalize">
9644
+ <xsl:with-param name="str">
9645
+ <xsl:call-template name="getLocalizedString">
9646
+ <xsl:with-param name="key">edition</xsl:with-param>
9647
+ </xsl:call-template>
9648
+ </xsl:with-param>
9649
+ </xsl:call-template>
9650
+ <xsl:text> </xsl:text>
9651
+ <xsl:value-of select="$edition"/>
9652
+ </xsl:if>
9653
+ </xsl:otherwise>
9654
+ </xsl:choose>
8499
9655
  </xsl:template><xsl:template name="convertDate">
8500
9656
  <xsl:param name="date"/>
8501
9657
  <xsl:param name="format" select="'short'"/>
@@ -9183,4 +10339,40 @@
9183
10339
  <xsl:value-of select="$value"/>
9184
10340
  </xsl:otherwise>
9185
10341
  </xsl:choose>
10342
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
10343
+ <xsl:param name="level">0</xsl:param>
10344
+
10345
+ <fo:block margin-left="{2*$level}mm">
10346
+ <xsl:text>
10347
+ &lt;</xsl:text>
10348
+ <xsl:value-of select="local-name()"/>
10349
+ <xsl:for-each select="@*">
10350
+ <xsl:text> </xsl:text>
10351
+ <xsl:value-of select="local-name()"/>
10352
+ <xsl:text>="</xsl:text>
10353
+ <xsl:value-of select="."/>
10354
+ <xsl:text>"</xsl:text>
10355
+ </xsl:for-each>
10356
+ <xsl:text>&gt;</xsl:text>
10357
+
10358
+ <xsl:if test="not(*)">
10359
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
10360
+ <xsl:text>&lt;/</xsl:text>
10361
+ <xsl:value-of select="local-name()"/>
10362
+ <xsl:text>&gt;</xsl:text>
10363
+ </xsl:if>
10364
+ </fo:block>
10365
+
10366
+ <xsl:if test="*">
10367
+ <fo:block>
10368
+ <xsl:apply-templates mode="print_as_xml">
10369
+ <xsl:with-param name="level" select="$level + 1"/>
10370
+ </xsl:apply-templates>
10371
+ </fo:block>
10372
+ <fo:block margin-left="{2*$level}mm">
10373
+ <xsl:text>&lt;/</xsl:text>
10374
+ <xsl:value-of select="local-name()"/>
10375
+ <xsl:text>&gt;</xsl:text>
10376
+ </fo:block>
10377
+ </xsl:if>
9186
10378
  </xsl:template></xsl:stylesheet>