metanorma-ogc 2.0.8.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/ogc/biblio.rb +1 -134
  3. data/lib/isodoc/ogc/html/html_ogc_titlepage.html +2 -0
  4. data/lib/isodoc/ogc/html/htmlstyle.css +6 -0
  5. data/lib/isodoc/ogc/html/htmlstyle.scss +2 -0
  6. data/lib/isodoc/ogc/html/ogc.css +18 -12
  7. data/lib/isodoc/ogc/html/ogc.scss +16 -9
  8. data/lib/isodoc/ogc/html/ogc_wp.css +18 -12
  9. data/lib/isodoc/ogc/html/ogc_wp.scss +16 -9
  10. data/lib/isodoc/ogc/html/word_ogc_intro.html +2 -3
  11. data/lib/isodoc/ogc/html/word_ogc_intro_wp.html +1 -2
  12. data/lib/isodoc/ogc/html/word_ogc_titlepage.html +20 -17
  13. data/lib/isodoc/ogc/html/word_ogc_titlepage_wp.html +3 -0
  14. data/lib/isodoc/ogc/i18n.rb +1 -1
  15. data/lib/isodoc/ogc/init.rb +5 -6
  16. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +1502 -401
  17. data/lib/isodoc/ogc/ogc.best-practice.xsl +1502 -401
  18. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +1502 -401
  19. data/lib/isodoc/ogc/ogc.community-practice.xsl +1502 -401
  20. data/lib/isodoc/ogc/ogc.community-standard.xsl +1502 -401
  21. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +1502 -401
  22. data/lib/isodoc/ogc/ogc.engineering-report.xsl +1502 -401
  23. data/lib/isodoc/ogc/ogc.other.xsl +1502 -401
  24. data/lib/isodoc/ogc/ogc.policy.xsl +1502 -401
  25. data/lib/isodoc/ogc/ogc.reference-model.xsl +1502 -401
  26. data/lib/isodoc/ogc/ogc.release-notes.xsl +1502 -401
  27. data/lib/isodoc/ogc/ogc.standard.xsl +1502 -401
  28. data/lib/isodoc/ogc/ogc.test-suite.xsl +1502 -401
  29. data/lib/isodoc/ogc/ogc.user-guide.xsl +1502 -401
  30. data/lib/isodoc/ogc/ogc.white-paper.xsl +1521 -420
  31. data/lib/isodoc/ogc/presentation_xml_convert.rb +14 -10
  32. data/lib/isodoc/ogc/word_convert.rb +3 -4
  33. data/lib/isodoc/ogc/xref.rb +6 -2
  34. data/lib/metanorma/ogc/biblio.rng +69 -42
  35. data/lib/metanorma/ogc/isodoc.rng +65 -0
  36. data/lib/metanorma/ogc/version.rb +1 -1
  37. data/lib/relaton/render/config.yml +10 -0
  38. data/lib/relaton/render/date.rb +9 -0
  39. data/lib/relaton/render/fields.rb +23 -0
  40. data/lib/relaton/render/general.rb +25 -0
  41. data/lib/relaton/render/parse.rb +11 -0
  42. data/metanorma-ogc.gemspec +1 -1
  43. metadata +10 -5
@@ -144,10 +144,7 @@
144
144
  <fo:block margin-top="6pt">URL for this OGC® document: <xsl:value-of select="$url"/></fo:block>
145
145
  </xsl:if>
146
146
 
147
- <xsl:variable name="edition" select="/ogc:ogc-standard/ogc:bibdata/ogc:edition"/>
148
- <xsl:if test="normalize-space($edition) != ''">
149
- <fo:block margin-top="6pt">Version: <xsl:value-of select="$edition"/></fo:block>
150
- </xsl:if>
147
+ <xsl:apply-templates select="/ogc:ogc-standard/ogc:bibdata/ogc:edition[normalize-space(@language) = '']"/>
151
148
 
152
149
  <fo:block margin-top="6pt"><xsl:text>Category: </xsl:text>
153
150
  <xsl:call-template name="capitalizeWords">
@@ -255,7 +252,7 @@
255
252
 
256
253
 
257
254
  <!-- Abstract, Keywords, Preface, Submitting Organizations, Submitters -->
258
- <xsl:for-each select="/*/*[local-name()='preface']/*">
255
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
259
256
  <xsl:sort select="@displayorder" data-type="number"/>
260
257
 
261
258
  <xsl:if test="local-name() = 'abstract' or local-name() = 'foreword' or local-name() = 'introduction'">
@@ -371,16 +368,21 @@
371
368
  </fo:block>
372
369
  </xsl:template>
373
370
 
371
+
374
372
  <xsl:template match="/ogc:ogc-standard/ogc:bibdata/ogc:edition">
375
- <fo:block margin-bottom="12pt">
376
- <xsl:variable name="title-edition">
377
- <xsl:call-template name="getTitle">
378
- <xsl:with-param name="name" select="'title-edition'"/>
373
+ <xsl:variable name="edition" select="."/>
374
+ <xsl:if test="normalize-space($edition) != ''">
375
+ <fo:block margin-top="6pt">
376
+ <xsl:call-template name="capitalize">
377
+ <xsl:with-param name="str">
378
+ <xsl:call-template name="getLocalizedString">
379
+ <xsl:with-param name="key">version</xsl:with-param>
380
+ </xsl:call-template>
381
+ </xsl:with-param>
379
382
  </xsl:call-template>
380
- </xsl:variable>
381
- <xsl:value-of select="$title-edition"/><xsl:text>: </xsl:text>
382
- <xsl:value-of select="."/><xsl:text> </xsl:text>
383
- </fo:block>
383
+ <xsl:text>: </xsl:text><xsl:value-of select="$edition"/>
384
+ </fo:block>
385
+ </xsl:if>
384
386
  </xsl:template>
385
387
 
386
388
 
@@ -486,6 +488,7 @@
486
488
 
487
489
  <xsl:template match="ogc:p" name="paragraph">
488
490
  <xsl:param name="inline" select="'false'"/>
491
+ <xsl:param name="split_keep-within-line"/>
489
492
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
490
493
  <xsl:variable name="element-name">
491
494
  <xsl:choose>
@@ -516,7 +519,9 @@
516
519
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
517
520
  </xsl:if>
518
521
  <xsl:attribute name="line-height">115%</xsl:attribute>
519
- <xsl:apply-templates/>
522
+ <xsl:apply-templates>
523
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
524
+ </xsl:apply-templates>
520
525
  </xsl:element>
521
526
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
522
527
  <fo:block margin-bottom="12pt">
@@ -638,12 +643,41 @@
638
643
  </xsl:choose>
639
644
  </xsl:template>
640
645
 
641
- <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">
646
+ <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_">
647
+ <xsl:for-each select="$table_widths_from_if//table">
648
+ <xsl:copy>
649
+ <xsl:copy-of select="@*"/>
650
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
651
+ </xsl:copy>
652
+ </xsl:for-each>
653
+ </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_">
654
+ false
655
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
642
656
  <xsl:call-template name="getLang"/>
643
- </xsl:variable><xsl:variable name="pageWidth_">
644
- 215.9
657
+ </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_">
658
+ <xsl:choose>
659
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
660
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
661
+ </xsl:choose>
662
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
663
+ <xsl:choose>
664
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
665
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
666
+ </xsl:choose>
667
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
668
+ <xsl:choose>
669
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
670
+ <xsl:otherwise>
671
+ 215.9
672
+ </xsl:otherwise>
673
+ </xsl:choose>
645
674
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
646
- 279.4
675
+ <xsl:choose>
676
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
677
+ <xsl:otherwise>
678
+ 279.4
679
+ </xsl:otherwise>
680
+ </xsl:choose>
647
681
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
648
682
  25.4
649
683
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -653,20 +687,7 @@
653
687
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
654
688
  25.4
655
689
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
656
-
657
- <title-edition lang="en">
658
-
659
- <xsl:text>Version</xsl:text>
660
-
661
- </title-edition>
662
-
663
- <title-edition lang="fr">
664
- <xsl:text>Édition </xsl:text>
665
- </title-edition>
666
690
 
667
- <title-edition lang="ru">
668
- <xsl:text>Издание </xsl:text>
669
- </title-edition>
670
691
 
671
692
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
672
693
  <title-toc lang="en">
@@ -747,7 +768,7 @@
747
768
  </xsl:variable><xsl:variable name="bibdata">
748
769
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
749
770
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
750
- </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">
771
+ </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">
751
772
  <xsl:param name="name"/>
752
773
  <xsl:param name="lang"/>
753
774
  <xsl:variable name="lang_">
@@ -795,7 +816,7 @@
795
816
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
796
817
 
797
818
  <xsl:variable name="additional_fonts_">
798
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
819
+ <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']">
799
820
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
800
821
  </xsl:for-each>
801
822
  </xsl:variable>
@@ -892,7 +913,6 @@
892
913
 
893
914
 
894
915
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
895
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
896
916
 
897
917
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
898
918
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -1019,6 +1039,7 @@
1019
1039
 
1020
1040
 
1021
1041
 
1042
+
1022
1043
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
1023
1044
 
1024
1045
 
@@ -1178,6 +1199,7 @@
1178
1199
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1179
1200
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1180
1201
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1202
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1181
1203
  <xsl:attribute name="display-align">center</xsl:attribute>
1182
1204
 
1183
1205
 
@@ -1202,6 +1224,7 @@
1202
1224
  <xsl:attribute name="display-align">center</xsl:attribute>
1203
1225
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1204
1226
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1227
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1205
1228
 
1206
1229
 
1207
1230
 
@@ -1290,7 +1313,8 @@
1290
1313
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
1291
1314
 
1292
1315
 
1293
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
1316
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
1317
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
1294
1318
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
1295
1319
 
1296
1320
 
@@ -1305,6 +1329,28 @@
1305
1329
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1306
1330
 
1307
1331
 
1332
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
1333
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
1334
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1335
+
1336
+
1337
+
1338
+
1339
+
1340
+
1341
+
1342
+
1343
+
1344
+ <xsl:attribute name="color">rgb(68, 84, 106)</xsl:attribute>
1345
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
1346
+
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
1353
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
1308
1354
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1309
1355
 
1310
1356
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -1643,6 +1689,25 @@
1643
1689
 
1644
1690
 
1645
1691
 
1692
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
1693
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
1694
+
1695
+
1696
+
1697
+
1698
+
1699
+
1700
+
1701
+
1702
+
1703
+ <xsl:attribute name="color">rgb(68, 84, 106)</xsl:attribute>
1704
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
1705
+
1706
+
1707
+
1708
+
1709
+
1710
+
1646
1711
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
1647
1712
 
1648
1713
 
@@ -2056,13 +2121,13 @@
2056
2121
 
2057
2122
  </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">
2058
2123
  <xsl:variable name="nodes_preface_">
2059
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2124
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2060
2125
  <node id="{@id}"/>
2061
2126
  </xsl:for-each>
2062
2127
  </xsl:variable>
2063
2128
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
2064
2129
 
2065
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2130
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2066
2131
  <xsl:sort select="@displayorder" data-type="number"/>
2067
2132
 
2068
2133
  <!-- process Section's title -->
@@ -2128,7 +2193,7 @@
2128
2193
  </xsl:for-each>
2129
2194
  </figures>
2130
2195
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2131
- <xsl:for-each select="/*/*[local-name()='preface']/*">
2196
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
2132
2197
  <xsl:sort select="@displayorder" data-type="number"/>
2133
2198
  <xsl:apply-templates select="."/>
2134
2199
  </xsl:for-each>
@@ -2148,22 +2213,32 @@
2148
2213
  <xsl:sort select="@displayorder" data-type="number"/>
2149
2214
  <xsl:apply-templates select="."/>
2150
2215
  </xsl:for-each>
