metanorma-iso 2.0.8 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +37 -0
  3. data/lib/isodoc/iso/base_convert.rb +1 -1
  4. data/lib/isodoc/iso/html/html_iso_titlepage.html +5 -0
  5. data/lib/isodoc/iso/html/isodoc-dis.css +304 -242
  6. data/lib/isodoc/iso/html/isodoc-dis.scss +379 -260
  7. data/lib/isodoc/iso/html/word_iso_intro-dis.html +7 -0
  8. data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +4 -3
  9. data/lib/isodoc/iso/html/word_iso_titlepage.html +10 -4
  10. data/lib/isodoc/iso/html/wordstyle-dis.css +168 -48
  11. data/lib/isodoc/iso/html/wordstyle-dis.scss +158 -43
  12. data/lib/isodoc/iso/html_convert.rb +2 -2
  13. data/lib/isodoc/iso/i18n-en.yaml +1 -0
  14. data/lib/isodoc/iso/i18n-fr.yaml +1 -0
  15. data/lib/isodoc/iso/i18n-ru.yaml +1 -0
  16. data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -0
  17. data/lib/isodoc/iso/init.rb +17 -1
  18. data/lib/isodoc/iso/iso.amendment.xsl +1697 -426
  19. data/lib/isodoc/iso/iso.international-standard.xsl +1697 -426
  20. data/lib/isodoc/iso/metadata.rb +13 -19
  21. data/lib/isodoc/iso/presentation_inline.rb +90 -0
  22. data/lib/isodoc/iso/presentation_xml_convert.rb +41 -100
  23. data/lib/isodoc/iso/presentation_xref.rb +126 -0
  24. data/lib/isodoc/iso/sections.rb +2 -2
  25. data/lib/isodoc/iso/word_cleanup.rb +16 -2
  26. data/lib/isodoc/iso/word_convert.rb +29 -12
  27. data/lib/isodoc/iso/word_dis_convert.rb +183 -0
  28. data/lib/isodoc/iso/xref.rb +46 -25
  29. data/lib/metanorma/iso/biblio.rng +37 -8
  30. data/lib/metanorma/iso/boilerplate-fr.xml +1 -1
  31. data/lib/metanorma/iso/boilerplate-ru.xml +1 -3
  32. data/lib/metanorma/iso/boilerplate.xml +1 -3
  33. data/lib/metanorma/iso/cleanup.rb +2 -1
  34. data/lib/metanorma/iso/isodoc.rng +56 -0
  35. data/lib/metanorma/iso/version.rb +1 -1
  36. data/lib/metanorma-iso.rb +1 -0
  37. data/lib/relaton/render/config.yml +4 -0
  38. data/lib/relaton/render/general.rb +13 -0
  39. data/metanorma-iso.gemspec +1 -1
  40. data/spec/isodoc/amd_spec.rb +31 -30
  41. data/spec/isodoc/blocks_spec.rb +286 -179
  42. data/spec/isodoc/i18n_spec.rb +187 -21
  43. data/spec/isodoc/inline_spec.rb +35 -42
  44. data/spec/isodoc/iso_spec.rb +1 -1
  45. data/spec/isodoc/metadata_spec.rb +17 -17
  46. data/spec/isodoc/postproc_spec.rb +28 -3
  47. data/spec/isodoc/ref_spec.rb +66 -69
  48. data/spec/isodoc/section_spec.rb +78 -76
  49. data/spec/isodoc/table_spec.rb +2 -2
  50. data/spec/isodoc/terms_spec.rb +2 -2
  51. data/spec/isodoc/word_dis_spec.rb +760 -0
  52. data/spec/isodoc/xref_spec.rb +51 -51
  53. data/spec/metanorma/base_spec.rb +10 -10
  54. data/spec/spec_helper.rb +11 -1
  55. data/spec/vcr_cassettes/withdrawn_iso.yml +26 -26
  56. metadata +11 -5
  57. data/spec/vcr_cassettes/docrels.yml +0 -385
@@ -194,6 +194,47 @@
194
194
  </xsl:for-each>
195
195
  </xsl:variable>
196
196
 
197
+ <xsl:variable name="editorialgroup_">
198
+ <xsl:variable name="data">
199
+ <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:technical-committee[normalize-space(@number) != '']">
200
+ <xsl:text>/TC </xsl:text><fo:inline font-weight="bold"><xsl:value-of select="@number"/></fo:inline>
201
+ </xsl:for-each>
202
+ <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:subcommittee[normalize-space(@number) != '']">
203
+ <xsl:text>/SC </xsl:text><fo:inline font-weight="bold"><xsl:value-of select="@number"/></fo:inline>
204
+ </xsl:for-each>
205
+ <xsl:if test="not($stage-abbreviation = 'DIS' or $stage-abbreviation = 'FDIS')">
206
+ <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:workgroup[normalize-space(@number) != '']">
207
+ <xsl:text>/WG </xsl:text><fo:inline font-weight="bold"><xsl:value-of select="@number"/></fo:inline>
208
+ </xsl:for-each>
209
+ </xsl:if>
210
+ </xsl:variable>
211
+ <xsl:if test="normalize-space($data) != ''">
212
+ <xsl:text>ISO</xsl:text><xsl:copy-of select="$data"/>
213
+ </xsl:if>
214
+ </xsl:variable>
215
+ <xsl:variable name="editorialgroup" select="xalan:nodeset($editorialgroup_)"/>
216
+
217
+ <xsl:variable name="secretariat_">
218
+ <xsl:variable name="value" select="normalize-space(/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:secretariat)"/>
219
+ <xsl:if test="$value != ''">
220
+ <xsl:call-template name="getLocalizedString">
221
+ <xsl:with-param name="key">secretariat</xsl:with-param>
222
+ </xsl:call-template>
223
+ <xsl:text>: </xsl:text>
224
+ <fo:inline font-weight="bold"><xsl:value-of select="$value"/></fo:inline>
225
+ </xsl:if>
226
+ </xsl:variable>
227
+ <xsl:variable name="secretariat" select="xalan:nodeset($secretariat_)"/>
228
+
229
+ <xsl:variable name="ics_">
230
+ <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:ics/iso:code">
231
+ <xsl:if test="position() = 1"><fo:inline>ICS: </fo:inline></xsl:if>
232
+ <xsl:value-of select="."/>
233
+ <xsl:if test="position() != last()"><xsl:text>; </xsl:text></xsl:if>
234
+ </xsl:for-each>
235
+ </xsl:variable>
236
+ <xsl:variable name="ics" select="xalan:nodeset($ics_)"/>
237
+
197
238
  <xsl:variable name="XML" select="/"/>
198
239
 
199
240
  <xsl:template match="/">
@@ -256,17 +297,17 @@
256
297
  <!-- contents pages -->
257
298
  <!-- odd pages -->
258
299
  <fo:simple-page-master master-name="odd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
259
- <fo:region-body margin-top="27.4mm" margin-bottom="13mm" margin-left="19mm" margin-right="19mm"/>
300
+ <fo:region-body margin-top="27.4mm" margin-bottom="{$marginBottom + 2}mm" margin-left="19mm" margin-right="19mm"/>
260
301
  <fo:region-before region-name="header-odd" extent="27.4mm"/> <!-- display-align="center" -->
261
- <fo:region-after region-name="footer-odd" extent="13mm"/>
302
+ <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
262
303
  <fo:region-start region-name="left-region" extent="19mm"/>
263
304
  <fo:region-end region-name="right-region" extent="19mm"/>
264
305
  </fo:simple-page-master>
265
306
  <!-- even pages -->
266
307
  <fo:simple-page-master master-name="even" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
267
- <fo:region-body margin-top="27.4mm" margin-bottom="13mm" margin-left="19mm" margin-right="19mm"/>
308
+ <fo:region-body margin-top="27.4mm" margin-bottom="{$marginBottom + 2}mm" margin-left="19mm" margin-right="19mm"/>
268
309
  <fo:region-before region-name="header-even" extent="27.4mm"/> <!-- display-align="center" -->
269
- <fo:region-after region-name="footer-even" extent="13mm"/>
310
+ <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
270
311
  <fo:region-start region-name="left-region" extent="19mm"/>
271
312
  <fo:region-end region-name="right-region" extent="19mm"/>
272
313
  </fo:simple-page-master>
@@ -286,7 +327,7 @@
286
327
 
287
328
  <!-- first page -->
288
329
  <fo:simple-page-master master-name="first-publishedISO" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
289
- <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
330
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
290
331
  <fo:region-before region-name="header-first" extent="{$marginTop}mm"/> <!-- display-align="center" -->
291
332
  <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
292
333
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
@@ -294,7 +335,7 @@
294
335
  </fo:simple-page-master>
295
336
  <!-- odd pages -->
296
337
  <fo:simple-page-master master-name="odd-publishedISO" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
297
- <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
338
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
298
339
  <fo:region-before region-name="header-odd" extent="{$marginTop}mm"/> <!-- display-align="center" -->
299
340
  <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
300
341
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
@@ -302,14 +343,14 @@
302
343
  </fo:simple-page-master>
303
344
  <!-- even pages -->
304
345
  <fo:simple-page-master master-name="even-publishedISO" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
305
- <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
346
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
306
347
  <fo:region-before region-name="header-even" extent="{$marginTop}mm"/>
307
348
  <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
308
349
  <fo:region-start region-name="left-region" extent="{$marginLeftRight2}mm"/>
309
350
  <fo:region-end region-name="right-region" extent="{$marginLeftRight1}mm"/>
310
351
  </fo:simple-page-master>
311
352
  <fo:simple-page-master master-name="blankpage" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
312
- <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
353
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
313
354
  <fo:region-before region-name="header" extent="{$marginTop}mm"/>
314
355
  <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
315
356
  <fo:region-start region-name="left" extent="{$marginLeftRight2}mm"/>
@@ -503,16 +544,14 @@
503
544
  <fo:block> </fo:block>
504
545
  </fo:table-cell>
505
546
  <fo:table-cell>
506
- <fo:block margin-bottom="3mm">ISO/TC <fo:inline font-weight="bold"><xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:technical-committee/@number"/></fo:inline>
547
+ <fo:block margin-bottom="3mm">
548
+ <xsl:copy-of select="$editorialgroup"/>
507
549
  </fo:block>
508
550
  </fo:table-cell>
509
551
  <fo:table-cell>
510
552
  <fo:block>
511
- <xsl:call-template name="getLocalizedString">
512
- <xsl:with-param name="key">secretariat</xsl:with-param>
513
- </xsl:call-template>
514
- <xsl:text>: </xsl:text>
515
- Secretariat: <fo:inline font-weight="bold"><xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:secretariat"/></fo:inline></fo:block>
553
+ <xsl:copy-of select="$secretariat"/>
554
+ </fo:block>
516
555
  </fo:table-cell>
517
556
  </fo:table-row>
518
557
  <fo:table-row>
@@ -598,11 +637,7 @@
598
637
  </fo:block>
599
638
 
600
639
  <fo:block margin-top="10mm">
601
- <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:ics/iso:code">
602
- <xsl:if test="position() = 1"><fo:inline>ICS: </fo:inline></xsl:if>
603
- <xsl:value-of select="."/>
604
- <xsl:if test="position() != last()"><xsl:text>; </xsl:text></xsl:if>
605
- </xsl:for-each>
640
+ <xsl:copy-of select="$ics"/>
606
641
  </fo:block>
607
642
 
608
643
  </fo:block-container>
@@ -611,7 +646,7 @@
611
646
  </fo:block-container>
612
647
  </fo:flow>
613
648
 
614
- </xsl:when>
649
+ </xsl:when> <!-- END: $stage-abbreviation = 'DIS' -->
615
650
  <xsl:otherwise>
616
651
 
617
652
  <!-- COVER PAGE for all documents except DIS -->
@@ -671,13 +706,17 @@
671
706
  </fo:block>
672
707
  </fo:table-cell>
673
708
  </fo:table-row>
674
- <fo:table-row height="42mm">
709
+ <fo:table-row height="25mm">
675
710
  <fo:table-cell number-columns-spanned="3" font-size="10pt" line-height="1.2">
676
711
  <fo:block text-align="right">
677
712
  <xsl:if test="$stage-abbreviation = 'PRF' or $stage-abbreviation = 'IS' or $stage-abbreviation = 'D' or $stage-abbreviation = 'published'">
678
713
  <xsl:call-template name="printEdition"/>
679
714
  </xsl:if>
680
715
  <xsl:choose>
716
+ <xsl:when test="($stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD') and /iso:iso-standard/iso:bibdata/iso:version/iso:revision-date">
717
+ <xsl:value-of select="$linebreak"/>
718
+ <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:version/iso:revision-date"/>
719
+ </xsl:when>
681
720
  <xsl:when test="$stage-abbreviation = 'IS' and /iso:iso-standard/iso:bibdata/iso:date[@type = 'published']">
682
721
  <xsl:value-of select="$linebreak"/>
683
722
  <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:date[@type = 'published']"/>
@@ -706,13 +745,40 @@
706
745
  </fo:block>
707
746
  <fo:block>
708
747
  <xsl:if test="/iso:iso-standard/iso:bibdata/iso:date[@type = 'updated']">
709
- <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:date[@type = 'updated']"/>
748
+ <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:date[@type = 'updated']"/>
710
749
  </xsl:if>
711
750
  </fo:block>
712
751
  </fo:block>
713
752
  </xsl:if>
714
753
  </fo:table-cell>
715
754
  </fo:table-row>
755
+ <fo:table-row height="17mm">
756
+ <fo:table-cell><fo:block/></fo:table-cell>
757
+ <fo:table-cell number-columns-spanned="2" font-size="10pt" line-height="1.2" display-align="center">
758
+ <fo:block>
759
+ <xsl:if test="$stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD'">
760
+ <fo:table table-layout="fixed" width="100%">
761
+ <fo:table-column column-width="50%"/>
762
+ <fo:table-column column-width="50%"/>
763
+ <fo:table-body>
764
+ <fo:table-row>
765
+ <fo:table-cell>
766
+ <fo:block>
767
+ <xsl:copy-of select="$editorialgroup"/>
768
+ </fo:block>
769
+ </fo:table-cell>
770
+ <fo:table-cell>
771
+ <fo:block>
772
+ <xsl:copy-of select="$secretariat"/>
773
+ </fo:block>
774
+ </fo:table-cell>
775
+ </fo:table-row>
776
+ </fo:table-body>
777
+ </fo:table>
778
+ </xsl:if>
779
+ </fo:block>
780
+ </fo:table-cell>
781
+ </fo:table-row>
716
782
 
717
783
  </fo:table-body>
718
784
  </fo:table>
@@ -729,8 +795,8 @@
729
795
  <xsl:if test="$stage-abbreviation = 'FDIS'">
730
796
  <fo:block-container border="0.5mm solid black" width="51mm">
731
797
  <fo:block margin="2mm">
732
- <fo:block margin-bottom="8pt">ISO/TC <fo:inline font-weight="bold"><xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:technical-committee/@number"/></fo:inline></fo:block>
733
- <fo:block margin-bottom="6pt">Secretariat: <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:secretariat"/></fo:block>
798
+ <fo:block margin-bottom="8pt"><xsl:copy-of select="$editorialgroup"/></fo:block>
799
+ <fo:block margin-bottom="6pt"><xsl:value-of select="$secretariat"/></fo:block>
734
800
  <fo:block margin-bottom="6pt">Voting begins on:<xsl:value-of select="$linebreak"/>
735
801
  <fo:inline font-weight="bold">
736
802
  <xsl:choose>
@@ -802,6 +868,12 @@
802
868
  </fo:block>
