metanorma-iso 2.0.8.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +169 -0
  3. data/lib/isodoc/iso/base_convert.rb +11 -1
  4. data/lib/isodoc/iso/html/html_iso_titlepage.html +7 -0
  5. data/lib/isodoc/iso/html/isodoc-dis.css +407 -427
  6. data/lib/isodoc/iso/html/isodoc-dis.scss +482 -438
  7. data/lib/isodoc/iso/html/isodoc.css +38 -13
  8. data/lib/isodoc/iso/html/isodoc.scss +38 -12
  9. data/lib/isodoc/iso/html/style-human.css +14 -1
  10. data/lib/isodoc/iso/html/style-human.scss +10 -1
  11. data/lib/isodoc/iso/html/style-iso.css +35 -23
  12. data/lib/isodoc/iso/html/style-iso.scss +31 -23
  13. data/lib/isodoc/iso/html/word_iso_intro-dis.html +3 -1
  14. data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +26 -13
  15. data/lib/isodoc/iso/html/word_iso_titlepage-prf.html +58 -0
  16. data/lib/isodoc/iso/html/word_iso_titlepage.html +16 -6
  17. data/lib/isodoc/iso/html/wordstyle-dis.css +168 -48
  18. data/lib/isodoc/iso/html/wordstyle-dis.scss +158 -43
  19. data/lib/isodoc/iso/html_convert.rb +7 -2
  20. data/lib/isodoc/iso/i18n-en.yaml +33 -4
  21. data/lib/isodoc/iso/i18n-fr.yaml +30 -3
  22. data/lib/isodoc/iso/i18n-ru.yaml +33 -4
  23. data/lib/isodoc/iso/i18n-zh-Hans.yaml +33 -3
  24. data/lib/isodoc/iso/i18n.rb +1 -1
  25. data/lib/isodoc/iso/init.rb +17 -1
  26. data/lib/isodoc/iso/iso.amendment.xsl +1711 -367
  27. data/lib/isodoc/iso/iso.international-standard.xsl +1711 -367
  28. data/lib/isodoc/iso/metadata.rb +72 -78
  29. data/lib/isodoc/iso/presentation_bibdata.rb +74 -0
  30. data/lib/isodoc/iso/presentation_xml_convert.rb +52 -100
  31. data/lib/isodoc/iso/presentation_xref.rb +132 -0
  32. data/lib/isodoc/iso/sections.rb +3 -3
  33. data/lib/isodoc/iso/word_cleanup.rb +17 -0
  34. data/lib/isodoc/iso/word_convert.rb +32 -12
  35. data/lib/isodoc/iso/word_dis_cleanup.rb +235 -0
  36. data/lib/isodoc/iso/word_dis_convert.rb +122 -0
  37. data/lib/isodoc/iso/xref.rb +78 -29
  38. data/lib/metanorma/iso/base.rb +20 -1
  39. data/lib/metanorma/iso/biblio.rng +69 -42
  40. data/lib/metanorma/iso/boilerplate-fr.xml +4 -1
  41. data/lib/metanorma/iso/boilerplate-ru.xml +4 -3
  42. data/lib/metanorma/iso/boilerplate.xml +4 -3
  43. data/lib/metanorma/iso/cleanup.rb +29 -1
  44. data/lib/metanorma/iso/front.rb +31 -6
  45. data/lib/metanorma/iso/front_id.rb +2 -0
  46. data/lib/metanorma/iso/isodoc.rng +65 -0
  47. data/lib/metanorma/iso/isostandard.rng +30 -12
  48. data/lib/metanorma/iso/macros.rb +29 -0
  49. data/lib/metanorma/iso/version.rb +1 -1
  50. data/lib/metanorma-iso.rb +1 -0
  51. data/lib/relaton/render/config.yml +4 -0
  52. data/lib/relaton/render/general.rb +13 -0
  53. data/metanorma-iso.gemspec +1 -1
  54. data/spec/isodoc/amd_spec.rb +35 -60
  55. data/spec/isodoc/blocks_spec.rb +783 -179
  56. data/spec/isodoc/i18n_spec.rb +331 -100
  57. data/spec/isodoc/inline_spec.rb +35 -42
  58. data/spec/isodoc/iso_spec.rb +51 -170
  59. data/spec/isodoc/metadata_spec.rb +240 -99
  60. data/spec/isodoc/postproc_spec.rb +68 -7
  61. data/spec/isodoc/ref_spec.rb +66 -69
  62. data/spec/isodoc/section_spec.rb +88 -80
  63. data/spec/isodoc/table_spec.rb +2 -2
  64. data/spec/isodoc/terms_spec.rb +2 -2
  65. data/spec/isodoc/word_dis_spec.rb +1886 -0
  66. data/spec/isodoc/xref_spec.rb +138 -64
  67. data/spec/metanorma/amd_spec.rb +53 -1
  68. data/spec/metanorma/base_spec.rb +195 -20
  69. data/spec/metanorma/blocks_spec.rb +54 -0
  70. data/spec/metanorma/lists_spec.rb +2 -2
  71. data/spec/metanorma/section_spec.rb +2 -2
  72. data/spec/spec_helper.rb +23 -4
  73. data/spec/vcr_cassettes/withdrawn_iso.yml +25 -25
  74. metadata +15 -10
  75. data/docs/asciiiso-syntax.adoc +0 -307
  76. data/docs/guidance.adoc +0 -487
  77. data/docs/navigation.adoc +0 -23
  78. data/docs/quickstart.adoc +0 -179
  79. data/spec/vcr_cassettes/docrels.yml +0 -385
@@ -194,6 +194,73 @@
194
194
  </xsl:for-each>
195
195
  </xsl:variable>
196
196
 
197
+ <xsl:variable name="editorialgroup_">
198
+ <!-- Example: ISO/TC 46/SC 2 -->
199
+ <!-- ISO/SG SMART/SG TS/AG 1 -->
200
+ <xsl:variable name="approvalgroup" select="normalize-space(/iso:iso-standard/iso:bibdata/iso:ext/iso:approvalgroup/@identifier)"/>
201
+ <xsl:variable name="parts_by_slash">
202
+ <xsl:call-template name="split">
203
+ <xsl:with-param name="pText" select="$approvalgroup"/>
204
+ <xsl:with-param name="sep" select="'/'"/>
205
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
206
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
207
+ </xsl:call-template>
208
+ </xsl:variable>
209
+ <xsl:variable name="parts_with_subparts">
210
+ <xsl:for-each select="xalan:nodeset($parts_by_slash)//item">
211
+ <subitem>
212
+ <xsl:call-template name="split">
213
+ <xsl:with-param name="pText" select="."/>
214
+ <xsl:with-param name="sep" select="' '"/>
215
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
216
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
217
+ </xsl:call-template>
218
+ </subitem>
219
+ </xsl:for-each>
220
+ </xsl:variable>
221
+ <xsl:for-each select="xalan:nodeset($parts_with_subparts)//subitem">
222
+ <xsl:choose>
223
+ <xsl:when test="position() = 1">
224
+ <xsl:value-of select="."/>
225
+ </xsl:when>
226
+ <xsl:otherwise>
227
+ <xsl:for-each select="item">
228
+ <xsl:choose>
229
+ <xsl:when test="position() = last()">
230
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
231
+ </xsl:when>
232
+ <xsl:otherwise>
233
+ <xsl:value-of select="."/>
234
+ </xsl:otherwise>
235
+ </xsl:choose>
236
+ </xsl:for-each>
237
+ </xsl:otherwise>
238
+ </xsl:choose>
239
+ </xsl:for-each>
240
+ </xsl:variable>
241
+ <xsl:variable name="editorialgroup" select="xalan:nodeset($editorialgroup_)"/>
242
+
243
+ <xsl:variable name="secretariat_">
244
+ <xsl:variable name="value" select="normalize-space(/iso:iso-standard/iso:bibdata/iso:ext/iso:editorialgroup/iso:secretariat)"/>
245
+ <xsl:if test="$value != ''">
246
+ <xsl:call-template name="getLocalizedString">
247
+ <xsl:with-param name="key">secretariat</xsl:with-param>
248
+ </xsl:call-template>
249
+ <xsl:text>: </xsl:text>
250
+ <fo:inline font-weight="bold"><xsl:value-of select="$value"/></fo:inline>
251
+ </xsl:if>
252
+ </xsl:variable>
253
+ <xsl:variable name="secretariat" select="xalan:nodeset($secretariat_)"/>
254
+
255
+ <xsl:variable name="ics_">
256
+ <xsl:for-each select="/iso:iso-standard/iso:bibdata/iso:ext/iso:ics/iso:code">
257
+ <xsl:if test="position() = 1"><fo:inline>ICS: </fo:inline></xsl:if>
258
+ <xsl:value-of select="."/>
259
+ <xsl:if test="position() != last()"><xsl:text>; </xsl:text></xsl:if>
260
+ </xsl:for-each>
261
+ </xsl:variable>
262
+ <xsl:variable name="ics" select="xalan:nodeset($ics_)"/>
263
+
197
264
  <xsl:variable name="XML" select="/"/>
198
265
 
199
266
  <xsl:template match="/">
@@ -223,25 +290,25 @@
223
290
  </fo:simple-page-master>
224
291
 
225
292
  <fo:simple-page-master master-name="cover-page-published" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
226
- <fo:region-body margin-top="12.7mm" margin-bottom="40mm" margin-left="78mm" margin-right="18.5mm"/>
293
+ <fo:region-body margin-top="12.7mm" margin-bottom="75mm" margin-left="78mm" margin-right="18.5mm"/>
227
294
  <fo:region-before region-name="cover-page-header" extent="12.7mm"/>
228
- <fo:region-after region-name="cover-page-footer" extent="40mm" display-align="after"/>
295
+ <fo:region-after region-name="cover-page-footer" extent="75mm" display-align="after"/>
229
296
  <fo:region-start region-name="cover-left-region" extent="78mm"/>
230
297
  <fo:region-end region-name="cover-right-region" extent="18.5mm"/>
231
298
  </fo:simple-page-master>
232
299
 
233
300
 
234
301
  <fo:simple-page-master master-name="cover-page-publishedISO-odd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
235
- <fo:region-body margin-top="12.7mm" margin-bottom="40mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
302
+ <fo:region-body margin-top="12.7mm" margin-bottom="75mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
236
303
  <fo:region-before region-name="cover-page-header" extent="12.7mm"/>
237
- <fo:region-after region-name="cover-page-footer" extent="40mm" display-align="after"/>
304
+ <fo:region-after region-name="cover-page-footer" extent="75mm" display-align="after"/>
238
305
  <fo:region-start region-name="cover-left-region" extent="{$marginLeftRight1}mm"/>
239
306
  <fo:region-end region-name="cover-right-region" extent="{$marginLeftRight2}mm"/>
240
307
  </fo:simple-page-master>
241
308
  <fo:simple-page-master master-name="cover-page-publishedISO-even" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
242
- <fo:region-body margin-top="12.7mm" margin-bottom="40mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
309
+ <fo:region-body margin-top="12.7mm" margin-bottom="75mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
243
310
  <fo:region-before region-name="cover-page-header" extent="12.7mm"/>
244
- <fo:region-after region-name="cover-page-footer" extent="40mm" display-align="after"/>
311
+ <fo:region-after region-name="cover-page-footer" extent="75mm" display-align="after"/>
245
312
  <fo:region-start region-name="cover-left-region" extent="{$marginLeftRight2}mm"/>
246
313
  <fo:region-end region-name="cover-right-region" extent="{$marginLeftRight1}mm"/>
247
314
  </fo:simple-page-master>
@@ -256,17 +323,17 @@
256
323
  <!-- contents pages -->
257
324
  <!-- odd pages -->
258
325
  <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"/>
326
+ <fo:region-body margin-top="27.4mm" margin-bottom="{$marginBottom + 2}mm" margin-left="19mm" margin-right="19mm"/>
260
327
  <fo:region-before region-name="header-odd" extent="27.4mm"/> <!-- display-align="center" -->
261
- <fo:region-after region-name="footer-odd" extent="13mm"/>
328
+ <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
262
329
  <fo:region-start region-name="left-region" extent="19mm"/>
263
330
  <fo:region-end region-name="right-region" extent="19mm"/>
264
331
  </fo:simple-page-master>
265
332
  <!-- even pages -->
266
333
  <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"/>
334
+ <fo:region-body margin-top="27.4mm" margin-bottom="{$marginBottom + 2}mm" margin-left="19mm" margin-right="19mm"/>
268
335
  <fo:region-before region-name="header-even" extent="27.4mm"/> <!-- display-align="center" -->
269
- <fo:region-after region-name="footer-even" extent="13mm"/>
336
+ <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
270
337
  <fo:region-start region-name="left-region" extent="19mm"/>
271
338
  <fo:region-end region-name="right-region" extent="19mm"/>
272
339
  </fo:simple-page-master>
@@ -286,7 +353,7 @@
286
353
 
287
354
  <!-- first page -->
288
355
  <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"/>
356
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
290
357
  <fo:region-before region-name="header-first" extent="{$marginTop}mm"/> <!-- display-align="center" -->
291
358
  <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
292
359
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
@@ -294,7 +361,7 @@
294
361
  </fo:simple-page-master>
295
362
  <!-- odd pages -->
296
363
  <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"/>
364
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
298
365
  <fo:region-before region-name="header-odd" extent="{$marginTop}mm"/> <!-- display-align="center" -->
299
366
  <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
300
367
  <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
@@ -302,14 +369,14 @@
302
369
  </fo:simple-page-master>
303
370
  <!-- even pages -->
304
371
  <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"/>
372
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
306
373
  <fo:region-before region-name="header-even" extent="{$marginTop}mm"/>
307
374
  <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
308
375
  <fo:region-start region-name="left-region" extent="{$marginLeftRight2}mm"/>
309
376
  <fo:region-end region-name="right-region" extent="{$marginLeftRight1}mm"/>
310
377
  </fo:simple-page-master>
311
378
  <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"/>
379
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom + 2}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
313
380
  <fo:region-before region-name="header" extent="{$marginTop}mm"/>
314
381
  <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
315
382
  <fo:region-start region-name="left" extent="{$marginLeftRight2}mm"/>
@@ -390,9 +457,9 @@
390
457
  <fo:table-column column-width="112.5mm"/>
391
458
  <fo:table-body>
392
459
  <fo:table-row>
393
- <fo:table-cell font-size="6.5pt" text-align="justify" display-align="after" padding-bottom="8mm"><!-- before -->
460
+ <fo:table-cell font-size="6.5pt" text-align="justify" display-align="after" padding-bottom="8mm">
394
461
  <!-- margin-top="-30mm" -->