2151
- </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">
2152
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2153
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
2154
- <xsl:call-template name="replace_fo_inline">
2155
- <xsl:with-param name="text" select="$text"/>
2156
- </xsl:call-template>
2157
- </xsl:template><xsl:template name="replace_fo_inline">
2216
+ </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">
2217
+
2218
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
2219
+ <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))"/>
2220
+ <xsl:call-template name="replace_fo_inline_tags">
2221
+ <xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
2222
+ <xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
2223
+ <xsl:with-param name="text" select="$text"/>
2224
+ </xsl:call-template>
2225
+
2226
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
2227
+ <xsl:param name="tag_open"/>
2228
+ <xsl:param name="tag_close"/>
2158
2229
  <xsl:param name="text"/>
2159
2230
  <xsl:choose>
2160
2231
  <xsl:when test="contains($text, $tag_open)">
2161
2232
  <xsl:value-of select="substring-before($text, $tag_open)"/>
2162
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
2233
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
2163
2234
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
2164
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2165
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
2166
- <xsl:call-template name="replace_fo_inline">
2235
+ <fo:inline keep-together.within-line="always">
2236
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
2237
+ </fo:inline>
2238
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
2239
+ <xsl:call-template name="replace_fo_inline_tags">
2240
+ <xsl:with-param name="tag_open" select="$tag_open"/>
2241
+ <xsl:with-param name="tag_close" select="$tag_close"/>
2167
2242
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
2168
2243
  </xsl:call-template>
2169
2244
  </xsl:when>
@@ -2171,6 +2246,39 @@
2171
2246
  </xsl:choose>
2172
2247
  </xsl:template><xsl:template match="*[local-name()='br']">
2173
2248
  <xsl:value-of select="$linebreak"/>
2249
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
2250
+ <xsl:param name="split_keep-within-line"/>
2251
+
2252
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
2253
+ <xsl:choose>
2254
+
2255
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
2256
+ <xsl:variable name="sep">_</xsl:variable>
2257
+ <xsl:variable name="items">
2258
+ <xsl:call-template name="split">
2259
+ <xsl:with-param name="pText" select="."/>
2260
+ <xsl:with-param name="sep" select="$sep"/>
2261
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
2262
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
2263
+ </xsl:call-template>
2264
+ </xsl:variable>
2265
+ <xsl:for-each select="xalan:nodeset($items)/item">
2266
+ <xsl:choose>
2267
+ <xsl:when test=". = $sep">
2268
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
2269
+ </xsl:when>
2270
+ <xsl:otherwise>
2271
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
2272
+ </xsl:otherwise>
2273
+ </xsl:choose>
2274
+ </xsl:for-each>
2275
+ </xsl:when>
2276
+
2277
+ <xsl:otherwise>
2278
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
2279
+ </xsl:otherwise>
2280
+
2281
+ </xsl:choose>
2174
2282
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
2175
2283
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
2176
2284
  <xsl:apply-templates/>
@@ -2278,11 +2386,24 @@
2278
2386
  <xsl:with-param name="margin" select="$margin"/>
2279
2387
  </xsl:call-template>
2280
2388
 
2281
- </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">
2282
-
2283
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
2284
- <xsl:call-template name="add-zero-spaces-java"/>
2285
-
2389
+ </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
2390
+ <xsl:choose>
2391
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
2392
+ <xsl:value-of select="."/>
2393
+ </xsl:when>
2394
+ <xsl:otherwise>
2395
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
2396
+ </xsl:otherwise>
2397
+ </xsl:choose>
2398
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
2399
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
2400
+ <!-- <xsl:copy-of select="$text"/> -->
2401
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
2402
+ <xsl:choose>
2403
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
2404
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
2405
+ </xsl:choose>
2406
+ </xsl:for-each>
2286
2407
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
2287
2408
 
2288
2409
  <xsl:variable name="table-preamble">
@@ -2292,9 +2413,14 @@
2292
2413
 
2293
2414
  <xsl:variable name="table">
2294
2415
 
2295
- <xsl:variable name="simple-table">
2296
- <xsl:call-template name="getSimpleTable"/>
2416
+ <xsl:variable name="simple-table">
2417
+ <xsl:call-template name="getSimpleTable">
2418
+ <xsl:with-param name="id" select="@id"/>
2419
+ </xsl:call-template>
2297
2420
  </xsl:variable>
2421
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
2422
+
2423
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
2298
2424
 
2299
2425
 
2300
2426
  <!-- Display table's name before table as standalone block -->
@@ -2315,7 +2441,23 @@
2315
2441
  </xsl:call-template>
2316
2442
  </xsl:if>
2317
2443
  </xsl:variable>
2318
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
2444
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
2445
+
2446
+ <!-- DEBUG -->
2447
+ <xsl:if test="$table_if_debug = 'true'">
2448
+ <fo:block font-size="60%">
2449
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
2450
+ </fo:block>
2451
+ </xsl:if>
2452
+
2453
+
2454
+ <!-- <xsl:copy-of select="$colwidths"/> -->
2455
+
2456
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
2457
+ DEBUG
2458
+ colwidths=<xsl:copy-of select="$colwidths"/>
2459
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
2460
+
2319
2461
 
2320
2462
 
2321
2463
  <xsl:variable name="margin-side">
@@ -2381,9 +2523,17 @@
2381
2523
  </xsl:element>
2382
2524
  </xsl:variable>
2383
2525
 
2526
+ <xsl:if test="$isGenerateTableIF = 'true'">
2527
+ <!-- to determine start of table -->
2528
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
2529
+ </xsl:if>
2384
2530
 
2385
2531
  <fo:table id="{@id}">
2386
2532
 
2533
+ <xsl:if test="$isGenerateTableIF = 'true'">
2534
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
2535
+ </xsl:if>
2536
+
2387
2537
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
2388
2538
  <xsl:attribute name="{local-name()}">
2389
2539
  <xsl:value-of select="."/>
@@ -2397,24 +2547,47 @@
2397
2547
 
2398
2548
 
2399
2549
  <xsl:choose>
2400
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
2401
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
2402
- <fo:table-column column-width="{@width}"/>
2403
- </xsl:for-each>
2550
+ <xsl:when test="$isGenerateTableIF = 'true'">
2551
+ <!-- generate IF for table widths -->
2552
+ <!-- example:
2553
+ <tr>
2554
+ <td valign="top" align="left" id="tab-symdu_1_1">
2555
+ <p>Symbol</p>
2556
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
2557
+ </td>
2558
+ <td valign="top" align="left" id="tab-symdu_1_2">
2559
+ <p>Description</p>
2560
+ <word id="tab-symdu_1_2_word_1">Description</word>
2561
+ </td>
2562
+ </tr>
2563
+ -->
2564
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
2565
+
2404
2566
  </xsl:when>
2405
2567
  <xsl:otherwise>
2406
- <xsl:call-template name="insertTableColumnWidth">
2407
- <xsl:with-param name="colwidths" select="$colwidths"/>
2408
- </xsl:call-template>
2409
- </xsl:otherwise>
2410
- </xsl:choose>
2411
2568
 
2412
- <xsl:choose>
2413
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
2414
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2415
- </xsl:when>
2416
- <xsl:otherwise>
2417
- <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 -->
2569
+ <xsl:choose>
2570
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
2571
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
2572
+ <fo:table-column column-width="{@width}"/>
2573
+ </xsl:for-each>
2574
+ </xsl:when>
2575
+ <xsl:otherwise>
2576
+ <xsl:call-template name="insertTableColumnWidth">
2577
+ <xsl:with-param name="colwidths" select="$colwidths"/>
2578
+ </xsl:call-template>
2579
+ </xsl:otherwise>
2580
+ </xsl:choose>
2581
+
2582
+ <xsl:choose>
2583
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
2584
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2585
+ </xsl:when>
2586
+ <xsl:otherwise>
2587
+ <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 -->
2588
+ </xsl:otherwise>
2589
+ </xsl:choose>
2590
+
2418
2591
  </xsl:otherwise>
2419
2592
  </xsl:choose>
2420
2593
 
@@ -2516,11 +2689,22 @@
2516
2689
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
2517
2690
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
2518
2691
  </xsl:template><xsl:template name="calculate-column-widths">
2692
+ <xsl:param name="table"/>
2693
+ <xsl:param name="cols-count"/>
2694
+
2695
+ <xsl:call-template name="calculate-column-widths-proportional">
2696
+ <xsl:with-param name="cols-count" select="$cols-count"/>
2697
+ <xsl:with-param name="table" select="$table"/>
2698
+ </xsl:call-template>
2699
+
2700
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
2519
2701
  <xsl:param name="table"/>
2520
2702
  <xsl:param name="cols-count"/>
2521
2703
  <xsl:param name="curr-col" select="1"/>
2522
2704
  <xsl:param name="width" select="0"/>
2523
2705
 
2706
+ <!-- table=<xsl:copy-of select="$table"/> -->
2707
+
2524
2708
  <xsl:if test="$curr-col &lt;= $cols-count">
2525
2709
  <xsl:variable name="widths">
2526
2710
  <xsl:choose>
@@ -2558,16 +2742,22 @@
2558
2742
  </xsl:for-each>
2559
2743
  </xsl:when>
2560
2744
  <xsl:otherwise>
2561
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
2745
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
2746
+
2747
+ <!-- <table><xsl:copy-of select="$table"/></table>
2748
+ -->
2749
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
2562
2750
  <xsl:variable name="td_text">
2563
2751
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
2564
2752
  </xsl:variable>
2753
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
2565
2754
  <xsl:variable name="words">
2566
2755
  <xsl:variable name="string_with_added_zerospaces">
2567
2756
  <xsl:call-template name="add-zero-spaces-java">
2568
2757
  <xsl:with-param name="text" select="$td_text"/>
2569
2758
  </xsl:call-template>
2570
2759
  </xsl:variable>
2760
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
2571
2761
  <xsl:call-template name="tokenize">
2572
2762
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
2573
2763
  <!-- 2009 thinspace -->
@@ -2575,11 +2765,13 @@
2575
2765
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
2576
2766
  </xsl:call-template>
2577
2767
  </xsl:variable>
2768
+ <!-- words=<xsl:copy-of select="$words"/> -->
2578
2769
  <xsl:variable name="max_length">
2579
2770
  <xsl:call-template name="max_length">
2580
2771
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
2581
2772
  </xsl:call-template>
2582
2773
  </xsl:variable>
2774
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
2583
2775
  <width>
2584
2776
  <xsl:variable name="divider">
2585
2777
  <xsl:choose>
@@ -2598,6 +2790,8 @@
2598
2790
  </xsl:choose>
2599
2791
  </xsl:variable>
2600
2792
 
2793
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
2794
+
2601
2795
  <column>
2602
2796
  <xsl:for-each select="xalan:nodeset($widths)//width">
2603
2797
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -2606,35 +2800,271 @@
2606
2800
  </xsl:if>
2607
2801
  </xsl:for-each>
2608
2802
  </column>
2609
- <xsl:call-template name="calculate-column-widths">
2803
+ <xsl:call-template name="calculate-column-widths-proportional">
2610
2804
  <xsl:with-param name="cols-count" select="$cols-count"/>
2611
2805
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
2612
2806
  <xsl:with-param name="table" select="$table"/>
2613
2807
  </xsl:call-template>
2614
2808
  </xsl:if>
2615
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]" mode="td_text">
2616
- <xsl:apply-templates mode="td_text"/>
2617
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]/text()[translate(., $express_reference_characters, '') = '']" mode="td_text">
2809
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
2810
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
2811
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
2812
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
2618
2813
 
2619
- <xsl:value-of select="."/>
2620
-
2814
+ <!-- if all capitals english letters or digits -->
2815
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
2816
+ <xsl:call-template name="repeat">
2817
+ <xsl:with-param name="char" select="'X'"/>
2818
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
2819
+ </xsl:call-template>
2820
+ </xsl:if>
2621
2821
  </xsl:template><xsl:template match="text()" mode="td_text">
2622
2822
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
2623
2823
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
2624
2824
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
2625
2825
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
2626
2826
  <xsl:value-of select="@target"/>