803
869
  </xsl:for-each>
804
870
 
871
+ <xsl:if test="$stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD'">
872
+ <fo:block margin-top="10mm">
873
+ <xsl:copy-of select="$ics"/>
874
+ </fo:block>
875
+ </xsl:if>
876
+
805
877
  </fo:block>
806
878
  </fo:block-container>
807
879
  </fo:table-cell>
@@ -958,41 +1030,21 @@
958
1030
  </xsl:otherwise>
959
1031
  </xsl:choose>
960
1032
 
961
- <!-- ISO/TC 46/WG 3 -->
962
- <!-- <fo:block margin-bottom="12pt">
963
- <xsl:value-of select="concat('ISO/', /iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:technical-committee/@type, ' ',
964
- /iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:technical-committee/@number, '/',
965
- /iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:workgroup/@type, ' ',
966
- /iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:workgroup/@number)"/>
967
- -->
968
1033
 
969
- <xsl:if test="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:technical-committee[normalize-space(@number) != ''] or /iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:subcommittee[normalize-space(@number) != ''] or /iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:workgroup[normalize-space(@number) != '']">
1034
+ <xsl:if test="normalize-space($editorialgroup) != ''">
970
1035
  <!-- ISO/TC 34/SC 4/WG 3 -->
971
1036
  <fo:block margin-bottom="12pt">
972
- <xsl:text>ISO</xsl:text>
973
- <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:technical-committee[normalize-space(@number) != '']">
974
- <xsl:text>/TC </xsl:text><xsl:value-of select="@number"/>
975
- </xsl:for-each>
976
- <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:subcommittee[normalize-space(@number) != '']">
977
- <xsl:text>/SC </xsl:text>
978
- <xsl:value-of select="@number"/>
979
- </xsl:for-each>
980
- <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:workgroup[normalize-space(@number) != '']">
981
- <xsl:text>/WG </xsl:text>
982
- <xsl:value-of select="@number"/>
983
- </xsl:for-each>
1037
+ <xsl:copy-of select="$editorialgroup"/>
984
1038
  </fo:block>
985
1039
  </xsl:if>
986
- <!-- Secretariat: AFNOR -->
987
1040
 
1041
+ <!-- Secretariat: AFNOR -->
988
1042
  <fo:block margin-bottom="100pt">
989
- <xsl:text>Secretariat: </xsl:text>
990
- <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:secretariat"/>
1043
+ <xsl:value-of select="$secretariat"/>
991
1044
  <xsl:text> </xsl:text>
992
1045
  </fo:block>
993
-
994
-
995
-
1046
+
1047
+
996
1048
  </fo:block-container>
997
1049
  <fo:block-container font-size="16pt">
998
1050
  <!-- Information and documentation — Codes for transcription systems -->
@@ -1065,7 +1117,12 @@
1065
1117
  </xsl:variable>
1066
1118
  <!-- DEBUG: updated_xml_step2=<xsl:copy-of select="$updated_xml_step2"/> -->
1067
1119
 
1068
- <xsl:for-each select="xalan:nodeset($updated_xml_step2)">
1120
+ <xsl:variable name="updated_xml_step3">
1121
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
1122
+ </xsl:variable>
1123
+ <!-- DEBUG: updated_xml_step3=<xsl:copy-of select="$updated_xml_step3"/> -->
1124
+
1125
+ <xsl:for-each select="xalan:nodeset($updated_xml_step3)">
1069
1126
 
1070
1127
  <fo:page-sequence master-reference="preface{$document-master-reference}" format="i" force-page-count="{$force-page-count-preface}">
1071
1128
  <xsl:call-template name="insertHeaderFooter">
@@ -1159,7 +1216,12 @@
1159
1216
 
1160
1217
  <fo:inline keep-together.within-line="always">
1161
1218
  <fo:leader font-size="9pt" font-weight="normal" leader-pattern="dots"/>
1162
- <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
1219
+ <fo:inline>
1220
+ <xsl:if test="@level = 1 and @type = 'annex'">
1221
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
1222
+ </xsl:if>
1223
+ <fo:page-number-citation ref-id="{@id}"/>
1224
+ </fo:inline>
1163
1225
  </fo:inline>
1164
1226
  </fo:basic-link>
1165
1227
  </fo:block>
@@ -1377,6 +1439,7 @@
1377
1439
  </fo:block>
1378
1440
  </xsl:template>
1379
1441
 
1442
+
1380
1443
  <!-- ==================== -->
1381
1444
  <!-- display titles -->
1382
1445
  <!-- ==================== -->
@@ -1707,6 +1770,7 @@
1707
1770
 
1708
1771
  <xsl:template match="iso:p" name="paragraph">
1709
1772
  <xsl:param name="inline" select="'false'"/>
1773
+ <xsl:param name="split_keep-within-line"/>
1710
1774
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
1711
1775
  <xsl:variable name="element-name">
1712
1776
  <xsl:choose>
@@ -1736,7 +1800,9 @@
1736
1800
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
1737
1801
  <xsl:attribute name="line-height">0</xsl:attribute>
1738
1802
  </xsl:if>
1739
- <xsl:apply-templates/>
1803
+ <xsl:apply-templates>
1804
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1805
+ </xsl:apply-templates>
1740
1806
  </xsl:element>
1741
1807
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
1742
1808
  <fo:block margin-bottom="12pt">
@@ -1951,29 +2017,11 @@
1951
2017
  <xsl:text>iVBORw0KGgoAAAANSUhEUgAAAFEAAABHCAIAAADwYjznAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA66SURBVHhezZt5sM/VG8fNVH7JruxkSZKQ3TAYS7aGajKpFBnRxBjjkhrLrRgmYwm59hrGjC0miSmmIgoVZYu00GJtxkyMkV2/1+fzPh7nfr7fe33v/X6/9/d7/3HmOc/nLM/7PM95zjnfS6F//xc4f/786dOnXaXAUdCcjx071rt373vvvbdChQrNmzdfuXKl+1CAKFDOR44cqVWrVqFChf4T4vbbb7/zzjsnT57sPhcUCo7ztWvX2rRpc9tttxUtWvSuEAgwp/z0009dowJBwXGeM2dO4cKFRZWySJEikvF2o0aNrly54tqlHwXE+cyZM9WrV4czJMW5WLFixv+OO+6YPn26a5p+FBDnjIwM/Ak9AHMcm5mZyWY2TeXKlf/66y/XOs0oCM4HDhwoU6aMMSSqs7Kyfv75Z5jjYXmeff7yyy+7DmlGQXB+7LHHcLKFcdu2bXft2vXtt9/Onz9fS8AnVqRkyZLff/+965NOpJ3zhg0bIsQ4k7/55psvv/xy9+7dnTp1MlezLp07d3bd0on0cr569WqTJk18VlxI9uzZs3XrVjhv37597dq199xzD2vBV9aFo2vVqlWuc9qQXs6zZs2CcLCJ77oLPlWqVOEohqo4U8L/hRdesEVBeOihhy5evOj6pwdp5Pz3339Xq1ZN5xOcEV577TXiWWxVfvXVV5R+M2Jh3Lhxboj0II2chw4dqtQF5EBtY+MsgXz2xhtvKKvTknAoX7780aNH3ShpQLo4Hzx4sFSpUmLCRgUzZsyAnlEVbZXo/XOLlSLg3UBpQLo4P/HEE+ZkhPbt23MOhXwdz5C1A+fWokWLuJmxNKwRK1W8eHG2vRsr1UgLZ51PArFaunRpzqevv/7aOAPJBpLZ448/zurQhWXC5xzjbrhUI/WcOZ+aNm2qQIUAwtNPPw0liBnbiADw6scff8xO9s8tnO8GTSlSz3n27NnwlLt0Pn3++edQEkNKE0KyNzWk9EGDBqkvIJPfd999586dc+OmDinmzPlUo0YN/3waNWrUvn37tmzZInohzWzMJYBt27ZxdMHTP7fGjBnjhk4dUsyZ84nXQuinIKrr1q3L+SRuKk0IWIbwZRL4pEmTlMkAYVK2bNnffvvNjZ4ipJLzL7/8wvsJQ7UhAa9iaEDGqOJJsvR3Ifi0Y8cOlPoK+Ep6b9GihdIBwNW9evVyE6QIqeTcs2dP/fQjW9u1a/fjjz+KqljBlgCePHlynz59eGwNHz58zZo1OrTVjJK4WLp0aYkSJexsZ7RNmza5OVKBlHH+7LPPMA4TMRRzeT+9//77uNHIQHjJkiV16tThK24E7FvigrylC6maUZLkWT4aMBRjIuD569evu5mSRmo4X7t2rXnz5hgXuDh08lNPPeUzwXscPDyhjInARqDxc889ZzcWQJLfuHFjxYoV+UpjwOrMmzfPTZY0UsOZ1z9myT4MxVzcrvNJ4ELCfdsWhWZWKobfeecd3cZZIMBuz8jI0Ji0QeA44FBw8yWHFHA+c+aMfz5BjOzt+w0yWVlZYVJzv3VSGqjSpWvXrsQFbGlPSTKjV+3atW1YMgWr4KZMDingPGLECEtdmPjAAw/gYXKVCIOdO3e++uqrClQRUGkCvZo1a0YzGhtt9j/PEv8Szh2WpOhmTQLJcj58+LB+6MAsefLtt9+2VCwCeAzrA4ohjLYEgJ8feeQRQkPt1RHs3bu3Y8eObHi1Z2XJ9m7iJJAsZw5PbJL1CJi4f/9+3boEOOD2Dz74QE/LkGkA0VAJ52eeeYY97PqEvQBZYPXq1bhXHeXw9evXu7nzi6Q4b9682UzBLA5Vzidi0r9pUhLnXLkrV66s64p4CsgAPXdMYjvk6wgDZDY5hznBr16sTsOGDXnGOAvyhaQ4t2rVCiNkOgLvp0h8SiAhQfv++++3sweol0pWjeC3vG3dAX2/+OKLqlWrWl8mYvs4C/KF/HPmvNXyAwziGcihShg7Y2+YTglYC65lWiAf9CVACPvly5cTydbe707Mv/766+Zq5uKtlswfPfLJ+ezZs3oAmR1DhgzRhpStQmB+CEL0ySefhHOwQmEXARnOnOeffPIJsRDpBVTlZla/fn1bYpJZMn/0yCdnXohKXQBTatWqRRAC31ArAXtVdwzxtBKgfPjhh1kvayz4IxACCxYsoDG7gJJlIrGR1Z01eUR+OP/+++9Esm0wLHjrrbf801UwGYHENm3aNFqqC3ZLAHBu3bq17jB+FxMASZGTuXPnzrbQCI8++qgzKI/ID+fnn3/e5iZcmzZtCiWZCGSlLwAcxQPDLhiAvhIYoXv37rYvcgIjcCj45xb46KOPnE15QZ45k6VkuiZGfvfdd0m5sjikeRMyF9Br3bp1ZcuWlatFWCV+HjZsmGI7FzAau7pfv35KCvRFYFNcvnzZWZYw8syZ9Os7uUePHrYVzTgJIOAdgq1O6ac9gBB6K/hpwQ5nYB0lhCMFAkmOc6t69eraVjJgypQpzrKEkTfOy5YtYz6sZD6Eu+++m1sRUWdmWWmgKg1L07JlS+OskqGIlPfee08HlaBe1lcIxgrPvMzMTOPMaJUqVTp16pSzLzHkgfOFCxd48bO0TAYQXnrpJeUewSzzrTSZ44rHE70wVxYDQj32oIoVDMQLl3muYmYGQTdw4EBnYmLIA+fx48crqrGYleZ82rFjh84nM06CEBp58xO29u/f3zgLOKpmzZoQ9ltK8OF/JV/OmTMHMxRurFrJkiVZUGdlAkiU8/HjxytUqKCgkq0sgX+o+rZKtlICO3bixIk2QuCjMDibNGnCclhLAxoprZQACC6FjAbBEzzLnKEJIFHOJEw/dWEoHMzJMgVINk1gZghkcjsZnu4irJKhunXrFvkZ0OArKSUA4os8whtWK4jD8Xbi/6QwIc7QK168uGJJWWf+/Pl2JptBglVD8wKoiqG8KO1fFQS+9g4q1/QGQyEiC6oSzC+++KK5mnHq1q37zz//OItzRUKcO3XqZDuZabgA6e9PBtnhKmHVBANBwXWqRo0aFt4AmYCP/MYQC9OboJxn5xbAMLabszhX3JozMWMXCQTOp7Vr10bOJwHZqhFZAvFSr149fCIrBV6RuV/jVMZqWKkJEybINgB5Ms4ff/zh7M4Zt+B86dIl+72ScTF3wIABpBCbW/DlWJiVxDBXGuOsFVyzZo3/AgW0FCJVII1AFdrNmjVjQJlHMPbu3duZnjNuwXnSpEkQZjgGZSGJTCZT6hI0d2jDrQVMxCYsCykHnqlWrRpRyoDWRkIEpo+UBAjPeOUaBmQRyTV8ctbngNw4nzhxwv9hHYG3uzlZs0oAZocJodppALJ+DMQtSoeQ52YWyf9+KcEgjaAqpb3MGVBjtmrVyhHIAblx5gphP+IyKLefyNU6Al9vshkngTBu3749lgECe+HChXF/EjJNRJDsa3Ru8Xox37CmixcvdhziIUfOrB/3G6IFwnILtx98opk0a6T0gcZXWpVIJnuPGjWKeyu3dz3IIlBjwa/qK5AsJSD0hgwZwiJiJJxxT+5/rM+Rsz3QNUqXLl04n/wpBclWCrEaA0o24aFDh3766ae9e/c6bagXXD1mQMHVb2gkUOIM3gJKZgDLWVbHJAbxOa9evRoPW2LQ+WTZ1Z9SiCglgPCj+ypg3Ny5c5999lkO+YyMDD4RnOjD5tFBrCpQNb0EyZRsumnTpmGwQpI45/Lz66+/Oj7ZEYfzlStX6tevr6wgJ/fp08ffyeFcbmJBGsGv6itQFQ9zeWJM/MCwgInsX0MCtYwtJZjGYJ8osZCMyJihpwNX9+zZ01HKjjicp06dSk8sA0RL1apVeannkloBsuDq3lfpAVs3KyuLMXGCVpOSHMlrQQ9S2vjtQThANr00IKKk5Jq0YsUK5SAGV5DG/Z8eUc6cT/YHB7rpfIp9A8StSogLPpEUeU7Yaga+CC929sO4mgnqJaga0asKJFOSGg8ePMiu8V3NjSX2jx5RzqRTnU+YhZN5P9lZIgQTxptSpY/wewDJOLNt27YyyGjDuXTp0qtWrdLvJNYr0j2it9KgKgvH8tlvsozPdLNmzXLcbiAbZzKz/SVNyYDzk00Yd4KIIJhSpQSBYNFLSNYILGvNmjVppp8NBLWXYFXgf/L1gpTs6pEjRzKsZtHejPyfvWycIz8ga6fZcII/gSANcPUQqloJYMXu4vZKHLGsrCkG4ZDMzEwtqyEcwMGq+uTDV5rMLITMgw8+yOBGZOjQoY5hiJucedzKFNoh6PbPQWIjBjOHMI2vFEwjIVJiDWHcuHFjMg2X5CpVqrzyyitGOOiWvYvBlKaPq5FMQM2cORM/iwvLyvbZv3+/42mcOZ8aNGggJ9OaCBw4cGBO6VTwlbeUEQBpBtqQ5H26ZMkSqhzXauDDevmQMhwm2/gG01CySfXH+sDRoau7d+8upsBx5v3EB9gCFoa3OAbFXkIEvyqZ0hBRxrbh2CN8IE8covc/GUyZiwAislX1mwzuVTLD4eDDDz8U2YDzyZMnK1WqpA1AC4SxY8fiZGhrFL/0BYCsqimlMfjKWBlEZFX9UjA5aJH9qzQRYH/fvn3hAiN4Ebncfy5duuQ4Dx48mLyibzRq0aLFDz/8QAIE7I28Ik+9btk4fzYAOO/bt6927dpyNYA299OAM3ncfySTvXiOjh49msvw8OHDrYxUTekj0tLgV5FVNcFgelV9+J/iNrOqfR02bNibb77JrhY1uZN3yPnz5wsdOHDA/uYmQJvPNAUSIlXBlw1xlSBux5wa+6CN38yqEoD0Bl+JAC/YQUruROYxV+jPP//UHzhDN7vbguQIctJHELdZrDIRDUhwUpBTS/T6BP8SJUrwjA32M9cj/d/zILuFV3MTBKua0qomhOoAvtJgn0yQbBogpcFpQ5jG9BEhUvpVARmO7dq141QOOF++fJk0Vq5cOb5pVf5PoLBMHvDiFtShQwf9EuzOZ3D06NFNmzbpfKI0KPUDyVZK8GUrfZjeBCsFk4MWubYJPnswvSFSFVBu3ryZJ5fj+e+//wVuVmgt0lkFPgAAAABJRU5ErkJggg==</xsl:text>