395
- <fo:block margin-top="-100mm">
462
+ <fo:block> <!-- margin-top="-100mm" -->
396
463
  <xsl:if test="$stage-abbreviation = 'DIS' or $stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD'">
397
464
  <fo:block margin-bottom="1.5mm">
398
465
  <xsl:text>THIS DOCUMENT IS A DRAFT CIRCULATED FOR COMMENT AND APPROVAL. IT IS THEREFORE SUBJECT TO CHANGE AND MAY NOT BE REFERRED TO AS AN INTERNATIONAL STANDARD UNTIL PUBLISHED AS SUCH.</xsl:text>
@@ -422,17 +489,50 @@
422
489
  <fo:table-cell>
423
490
  <fo:block> </fo:block>
424
491
  </fo:table-cell>
425
- <fo:table-cell>
426
- <xsl:if test="$stage-abbreviation = 'DIS'">
427
- <fo:block-container margin-top="-15mm" margin-bottom="7mm" margin-left="1mm">
428
- <fo:block font-size="9pt" border="0.5pt solid black" fox:border-radius="5pt" padding-left="2mm" padding-top="2mm" padding-bottom="2mm">
429
- <xsl:text>This document is circulated as received from the committee secretariat.</xsl:text>
430
- </fo:block>
431
- </fo:block-container>
432
- </xsl:if>
492
+ <fo:table-cell display-align="after" padding-bottom="3mm">
493
+ <fo:block-container height="22.5mm" display-align="center">
494
+
495
+ <xsl:variable name="iso-fast-track">false</xsl:variable>
496
+
497
+ <xsl:if test="normalize-space($iso-fast-track) = 'true'">
498
+ <xsl:attribute name="height">28mm</xsl:attribute>
499
+ </xsl:if>
500
+
501
+ <fo:block>
502
+ <xsl:if test="$stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'DIS' or $stage-abbreviation = 'FDIS'">
503
+ <xsl:variable name="text">
504
+ <xsl:for-each select="/iso:iso-standard/iso:preface/iso:note[@coverpage='true']/iso:p">
505
+ <fo:block>
506
+ <xsl:apply-templates/>
507
+ </fo:block>
508
+ </xsl:for-each>
509
+ </xsl:variable>
510
+ <xsl:if test="normalize-space($text) != ''">
511
+ <fo:block-container margin-left="1mm"> <!-- margin-bottom="7mm" margin-top="-15mm" -->
512
+ <fo:block font-size="9pt" border="0.5pt solid black" fox:border-radius="5pt" padding-left="2mm" padding-top="2mm" padding-bottom="2mm">
513
+ <!-- <xsl:text>This document is circulated as received from the committee secretariat.</xsl:text> -->
514
+ <xsl:copy-of select="xalan:nodeset($text)/node()"/>
515
+ </fo:block>
516
+ </fo:block-container>
517
+ </xsl:if>
518
+
519
+ <xsl:if test="normalize-space($iso-fast-track) = 'true'">
520
+ <fo:block-container space-before="2mm">
521
+ <fo:block background-color="rgb(77,77,77)" color="white" fox:border-radius="5pt" text-align="center" display-align="center" font-size="19pt" font-weight="bold">
522
+ <fo:block-container height="13.2mm">
523
+ <fo:block>
524
+ <xsl:text>FAST TRACK PROCEDURE</xsl:text>
525
+ </fo:block>
526
+ </fo:block-container>
527
+ </fo:block>
528
+ </fo:block-container>
529
+ </xsl:if>
530
+ </xsl:if>
531
+ </fo:block>
532
+ </fo:block-container>
433
533
  <fo:block>
434
534
  <xsl:call-template name="insertTripleLine"/>
435
- <fo:table table-layout="fixed" width="100%" margin-bottom="3mm">
535
+ <fo:table table-layout="fixed" width="100%"> <!-- margin-bottom="3mm" -->
436
536
  <fo:table-column column-width="50%"/>
437
537
  <fo:table-column column-width="50%"/>
438
538
  <fo:table-body>
@@ -503,16 +603,14 @@
503
603
  <fo:block> </fo:block>
504
604
  </fo:table-cell>
505
605
  <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>
606
+ <fo:block margin-bottom="3mm">
607
+ <xsl:copy-of select="$editorialgroup"/>
507
608
  </fo:block>
508
609
  </fo:table-cell>
509
610
  <fo:table-cell>
510
611
  <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>
612
+ <xsl:copy-of select="$secretariat"/>
613
+ </fo:block>
516
614
  </fo:table-cell>
517
615
  </fo:table-row>
518
616
  <fo:table-row>
@@ -598,11 +696,7 @@
598
696
  </fo:block>
599
697
 
600
698
  <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>
699
+ <xsl:copy-of select="$ics"/>
606
700
  </fo:block>
607
701
 
608
702
  </fo:block-container>
@@ -611,7 +705,7 @@
611
705
  </fo:block-container>
612
706
  </fo:flow>
613
707
 
614
- </xsl:when>
708
+ </xsl:when> <!-- END: $stage-abbreviation = 'DIS' -->
615
709
  <xsl:otherwise>
616
710
 
617
711
  <!-- COVER PAGE for all documents except DIS -->
@@ -671,13 +765,17 @@
671
765
  </fo:block>
672
766
  </fo:table-cell>
673
767
  </fo:table-row>
674
- <fo:table-row height="42mm">
768
+ <fo:table-row height="25mm">
675
769
  <fo:table-cell number-columns-spanned="3" font-size="10pt" line-height="1.2">
676
770
  <fo:block text-align="right">
677
771
  <xsl:if test="$stage-abbreviation = 'PRF' or $stage-abbreviation = 'IS' or $stage-abbreviation = 'D' or $stage-abbreviation = 'published'">
678
772
  <xsl:call-template name="printEdition"/>
679
773
  </xsl:if>
680
774
  <xsl:choose>
775
+ <xsl:when test="($stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'FDIS') and /iso:iso-standard/iso:bibdata/iso:version/iso:revision-date">
776
+ <xsl:value-of select="$linebreak"/>
777
+ <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:version/iso:revision-date"/>
778
+ </xsl:when>
681
779
  <xsl:when test="$stage-abbreviation = 'IS' and /iso:iso-standard/iso:bibdata/iso:date[@type = 'published']">
682
780
  <xsl:value-of select="$linebreak"/>
683
781
  <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:date[@type = 'published']"/>
@@ -706,13 +804,40 @@
706
804
  </fo:block>
707
805
  <fo:block>
708
806
  <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']"/>
807
+ <xsl:value-of select="/iso:iso-standard/iso:bibdata/iso:date[@type = 'updated']"/>
710
808
  </xsl:if>
711
809
  </fo:block>
712
810
  </fo:block>
713
811
  </xsl:if>
714
812
  </fo:table-cell>
715
813
  </fo:table-row>
814
+ <fo:table-row height="17mm">
815
+ <fo:table-cell><fo:block/></fo:table-cell>
816
+ <fo:table-cell number-columns-spanned="2" font-size="10pt" line-height="1.2" display-align="center">
817
+ <fo:block>
818
+ <xsl:if test="$stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'FDIS'">
819
+ <fo:table table-layout="fixed" width="100%">
820
+ <fo:table-column column-width="50%"/>
821
+ <fo:table-column column-width="50%"/>
822
+ <fo:table-body>
823
+ <fo:table-row>
824
+ <fo:table-cell>
825
+ <fo:block>
826
+ <xsl:copy-of select="$editorialgroup"/>
827
+ </fo:block>
828
+ </fo:table-cell>
829
+ <fo:table-cell>
830
+ <fo:block>
831
+ <xsl:copy-of select="$secretariat"/>
832
+ </fo:block>
833
+ </fo:table-cell>
834
+ </fo:table-row>
835
+ </fo:table-body>
836
+ </fo:table>
837
+ </xsl:if>
838
+ </fo:block>
839
+ </fo:table-cell>
840
+ </fo:table-row>
716
841
 
717
842
  </fo:table-body>
718
843
  </fo:table>
@@ -729,8 +854,8 @@
729
854
  <xsl:if test="$stage-abbreviation = 'FDIS'">
730
855
  <fo:block-container border="0.5mm solid black" width="51mm">
731
856
  <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>
857
+ <fo:block margin-bottom="8pt"><xsl:copy-of select="$editorialgroup"/></fo:block>
858
+ <fo:block margin-bottom="6pt"><xsl:value-of select="$secretariat"/></fo:block>
734
859
  <fo:block margin-bottom="6pt">Voting begins on:<xsl:value-of select="$linebreak"/>
735
860
  <fo:inline font-weight="bold">
736
861
  <xsl:choose>
@@ -802,6 +927,12 @@
802
927
  </fo:block>
803
928
  </xsl:for-each>
804
929
 
930
+ <xsl:if test="$stage-abbreviation = 'NWIP' or $stage-abbreviation = 'NP' or $stage-abbreviation = 'PWI' or $stage-abbreviation = 'AWI' or $stage-abbreviation = 'WD' or $stage-abbreviation = 'CD' or $stage-abbreviation = 'FDIS'">
931
+ <fo:block margin-top="10mm">
932
+ <xsl:copy-of select="$ics"/>
933
+ </fo:block>
934
+ </xsl:if>
935
+
805
936
  </fo:block>
806
937
  </fo:block-container>
807
938
  </fo:table-cell>
@@ -958,41 +1089,21 @@
958
1089
  </xsl:otherwise>
959
1090
  </xsl:choose>
960
1091
 
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
1092
 
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) != '']">
1093
+ <xsl:if test="normalize-space($editorialgroup) != ''">
970
1094
  <!-- ISO/TC 34/SC 4/WG 3 -->
971
1095
  <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>
1096
+ <xsl:copy-of select="$editorialgroup"/>
984
1097
  </fo:block>
985
1098
  </xsl:if>
986
- <!-- Secretariat: AFNOR -->
987
1099
 
1100
+ <!-- Secretariat: AFNOR -->
988
1101
  <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"/>
1102
+ <xsl:value-of select="$secretariat"/>
991
1103
  <xsl:text> </xsl:text>
992
1104
  </fo:block>
993
-
994
-
995
-
1105
+
1106
+
996
1107
  </fo:block-container>
997
1108
  <fo:block-container font-size="16pt">
998
1109
  <!-- Information and documentation — Codes for transcription systems -->
@@ -1065,7 +1176,12 @@
1065
1176
  </xsl:variable>
1066
1177
  <!-- DEBUG: updated_xml_step2=<xsl:copy-of select="$updated_xml_step2"/> -->
1067
1178
 
1068
- <xsl:for-each select="xalan:nodeset($updated_xml_step2)">
1179
+ <xsl:variable name="updated_xml_step3">
1180
+ <xsl:apply-templates select="xalan:nodeset($updated_xml_step2)" mode="update_xml_enclose_keep-together_within-line"/>
1181
+ </xsl:variable>
1182
+ <!-- DEBUG: updated_xml_step3=<xsl:copy-of select="$updated_xml_step3"/> -->
1183
+
1184
+ <xsl:for-each select="xalan:nodeset($updated_xml_step3)">
1069
1185
 
1070
1186
  <fo:page-sequence master-reference="preface{$document-master-reference}" format="i" force-page-count="{$force-page-count-preface}">
1071
1187
  <xsl:call-template name="insertHeaderFooter">
@@ -1159,7 +1275,12 @@
1159
1275
 
1160
1276
  <fo:inline keep-together.within-line="always">
1161
1277
  <fo:leader font-size="9pt" font-weight="normal" leader-pattern="dots"/>
1162
- <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
1278
+ <fo:inline>
1279
+ <xsl:if test="@level = 1 and @type = 'annex'">
1280
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
1281
+ </xsl:if>
1282
+ <fo:page-number-citation ref-id="{@id}"/>
1283
+ </fo:inline>
1163
1284
  </fo:inline>
1164
1285
  </fo:basic-link>
1165
1286
  </fo:block>
@@ -1377,6 +1498,7 @@
1377
1498
  </fo:block>
1378
1499
  </xsl:template>
1379
1500
 
1501
+
1380
1502
  <!-- ==================== -->
1381
1503
  <!-- display titles -->
1382
1504
  <!-- ==================== -->
@@ -1707,6 +1829,7 @@
1707
1829
 
1708
1830
  <xsl:template match="iso:p" name="paragraph">
1709
1831
  <xsl:param name="inline" select="'false'"/>
1832
+ <xsl:param name="split_keep-within-line"/>
1710
1833
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
1711
1834
  <xsl:variable name="element-name">
1712
1835
  <xsl:choose>
@@ -1736,7 +1859,9 @@
1736
1859
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
1737
1860
  <xsl:attribute name="line-height">0</xsl:attribute>
1738
1861
  </xsl:if>
1739
- <xsl:apply-templates/>
1862
+ <xsl:apply-templates>
1863
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1864
+ </xsl:apply-templates>
1740
1865
  </xsl:element>
1741
1866
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
1742
1867
  <fo:block margin-bottom="12pt">
@@ -1951,34 +2076,43 @@
1951
2076
  <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
2077
  </xsl:variable>
1953
2078
 
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>
2079
+ <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:param name="add_math_as_text">true</xsl:param><xsl:param name="table_if">false</xsl:param><xsl:param name="table_widths"/><xsl:variable name="table_widths_from_if" select="xalan:nodeset($table_widths)"/><xsl:variable name="table_widths_from_if_calculated_">
2080
+ <xsl:for-each select="$table_widths_from_if//table">
2081
+ <xsl:copy>
2082
+ <xsl:copy-of select="@*"/>
2083
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
2084
+ </xsl:copy>
2085
+ </xsl:for-each>
2086
+ </xsl:variable><xsl:variable name="table_widths_from_if_calculated" select="xalan:nodeset($table_widths_from_if_calculated_)"/><xsl:param name="table_if_debug">false</xsl:param><xsl:variable name="isGenerateTableIF_">
2087
+
2088
+ <xsl:value-of select="normalize-space($table_if) = 'true'"/>
2089
+
2090
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
2091
+ <xsl:call-template name="getLang"/>
2092
+ </xsl:variable><xsl:variable name="papersize" select="java:toLowerCase(java:java.lang.String.new(normalize-space(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata']/*[local-name() = 'papersize'])))"/><xsl:variable name="papersize_width_">
1957
2093
  <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>
2094
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
2095
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
2096
+ </xsl:choose>
2097
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
2098
+ <xsl:choose>
2099
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
2100
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
2101
+ </xsl:choose>
2102
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
2103
+ <xsl:choose>
2104
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
2105
+ <xsl:otherwise>
2106
+ 210
2107
+ </xsl:otherwise>
1966
2108
  </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:param name="add_math_as_text">true</xsl:param><xsl:variable name="lang">