2627
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
2628
- <xsl:variable name="mathml">
2629
- <xsl:for-each select="*">
2630
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
2631
- <xsl:copy-of select="."/>
2632
- </xsl:if>
2827
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
2828
+ <xsl:if test="$isGenerateTableIF = 'false'">
2829
+ <xsl:variable name="mathml_">
2830
+ <xsl:for-each select="*">
2831
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
2832
+ <xsl:copy-of select="."/>
2833
+ </xsl:if>
2834
+ </xsl:for-each>
2835
+ </xsl:variable>
2836
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
2837
+
2838
+ <xsl:variable name="math_text">
2839
+ <xsl:value-of select="normalize-space($mathml)"/>
2840
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
2841
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
2842
+ </xsl:variable>
2843
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
2844
+ </xsl:if>
2845
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
2846
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
2847
+
2848
+ <!-- via intermediate format -->
2849
+
2850
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
2851
+
2852
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
2853
+
2854
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
2855
+
2856
+ <!-- get current table id -->
2857
+ <xsl:variable name="table_id" select="@id"/>
2858
+ <!-- find table by id in the file 'table_widths' -->
2859
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
2860
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
2861
+
2862
+ <!-- table='<xsl:copy-of select="$table"/>' -->
2863
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
2864
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
2865
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
2866
+
2867
+ <xsl:variable name="table_with_cell_widths_">
2868
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
2869
+ </xsl:variable>
2870
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
2871
+
2872
+ <!-- <xsl:if test="$table_if_debug = 'true'">
2873
+ <xsl:copy-of select="$table_with_cell_widths"/>
2874
+ </xsl:if> -->
2875
+
2876
+
2877
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
2878
+
2879
+ <xsl:variable name="column_widths_">
2880
+ <!-- iteration of columns -->
2881
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
2882
+ <xsl:variable name="pos" select="position()"/>
2883
+ <column>
2884
+ <xsl:attribute name="width_max">
2885
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
2886
+ <xsl:sort select="." data-type="number" order="descending"/>
2887
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
2888
+ </xsl:for-each>
2889
+ </xsl:attribute>
2890
+ <xsl:attribute name="width_min">
2891
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
2892
+ <xsl:sort select="." data-type="number" order="descending"/>
2893
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
2894
+ </xsl:for-each>
2895
+ </xsl:attribute>
2896
+ </column>
2633
2897
  </xsl:for-each>
2634
2898
  </xsl:variable>
2899
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
2900
+
2901
+ <!-- <column_widths>
2902
+ <xsl:copy-of select="$column_widths"/>
2903
+ </column_widths> -->
2904
+
2905
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
2906
+ <xsl:variable name="table_widths_">
2907
+ <table>
2908
+ <xsl:attribute name="width_max">
2909
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
2910
+ </xsl:attribute>
2911
+ <xsl:attribute name="width_min">
2912
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
2913
+ </xsl:attribute>
2914
+ </table>
2915
+ </xsl:variable>
2916
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
2917
+
2918
+ <xsl:variable name="page_width">
2919
+ <xsl:choose>
2920
+ <xsl:when test="$parent_table_page-width != ''">
2921
+ <xsl:value-of select="$parent_table_page-width"/>
2922
+ </xsl:when>
2923
+ <xsl:otherwise>
2924
+ <xsl:value-of select="@page-width"/>
2925
+ </xsl:otherwise>
2926
+ </xsl:choose>
2927
+ </xsl:variable>
2928
+
2929
+ <xsl:if test="$table_if_debug = 'true'">
2930
+ <table_width>
2931
+ <xsl:copy-of select="$table_widths"/>
2932
+ </table_width>
2933
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
2934
+ </xsl:if>
2935
+
2936
+
2937
+ <!-- There are three cases: -->
2938
+ <xsl:choose>
2939
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
2940
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
2941
+ <!-- call old algorithm -->
2942
+ <case1/>
2943
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
2944
+ <xsl:call-template name="calculate-column-widths-proportional">
2945
+ <xsl:with-param name="cols-count" select="$cols-count"/>
2946
+ <xsl:with-param name="table" select="$table"/>
2947
+ </xsl:call-template> -->
2948
+ </xsl:when>
2949
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
2950
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
2951
+ <case2/>
2952
+ <autolayout/>
2953
+ <xsl:for-each select="$column_widths/column/@width_max">
2954
+ <column divider="100"><xsl:value-of select="."/></column>
2955
+ </xsl:for-each>
2956
+ </xsl:when>
2957
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
2958
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
2959
+ Lets also call D the difference between maximum and minimum width of the table.
2960
+ For each column, let d be the difference between maximum and minimum width of that column.
2961
+ Now set the column's width to the minimum width plus d times W over D.
2962
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
2963
+ <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)">
2964
+ <!-- difference between the available space and the minimum table width -->
2965
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
2966
+ <W><xsl:value-of select="$W"/></W>
2967
+ <!-- difference between maximum and minimum width of the table -->
2968
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
2969
+ <D><xsl:value-of select="$D"/></D>
2970
+ <case3/>
2971
+ <autolayout/>
2972
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
2973
+ <split_keep-within-line>true</split_keep-within-line>
2974
+ </xsl:if>
2975
+ <xsl:for-each select="$column_widths/column">
2976
+ <!-- difference between maximum and minimum width of that column. -->
2977
+ <xsl:variable name="d" select="@width_max - @width_min"/>
2978
+ <d><xsl:value-of select="$d"/></d>
2979
+ <width_min><xsl:value-of select="@width_min"/></width_min>
2980
+ <e><xsl:value-of select="$d * $W div $D"/></e>
2981
+ <!-- set the column's width to the minimum width plus d times W over D. -->
2982
+ <column divider="100">
2983
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
2984
+ </column>
2985
+ </xsl:for-each>
2986
+
2987
+ </xsl:when>
2988
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
2989
+ </xsl:choose>
2990
+
2991
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
2992
+
2993
+ <!-- if nested 'dl' or 'table' -->
2994
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
2995
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
2996
+
2997
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
2998
+
2999
+ <xsl:variable name="parent_table_page-width_">
3000
+ <xsl:if test="$parent_table_id != ''">
3001
+ <!-- determine column number in the parent table -->
3002
+ <xsl:variable name="parent_table_column_number">
3003
+ <xsl:choose>
3004
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
3005
+ <xsl:otherwise> <!-- parent is table -->
3006
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
3007
+ </xsl:otherwise>
3008
+ </xsl:choose>
3009
+ </xsl:variable>
3010
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
3011
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
3012
+ </xsl:if>
3013
+ </xsl:variable>
3014
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
3015
+
3016
+ <!-- get current table id -->
3017
+ <xsl:variable name="table_id" select="@id"/>
3018
+
3019
+ <xsl:choose>
3020
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
3021
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
3022
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
3023
+ </xsl:when>
3024
+ <xsl:otherwise>
3025
+ <!-- recalculate columns width based on parent table width -->
3026
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
3027
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
3028
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
3029
+ </xsl:call-template>
3030
+ </xsl:for-each>
3031
+ </xsl:otherwise>
3032
+ </xsl:choose>
2635
3033
 
2636
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
2637
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3034
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
3035
+ <xsl:copy>
3036
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
3037
+ </xsl:copy>
3038
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
3039
+ <xsl:copy>
3040
+ <xsl:copy-of select="@*"/>
3041
+
3042
+ <!-- The maximum width is given by the widest line. -->
3043
+ <xsl:attribute name="width_max">
3044
+ <xsl:for-each select="p_len">
3045
+ <xsl:sort select="." data-type="number" order="descending"/>
3046
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3047
+ </xsl:for-each>
3048
+ </xsl:attribute>
3049
+
3050
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
3051
+ <xsl:variable name="width_min">
3052
+ <xsl:for-each select="word_len">
3053
+ <xsl:sort select="." data-type="number" order="descending"/>
3054
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
3055
+ </xsl:for-each>
3056
+ </xsl:variable>
3057
+ <xsl:attribute name="width_min">
3058
+ <xsl:value-of select="$width_min"/>
3059
+ </xsl:attribute>
3060
+
3061
+ <xsl:if test="$width_min = 0">
3062
+ <xsl:attribute name="width_min">1</xsl:attribute>
3063
+ </xsl:if>
3064
+
3065
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
3066
+
3067
+ </xsl:copy>
2638
3068
  </xsl:template><xsl:template match="*[local-name()='thead']">
2639
3069
  <xsl:param name="cols-count"/>
2640
3070
  <fo:table-header>
@@ -2719,6 +3149,7 @@
2719
3149
  </xsl:for-each>
2720
3150
  </xsl:when>
2721
3151
  <xsl:otherwise>
3152
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
2722
3153
  <xsl:call-template name="insertTableColumnWidth">
2723
3154
  <xsl:with-param name="colwidths" select="$colwidths"/>
2724
3155
  </xsl:call-template>
@@ -2798,23 +3229,69 @@
2798
3229
 
2799
3230
  </fo:table-body>
2800
3231
 
2801
- </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
2802
- <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3232
+ </xsl:template><xsl:template match="/" mode="process_table-if">
3233
+ <xsl:param name="table_or_dl">table</xsl:param>
3234
+ <xsl:apply-templates mode="process_table-if">
3235
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
3236
+ </xsl:apply-templates>
3237
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
3238
+ <xsl:param name="table_or_dl">table</xsl:param>
2803
3239
 
2804
-
2805
-
2806
-
3240
+ <fo:table-body>
3241
+ <xsl:for-each select="*[local-name() = 'tr']">
3242
+ <xsl:variable name="col_count" select="count(*)"/>
2807
3243
 
2808
-
2809
-
2810
- <xsl:call-template name="setTableRowAttributes"/>
2811
-
2812
- <xsl:apply-templates/>
2813
- </fo:table-row>
2814
- </xsl:template><xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
2815
- <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
2816
-
2817
- <xsl:call-template name="setTableRowAttributes"/>
3244
+ <!-- iteration for each tr/td -->
3245
+
3246
+ <xsl:choose>
3247
+ <xsl:when test="$table_or_dl = 'table'">
3248
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
3249
+ <fo:table-row number-columns-spanned="{$col_count}">
3250
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
3251
+ <xsl:call-template name="td"/>
3252
+ </fo:table-row>
3253
+ </xsl:for-each>
3254
+ </xsl:when>
3255
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
3256
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
3257
+ <xsl:variable name="is_dt" select="position() = 1"/>
3258
+
3259
+ <xsl:for-each select="*">
3260
+ <!-- <test><xsl:copy-of select="."/></test> -->
3261
+ <fo:table-row number-columns-spanned="{$col_count}">
3262
+ <xsl:choose>
3263
+ <xsl:when test="$is_dt">
3264
+ <xsl:call-template name="insert_dt_cell"/>
3265
+ </xsl:when>
3266
+ <xsl:otherwise>
3267
+ <xsl:call-template name="insert_dd_cell"/>
3268
+ </xsl:otherwise>
3269
+ </xsl:choose>
3270
+ </fo:table-row>
3271
+ </xsl:for-each>
3272
+ </xsl:for-each>
3273
+ </xsl:otherwise>
3274
+ </xsl:choose>
3275
+
3276
+ </xsl:for-each>
3277
+ </fo:table-body>
3278
+ </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3279
+ <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3280
+
3281
+
3282
+
3283
+
3284
+
3285
+
3286
+
3287
+ <xsl:call-template name="setTableRowAttributes"/>
3288
+
3289
+ <xsl:apply-templates/>
3290
+ </fo:table-row>
3291
+ </xsl:template><xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3292
+ <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
3293
+
3294
+ <xsl:call-template name="setTableRowAttributes"/>
2818
3295
  <xsl:apply-templates/>
2819
3296
  </fo:table-row>
2820
3297
  </xsl:template><xsl:template match="*[local-name()='tr']">
@@ -2884,7 +3361,7 @@
2884
3361
  </xsl:choose>
2885
3362
  </xsl:attribute>
2886
3363
  </xsl:if>
2887
- </xsl:template><xsl:template match="*[local-name()='td']">
3364
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
2888
3365
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
2889
3366
  <xsl:call-template name="setTextAlignment">
2890
3367
  <xsl:with-param name="default">left</xsl:with-param>
@@ -2918,11 +3395,24 @@
2918
3395
 
2919
3396
  <xsl:call-template name="setTableCellAttributes"/>
2920
3397
 