1952
2018
  </xsl:variable>
1953
2019
 
1954
- <xsl:template name="printEdition">
1955
- <xsl:variable name="edition" select="normalize-space(/iso:iso-standard/iso:bibdata/iso:edition)"/>
1956
- <xsl:text> </xsl:text>
1957
- <xsl:choose>
1958
- <xsl:when test="number($edition) = $edition">
1959
- <xsl:call-template name="number-to-words">
1960
- <xsl:with-param name="number" select="$edition"/>
1961
- </xsl:call-template>
1962
- </xsl:when>
1963
- <xsl:when test="$edition != ''">
1964
- <xsl:value-of select="$edition"/>
1965
- </xsl:when>
1966
- </xsl:choose>
1967
- <xsl:variable name="title-edition">
1968
- <xsl:call-template name="getLocalizedString">
1969
- <xsl:with-param name="key">edition</xsl:with-param>
1970
- </xsl:call-template>
1971
- </xsl:variable>
1972
- <xsl:if test="$edition != ''"><xsl:text> </xsl:text><xsl:value-of select="java:toLowerCase(java:java.lang.String.new($title-edition))"/></xsl:if>
1973
- </xsl:template>
1974
-
1975
-
1976
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="lang">
2020
+ <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:param name="table_if_debug">false</xsl:param><xsl:variable name="isGenerateTableIF_">
2021
+
2022
+ <xsl:value-of select="normalize-space($table_if) = 'true'"/>
2023
+
2024
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
1977
2025
  <xsl:call-template name="getLang"/>
1978
2026
  </xsl:variable><xsl:variable name="pageWidth_">
1979
2027
  210
@@ -1988,20 +2036,7 @@
1988
2036
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1989
2037
  13
1990
2038
  </xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
1991
-
1992
- <title-edition lang="en">
1993
-
1994
- <xsl:text>Edition </xsl:text>
1995
-
1996
- </title-edition>
1997
-
1998
- <title-edition lang="fr">
1999
- <xsl:text>Édition </xsl:text>
2000
- </title-edition>
2001
2039
 
2002
- <title-edition lang="ru">
2003
- <xsl:text>Издание </xsl:text>
2004
- </title-edition>
2005
2040
 
2006
2041
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
2007
2042
  <title-toc lang="en">
@@ -2086,7 +2121,7 @@
2086
2121
  </xsl:variable><xsl:variable name="bibdata">
2087
2122
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
2088
2123
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
2089
- </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">
2124
+ </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">
2090
2125
  <xsl:param name="name"/>
2091
2126
  <xsl:param name="lang"/>
2092
2127
  <xsl:variable name="lang_">
@@ -2134,7 +2169,7 @@
2134
2169
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
2135
2170
 
2136
2171
  <xsl:variable name="additional_fonts_">
2137
- <xsl:for-each select="//*[local-name() = 'misc-container'][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
2172
+ <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']">
2138
2173
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
2139
2174
  </xsl:for-each>
2140
2175
  </xsl:variable>
@@ -2214,7 +2249,6 @@
2214
2249
 
2215
2250
 
2216
2251
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
2217
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2218
2252
 
2219
2253
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
2220
2254
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -2301,6 +2335,10 @@
2301
2335
 
2302
2336
 
2303
2337
 
2338
+
2339
+ <xsl:attribute name="margin-left">7mm</xsl:attribute>
2340
+ <xsl:attribute name="margin-right">7mm</xsl:attribute>
2341
+
2304
2342
 
2305
2343
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2306
2344
 
@@ -2309,6 +2347,7 @@
2309
2347
 
2310
2348
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2311
2349
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
2350
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2312
2351
 
2313
2352
 
2314
2353
 
@@ -2466,6 +2505,7 @@
2466
2505
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2467
2506
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2468
2507
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2508
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2469
2509
  <xsl:attribute name="display-align">center</xsl:attribute>
2470
2510
 
2471
2511
 
@@ -2486,6 +2526,7 @@
2486
2526
  <xsl:attribute name="display-align">center</xsl:attribute>
2487
2527
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2488
2528
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2529
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2489
2530
 
2490
2531
 
2491
2532
 
@@ -2580,7 +2621,8 @@
2580
2621
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
2581
2622
 
2582
2623
 
2583
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2624
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2625
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2584
2626
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2585
2627
 
2586
2628
 
@@ -2594,6 +2636,8 @@
2594
2636
 
2595
2637
 
2596
2638
 
2639
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2640
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2597
2641
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2598
2642
 
2599
2643
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -3404,22 +3448,24 @@
3404
3448
  <xsl:sort select="@displayorder" data-type="number"/>
3405
3449
  <xsl:apply-templates select="."/>
3406
3450
  </xsl:for-each>
3407
- </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">
3408
- <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
3409
- <xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_open,'$1',$tag_close))"/>
3410
- <xsl:call-template name="replace_fo_inline">
3411
- <xsl:with-param name="text" select="$text"/>
3412
- </xsl:call-template>
3413
- </xsl:template><xsl:template name="replace_fo_inline">
3451
+ </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">
3452
+ <xsl:value-of select="."/>
3453
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3454
+ <xsl:param name="tag_open"/>
3455
+ <xsl:param name="tag_close"/>
3414
3456
  <xsl:param name="text"/>
3415
3457
  <xsl:choose>
3416
3458
  <xsl:when test="contains($text, $tag_open)">
3417
3459
  <xsl:value-of select="substring-before($text, $tag_open)"/>
3418
- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text>
3460
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3419
3461
  <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
3420
- <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3421
- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text>
3422
- <xsl:call-template name="replace_fo_inline">
3462
+ <fo:inline keep-together.within-line="always">
3463
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3464
+ </fo:inline>
3465
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3466
+ <xsl:call-template name="replace_fo_inline_tags">
3467
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3468
+ <xsl:with-param name="tag_close" select="$tag_close"/>
3423
3469
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3424
3470
  </xsl:call-template>
3425
3471
  </xsl:when>
@@ -3427,6 +3473,39 @@
3427
3473
  </xsl:choose>
3428
3474
  </xsl:template><xsl:template match="*[local-name()='br']">
3429
3475
  <xsl:value-of select="$linebreak"/>
3476
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3477
+ <xsl:param name="split_keep-within-line"/>
3478
+
3479
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3480
+ <xsl:choose>
3481
+
3482
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3483
+ <xsl:variable name="sep">_</xsl:variable>
3484
+ <xsl:variable name="items">
3485
+ <xsl:call-template name="split">
3486
+ <xsl:with-param name="pText" select="."/>
3487
+ <xsl:with-param name="sep" select="$sep"/>
3488
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3489
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3490
+ </xsl:call-template>
3491
+ </xsl:variable>
3492
+ <xsl:for-each select="xalan:nodeset($items)/item">
3493
+ <xsl:choose>
3494
+ <xsl:when test=". = $sep">
3495
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3496
+ </xsl:when>
3497
+ <xsl:otherwise>
3498
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3499
+ </xsl:otherwise>
3500
+ </xsl:choose>
3501
+ </xsl:for-each>
3502
+ </xsl:when>
3503
+
3504
+ <xsl:otherwise>
3505
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3506
+ </xsl:otherwise>
3507
+
3508
+ </xsl:choose>
3430
3509
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3431
3510
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3432
3511
  <xsl:apply-templates/>
@@ -3507,8 +3586,23 @@
3507
3586
  </xsl:call-template>
3508
3587
 
3509
3588
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3510
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3511
- <xsl:call-template name="add-zero-spaces-java"/>
3589
+ <xsl:choose>
3590
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3591
+ <xsl:value-of select="."/>
3592
+ </xsl:when>
3593
+ <xsl:otherwise>
3594
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3595
+ </xsl:otherwise>
3596
+ </xsl:choose>
3597
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3598
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3599
+ <!-- <xsl:copy-of select="$text"/> -->
3600
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3601
+ <xsl:choose>
3602
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3603
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3604
+ </xsl:choose>
3605
+ </xsl:for-each>
3512
3606
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3513
3607
 
3514
3608
  <xsl:variable name="table-preamble">
@@ -3518,9 +3612,14 @@
3518
3612
 
3519
3613
  <xsl:variable name="table">
3520
3614
 
3521
- <xsl:variable name="simple-table">
3522
- <xsl:call-template name="getSimpleTable"/>
3615
+ <xsl:variable name="simple-table">
3616
+ <xsl:call-template name="getSimpleTable">
3617
+ <xsl:with-param name="id" select="@id"/>
3618
+ </xsl:call-template>
3523
3619
  </xsl:variable>
3620
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3621
+
3622
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3524
3623
 
3525
3624
 
3526
3625
  <!-- Display table's name before table as standalone block -->
@@ -3539,7 +3638,23 @@
3539
3638
  </xsl:call-template>
3540
3639
  </xsl:if>
3541
3640
  </xsl:variable>
3542
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3641
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3642
+
3643
+ <!-- DEBUG -->
3644
+ <xsl:if test="$table_if_debug = 'true'">
3645
+ <fo:block font-size="60%">
3646
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3647
+ </fo:block>
3648
+ </xsl:if>
3649
+
3650
+
3651
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3652
+
3653
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3654
+ DEBUG
3655
+ colwidths=<xsl:copy-of select="$colwidths"/>
3656
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3657
+
3543
3658
 
3544
3659
 
3545
3660
  <xsl:variable name="margin-side">
@@ -3608,9 +3723,17 @@
3608
3723
  </xsl:element>
3609
3724
  </xsl:variable>
3610
3725
 
3726
+ <xsl:if test="$isGenerateTableIF = 'true'">
3727
+ <!-- to determine start of table -->
3728
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3729
+ </xsl:if>
3611
3730
 
3612
3731
  <fo:table id="{@id}">
3613
3732
 
3733
+ <xsl:if test="$isGenerateTableIF = 'true'">
3734
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3735
+ </xsl:if>
3736
+
3614
3737
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3615
3738
  <xsl:attribute name="{local-name()}">
3616
3739
  <xsl:value-of select="."/>
@@ -3624,31 +3747,47 @@
3624
3747
 
3625
3748
 
3626
3749
  <xsl:choose>
3627
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3628
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3629
- <fo:table-column column-width="{@width}"/>
3630
- </xsl:for-each>
3750
+ <xsl:when test="$isGenerateTableIF = 'true'">
3751
+ <!-- generate IF for table widths -->
3752
+ <!-- example:
3753
+ <tr>
3754
+ <td valign="top" align="left" id="tab-symdu_1_1">
3755
+ <p>Symbol</p>
3756
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3757
+ </td>
3758
+ <td valign="top" align="left" id="tab-symdu_1_2">
3759
+ <p>Description</p>
3760
+ <word id="tab-symdu_1_2_word_1">Description</word>
3761
+ </td>
3762
+ </tr>
3763
+ -->
3764
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3765
+
3631
3766
  </xsl:when>
3632
3767
  <xsl:otherwise>
3633
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3634
- <xsl:choose>
3635
- <xsl:when test=". = 1 or . = 0">
3636
- <fo:table-column column-width="proportional-column-width(2)"/>
3637
- </xsl:when>
3638
- <xsl:otherwise>
3639
- <fo:table-column column-width="proportional-column-width({.})"/>
3640
- </xsl:otherwise>
3641
- </xsl:choose>
3642
- </xsl:for-each>
3643
- </xsl:otherwise>
3644
- </xsl:choose>
3645
3768
 
3646
- <xsl:choose>
3647
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3648
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3649
- </xsl:when>
3650
- <xsl:otherwise>
3651
- <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 -->
3769
+ <xsl:choose>
3770
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3771
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3772
+ <fo:table-column column-width="{@width}"/>
3773
+ </xsl:for-each>
3774
+ </xsl:when>
3775
+ <xsl:otherwise>
3776
+ <xsl:call-template name="insertTableColumnWidth">
3777
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3778
+ </xsl:call-template>
3779
+ </xsl:otherwise>
3780
+ </xsl:choose>
3781
+
3782
+ <xsl:choose>
3783
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3784
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3785
+ </xsl:when>
3786
+ <xsl:otherwise>
3787
+ <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 -->
3788
+ </xsl:otherwise>
3789
+ </xsl:choose>
3790
+
3652
3791
  </xsl:otherwise>
3653
3792
  </xsl:choose>
3654
3793
 
@@ -3753,11 +3892,23 @@
3753
3892
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3754
3893
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3755
3894
  </xsl:template><xsl:template name="calculate-column-widths">
3895
+ <xsl:param name="table"/>
3896
+ <xsl:param name="cols-count"/>
3897
+
3898
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
3899
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3900
+ <xsl:with-param name="table" select="$table"/>
3901
+ <xsl:with-param name="if">true</xsl:with-param>
3902
+ </xsl:call-template>
3903
+
3904
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3756
3905
  <xsl:param name="table"/>
3757
3906
  <xsl:param name="cols-count"/>
3758
3907
  <xsl:param name="curr-col" select="1"/>
3759
3908
  <xsl:param name="width" select="0"/>
3760
3909
 
3910
+ <!-- table=<xsl:copy-of select="$table"/> -->
3911
+
3761
3912
  <xsl:if test="$curr-col &lt;= $cols-count">
3762
3913
  <xsl:variable name="widths">
3763
3914
  <xsl:choose>
@@ -3795,16 +3946,22 @@
3795
3946
  </xsl:for-each>
3796
3947
  </xsl:when>
3797
3948
  <xsl:otherwise>
3798
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
3949
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
3950
+
3951
+ <!-- <table><xsl:copy-of select="$table"/></table>
3952
+ -->
3953
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3799
3954
  <xsl:variable name="td_text">
3800
3955
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3801
3956
  </xsl:variable>
3957
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3802
3958
  <xsl:variable name="words">
3803
3959
  <xsl:variable name="string_with_added_zerospaces">
3804
3960
  <xsl:call-template name="add-zero-spaces-java">
3805
3961
  <xsl:with-param name="text" select="$td_text"/>
3806
3962
  </xsl:call-template>
3807
3963
  </xsl:variable>
3964
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3808
3965
  <xsl:call-template name="tokenize">
3809
3966
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3810
3967
  <!-- 2009 thinspace -->