1977
- <xsl:call-template name="getLang"/>
1978
- </xsl:variable><xsl:variable name="pageWidth_">
1979
- 210
1980
2109
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
1981
- 297
2110
+ <xsl:choose>
2111
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
2112
+ <xsl:otherwise>
2113
+ 297
2114
+ </xsl:otherwise>
2115
+ </xsl:choose>
1982
2116
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
1983
2117
  25
1984
2118
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -1988,20 +2122,7 @@
1988
2122
  </xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
1989
2123
  13
1990
2124
  </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
2125
 
2002
- <title-edition lang="ru">
2003
- <xsl:text>Издание </xsl:text>
2004
- </title-edition>
2005
2126
 
2006
2127
  <!-- These titles of Table of contents renders different than determined in localized-strings -->
2007
2128
  <title-toc lang="en">
@@ -2086,7 +2207,7 @@
2086
2207
  </xsl:variable><xsl:variable name="bibdata">
2087
2208
  <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
2088
2209
  <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">
2210
+ </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
2211
  <xsl:param name="name"/>
2091
2212
  <xsl:param name="lang"/>
2092
2213
  <xsl:variable name="lang_">
@@ -2134,7 +2255,7 @@
2134
2255
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
2135
2256
 
2136
2257
  <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']">
2258
+ <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
2259
  <xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
2139
2260
  </xsl:for-each>
2140
2261
  </xsl:variable>
@@ -2214,7 +2335,6 @@
2214
2335
 
2215
2336
 
2216
2337
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
2217
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2218
2338
 
2219
2339
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
2220
2340
  <xsl:attribute name="white-space">pre</xsl:attribute>
@@ -2301,6 +2421,10 @@
2301
2421
 
2302
2422
 
2303
2423
 
2424
+
2425
+ <xsl:attribute name="margin-left">7mm</xsl:attribute>
2426
+ <xsl:attribute name="margin-right">7mm</xsl:attribute>
2427
+
2304
2428
 
2305
2429
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2306
2430
 
@@ -2309,6 +2433,7 @@
2309
2433
 
2310
2434
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2311
2435
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
2436
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2312
2437
 
2313
2438
 
2314
2439
 
@@ -2466,6 +2591,7 @@
2466
2591
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2467
2592
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2468
2593
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2594
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2469
2595
  <xsl:attribute name="display-align">center</xsl:attribute>
2470
2596
 
2471
2597
 
@@ -2486,6 +2612,7 @@
2486
2612
  <xsl:attribute name="display-align">center</xsl:attribute>
2487
2613
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2488
2614
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2615
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
2489
2616
 
2490
2617
 
2491
2618
 
@@ -2580,7 +2707,8 @@
2580
2707
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
2581
2708
 
2582
2709
 
2583
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
2710
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
2711
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
2584
2712
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
2585
2713
 
2586
2714
 
@@ -2594,6 +2722,27 @@
2594
2722
 
2595
2723
 
2596
2724
 
2725
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
2726
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2727
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
2735
+
2736
+
2737
+
2738
+
2739
+
2740
+
2741
+
2742
+
2743
+
2744
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
2745
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
2597
2746
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
2598
2747
 
2599
2748
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -2918,6 +3067,25 @@
2918
3067
 
2919
3068
 
2920
3069
 
3070
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
3071
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
3072
+
3073
+
3074
+
3075
+
3076
+
3077
+
3078
+ <xsl:attribute name="margin-top">8pt</xsl:attribute>
3079
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
3080
+
3081
+
3082
+
3083
+
3084
+
3085
+
3086
+
3087
+
3088
+
2921
3089
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
2922
3090
 
2923
3091
 
@@ -3312,13 +3480,13 @@
3312
3480
 
3313
3481
  </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
3314
3482
  <xsl:variable name="nodes_preface_">
3315
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3483
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3316
3484
  <node id="{@id}"/>
3317
3485
  </xsl:for-each>
3318
3486
  </xsl:variable>
3319
3487
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
3320
3488
 
3321
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3489
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3322
3490
  <xsl:sort select="@displayorder" data-type="number"/>
3323
3491
 
3324
3492
  <!-- process Section's title -->
@@ -3384,7 +3552,7 @@
3384
3552
  </xsl:for-each>
3385
3553
  </figures>
3386
3554
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3387
- <xsl:for-each select="/*/*[local-name()='preface']/*">
3555
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
3388
3556
  <xsl:sort select="@displayorder" data-type="number"/>
3389
3557
  <xsl:apply-templates select="."/>
3390
3558
  </xsl:for-each>
@@ -3404,22 +3572,24 @@
3404
3572
  <xsl:sort select="@displayorder" data-type="number"/>
3405
3573
  <xsl:apply-templates select="."/>
3406
3574
  </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">
3575
+ </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">
3576
+ <xsl:value-of select="."/>
3577
+ </xsl:template><xsl:template name="replace_fo_inline_tags">
3578
+ <xsl:param name="tag_open"/>
3579
+ <xsl:param name="tag_close"/>
3414
3580
  <xsl:param name="text"/>
3415
3581
  <xsl:choose>
3416
3582
  <xsl:when test="contains($text, $tag_open)">
3417
3583
  <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>
3584
+ <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> -->
3419
3585
  <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">
3586
+ <fo:inline keep-together.within-line="always">
3587
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
3588
+ </fo:inline>
3589
+ <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> -->
3590
+ <xsl:call-template name="replace_fo_inline_tags">
3591
+ <xsl:with-param name="tag_open" select="$tag_open"/>
3592
+ <xsl:with-param name="tag_close" select="$tag_close"/>
3423
3593
  <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
3424
3594
  </xsl:call-template>
3425
3595
  </xsl:when>
@@ -3427,6 +3597,39 @@
3427
3597
  </xsl:choose>
3428
3598
  </xsl:template><xsl:template match="*[local-name()='br']">
3429
3599
  <xsl:value-of select="$linebreak"/>
3600
+ </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
3601
+ <xsl:param name="split_keep-within-line"/>
3602
+
3603
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
3604
+ <xsl:choose>
3605
+
3606
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
3607
+ <xsl:variable name="sep">_</xsl:variable>
3608
+ <xsl:variable name="items">
3609
+ <xsl:call-template name="split">
3610
+ <xsl:with-param name="pText" select="."/>
3611
+ <xsl:with-param name="sep" select="$sep"/>
3612
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
3613
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
3614
+ </xsl:call-template>
3615
+ </xsl:variable>
3616
+ <xsl:for-each select="xalan:nodeset($items)/item">
3617
+ <xsl:choose>
3618
+ <xsl:when test=". = $sep">
3619
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
3620
+ </xsl:when>
3621
+ <xsl:otherwise>
3622
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3623
+ </xsl:otherwise>
3624
+ </xsl:choose>
3625
+ </xsl:for-each>
3626
+ </xsl:when>
3627
+
3628
+ <xsl:otherwise>
3629
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
3630
+ </xsl:otherwise>
3631
+
3632
+ </xsl:choose>
3430
3633
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
3431
3634
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
3432
3635
  <xsl:apply-templates/>
@@ -3506,19 +3709,24 @@
3506
3709
  <xsl:with-param name="margin" select="$margin"/>
3507
3710
  </xsl:call-template>
3508
3711
 
3509
- </xsl:template><xsl:variable name="express_reference_separators">_.\</xsl:variable><xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3510
-
3511
- <xsl:choose>
3512
- <!-- if EXPRESS reference -->
3513
- <xsl:when test="parent::*[local-name()='strong'] and translate(., $express_reference_characters, '') = ''">
3514
- <xsl:value-of select="."/>
3515
- </xsl:when>
3516
- <xsl:otherwise>
3517
- <!-- <xsl:call-template name="add-zero-spaces"/> -->
3518
- <xsl:call-template name="add-zero-spaces-java"/>
3519
- </xsl:otherwise>
3520
- </xsl:choose>
3521
-
3712
+ </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
3713
+ <xsl:choose>
3714
+ <xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
3715
+ <xsl:value-of select="."/>
3716
+ </xsl:when>
3717
+ <xsl:otherwise>
3718
+ <xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
3719
+ </xsl:otherwise>
3720
+ </xsl:choose>
3721
+ </xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
3722
+ <xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
3723
+ <!-- <xsl:copy-of select="$text"/> -->
3724
+ <xsl:for-each select="xalan:nodeset($text)/text/node()">
3725
+ <xsl:choose>
3726
+ <xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
3727
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
3728
+ </xsl:choose>
3729
+ </xsl:for-each>
3522
3730
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
3523
3731
 
3524
3732
  <xsl:variable name="table-preamble">
@@ -3528,9 +3736,14 @@
3528
3736
 
3529
3737
  <xsl:variable name="table">
3530
3738
 
3531
- <xsl:variable name="simple-table">
3532
- <xsl:call-template name="getSimpleTable"/>
3739
+ <xsl:variable name="simple-table">
3740
+ <xsl:call-template name="getSimpleTable">
3741
+ <xsl:with-param name="id" select="@id"/>
3742
+ </xsl:call-template>
3533
3743
  </xsl:variable>
3744
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3745
+
3746
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
3534
3747
 
3535
3748
 
3536
3749
  <!-- Display table's name before table as standalone block -->
@@ -3549,7 +3762,23 @@
3549
3762
  </xsl:call-template>
3550
3763
  </xsl:if>
3551
3764
  </xsl:variable>
3552
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
3765
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
3766
+
3767
+ <!-- DEBUG -->
3768
+ <xsl:if test="$table_if_debug = 'true'">
3769
+ <fo:block font-size="60%">
3770
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
3771
+ </fo:block>
3772
+ </xsl:if>
3773
+
3774
+
3775
+ <!-- <xsl:copy-of select="$colwidths"/> -->
3776
+
3777
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
3778
+ DEBUG
3779
+ colwidths=<xsl:copy-of select="$colwidths"/>
3780
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
3781
+
3553
3782
 
3554
3783
 
3555
3784
  <xsl:variable name="margin-side">
@@ -3618,9 +3847,17 @@
3618
3847
  </xsl:element>
3619
3848
  </xsl:variable>
3620
3849
 
3850
+ <xsl:if test="$isGenerateTableIF = 'true'">
3851
+ <!-- to determine start of table -->
3852
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
3853
+ </xsl:if>
3621
3854
 
3622
3855
  <fo:table id="{@id}">
3623
3856
 
3857
+ <xsl:if test="$isGenerateTableIF = 'true'">
3858
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
3859
+ </xsl:if>
3860
+
3624
3861
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3625
3862
  <xsl:attribute name="{local-name()}">
3626
3863
  <xsl:value-of select="."/>
@@ -3634,24 +3871,47 @@
3634
3871
 
3635
3872
 
3636
3873
  <xsl:choose>
3637
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3638
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3639
- <fo:table-column column-width="{@width}"/>
3640
- </xsl:for-each>
3874
+ <xsl:when test="$isGenerateTableIF = 'true'">
3875
+ <!-- generate IF for table widths -->
3876
+ <!-- example:
3877
+ <tr>
3878
+ <td valign="top" align="left" id="tab-symdu_1_1">
3879
+ <p>Symbol</p>
3880
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
3881
+ </td>
3882
+ <td valign="top" align="left" id="tab-symdu_1_2">
3883
+ <p>Description</p>
3884
+ <word id="tab-symdu_1_2_word_1">Description</word>
3885
+ </td>
3886
+ </tr>
3887
+ -->
3888
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
3889
+
3641
3890
  </xsl:when>
3642
3891
  <xsl:otherwise>
3643
- <xsl:call-template name="insertTableColumnWidth">
3644
- <xsl:with-param name="colwidths" select="$colwidths"/>
3645
- </xsl:call-template>
3646
- </xsl:otherwise>
3647
- </xsl:choose>
3648
3892
 
3649
- <xsl:choose>
3650
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3651
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3652
- </xsl:when>
3653
- <xsl:otherwise>
3654
- <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 -->
3893
+ <xsl:choose>
3894
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3895
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
3896
+ <fo:table-column column-width="{@width}"/>
3897
+ </xsl:for-each>
3898
+ </xsl:when>
3899
+ <xsl:otherwise>
3900
+ <xsl:call-template name="insertTableColumnWidth">
3901
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3902
+ </xsl:call-template>
3903
+ </xsl:otherwise>
3904
+ </xsl:choose>
3905
+
3906
+ <xsl:choose>
3907
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
3908
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3909
+ </xsl:when>
3910
+ <xsl:otherwise>
3911
+ <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 -->
3912
+ </xsl:otherwise>
3913
+ </xsl:choose>
3914
+
3655
3915
  </xsl:otherwise>
3656
3916
  </xsl:choose>
3657
3917
 
@@ -3756,11 +4016,19 @@
3756
4016
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
3757
4017
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
3758
4018
  </xsl:template><xsl:template name="calculate-column-widths">
4019
+ <xsl:param name="table"/>
4020
+ <xsl:param name="cols-count"/>
4021
+
4022
+ <xsl:call-template name="get-calculated-column-widths-autolayout-algorithm"/>
4023
+
4024
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
3759
4025
  <xsl:param name="table"/>
3760
4026
  <xsl:param name="cols-count"/>
3761
4027
  <xsl:param name="curr-col" select="1"/>
3762
4028
  <xsl:param name="width" select="0"/>
3763
4029
 
4030
+ <!-- table=<xsl:copy-of select="$table"/> -->
4031
+
3764
4032
  <xsl:if test="$curr-col &lt;= $cols-count">
3765
4033
  <xsl:variable name="widths">
3766
4034
  <xsl:choose>
@@ -3798,16 +4066,22 @@
3798
4066
  </xsl:for-each>
3799
4067
  </xsl:when>
3800
4068
  <xsl:otherwise>
3801
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
4069
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
4070
+
4071
+ <!-- <table><xsl:copy-of select="$table"/></table>
4072
+ -->
4073
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
3802
4074
  <xsl:variable name="td_text">
3803
4075
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
3804
4076
  </xsl:variable>
4077
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
3805
4078
  <xsl:variable name="words">
3806
4079
  <xsl:variable name="string_with_added_zerospaces">
3807
4080
  <xsl:call-template name="add-zero-spaces-java">
3808
4081
  <xsl:with-param name="text" select="$td_text"/>
3809
4082
  </xsl:call-template>
3810
4083
  </xsl:variable>
4084
+ <!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
3811
4085
  <xsl:call-template name="tokenize">
3812
4086
  <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
3813
4087
  <!-- 2009 thinspace -->
@@ -3815,11 +4089,13 @@
3815
4089
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
3816
4090
  </xsl:call-template>