3398
+ <xsl:if test="$isGenerateTableIF = 'true'">
3399
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
3400
+ <xsl:attribute name="text-align">left</xsl:attribute>
3401
+ </xsl:if>
3402
+
2921
3403
  <fo:block>
2922
3404
 
3405
+ <xsl:if test="$isGenerateTableIF = 'true'">
3406
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
3407
+ </xsl:if>
3408
+
3409
+
2923
3410
 
2924
3411
 
2925
3412
  <xsl:apply-templates/>
3413
+
3414
+ <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"/> -->
3415
+
2926
3416
  </fo:block>
2927
3417
  </fo:table-cell>
2928
3418
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -3125,9 +3615,9 @@
3125
3615
  <!-- current hierarchy is 'figure' element -->
3126
3616
  <xsl:variable name="following_dl_colwidths">
3127
3617
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3128
- <xsl:variable name="html-table">
3129
- <xsl:variable name="doc_ns">
3130
-
3618
+ <xsl:variable name="simple-table">
3619
+ <!-- <xsl:variable name="doc_ns">
3620
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3131
3621
  </xsl:variable>
3132
3622
  <xsl:variable name="ns">
3133
3623
  <xsl:choose>
@@ -3138,7 +3628,7 @@
3138
3628
  <xsl:value-of select="substring-before(name(/*), '-')"/>
3139
3629
  </xsl:otherwise>
3140
3630
  </xsl:choose>
3141
- </xsl:variable>
3631
+ </xsl:variable> -->
3142
3632
 
3143
3633
  <xsl:for-each select="*[local-name() = 'dl'][1]">
3144
3634
  <tbody>
@@ -3149,7 +3639,7 @@
3149
3639
 
3150
3640
  <xsl:call-template name="calculate-column-widths">
3151
3641
  <xsl:with-param name="cols-count" select="2"/>
3152
- <xsl:with-param name="table" select="$html-table"/>
3642
+ <xsl:with-param name="table" select="$simple-table"/>
3153
3643
  </xsl:call-template>
3154
3644
 
3155
3645
  </xsl:if>
@@ -3273,8 +3763,10 @@
3273
3763
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
3274
3764
  </xsl:variable>
3275
3765
 
3766
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
3767
+
3276
3768
  <xsl:choose>
3277
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
3769
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
3278
3770
 
3279
3771
  <fo:block margin-bottom="12pt" text-align="left">
3280
3772
 
@@ -3289,7 +3781,7 @@
3289
3781
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3290
3782
  </fo:block>
3291
3783
 
3292
- </xsl:when>
3784
+ </xsl:when> <!-- END: only one component -->
3293
3785
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3294
3786
  <fo:block margin-bottom="12pt" text-align="left">
3295
3787
 
@@ -3303,8 +3795,8 @@
3303
3795
  </xsl:variable>
3304
3796
  <xsl:value-of select="$title-where"/>
3305
3797
  </fo:block>
3306
- </xsl:when>
3307
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
3798
+ </xsl:when> <!-- END: a few components -->
3799
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
3308
3800
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
3309
3801
 
3310
3802
 
@@ -3317,22 +3809,41 @@
3317
3809
  </xsl:variable>
3318
3810
  <xsl:value-of select="$title-key"/>
3319
3811
  </fo:block>
3320
- </xsl:when>
3812
+ </xsl:when> <!-- END: definition list in a figure -->
3321
3813
  </xsl:choose>
3322
3814
 
3323
3815
  <!-- a few components -->
3324
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
3816
+ <xsl:if test="$onlyOneComponent = 'false'">
3325
3817
  <fo:block>
3326
3818
 
3327
3819
 
3328
3820
 
3329
3821
 
3822
+
3823
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
3824
+ <xsl:attribute name="margin-top">0</xsl:attribute>
3825
+ </xsl:if>
3826
+
3330
3827
  <fo:block>
3331
3828
 
3332
3829
 
3333
3830
 
3334
3831
 
3832
+ <xsl:apply-templates select="*[local-name() = 'name']">
3833
+ <xsl:with-param name="process">true</xsl:with-param>
3834
+ </xsl:apply-templates>
3835
+
3836
+ <xsl:if test="$isGenerateTableIF = 'true'">
3837
+ <!-- to determine start of table -->
3838
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3839
+ </xsl:if>
3840
+
3335
3841
  <fo:table width="95%" table-layout="fixed">
3842
+
3843
+ <xsl:if test="$isGenerateTableIF = 'true'">
3844
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3845
+ </xsl:if>
3846
+
3336
3847
 
3337
3848
  <xsl:choose>
3338
3849
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -3341,69 +3852,174 @@
3341
3852
 
3342
3853
  </xsl:when>
3343
3854
  </xsl:choose>
3344
- <!-- create virtual html table for dl/[dt and dd] -->
3345
- <xsl:variable name="html-table">
3346
- <xsl:variable name="doc_ns">
3855
+
3856
+
3857
+
3858
+ <xsl:choose>
3859
+ <xsl:when test="$isGenerateTableIF = 'true'">
3860
+ <!-- generate IF for table widths -->
3861
+ <!-- example:
3862
+ <tr>
3863
+ <td valign="top" align="left" id="tab-symdu_1_1">
3864
+ <p>Symbol</p>
3865
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3866
+ </td>
3867
+ <td valign="top" align="left" id="tab-symdu_1_2">
3868
+ <p>Description</p>
3869
+ <word id="tab-symdu_1_2_word_1">Description</word>
3870
+ </td>
3871
+ </tr>
3872
+ -->
3347
3873
 
3348
- </xsl:variable>
3349
- <xsl:variable name="ns">
3350
- <xsl:choose>
3351
- <xsl:when test="normalize-space($doc_ns) != ''">
3352
- <xsl:value-of select="normalize-space($doc_ns)"/>
3353
- </xsl:when>
3354
- <xsl:otherwise>
3355
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3356
- </xsl:otherwise>
3357
- </xsl:choose>
3358
- </xsl:variable>
3359
- <tbody>
3360
- <xsl:apply-templates mode="dl"/>
3361
- </tbody>
3362
- </xsl:variable>
3363
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
3364
- <xsl:variable name="colwidths">
3365
- <xsl:call-template name="calculate-column-widths">
3366
- <xsl:with-param name="cols-count" select="2"/>
3367
- <xsl:with-param name="table" select="$html-table"/>
3368
- </xsl:call-template>
3369
- </xsl:variable>
3370
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3371
- <xsl:variable name="maxlength_dt">
3372
- <xsl:call-template name="getMaxLength_dt"/>
3373
- </xsl:variable>
3374
- <xsl:variable name="isContainsExpressReference_">
3375
- false
3376
- </xsl:variable>
3377
- <xsl:variable name="isContainsExpressReference" select="normalize-space($isContainsExpressReference_)"/>
3378
- <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
3379
- <xsl:call-template name="setColumnWidth_dl">
3380
- <xsl:with-param name="colwidths" select="$colwidths"/>
3381
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3382
- <xsl:with-param name="isContainsExpressReference" select="$isContainsExpressReference"/>
3383
- </xsl:call-template>
3384
- <fo:table-body>
3385
- <xsl:apply-templates>
3386
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
3387
- </xsl:apply-templates>
3388
- </fo:table-body>
3874
+ <!-- create virtual html table for dl/[dt and dd] -->
3875
+ <xsl:variable name="simple-table">
3876
+
3877
+ <xsl:variable name="dl_table">
3878
+ <tbody>
3879
+ <xsl:apply-templates mode="dl_if">
3880
+ <xsl:with-param name="id" select="@id"/>
3881
+ </xsl:apply-templates>
3882
+ </tbody>
3883
+ </xsl:variable>
3884
+
3885
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
3886
+
3887
+ <!-- Step: replace <br/> to <p>...</p> -->
3888
+ <xsl:variable name="table_without_br">
3889
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
3890
+ </xsl:variable>
3891
+
3892
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
3893
+
3894
+ <!-- Step: add id to each cell -->
3895
+ <!-- add <word>...</word> for each word, image, math -->
3896
+ <xsl:variable name="simple-table-id">
3897
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
3898
+ <xsl:with-param name="id" select="@id"/>
3899
+ </xsl:apply-templates>
3900
+ </xsl:variable>
3901
+
3902
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
3903
+
3904
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
3905
+
3906
+ </xsl:variable>
3907
+
3908
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
3909
+
3910
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
3911
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
3912
+ </xsl:apply-templates>
3913
+
3914
+ </xsl:when>
3915
+ <xsl:otherwise>
3916
+
3917
+ <xsl:variable name="simple-table">
3918
+
3919
+ <xsl:variable name="dl_table">
3920
+ <tbody>
3921
+ <xsl:apply-templates mode="dl">
3922
+ <xsl:with-param name="id" select="@id"/>
3923
+ </xsl:apply-templates>
3924
+ </tbody>
3925
+ </xsl:variable>
3926
+
3927
+ <xsl:copy-of select="$dl_table"/>
3928
+ </xsl:variable>
3929
+
3930
+ <xsl:variable name="colwidths">
3931
+ <xsl:call-template name="calculate-column-widths">
3932
+ <xsl:with-param name="cols-count" select="2"/>
3933
+ <xsl:with-param name="table" select="$simple-table"/>
3934
+ </xsl:call-template>
3935
+ </xsl:variable>
3936
+
3937
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3938
+ DEBUG
3939
+ colwidths=<xsl:copy-of select="$colwidths"/>
3940
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3941
+
3942
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
3943
+
3944
+ <xsl:variable name="maxlength_dt">
3945
+ <xsl:call-template name="getMaxLength_dt"/>
3946
+ </xsl:variable>
3947
+
3948
+ <xsl:variable name="isContainsKeepTogetherTag_">
3949
+ false
3950
+ </xsl:variable>
3951
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
3952
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
3953
+
3954
+
3955
+ <xsl:call-template name="setColumnWidth_dl">
3956
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3957
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3958
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
3959
+ </xsl:call-template>
3960
+
3961
+ <fo:table-body>
3962
+
3963
+ <!-- DEBUG -->
3964
+ <xsl:if test="$table_if_debug = 'true'">
3965
+ <fo:table-row>
3966
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
3967
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3968
+ </fo:table-cell>
3969
+ </fo:table-row>
3970
+ </xsl:if>
3971
+
3972
+ <xsl:apply-templates>
3973
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
3974
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
3975
+ </xsl:apply-templates>
3976
+
3977
+ </fo:table-body>
3978
+ </xsl:otherwise>
3979
+ </xsl:choose>
3389
3980
  </fo:table>
3390
3981
  </fo:block>
3391
3982
  </fo:block>
3392
- </xsl:if>
3983
+ </xsl:if> <!-- END: a few components -->
3393
3984
  </fo:block-container>
3394
3985
  </fo:block-container>
3986
+
3987
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
3988
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
3989
+ </xsl:if>
3990
+
3991
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3992
+ <xsl:param name="process">false</xsl:param>
3993
+ <xsl:if test="$process = 'true'">
3994
+ <fo:block xsl:use-attribute-sets="dl-name-style">
3995
+ <xsl:apply-templates/>
3996
+ </fo:block>
3997
+ </xsl:if>
3395
3998
  </xsl:template><xsl:template name="setColumnWidth_dl">
3396
3999
  <xsl:param name="colwidths"/>
3397
4000
  <xsl:param name="maxlength_dt"/>
3398
- <xsl:param name="isContainsExpressReference"/>
4001
+ <xsl:param name="isContainsKeepTogetherTag"/>
4002
+
4003
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
4004
+
3399
4005
  <xsl:choose>
4006
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
4007
+ <xsl:call-template name="insertTableColumnWidth">
4008
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4009
+ </xsl:call-template>
4010
+ </xsl:when>
3400
4011
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
3401
4012
  <fo:table-column column-width="50%"/>
3402
4013
  <fo:table-column column-width="50%"/>
3403
4014
  </xsl:when>
3404
4015
  <xsl:otherwise>
3405
4016
  <xsl:choose>
3406
- <xsl:when test="$isContainsExpressReference">
4017
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
4018
+ <xsl:call-template name="insertTableColumnWidth">
4019
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4020
+ </xsl:call-template>
4021
+ </xsl:when>
4022
+ <xsl:when test="$isContainsKeepTogetherTag">
3407
4023
  <xsl:call-template name="insertTableColumnWidth">