@@ -3812,11 +3969,13 @@
3812
3969
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3813
3970
  </xsl:call-template>
3814
3971
  </xsl:variable>
3972
+ <!-- words=<xsl:copy-of select="$words"/> -->
3815
3973
  <xsl:variable name="max_length">
3816
3974
  <xsl:call-template name="max_length">
3817
3975
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3818
3976
  </xsl:call-template>
3819
3977
  </xsl:variable>
3978
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3820
3979
  <width>
3821
3980
  <xsl:variable name="divider">
3822
3981
  <xsl:choose>
@@ -3835,6 +3994,8 @@
3835
3994
  </xsl:choose>
3836
3995
  </xsl:variable>
3837
3996
 
3997
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
3998
+
3838
3999
  <column>
3839
4000
  <xsl:for-each select="xalan:nodeset($widths)//width">
3840
4001
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3843,107 +4004,405 @@
3843
4004
  </xsl:if>
3844
4005
  </xsl:for-each>
3845
4006
  </column>
3846
- <xsl:call-template name="calculate-column-widths">
4007
+ <xsl:call-template name="calculate-column-widths-proportional">
3847
4008
  <xsl:with-param name="cols-count" select="$cols-count"/>
3848
4009
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3849
4010
  <xsl:with-param name="table" select="$table"/>
3850
4011
  </xsl:call-template>
3851
4012
  </xsl:if>
4013
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
4014
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
4015
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
4016
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
4017
+
4018
+ <!-- if all capitals english letters or digits -->
4019
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
4020
+ <xsl:call-template name="repeat">
4021
+ <xsl:with-param name="char" select="'X'"/>
4022
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
4023
+ </xsl:call-template>
4024
+ </xsl:if>
3852
4025
  </xsl:template><xsl:template match="text()" mode="td_text">
3853
4026
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3854
4027
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3855
4028
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3856
4029
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3857
4030
  <xsl:value-of select="@target"/>
3858
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3859
- <xsl:variable name="mathml">
3860
- <xsl:for-each select="*">
3861
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3862
- <xsl:copy-of select="."/>
3863
- </xsl:if>
3864
- </xsl:for-each>
3865
- </xsl:variable>
3866
-
3867
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3868
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3869
- </xsl:template><xsl:template match="*[local-name()='thead']">
3870
- <xsl:param name="cols-count"/>
3871
- <fo:table-header>
3872
-
3873
- <xsl:call-template name="table-header-title">
3874
- <xsl:with-param name="cols-count" select="$cols-count"/>
3875
- </xsl:call-template>
3876
-
3877
-
3878
- <xsl:apply-templates/>
3879
- </fo:table-header>
3880
- </xsl:template><xsl:template name="table-header-title">
3881
- <xsl:param name="cols-count"/>
3882
- <!-- row for title -->
3883
- <fo:table-row>
3884
- <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
3885
-
3886
- <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
3887
- <xsl:with-param name="continued">true</xsl:with-param>
3888
- </xsl:apply-templates>
3889
-
3890
-
3891
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
3892
- <xsl:call-template name="table_name_fn_display"/>
3893
- </xsl:for-each>
4031
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
4032
+ <xsl:if test="$isGenerateTableIF = 'false'">
4033
+ <xsl:variable name="mathml_">
4034
+ <xsl:for-each select="*">
4035
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
4036
+ <xsl:copy-of select="."/>
4037
+ </xsl:if>
4038
+ </xsl:for-each>
4039
+ </xsl:variable>
4040
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
3894
4041
 
3895
- <fo:block text-align="right" font-style="italic">
3896
- <xsl:text> </xsl:text>
3897
- <fo:retrieve-table-marker retrieve-class-name="table_continued"/>
3898
- </fo:block>
3899
-
4042
+ <xsl:variable name="math_text">
4043
+ <xsl:value-of select="normalize-space($mathml)"/>
4044
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
4045
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
4046
+ </xsl:variable>
4047
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4048
+ </xsl:if>
4049
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
4050
+ <xsl:param name="table"/>
4051
+ <xsl:param name="if">false</xsl:param> <!-- via intermediate format -->
4052
+
4053
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
4054
+
4055
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
4056
+
4057
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
4058
+
4059
+ <!-- get current table id -->
4060
+ <xsl:variable name="table_id" select="@id"/>
4061
+ <!-- find table by id in the file 'table_widths' -->
4062
+ <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
4063
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/>
4064
+
4065
+
4066
+ <!-- table='<xsl:copy-of select="$table"/>' -->
4067
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
4068
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
4069
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
4070
+
4071
+ <xsl:variable name="table_with_cell_widths_">
4072
+ <xsl:choose>
4073
+ <xsl:when test="$if = 'true' and normalize-space($table-if) != ''"> <!-- if we read column's width from IF and there is table in IF -->
3900
4074
 
3901
- </fo:table-cell>
3902
- </fo:table-row>
3903
- </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
3904
- <fo:table-body>
3905
- <xsl:apply-templates/>
3906
- </fo:table-body>
3907
- </xsl:template><xsl:template match="*[local-name()='tfoot']">
3908
- <xsl:apply-templates/>
3909
- </xsl:template><xsl:template name="insertTableFooter">
3910
- <xsl:param name="cols-count"/>
3911
- <xsl:if test="../*[local-name()='tfoot']">
3912
- <fo:table-footer>
3913
- <xsl:apply-templates select="../*[local-name()='tfoot']"/>
3914
- </fo:table-footer>
4075
+ <!-- Example: <column>10</column>
4076
+ <column>11</column>
4077
+ -->
4078
+ <xsl:apply-templates select="$table-if" mode="determine_cell_widths-if"/>
4079
+ </xsl:when>
4080
+ <xsl:otherwise>
4081
+ <xsl:apply-templates select="xalan:nodeset($table)" mode="determine_cell_widths"/>
4082
+ </xsl:otherwise>
4083
+ </xsl:choose>
4084
+ </xsl:variable>
4085
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
4086
+
4087
+ <xsl:if test="$table_if_debug = 'true'">
4088
+ <xsl:copy-of select="$table_with_cell_widths"/>
3915
4089
  </xsl:if>
3916
- </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
3917
- <xsl:param name="table_attributes"/>
3918
- <xsl:param name="colwidths"/>
3919
- <xsl:param name="colgroup"/>
3920
4090
 
3921
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3922
4091
 
3923
- <xsl:variable name="isNoteOrFnExistShowAfterTable">
3924
-
4092
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
4093
+
4094
+ <xsl:variable name="column_widths_">
4095
+ <!-- iteration of columns -->
4096
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
4097
+ <xsl:variable name="pos" select="position()"/>
4098
+ <column>
4099
+ <xsl:attribute name="width_max">
4100
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
4101
+ <xsl:sort select="." data-type="number" order="descending"/>
4102
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4103
+ </xsl:for-each>
4104
+ </xsl:attribute>
4105
+ <xsl:attribute name="width_min">
4106
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
4107
+ <xsl:sort select="." data-type="number" order="descending"/>
4108
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4109
+ </xsl:for-each>
4110
+ </xsl:attribute>
4111
+ </column>
4112
+ </xsl:for-each>
3925
4113
  </xsl:variable>
4114
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
3926
4115
 
3927
- <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
4116
+ <!-- <column_widths>
4117
+ <xsl:copy-of select="$column_widths"/>
4118
+ </column_widths> -->
3928
4119
 
3929
- <xsl:variable name="cols-count">
3930
- <xsl:choose>
3931
- <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
3932
- <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
3933
- </xsl:when>
3934
- <xsl:otherwise>
3935
- <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/>
3936
- </xsl:otherwise>
3937
- </xsl:choose>
3938
- </xsl:variable>
3939
-
3940
- <fo:table keep-with-previous="always">
3941
- <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3942
- <xsl:variable name="name" select="local-name()"/>
3943
- <xsl:choose>
3944
- <xsl:when test="$name = 'border-top'">
3945
- <xsl:attribute name="{$name}">0pt solid black</xsl:attribute>
3946
- </xsl:when>
4120
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
4121
+ <xsl:variable name="table_widths_">
4122
+ <table>
4123
+ <xsl:attribute name="width_max">
4124
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
4125
+ </xsl:attribute>
4126
+ <xsl:attribute name="width_min">
4127
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
4128
+ </xsl:attribute>
4129
+ </table>
4130
+ </xsl:variable>
4131
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
4132
+
4133
+ <xsl:variable name="page_width">
4134
+ <xsl:choose>
4135
+ <xsl:when test="$if = 'true'"><xsl:value-of select="$table-if/@page-width"/></xsl:when>
4136
+ <xsl:otherwise>75</xsl:otherwise>
4137
+ </xsl:choose>
4138
+ </xsl:variable>
4139
+
4140
+ <xsl:if test="$table_if_debug = 'true'">
4141
+ <table_width>
4142
+ <xsl:copy-of select="$table_widths"/>
4143
+ </table_width>
4144
+ <!-- <debug>$table_widths/@width_min=<xsl:value-of select="$table_widths/table/@width_min"/></debug>
4145
+ <debug>$table_widths/@width_max=<xsl:value-of select="$table_widths/table/@width_max"/></debug>
4146
+ -->
4147
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
4148
+ </xsl:if>
4149
+
4150
+
4151
+ <!-- There are three cases: -->
4152
+ <xsl:choose>
4153
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
4154
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
4155
+ <!-- call old algorithm -->
4156
+ <case1/>
4157
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
4158
+ <xsl:call-template name="calculate-column-widths-proportional">
4159
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4160
+ <xsl:with-param name="table" select="$table"/>
4161
+ </xsl:call-template>
4162
+ </xsl:when>
4163
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
4164
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
4165
+ <case2/>
4166
+ <autolayout/>
4167
+ <xsl:for-each select="$column_widths/column/@width_max">
4168
+ <column divider="100"><xsl:value-of select="."/></column>
4169
+ </xsl:for-each>
4170
+ </xsl:when>
4171
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
4172
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
4173
+ Lets also call D the difference between maximum and minimum width of the table.
4174
+ For each column, let d be the difference between maximum and minimum width of that column.
4175
+ Now set the column's width to the minimum width plus d times W over D.
4176
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
4177
+ <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)">
4178
+ <!-- difference between the available space and the minimum table width -->
4179
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
4180
+ <W><xsl:value-of select="$W"/></W>
4181
+ <!-- difference between maximum and minimum width of the table -->
4182
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
4183
+ <D><xsl:value-of select="$D"/></D>
4184
+ <case3/>
4185
+ <autolayout/>
4186
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
4187
+ <split_keep-within-line>true</split_keep-within-line>
4188
+ </xsl:if>
4189
+ <xsl:for-each select="$column_widths/column">
4190
+ <!-- difference between maximum and minimum width of that column. -->
4191
+ <xsl:variable name="d" select="@width_max - @width_min"/>
4192
+ <d><xsl:value-of select="$d"/></d>
4193
+ <width_min><xsl:value-of select="@width_min"/></width_min>
4194
+ <e><xsl:value-of select="$d * $W div $D"/></e>
4195
+ <!-- set the column's width to the minimum width plus d times W over D. -->
4196
+ <column divider="100">
4197
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4198
+ </column>
4199
+ </xsl:for-each>
4200
+
4201
+ </xsl:when>
4202
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
4203
+ </xsl:choose>
4204
+
4205
+
4206
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths">
4207
+ <xsl:copy>
4208
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths"/>
4209
+ </xsl:copy>
4210
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths">
4211
+ <xsl:copy>
4212
+ <xsl:copy-of select="@*"/>
4213
+
4214
+ <!-- The maximum width is given by the widest line. -->
4215
+ <xsl:variable name="widths_max">
4216
+ <xsl:for-each select=".//*[local-name() = 'p']">
4217
+ <xsl:call-template name="add_width"/>
4218
+ </xsl:for-each>
4219
+ <xsl:if test="not(*[local-name() = 'p'])">
4220
+ <xsl:call-template name="add_width"/>
4221
+ </xsl:if>
4222
+ </xsl:variable>
4223
+ <xsl:variable name="width_max">
4224
+ <xsl:for-each select="xalan:nodeset($widths_max)//width">
4225
+ <xsl:sort select="." data-type="number" order="descending"/>
4226
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4227
+ </xsl:for-each>
4228
+ </xsl:variable>
4229
+ <xsl:attribute name="width_max">
4230
+ <xsl:value-of select="$width_max"/>
4231
+ </xsl:attribute>
4232
+
4233
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4234
+ <!-- To do: image width -->
4235
+ <xsl:variable name="td_text">
4236
+ <xsl:apply-templates select="." mode="td_text"/>
4237
+ </xsl:variable>
4238
+ <xsl:variable name="words">
4239
+ <xsl:variable name="string_with_added_zerospaces">
4240
+ <xsl:call-template name="add-zero-spaces-java">
4241
+ <xsl:with-param name="text" select="$td_text"/>
4242
+ </xsl:call-template>
4243
+ </xsl:variable>
4244
+ <xsl:call-template name="tokenize">
4245
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
4246
+ </xsl:call-template>
4247
+ </xsl:variable>
4248
+
4249
+ <xsl:variable name="max_word_length">
4250
+ <xsl:call-template name="max_length">
4251
+ <xsl:with-param name="words" select="xalan:nodeset($words)"/>
4252
+ </xsl:call-template>
4253
+ </xsl:variable>
4254
+ <xsl:variable name="width_min">
4255
+ <xsl:value-of select="$max_word_length"/>
4256
+ </xsl:variable>
4257
+ <xsl:attribute name="width_min">
4258
+ <xsl:value-of select="$width_min"/>
4259
+ </xsl:attribute>
4260
+ <!-- width_max="1" width_min="1.5"> --> <!-- see 'tokenize' template, multiply 1.5 for all latin capitals -->
4261
+ <xsl:if test="$width_min &gt; $width_max">
4262
+ <xsl:attribute name="width_max">
4263
+ <xsl:value-of select="$width_min"/>
4264
+ </xsl:attribute>
4265
+ </xsl:if>
4266
+ <xsl:if test="$width_min = 0">
4267
+ <xsl:attribute name="width_min">1</xsl:attribute>
4268
+ </xsl:if>
4269
+
4270
+ <xsl:apply-templates select="node()" mode="determine_cell_widths"/>
4271
+
4272
+ </xsl:copy>
4273
+ </xsl:template><xsl:template name="add_width">
4274
+ <xsl:variable name="p_text"><xsl:apply-templates select="." mode="td_text"/></xsl:variable>
4275
+ <xsl:variable name="p_text_len_" select="string-length(normalize-space($p_text))"/>
4276
+
4277
+ <xsl:variable name="p_text_len">
4278
+ <xsl:choose>
4279
+ <xsl:when test="normalize-space(translate($p_text, concat($upper,'0123456789'), '')) = ''"> <!-- english word in CAPITAL letters -->
4280
+ <xsl:value-of select="$p_text_len_ * 1.5"/>
4281
+ </xsl:when>
4282
+ <xsl:otherwise><xsl:value-of select="$p_text_len_"/></xsl:otherwise>
4283
+ </xsl:choose>
4284
+ </xsl:variable>
4285
+
4286
+ <xsl:variable name="math_addon_text">
4287
+ <xsl:for-each select=".//*[local-name() = 'math']">
4288
+ <xsl:apply-templates mode="td_text"/>
4289
+ </xsl:for-each>
4290
+ </xsl:variable>
4291
+ <xsl:variable name="math_addon_length" select="string-length(normalize-space($math_addon_text)) * 0.2"/> <!-- plus 20% -->
4292
+
4293
+ <width><xsl:value-of select="$p_text_len + $math_addon_length"/></width>
4294
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
4295
+ <xsl:copy>
4296
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
4297
+ </xsl:copy>
4298
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
4299
+ <xsl:copy>
4300
+ <xsl:copy-of select="@*"/>
4301
+
4302
+ <!-- The maximum width is given by the widest line. -->
4303
+ <xsl:attribute name="width_max">
4304
+ <xsl:for-each select="p_len">
4305
+ <xsl:sort select="." data-type="number" order="descending"/>
4306
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4307
+ </xsl:for-each>
4308
+ </xsl:attribute>
4309
+
4310
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4311
+ <xsl:variable name="width_min">
4312
+ <xsl:for-each select="word_len">
4313
+ <xsl:sort select="." data-type="number" order="descending"/>
4314
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4315
+ </xsl:for-each>
4316
+ </xsl:variable>
4317
+ <xsl:attribute name="width_min">
4318
+ <xsl:value-of select="$width_min"/>
4319
+ </xsl:attribute>
4320
+
4321
+ <xsl:if test="$width_min = 0">
4322
+ <xsl:attribute name="width_min">1</xsl:attribute>
4323
+ </xsl:if>
4324
+
4325
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
4326
+
4327
+ </xsl:copy>
4328
+ </xsl:template><xsl:template match="*[local-name()='thead']">
4329
+ <xsl:param name="cols-count"/>
4330
+ <fo:table-header>
4331
+
4332
+ <xsl:call-template name="table-header-title">
4333
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4334
+ </xsl:call-template>
4335
+
4336
+
4337
+ <xsl:apply-templates/>
4338
+ </fo:table-header>
4339
+ </xsl:template><xsl:template name="table-header-title">
4340
+ <xsl:param name="cols-count"/>
4341
+ <!-- row for title -->
4342
+ <fo:table-row>
4343
+ <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
4344
+
4345
+ <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
4346
+ <xsl:with-param name="continued">true</xsl:with-param>
4347
+ </xsl:apply-templates>
4348
+
4349
+
4350
+ <xsl:for-each select="ancestor::*[local-name()='table'][1]">
4351
+ <xsl:call-template name="table_name_fn_display"/>
4352
+ </xsl:for-each>
4353
+
4354
+ <fo:block text-align="right" font-style="italic">
4355
+ <xsl:text> </xsl:text>
4356
+ <fo:retrieve-table-marker retrieve-class-name="table_continued"/>
4357
+ </fo:block>
4358
+
4359
+
4360
+ </fo:table-cell>
4361
+ </fo:table-row>
4362
+ </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
4363
+ <fo:table-body>
4364
+ <xsl:apply-templates/>
4365
+ </fo:table-body>
4366
+ </xsl:template><xsl:template match="*[local-name()='tfoot']">
4367
+ <xsl:apply-templates/>
4368
+ </xsl:template><xsl:template name="insertTableFooter">
4369
+ <xsl:param name="cols-count"/>
4370
+ <xsl:if test="../*[local-name()='tfoot']">
4371
+ <fo:table-footer>
4372
+ <xsl:apply-templates select="../*[local-name()='tfoot']"/>
4373
+ </fo:table-footer>
4374
+ </xsl:if>
4375
+ </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
4376
+ <xsl:param name="table_attributes"/>
4377
+ <xsl:param name="colwidths"/>
4378
+ <xsl:param name="colgroup"/>
4379
+
4380
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4381
+
4382
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
4383
+
4384
+ </xsl:variable>
4385
+
4386
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
4387
+
4388
+ <xsl:variable name="cols-count">
4389
+ <xsl:choose>
4390
+ <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
4391
+ <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
4392
+ </xsl:when>
4393
+ <xsl:otherwise>
4394
+ <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/>
4395
+ </xsl:otherwise>
4396
+ </xsl:choose>
4397
+ </xsl:variable>
4398
+
4399
+ <fo:table keep-with-previous="always">
4400
+ <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
4401
+ <xsl:variable name="name" select="local-name()"/>
4402
+ <xsl:choose>
4403
+ <xsl:when test="$name = 'border-top'">
4404
+ <xsl:attribute name="{$name}">0pt solid black</xsl:attribute>
4405
+ </xsl:when>
3947
4406
  <xsl:when test="$name = 'border'">