3817
4091
  </xsl:variable>
4092
+ <!-- words=<xsl:copy-of select="$words"/> -->
3818
4093
  <xsl:variable name="max_length">
3819
4094
  <xsl:call-template name="max_length">
3820
4095
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
3821
4096
  </xsl:call-template>
3822
4097
  </xsl:variable>
4098
+ <!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
3823
4099
  <width>
3824
4100
  <xsl:variable name="divider">
3825
4101
  <xsl:choose>
@@ -3838,6 +4114,8 @@
3838
4114
  </xsl:choose>
3839
4115
  </xsl:variable>
3840
4116
 
4117
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
4118
+
3841
4119
  <column>
3842
4120
  <xsl:for-each select="xalan:nodeset($widths)//width">
3843
4121
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -3846,41 +4124,276 @@
3846
4124
  </xsl:if>
3847
4125
  </xsl:for-each>
3848
4126
  </column>
3849
- <xsl:call-template name="calculate-column-widths">
4127
+ <xsl:call-template name="calculate-column-widths-proportional">
3850
4128
  <xsl:with-param name="cols-count" select="$cols-count"/>
3851
4129
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
3852
4130
  <xsl:with-param name="table" select="$table"/>
3853
4131
  </xsl:call-template>
3854
4132
  </xsl:if>
3855
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]" mode="td_text">
3856
- <xsl:apply-templates mode="td_text"/>
3857
- </xsl:template><xsl:template match="*[(local-name()='strong' or (local-name()='inline' and @font-weight = 'bold'))]/text()[translate(., $express_reference_characters, '') = '']" mode="td_text">
4133
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
4134
+ <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
4135
+ <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
4136
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
3858
4137
 
3859
- <!-- replace underscore, back slash, dot to 'x', just to skip further tokenization -->
3860
- <xsl:value-of select="translate(., $express_reference_separators, 'xxx')"/>
3861
-
4138
+ <!-- if all capitals english letters or digits -->
4139
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
4140
+ <xsl:call-template name="repeat">
4141
+ <xsl:with-param name="char" select="'X'"/>
4142
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
4143
+ </xsl:call-template>
4144
+ </xsl:if>
3862
4145
  </xsl:template><xsl:template match="text()" mode="td_text">
3863
4146
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
3864
4147
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
3865
4148
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
3866
4149
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
3867
4150
  <xsl:value-of select="@target"/>
3868
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
3869
- <xsl:variable name="mathml">
3870
- <xsl:for-each select="*">
3871
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
3872
- <xsl:copy-of select="."/>
3873
- </xsl:if>
3874
- </xsl:for-each>
4151
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
4152
+ <xsl:if test="$isGenerateTableIF = 'false'">
4153
+ <xsl:variable name="mathml_">
4154
+ <xsl:for-each select="*">
4155
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
4156
+ <xsl:copy-of select="."/>
4157
+ </xsl:if>
4158
+ </xsl:for-each>
4159
+ </xsl:variable>
4160
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
4161
+
4162
+ <xsl:variable name="math_text">
4163
+ <xsl:value-of select="normalize-space($mathml)"/>
4164
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
4165
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
4166
+ </xsl:variable>
4167
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
4168
+ </xsl:if>
4169
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
4170
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
4171
+
4172
+ <!-- via intermediate format -->
4173
+
4174
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
4175
+
4176
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
4177
+
4178
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
4179
+
4180
+ <!-- get current table id -->
4181
+ <xsl:variable name="table_id" select="@id"/>
4182
+ <!-- find table by id in the file 'table_widths' -->
4183
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
4184
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
4185
+
4186
+ <!-- table='<xsl:copy-of select="$table"/>' -->
4187
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
4188
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
4189
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
4190
+
4191
+ <xsl:variable name="table_with_cell_widths_">
4192
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
3875
4193
  </xsl:variable>
4194
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
3876
4195
 
3877
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
3878
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
3879
- </xsl:template><xsl:template match="*[local-name()='thead']">
3880
- <xsl:param name="cols-count"/>
3881
- <fo:table-header>
3882
-
3883
- <xsl:call-template name="table-header-title">
4196
+ <!-- <xsl:if test="$table_if_debug = 'true'">
4197
+ <xsl:copy-of select="$table_with_cell_widths"/>
4198
+ </xsl:if> -->
4199
+
4200
+
4201
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
4202
+
4203
+ <xsl:variable name="column_widths_">
4204
+ <!-- iteration of columns -->
4205
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
4206
+ <xsl:variable name="pos" select="position()"/>
4207
+ <column>
4208
+ <xsl:attribute name="width_max">
4209
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
4210
+ <xsl:sort select="." data-type="number" order="descending"/>
4211
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4212
+ </xsl:for-each>
4213
+ </xsl:attribute>
4214
+ <xsl:attribute name="width_min">
4215
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
4216
+ <xsl:sort select="." data-type="number" order="descending"/>
4217
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4218
+ </xsl:for-each>
4219
+ </xsl:attribute>
4220
+ </column>
4221
+ </xsl:for-each>
4222
+ </xsl:variable>
4223
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
4224
+
4225
+ <!-- <column_widths>
4226
+ <xsl:copy-of select="$column_widths"/>
4227
+ </column_widths> -->
4228
+
4229
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
4230
+ <xsl:variable name="table_widths_">
4231
+ <table>
4232
+ <xsl:attribute name="width_max">
4233
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
4234
+ </xsl:attribute>
4235
+ <xsl:attribute name="width_min">
4236
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
4237
+ </xsl:attribute>
4238
+ </table>
4239
+ </xsl:variable>
4240
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
4241
+
4242
+ <xsl:variable name="page_width">
4243
+ <xsl:choose>
4244
+ <xsl:when test="$parent_table_page-width != ''">
4245
+ <xsl:value-of select="$parent_table_page-width"/>
4246
+ </xsl:when>
4247
+ <xsl:otherwise>
4248
+ <xsl:value-of select="@page-width"/>
4249
+ </xsl:otherwise>
4250
+ </xsl:choose>
4251
+ </xsl:variable>
4252
+
4253
+ <xsl:if test="$table_if_debug = 'true'">
4254
+ <table_width>
4255
+ <xsl:copy-of select="$table_widths"/>
4256
+ </table_width>
4257
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
4258
+ </xsl:if>
4259
+
4260
+
4261
+ <!-- There are three cases: -->
4262
+ <xsl:choose>
4263
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
4264
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
4265
+ <!-- call old algorithm -->
4266
+ <case1/>
4267
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
4268
+ <xsl:call-template name="calculate-column-widths-proportional">
4269
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4270
+ <xsl:with-param name="table" select="$table"/>
4271
+ </xsl:call-template> -->
4272
+ </xsl:when>
4273
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
4274
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
4275
+ <case2/>
4276
+ <autolayout/>
4277
+ <xsl:for-each select="$column_widths/column/@width_max">
4278
+ <column divider="100"><xsl:value-of select="."/></column>
4279
+ </xsl:for-each>
4280
+ </xsl:when>
4281
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
4282
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
4283
+ Lets also call D the difference between maximum and minimum width of the table.
4284
+ For each column, let d be the difference between maximum and minimum width of that column.
4285
+ Now set the column's width to the minimum width plus d times W over D.
4286
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
4287
+ <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)">
4288
+ <!-- difference between the available space and the minimum table width -->
4289
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
4290
+ <W><xsl:value-of select="$W"/></W>
4291
+ <!-- difference between maximum and minimum width of the table -->
4292
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
4293
+ <D><xsl:value-of select="$D"/></D>
4294
+ <case3/>
4295
+ <autolayout/>
4296
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
4297
+ <split_keep-within-line>true</split_keep-within-line>
4298
+ </xsl:if>
4299
+ <xsl:for-each select="$column_widths/column">
4300
+ <!-- difference between maximum and minimum width of that column. -->
4301
+ <xsl:variable name="d" select="@width_max - @width_min"/>
4302
+ <d><xsl:value-of select="$d"/></d>
4303
+ <width_min><xsl:value-of select="@width_min"/></width_min>
4304
+ <e><xsl:value-of select="$d * $W div $D"/></e>
4305
+ <!-- set the column's width to the minimum width plus d times W over D. -->
4306
+ <column divider="100">
4307
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
4308
+ </column>
4309
+ </xsl:for-each>
4310
+
4311
+ </xsl:when>
4312
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
4313
+ </xsl:choose>
4314
+
4315
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
4316
+
4317
+ <!-- if nested 'dl' or 'table' -->
4318
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
4319
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
4320
+
4321
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
4322
+
4323
+ <xsl:variable name="parent_table_page-width_">
4324
+ <xsl:if test="$parent_table_id != ''">
4325
+ <!-- determine column number in the parent table -->
4326
+ <xsl:variable name="parent_table_column_number">
4327
+ <xsl:choose>
4328
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
4329
+ <xsl:otherwise> <!-- parent is table -->
4330
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
4331
+ </xsl:otherwise>
4332
+ </xsl:choose>
4333
+ </xsl:variable>
4334
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
4335
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
4336
+ </xsl:if>
4337
+ </xsl:variable>
4338
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
4339
+
4340
+ <!-- get current table id -->
4341
+ <xsl:variable name="table_id" select="@id"/>
4342
+
4343
+ <xsl:choose>
4344
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
4345
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
4346
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
4347
+ </xsl:when>
4348
+ <xsl:otherwise>
4349
+ <!-- recalculate columns width based on parent table width -->
4350
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
4351
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
4352
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
4353
+ </xsl:call-template>
4354
+ </xsl:for-each>
4355
+ </xsl:otherwise>
4356
+ </xsl:choose>
4357
+
4358
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
4359
+ <xsl:copy>
4360
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
4361
+ </xsl:copy>
4362
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
4363
+ <xsl:copy>
4364
+ <xsl:copy-of select="@*"/>
4365
+
4366
+ <!-- The maximum width is given by the widest line. -->
4367
+ <xsl:attribute name="width_max">
4368
+ <xsl:for-each select="p_len">
4369
+ <xsl:sort select="." data-type="number" order="descending"/>
4370
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4371
+ </xsl:for-each>
4372
+ </xsl:attribute>
4373
+
4374
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
4375
+ <xsl:variable name="width_min">
4376
+ <xsl:for-each select="word_len">
4377
+ <xsl:sort select="." data-type="number" order="descending"/>
4378
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
4379
+ </xsl:for-each>
4380
+ </xsl:variable>
4381
+ <xsl:attribute name="width_min">
4382
+ <xsl:value-of select="$width_min"/>
4383
+ </xsl:attribute>
4384
+
4385
+ <xsl:if test="$width_min = 0">
4386
+ <xsl:attribute name="width_min">1</xsl:attribute>
4387
+ </xsl:if>
4388
+
4389
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
4390
+
4391
+ </xsl:copy>
4392
+ </xsl:template><xsl:template match="*[local-name()='thead']">
4393
+ <xsl:param name="cols-count"/>
4394
+ <fo:table-header>
4395
+
4396
+ <xsl:call-template name="table-header-title">
3884
4397
  <xsl:with-param name="cols-count" select="$cols-count"/>
3885
4398
  </xsl:call-template>
3886
4399
 
@@ -3973,6 +4486,7 @@
3973
4486
  </xsl:for-each>
3974
4487
  </xsl:when>
3975
4488
  <xsl:otherwise>
4489
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
3976
4490
  <xsl:call-template name="insertTableColumnWidth">
3977
4491
  <xsl:with-param name="colwidths" select="$colwidths"/>
3978
4492
  </xsl:call-template>
@@ -4097,6 +4611,52 @@
4097
4611
 
4098
4612
  </fo:table-body>
4099
4613
 
4614
+ </xsl:template><xsl:template match="/" mode="process_table-if">
4615
+ <xsl:param name="table_or_dl">table</xsl:param>
4616
+ <xsl:apply-templates mode="process_table-if">
4617
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
4618
+ </xsl:apply-templates>
4619
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
4620
+ <xsl:param name="table_or_dl">table</xsl:param>
4621
+
4622
+ <fo:table-body>
4623
+ <xsl:for-each select="*[local-name() = 'tr']">
4624
+ <xsl:variable name="col_count" select="count(*)"/>
4625
+
4626
+ <!-- iteration for each tr/td -->
4627
+
4628
+ <xsl:choose>
4629
+ <xsl:when test="$table_or_dl = 'table'">
4630
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
4631
+ <fo:table-row number-columns-spanned="{$col_count}">
4632
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
4633
+ <xsl:call-template name="td"/>
4634
+ </fo:table-row>
4635
+ </xsl:for-each>
4636
+ </xsl:when>
4637
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
4638
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
4639
+ <xsl:variable name="is_dt" select="position() = 1"/>
4640
+
4641
+ <xsl:for-each select="*">
4642
+ <!-- <test><xsl:copy-of select="."/></test> -->
4643
+ <fo:table-row number-columns-spanned="{$col_count}">
4644
+ <xsl:choose>
4645
+ <xsl:when test="$is_dt">
4646
+ <xsl:call-template name="insert_dt_cell"/>
4647
+ </xsl:when>
4648
+ <xsl:otherwise>
4649
+ <xsl:call-template name="insert_dd_cell"/>
4650
+ </xsl:otherwise>
4651
+ </xsl:choose>
4652
+ </fo:table-row>
4653
+ </xsl:for-each>
4654
+ </xsl:for-each>
4655
+ </xsl:otherwise>
4656
+ </xsl:choose>
4657
+
4658
+ </xsl:for-each>
4659
+ </fo:table-body>
4100
4660
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4101
4661
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4102
4662
 
@@ -4194,7 +4754,7 @@
4194
4754
  </xsl:choose>
4195
4755
  </xsl:attribute>
4196
4756
  </xsl:if>
4197
- </xsl:template><xsl:template match="*[local-name()='td']">
4757
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
4198
4758
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
4199
4759
  <xsl:call-template name="setTextAlignment">
4200
4760
  <xsl:with-param name="default">left</xsl:with-param>
@@ -4232,11 +4792,24 @@
4232
4792
 
4233
4793
  <xsl:call-template name="setTableCellAttributes"/>
4234
4794
 
4795
+ <xsl:if test="$isGenerateTableIF = 'true'">
4796
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
4797
+ <xsl:attribute name="text-align">left</xsl:attribute>
4798
+ </xsl:if>
4799
+
4235
4800
  <fo:block>
4236
4801
 
4802
+ <xsl:if test="$isGenerateTableIF = 'true'">
4803
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
4804
+ </xsl:if>
4805
+
4806
+
4237
4807
 
4238
4808
 
4239
4809
  <xsl:apply-templates/>