3408
4024
  <xsl:with-param name="colwidths" select="$colwidths"/>
3409
4025
  </xsl:call-template>
@@ -3447,13 +4063,19 @@
3447
4063
  </xsl:choose>
3448
4064
  </xsl:template><xsl:template name="insertTableColumnWidth">
3449
4065
  <xsl:param name="colwidths"/>
4066
+
3450
4067
  <xsl:for-each select="xalan:nodeset($colwidths)//column">
3451
4068
  <xsl:choose>
3452
4069
  <xsl:when test=". = 1 or . = 0">
3453
4070
  <fo:table-column column-width="proportional-column-width(2)"/>
3454
4071
  </xsl:when>
3455
4072
  <xsl:otherwise>
3456
- <fo:table-column column-width="proportional-column-width({.})"/>
4073
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
4074
+ <xsl:variable name="divider">
4075
+ <xsl:value-of select="@divider"/>
4076
+ <xsl:if test="not(@divider)">1</xsl:if>
4077
+ </xsl:variable>
4078
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
3457
4079
  </xsl:otherwise>
3458
4080
  </xsl:choose>
3459
4081
  </xsl:for-each>
@@ -3480,7 +4102,6 @@
3480
4102
  <xsl:value-of select="$maxLength"/>
3481
4103
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
3482
4104
  <xsl:param name="key_iso"/>
3483
-
3484
4105
  <!-- <tr>
3485
4106
  <td>NOTE</td>
3486
4107
  <td>
@@ -3488,27 +4109,47 @@
3488
4109
  </td>
3489
4110
  </tr>
3490
4111
  -->
3491
- <fo:table-row>
4112
+ <!-- OLD Variant -->
4113
+ <!-- <fo:table-row>
3492
4114
  <fo:table-cell>
3493
4115
  <fo:block margin-top="6pt">
3494
4116
  <xsl:if test="normalize-space($key_iso) = 'true'">
3495
4117
  <xsl:attribute name="margin-top">0</xsl:attribute>
3496
4118
  </xsl:if>
3497
- <xsl:apply-templates select="*[local-name() = 'name']"/>
4119
+ <xsl:apply-templates select="*[local-name() = 'name']" />
3498
4120
  </fo:block>
3499
4121
  </fo:table-cell>
3500
4122
  <fo:table-cell>
3501
4123
  <fo:block>
3502
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
4124
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
4125
+ </fo:block>
4126
+ </fo:table-cell>
4127
+ </fo:table-row> -->
4128
+ <!-- <tr>
4129
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
4130
+ </tr>
4131
+ -->
4132
+ <fo:table-row>
4133
+ <fo:table-cell number-columns-spanned="2">
4134
+ <fo:block>
4135
+ <xsl:call-template name="note"/>
3503
4136
  </fo:block>
3504
4137
  </fo:table-cell>
3505
4138
  </fo:table-row>
3506
4139
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
4140
+ <xsl:param name="id"/>
4141
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
3507
4142
  <tr>
3508
4143
  <td>
4144
+ <xsl:attribute name="id">
4145
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
4146
+ </xsl:attribute>
3509
4147
  <xsl:apply-templates/>
3510
4148
  </td>
3511
4149
  <td>
4150
+ <xsl:attribute name="id">
4151
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
4152
+ </xsl:attribute>
3512
4153
 
3513
4154
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
3514
4155
  <xsl:with-param name="process">true</xsl:with-param>
@@ -3519,50 +4160,134 @@
3519
4160
 
3520
4161
  </xsl:template><xsl:template match="*[local-name()='dt']">
3521
4162
  <xsl:param name="key_iso"/>
4163
+ <xsl:param name="split_keep-within-line"/>
3522
4164
 
3523
4165
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
3524
- <fo:table-cell>
4166
+ <xsl:call-template name="insert_dt_cell">
4167
+ <xsl:with-param name="key_iso" select="$key_iso"/>
4168
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4169
+ </xsl:call-template>
4170
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
4171
+ <xsl:call-template name="insert_dd_cell">
4172
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4173
+ </xsl:call-template>
4174
+ </xsl:for-each>
4175
+ </fo:table-row>
4176
+ </xsl:template><xsl:template name="insert_dt_cell">
4177
+ <xsl:param name="key_iso"/>
4178
+ <xsl:param name="split_keep-within-line"/>
4179
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
4180
+
4181
+ <xsl:if test="$isGenerateTableIF = 'true'">
4182
+ <!-- border is mandatory, to calculate real width -->
4183
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4184
+ <xsl:attribute name="text-align">left</xsl:attribute>
4185
+ </xsl:if>
4186
+
4187
+
4188
+ <fo:block xsl:use-attribute-sets="dt-block-style">
4189
+ <xsl:copy-of select="@id"/>
4190
+
4191
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4192
+ <xsl:attribute name="margin-top">0</xsl:attribute>
4193
+ </xsl:if>
4194
+
4195
+
4196
+
4197
+ <xsl:apply-templates>
4198
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4199
+ </xsl:apply-templates>
4200
+
4201
+ <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"/> -->
4202
+
4203
+ </fo:block>
4204
+ </fo:table-cell>
4205
+ </xsl:template><xsl:template name="insert_dd_cell">
4206
+ <xsl:param name="split_keep-within-line"/>
4207
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
4208
+
4209
+ <xsl:if test="$isGenerateTableIF = 'true'">
4210
+ <!-- border is mandatory, to calculate real width -->
4211
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
4212
+ </xsl:if>
4213
+
4214
+ <fo:block>
4215
+
4216
+ <xsl:if test="$isGenerateTableIF = 'true'">
4217
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4218
+ </xsl:if>
4219
+
3525
4220
 
3526
- <fo:block xsl:use-attribute-sets="dt-style">
3527
- <xsl:copy-of select="@id"/>
3528
-
3529
- <xsl:if test="normalize-space($key_iso) = 'true'">
3530
- <xsl:attribute name="margin-top">0</xsl:attribute>
3531
- </xsl:if>
3532
-
3533
-
3534
-
3535
- <xsl:apply-templates/>
3536
- </fo:block>
3537
- </fo:table-cell>
3538
- <fo:table-cell>
3539
- <fo:block>
3540
-
3541
4221
 
3542
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
3543
- <xsl:with-param name="process">true</xsl:with-param>
3544
- </xsl:apply-templates>
3545
- </fo:block>
3546
- </fo:table-cell>
3547
- </fo:table-row>
4222
+ <xsl:choose>
4223
+ <xsl:when test="$isGenerateTableIF = 'true'">
4224
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
4225
+ <xsl:with-param name="process">true</xsl:with-param>
4226
+ </xsl:apply-templates>
4227
+ </xsl:when>
4228
+ <xsl:otherwise>
4229
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
4230
+ <xsl:with-param name="process">true</xsl:with-param>
4231
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4232
+ </xsl:apply-templates>
4233
+ </xsl:otherwise>
4234
+
4235
+ </xsl:choose>
4236
+
4237
+ <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"/> -->
4238
+
4239
+ </fo:block>
4240
+ </fo:table-cell>
3548
4241
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
3549
4242
  <xsl:apply-templates/>
3550
4243
  </xsl:template><xsl:template match="*[local-name()='dd']">
3551
4244
  <xsl:param name="process">false</xsl:param>
4245
+ <xsl:param name="split_keep-within-line"/>
3552
4246
  <xsl:if test="$process = 'true'">
3553
4247
  <xsl:apply-templates select="@language"/>
3554
- <xsl:apply-templates/>
4248
+ <xsl:apply-templates>
4249
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4250
+ </xsl:apply-templates>
3555
4251
  </xsl:if>
3556
4252
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
3557
4253
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
3558
- </xsl:template><xsl:template match="*[local-name()='em']">
4254
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
4255
+ <xsl:param name="id"/>
4256
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4257
+ <tr>
4258
+ <td>
4259
+ <xsl:copy-of select="node()"/>
4260
+ </td>
4261
+ <td>
4262
+
4263
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
4264
+
4265
+ <!-- get paragraphs from nested 'dl' -->
4266
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
4267
+
4268
+
4269
+ </td>
4270
+ </tr>
4271
+
4272
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
4273
+ <xsl:for-each select="*[local-name() = 'dt']">
4274
+ <p>
4275
+ <xsl:copy-of select="node()"/>
4276
+ <xsl:text> </xsl:text>
4277
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
4278
+ </p>
4279
+ </xsl:for-each>
4280
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
3559
4281
  <fo:inline font-style="italic">
3560
4282
  <xsl:apply-templates/>
3561
4283
  </fo:inline>
3562
4284
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
4285
+ <xsl:param name="split_keep-within-line"/>
3563
4286
  <fo:inline font-weight="bold">
3564
4287
 
3565
- <xsl:apply-templates/>
4288
+ <xsl:apply-templates>
4289
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
4290
+ </xsl:apply-templates>
3566
4291
  </fo:inline>
3567
4292
  </xsl:template><xsl:template match="*[local-name()='padding']">
3568
4293
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -3583,7 +4308,7 @@
3583
4308
 
3584
4309
 
3585
4310
 
3586
-
4311
+ <!-- 10 -->
3587
4312
 
3588
4313
 
3589
4314
 
@@ -3601,13 +4326,15 @@
3601
4326
  <xsl:choose>
3602
4327
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
3603
4328
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
3604
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4329
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
3605
4330
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
3606
4331
  </xsl:choose>
3607
4332
  </xsl:attribute>
3608
4333
  </xsl:if>
3609
4334
  <xsl:apply-templates/>
3610
4335
  </fo:inline>
4336
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
4337
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
3611
4338
  </xsl:template><xsl:template match="*[local-name()='underline']">
3612
4339
  <fo:inline text-decoration="underline">
3613
4340
  <xsl:apply-templates/>
@@ -3755,54 +4482,120 @@
3755
4482
  <fo:block break-after="page"/>
3756
4483
  <fo:block> </fo:block>
3757
4484
  <fo:block break-after="page"/>
4485
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
4486
+ <xsl:apply-templates/>
3758
4487
  </xsl:template><xsl:template name="tokenize">
3759
4488
  <xsl:param name="text"/>
3760
4489
  <xsl:param name="separator" select="' '"/>
3761
4490
  <xsl:choose>
4491
+
4492
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
4493
+ <word><xsl:value-of select="normalize-space($text)"/></word>
4494
+ </xsl:when>
3762
4495
  <xsl:when test="not(contains($text, $separator))">
3763
4496
  <word>
3764
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
3765
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
3766
4497
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
3767
- <xsl:variable name="len_str">
3768
- <xsl:choose>
3769
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
3770
- <xsl:value-of select="$len_str_tmp * 1.5"/>
3771
- </xsl:when>
3772
- <xsl:otherwise>
3773
- <xsl:value-of select="$len_str_tmp"/>
3774
- </xsl:otherwise>
3775
- </xsl:choose>
3776
- </xsl:variable>
3777
-
3778
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
3779
- <xsl:message>
3780
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
3781
- len_str=<xsl:value-of select="$len_str"/>
3782
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
3783
- </xsl:message>
3784
- </xsl:if> -->
3785
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
3786
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
3787
4498
  <xsl:choose>
3788
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
3789
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4499
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
4500
+ <xsl:value-of select="$len_str_tmp"/>
3790
4501
  </xsl:when>
3791
4502
  <xsl:otherwise>
3792
- <xsl:value-of select="$len_str"/>
4503
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
4504
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
4505
+ <xsl:variable name="len_str">
4506
+ <xsl:choose>
4507
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
4508
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
4509
+ </xsl:when>
4510
+ <xsl:otherwise>
4511
+ <xsl:value-of select="$len_str_tmp"/>
4512
+ </xsl:otherwise>
4513
+ </xsl:choose>
4514
+ </xsl:variable>
4515
+
4516
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
4517
+ <xsl:message>
4518
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
4519
+ len_str=<xsl:value-of select="$len_str"/>
4520
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
4521
+ </xsl:message>
4522
+ </xsl:if> -->
4523
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
4524
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
4525
+ <xsl:choose>
4526
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
4527
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
4528
+ </xsl:when>
4529
+ <xsl:otherwise>
4530
+ <xsl:value-of select="$len_str"/>
4531
+ </xsl:otherwise>
4532
+ </xsl:choose>
3793
4533
  </xsl:otherwise>