3948
4407
  <xsl:attribute name="{$name}"><xsl:value-of select="."/></xsl:attribute>
3949
4408
  <xsl:attribute name="border-top">0pt solid black</xsl:attribute>
@@ -3963,16 +4422,10 @@
3963
4422
  </xsl:for-each>
3964
4423
  </xsl:when>
3965
4424
  <xsl:otherwise>
3966
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
3967
- <xsl:choose>
3968
- <xsl:when test=". = 1 or . = 0">
3969
- <fo:table-column column-width="proportional-column-width(2)"/>
3970
- </xsl:when>
3971
- <xsl:otherwise>
3972
- <fo:table-column column-width="proportional-column-width({.})"/>
3973
- </xsl:otherwise>
3974
- </xsl:choose>
3975
- </xsl:for-each>
4425
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
4426
+ <xsl:call-template name="insertTableColumnWidth">
4427
+ <xsl:with-param name="colwidths" select="$colwidths"/>
4428
+ </xsl:call-template>
3976
4429
  </xsl:otherwise>
3977
4430
  </xsl:choose>
3978
4431
 
@@ -4094,6 +4547,52 @@
4094
4547
 
4095
4548
  </fo:table-body>
4096
4549
 
4550
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4551
+ <xsl:param name="table_or_dl">table</xsl:param>
4552
+ <xsl:apply-templates mode="process_table-if">
4553
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4554
+ </xsl:apply-templates>
4555
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4556
+ <xsl:param name="table_or_dl">table</xsl:param>
4557
+
4558
+ <fo:table-body>
4559
+ <xsl:for-each select="*[local-name() = 'tr']">
4560
+ <xsl:variable name="col_count" select="count(*)"/>
4561
+
4562
+ <!-- iteration for each tr/td -->
4563
+
4564
+ <xsl:choose>
4565
+ <xsl:when test="$table_or_dl = 'table'">
4566
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4567
+ <fo:table-row number-columns-spanned="{$col_count}">
4568
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4569
+ <xsl:call-template name="td"/>
4570
+ </fo:table-row>
4571
+ </xsl:for-each>
4572
+ </xsl:when>
4573
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4574
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4575
+ <xsl:variable name="is_dt" select="position() = 1"/>
4576
+
4577
+ <xsl:for-each select="*">
4578
+ <!-- <test><xsl:copy-of select="."/></test> -->
4579
+ <fo:table-row number-columns-spanned="{$col_count}">
4580
+ <xsl:choose>
4581
+ <xsl:when test="$is_dt">
4582
+ <xsl:call-template name="insert_dt_cell"/>
4583
+ </xsl:when>
4584
+ <xsl:otherwise>
4585
+ <xsl:call-template name="insert_dd_cell"/>
4586
+ </xsl:otherwise>
4587
+ </xsl:choose>
4588
+ </fo:table-row>
4589
+ </xsl:for-each>
4590
+ </xsl:for-each>
4591
+ </xsl:otherwise>
4592
+ </xsl:choose>
4593
+
4594
+ </xsl:for-each>
4595
+ </fo:table-body>
4097
4596
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4098
4597
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4099
4598
 
@@ -4191,7 +4690,7 @@
4191
4690
  </xsl:choose>
4192
4691
  </xsl:attribute>
4193
4692
  </xsl:if>
4194
- </xsl:template><xsl:template match="*[local-name()='td']">
4693
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
4195
4694
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
4196
4695
  <xsl:call-template name="setTextAlignment">
4197
4696
  <xsl:with-param name="default">left</xsl:with-param>
@@ -4229,11 +4728,24 @@
4229
4728
 
4230
4729
  <xsl:call-template name="setTableCellAttributes"/>
4231
4730
 
4731
+ <xsl:if test="$isGenerateTableIF = 'true'">
4732
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4733
+ <xsl:attribute name="text-align">left</xsl:attribute>
4734
+ </xsl:if>
4735
+
4232
4736
  <fo:block>
4233
4737
 
4738
+ <xsl:if test="$isGenerateTableIF = 'true'">
4739
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4740
+ </xsl:if>
4741
+
4742
+
4234
4743
 
4235
4744
 
4236
4745
  <xsl:apply-templates/>
4746
+
4747
+ <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"/> -->
4748
+
4237
4749
  </fo:block>
4238
4750
  </fo:table-cell>
4239
4751
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -4432,9 +4944,9 @@
4432
4944
  <!-- current hierarchy is 'figure' element -->
4433
4945
  <xsl:variable name="following_dl_colwidths">
4434
4946
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4435
- <xsl:variable name="html-table">
4436
- <xsl:variable name="doc_ns">
4437
-
4947
+ <xsl:variable name="simple-table">
4948
+ <!-- <xsl:variable name="doc_ns">
4949
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4438
4950
  </xsl:variable>
4439
4951
  <xsl:variable name="ns">
4440
4952
  <xsl:choose>
@@ -4445,7 +4957,7 @@
4445
4957
  <xsl:value-of select="substring-before(name(/*), '-')"/>
4446
4958
  </xsl:otherwise>
4447
4959
  </xsl:choose>
4448
- </xsl:variable>
4960
+ </xsl:variable> -->
4449
4961
 
4450
4962
  <xsl:for-each select="*[local-name() = 'dl'][1]">
4451
4963
  <tbody>
@@ -4456,7 +4968,7 @@
4456
4968
 
4457
4969
  <xsl:call-template name="calculate-column-widths">
4458
4970
  <xsl:with-param name="cols-count" select="2"/>
4459
- <xsl:with-param name="table" select="$html-table"/>
4971
+ <xsl:with-param name="table" select="$simple-table"/>
4460
4972
  </xsl:call-template>
4461
4973
 
4462
4974
  </xsl:if>
@@ -4582,8 +5094,10 @@
4582
5094
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4583
5095
  </xsl:variable>
4584
5096
 
5097
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
5098
+
4585
5099
  <xsl:choose>
4586
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
5100
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4587
5101
 
4588
5102
  <fo:block margin-bottom="12pt" text-align="left">
4589
5103
 
@@ -4600,7 +5114,7 @@
4600
5114
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4601
5115
  </fo:block>
4602
5116
 
4603
- </xsl:when>
5117
+ </xsl:when> <!-- END: only one component -->
4604
5118
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4605
5119
  <fo:block margin-bottom="12pt" text-align="left">
4606
5120
 
@@ -4616,8 +5130,8 @@
4616
5130
  </xsl:variable>
4617
5131
  <xsl:value-of select="$title-where"/>
4618
5132
  </fo:block>
4619
- </xsl:when>
4620
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
5133
+ </xsl:when> <!-- END: a few components -->
5134
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4621
5135
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4622
5136
 
4623
5137
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -4633,11 +5147,11 @@
4633
5147
  </xsl:variable>
4634
5148
  <xsl:value-of select="$title-key"/>
4635
5149
  </fo:block>
4636
- </xsl:when>
5150
+ </xsl:when> <!-- END: definition list in a figure -->
4637
5151
  </xsl:choose>
4638
5152
 
4639
5153
  <!-- a few components -->
4640
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
5154
+ <xsl:if test="$onlyOneComponent = 'false'">
4641
5155
  <fo:block>
4642
5156
 
4643
5157
  <xsl:if test="$parent = 'formula'">
@@ -4653,7 +5167,18 @@
4653
5167
 
4654
5168
 
4655
5169
 
5170
+
5171
+ <xsl:if test="$isGenerateTableIF = 'true'">
5172
+ <!-- to determine start of table -->
5173
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
5174
+ </xsl:if>
5175
+
4656
5176
  <fo:table width="95%" table-layout="fixed">
5177
+
5178
+ <xsl:if test="$isGenerateTableIF = 'true'">
5179
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
5180
+ </xsl:if>
5181
+
4657
5182
 
4658
5183
  <xsl:choose>
4659
5184
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4662,54 +5187,145 @@
4662
5187
 
4663
5188
  </xsl:when>
4664
5189
  </xsl:choose>
4665
- <!-- create virtual html table for dl/[dt and dd] -->
4666
- <xsl:variable name="html-table">
4667
- <xsl:variable name="doc_ns">
5190
+
5191
+
5192
+ <xsl:choose>
5193
+ <xsl:when test="$isGenerateTableIF = 'true'">
5194
+ <!-- generate IF for table widths -->
5195
+ <!-- example:
5196
+ <tr>
5197
+ <td valign="top" align="left" id="tab-symdu_1_1">
5198
+ <p>Symbol</p>
5199
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
5200
+ </td>
5201
+ <td valign="top" align="left" id="tab-symdu_1_2">
5202
+ <p>Description</p>
5203
+ <word id="tab-symdu_1_2_word_1">Description</word>
5204
+ </td>
5205
+ </tr>
5206
+ -->
4668
5207
 
4669
- </xsl:variable>
4670
- <xsl:variable name="ns">
4671
- <xsl:choose>
4672
- <xsl:when test="normalize-space($doc_ns) != ''">
4673
- <xsl:value-of select="normalize-space($doc_ns)"/>
4674
- </xsl:when>
4675
- <xsl:otherwise>
4676
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4677
- </xsl:otherwise>
4678
- </xsl:choose>
4679
- </xsl:variable>
4680
- <tbody>
4681
- <xsl:apply-templates mode="dl"/>
4682
- </tbody>
4683
- </xsl:variable>
4684
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4685
- <xsl:variable name="colwidths">
4686
- <xsl:call-template name="calculate-column-widths">
4687
- <xsl:with-param name="cols-count" select="2"/>
4688
- <xsl:with-param name="table" select="$html-table"/>
4689
- </xsl:call-template>
4690
- </xsl:variable>
4691
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4692
- <xsl:variable name="maxlength_dt">
4693
- <xsl:call-template name="getMaxLength_dt"/>
4694
- </xsl:variable>
4695
- <xsl:call-template name="setColumnWidth_dl">
4696
- <xsl:with-param name="colwidths" select="$colwidths"/>
4697
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4698
- </xsl:call-template>
4699
- <fo:table-body>
4700
- <xsl:apply-templates>
4701
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4702
- </xsl:apply-templates>
4703
- </fo:table-body>
5208
+ <!-- create virtual html table for dl/[dt and dd] -->
5209
+ <xsl:variable name="simple-table">
5210
+
5211
+ <xsl:variable name="dl_table">
5212
+ <tbody>
5213
+ <xsl:apply-templates mode="dl_if">
5214
+ <xsl:with-param name="id" select="@id"/>
5215
+ </xsl:apply-templates>
5216
+ </tbody>
5217
+ </xsl:variable>
5218
+
5219
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
5220
+
5221
+ <!-- Step: replace <br/> to <p>...</p> -->
5222
+ <xsl:variable name="table_without_br">
5223
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
5224
+ </xsl:variable>
5225
+
5226
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
5227
+
5228
+ <!-- Step: add id to each cell -->
5229
+ <!-- add <word>...</word> for each word, image, math -->
5230
+ <xsl:variable name="simple-table-id">
5231
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
5232
+ <xsl:with-param name="id" select="@id"/>
5233
+ </xsl:apply-templates>
5234
+ </xsl:variable>
5235
+
5236
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
5237
+
5238
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5239
+
5240
+ </xsl:variable>
5241
+
5242
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
5243
+
5244
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
5245
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
5246
+ </xsl:apply-templates>
5247
+
5248
+ </xsl:when>
5249
+ <xsl:otherwise>
5250
+
5251
+ <xsl:variable name="simple-table">
5252
+
5253
+ <xsl:variable name="dl_table">
5254
+ <tbody>
5255
+ <xsl:apply-templates mode="dl">
5256
+ <xsl:with-param name="id" select="@id"/>
5257
+ </xsl:apply-templates>
5258
+ </tbody>
5259
+ </xsl:variable>
5260
+
5261
+ <xsl:copy-of select="$dl_table"/>
5262
+ </xsl:variable>
5263
+
5264
+ <xsl:variable name="colwidths">
5265
+ <xsl:call-template name="calculate-column-widths">
5266
+ <xsl:with-param name="cols-count" select="2"/>
5267
+ <xsl:with-param name="table" select="$simple-table"/>
5268
+ </xsl:call-template>
5269
+ </xsl:variable>
5270
+
5271
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
5272
+ DEBUG
5273
+ colwidths=<xsl:copy-of select="$colwidths"/>
5274
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
5275
+
5276
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
5277
+
5278
+ <xsl:variable name="maxlength_dt">
5279
+ <xsl:call-template name="getMaxLength_dt"/>
5280
+ </xsl:variable>
5281
+
5282
+ <xsl:variable name="isContainsKeepTogetherTag_">
5283
+
5284
+ <xsl:value-of select="count(.//*[local-name() = $element_name_keep-together_within-line]) &gt; 0"/>
5285
+
5286
+ </xsl:variable>
5287
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
5288
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
5289
+
5290
+
5291
+ <xsl:call-template name="setColumnWidth_dl">
5292
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5293
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5294
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
5295
+ </xsl:call-template>
5296
+
5297
+ <fo:table-body>
5298
+
5299
+ <!-- DEBUG -->
5300
+ <xsl:if test="$table_if_debug = 'true'">
5301
+ <fo:table-row>
5302
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
5303
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5304
+ </fo:table-cell>
5305
+ </fo:table-row>
5306
+ </xsl:if>
5307
+
5308
+ <xsl:apply-templates>
5309
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
5310
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
5311
+ </xsl:apply-templates>
5312
+
5313
+ </fo:table-body>
5314
+ </xsl:otherwise>
5315
+ </xsl:choose>
4704
5316
  </fo:table>