4810
+
4811
+ <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"/> -->
4812
+
4240
4813
  </fo:block>
4241
4814
  </fo:table-cell>
4242
4815
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -4435,9 +5008,9 @@
4435
5008
  <!-- current hierarchy is 'figure' element -->
4436
5009
  <xsl:variable name="following_dl_colwidths">
4437
5010
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4438
- <xsl:variable name="html-table">
4439
- <xsl:variable name="doc_ns">
4440
-
5011
+ <xsl:variable name="simple-table">
5012
+ <!-- <xsl:variable name="doc_ns">
5013
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4441
5014
  </xsl:variable>
4442
5015
  <xsl:variable name="ns">
4443
5016
  <xsl:choose>
@@ -4448,7 +5021,7 @@
4448
5021
  <xsl:value-of select="substring-before(name(/*), '-')"/>
4449
5022
  </xsl:otherwise>
4450
5023
  </xsl:choose>
4451
- </xsl:variable>
5024
+ </xsl:variable> -->
4452
5025
 
4453
5026
  <xsl:for-each select="*[local-name() = 'dl'][1]">
4454
5027
  <tbody>
@@ -4459,7 +5032,7 @@
4459
5032
 
4460
5033
  <xsl:call-template name="calculate-column-widths">
4461
5034
  <xsl:with-param name="cols-count" select="2"/>
4462
- <xsl:with-param name="table" select="$html-table"/>
5035
+ <xsl:with-param name="table" select="$simple-table"/>
4463
5036
  </xsl:call-template>
4464
5037
 
4465
5038
  </xsl:if>
@@ -4585,8 +5158,10 @@
4585
5158
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
4586
5159
  </xsl:variable>
4587
5160
 
5161
+ <xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
5162
+
4588
5163
  <xsl:choose>
4589
- <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->
5164
+ <xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
4590
5165
 
4591
5166
  <fo:block margin-bottom="12pt" text-align="left">
4592
5167
 
@@ -4603,7 +5178,7 @@
4603
5178
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4604
5179
  </fo:block>
4605
5180
 
4606
- </xsl:when>
5181
+ </xsl:when> <!-- END: only one component -->
4607
5182
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
4608
5183
  <fo:block margin-bottom="12pt" text-align="left">
4609
5184
 
@@ -4619,8 +5194,8 @@
4619
5194
  </xsl:variable>
4620
5195
  <xsl:value-of select="$title-where"/>
4621
5196
  </fo:block>
4622
- </xsl:when>
4623
- <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
5197
+ </xsl:when> <!-- END: a few components -->
5198
+ <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
4624
5199
  <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
4625
5200
 
4626
5201
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -4636,11 +5211,11 @@
4636
5211
  </xsl:variable>
4637
5212
  <xsl:value-of select="$title-key"/>
4638
5213
  </fo:block>
4639
- </xsl:when>
5214
+ </xsl:when> <!-- END: definition list in a figure -->
4640
5215
  </xsl:choose>
4641
5216
 
4642
5217
  <!-- a few components -->
4643
- <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
5218
+ <xsl:if test="$onlyOneComponent = 'false'">
4644
5219
  <fo:block>
4645
5220
 
4646
5221
  <xsl:if test="$parent = 'formula'">
@@ -4651,12 +5226,31 @@
4651
5226
 
4652
5227
 
4653
5228
 
5229
+
5230
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
5231
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5232
+ </xsl:if>
5233
+
4654
5234
  <fo:block>
4655
5235
 
4656
5236
 
4657
5237
 
4658
5238
 
5239
+ <xsl:apply-templates select="*[local-name() = 'name']">
5240
+ <xsl:with-param name="process">true</xsl:with-param>
5241
+ </xsl:apply-templates>
5242
+
5243
+ <xsl:if test="$isGenerateTableIF = 'true'">
5244
+ <!-- to determine start of table -->
5245
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
5246
+ </xsl:if>
5247
+
4659
5248
  <fo:table width="95%" table-layout="fixed">
5249
+
5250
+ <xsl:if test="$isGenerateTableIF = 'true'">
5251
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
5252
+ </xsl:if>
5253
+
4660
5254
 
4661
5255
  <xsl:choose>
4662
5256
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -4665,71 +5259,178 @@
4665
5259
 
4666
5260
  </xsl:when>
4667
5261
  </xsl:choose>
4668
- <!-- create virtual html table for dl/[dt and dd] -->
4669
- <xsl:variable name="html-table">
4670
- <xsl:variable name="doc_ns">
5262
+
5263
+
5264
+ <xsl:attribute name="width">100%</xsl:attribute>
5265
+
5266
+
5267
+ <xsl:choose>
5268
+ <xsl:when test="$isGenerateTableIF = 'true'">
5269
+ <!-- generate IF for table widths -->
5270
+ <!-- example:
5271
+ <tr>
5272
+ <td valign="top" align="left" id="tab-symdu_1_1">
5273
+ <p>Symbol</p>
5274
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
5275
+ </td>
5276
+ <td valign="top" align="left" id="tab-symdu_1_2">
5277
+ <p>Description</p>
5278
+ <word id="tab-symdu_1_2_word_1">Description</word>
5279
+ </td>
5280
+ </tr>
5281
+ -->
4671
5282
 
4672
- </xsl:variable>
4673
- <xsl:variable name="ns">
4674
- <xsl:choose>
4675
- <xsl:when test="normalize-space($doc_ns) != ''">
4676
- <xsl:value-of select="normalize-space($doc_ns)"/>
4677
- </xsl:when>
4678
- <xsl:otherwise>
4679
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4680
- </xsl:otherwise>
4681
- </xsl:choose>
4682
- </xsl:variable>
4683
- <tbody>
4684
- <xsl:apply-templates mode="dl"/>
4685
- </tbody>
4686
- </xsl:variable>
4687
- <!-- html-table<xsl:copy-of select="$html-table"/> -->
4688
- <xsl:variable name="colwidths">
4689
- <xsl:call-template name="calculate-column-widths">
4690
- <xsl:with-param name="cols-count" select="2"/>
4691
- <xsl:with-param name="table" select="$html-table"/>
4692
- </xsl:call-template>
4693
- </xsl:variable>
4694
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
4695
- <xsl:variable name="maxlength_dt">
4696
- <xsl:call-template name="getMaxLength_dt"/>
4697
- </xsl:variable>
4698
- <xsl:variable name="isContainsExpressReference_">
4699
-
4700
- <xsl:value-of select="count(.//*[local-name() = 'strong'][translate(., $express_reference_characters, '') = '']) &gt; 0"/>
5283
+ <!-- create virtual html table for dl/[dt and dd] -->
5284
+ <xsl:variable name="simple-table">
5285
+
5286
+ <xsl:variable name="dl_table">
5287
+ <tbody>
5288
+ <xsl:apply-templates mode="dl_if">
5289
+ <xsl:with-param name="id" select="@id"/>
5290
+ </xsl:apply-templates>
5291
+ </tbody>
5292
+ </xsl:variable>
5293
+
5294
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
5295
+
5296
+ <!-- Step: replace <br/> to <p>...</p> -->
5297
+ <xsl:variable name="table_without_br">
5298
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
5299
+ </xsl:variable>
5300
+
5301
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
5302
+
5303
+ <!-- Step: add id to each cell -->
5304
+ <!-- add <word>...</word> for each word, image, math -->
5305
+ <xsl:variable name="simple-table-id">
5306
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
5307
+ <xsl:with-param name="id" select="@id"/>
5308
+ </xsl:apply-templates>
5309
+ </xsl:variable>
5310
+
5311
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
5312
+
5313
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
5314
+
5315
+ </xsl:variable>
4701
5316
 
4702
- </xsl:variable>
4703
- <xsl:variable name="isContainsExpressReference" select="normalize-space($isContainsExpressReference_)"/>
4704
- <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
4705
- <xsl:call-template name="setColumnWidth_dl">
4706
- <xsl:with-param name="colwidths" select="$colwidths"/>
4707
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4708
- <xsl:with-param name="isContainsExpressReference" select="$isContainsExpressReference"/>
4709
- </xsl:call-template>
4710
- <fo:table-body>
4711
- <xsl:apply-templates>
4712
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
4713
- </xsl:apply-templates>
4714
- </fo:table-body>
5317
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
5318
+
5319
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
5320
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
5321
+ </xsl:apply-templates>
5322
+
5323
+ </xsl:when>
5324
+ <xsl:otherwise>
5325
+
5326
+ <xsl:variable name="simple-table">
5327
+
5328
+ <xsl:variable name="dl_table">
5329
+ <tbody>
5330
+ <xsl:apply-templates mode="dl">
5331
+ <xsl:with-param name="id" select="@id"/>
5332
+ </xsl:apply-templates>
5333
+ </tbody>
5334
+ </xsl:variable>
5335
+
5336
+ <xsl:copy-of select="$dl_table"/>
5337
+ </xsl:variable>
5338
+
5339
+ <xsl:variable name="colwidths">
5340
+ <xsl:call-template name="calculate-column-widths">
5341
+ <xsl:with-param name="cols-count" select="2"/>
5342
+ <xsl:with-param name="table" select="$simple-table"/>
5343
+ </xsl:call-template>
5344
+ </xsl:variable>
5345
+
5346
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
5347
+ DEBUG
5348
+ colwidths=<xsl:copy-of select="$colwidths"/>
5349
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
5350
+
5351
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
5352
+
5353
+ <xsl:variable name="maxlength_dt">
5354
+ <xsl:call-template name="getMaxLength_dt"/>
5355
+ </xsl:variable>
5356
+
5357
+ <xsl:variable name="isContainsKeepTogetherTag_">
5358
+
5359
+ <xsl:value-of select="count(.//*[local-name() = $element_name_keep-together_within-line]) &gt; 0"/>
5360
+
5361
+ </xsl:variable>
5362
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
5363
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
5364
+
5365
+
5366
+ <xsl:call-template name="setColumnWidth_dl">
5367
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5368
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5369
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
5370
+ </xsl:call-template>
5371
+
5372
+ <fo:table-body>
5373
+
5374
+ <!-- DEBUG -->
5375
+ <xsl:if test="$table_if_debug = 'true'">
5376
+ <fo:table-row>
5377
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
5378
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5379
+ </fo:table-cell>
5380
+ </fo:table-row>
5381
+ </xsl:if>
5382
+
5383
+ <xsl:apply-templates>
5384
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
5385
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
5386
+ </xsl:apply-templates>
5387
+
5388
+ </fo:table-body>
5389
+ </xsl:otherwise>
5390
+ </xsl:choose>
4715
5391
  </fo:table>
4716
5392
  </fo:block>
4717
5393
  </fo:block>
4718
- </xsl:if>
5394
+ </xsl:if> <!-- END: a few components -->
4719
5395
  </fo:block-container>
4720
5396
  </fo:block-container>
5397
+
5398
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
5399
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
5400
+ </xsl:if>
5401
+
5402
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
5403
+ <xsl:param name="process">false</xsl:param>
5404
+ <xsl:if test="$process = 'true'">
5405
+ <fo:block xsl:use-attribute-sets="dl-name-style">
5406
+ <xsl:apply-templates/>
5407
+ </fo:block>
5408
+ </xsl:if>
4721
5409
  </xsl:template><xsl:template name="setColumnWidth_dl">
4722
5410
  <xsl:param name="colwidths"/>
4723
5411
  <xsl:param name="maxlength_dt"/>
4724
- <xsl:param name="isContainsExpressReference"/>
5412
+ <xsl:param name="isContainsKeepTogetherTag"/>
5413
+
5414
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
5415
+
4725
5416
  <xsl:choose>
5417
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5418
+ <xsl:call-template name="insertTableColumnWidth">
5419
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5420
+ </xsl:call-template>
5421
+ </xsl:when>
4726
5422
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
4727
5423
  <fo:table-column column-width="50%"/>
4728
5424
  <fo:table-column column-width="50%"/>
4729
5425
  </xsl:when>
4730
5426
  <xsl:otherwise>
4731
5427
  <xsl:choose>
4732
- <xsl:when test="$isContainsExpressReference">
5428
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
5429
+ <xsl:call-template name="insertTableColumnWidth">
5430
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5431
+ </xsl:call-template>
5432
+ </xsl:when>
5433
+ <xsl:when test="$isContainsKeepTogetherTag">
4733
5434
  <xsl:call-template name="insertTableColumnWidth">
4734
5435
  <xsl:with-param name="colwidths" select="$colwidths"/>
4735
5436
  </xsl:call-template>
@@ -4773,13 +5474,19 @@
4773
5474
  </xsl:choose>
4774
5475
  </xsl:template><xsl:template name="insertTableColumnWidth">
4775
5476
  <xsl:param name="colwidths"/>
5477
+
4776
5478
  <xsl:for-each select="xalan:nodeset($colwidths)//column">
4777
5479
  <xsl:choose>
4778
5480
  <xsl:when test=". = 1 or . = 0">
4779
5481
  <fo:table-column column-width="proportional-column-width(2)"/>
4780
5482
  </xsl:when>
4781
5483
  <xsl:otherwise>
4782
- <fo:table-column column-width="proportional-column-width({.})"/>
5484
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
5485
+ <xsl:variable name="divider">
5486
+ <xsl:value-of select="@divider"/>
5487
+ <xsl:if test="not(@divider)">1</xsl:if>
5488
+ </xsl:variable>
5489
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
4783
5490
  </xsl:otherwise>
4784
5491
  </xsl:choose>
4785
5492
  </xsl:for-each>
@@ -4806,7 +5513,6 @@
4806
5513
  <xsl:value-of select="$maxLength"/>
4807
5514
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
4808
5515
  <xsl:param name="key_iso"/>
4809
-
4810
5516
  <!-- <tr>
4811
5517
  <td>NOTE</td>
4812
5518
  <td>
@@ -4814,27 +5520,47 @@
4814
5520
  </td>
4815
5521
  </tr>
4816
5522
  -->
4817
- <fo:table-row>
5523
+ <!-- OLD Variant -->
5524
+ <!-- <fo:table-row>
4818
5525
  <fo:table-cell>
4819
5526
  <fo:block margin-top="6pt">
4820
5527
  <xsl:if test="normalize-space($key_iso) = 'true'">
4821
5528
  <xsl:attribute name="margin-top">0</xsl:attribute>
4822
5529
  </xsl:if>
4823
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5530
+ <xsl:apply-templates select="*[local-name() = 'name']" />
4824
5531
  </fo:block>
4825
5532
  </fo:table-cell>
4826
5533
  <fo:table-cell>
4827
5534
  <fo:block>