3794
4534
  </xsl:choose>
3795
4535
  </word>
3796
4536
  </xsl:when>
3797
4537
  <xsl:otherwise>
3798
4538
  <word>
3799
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
4539
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
4540
+ <xsl:choose>
4541
+ <xsl:when test="$isGenerateTableIF = 'true'">
4542
+ <xsl:value-of select="$word"/>
4543
+ </xsl:when>
4544
+ <xsl:otherwise>
4545
+ <xsl:value-of select="string-length($word)"/>
4546
+ </xsl:otherwise>
4547
+ </xsl:choose>
3800
4548
  </word>
3801
4549
  <xsl:call-template name="tokenize">
3802
4550
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
3803
4551
  </xsl:call-template>
3804
4552
  </xsl:otherwise>
3805
4553
  </xsl:choose>
4554
+ </xsl:template><xsl:template name="tokenize_with_tags">
4555
+ <xsl:param name="tags"/>
4556
+ <xsl:param name="text"/>
4557
+ <xsl:param name="separator" select="' '"/>
4558
+ <xsl:choose>
4559
+
4560
+ <xsl:when test="not(contains($text, $separator))">
4561
+ <word>
4562
+ <xsl:call-template name="enclose_text_in_tags">
4563
+ <xsl:with-param name="text" select="normalize-space($text)"/>
4564
+ <xsl:with-param name="tags" select="$tags"/>
4565
+ </xsl:call-template>
4566
+ </word>
4567
+ </xsl:when>
4568
+ <xsl:otherwise>
4569
+ <word>
4570
+ <xsl:call-template name="enclose_text_in_tags">
4571
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
4572
+ <xsl:with-param name="tags" select="$tags"/>
4573
+ </xsl:call-template>
4574
+ </word>
4575
+ <xsl:call-template name="tokenize_with_tags">
4576
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
4577
+ </xsl:call-template>
4578
+ </xsl:otherwise>
4579
+ </xsl:choose>
4580
+ </xsl:template><xsl:template name="enclose_text_in_tags">
4581
+ <xsl:param name="text"/>
4582
+ <xsl:param name="tags"/>
4583
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
4584
+
4585
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
4586
+
4587
+ <xsl:choose>
4588
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
4589
+ <xsl:otherwise>
4590
+ <xsl:element name="{$tag_name}">
4591
+ <xsl:call-template name="enclose_text_in_tags">
4592
+ <xsl:with-param name="text" select="$text"/>
4593
+ <xsl:with-param name="tags" select="$tags"/>
4594
+ <xsl:with-param name="num" select="$num + 1"/>
4595
+ </xsl:call-template>
4596
+ </xsl:element>
4597
+ </xsl:otherwise>
4598
+ </xsl:choose>
3806
4599
  </xsl:template><xsl:template name="max_length">
3807
4600
  <xsl:param name="words"/>
3808
4601
  <xsl:for-each select="$words//word">
@@ -3903,12 +4696,19 @@
3903
4696
  </xsl:otherwise>
3904
4697
  </xsl:choose>
3905
4698
  </xsl:template><xsl:template name="getSimpleTable">
4699
+ <xsl:param name="id"/>
4700
+
3906
4701
  <xsl:variable name="simple-table">
3907
4702
 
4703
+ <!-- Step 0. replace <br/> to <p>...</p> -->
4704
+ <xsl:variable name="table_without_br">
4705
+ <xsl:apply-templates mode="table-without-br"/>
4706
+ </xsl:variable>
4707
+
3908
4708
  <!-- Step 1. colspan processing -->
3909
4709
  <xsl:variable name="simple-table-colspan">
3910
4710
  <tbody>
3911
- <xsl:apply-templates mode="simple-table-colspan"/>
4711
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
3912
4712
  </tbody>
3913
4713
  </xsl:variable>
3914
4714
 
@@ -3917,10 +4717,67 @@
3917
4717
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
3918
4718
  </xsl:variable>
3919
4719
 
3920
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
3921
-
4720
+ <!-- Step 3: add id to each cell -->
4721
+ <!-- add <word>...</word> for each word, image, math -->
4722
+ <xsl:variable name="simple-table-id">
4723
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
4724
+ <xsl:with-param name="id" select="$id"/>
4725
+ </xsl:apply-templates>
4726
+ </xsl:variable>
4727
+
4728
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
4729
+
3922
4730
  </xsl:variable>
3923
4731
  <xsl:copy-of select="$simple-table"/>
4732
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
4733
+ <xsl:copy>
4734
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
4735
+ </xsl:copy>
4736
+ </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">
4737
+ <xsl:copy>
4738
+ <xsl:copy-of select="@*"/>
4739
+ <p>
4740
+ <xsl:copy-of select="node()"/>
4741
+ </p>
4742
+ </xsl:copy>
4743
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
4744
+ <xsl:copy>
4745
+ <xsl:copy-of select="@*"/>
4746
+ <xsl:for-each select="*[local-name()='br']">
4747
+ <xsl:variable name="current_id" select="generate-id()"/>
4748
+ <p>
4749
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
4750
+ <xsl:copy-of select="."/>
4751
+ </xsl:for-each>
4752
+ </p>
4753
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
4754
+ <p>
4755
+ <xsl:for-each select="following-sibling::node()">
4756
+ <xsl:copy-of select="."/>
4757
+ </xsl:for-each>
4758
+ </p>
4759
+ </xsl:if>
4760
+ </xsl:for-each>
4761
+ </xsl:copy>
4762
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
4763
+ <xsl:for-each select="*[local-name()='br']">
4764
+ <xsl:variable name="current_id" select="generate-id()"/>
4765
+ <p>
4766
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
4767
+ <xsl:copy-of select="."/>
4768
+ </xsl:for-each>
4769
+ </p>
4770
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
4771
+ <p>
4772
+ <xsl:for-each select="following-sibling::node()">
4773
+ <xsl:copy-of select="."/>
4774
+ </xsl:for-each>
4775
+ </p>
4776
+ </xsl:if>
4777
+ </xsl:for-each>
4778
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
4779
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
4780
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
3924
4781
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
3925
4782
  <xsl:apply-templates mode="simple-table-colspan"/>
3926
4783
  </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">
@@ -3998,18 +4855,138 @@
3998
4855
  </xsl:choose>
3999
4856
  </xsl:for-each>
4000
4857
  </xsl:variable>
4001
-
4002
- <xsl:variable name="newRow">
4003
- <xsl:copy>
4004
- <xsl:copy-of select="$currentRow/@*"/>
4005
- <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
4006
- </xsl:copy>
4858
+
4859
+ <xsl:variable name="newRow">
4860
+ <xsl:copy>
4861
+ <xsl:copy-of select="$currentRow/@*"/>
4862
+ <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
4863
+ </xsl:copy>
4864
+ </xsl:variable>
4865
+ <xsl:copy-of select="$newRow"/>
4866
+
4867
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
4868
+ <xsl:with-param name="previousRow" select="$newRow"/>
4869
+ </xsl:apply-templates>
4870
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
4871
+ <xsl:param name="id"/>
4872
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
4873
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
4874
+ <xsl:with-param name="id" select="$id_prefixed"/>
4875
+ </xsl:apply-templates>
4876
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
4877
+ <xsl:param name="id"/>
4878
+ <xsl:copy>
4879
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
4880
+ <xsl:with-param name="id" select="$id"/>
4881
+ </xsl:apply-templates>
4882
+ </xsl:copy>
4883
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
4884
+ <xsl:param name="id"/>
4885
+ <xsl:copy>
4886
+ <xsl:copy-of select="@*"/>
4887
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4888
+ <xsl:apply-templates select="node()" mode="simple-table-id">
4889
+ <xsl:with-param name="id" select="$id"/>
4890
+ </xsl:apply-templates>
4891
+ </xsl:copy>
4892
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
4893
+ <xsl:param name="id"/>
4894
+ <xsl:copy>
4895
+ <xsl:copy-of select="@*"/>
4896
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
4897
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
4898
+ <xsl:attribute name="id">
4899
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
4900
+ </xsl:attribute>
4901
+
4902
+ <xsl:for-each select="*[local-name() = 'p']">
4903
+ <xsl:copy>
4904
+ <xsl:copy-of select="@*"/>
4905
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
4906
+ <xsl:attribute name="id">
4907
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
4908
+ </xsl:attribute>
4909
+
4910
+ <xsl:copy-of select="node()"/>
4911
+ </xsl:copy>
4912
+ </xsl:for-each>
4913
+
4914
+
4915
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
4916
+
4917
+ <xsl:variable name="td_text">
4918
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
4919
+ </xsl:variable>
4920
+
4921
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
4922
+
4923
+ <xsl:variable name="words">
4924
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
4925
+ <word>
4926
+ <xsl:copy-of select="."/>
4927
+ </word>
4928
+ </xsl:for-each>
4929
+
4930
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
4931
+ <xsl:copy-of select="."/>
4932
+ </xsl:for-each>
4933
+
4934
+ </xsl:variable>
4935
+
4936
+ <xsl:for-each select="xalan:nodeset($words)/word">
4937
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
4938
+ <xsl:copy>
4939
+ <xsl:attribute name="id">
4940
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
4941
+ </xsl:attribute>
4942
+ <xsl:copy-of select="node()"/>
4943
+ </xsl:copy>
4944
+ </xsl:for-each>
4945
+ </xsl:if>
4946
+ </xsl:copy>
4947
+
4948
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
4949
+ <xsl:copy>
4950
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
4951
+ </xsl:copy>
4952
+ </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">
4953
+ <xsl:variable name="formatting_tags">
4954
+ <xsl:call-template name="getFormattingTags"/>
4955
+ </xsl:variable>
4956
+ <word>
4957
+ <xsl:call-template name="enclose_text_in_tags">
4958
+ <xsl:with-param name="text" select="normalize-space(.)"/>
4959
+ <xsl:with-param name="tags" select="$formatting_tags"/>
4960
+ </xsl:call-template>
4961
+ </word>
4962
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
4963
+
4964
+ <xsl:variable name="td_text" select="."/>
4965
+
4966
+ <xsl:variable name="string_with_added_zerospaces">
4967
+ <xsl:call-template name="add-zero-spaces-java">
4968
+ <xsl:with-param name="text" select="$td_text"/>
4969
+ </xsl:call-template>
4007
4970
  </xsl:variable>
4008
- <xsl:copy-of select="$newRow"/>
4009
-
4010
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
4011
- <xsl:with-param name="previousRow" select="$newRow"/>
4012
- </xsl:apply-templates>
4971
+
4972
+ <xsl:variable name="formatting_tags">
4973
+ <xsl:call-template name="getFormattingTags"/>
4974
+ </xsl:variable>
4975
+
4976
+ <!-- <word>text</word> -->
4977
+ <xsl:call-template name="tokenize_with_tags">
4978
+ <xsl:with-param name="tags" select="$formatting_tags"/>
4979
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
4980
+ </xsl:call-template>
4981
+ </xsl:template><xsl:template name="getFormattingTags">
4982
+ <tags>
4983
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
4984
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
4985
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
4986
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
4987
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
4988
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
4989
+ </tags>
4013
4990
  </xsl:template><xsl:template name="getLang">
4014
4991
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
4015
4992
  <xsl:variable name="language">
@@ -4178,7 +5155,9 @@
4178
5155
  <!-- replace start and end spaces to non-break space -->
4179
5156
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4180
5157
  </xsl:copy>
4181
- </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">
5158
+ </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">
5159
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5160
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
4182
5161
  <xsl:variable name="target">
4183
5162
  <xsl:choose>
4184
5163
  <xsl:when test="@updatetype = 'true'">
@@ -4996,7 +5975,11 @@
4996
5975
  <xsl:apply-templates mode="bookmarks"/>