4705
5317
  </fo:block>
4706
5318
  </fo:block>
4707
- </xsl:if>
5319
+ </xsl:if> <!-- END: a few components -->
4708
5320
  </fo:block-container>
4709
5321
  </fo:block-container>
4710
5322
  </xsl:template><xsl:template name="setColumnWidth_dl">
4711
5323
  <xsl:param name="colwidths"/>
4712
5324
  <xsl:param name="maxlength_dt"/>
5325
+ <xsl:param name="isContainsKeepTogetherTag"/>
5326
+
5327
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
5328
+
4713
5329
  <xsl:choose>
4714
5330
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4715
5331
  <fo:table-column column-width="50%"/>
@@ -4717,6 +5333,16 @@
4717
5333
  </xsl:when>
4718
5334
  <xsl:otherwise>
4719
5335
  <xsl:choose>
5336
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5337
+ <xsl:call-template name="insertTableColumnWidth">
5338
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5339
+ </xsl:call-template>
5340
+ </xsl:when>
5341
+ <xsl:when test="$isContainsKeepTogetherTag">
5342
+ <xsl:call-template name="insertTableColumnWidth">
5343
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5344
+ </xsl:call-template>
5345
+ </xsl:when>
4720
5346
  <!-- to set width check most wide chars like `W` -->
4721
5347
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
4722
5348
  <fo:table-column column-width="7%"/>
@@ -4747,20 +5373,31 @@
4747
5373
  <fo:table-column column-width="60%"/>
4748
5374
  </xsl:when>
4749
5375
  <xsl:otherwise>
4750
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
4751
- <xsl:choose>
4752
- <xsl:when test=". = 1 or . = 0">
4753
- <fo:table-column column-width="proportional-column-width(2)"/>
4754
- </xsl:when>
4755
- <xsl:otherwise>
4756
- <fo:table-column column-width="proportional-column-width({.})"/>
4757
- </xsl:otherwise>
4758
- </xsl:choose>
4759
- </xsl:for-each>
5376
+ <xsl:call-template name="insertTableColumnWidth">
5377
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5378
+ </xsl:call-template>
4760
5379
  </xsl:otherwise>
4761
5380
  </xsl:choose>
4762
5381
  </xsl:otherwise>
4763
5382
  </xsl:choose>
5383
+ </xsl:template><xsl:template name="insertTableColumnWidth">
5384
+ <xsl:param name="colwidths"/>
5385
+
5386
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
5387
+ <xsl:choose>
5388
+ <xsl:when test=". = 1 or . = 0">
5389
+ <fo:table-column column-width="proportional-column-width(2)"/>
5390
+ </xsl:when>
5391
+ <xsl:otherwise>
5392
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
5393
+ <xsl:variable name="divider">
5394
+ <xsl:value-of select="@divider"/>
5395
+ <xsl:if test="not(@divider)">1</xsl:if>
5396
+ </xsl:variable>
5397
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
5398
+ </xsl:otherwise>
5399
+ </xsl:choose>
5400
+ </xsl:for-each>
4764
5401
  </xsl:template><xsl:template name="getMaxLength_dt">
4765
5402
  <xsl:variable name="lengths">
4766
5403
  <xsl:for-each select="*[local-name()='dt']">
@@ -4784,7 +5421,6 @@
4784
5421
  <xsl:value-of select="$maxLength"/>
4785
5422
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4786
5423
  <xsl:param name="key_iso"/>
4787
-
4788
5424
  <!-- <tr>
4789
5425
  <td>NOTE</td>
4790
5426
  <td>
@@ -4792,27 +5428,47 @@
4792
5428
  </td>
4793
5429
  </tr>
4794
5430
  -->
4795
- <fo:table-row>
5431
+ <!-- OLD Variant -->
5432
+ <!-- <fo:table-row>
4796
5433
  <fo:table-cell>
4797
5434
  <fo:block margin-top="6pt">
4798
5435
  <xsl:if test="normalize-space($key_iso) = 'true'">
4799
5436
  <xsl:attribute name="margin-top">0</xsl:attribute>
4800
5437
  </xsl:if>
4801
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5438
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4802
5439
  </fo:block>
4803
5440
  </fo:table-cell>
4804
5441
  <fo:table-cell>
4805
5442
  <fo:block>
4806
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5443
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
5444
+ </fo:block>
5445
+ </fo:table-cell>
5446
+ </fo:table-row> -->
5447
+ <!-- <tr>
5448
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
5449
+ </tr>
5450
+ -->
5451
+ <fo:table-row>
5452
+ <fo:table-cell number-columns-spanned="2">
5453
+ <fo:block>
5454
+ <xsl:call-template name="note"/>
4807
5455
  </fo:block>
4808
5456
  </fo:table-cell>
4809
5457
  </fo:table-row>
4810
5458
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
5459
+ <xsl:param name="id"/>
5460
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4811
5461
  <tr>
4812
5462
  <td>
5463
+ <xsl:attribute name="id">
5464
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5465
+ </xsl:attribute>
4813
5466
  <xsl:apply-templates/>
4814
5467
  </td>
4815
5468
  <td>
5469
+ <xsl:attribute name="id">
5470
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5471
+ </xsl:attribute>
4816
5472
 
4817
5473
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4818
5474
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4823,50 +5479,122 @@
4823
5479
 
4824
5480
  </xsl:template><xsl:template match="*[local-name()='dt']">
4825
5481
  <xsl:param name="key_iso"/>
5482
+ <xsl:param name="split_keep-within-line"/>
4826
5483
 
4827
5484
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4828
- <fo:table-cell>
5485
+ <xsl:call-template name="insert_dt_cell">
5486
+ <xsl:with-param name="key_iso" select="$key_iso"/>
5487
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5488
+ </xsl:call-template>
5489
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
5490
+ <xsl:call-template name="insert_dd_cell">
5491
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5492
+ </xsl:call-template>
5493
+ </xsl:for-each>
5494
+ </fo:table-row>
5495
+ </xsl:template><xsl:template name="insert_dt_cell">
5496
+ <xsl:param name="key_iso"/>
5497
+ <xsl:param name="split_keep-within-line"/>
5498
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
5499
+
5500
+ <xsl:if test="$isGenerateTableIF = 'true'">
5501
+ <!-- border is mandatory, to calculate real width -->
5502
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5503
+ <xsl:attribute name="text-align">left</xsl:attribute>
5504
+ </xsl:if>
5505
+
5506
+
5507
+ <fo:block xsl:use-attribute-sets="dt-block-style">
5508
+ <xsl:copy-of select="@id"/>
5509
+
5510
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5511
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5512
+ </xsl:if>
5513
+
5514
+
5515
+
5516
+ <xsl:apply-templates>
5517
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5518
+ </xsl:apply-templates>
5519
+
5520
+ <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"/> -->
5521
+
5522
+ </fo:block>
5523
+ </fo:table-cell>
5524
+ </xsl:template><xsl:template name="insert_dd_cell">
5525
+ <xsl:param name="split_keep-within-line"/>
5526
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5527
+
5528
+ <xsl:if test="$isGenerateTableIF = 'true'">
5529
+ <!-- border is mandatory, to calculate real width -->
5530
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5531
+ </xsl:if>
5532
+
5533
+ <fo:block>
5534
+
5535
+ <xsl:if test="$isGenerateTableIF = 'true'">
5536
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5537
+ </xsl:if>
5538
+
4829
5539
 
4830
- <fo:block xsl:use-attribute-sets="dt-style">
4831
- <xsl:copy-of select="@id"/>
4832
-
4833
- <xsl:if test="normalize-space($key_iso) = 'true'">
4834
- <xsl:attribute name="margin-top">0</xsl:attribute>
4835
- </xsl:if>
4836
-
4837
-
4838
-
4839
- <xsl:apply-templates/>
4840
- </fo:block>
4841
- </fo:table-cell>
4842
- <fo:table-cell>
4843
- <fo:block>
4844
-
4845
5540
 
4846
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4847
- <xsl:with-param name="process">true</xsl:with-param>
4848
- </xsl:apply-templates>
4849
- </fo:block>
4850
- </fo:table-cell>
4851
- </fo:table-row>
5541
+ <xsl:choose>
5542
+ <xsl:when test="$isGenerateTableIF = 'true'">
5543
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5544
+ <xsl:with-param name="process">true</xsl:with-param>
5545
+ </xsl:apply-templates>
5546
+ </xsl:when>
5547
+ <xsl:otherwise>
5548
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5549
+ <xsl:with-param name="process">true</xsl:with-param>
5550
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5551
+ </xsl:apply-templates>
5552
+ </xsl:otherwise>
5553
+
5554
+ </xsl:choose>
5555
+
5556
+ <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"/> -->
5557
+
5558
+ </fo:block>
5559
+ </fo:table-cell>
4852
5560
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4853
5561
  <xsl:apply-templates/>
4854
5562
  </xsl:template><xsl:template match="*[local-name()='dd']">
4855
5563
  <xsl:param name="process">false</xsl:param>
5564
+ <xsl:param name="split_keep-within-line"/>
4856
5565
  <xsl:if test="$process = 'true'">
4857
5566
  <xsl:apply-templates select="@language"/>
4858
- <xsl:apply-templates/>
5567
+ <xsl:apply-templates>
5568
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5569
+ </xsl:apply-templates>
4859
5570
  </xsl:if>
4860
5571
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4861
5572
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4862
- </xsl:template><xsl:template match="*[local-name()='em']">
5573
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5574
+ <xsl:param name="id"/>
5575
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5576
+ <tr>
5577
+ <td>
5578
+ <xsl:copy-of select="node()"/>
5579
+ </td>
5580
+ <td>
5581
+
5582
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()"/>
5583
+
5584
+ </td>
5585
+ </tr>
5586
+
5587
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='em']">
4863
5588
  <fo:inline font-style="italic">
4864
5589
  <xsl:apply-templates/>
4865
5590
  </fo:inline>
4866
5591
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5592
+ <xsl:param name="split_keep-within-line"/>
4867
5593
  <fo:inline font-weight="bold">
4868
5594
 
4869
- <xsl:apply-templates/>
5595
+ <xsl:apply-templates>
5596
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5597
+ </xsl:apply-templates>
4870
5598
  </fo:inline>
4871
5599
  </xsl:template><xsl:template match="*[local-name()='padding']">
4872
5600
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4905,13 +5633,15 @@
4905
5633
  <xsl:choose>
4906
5634
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4907
5635
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4908
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5636
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4909
5637
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4910
5638
  </xsl:choose>
4911
5639
  </xsl:attribute>
4912
5640
  </xsl:if>
4913
5641
  <xsl:apply-templates/>
4914
5642
  </fo:inline>
5643
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
5644
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4915
5645
  </xsl:template><xsl:template match="*[local-name()='underline']">
4916
5646
  <fo:inline text-decoration="underline">
4917
5647
  <xsl:apply-templates/>
@@ -5059,54 +5789,120 @@
5059
5789
  <fo:block break-after="page"/>
5060
5790
  <fo:block> </fo:block>
5061
5791
  <fo:block break-after="page"/>
5792
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5793
+ <xsl:apply-templates/>
5062
5794
  </xsl:template><xsl:template name="tokenize">
5063
5795
  <xsl:param name="text"/>
5064
5796
  <xsl:param name="separator" select="' '"/>
5065
5797
  <xsl:choose>
5798
+
5799
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5800
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5801
+ </xsl:when>
5066
5802
  <xsl:when test="not(contains($text, $separator))">
5067
5803
  <word>
5068
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5069
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5070
5804
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
5071
- <xsl:variable name="len_str">
5072
- <xsl:choose>
5073
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5074
- <xsl:value-of select="$len_str_tmp * 1.5"/>
5075
- </xsl:when>
5076
- <xsl:otherwise>
5077
- <xsl:value-of select="$len_str_tmp"/>
5078
- </xsl:otherwise>
5079
- </xsl:choose>
5080
- </xsl:variable>
5081
-
5082
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5083
- <xsl:message>
5084
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5085
- len_str=<xsl:value-of select="$len_str"/>
5086
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5087
- </xsl:message>
5088
- </xsl:if> -->
5089
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5090
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
5091
5805
  <xsl:choose>
5092
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5093
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5806
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5807
+ <xsl:value-of select="$len_str_tmp"/>
5094
5808
  </xsl:when>
5095
5809
  <xsl:otherwise>
5096
- <xsl:value-of select="$len_str"/>
5810
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5811
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5812
+ <xsl:variable name="len_str">
5813
+ <xsl:choose>
5814
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5815
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5816
+ </xsl:when>
5817
+ <xsl:otherwise>
5818
+ <xsl:value-of select="$len_str_tmp"/>
5819
+ </xsl:otherwise>
5820
+ </xsl:choose>
5821
+ </xsl:variable>
5822
+
5823
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5824
+ <xsl:message>
5825
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5826
+ len_str=<xsl:value-of select="$len_str"/>
5827
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5828
+ </xsl:message>
5829
+ </xsl:if> -->
5830
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5831
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5832
+ <xsl:choose>
5833
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5834
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5835
+ </xsl:when>
5836
+ <xsl:otherwise>
5837
+ <xsl:value-of select="$len_str"/>
5838
+ </xsl:otherwise>
5839
+ </xsl:choose>
5097
5840
  </xsl:otherwise>
5098
5841
  </xsl:choose>
5099
5842
  </word>
5100
5843
  </xsl:when>
5101
5844
  <xsl:otherwise>
5102
5845
  <word>