4828
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5535
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]" />
5536
+ </fo:block>
5537
+ </fo:table-cell>
5538
+ </fo:table-row> -->
5539
+ <!-- <tr>
5540
+ <td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
5541
+ </tr>
5542
+ -->
5543
+ <fo:table-row>
5544
+ <fo:table-cell number-columns-spanned="2">
5545
+ <fo:block>
5546
+ <xsl:call-template name="note"/>
4829
5547
  </fo:block>
4830
5548
  </fo:table-cell>
4831
5549
  </fo:table-row>
4832
5550
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
5551
+ <xsl:param name="id"/>
5552
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
4833
5553
  <tr>
4834
5554
  <td>
5555
+ <xsl:attribute name="id">
5556
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
5557
+ </xsl:attribute>
4835
5558
  <xsl:apply-templates/>
4836
5559
  </td>
4837
5560
  <td>
5561
+ <xsl:attribute name="id">
5562
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
5563
+ </xsl:attribute>
4838
5564
 
4839
5565
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4840
5566
  <xsl:with-param name="process">true</xsl:with-param>
@@ -4845,50 +5571,134 @@
4845
5571
 
4846
5572
  </xsl:template><xsl:template match="*[local-name()='dt']">
4847
5573
  <xsl:param name="key_iso"/>
5574
+ <xsl:param name="split_keep-within-line"/>
4848
5575
 
4849
5576
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
4850
- <fo:table-cell>
5577
+ <xsl:call-template name="insert_dt_cell">
5578
+ <xsl:with-param name="key_iso" select="$key_iso"/>
5579
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5580
+ </xsl:call-template>
5581
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
5582
+ <xsl:call-template name="insert_dd_cell">
5583
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5584
+ </xsl:call-template>
5585
+ </xsl:for-each>
5586
+ </fo:table-row>
5587
+ </xsl:template><xsl:template name="insert_dt_cell">
5588
+ <xsl:param name="key_iso"/>
5589
+ <xsl:param name="split_keep-within-line"/>
5590
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
5591
+
5592
+ <xsl:if test="$isGenerateTableIF = 'true'">
5593
+ <!-- border is mandatory, to calculate real width -->
5594
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5595
+ <xsl:attribute name="text-align">left</xsl:attribute>
5596
+ </xsl:if>
5597
+
5598
+
5599
+ <fo:block xsl:use-attribute-sets="dt-block-style">
5600
+ <xsl:copy-of select="@id"/>
5601
+
5602
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5603
+ <xsl:attribute name="margin-top">0</xsl:attribute>
5604
+ </xsl:if>
5605
+
5606
+
5607
+
5608
+ <xsl:apply-templates>
5609
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5610
+ </xsl:apply-templates>
5611
+
5612
+ <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"/> -->
5613
+
5614
+ </fo:block>
5615
+ </fo:table-cell>
5616
+ </xsl:template><xsl:template name="insert_dd_cell">
5617
+ <xsl:param name="split_keep-within-line"/>
5618
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
5619
+
5620
+ <xsl:if test="$isGenerateTableIF = 'true'">
5621
+ <!-- border is mandatory, to calculate real width -->
5622
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
5623
+ </xsl:if>
5624
+
5625
+ <fo:block>
5626
+
5627
+ <xsl:if test="$isGenerateTableIF = 'true'">
5628
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
5629
+ </xsl:if>
5630
+
4851
5631
 
4852
- <fo:block xsl:use-attribute-sets="dt-style">
4853
- <xsl:copy-of select="@id"/>
4854
-
4855
- <xsl:if test="normalize-space($key_iso) = 'true'">
4856
- <xsl:attribute name="margin-top">0</xsl:attribute>
4857
- </xsl:if>
4858
-
4859
-
4860
-
4861
- <xsl:apply-templates/>
4862
- </fo:block>
4863
- </fo:table-cell>
4864
- <fo:table-cell>
4865
- <fo:block>
4866
-
4867
5632
 
4868
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
4869
- <xsl:with-param name="process">true</xsl:with-param>
4870
- </xsl:apply-templates>
4871
- </fo:block>
4872
- </fo:table-cell>
4873
- </fo:table-row>
5633
+ <xsl:choose>
5634
+ <xsl:when test="$isGenerateTableIF = 'true'">
5635
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
5636
+ <xsl:with-param name="process">true</xsl:with-param>
5637
+ </xsl:apply-templates>
5638
+ </xsl:when>
5639
+ <xsl:otherwise>
5640
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
5641
+ <xsl:with-param name="process">true</xsl:with-param>
5642
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5643
+ </xsl:apply-templates>
5644
+ </xsl:otherwise>
5645
+
5646
+ </xsl:choose>
5647
+
5648
+ <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"/> -->
5649
+
5650
+ </fo:block>
5651
+ </fo:table-cell>
4874
5652
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4875
5653
  <xsl:apply-templates/>
4876
5654
  </xsl:template><xsl:template match="*[local-name()='dd']">
4877
5655
  <xsl:param name="process">false</xsl:param>
5656
+ <xsl:param name="split_keep-within-line"/>
4878
5657
  <xsl:if test="$process = 'true'">
4879
5658
  <xsl:apply-templates select="@language"/>
4880
- <xsl:apply-templates/>
5659
+ <xsl:apply-templates>
5660
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5661
+ </xsl:apply-templates>
4881
5662
  </xsl:if>
4882
5663
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4883
5664
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4884
- </xsl:template><xsl:template match="*[local-name()='em']">
5665
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
5666
+ <xsl:param name="id"/>
5667
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
5668
+ <tr>
5669
+ <td>
5670
+ <xsl:copy-of select="node()"/>
5671
+ </td>
5672
+ <td>
5673
+
5674
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
5675
+
5676
+ <!-- get paragraphs from nested 'dl' -->
5677
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
5678
+
5679
+
5680
+ </td>
5681
+ </tr>
5682
+
5683
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
5684
+ <xsl:for-each select="*[local-name() = 'dt']">
5685
+ <p>
5686
+ <xsl:copy-of select="node()"/>
5687
+ <xsl:text> </xsl:text>
5688
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
5689
+ </p>
5690
+ </xsl:for-each>
5691
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
4885
5692
  <fo:inline font-style="italic">
4886
5693
  <xsl:apply-templates/>
4887
5694
  </fo:inline>
4888
5695
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
5696
+ <xsl:param name="split_keep-within-line"/>
4889
5697
  <fo:inline font-weight="bold">
4890
5698
 
4891
- <xsl:apply-templates/>
5699
+ <xsl:apply-templates>
5700
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
5701
+ </xsl:apply-templates>
4892
5702
  </fo:inline>
4893
5703
  </xsl:template><xsl:template match="*[local-name()='padding']">
4894
5704
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -4909,7 +5719,7 @@
4909
5719
 
4910
5720
 
4911
5721
 
4912
- 10
5722
+ inherit <!-- 10 -->
4913
5723
 
4914
5724
 
4915
5725
 
@@ -4927,13 +5737,15 @@
4927
5737
  <xsl:choose>
4928
5738
  <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4929
5739
  <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4930
- <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5740
+ <xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4931
5741
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4932
5742
  </xsl:choose>
4933
5743
  </xsl:attribute>
4934
5744
  </xsl:if>
4935
5745
  <xsl:apply-templates/>
4936
5746
  </fo:inline>
5747
+ </xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
5748
+ <xsl:call-template name="add_spaces_to_sourcecode"/>
4937
5749
  </xsl:template><xsl:template match="*[local-name()='underline']">
4938
5750
  <fo:inline text-decoration="underline">
4939
5751
  <xsl:apply-templates/>
@@ -5081,54 +5893,120 @@
5081
5893
  <fo:block break-after="page"/>
5082
5894
  <fo:block> </fo:block>
5083
5895
  <fo:block break-after="page"/>
5896
+ </xsl:template><xsl:template match="*[local-name() = 'span']">
5897
+ <xsl:apply-templates/>
5084
5898
  </xsl:template><xsl:template name="tokenize">
5085
5899
  <xsl:param name="text"/>
5086
5900
  <xsl:param name="separator" select="' '"/>
5087
5901
  <xsl:choose>
5902
+
5903
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
5904
+ <word><xsl:value-of select="normalize-space($text)"/></word>
5905
+ </xsl:when>
5088
5906
  <xsl:when test="not(contains($text, $separator))">
5089
5907
  <word>
5090
- <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5091
- <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5092
5908
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
5093
- <xsl:variable name="len_str">
5094
- <xsl:choose>
5095
- <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5096
- <xsl:value-of select="$len_str_tmp * 1.5"/>
5097
- </xsl:when>
5098
- <xsl:otherwise>
5099
- <xsl:value-of select="$len_str_tmp"/>
5100
- </xsl:otherwise>
5101
- </xsl:choose>
5102
- </xsl:variable>
5103
-
5104
- <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5105
- <xsl:message>
5106
- div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5107
- len_str=<xsl:value-of select="$len_str"/>
5108
- len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5109
- </xsl:message>
5110
- </xsl:if> -->
5111
- <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5112
- <len_str><xsl:value-of select="$len_str"/></len_str> -->
5113
5909
  <xsl:choose>
5114
- <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5115
- <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5910
+ <xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
5911
+ <xsl:value-of select="$len_str_tmp"/>
5116
5912
  </xsl:when>
5117
5913
  <xsl:otherwise>
5118
- <xsl:value-of select="$len_str"/>
5914
+ <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
5915
+ <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
5916
+ <xsl:variable name="len_str">
5917
+ <xsl:choose>
5918
+ <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
5919
+ <xsl:value-of select="$len_str_tmp * 1.5"/>
5920
+ </xsl:when>
5921
+ <xsl:otherwise>
5922
+ <xsl:value-of select="$len_str_tmp"/>
5923
+ </xsl:otherwise>
5924
+ </xsl:choose>
5925
+ </xsl:variable>
5926
+
5927
+ <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
5928
+ <xsl:message>
5929
+ div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
5930
+ len_str=<xsl:value-of select="$len_str"/>
5931
+ len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
5932
+ </xsl:message>
5933
+ </xsl:if> -->
5934
+ <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
5935
+ <len_str><xsl:value-of select="$len_str"/></len_str> -->
5936
+ <xsl:choose>
5937
+ <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
5938
+ <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
5939
+ </xsl:when>
5940
+ <xsl:otherwise>
5941
+ <xsl:value-of select="$len_str"/>
5942
+ </xsl:otherwise>
5943
+ </xsl:choose>
5119
5944
  </xsl:otherwise>
5120
5945
  </xsl:choose>
5121
5946
  </word>
5122
5947
  </xsl:when>
5123
5948
  <xsl:otherwise>
5124
5949
  <word>
5125
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
5950
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
5951
+ <xsl:choose>
5952
+ <xsl:when test="$isGenerateTableIF = 'true'">
5953
+ <xsl:value-of select="$word"/>
5954
+ </xsl:when>
5955
+ <xsl:otherwise>
5956
+ <xsl:value-of select="string-length($word)"/>
5957
+ </xsl:otherwise>
5958
+ </xsl:choose>
5126
5959
  </word>
5127
5960
  <xsl:call-template name="tokenize">
5128
5961
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5129
5962
  </xsl:call-template>
5130
5963
  </xsl:otherwise>
5131
5964
  </xsl:choose>
5965
+ </xsl:template><xsl:template name="tokenize_with_tags">
5966
+ <xsl:param name="tags"/>
5967
+ <xsl:param name="text"/>
5968
+ <xsl:param name="separator" select="' '"/>
5969
+ <xsl:choose>
5970
+
5971
+ <xsl:when test="not(contains($text, $separator))">
5972
+ <word>
5973
+ <xsl:call-template name="enclose_text_in_tags">
5974
+ <xsl:with-param name="text" select="normalize-space($text)"/>
5975
+ <xsl:with-param name="tags" select="$tags"/>
5976
+ </xsl:call-template>
5977
+ </word>
5978
+ </xsl:when>
5979
+ <xsl:otherwise>
5980
+ <word>
5981
+ <xsl:call-template name="enclose_text_in_tags">
5982
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
5983
+ <xsl:with-param name="tags" select="$tags"/>
5984
+ </xsl:call-template>
5985
+ </word>
5986
+ <xsl:call-template name="tokenize_with_tags">
5987
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
5988
+ </xsl:call-template>
5989
+ </xsl:otherwise>
5990
+ </xsl:choose>
5991
+ </xsl:template><xsl:template name="enclose_text_in_tags">
5992
+ <xsl:param name="text"/>
5993
+ <xsl:param name="tags"/>
5994
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
5995
+
5996
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
5997
+
5998
+ <xsl:choose>
5999
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
6000
+ <xsl:otherwise>
6001
+ <xsl:element name="{$tag_name}">
6002
+ <xsl:call-template name="enclose_text_in_tags">
6003
+ <xsl:with-param name="text" select="$text"/>
6004
+ <xsl:with-param name="tags" select="$tags"/>
6005
+ <xsl:with-param name="num" select="$num + 1"/>
6006
+ </xsl:call-template>
6007
+ </xsl:element>
6008
+ </xsl:otherwise>
6009
+ </xsl:choose>
5132
6010
  </xsl:template><xsl:template name="max_length">
5133
6011
  <xsl:param name="words"/>
5134
6012
  <xsl:for-each select="$words//word">
@@ -5229,12 +6107,19 @@
5229
6107
  </xsl:otherwise>
5230
6108
  </xsl:choose>
5231
6109
  </xsl:template><xsl:template name="getSimpleTable">
6110
+ <xsl:param name="id"/>
6111
+
5232
6112
  <xsl:variable name="simple-table">
5233
6113
 
6114
+ <!-- Step 0. replace <br/> to <p>...</p> -->
6115
+ <xsl:variable name="table_without_br">
6116
+ <xsl:apply-templates mode="table-without-br"/>
6117
+ </xsl:variable>
6118
+
5234
6119
  <!-- Step 1. colspan processing -->
5235
6120
  <xsl:variable name="simple-table-colspan">
5236
6121
  <tbody>
5237
- <xsl:apply-templates mode="simple-table-colspan"/>
6122
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
5238
6123
  </tbody>
5239
6124
  </xsl:variable>
5240
6125
 
@@ -5243,10 +6128,67 @@
5243
6128
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
5244
6129
  </xsl:variable>
5245
6130
 
5246
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
5247
-
6131
+ <!-- Step 3: add id to each cell -->
6132
+ <!-- add <word>...</word> for each word, image, math -->
6133
+ <xsl:variable name="simple-table-id">
6134
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
6135
+ <xsl:with-param name="id" select="$id"/>
6136
+ </xsl:apply-templates>
6137
+ </xsl:variable>
6138
+
6139
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
6140
+
5248
6141
  </xsl:variable>