4997
5976
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
4998
5977
  <xsl:apply-templates select="."/>
4999
- </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">
5978
+ </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">
5979
+ <xsl:apply-templates mode="contents"/>
5980
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
5981
+ <xsl:apply-templates mode="bookmarks"/>
5982
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
5000
5983
  <xsl:apply-templates mode="bookmarks"/>
5001
5984
  </xsl:template><xsl:template name="addBookmarks">
5002
5985
  <xsl:param name="contents"/>
@@ -5267,7 +6250,9 @@
5267
6250
  <xsl:apply-templates/>
5268
6251
  </xsl:otherwise>
5269
6252
  </xsl:choose>
5270
- </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">
6253
+ </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">
6254
+ <xsl:value-of select="."/>
6255
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
5271
6256
  <xsl:text> </xsl:text>
5272
6257
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
5273
6258
  <xsl:copy>
@@ -5298,9 +6283,22 @@
5298
6283
  </xsl:when>
5299
6284
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
5300
6285
  </xsl:choose>
6286
+ </xsl:template><xsl:template match="text()" mode="contents_item">
6287
+ <xsl:call-template name="keep_together_standard_number"/>
6288
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
6289
+ <xsl:apply-templates mode="contents_item"/>
5301
6290
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
5302
6291
 
5303
6292
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
6293
+
6294
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
6295
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6296
+ </xsl:if>
6297
+
6298
+ <xsl:if test="ancestor::*[local-name() = 'example']">
6299
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6300
+ </xsl:if>
6301
+
5304
6302
  <xsl:copy-of select="@id"/>
5305
6303
 
5306
6304
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -5325,7 +6323,7 @@
5325
6323
 
5326
6324
 
5327
6325
 
5328
-
6326
+ <!-- 9 -->
5329
6327
 
5330
6328
 
5331
6329
 
@@ -5409,7 +6407,7 @@
5409
6407
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
5410
6408
  <xsl:choose>
5411
6409
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
5412
- <xsl:call-template name="interspers">
6410
+ <xsl:call-template name="interspers-java">
5413
6411
  <xsl:with-param name="str" select="."/>
5414
6412
  </xsl:call-template>
5415
6413
  </xsl:when>
@@ -5459,6 +6457,10 @@
5459
6457
  <xsl:with-param name="char" select="$char"/>
5460
6458
  </xsl:call-template>
5461
6459
  </xsl:if>
6460
+ </xsl:template><xsl:template name="interspers-java">
6461
+ <xsl:param name="str"/>
6462
+ <xsl:param name="char" select="$zero_width_space"/>
6463
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
5462
6464
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
5463
6465
  <xsl:apply-templates mode="syntax_highlight"/>
5464
6466
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -5679,7 +6681,9 @@
5679
6681
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
5680
6682
  </xsl:if>
5681
6683
  <xsl:variable name="simple-table">
5682
- <xsl:call-template name="getSimpleTable"/>
6684
+ <xsl:call-template name="getSimpleTable">
6685
+ <xsl:with-param name="id" select="@id"/>
6686
+ </xsl:call-template>
5683
6687
  </xsl:variable>
5684
6688
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
5685
6689
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -5788,39 +6792,67 @@
5788
6792
  </xsl:otherwise>
5789
6793
  </xsl:choose>
5790
6794
  </xsl:template><xsl:template match="*[local-name() = 'example']">
5791
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
5792
-
6795
+
6796
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
6797
+
5793
6798
 
6799
+
5794
6800
  <xsl:variable name="fo_element">
5795
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
6801
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
5796
6802
  block
5797
6803
  </xsl:variable>
5798
6804
 
5799
- <!-- display 'EXAMPLE' -->
5800
- <xsl:apply-templates select="*[local-name()='name']">
5801
- <xsl:with-param name="fo_element" select="$fo_element"/>
5802
- </xsl:apply-templates>
6805
+ <fo:block-container margin-left="0mm">
5803
6806
 
5804
- <xsl:choose>
5805
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
5806
- <fo:block-container xsl:use-attribute-sets="example-body-style">
5807
- <fo:block-container margin-left="0mm" margin-right="0mm">
5808
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6807
+ <xsl:choose>
6808
+
6809
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
6810
+
6811
+ <!-- display name 'EXAMPLE' in a separate block -->
6812
+ <fo:block>
6813
+ <xsl:apply-templates select="*[local-name()='name']">
5809
6814
  <xsl:with-param name="fo_element" select="$fo_element"/>
5810
6815
  </xsl:apply-templates>
6816
+ </fo:block>
6817
+
6818
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6819
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6820
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6821
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6822
+ </xsl:apply-templates>
6823
+ </fo:block-container>
5811
6824
  </fo:block-container>
5812
- </fo:block-container>
5813
- </xsl:when>
5814
- <xsl:otherwise>
5815
- <fo:inline>
5816
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
5817
- <xsl:with-param name="fo_element" select="$fo_element"/>
5818
- </xsl:apply-templates>
5819
- </fo:inline>
5820
- </xsl:otherwise>
5821
- </xsl:choose>
5822
-
5823
- </fo:block>
6825
+ </xsl:when> <!-- end block -->
6826
+
6827
+ <xsl:otherwise> <!-- inline -->
6828
+
6829
+ <!-- display 'EXAMPLE' and first element in the same line -->
6830
+ <fo:block>
6831
+ <xsl:apply-templates select="*[local-name()='name']">
6832
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6833
+ </xsl:apply-templates>
6834
+ <fo:inline>
6835
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
6836
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6837
+ </xsl:apply-templates>
6838
+ </fo:inline>
6839
+ </fo:block>
6840
+
6841
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
6842
+ <!-- display further elements in blocks -->
6843
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6844
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6845
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
6846
+ <xsl:with-param name="fo_element" select="'block'"/>
6847
+ </xsl:apply-templates>
6848
+ </fo:block-container>
6849
+ </fo:block-container>
6850
+ </xsl:if>
6851
+ </xsl:otherwise> <!-- end inline -->
6852
+
6853
+ </xsl:choose>
6854
+ </fo:block-container>
6855
+ </fo:block-container>
5824
6856
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
5825
6857
  <xsl:param name="fo_element">block</xsl:param>
5826
6858
 
@@ -5852,10 +6884,16 @@
5852
6884
  </xsl:variable>
5853
6885
  <xsl:choose>
5854
6886
  <xsl:when test="starts-with(normalize-space($element), 'block')">
5855
- <fo:block xsl:use-attribute-sets="example-p-style">
5856
-
5857
- <xsl:apply-templates/>
5858
- </fo:block>
6887
+ <fo:block-container>
6888
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
6889
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
6890
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
6891
+ </xsl:if>
6892
+ <fo:block xsl:use-attribute-sets="example-p-style">
6893
+
6894
+ <xsl:apply-templates/>
6895
+ </fo:block>
6896
+ </fo:block-container>
5859
6897
  </xsl:when>
5860
6898
  <xsl:otherwise>
5861
6899
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -6037,7 +7075,16 @@
6037
7075
  </fo:inline>
6038
7076
  </xsl:when>
6039
7077
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
6040
- <fo:inline><xsl:apply-templates/></fo:inline>
7078
+
7079
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
7080
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
7081
+ <xsl:choose>
7082
+ <xsl:when test="$uri_src != ''">
7083
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
7084
+ </xsl:when>
7085
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
7086
+ </xsl:choose>
7087
+
6041
7088
  </xsl:otherwise>
6042
7089
  </xsl:choose>
6043
7090
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -6222,10 +7269,24 @@
6222
7269
 
6223
7270
  </fo:block>
6224
7271
  <xsl:apply-templates/>
6225
- </xsl:template><xsl:template match="*[local-name() = 'review']">
7272
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
6226
7273
  <!-- comment 2019-11-29 -->
6227
7274
  <!-- <fo:block font-weight="bold">Review:</fo:block>
6228
7275
  <xsl:apply-templates /> -->
7276
+
7277
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
7278
+
7279
+ <xsl:choose>
7280
+ <!-- if there isn't the attribute '@from', then -->
7281
+ <xsl:when test="$id_from = ''">
7282
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7283
+ </xsl:when>
7284
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
7285
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
7286
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
7287
+ </xsl:when>
7288
+ </xsl:choose>
7289
+
6229
7290
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
6230
7291
  <!-- 0xA0 to space replacement -->
6231
7292
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -6370,6 +7431,11 @@
6370
7431
  </xsl:otherwise>
6371
7432
  </xsl:choose>
6372
7433
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
7434
+
7435
+ <xsl:apply-templates select="*[local-name() = 'name']">
7436
+ <xsl:with-param name="process">true</xsl:with-param>
7437
+ </xsl:apply-templates>
7438
+
6373
7439
  <fo:list-block xsl:use-attribute-sets="list-style">
6374
7440
 
6375
7441
 
@@ -6380,12 +7446,23 @@
6380
7446
 
6381
7447
 
6382
7448
 
7449
+ <xsl:if test="*[local-name() = 'name']">
7450
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
7451
+ </xsl:if>
7452
+
6383
7453
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
6384
7454
  </fo:list-block>
6385
7455
  <!-- <xsl:for-each select="./iho:note">
6386
7456
  <xsl:call-template name="note"/>
6387
7457
  </xsl:for-each> -->
6388
7458
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
7459
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
7460
+ <xsl:param name="process">false</xsl:param>
7461
+ <xsl:if test="$process = 'true'">
7462
+ <fo:block xsl:use-attribute-sets="list-name-style">
7463
+ <xsl:apply-templates/>
7464
+ </fo:block>
7465
+ </xsl:if>
6389
7466
  </xsl:template><xsl:template match="*[local-name()='li']">
6390
7467
  <fo:list-item xsl:use-attribute-sets="list-item-style">
6391
7468
  <xsl:copy-of select="@id"/>
@@ -6582,7 +7659,10 @@
6582
7659
  <!-- to split by '_' and other chars -->
6583
7660
  <xsl:call-template name="add-zero-spaces-java"/>
6584
7661
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
6585
- <fo:inline id="{@id}" font-size="1pt"/>
7662
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
7663
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
7664
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
7665
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
6586
7666
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
6587
7667
  <!-- <row>
6588
7668
  <date>05-07-2013</date>
@@ -6686,143 +7766,7 @@
6686
7766
  <xsl:if test=".//ogc:fn">
6687
7767
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
6688
7768
  </xsl:if>