5103
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5846
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5847
+ <xsl:choose>
5848
+ <xsl:when test="$isGenerateTableIF = 'true'">
5849
+ <xsl:value-of select="$word"/>
5850
+ </xsl:when>
5851
+ <xsl:otherwise>
5852
+ <xsl:value-of select="string-length($word)"/>
5853
+ </xsl:otherwise>
5854
+ </xsl:choose>
5104
5855
  </word>
5105
5856
  <xsl:call-template name="tokenize">
5106
5857
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5107
5858
  </xsl:call-template>
5108
5859
  </xsl:otherwise>
5109
5860
  </xsl:choose>
5861
+ </xsl:template><xsl:template name="tokenize_with_tags">
5862
+ <xsl:param name="tags"/>
5863
+ <xsl:param name="text"/>
5864
+ <xsl:param name="separator" select="' '"/>
5865
+ <xsl:choose>
5866
+
5867
+ <xsl:when test="not(contains($text, $separator))">
5868
+ <word>
5869
+ <xsl:call-template name="enclose_text_in_tags">
5870
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5871
+ <xsl:with-param name="tags" select="$tags"/>
5872
+ </xsl:call-template>
5873
+ </word>
5874
+ </xsl:when>
5875
+ <xsl:otherwise>
5876
+ <word>
5877
+ <xsl:call-template name="enclose_text_in_tags">
5878
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5879
+ <xsl:with-param name="tags" select="$tags"/>
5880
+ </xsl:call-template>
5881
+ </word>
5882
+ <xsl:call-template name="tokenize_with_tags">
5883
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5884
+ </xsl:call-template>
5885
+ </xsl:otherwise>
5886
+ </xsl:choose>
5887
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5888
+ <xsl:param name="text"/>
5889
+ <xsl:param name="tags"/>
5890
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5891
+
5892
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5893
+
5894
+ <xsl:choose>
5895
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
5896
+ <xsl:otherwise>
5897
+ <xsl:element name="{$tag_name}">
5898
+ <xsl:call-template name="enclose_text_in_tags">
5899
+ <xsl:with-param name="text" select="$text"/>
5900
+ <xsl:with-param name="tags" select="$tags"/>
5901
+ <xsl:with-param name="num" select="$num + 1"/>
5902
+ </xsl:call-template>
5903
+ </xsl:element>
5904
+ </xsl:otherwise>
5905
+ </xsl:choose>
5110
5906
  </xsl:template><xsl:template name="max_length">
5111
5907
  <xsl:param name="words"/>
5112
5908
  <xsl:for-each select="$words//word">
@@ -5207,12 +6003,19 @@
5207
6003
  </xsl:otherwise>
5208
6004
  </xsl:choose>
5209
6005
  </xsl:template><xsl:template name="getSimpleTable">
6006
+ <xsl:param name="id"/>
6007
+
5210
6008
  <xsl:variable name="simple-table">
5211
6009
 
6010
+ <!-- Step 0. replace <br/> to <p>...</p> -->
6011
+ <xsl:variable name="table_without_br">
6012
+ <xsl:apply-templates mode="table-without-br"/>
6013
+ </xsl:variable>
6014
+
5212
6015
  <!-- Step 1. colspan processing -->
5213
6016
  <xsl:variable name="simple-table-colspan">
5214
6017
  <tbody>
5215
- <xsl:apply-templates mode="simple-table-colspan"/>
6018
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
5216
6019
  </tbody>
5217
6020
  </xsl:variable>
5218
6021
 
@@ -5221,10 +6024,67 @@
5221
6024
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
5222
6025
  </xsl:variable>
5223
6026
 
5224
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
5225
-
6027
+ <!-- Step 3: add id to each cell -->
6028
+ <!-- add <word>...</word> for each word, image, math -->
6029
+ <xsl:variable name="simple-table-id">
6030
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
6031
+ <xsl:with-param name="id" select="$id"/>
6032
+ </xsl:apply-templates>
6033
+ </xsl:variable>
6034
+
6035
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
6036
+
5226
6037
  </xsl:variable>
5227
6038
  <xsl:copy-of select="$simple-table"/>
6039
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
6040
+ <xsl:copy>
6041
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
6042
+ </xsl:copy>
6043
+ </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">
6044
+ <xsl:copy>
6045
+ <xsl:copy-of select="@*"/>
6046
+ <p>
6047
+ <xsl:copy-of select="node()"/>
6048
+ </p>
6049
+ </xsl:copy>
6050
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
6051
+ <xsl:copy>
6052
+ <xsl:copy-of select="@*"/>
6053
+ <xsl:for-each select="*[local-name()='br']">
6054
+ <xsl:variable name="current_id" select="generate-id()"/>
6055
+ <p>
6056
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6057
+ <xsl:copy-of select="."/>
6058
+ </xsl:for-each>
6059
+ </p>
6060
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6061
+ <p>
6062
+ <xsl:for-each select="following-sibling::node()">
6063
+ <xsl:copy-of select="."/>
6064
+ </xsl:for-each>
6065
+ </p>
6066
+ </xsl:if>
6067
+ </xsl:for-each>
6068
+ </xsl:copy>
6069
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
6070
+ <xsl:for-each select="*[local-name()='br']">
6071
+ <xsl:variable name="current_id" select="generate-id()"/>
6072
+ <p>
6073
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6074
+ <xsl:copy-of select="."/>
6075
+ </xsl:for-each>
6076
+ </p>
6077
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6078
+ <p>
6079
+ <xsl:for-each select="following-sibling::node()">
6080
+ <xsl:copy-of select="."/>
6081
+ </xsl:for-each>
6082
+ </p>
6083
+ </xsl:if>
6084
+ </xsl:for-each>
6085
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
6086
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
6087
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
5228
6088
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
5229
6089
  <xsl:apply-templates mode="simple-table-colspan"/>
5230
6090
  </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">
@@ -5314,6 +6174,126 @@
5314
6174
  <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5315
6175
  <xsl:with-param name="previousRow" select="$newRow"/>
5316
6176
  </xsl:apply-templates>
6177
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
6178
+ <xsl:param name="id"/>
6179
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
6180
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6181
+ <xsl:with-param name="id" select="$id_prefixed"/>
6182
+ </xsl:apply-templates>
6183
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
6184
+ <xsl:param name="id"/>
6185
+ <xsl:copy>
6186
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6187
+ <xsl:with-param name="id" select="$id"/>
6188
+ </xsl:apply-templates>
6189
+ </xsl:copy>
6190
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
6191
+ <xsl:param name="id"/>
6192
+ <xsl:copy>
6193
+ <xsl:copy-of select="@*"/>
6194
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
6195
+ <xsl:apply-templates select="node()" mode="simple-table-id">
6196
+ <xsl:with-param name="id" select="$id"/>
6197
+ </xsl:apply-templates>
6198
+ </xsl:copy>
6199
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
6200
+ <xsl:param name="id"/>
6201
+ <xsl:copy>
6202
+ <xsl:copy-of select="@*"/>
6203
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
6204
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
6205
+ <xsl:attribute name="id">
6206
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
6207
+ </xsl:attribute>
6208
+
6209
+ <xsl:for-each select="*[local-name() = 'p']">
6210
+ <xsl:copy>
6211
+ <xsl:copy-of select="@*"/>
6212
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
6213
+ <xsl:attribute name="id">
6214
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
6215
+ </xsl:attribute>
6216
+
6217
+ <xsl:copy-of select="node()"/>
6218
+ </xsl:copy>
6219
+ </xsl:for-each>
6220
+
6221
+
6222
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
6223
+
6224
+ <xsl:variable name="td_text">
6225
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
6226
+ </xsl:variable>
6227
+
6228
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
6229
+
6230
+ <xsl:variable name="words">
6231
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
6232
+ <word>
6233
+ <xsl:copy-of select="."/>
6234
+ </word>
6235
+ </xsl:for-each>
6236
+
6237
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
6238
+ <xsl:copy-of select="."/>
6239
+ </xsl:for-each>
6240
+
6241
+ </xsl:variable>
6242
+
6243
+ <xsl:for-each select="xalan:nodeset($words)/word">
6244
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
6245
+ <xsl:copy>
6246
+ <xsl:attribute name="id">
6247
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
6248
+ </xsl:attribute>
6249
+ <xsl:copy-of select="node()"/>
6250
+ </xsl:copy>
6251
+ </xsl:for-each>
6252
+ </xsl:if>
6253
+ </xsl:copy>
6254
+
6255
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
6256
+ <xsl:copy>
6257
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
6258
+ </xsl:copy>
6259
+ </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">
6260
+ <xsl:variable name="formatting_tags">
6261
+ <xsl:call-template name="getFormattingTags"/>
6262
+ </xsl:variable>
6263
+ <word>
6264
+ <xsl:call-template name="enclose_text_in_tags">
6265
+ <xsl:with-param name="text" select="normalize-space(.)"/>
6266
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6267
+ </xsl:call-template>
6268
+ </word>
6269
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
6270
+
6271
+ <xsl:variable name="td_text" select="."/>
6272
+
6273
+ <xsl:variable name="string_with_added_zerospaces">
6274
+ <xsl:call-template name="add-zero-spaces-java">
6275
+ <xsl:with-param name="text" select="$td_text"/>
6276
+ </xsl:call-template>
6277
+ </xsl:variable>
6278
+
6279
+ <xsl:variable name="formatting_tags">
6280
+ <xsl:call-template name="getFormattingTags"/>
6281
+ </xsl:variable>
6282
+
6283
+ <!-- <word>text</word> -->
6284
+ <xsl:call-template name="tokenize_with_tags">
6285
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6286
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
6287
+ </xsl:call-template>
6288
+ </xsl:template><xsl:template name="getFormattingTags">
6289
+ <tags>
6290
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
6291
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
6292
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6293
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6294
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6295
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6296
+ </tags>
5317
6297
  </xsl:template><xsl:template name="getLang">
5318
6298
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5319
6299
  <xsl:variable name="language">
@@ -5368,6 +6348,9 @@
5368
6348
  <xsl:variable name="isDeleted" select="@deleted"/>
5369
6349
 
5370
6350
  <fo:inline xsl:use-attribute-sets="mathml-style">
6351
+
6352
+
6353
+
5371
6354
 
5372
6355
 
5373
6356
  <xsl:call-template name="setTrackChangesStyles">
@@ -5375,55 +6358,87 @@
5375
6358
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
5376
6359
  </xsl:call-template>
5377
6360
 
6361
+ <xsl:if test="$add_math_as_text = 'true'">
6362
+ <!-- insert helper tag -->
6363
+ <!-- set unique font-size (fiction) -->
6364
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
6365
+ <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal"><xsl:value-of select="$zero_width_space"/></fo:inline> <!-- zero width space -->
6366
+ </xsl:if>
5378
6367
 
5379
-
5380
- <xsl:variable name="mathml">
5381
- <xsl:apply-templates select="." mode="mathml"/>
6368
+ <xsl:variable name="mathml_content">
6369
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
5382
6370
  </xsl:variable>
5383
- <fo:instream-foreign-object fox:alt-text="Math">
5384
6371
 
6372
+
6373
+ <xsl:call-template name="mathml_instream_object">
6374
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
6375
+ </xsl:call-template>
5385
6376
 
5386
-
5387
- <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
5388
- <xsl:variable name="comment_text_">
5389
- <xsl:choose>
5390
- <xsl:when test="normalize-space($comment_text_following) != ''">
5391
- <xsl:value-of select="$comment_text_following"/>
5392
- </xsl:when>
5393
- <xsl:otherwise>
5394
- <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
5395
- </xsl:otherwise>
5396
- </xsl:choose>
5397
- </xsl:variable>
5398
- <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
5399
-
5400
- <xsl:if test="normalize-space($comment_text) != ''">
5401
- <!-- put Mathin Alternate Text -->
5402
- <xsl:attribute name="fox:alt-text">
5403
- <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
5404
- </xsl:attribute>
6377
+
6378
+ </fo:inline>
6379
+ </xsl:template><xsl:template name="getMathml_comment_text">
6380
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
6381
+ <xsl:variable name="comment_text_">
6382
+ <xsl:choose>
6383
+ <xsl:when test="normalize-space($comment_text_following) != ''">
6384
+ <xsl:value-of select="$comment_text_following"/>
6385
+ </xsl:when>
6386
+ <xsl:otherwise>
6387
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
6388
+ </xsl:otherwise>
6389
+ </xsl:choose>
6390
+ </xsl:variable>
6391
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
6392
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
6393
+ <xsl:value-of select="$comment_text"/>
6394
+ </xsl:template><xsl:template name="mathml_instream_object">
6395
+ <xsl:param name="comment_text"/>
6396
+ <xsl:param name="mathml_content"/>
6397
+
6398
+ <xsl:variable name="comment_text_">
6399
+ <xsl:choose>
6400
+ <xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
6401
+ <xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
6402
+ </xsl:choose>
6403
+ </xsl:variable>
6404
+
6405
+ <xsl:variable name="mathml">
6406
+ <xsl:apply-templates select="." mode="mathml"/>
6407
+ </xsl:variable>
6408
+
6409
+ <fo:instream-foreign-object fox:alt-text="Math">
6410
+
6411
+
6412
+
6413
+
6414
+ <xsl:if test="count(ancestor::*[local-name() = 'table']) &gt; 1">
6415
+ <xsl:attribute name="width">95%</xsl:attribute>
6416
+ <xsl:attribute name="content-height">100%</xsl:attribute>
6417
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6418
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5405
6419
  </xsl:if>
5406
-
5407
- <xsl:variable name="mathml_content">
5408
- <xsl:apply-templates select="." mode="mathml_actual_text"/>
5409
- </xsl:variable>
5410
- <!-- put MathML in Actual Text -->
5411
- <xsl:attribute name="fox:actual-text">
5412
- <xsl:value-of select="$mathml_content"/>
6420
+
6421
+
6422
+
6423
+
6424
+ <!-- put MathML in Actual Text -->
6425
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
6426
+ <xsl:attribute name="fox:actual-text">
6427
+ <xsl:value-of select="$mathml_content"/>
6428
+ </xsl:attribute>
6429
+
6430
+ <!-- <xsl:if test="$add_math_as_text = 'true'"> -->
6431
+ <xsl:if test="normalize-space($comment_text_) != ''">
6432
+ <!-- put Mathin Alternate Text -->
6433
+ <xsl:attribute name="fox:alt-text">
6434
+ <xsl:value-of select="$comment_text_"/>
5413
6435
  </xsl:attribute>
5414
-
5415
-
5416
- <xsl:if test="count(ancestor::*[local-name() = 'table']) &gt; 1">
5417
- <xsl:attribute name="width">95%</xsl:attribute>
5418
- <xsl:attribute name="content-height">100%</xsl:attribute>
5419
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5420
- <xsl:attribute name="scaling">uniform</xsl:attribute>
5421
- </xsl:if>
5422
-
5423
-
5424
- <xsl:copy-of select="xalan:nodeset($mathml)"/>
5425
- </fo:instream-foreign-object>
5426
- </fo:inline>
6436
+ </xsl:if>
6437
+ <!-- </xsl:if> -->
6438
+
6439
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
6440
+
6441
+ </fo:instream-foreign-object>
5427
6442
  </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
5428
6443
  <!-- <xsl:text>a+b</xsl:text> -->
5429
6444
  <xsl:text>&lt;</xsl:text>
@@ -5454,7 +6469,9 @@
5454
6469
  <!-- replace start and end spaces to non-break space -->
5455
6470
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
5456
6471
  </xsl:copy>
5457
- </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">
6472
+ </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">
6473
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
6474
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5458
6475
  <xsl:variable name="target">
5459
6476
  <xsl:choose>
5460
6477
  <xsl:when test="@updatetype = 'true'">