5249
6142
  <xsl:copy-of select="$simple-table"/>
6143
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
6144
+ <xsl:copy>
6145
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
6146
+ </xsl:copy>
6147
+ </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">
6148
+ <xsl:copy>
6149
+ <xsl:copy-of select="@*"/>
6150
+ <p>
6151
+ <xsl:copy-of select="node()"/>
6152
+ </p>
6153
+ </xsl:copy>
6154
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
6155
+ <xsl:copy>
6156
+ <xsl:copy-of select="@*"/>
6157
+ <xsl:for-each select="*[local-name()='br']">
6158
+ <xsl:variable name="current_id" select="generate-id()"/>
6159
+ <p>
6160
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6161
+ <xsl:copy-of select="."/>
6162
+ </xsl:for-each>
6163
+ </p>
6164
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6165
+ <p>
6166
+ <xsl:for-each select="following-sibling::node()">
6167
+ <xsl:copy-of select="."/>
6168
+ </xsl:for-each>
6169
+ </p>
6170
+ </xsl:if>
6171
+ </xsl:for-each>
6172
+ </xsl:copy>
6173
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
6174
+ <xsl:for-each select="*[local-name()='br']">
6175
+ <xsl:variable name="current_id" select="generate-id()"/>
6176
+ <p>
6177
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
6178
+ <xsl:copy-of select="."/>
6179
+ </xsl:for-each>
6180
+ </p>
6181
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
6182
+ <p>
6183
+ <xsl:for-each select="following-sibling::node()">
6184
+ <xsl:copy-of select="."/>
6185
+ </xsl:for-each>
6186
+ </p>
6187
+ </xsl:if>
6188
+ </xsl:for-each>
6189
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
6190
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
6191
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
5250
6192
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
5251
6193
  <xsl:apply-templates mode="simple-table-colspan"/>
5252
6194
  </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">
@@ -5336,6 +6278,126 @@
5336
6278
  <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5337
6279
  <xsl:with-param name="previousRow" select="$newRow"/>
5338
6280
  </xsl:apply-templates>
6281
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
6282
+ <xsl:param name="id"/>
6283
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
6284
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6285
+ <xsl:with-param name="id" select="$id_prefixed"/>
6286
+ </xsl:apply-templates>
6287
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
6288
+ <xsl:param name="id"/>
6289
+ <xsl:copy>
6290
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
6291
+ <xsl:with-param name="id" select="$id"/>
6292
+ </xsl:apply-templates>
6293
+ </xsl:copy>
6294
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
6295
+ <xsl:param name="id"/>
6296
+ <xsl:copy>
6297
+ <xsl:copy-of select="@*"/>
6298
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
6299
+ <xsl:apply-templates select="node()" mode="simple-table-id">
6300
+ <xsl:with-param name="id" select="$id"/>
6301
+ </xsl:apply-templates>
6302
+ </xsl:copy>
6303
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
6304
+ <xsl:param name="id"/>
6305
+ <xsl:copy>
6306
+ <xsl:copy-of select="@*"/>
6307
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
6308
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
6309
+ <xsl:attribute name="id">
6310
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
6311
+ </xsl:attribute>
6312
+
6313
+ <xsl:for-each select="*[local-name() = 'p']">
6314
+ <xsl:copy>
6315
+ <xsl:copy-of select="@*"/>
6316
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
6317
+ <xsl:attribute name="id">
6318
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
6319
+ </xsl:attribute>
6320
+
6321
+ <xsl:copy-of select="node()"/>
6322
+ </xsl:copy>
6323
+ </xsl:for-each>
6324
+
6325
+
6326
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
6327
+
6328
+ <xsl:variable name="td_text">
6329
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
6330
+ </xsl:variable>
6331
+
6332
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
6333
+
6334
+ <xsl:variable name="words">
6335
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
6336
+ <word>
6337
+ <xsl:copy-of select="."/>
6338
+ </word>
6339
+ </xsl:for-each>
6340
+
6341
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
6342
+ <xsl:copy-of select="."/>
6343
+ </xsl:for-each>
6344
+
6345
+ </xsl:variable>
6346
+
6347
+ <xsl:for-each select="xalan:nodeset($words)/word">
6348
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
6349
+ <xsl:copy>
6350
+ <xsl:attribute name="id">
6351
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
6352
+ </xsl:attribute>
6353
+ <xsl:copy-of select="node()"/>
6354
+ </xsl:copy>
6355
+ </xsl:for-each>
6356
+ </xsl:if>
6357
+ </xsl:copy>
6358
+
6359
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
6360
+ <xsl:copy>
6361
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
6362
+ </xsl:copy>
6363
+ </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">
6364
+ <xsl:variable name="formatting_tags">
6365
+ <xsl:call-template name="getFormattingTags"/>
6366
+ </xsl:variable>
6367
+ <word>
6368
+ <xsl:call-template name="enclose_text_in_tags">
6369
+ <xsl:with-param name="text" select="normalize-space(.)"/>
6370
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6371
+ </xsl:call-template>
6372
+ </word>
6373
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
6374
+
6375
+ <xsl:variable name="td_text" select="."/>
6376
+
6377
+ <xsl:variable name="string_with_added_zerospaces">
6378
+ <xsl:call-template name="add-zero-spaces-java">
6379
+ <xsl:with-param name="text" select="$td_text"/>
6380
+ </xsl:call-template>
6381
+ </xsl:variable>
6382
+
6383
+ <xsl:variable name="formatting_tags">
6384
+ <xsl:call-template name="getFormattingTags"/>
6385
+ </xsl:variable>
6386
+
6387
+ <!-- <word>text</word> -->
6388
+ <xsl:call-template name="tokenize_with_tags">
6389
+ <xsl:with-param name="tags" select="$formatting_tags"/>
6390
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
6391
+ </xsl:call-template>
6392
+ </xsl:template><xsl:template name="getFormattingTags">
6393
+ <tags>
6394
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
6395
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
6396
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
6397
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
6398
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
6399
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
6400
+ </tags>
5339
6401
  </xsl:template><xsl:template name="getLang">
5340
6402
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
5341
6403
  <xsl:variable name="language">
@@ -5511,7 +6573,9 @@
5511
6573
  <!-- replace start and end spaces to non-break space -->
5512
6574
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
5513
6575
  </xsl:copy>
5514
- </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">
6576
+ </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">
6577
+ <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
6578
+ </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
5515
6579
  <xsl:variable name="target">
5516
6580
  <xsl:choose>
5517
6581
  <xsl:when test="@updatetype = 'true'">
@@ -6327,7 +7391,11 @@
6327
7391
  <xsl:apply-templates mode="bookmarks"/>
6328
7392
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
6329
7393
  <xsl:apply-templates select="."/>
6330
- </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">
7394
+ </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">
7395
+ <xsl:apply-templates mode="contents"/>
7396
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
7397
+ <xsl:apply-templates mode="bookmarks"/>
7398
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
6331
7399
  <xsl:apply-templates mode="bookmarks"/>
6332
7400
  </xsl:template><xsl:template name="addBookmarks">
6333
7401
  <xsl:param name="contents"/>
@@ -6609,7 +7677,9 @@
6609
7677
  <xsl:apply-templates/>
6610
7678
  </xsl:otherwise>
6611
7679
  </xsl:choose>
6612
- </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">
7680
+ </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">
7681
+ <xsl:value-of select="."/>
7682
+ </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
6613
7683
  <xsl:text> </xsl:text>
6614
7684
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
6615
7685
  <xsl:copy>
@@ -6640,9 +7710,22 @@
6640
7710
  </xsl:when>
6641
7711
  <xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
6642
7712
  </xsl:choose>
7713
+ </xsl:template><xsl:template match="text()" mode="contents_item">
7714
+ <xsl:call-template name="keep_together_standard_number"/>
7715
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
7716
+ <xsl:apply-templates mode="contents_item"/>
6643
7717
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6644
7718
 
6645
7719
  <fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
7720
+
7721
+ <xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
7722
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
7723
+ </xsl:if>
7724
+
7725
+ <xsl:if test="ancestor::*[local-name() = 'example']">
7726
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
7727
+ </xsl:if>
7728
+
6646
7729
  <xsl:copy-of select="@id"/>
6647
7730
 
6648
7731
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -6667,7 +7750,7 @@
6667
7750
 
6668
7751
 
6669
7752
 
6670
- 9
7753
+ inherit<!-- 9 -->
6671
7754
 
6672
7755
 
6673
7756
 
@@ -6751,7 +7834,7 @@
6751
7834
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
6752
7835
  <xsl:choose>
6753
7836
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
6754
- <xsl:call-template name="interspers">
7837
+ <xsl:call-template name="interspers-java">
6755
7838
  <xsl:with-param name="str" select="."/>
6756
7839
  </xsl:call-template>
6757
7840
  </xsl:when>
@@ -6801,6 +7884,10 @@
6801
7884
  <xsl:with-param name="char" select="$char"/>
6802
7885
  </xsl:call-template>
6803
7886
  </xsl:if>
7887
+ </xsl:template><xsl:template name="interspers-java">
7888
+ <xsl:param name="str"/>
7889
+ <xsl:param name="char" select="$zero_width_space"/>
7890
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
6804
7891
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
6805
7892
  <xsl:apply-templates mode="syntax_highlight"/>
6806
7893
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -7013,7 +8100,9 @@
7013
8100
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
7014
8101
  </xsl:if>
7015
8102
  <xsl:variable name="simple-table">
7016
- <xsl:call-template name="getSimpleTable"/>
8103
+ <xsl:call-template name="getSimpleTable">
8104
+ <xsl:with-param name="id" select="@id"/>
8105
+ </xsl:call-template>
7017
8106
  </xsl:variable>
7018
8107
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
7019
8108
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -7120,39 +8209,67 @@
7120
8209
  </xsl:otherwise>
7121
8210
  </xsl:choose>
7122
8211
  </xsl:template><xsl:template match="*[local-name() = 'example']">
7123
- <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
7124
-
8212
+
8213
+ <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
8214
+
7125
8215
 
8216
+
7126
8217
  <xsl:variable name="fo_element">
7127
- <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
8218
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
7128
8219
  inline
7129
8220
  </xsl:variable>
7130
8221
 
7131
- <!-- display 'EXAMPLE' -->
7132
- <xsl:apply-templates select="*[local-name()='name']">
7133
- <xsl:with-param name="fo_element" select="$fo_element"/>
7134
- </xsl:apply-templates>
8222
+ <fo:block-container margin-left="0mm">
7135
8223
 
7136
- <xsl:choose>
7137
- <xsl:when test="contains(normalize-space($fo_element), 'block')">
7138
- <fo:block-container xsl:use-attribute-sets="example-body-style">
7139
- <fo:block-container margin-left="0mm" margin-right="0mm">
7140
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8224
+ <xsl:choose>
8225
+
8226
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
8227
+
8228
+ <!-- display name 'EXAMPLE' in a separate block -->
8229
+ <fo:block>
8230
+ <xsl:apply-templates select="*[local-name()='name']">
7141
8231
  <xsl:with-param name="fo_element" select="$fo_element"/>
7142
8232
  </xsl:apply-templates>
8233
+ </fo:block>
8234
+
8235
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8236
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8237
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8238
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8239
+ </xsl:apply-templates>
8240
+ </fo:block-container>
7143
8241
  </fo:block-container>
7144
- </fo:block-container>
7145
- </xsl:when>
7146
- <xsl:otherwise>
7147
- <fo:inline>
7148
- <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7149
- <xsl:with-param name="fo_element" select="$fo_element"/>
7150
- </xsl:apply-templates>
7151
- </fo:inline>
7152
- </xsl:otherwise>
7153
- </xsl:choose>
7154
-
7155
- </fo:block>
8242
+ </xsl:when> <!-- end block -->
8243
+
8244
+ <xsl:otherwise> <!-- inline -->
8245
+
8246
+ <!-- display 'EXAMPLE' and first element in the same line -->
8247
+ <fo:block>
8248
+ <xsl:apply-templates select="*[local-name()='name']">
8249
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8250
+ </xsl:apply-templates>
8251
+ <fo:inline>
8252
+ <xsl:apply-templates select="*[not(local-name() = 'name')][1]">
8253
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8254
+ </xsl:apply-templates>
8255
+ </fo:inline>
8256
+ </fo:block>
8257
+
8258
+ <xsl:if test="*[not(local-name() = 'name')][position() &gt; 1]">
8259
+ <!-- display further elements in blocks -->
8260
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
8261
+ <fo:block-container margin-left="0mm" margin-right="0mm">
8262
+ <xsl:apply-templates select="*[not(local-name() = 'name')][position() &gt; 1]">
8263
+ <xsl:with-param name="fo_element" select="'block'"/>
8264
+ </xsl:apply-templates>
8265
+ </fo:block-container>
8266
+ </fo:block-container>
8267
+ </xsl:if>
8268
+ </xsl:otherwise> <!-- end inline -->
8269
+
8270
+ </xsl:choose>
8271
+ </fo:block-container>
8272
+ </fo:block-container>
7156
8273
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
7157
8274
  <xsl:param name="fo_element">block</xsl:param>
7158
8275
 
@@ -7189,10 +8306,16 @@
7189
8306
  </xsl:variable>
7190
8307
  <xsl:choose>
7191
8308
  <xsl:when test="starts-with(normalize-space($element), 'block')">
7192
- <fo:block xsl:use-attribute-sets="example-p-style">
7193
-
7194
- <xsl:apply-templates/>
7195
- </fo:block>
8309
+ <fo:block-container>
8310
+ <xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
8311
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
8312
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
8313
+ </xsl:if>
8314
+ <fo:block xsl:use-attribute-sets="example-p-style">
8315
+
8316
+ <xsl:apply-templates/>
8317
+ </fo:block>
8318
+ </fo:block-container>
7196
8319
  </xsl:when>
7197
8320
  <xsl:otherwise>
7198
8321
  <fo:inline xsl:use-attribute-sets="example-p-style">
@@ -7371,7 +8494,16 @@
7371
8494
  </fo:inline>
7372
8495
  </xsl:when>
7373
8496
  <xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
7374
- <fo:inline><xsl:apply-templates/></fo:inline>
8497
+
8498
+ <!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
8499
+ <xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
8500
+ <xsl:choose>
8501
+ <xsl:when test="$uri_src != ''">
8502
+ <fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
8503
+ </xsl:when>
8504
+ <xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
8505
+ </xsl:choose>
8506
+
7375
8507
  </xsl:otherwise>
7376
8508
  </xsl:choose>
7377
8509
  </xsl:template><xsl:template match="*[local-name() = 'tab']">
@@ -7547,10 +8679,24 @@
7547
8679
 