6689
- <xsl:choose>
6690
- <xsl:when test="*[local-name() = 'formattedref']">
6691
- <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
6692
- </xsl:when>
6693
- <xsl:otherwise>
6694
- <xsl:variable name="personalAuthors">
6695
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']/*[local-name() = 'person']">
6696
- <xsl:call-template name="processPersonalAuthor"/>
6697
- </xsl:for-each>
6698
- <xsl:if test="not(*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']/*[local-name() = 'person'])">
6699
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='editor']/*[local-name() = 'person']">
6700
- <xsl:call-template name="processPersonalAuthor"/>
6701
- </xsl:for-each>
6702
- </xsl:if>
6703
- </xsl:variable>
6704
-
6705
- <xsl:variable name="city" select="*[local-name() = 'place']"/>
6706
- <xsl:variable name="year">
6707
- <xsl:choose>
6708
- <xsl:when test="*[local-name() = 'date'][@type = 'published']">
6709
- <xsl:for-each select="*[local-name() = 'date'][@type = 'published']">
6710
- <xsl:call-template name="renderDate"/>
6711
- </xsl:for-each>
6712
- </xsl:when>
6713
- <xsl:when test="*[local-name() = 'date'][@type = 'issued']">
6714
- <xsl:for-each select="*[local-name() = 'date'][@type = 'issued']">
6715
- <xsl:call-template name="renderDate"/>
6716
- </xsl:for-each>
6717
- </xsl:when>
6718
- <xsl:when test="*[local-name() = 'date'][@type = 'circulated']">
6719
- <xsl:for-each select="*[local-name() = 'date'][@type = 'circulated']">
6720
- <xsl:call-template name="renderDate"/>
6721
- </xsl:for-each>
6722
- </xsl:when>
6723
- <xsl:otherwise>
6724
- <xsl:for-each select="*[local-name() = 'date']">
6725
- <xsl:call-template name="renderDate"/>
6726
- </xsl:for-each>
6727
- </xsl:otherwise>
6728
- </xsl:choose>
6729
- </xsl:variable>
6730
-
6731
- <xsl:variable name="uri" select="*[local-name() = 'uri']"/>
6732
-
6733
-
6734
- <!-- citation structure:
6735
- {personal names | organisation}: {document identifier}, {title}. {publisher}, {city} ({year})
6736
- -->
6737
-
6738
- <!-- Author(s) -->
6739
- <xsl:choose>
6740
- <xsl:when test="xalan:nodeset($personalAuthors)//author">
6741
- <xsl:for-each select="xalan:nodeset($personalAuthors)//author">
6742
- <xsl:apply-templates/>
6743
- <xsl:if test="position() != last()">, </xsl:if>
6744
- </xsl:for-each>
6745
- <xsl:text>: </xsl:text>
6746
- </xsl:when>
6747
- <xsl:when test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'abbreviation']">
6748
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'abbreviation']">
6749
- <xsl:value-of select="."/>
6750
- <xsl:if test="position() != last()">/</xsl:if>
6751
- </xsl:for-each>
6752
- <xsl:text>: </xsl:text>
6753
- </xsl:when>
6754
- <xsl:when test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
6755
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
6756
- <xsl:value-of select="."/>
6757
- <xsl:if test="position() != last()">, </xsl:if>
6758
- </xsl:for-each>
6759
- <xsl:text>: </xsl:text>
6760
- </xsl:when>
6761
- </xsl:choose>
6762
-
6763
-
6764
- <xsl:variable name="document_identifier">
6765
- <xsl:call-template name="processBibitemDocId"/>
6766
- </xsl:variable>
6767
-
6768
- <xsl:value-of select="$document_identifier"/>
6769
-
6770
- <xsl:apply-templates select="*[local-name() = 'note']"/>
6771
-
6772
- <xsl:variable name="isDraft">
6773
- <xsl:variable name="stage" select="normalize-space(*[local-name() = 'status']/*[local-name() = 'stage'])"/>
6774
- <xsl:if test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization'][*[local-name() = 'name']/text() = 'Open Geospatial Consortium'] and $stage != '' and $stage != 'published' and $stage != 'deprecated' and $stage != 'retired'">true</xsl:if>
6775
- </xsl:variable>
6776
-
6777
- <xsl:if test="$isDraft = 'true'">
6778
- <xsl:text> (Draft)</xsl:text>
6779
- </xsl:if>
6780
-
6781
- <xsl:text>, </xsl:text>
6782
-
6783
- <xsl:choose>
6784
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = 'en']">
6785
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = 'en']"/>
6786
- </xsl:when>
6787
- <xsl:otherwise>
6788
- <xsl:apply-templates select="*[local-name() = 'title']"/>
6789
- </xsl:otherwise>
6790
- </xsl:choose>
6791
-
6792
- <xsl:text>. </xsl:text>
6793
-
6794
- <xsl:if test="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
6795
- <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name']">
6796
- <xsl:value-of select="."/>
6797
- <xsl:if test="position() != last()">, </xsl:if>
6798
- </xsl:for-each>
6799
- <xsl:if test="normalize-space($city) != ''">, </xsl:if>
6800
- </xsl:if>
6801
-
6802
- <xsl:value-of select="$city"/>
6803
-
6804
- <xsl:if test="(*[local-name() = 'contributor'][*[local-name() = 'role']/@type = 'publisher']/*[local-name() = 'organization']/*[local-name() = 'name'] or normalize-space($city) != '') and normalize-space($year) != ''">
6805
- <xsl:text> </xsl:text>
6806
- </xsl:if>
6807
-
6808
- <xsl:if test="normalize-space($year) != ''">
6809
- <xsl:text>(</xsl:text>
6810
- <xsl:value-of select="$year"/>
6811
- <xsl:text>). </xsl:text>
6812
- </xsl:if>
6813
-
6814
- <xsl:if test="normalize-space($uri) != ''">
6815
- <fo:inline>
6816
-
6817
- <xsl:text> </xsl:text>
6818
- <fo:basic-link external-destination="{$uri}" fox:alt-text="{$uri}">
6819
- <xsl:value-of select="$uri"/>
6820
- </fo:basic-link>
6821
- </fo:inline>
6822
- </xsl:if>
6823
-
6824
- </xsl:otherwise>
6825
- </xsl:choose>
7769
+ <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
6826
7770
  <!-- end OGC bibitem processing-->
6827
7771
 
6828
7772
  </xsl:template><xsl:template name="processBibitemDocId">
@@ -7150,25 +8094,32 @@
7150
8094
  </fo:block-container>
7151
8095
 
7152
8096
  </xsl:template><xsl:template name="displayAdmonitionName">
7153
-
8097
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
8098
+ <!-- <xsl:choose>
8099
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
8100
+ <xsl:choose>
8101
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
8102
+ <xsl:otherwise>
8103
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8104
+ </xsl:otherwise>
8105
+ </xsl:choose>
8106
+ </xsl:when>
8107
+ <xsl:otherwise>
7154
8108
  <xsl:apply-templates select="*[local-name() = 'name']"/>
7155
8109
  <xsl:if test="not(*[local-name() = 'name'])">
7156
8110
  <xsl:apply-templates select="@type"/>
7157
8111
  </xsl:if>
7158
-
7159
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
7160
- <xsl:apply-templates/>
7161
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
7162
- <xsl:variable name="admonition_type_">
7163
- <xsl:call-template name="getLocalizedString">
7164
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
7165
- </xsl:call-template>
8112
+ </xsl:otherwise>
8113
+ </xsl:choose> -->
8114
+ <xsl:variable name="name">
8115
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
7166
8116
  </xsl:variable>
7167
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
7168
- <xsl:value-of select="$admonition_type"/>
7169
- <xsl:if test="$admonition_type = ''">
7170
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
8117
+ <xsl:copy-of select="$name"/>
8118
+ <xsl:if test="normalize-space($name) != ''">
8119
+ <xsl:value-of select="$sep"/>
7171
8120
  </xsl:if>
8121
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8122
+ <xsl:apply-templates/>
7172
8123
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
7173
8124
 
7174
8125
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -7250,6 +8201,120 @@
7250
8201
  <xsl:apply-templates select="." mode="update_xml_step1"/>
7251
8202
  </xsl:for-each>
7252
8203
  </xsl:copy>
8204
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
8205
+ <xsl:apply-templates mode="update_xml_step1"/>
8206
+ </xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
8207
+ <xsl:copy>
8208
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
8209
+ </xsl:copy>
8210
+ </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">
8211
+
8212
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
8213
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
8214
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8215
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
8216
+ <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))"/>
8217
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
8218
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8219
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8220
+ <xsl:with-param name="text" select="$text_"/>
8221
+ </xsl:call-template></text></xsl:variable>
8222
+
8223
+ <xsl:variable name="parent" select="local-name(..)"/>
8224
+
8225
+ <xsl:variable name="text2">
8226
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
8227
+ <xsl:copy-of select="."/>
8228
+ </xsl:for-each></text>
8229
+ </xsl:variable>
8230
+
8231
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
8232
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
8233
+ <xsl:variable name="text3">
8234
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
8235
+ <xsl:choose>
8236
+ <xsl:when test="self::text()">
8237
+ <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))"/>
8238
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
8239
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8240
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8241
+ <xsl:with-param name="text" select="$text_units_"/>
8242
+ </xsl:call-template></text></xsl:variable>
8243
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
8244
+ </xsl:when>
8245
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8246
+ </xsl:choose>
8247
+ </xsl:for-each></text>
8248
+ </xsl:variable>
8249
+
8250
+ <xsl:choose>
8251
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
8252
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
8253
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
8254
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
8255
+ <xsl:choose>
8256
+ <xsl:when test="self::text()">
8257
+ <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))"/>
8258
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
8259
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
8260
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
8261
+ <xsl:with-param name="text" select="$text_dots_"/>
8262
+ </xsl:call-template></text></xsl:variable>
8263
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
8264
+ </xsl:when>
8265
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
8266
+ </xsl:choose>
8267
+ </xsl:for-each>
8268
+ </xsl:when>
8269
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
8270
+ </xsl:choose>
8271
+
8272
+ </xsl:template><xsl:template name="replace_text_tags">
8273
+ <xsl:param name="tag_open"/>
8274
+ <xsl:param name="tag_close"/>
8275
+ <xsl:param name="text"/>
8276
+ <xsl:choose>
8277
+ <xsl:when test="contains($text, $tag_open)">
8278
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
8279
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
8280
+
8281
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
8282
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
8283
+ </xsl:element>
8284
+
8285
+ <xsl:call-template name="replace_text_tags">
8286
+ <xsl:with-param name="tag_open" select="$tag_open"/>
8287
+ <xsl:with-param name="tag_close" select="$tag_close"/>
8288
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
8289
+ </xsl:call-template>
8290
+ </xsl:when>
8291
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
8292
+ </xsl:choose>
8293
+ </xsl:template><xsl:template name="printEdition">
8294
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
8295
+ <xsl:text> </xsl:text>
8296
+ <xsl:choose>
8297
+ <xsl:when test="$edition_i18n != ''">
8298
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
8299
+ <xsl:call-template name="capitalize">
8300
+ <xsl:with-param name="str" select="$edition_i18n"/>
8301
+ </xsl:call-template>
8302
+ </xsl:when>
8303
+ <xsl:otherwise>
8304
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
8305
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
8306
+ <xsl:call-template name="capitalize">
8307
+ <xsl:with-param name="str">
8308
+ <xsl:call-template name="getLocalizedString">
8309
+ <xsl:with-param name="key">edition</xsl:with-param>
8310
+ </xsl:call-template>
8311
+ </xsl:with-param>
8312
+ </xsl:call-template>
8313
+ <xsl:text> </xsl:text>
8314
+ <xsl:value-of select="$edition"/>
8315
+ </xsl:if>
8316
+ </xsl:otherwise>
8317
+ </xsl:choose>
7253
8318
  </xsl:template><xsl:template name="convertDate">
7254
8319
  <xsl:param name="date"/>
7255
8320
  <xsl:param name="format" select="'short'"/>
@@ -7937,4 +9002,40 @@
7937
9002
  <xsl:value-of select="$value"/>
7938
9003
  </xsl:otherwise>
7939
9004
  </xsl:choose>
9005
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
9006
+ <xsl:param name="level">0</xsl:param>
9007
+
9008
+ <fo:block margin-left="{2*$level}mm">
9009
+ <xsl:text>
9010
+ &lt;</xsl:text>
9011
+ <xsl:value-of select="local-name()"/>
9012
+ <xsl:for-each select="@*">
9013
+ <xsl:text> </xsl:text>
9014
+ <xsl:value-of select="local-name()"/>
9015
+ <xsl:text>="</xsl:text>
9016
+ <xsl:value-of select="."/>
9017
+ <xsl:text>"</xsl:text>
9018
+ </xsl:for-each>
9019
+ <xsl:text>&gt;</xsl:text>
9020
+
9021
+ <xsl:if test="not(*)">
9022
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
9023
+ <xsl:text>&lt;/</xsl:text>
9024
+ <xsl:value-of select="local-name()"/>
9025
+ <xsl:text>&gt;</xsl:text>
9026
+ </xsl:if>
9027
+ </fo:block>
9028
+
9029
+ <xsl:if test="*">
9030
+ <fo:block>
9031
+ <xsl:apply-templates mode="print_as_xml">
9032
+ <xsl:with-param name="level" select="$level + 1"/>
9033
+ </xsl:apply-templates>
9034
+ </fo:block>
9035
+ <fo:block margin-left="{2*$level}mm">
9036
+ <xsl:text>&lt;/</xsl:text>
9037
+ <xsl:value-of select="local-name()"/>
9038
+ <xsl:text>&gt;</xsl:text>
9039
+ </fo:block>
9040
+ </xsl:if>
7940
9041
  </xsl:template></xsl:stylesheet>