@@ -6049,18 +7066,33 @@
6049
7066
  </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
6050
7067
  <xsl:copy>
6051
7068
  <xsl:apply-templates select="@*" mode="svg_update"/>
6052
- <xsl:variable name="viewbox">
7069
+ <xsl:variable name="viewbox_">
6053
7070
  <xsl:call-template name="split">
6054
7071
  <xsl:with-param name="pText" select="@viewBox"/>
6055
7072
  <xsl:with-param name="sep" select="' '"/>
6056
7073
  </xsl:call-template>
6057
7074
  </xsl:variable>
7075
+ <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
7076
+ <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7077
+ <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7078
+
6058
7079
  <xsl:attribute name="width">
6059
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
7080
+ <xsl:choose>
7081
+ <xsl:when test="$width != ''">
7082
+ <xsl:value-of select="round($width)"/>
7083
+ </xsl:when>
7084
+ <xsl:otherwise>400</xsl:otherwise> <!-- default width -->
7085
+ </xsl:choose>
6060
7086
  </xsl:attribute>
6061
7087
  <xsl:attribute name="height">
6062
- <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
7088
+ <xsl:choose>
7089
+ <xsl:when test="$height != ''">
7090
+ <xsl:value-of select="round($height)"/>
7091
+ </xsl:when>
7092
+ <xsl:otherwise>400</xsl:otherwise> <!-- default height -->
7093
+ </xsl:choose>
6063
7094
  </xsl:attribute>
7095
+
6064
7096
  <xsl:apply-templates mode="svg_update"/>
6065
7097
  </xsl:copy>
6066
7098
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
@@ -6255,7 +7287,11 @@
6255
7287
  <xsl:apply-templates mode="bookmarks"/>
6256
7288
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
6257
7289
  <xsl:apply-templates select="."/>
6258
- </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">
7290
+ </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">
7291
+ <xsl:apply-templates mode="contents"/>
7292
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
7293
+ <xsl:apply-templates mode="bookmarks"/>
7294
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
6259
7295
  <xsl:apply-templates mode="bookmarks"/>
6260
7296
  </xsl:template><xsl:template name="addBookmarks">
6261
7297
  <xsl:param name="contents"/>
@@ -6537,7 +7573,9 @@
6537
7573
  <xsl:apply-templates/>
6538
7574
  </xsl:otherwise>
6539
7575
  </xsl:choose>
6540
- </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">
7576
+ </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">
7577
+ <xsl:value-of select="."/>
7578
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6541
7579
  <xsl:text> </xsl:text>
6542
7580
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6543
7581
  <xsl:copy>
@@ -6568,9 +7606,22 @@
6568
7606
  </xsl:when>
6569
7607
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6570
7608
  </xsl:choose>
7609
+ </xsl:template><xsl:template match="text()" mode="contents_item">
7610
+ <xsl:call-template name="keep_together_standard_number"/>
7611
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
7612
+ <xsl:apply-templates mode="contents_item"/>
6571
7613
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6572
7614
 
6573
7615
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7616
+
7617
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7618
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7619
+ </xsl:if>
7620
+
7621
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7622
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7623
+ </xsl:if>
7624
+
6574
7625
  <xsl:copy-of select="@id"/>
6575
7626
 
6576
7627
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6941,7 +7992,9 @@
6941
7992
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
6942
7993
  </xsl:if>
6943
7994
  <xsl:variable name="simple-table">
6944
- <xsl:call-template name="getSimpleTable"/>
7995
+ <xsl:call-template name="getSimpleTable">
7996
+ <xsl:with-param name="id" select="@id"/>
7997
+ </xsl:call-template>
6945
7998
  </xsl:variable>
6946
7999
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
6947
8000
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -7048,39 +8101,67 @@
7048
8101
  </xsl:otherwise>
7049
8102
  </xsl:choose>
7050
8103
  </xsl:template><xsl:template match="*[local-name() = 'example']">
7051
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
7052
-
8104
+
8105
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
8106
+
7053
8107
 
8108
+
7054
8109
  <xsl:variable name="fo_element">
7055
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
8110
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
7056
8111
  inline
7057
8112
  </xsl:variable>
7058
8113
 
7059
- <!-- display 'EXAMPLE' -->
7060
- <xsl:apply-templates select="*[local-name()='name']">
7061
- <xsl:with-param name="fo_element" select="$fo_element"/>
7062
- </xsl:apply-templates>
8114
+ <fo:block-container margin-left="0mm">
7063
8115
 
7064
- <xsl:choose>
7065
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
7066
- <fo:block-container xsl:use-attribute-sets="example-body-style">
7067
- <fo:block-container margin-left="0mm" margin-right="0mm">
7068
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8116
+ <xsl:choose>
8117
+
8118
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
8119
+
8120
+ <!-- display name 'EXAMPLE' in a separate block -->
8121
+ <fo:block>
8122
+ <xsl:apply-templates select="*[local-name()='name']">
7069
8123
  <xsl:with-param name="fo_element" select="$fo_element"/>
7070
8124
  </xsl:apply-templates>
8125
+ </fo:block>
8126
+
8127
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8128
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8129
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8130
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8131
+ </xsl:apply-templates>
8132
+ </fo:block-container>
7071
8133
  </fo:block-container>
7072
- </fo:block-container>
7073
- </xsl:when>
7074
- <xsl:otherwise>
7075
- <fo:inline>
7076
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7077
- <xsl:with-param name="fo_element" select="$fo_element"/>
7078
- </xsl:apply-templates>
7079
- </fo:inline>
7080
- </xsl:otherwise>
7081
- </xsl:choose>
7082
-
7083
- </fo:block>
8134
+ </xsl:when> <!-- end block -->
8135
+
8136
+ <xsl:otherwise> <!-- inline -->
8137
+
8138
+ <!-- display 'EXAMPLE' and first element in the same line -->
8139
+ <fo:block>
8140
+ <xsl:apply-templates select="*[local-name()='name']">
8141
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8142
+ </xsl:apply-templates>
8143
+ <fo:inline>
8144
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
8145
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8146
+ </xsl:apply-templates>
8147
+ </fo:inline>
8148
+ </fo:block>
8149
+
8150
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
8151
+ <!-- display further elements in blocks -->
8152
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8153
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8154
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
8155
+ <xsl:with-param name="fo_element" select="'block'"/>
8156
+ </xsl:apply-templates>
8157
+ </fo:block-container>
8158
+ </fo:block-container>
8159
+ </xsl:if>
8160
+ </xsl:otherwise> <!-- end inline -->
8161
+
8162
+ </xsl:choose>
8163
+ </fo:block-container>
8164
+ </fo:block-container>
7084
8165
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
7085
8166
  <xsl:param name="fo_element">block</xsl:param>
7086
8167
 
@@ -7117,10 +8198,16 @@
7117
8198
  </xsl:variable>
7118
8199
  <xsl:choose>
7119
8200
  <xsl:when test="starts-with(normalize-space($element), 'block')">
7120
- <fo:block xsl:use-attribute-sets="example-p-style">
7121
-
7122
- <xsl:apply-templates/>
7123
- </fo:block>
8201
+ <fo:block-container>
8202
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
8203
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
8204
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
8205
+ </xsl:if>
8206
+ <fo:block xsl:use-attribute-sets="example-p-style">
8207
+
8208
+ <xsl:apply-templates/>
8209
+ </fo:block>
8210
+ </fo:block-container>
7124
8211
  </xsl:when>
7125
8212
  <xsl:otherwise>
7126
8213
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -7299,7 +8386,16 @@
7299
8386
  </fo:inline>
7300
8387
  </xsl:when>
7301
8388
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7302
- <fo:inline><xsl:apply-templates/></fo:inline>
8389
+
8390
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
8391
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
8392
+ <xsl:choose>
8393
+ <xsl:when test="$uri_src != ''">
8394
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
8395
+ </xsl:when>
8396
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
8397
+ </xsl:choose>
8398
+
7303
8399
  </xsl:otherwise>
7304
8400
  </xsl:choose>
7305
8401
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7475,10 +8571,24 @@
7475
8571
 
7476
8572
  </fo:block>
7477
8573
  <xsl:apply-templates/>
7478
- </xsl:template><xsl:template match="*[local-name() = 'review']">
8574
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7479
8575
  <!-- comment 2019-11-29 -->
7480
8576
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7481
8577
  <xsl:apply-templates /> -->
8578
+
8579
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
8580
+
8581
+ <xsl:choose>
8582
+ <!-- if there isn't the attribute '@from', then -->
8583
+ <xsl:when test="$id_from = ''">
8584
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8585
+ </xsl:when>
8586
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
8587
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
8588
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8589
+ </xsl:when>
8590
+ </xsl:choose>
8591
+
7482
8592
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7483
8593
  <!-- 0xA0 to space replacement -->
7484
8594
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7835,7 +8945,10 @@
7835
8945
  <!-- to split by '_' and other chars -->
7836
8946
  <xsl:call-template name="add-zero-spaces-java"/>
7837
8947
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7838
- <fo:inline id="{@id}" font-size="1pt"/>
8948
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
8949
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
8950
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
8951
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7839
8952
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7840
8953
  <!-- <row>
7841
8954
  <date>05-07-2013</date>
@@ -8371,6 +9484,8 @@
8371
9484
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8372
9485
  </xsl:for-each>
8373
9486
  </xsl:copy>
9487
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9488
+ <xsl:apply-templates mode="update_xml_step1"/>
8374
9489
  </xsl:template>
8375
9490
  <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
8376
9491
  <xsl:template match="@*|node()" mode="update_xml_step2">
@@ -8433,7 +9548,127 @@
8433
9548
  </xsl:template>
8434
9549
 
8435
9550
  <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
8436
- <xsl:template name="convertDate">
9551
+ <xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9552
+ <xsl:copy>
9553
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
9554
+ </xsl:copy>
9555
+ </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">
9556
+
9557
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
9558
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9559
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9560
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9561
+ <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))"/>
9562
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9563
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9564
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9565
+ <xsl:with-param name="text" select="$text_"/>
9566
+ </xsl:call-template></text></xsl:variable>
9567
+
9568
+ <xsl:variable name="parent" select="local-name(..)"/>
9569
+
9570
+ <xsl:variable name="text2">
9571
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
9572
+
9573
+ <xsl:choose>
9574
+ <!-- if EXPRESS reference -->
9575
+ <xsl:when test="self::text() and $parent = 'strong' and translate(., $express_reference_characters, '') = ''">
9576
+ <xsl:element name="{$element_name_keep-together_within-line}"><xsl:value-of select="."/></xsl:element>
9577
+ </xsl:when>
9578
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9579
+ </xsl:choose>
9580
+
9581
+ </xsl:for-each></text>
9582
+ </xsl:variable>
9583
+
9584
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9585
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
9586
+ <xsl:variable name="text3">
9587
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9588
+ <xsl:choose>
9589
+ <xsl:when test="self::text()">
9590
+ <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))"/>
9591
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
9592
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9593
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9594
+ <xsl:with-param name="text" select="$text_units_"/>
9595
+ </xsl:call-template></text></xsl:variable>
9596
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
9597
+ </xsl:when>
9598
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9599
+ </xsl:choose>
9600
+ </xsl:for-each></text>
9601
+ </xsl:variable>
9602
+
9603
+ <xsl:choose>
9604
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9605
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9606
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9607
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9608
+ <xsl:choose>
9609
+ <xsl:when test="self::text()">
9610
+ <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))"/>
9611
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
9612
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9613
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9614
+ <xsl:with-param name="text" select="$text_dots_"/>
9615
+ </xsl:call-template></text></xsl:variable>
9616
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
9617
+ </xsl:when>
9618
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9619
+ </xsl:choose>
9620
+ </xsl:for-each>
9621
+ </xsl:when>
9622
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
9623
+ </xsl:choose>
9624
+
9625
+ </xsl:template><xsl:template name="replace_text_tags">
9626
+ <xsl:param name="tag_open"/>
9627
+ <xsl:param name="tag_close"/>
9628
+ <xsl:param name="text"/>
9629
+ <xsl:choose>
9630
+ <xsl:when test="contains($text, $tag_open)">
9631
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
9632
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
9633
+
9634
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
9635
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
9636
+ </xsl:element>
9637
+
9638
+ <xsl:call-template name="replace_text_tags">
9639
+ <xsl:with-param name="tag_open" select="$tag_open"/>
9640
+ <xsl:with-param name="tag_close" select="$tag_close"/>
9641
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
9642
+ </xsl:call-template>
9643
+ </xsl:when>
9644
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
9645
+ </xsl:choose>
9646
+ </xsl:template><xsl:template name="printEdition">
9647
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
9648
+ <xsl:text> </xsl:text>
9649
+ <xsl:choose>
9650
+ <xsl:when test="$edition_i18n != ''">
9651
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
9652
+ <xsl:call-template name="capitalize">
9653
+ <xsl:with-param name="str" select="$edition_i18n"/>
9654
+ </xsl:call-template>
9655
+ </xsl:when>
9656
+ <xsl:otherwise>
9657
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
9658
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
9659
+ <xsl:call-template name="capitalize">
9660
+ <xsl:with-param name="str">
9661
+ <xsl:call-template name="getLocalizedString">
9662
+ <xsl:with-param name="key">edition</xsl:with-param>
9663
+ </xsl:call-template>
9664
+ </xsl:with-param>
9665
+ </xsl:call-template>
9666
+ <xsl:text> </xsl:text>
9667
+ <xsl:value-of select="$edition"/>
9668
+ </xsl:if>
9669
+ </xsl:otherwise>
9670
+ </xsl:choose>
9671
+ </xsl:template><xsl:template name="convertDate">
8437
9672
  <xsl:param name="date"/>
8438
9673
  <xsl:param name="format" select="'short'"/>
8439
9674
  <xsl:variable name="year" select="substring($date, 1, 4)"/>
@@ -9120,4 +10355,40 @@
9120
10355
  <xsl:value-of select="$value"/>
9121
10356
  </xsl:otherwise>
9122
10357
  </xsl:choose>
10358
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
10359
+ <xsl:param name="level">0</xsl:param>
10360
+
10361
+ <fo:block margin-left="{2*$level}mm">
10362
+ <xsl:text>
10363
+ &lt;</xsl:text>
10364
+ <xsl:value-of select="local-name()"/>
10365
+ <xsl:for-each select="@*">
10366
+ <xsl:text> </xsl:text>
10367
+ <xsl:value-of select="local-name()"/>
10368
+ <xsl:text>="</xsl:text>
10369
+ <xsl:value-of select="."/>
10370
+ <xsl:text>"</xsl:text>
10371
+ </xsl:for-each>
10372
+ <xsl:text>&gt;</xsl:text>
10373
+
10374
+ <xsl:if test="not(*)">
10375
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
10376
+ <xsl:text>&lt;/</xsl:text>
10377
+ <xsl:value-of select="local-name()"/>
10378
+ <xsl:text>&gt;</xsl:text>
10379
+ </xsl:if>
10380
+ </fo:block>
10381
+
10382
+ <xsl:if test="*">
10383
+ <fo:block>
10384
+ <xsl:apply-templates mode="print_as_xml">
10385
+ <xsl:with-param name="level" select="$level + 1"/>
10386
+ </xsl:apply-templates>
10387
+ </fo:block>
10388
+ <fo:block margin-left="{2*$level}mm">
10389
+ <xsl:text>&lt;/</xsl:text>
10390
+ <xsl:value-of select="local-name()"/>
10391
+ <xsl:text>&gt;</xsl:text>
10392
+ </fo:block>
10393
+ </xsl:if>
9123
10394
  </xsl:template></xsl:stylesheet>