7548
8680
  </fo:block>
7549
8681
  <xsl:apply-templates/>
7550
- </xsl:template><xsl:template match="*[local-name() = 'review']">
8682
+ </xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
7551
8683
  <!-- comment 2019-11-29 -->
7552
8684
  <!-- <fo:block font-weight="bold">Review:</fo:block>
7553
8685
  <xsl:apply-templates /> -->
8686
+
8687
+ <xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
8688
+
8689
+ <xsl:choose>
8690
+ <!-- if there isn't the attribute '@from', then -->
8691
+ <xsl:when test="$id_from = ''">
8692
+ <fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8693
+ </xsl:when>
8694
+ <!-- if there isn't element with id 'from', then create 'bookmark' here -->
8695
+ <xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
8696
+ <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
8697
+ </xsl:when>
8698
+ </xsl:choose>
8699
+
7554
8700
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
7555
8701
  <!-- 0xA0 to space replacement -->
7556
8702
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
@@ -7648,7 +8794,7 @@
7648
8794
  <xsl:variable name="format">
7649
8795
  <xsl:choose>
7650
8796
  <xsl:when test="$type = 'arabic'">
7651
- 1.
8797
+ 1)
7652
8798
  </xsl:when>
7653
8799
  <xsl:when test="$type = 'alphabet'">
7654
8800
  a)
@@ -7695,6 +8841,11 @@
7695
8841
  </xsl:otherwise>
7696
8842
  </xsl:choose>
7697
8843
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
8844
+
8845
+ <xsl:apply-templates select="*[local-name() = 'name']">
8846
+ <xsl:with-param name="process">true</xsl:with-param>
8847
+ </xsl:apply-templates>
8848
+
7698
8849
  <fo:list-block xsl:use-attribute-sets="list-style">
7699
8850
 
7700
8851
 
@@ -7705,12 +8856,23 @@
7705
8856
 
7706
8857
 
7707
8858
 
8859
+ <xsl:if test="*[local-name() = 'name']">
8860
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8861
+ </xsl:if>
8862
+
7708
8863
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
7709
8864
  </fo:list-block>
7710
8865
  <!-- <xsl:for-each select="./iho:note">
7711
8866
  <xsl:call-template name="note"/>
7712
8867
  </xsl:for-each> -->
7713
8868
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
8869
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
8870
+ <xsl:param name="process">false</xsl:param>
8871
+ <xsl:if test="$process = 'true'">
8872
+ <fo:block xsl:use-attribute-sets="list-name-style">
8873
+ <xsl:apply-templates/>
8874
+ </fo:block>
8875
+ </xsl:if>
7714
8876
  </xsl:template><xsl:template match="*[local-name()='li']">
7715
8877
  <fo:list-item xsl:use-attribute-sets="list-item-style">
7716
8878
  <xsl:copy-of select="@id"/>
@@ -7907,7 +9069,10 @@
7907
9069
  <!-- to split by '_' and other chars -->
7908
9070
  <xsl:call-template name="add-zero-spaces-java"/>
7909
9071
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
7910
- <fo:inline id="{@id}" font-size="1pt"/>
9072
+ <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
9073
+ <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
9074
+ <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
9075
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
7911
9076
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
7912
9077
  <!-- <row>
7913
9078
  <date>05-07-2013</date>
@@ -8011,26 +9176,23 @@
8011
9176
  <xsl:if test=".//*[local-name() = 'fn']">
8012
9177
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
8013
9178
  </xsl:if>
9179
+
9180
+ <!-- display document identifier, not number [1] -->
8014
9181
  <xsl:variable name="docidentifier">
8015
9182
  <xsl:choose>
8016
9183
  <xsl:when test="*[local-name() = 'docidentifier']/@type = 'metanorma'"/>
8017
9184
  <xsl:otherwise><xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma-ordinal')]"/></xsl:otherwise>
8018
9185
  </xsl:choose>
8019
9186
  </xsl:variable>
8020
- <fo:inline><xsl:value-of select="$docidentifier"/></fo:inline>
9187
+ <xsl:value-of select="$docidentifier"/>
9188
+
8021
9189
  <xsl:apply-templates select="*[local-name() = 'note']"/>
8022
- <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
8023
- <xsl:choose>
8024
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = $lang]">
8025
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = $lang]"/>
8026
- </xsl:when>
8027
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = 'en']">
8028
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = 'en']"/>
8029
- </xsl:when>
8030
- <xsl:otherwise>
8031
- <xsl:apply-templates select="*[local-name() = 'title']"/>
8032
- </xsl:otherwise>
8033
- </xsl:choose>
9190
+
9191
+ <xsl:if test="normalize-space($docidentifier) != '' and *[local-name() = 'formattedref']">
9192
+ <xsl:text>,</xsl:text>
9193
+ <xsl:text> </xsl:text>
9194
+ </xsl:if>
9195
+
8034
9196
  <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
8035
9197
  <!-- end bibitem processing -->
8036
9198
 
@@ -8337,36 +9499,60 @@
8337
9499
 
8338
9500
 
8339
9501
 
9502
+ <xsl:if test="@type = 'editorial'">
9503
+ <xsl:attribute name="color">green</xsl:attribute>
9504
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
9505
+
9506
+ <!-- <xsl:variable name="note-style">
9507
+ <style xsl:use-attribute-sets="note-style"></style>
9508
+ </xsl:variable>
9509
+ <xsl:for-each select="xalan:nodeset($note-style)//style/@*">
9510
+ <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
9511
+ </xsl:for-each> -->
9512
+ </xsl:if>
9513
+
9514
+
8340
9515
 
8341
9516
 
9517
+ <xsl:if test="@type != 'editorial'">
9518
+ <xsl:call-template name="displayAdmonitionName">
9519
+ <xsl:with-param name="sep"> — </xsl:with-param>
9520
+ </xsl:call-template>
9521
+ </xsl:if>
9522
+
8342
9523
 
8343
- <xsl:call-template name="displayAdmonitionName"/>
8344
- <xsl:text> — </xsl:text>
8345
9524
 
8346
9525
 
8347
9526
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8348
9527
  </fo:block>
8349
9528
 
8350
9529
  </xsl:template><xsl:template name="displayAdmonitionName">
8351
-
9530
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
9531
+ <!-- <xsl:choose>
9532
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
9533
+ <xsl:choose>
9534
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
9535
+ <xsl:otherwise>
9536
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
9537
+ </xsl:otherwise>
9538
+ </xsl:choose>
9539
+ </xsl:when>
9540
+ <xsl:otherwise>
8352
9541
  <xsl:apply-templates select="*[local-name() = 'name']"/>
8353
9542
  <xsl:if test="not(*[local-name() = 'name'])">
8354
9543
  <xsl:apply-templates select="@type"/>
8355
9544
  </xsl:if>
8356
-
8357
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
8358
- <xsl:apply-templates/>
8359
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
8360
- <xsl:variable name="admonition_type_">
8361
- <xsl:call-template name="getLocalizedString">
8362
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
8363
- </xsl:call-template>
9545
+ </xsl:otherwise>
9546
+ </xsl:choose> -->
9547
+ <xsl:variable name="name">
9548
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
8364
9549
  </xsl:variable>
8365
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
8366
- <xsl:value-of select="$admonition_type"/>
8367
- <xsl:if test="$admonition_type = ''">
8368
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
9550
+ <xsl:copy-of select="$name"/>
9551
+ <xsl:if test="normalize-space($name) != ''">
9552
+ <xsl:value-of select="$sep"/>
8369
9553
  </xsl:if>
9554
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
9555
+ <xsl:apply-templates/>
8370
9556
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
8371
9557
  <!-- processing for admonition/p found in the template for 'p' -->
8372
9558
  <xsl:call-template name="paragraph"/>
@@ -8443,6 +9629,8 @@
8443
9629
  <xsl:apply-templates select="." mode="update_xml_step1"/>
8444
9630
  </xsl:for-each>
8445
9631
  </xsl:copy>
9632
+ </xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
9633
+ <xsl:apply-templates mode="update_xml_step1"/>
8446
9634
  </xsl:template>
8447
9635
  <!-- STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
8448
9636
  <xsl:template match="@*|node()" mode="update_xml_step2">
@@ -8505,7 +9693,127 @@
8505
9693
  </xsl:template>
8506
9694
 
8507
9695
  <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
8508
- <xsl:template name="convertDate">
9696
+ <xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
9697
+ <xsl:copy>
9698
+ <xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
9699
+ </xsl:copy>
9700
+ </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">
9701
+
9702
+ <!-- enclose standard's number into tag 'keep-together_within-line' -->
9703
+ <xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
9704
+ <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9705
+ <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
9706
+ <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))"/>
9707
+ <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
9708
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9709
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9710
+ <xsl:with-param name="text" select="$text_"/>
9711
+ </xsl:call-template></text></xsl:variable>
9712
+
9713
+ <xsl:variable name="parent" select="local-name(..)"/>
9714
+
9715
+ <xsl:variable name="text2">
9716
+ <text><xsl:for-each select="xalan:nodeset($text)/text/node()">
9717
+
9718
+ <xsl:choose>
9719
+ <!-- if EXPRESS reference -->
9720
+ <xsl:when test="self::text() and $parent = 'strong' and translate(., $express_reference_characters, '') = ''">
9721
+ <xsl:element name="{$element_name_keep-together_within-line}"><xsl:value-of select="."/></xsl:element>
9722
+ </xsl:when>
9723
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9724
+ </xsl:choose>
9725
+
9726
+ </xsl:for-each></text>
9727
+ </xsl:variable>
9728
+
9729
+ <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
9730
+ <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
9731
+ <xsl:variable name="text3">
9732
+ <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
9733
+ <xsl:choose>
9734
+ <xsl:when test="self::text()">
9735
+ <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))"/>
9736
+ <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
9737
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9738
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9739
+ <xsl:with-param name="text" select="$text_units_"/>
9740
+ </xsl:call-template></text></xsl:variable>
9741
+ <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
9742
+ </xsl:when>
9743
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9744
+ </xsl:choose>
9745
+ </xsl:for-each></text>
9746
+ </xsl:variable>
9747
+
9748
+ <xsl:choose>
9749
+ <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9750
+ <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9751
+ <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9752
+ <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9753
+ <xsl:choose>
9754
+ <xsl:when test="self::text()">
9755
+ <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))"/>
9756
+ <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
9757
+ <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
9758
+ <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
9759
+ <xsl:with-param name="text" select="$text_dots_"/>
9760
+ </xsl:call-template></text></xsl:variable>
9761
+ <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
9762
+ </xsl:when>
9763
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
9764
+ </xsl:choose>
9765
+ </xsl:for-each>
9766
+ </xsl:when>
9767
+ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
9768
+ </xsl:choose>
9769
+
9770
+ </xsl:template><xsl:template name="replace_text_tags">
9771
+ <xsl:param name="tag_open"/>
9772
+ <xsl:param name="tag_close"/>
9773
+ <xsl:param name="text"/>
9774
+ <xsl:choose>
9775
+ <xsl:when test="contains($text, $tag_open)">
9776
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
9777
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
9778
+
9779
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
9780
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
9781
+ </xsl:element>
9782
+
9783
+ <xsl:call-template name="replace_text_tags">
9784
+ <xsl:with-param name="tag_open" select="$tag_open"/>
9785
+ <xsl:with-param name="tag_close" select="$tag_close"/>
9786
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
9787
+ </xsl:call-template>
9788
+ </xsl:when>
9789
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
9790
+ </xsl:choose>
9791
+ </xsl:template><xsl:template name="printEdition">
9792
+ <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
9793
+ <xsl:text> </xsl:text>
9794
+ <xsl:choose>
9795
+ <xsl:when test="$edition_i18n != ''">
9796
+ <!-- Example: <edition language="fr">deuxième édition</edition> -->
9797
+ <xsl:call-template name="capitalize">
9798
+ <xsl:with-param name="str" select="$edition_i18n"/>
9799
+ </xsl:call-template>
9800
+ </xsl:when>
9801
+ <xsl:otherwise>
9802
+ <xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
9803
+ <xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
9804
+ <xsl:call-template name="capitalize">
9805
+ <xsl:with-param name="str">
9806
+ <xsl:call-template name="getLocalizedString">
9807
+ <xsl:with-param name="key">edition</xsl:with-param>
9808
+ </xsl:call-template>
9809
+ </xsl:with-param>
9810
+ </xsl:call-template>
9811
+ <xsl:text> </xsl:text>
9812
+ <xsl:value-of select="$edition"/>
9813
+ </xsl:if>
9814
+ </xsl:otherwise>
9815
+ </xsl:choose>
9816
+ </xsl:template><xsl:template name="convertDate">
8509
9817
  <xsl:param name="date"/>
8510
9818
  <xsl:param name="format" select="'short'"/>
8511
9819
  <xsl:variable name="year" select="substring($date, 1, 4)"/>
@@ -9192,4 +10500,40 @@
9192
10500
  <xsl:value-of select="$value"/>
9193
10501
  </xsl:otherwise>
9194
10502
  </xsl:choose>
10503
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
10504
+ <xsl:param name="level">0</xsl:param>
10505
+
10506
+ <fo:block margin-left="{2*$level}mm">
10507
+ <xsl:text>
10508
+ &lt;</xsl:text>
10509
+ <xsl:value-of select="local-name()"/>
10510
+ <xsl:for-each select="@*">
10511
+ <xsl:text> </xsl:text>
10512
+ <xsl:value-of select="local-name()"/>
10513
+ <xsl:text>="</xsl:text>
10514
+ <xsl:value-of select="."/>
10515
+ <xsl:text>"</xsl:text>
10516
+ </xsl:for-each>
10517
+ <xsl:text>&gt;</xsl:text>
10518
+
10519
+ <xsl:if test="not(*)">
10520
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
10521
+ <xsl:text>&lt;/</xsl:text>
10522
+ <xsl:value-of select="local-name()"/>
10523
+ <xsl:text>&gt;</xsl:text>
10524
+ </xsl:if>
10525
+ </fo:block>
10526
+
10527
+ <xsl:if test="*">
10528
+ <fo:block>
10529
+ <xsl:apply-templates mode="print_as_xml">
10530
+ <xsl:with-param name="level" select="$level + 1"/>
10531
+ </xsl:apply-templates>
10532
+ </fo:block>
10533
+ <fo:block margin-left="{2*$level}mm">
10534
+ <xsl:text>&lt;/</xsl:text>
10535
+ <xsl:value-of select="local-name()"/>
10536
+ <xsl:text>&gt;</xsl:text>
10537
+ </fo:block>
10538
+ </xsl:if>
9195
10539
  </xsl:template></xsl:stylesheet>