metanorma-iso 2.3.5 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,7 @@
19
19
  </xsl:if>
20
20
  </xsl:variable>
21
21
  <xsl:variable name="docidentifierISO" select="normalize-space($docidentifierISO_)"/>
22
+ <xsl:variable name="docidentifierISO_with_break" select="java:replaceAll(java:java.lang.String.new($docidentifierISO),'^([^\d]+) (\d)', concat('$1', $linebreak, '$2'))"/> <!-- add line break before 1st sequence 'space digit' -->
22
23
 
23
24
  <xsl:variable name="all_rights_reserved">
24
25
  <xsl:call-template name="getLocalizedString">
@@ -856,7 +857,7 @@
856
857
  <xsl:if test="$font-size != ''">
857
858
  <xsl:attribute name="font-size"><xsl:value-of select="$font-size"/></xsl:attribute>
858
859
  </xsl:if>
859
- <xsl:value-of select="$docidentifierISO"/>
860
+ <xsl:value-of select="$docidentifierISO_with_break"/>
860
861
  </fo:block>
861
862
  </fo:table-cell>
862
863
  </fo:table-row>
@@ -1105,7 +1106,7 @@
1105
1106
  </fo:table-cell>
1106
1107
  <fo:table-cell>
1107
1108
  <fo:block text-align="right" font-weight="bold" margin-bottom="13mm">
1108
- <xsl:value-of select="$docidentifierISO"/>
1109
+ <xsl:value-of select="$docidentifierISO_with_break"/>
1109
1110
  </fo:block>
1110
1111
  </fo:table-cell>
1111
1112
  </fo:table-row>
@@ -2886,11 +2887,11 @@
2886
2887
 
2887
2888
  <xsl:attribute-set name="table-header-cell-style">
2888
2889
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2889
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2890
2890
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2891
2891
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2892
2892
  <xsl:attribute name="display-align">center</xsl:attribute>
2893
2893
 
2894
+ <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2894
2895
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
2895
2896
  <xsl:attribute name="border-left"><xsl:value-of select="$table-cell-border"/></xsl:attribute>
2896
2897
  <xsl:attribute name="border-right"><xsl:value-of select="$table-cell-border"/></xsl:attribute>
@@ -2899,7 +2900,6 @@
2899
2900
 
2900
2901
  <xsl:attribute-set name="table-cell-style">
2901
2902
  <xsl:attribute name="display-align">center</xsl:attribute>
2902
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2903
2903
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2904
2904
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2905
2905
 
@@ -3651,7 +3651,7 @@
3651
3651
  <xsl:apply-templates select="." mode="contents"/>
3652
3652
  </xsl:for-each>
3653
3653
 
3654
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3654
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0]">
3655
3655
  <xsl:sort select="@displayorder" data-type="number"/>
3656
3656
  <xsl:apply-templates select="." mode="contents"/>
3657
3657
  </xsl:for-each>
@@ -4102,7 +4102,7 @@
4102
4102
  <xsl:variable name="isDeleted" select="@deleted"/>
4103
4103
 
4104
4104
  <xsl:choose>
4105
- <xsl:when test="@width">
4105
+ <xsl:when test="@width and @width != 'full-page-width' and @width != 'text-width'">
4106
4106
 
4107
4107
  <!-- centered table when table name is centered (see table-name-style) -->
4108
4108
 
@@ -4446,6 +4446,7 @@
4446
4446
  This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
4447
4447
  <xsl:when test="(@width_max &gt; $page_width and @width_min &lt; $page_width) or (@width_min &gt;= $page_width)">
4448
4448
  <!-- difference between the available space and the minimum table width -->
4449
+ <_width_min><xsl:value-of select="@width_min"/></_width_min>
4449
4450
  <xsl:variable name="W" select="$page_width - @width_min"/>
4450
4451
  <W><xsl:value-of select="$W"/></W>
4451
4452
  <!-- difference between maximum and minimum width of the table -->
@@ -4623,6 +4624,10 @@
4623
4624
  </xsl:choose>
4624
4625
  </xsl:variable>
4625
4626
 
4627
+ <xsl:variable name="table_fn_block">
4628
+ <xsl:call-template name="table_fn_display"/>
4629
+ </xsl:variable>
4630
+
4626
4631
  <xsl:variable name="tableWithNotesAndFootnotes">
4627
4632
 
4628
4633
  <fo:table keep-with-previous="always">
@@ -4670,11 +4675,25 @@
4670
4675
 
4671
4676
  <xsl:apply-templates select="../*[local-name()='note']"/>
4672
4677
 
4678
+ <xsl:variable name="isDisplayRowSeparator">
4679
+
4680
+ </xsl:variable>
4681
+
4673
4682
  <!-- horizontal row separator -->
4683
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
4684
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
4685
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
4686
+
4687
+ <xsl:call-template name="setBordersTableArray"/>
4688
+ <fo:block font-size="1pt"> </fo:block>
4689
+ </fo:block-container>
4690
+ </xsl:if>
4691
+ </xsl:if>
4674
4692
 
4675
4693
  <!-- fn processing -->
4676
4694
 
4677
- <xsl:call-template name="table_fn_display"/>
4695
+ <!-- <xsl:call-template name="table_fn_display" /> -->
4696
+ <xsl:copy-of select="$table_fn_block"/>
4678
4697
 
4679
4698
  <!-- for PAS display Notes after footnotes -->
4680
4699
 
@@ -4846,6 +4865,28 @@
4846
4865
  </fo:table-row>
4847
4866
  </xsl:template>
4848
4867
 
4868
+ <xsl:template name="setBorderUnderRow">
4869
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
4870
+ <xsl:choose>
4871
+ <xsl:when test="$border_under_row_ != ''">
4872
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
4873
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
4874
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
4875
+ <xsl:variable name="border_under_row">
4876
+ <xsl:call-template name="split">
4877
+ <xsl:with-param name="pText" select="$border_under_row_"/>
4878
+ </xsl:call-template>
4879
+ </xsl:variable>
4880
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
4881
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4882
+ </xsl:if>
4883
+ </xsl:when>
4884
+ <xsl:otherwise>
4885
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4886
+ </xsl:otherwise>
4887
+ </xsl:choose>
4888
+ </xsl:template>
4889
+
4849
4890
  <!-- row in table footer (tfoot) -->
4850
4891
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
4851
4892
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
@@ -5154,17 +5195,20 @@
5154
5195
  <xsl:for-each select="xalan:nodeset($references)//fn">
5155
5196
  <xsl:variable name="reference" select="@reference"/>
5156
5197
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
5157
- <fo:block xsl:use-attribute-sets="table-fn-style">
5158
5198
 
5159
- <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
5199
+ <fo:block xsl:use-attribute-sets="table-fn-style">
5160
5200
 
5161
- <xsl:value-of select="@reference"/>
5201
+ <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
5202
+
5203
+ <xsl:value-of select="@reference"/>
5204
+
5205
+ </fo:inline>
5206
+ <fo:inline xsl:use-attribute-sets="table-fn-body-style">
5207
+ <xsl:copy-of select="./node()"/>
5208
+ </fo:inline>
5209
+
5210
+ </fo:block>
5162
5211
 
5163
- </fo:inline>
5164
- <fo:inline xsl:use-attribute-sets="table-fn-body-style">
5165
- <xsl:copy-of select="./node()"/>
5166
- </fo:inline>
5167
- </fo:block>
5168
5212
  </xsl:if>
5169
5213
  </xsl:for-each>
5170
5214
  </xsl:template>
@@ -5193,8 +5237,16 @@
5193
5237
  <!-- figure's footnotes rendering -->
5194
5238
  <xsl:template name="fn_display_figure">
5195
5239
 
5240
+ <!-- current figure id -->
5241
+ <xsl:variable name="figure_id_">
5242
+ <xsl:value-of select="@id"/>
5243
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
5244
+ </xsl:variable>
5245
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
5246
+
5247
+ <!-- all footnotes relates to the current figure -->
5196
5248
  <xsl:variable name="references">
5197
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
5249
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
5198
5250
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
5199
5251
  <xsl:apply-templates/>
5200
5252
  </fn>
@@ -5207,91 +5259,93 @@
5207
5259
  true
5208
5260
  </xsl:variable>
5209
5261
 
5210
- <!-- current hierarchy is 'figure' element -->
5211
- <xsl:variable name="following_dl_colwidths">
5212
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
5213
- <xsl:variable name="simple-table">
5214
- <!-- <xsl:variable name="doc_ns">
5215
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
5262
+ <fo:block>
5263
+
5264
+ <!-- current hierarchy is 'figure' element -->
5265
+ <xsl:variable name="following_dl_colwidths">
5266
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
5267
+ <xsl:variable name="simple-table">
5268
+ <!-- <xsl:variable name="doc_ns">
5269
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
5270
+ </xsl:variable>
5271
+ <xsl:variable name="ns">
5272
+ <xsl:choose>
5273
+ <xsl:when test="normalize-space($doc_ns) != ''">
5274
+ <xsl:value-of select="normalize-space($doc_ns)"/>
5275
+ </xsl:when>
5276
+ <xsl:otherwise>
5277
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
5278
+ </xsl:otherwise>
5279
+ </xsl:choose>
5280
+ </xsl:variable> -->
5281
+
5282
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
5283
+ <tbody>
5284
+ <xsl:apply-templates mode="dl"/>
5285
+ </tbody>
5286
+ </xsl:for-each>
5287
+ </xsl:variable>
5288
+
5289
+ <xsl:call-template name="calculate-column-widths">
5290
+ <xsl:with-param name="cols-count" select="2"/>
5291
+ <xsl:with-param name="table" select="$simple-table"/>
5292
+ </xsl:call-template>
5293
+
5294
+ </xsl:if>
5295
+ </xsl:variable>
5296
+
5297
+ <xsl:variable name="maxlength_dt">
5298
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
5299
+ <xsl:call-template name="getMaxLength_dt"/>
5300
+ </xsl:for-each>
5216
5301
  </xsl:variable>
5217
- <xsl:variable name="ns">
5302
+
5303
+ <fo:table width="95%" table-layout="fixed">
5304
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5305
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
5306
+
5307
+ </xsl:if>
5218
5308
  <xsl:choose>
5219
- <xsl:when test="normalize-space($doc_ns) != ''">
5220
- <xsl:value-of select="normalize-space($doc_ns)"/>
5309
+ <!-- if there 'dl', then set same columns width -->
5310
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
5311
+ <xsl:call-template name="setColumnWidth_dl">
5312
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
5313
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5314
+ </xsl:call-template>
5221
5315
  </xsl:when>
5222
5316
  <xsl:otherwise>
5223
- <xsl:value-of select="substring-before(name(/*), '-')"/>
5317
+ <fo:table-column column-width="5%"/>
5318
+ <fo:table-column column-width="95%"/>
5224
5319
  </xsl:otherwise>
5225
5320
  </xsl:choose>
5226
- </xsl:variable> -->
5227
-
5228
- <xsl:for-each select="*[local-name() = 'dl'][1]">
5229
- <tbody>
5230
- <xsl:apply-templates mode="dl"/>
5231
- </tbody>
5232
- </xsl:for-each>
5233
- </xsl:variable>
5234
-
5235
- <xsl:call-template name="calculate-column-widths">
5236
- <xsl:with-param name="cols-count" select="2"/>
5237
- <xsl:with-param name="table" select="$simple-table"/>
5238
- </xsl:call-template>
5239
-
5240
- </xsl:if>
5241
- </xsl:variable>
5242
-
5243
- <xsl:variable name="maxlength_dt">
5244
- <xsl:for-each select="*[local-name() = 'dl'][1]">
5245
- <xsl:call-template name="getMaxLength_dt"/>
5246
- </xsl:for-each>
5247
- </xsl:variable>
5321
+ <fo:table-body>
5322
+ <xsl:for-each select="xalan:nodeset($references)//fn">
5323
+ <xsl:variable name="reference" select="@reference"/>
5324
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
5325
+ <fo:table-row>
5326
+ <fo:table-cell>
5327
+ <fo:block>
5328
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
5329
+ <xsl:value-of select="@reference"/>
5330
+ </fo:inline>
5331
+ </fo:block>
5332
+ </fo:table-cell>
5333
+ <fo:table-cell>
5334
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
5335
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5248
5336
 
5249
- <fo:block>
5250
- <fo:table width="95%" table-layout="fixed">
5251
- <xsl:if test="normalize-space($key_iso) = 'true'">
5252
- <xsl:attribute name="font-size">10pt</xsl:attribute>
5337
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
5253
5338
 
5254
- </xsl:if>
5255
- <xsl:choose>
5256
- <!-- if there 'dl', then set same columns width -->
5257
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
5258
- <xsl:call-template name="setColumnWidth_dl">
5259
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
5260
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5261
- </xsl:call-template>
5262
- </xsl:when>
5263
- <xsl:otherwise>
5264
- <fo:table-column column-width="15%"/>
5265
- <fo:table-column column-width="85%"/>
5266
- </xsl:otherwise>
5267
- </xsl:choose>
5268
- <fo:table-body>
5269
- <xsl:for-each select="xalan:nodeset($references)//fn">
5270
- <xsl:variable name="reference" select="@reference"/>
5271
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
5272
- <fo:table-row>
5273
- <fo:table-cell>
5274
- <fo:block>
5275
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
5276
- <xsl:value-of select="@reference"/>
5277
- </fo:inline>
5278
- </fo:block>
5279
- </fo:table-cell>
5280
- <fo:table-cell>
5281
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
5282
- <xsl:if test="normalize-space($key_iso) = 'true'">
5283
-
5284
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
5339
+ </xsl:if>
5340
+ <xsl:copy-of select="./node()"/>
5341
+ </fo:block>
5342
+ </fo:table-cell>
5343
+ </fo:table-row>
5344
+ </xsl:if>
5345
+ </xsl:for-each>
5346
+ </fo:table-body>
5347
+ </fo:table>
5285
5348
 
5286
- </xsl:if>
5287
- <xsl:copy-of select="./node()"/>
5288
- </fo:block>
5289
- </fo:table-cell>
5290
- </fo:table-row>
5291
- </xsl:if>
5292
- </xsl:for-each>
5293
- </fo:table-body>
5294
- </fo:table>
5295
5349
  </fo:block>
5296
5350
  </xsl:if>
5297
5351
 
@@ -5363,7 +5417,7 @@
5363
5417
 
5364
5418
  <xsl:variable name="key_iso">
5365
5419
 
5366
- <xsl:if test="$parent = 'figure' or $parent = 'formula'">true</xsl:if>
5420
+ <xsl:if test="$parent = 'figure' or $parent = 'formula' or ../@key = 'true'">true</xsl:if>
5367
5421
  <!-- and (not(../@class) or ../@class !='pseudocode') -->
5368
5422
  </xsl:variable>
5369
5423
 
@@ -5376,12 +5430,14 @@
5376
5430
 
5377
5431
  <xsl:attribute name="margin-bottom">0</xsl:attribute>
5378
5432
 
5379
- <xsl:variable name="title-where">
5433
+ <!-- <xsl:variable name="title-where">
5380
5434
  <xsl:call-template name="getLocalizedString">
5381
5435
  <xsl:with-param name="key">where</xsl:with-param>
5382
5436
  </xsl:call-template>
5383
5437
  </xsl:variable>
5384
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
5438
+ <xsl:value-of select="$title-where"/> -->
5439
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
5440
+ <xsl:text> </xsl:text>
5385
5441
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
5386
5442
  <xsl:text/>
5387
5443
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -5393,12 +5449,14 @@
5393
5449
 
5394
5450
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
5395
5451
 
5396
- <xsl:variable name="title-where">
5452
+ <!-- <xsl:variable name="title-where">
5397
5453
  <xsl:call-template name="getLocalizedString">
5398
5454
  <xsl:with-param name="key">where</xsl:with-param>
5399
5455
  </xsl:call-template>
5400
5456
  </xsl:variable>
5401
- <xsl:value-of select="$title-where"/>
5457
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
5458
+ <!-- preceding 'p' with word 'where' -->
5459
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
5402
5460
  </fo:block>
5403
5461
  </xsl:when> <!-- END: a few components -->
5404
5462
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -5593,6 +5651,9 @@
5593
5651
 
5594
5652
  </xsl:template> <!-- END: dl -->
5595
5653
 
5654
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
5655
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
5656
+
5596
5657
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
5597
5658
  <xsl:param name="process">false</xsl:param>
5598
5659
  <xsl:if test="$process = 'true'">
@@ -6123,12 +6184,12 @@
6123
6184
  <xsl:param name="value"/>
6124
6185
  <xsl:variable name="add_width" select="string-length($value) * 20"/>
6125
6186
  <xsl:variable name="maxwidth" select="60 + $add_width"/>
6126
- <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" -->
6127
- <xsl:attribute name="height">5mm</xsl:attribute>
6187
+ <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-10%"><!-- alignment-baseline="middle" -->
6188
+ <xsl:attribute name="height">3.5mm</xsl:attribute> <!-- 5mm -->
6128
6189
  <xsl:attribute name="content-width">100%</xsl:attribute>
6129
6190
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6130
6191
  <xsl:attribute name="scaling">uniform</xsl:attribute>
6131
- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
6192
+ <!-- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
6132
6193
  <g>
6133
6194
  <xsl:if test="$type = 'closing' or $type = 'end'">
6134
6195
  <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
@@ -6142,6 +6203,27 @@
6142
6203
  </xsl:if>
6143
6204
  <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
6144
6205
  </text>
6206
+ </svg> -->
6207
+ <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
6208
+ <g>
6209
+ <xsl:if test="$type = 'closing' or $type = 'end'">
6210
+ <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
6211
+ </xsl:if>
6212
+ <polyline points="0,2.5 {$maxwidth},2.5 {$maxwidth + 20},40 {$maxwidth},77.5 0,77.5" stroke="black" stroke-width="5" fill="white"/>
6213
+ <line x1="9.5" y1="0" x2="9.5" y2="80" stroke="black" stroke-width="19"/>
6214
+ </g>
6215
+ <xsl:variable name="text_x">
6216
+ <xsl:choose>
6217
+ <xsl:when test="$type = 'closing' or $type = 'end'">28</xsl:when>
6218
+ <xsl:otherwise>22</xsl:otherwise>
6219
+ </xsl:choose>
6220
+ </xsl:variable>
6221
+ <text font-family="Arial" x="{$text_x}" y="50" font-size="40pt">
6222
+ <xsl:value-of select="$kind"/>
6223
+ </text>
6224
+ <text font-family="Arial" x="{$text_x + 33}" y="65" font-size="38pt">
6225
+ <xsl:value-of select="$value"/>
6226
+ </text>
6145
6227
  </svg>
6146
6228
  </fo:instream-foreign-object>
6147
6229
  </xsl:template>
@@ -6210,7 +6292,7 @@
6210
6292
  </xsl:copy>
6211
6293
  </xsl:template>
6212
6294
 
6213
- <xsl:template match="*[local-name() = 'pagebreak']" mode="landscape_portrait">
6295
+ <xsl:template match="*[local-name() = 'pagebreak'][not(following-sibling::*[1][local-name() = 'pagebreak'])]" mode="landscape_portrait">
6214
6296
 
6215
6297
  <!-- determine pagebreak is last element before </fo:flow> or not -->
6216
6298
  <xsl:variable name="isLast">
@@ -6222,16 +6304,18 @@
6222
6304
  <xsl:if test="contains($isLast, 'false')">
6223
6305
 
6224
6306
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
6225
- <xsl:variable name="tree">
6307
+
6308
+ <xsl:variable name="tree_">
6226
6309
  <xsl:for-each select="ancestor::*[ancestor::fo:flow]">
6227
6310
  <element pos="{position()}">
6228
6311
  <xsl:value-of select="name()"/>
6229
6312
  </element>
6230
6313
  </xsl:for-each>
6231
6314
  </xsl:variable>
6315
+ <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
6232
6316
 
6233
6317
  <!-- close fo:page-sequence (closing preceding fo elements) -->
6234
- <xsl:for-each select="xalan:nodeset($tree)//element">
6318
+ <xsl:for-each select="$tree//element">
6235
6319
  <xsl:sort data-type="number" order="descending" select="@pos"/>
6236
6320
  <xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
6237
6321
  <xsl:value-of select="."/>
@@ -6242,7 +6326,6 @@
6242
6326
 
6243
6327
  <!-- <pagebreak/> -->
6244
6328
  <!-- create a new fo:page-sequence (opening fo elements) -->
6245
-
6246
6329
  <xsl:text disable-output-escaping="yes">&lt;fo:page-sequence master-reference="document</xsl:text><xsl:if test="$orientation != ''">-<xsl:value-of select="$orientation"/></xsl:if><xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
6247
6330
  <fo:static-content flow-name="xsl-footnote-separator">
6248
6331
  <fo:block>
@@ -6252,7 +6335,7 @@
6252
6335
  <xsl:call-template name="insertHeaderFooter"/>
6253
6336
  <xsl:text disable-output-escaping="yes">&lt;fo:flow flow-name="xsl-region-body"&gt;</xsl:text>
6254
6337
 
6255
- <xsl:for-each select="xalan:nodeset($tree)//element">
6338
+ <xsl:for-each select="$tree//element">
6256
6339
  <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
6257
6340
  <xsl:value-of select="."/>
6258
6341
  <xsl:for-each select="@*[local-name() != 'pos']">
@@ -6264,6 +6347,7 @@
6264
6347
  </xsl:for-each>
6265
6348
  <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
6266
6349
  </xsl:for-each>
6350
+
6267
6351
  </xsl:if>
6268
6352
  </xsl:template>
6269
6353
  <!-- ================================================================ -->
@@ -6465,18 +6549,34 @@
6465
6549
 
6466
6550
  <xsl:template name="add-zero-spaces-java">
6467
6551
  <xsl:param name="text" select="."/>
6468
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
6469
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
6552
+
6553
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
6554
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
6555
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
6556
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
6557
+ <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
6558
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
6470
6559
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
6471
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
6560
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
6472
6561
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
6473
- <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
6562
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
6474
6563
  <!-- add zero-width space (#x200B) before character: { -->
6475
- <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
6564
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
6476
6565
  <!-- add zero-width space (#x200B) after character: , -->
6477
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
6566
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
6567
+ <!-- add zero-width space (#x200B) after character: '/' -->
6568
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
6569
+
6570
+ <xsl:variable name="text9">
6571
+ <xsl:choose>
6572
+ <xsl:when test="$isGenerateTableIF = 'true'">
6573
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
6574
+ </xsl:when>
6575
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
6576
+ </xsl:choose>
6577
+ </xsl:variable>
6478
6578
 
6479
- <xsl:value-of select="$text5"/>
6579
+ <xsl:value-of select="$text9"/>
6480
6580
  </xsl:template>
6481
6581
 
6482
6582
  <xsl:template name="add-zero-spaces-link-java">
@@ -6484,8 +6584,10 @@
6484
6584
 
6485
6585
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
6486
6586
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
6487
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
6488
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
6587
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
6588
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
6589
+ <!-- remove zero-width space at the end -->
6590
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
6489
6591
  </xsl:template>
6490
6592
 
6491
6593
  <!-- add zero space after dash character (for table's entries) -->
@@ -6622,7 +6724,7 @@
6622
6724
  </xsl:copy>
6623
6725
  </xsl:template>
6624
6726
 
6625
- <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p']) and not(*[local-name()='sourcecode'])]" mode="table-without-br">
6727
+ <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p']) and not(*[local-name()='sourcecode']) and not(*[local-name()='ul']) and not(*[local-name()='ol'])]" mode="table-without-br">
6626
6728
  <xsl:copy>
6627
6729
  <xsl:copy-of select="@*"/>
6628
6730
  <p>
@@ -6698,6 +6800,14 @@
6698
6800
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
6699
6801
  </xsl:template>
6700
6802
 
6803
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'ol' or local-name() = 'ul']" mode="table-without-br">
6804
+ <xsl:apply-templates mode="table-without-br"/>
6805
+ </xsl:template>
6806
+
6807
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'li']" mode="table-without-br">
6808
+ <xsl:apply-templates mode="table-without-br"/>
6809
+ </xsl:template>
6810
+
6701
6811
  <!-- mode="table-without-br" -->
6702
6812
  <!-- ================================== -->
6703
6813
  <!-- END: Step 0. replace <br/> to <p>...</p> -->
@@ -6830,9 +6940,28 @@
6830
6940
  </xsl:variable>
6831
6941
  <xsl:copy-of select="$newRow"/>
6832
6942
 
6833
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6834
- <xsl:with-param name="previousRow" select="$newRow"/>
6835
- </xsl:apply-templates>
6943
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
6944
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
6945
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
6946
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
6947
+ <xsl:choose>
6948
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
6949
+ <xsl:copy-of select="following-sibling::tr"/>
6950
+ </xsl:when>
6951
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
6952
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
6953
+
6954
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6955
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
6956
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6957
+ </xsl:apply-templates>
6958
+ </xsl:when> -->
6959
+ <xsl:otherwise>
6960
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6961
+ <xsl:with-param name="previousRow" select="$newRow"/>
6962
+ </xsl:apply-templates>
6963
+ </xsl:otherwise>
6964
+ </xsl:choose>
6836
6965
  </xsl:template>
6837
6966
  <!-- End mode simple-table-rowspan -->
6838
6967
 
@@ -6995,6 +7124,27 @@
6995
7124
  </xsl:call-template>
6996
7125
  </xsl:template>
6997
7126
 
7127
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
7128
+ <xsl:variable name="link">
7129
+ <link_updated>
7130
+ <xsl:variable name="target_text">
7131
+ <xsl:choose>
7132
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
7133
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
7134
+ </xsl:when>
7135
+ <xsl:otherwise>
7136
+ <xsl:value-of select="normalize-space(@target)"/>
7137
+ </xsl:otherwise>
7138
+ </xsl:choose>
7139
+ </xsl:variable>
7140
+ <xsl:value-of select="$target_text"/>
7141
+ </link_updated>
7142
+ </xsl:variable>
7143
+ <xsl:for-each select="xalan:nodeset($link)/*">
7144
+ <xsl:apply-templates mode="td_text_with_formatting"/>
7145
+ </xsl:for-each>
7146
+ </xsl:template>
7147
+
6998
7148
  <xsl:template name="getFormattingTags">
6999
7149
  <tags>
7000
7150
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -7343,7 +7493,7 @@
7343
7493
  </xsl:variable>
7344
7494
  <fo:inline xsl:use-attribute-sets="link-style">
7345
7495
 
7346
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
7496
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
7347
7497
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
7348
7498
  </xsl:if>
7349
7499
 
@@ -7522,7 +7672,7 @@
7522
7672
  <xsl:attribute name="font-size">inherit</xsl:attribute>
7523
7673
  </xsl:if>
7524
7674
 
7525
- <fo:block-container margin-left="0mm">
7675
+ <fo:block-container margin-left="0mm" margin-right="0mm">
7526
7676
 
7527
7677
  <fo:block>
7528
7678
 
@@ -7704,13 +7854,16 @@
7704
7854
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
7705
7855
  </xsl:call-template>
7706
7856
 
7857
+ <!-- Example: Dimensions in millimeters -->
7858
+ <xsl:apply-templates select="*[local-name() = 'note'][@type = 'units']"/>
7859
+
7707
7860
  <fo:block xsl:use-attribute-sets="figure-style">
7708
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7861
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
7709
7862
  </fo:block>
7710
- <xsl:call-template name="fn_display_figure"/>
7711
- <xsl:for-each select="*[local-name() = 'note']">
7863
+ <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
7712
7864
  <xsl:call-template name="note"/>
7713
7865
  </xsl:for-each>
7866
+ <xsl:call-template name="fn_display_figure"/>
7714
7867
 
7715
7868
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
7716
7869
 
@@ -7773,7 +7926,13 @@
7773
7926
  </xsl:choose>
7774
7927
  </xsl:variable>
7775
7928
 
7776
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7929
+ <xsl:variable name="image_width_effective">
7930
+
7931
+ <xsl:value-of select="$width_effective"/>
7932
+
7933
+ </xsl:variable>
7934
+
7935
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7777
7936
  <xsl:if test="number($scale) &lt; 100">
7778
7937
 
7779
7938
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -7965,24 +8124,47 @@
7965
8124
 
7966
8125
  </xsl:when>
7967
8126
  <xsl:otherwise>
7968
- <fo:block xsl:use-attribute-sets="image-style">
7969
- <fo:instream-foreign-object fox:alt-text="{$alt-text}">
7970
- <xsl:attribute name="width">100%</xsl:attribute>
7971
- <xsl:attribute name="content-height">100%</xsl:attribute>
7972
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7973
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
7974
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
7975
- <!-- effective height 297 - 27.4 - 13 = 256.6 -->
7976
- <!-- effective width 210 - 12.5 - 25 = 172.5 -->
7977
- <!-- effective height / width = 1.48, 1.4 - with title -->
7978
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
7979
- <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
7980
- <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
7981
- </xsl:if>
7982
- <xsl:attribute name="scaling">uniform</xsl:attribute>
7983
- <xsl:copy-of select="$svg_content"/>
7984
- </fo:instream-foreign-object>
7985
- </fo:block>
8127
+
8128
+ <xsl:variable name="element">
8129
+ <xsl:choose>
8130
+ <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
8131
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
8132
+ </xsl:when>
8133
+ <xsl:otherwise>
8134
+ <fo:block xsl:use-attribute-sets="image-style">
8135
+ <xsl:if test="ancestor::*[local-name() = 'dt']">
8136
+ <xsl:attribute name="text-align">left</xsl:attribute>
8137
+ </xsl:if>
8138
+ </fo:block>
8139
+ </xsl:otherwise>
8140
+ </xsl:choose>
8141
+ </xsl:variable>
8142
+
8143
+ <xsl:for-each select="xalan:nodeset($element)/*">
8144
+ <xsl:copy>
8145
+ <xsl:copy-of select="@*"/>
8146
+ <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
8147
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
8148
+ <xsl:if test="$isGenerateTableIF = 'false'">
8149
+ <xsl:attribute name="width">100%</xsl:attribute>
8150
+ </xsl:if>
8151
+ <xsl:attribute name="content-height">100%</xsl:attribute>
8152
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8153
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
8154
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
8155
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
8156
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
8157
+ <!-- effective height / width = 1.48, 1.4 - with title -->
8158
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
8159
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
8160
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
8161
+ </xsl:if>
8162
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
8163
+ <xsl:copy-of select="$svg_content"/>
8164
+ </fo:instream-foreign-object>
8165
+ <!-- </fo:block> -->
8166
+ </xsl:copy>
8167
+ </xsl:for-each>
7986
8168
  </xsl:otherwise>
7987
8169
  </xsl:choose>
7988
8170
  </xsl:template>
@@ -8074,6 +8256,13 @@
8074
8256
  </xsl:for-each>
8075
8257
  </xsl:template>
8076
8258
 
8259
+ <!-- For the structures like: <dt><image src="" mimetype="image/svg+xml" height="" width=""><svg xmlns="http://www.w3.org/2000/svg" ... -->
8260
+ <xsl:template match="*[local-name() != 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
8261
+ <xsl:for-each select="*[local-name() = 'svg']">
8262
+ <xsl:call-template name="image_svg"/>
8263
+ </xsl:for-each>
8264
+ </xsl:template>
8265
+
8077
8266
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
8078
8267
  <xsl:variable name="svg_content" select="document(@src)"/>
8079
8268
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -8212,6 +8401,8 @@
8212
8401
  <xsl:value-of select="."/>
8213
8402
  </xsl:template>
8214
8403
 
8404
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="bookmarks" priority="3"/>
8405
+
8215
8406
  <xsl:template match="node()" mode="contents">
8216
8407
  <xsl:apply-templates mode="contents"/>
8217
8408
  </xsl:template>
@@ -8328,6 +8519,13 @@
8328
8519
  <xsl:when test="$contents_nodes/doc">
8329
8520
  <xsl:choose>
8330
8521
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
8522
+
8523
+ <xsl:if test="$contents_nodes/collection">
8524
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
8525
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
8526
+ </fo:bookmark>
8527
+ </xsl:if>
8528
+
8331
8529
  <xsl:for-each select="$contents_nodes/doc">
8332
8530
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
8333
8531
  <xsl:if test="@bundle = 'true'">
@@ -8519,7 +8717,15 @@
8519
8717
  <xsl:value-of select="@section"/>
8520
8718
  <xsl:text> </xsl:text>
8521
8719
  </xsl:if>
8522
- <xsl:value-of select="normalize-space(title)"/>
8720
+ <xsl:variable name="title">
8721
+ <xsl:for-each select="title/node()">
8722
+ <xsl:choose>
8723
+ <xsl:when test="local-name() = 'add' and starts-with(., $ace_tag)"><!-- skip --></xsl:when>
8724
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
8725
+ </xsl:choose>
8726
+ </xsl:for-each>
8727
+ </xsl:variable>
8728
+ <xsl:value-of select="normalize-space($title)"/>
8523
8729
  </fo:bookmark-title>
8524
8730
  <xsl:apply-templates mode="bookmark"/>
8525
8731
  </fo:bookmark>
@@ -8545,6 +8751,12 @@
8545
8751
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/>
8546
8752
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/>
8547
8753
 
8754
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note'][@type = 'units'] | *[local-name() = 'image']/*[local-name() = 'note'][@type = 'units']" priority="2">
8755
+ <fo:block text-align="right" keep-with-next="always">
8756
+ <xsl:apply-templates/>
8757
+ </fo:block>
8758
+ </xsl:template>
8759
+
8548
8760
  <!-- ====== -->
8549
8761
  <!-- ====== -->
8550
8762
  <xsl:template match="*[local-name() = 'title']" mode="contents_item">
@@ -8694,6 +8906,10 @@
8694
8906
  </xsl:for-each>
8695
8907
  </xsl:template>
8696
8908
 
8909
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="contents_item" priority="2">
8910
+ <xsl:value-of select="."/>
8911
+ </xsl:template>
8912
+
8697
8913
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
8698
8914
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
8699
8915
  <xsl:apply-templates mode="contents_item"/>
@@ -10192,6 +10408,44 @@
10192
10408
 
10193
10409
  <fo:list-block xsl:use-attribute-sets="list-style">
10194
10410
 
10411
+ <xsl:variable name="provisional_distance_between_starts_">
10412
+ <attributes xsl:use-attribute-sets="list-style">
10413
+
10414
+ </attributes>
10415
+ </xsl:variable>
10416
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
10417
+ <xsl:if test="$provisional_distance_between_starts != ''">
10418
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
10419
+ </xsl:if>
10420
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
10421
+
10422
+ <!-- increase provisional-distance-between-starts for long lists -->
10423
+ <xsl:if test="local-name() = 'ol'">
10424
+ <!-- Examples: xiii), xviii), xxviii) -->
10425
+ <xsl:variable name="item_numbers">
10426
+ <xsl:for-each select="*[local-name() = 'li']">
10427
+ <item><xsl:call-template name="getListItemFormat"/></item>
10428
+ </xsl:for-each>
10429
+ </xsl:variable>
10430
+
10431
+ <xsl:variable name="max_length">
10432
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
10433
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
10434
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
10435
+ </xsl:for-each>
10436
+ </xsl:variable>
10437
+
10438
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
10439
+ <xsl:variable name="addon" select="$max_length - 4"/>
10440
+ <xsl:if test="$addon &gt; 0">
10441
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
10442
+ </xsl:if>
10443
+ <!-- DEBUG -->
10444
+ <!-- <xsl:copy-of select="$item_numbers"/>
10445
+ <max_length><xsl:value-of select="$max_length"/></max_length>
10446
+ <addon><xsl:value-of select="$addon"/></addon> -->
10447
+ </xsl:if>
10448
+
10195
10449
  <xsl:if test="not(ancestor::*[local-name() = 'ul' or local-name() = 'ol'])">
10196
10450
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
10197
10451
  </xsl:if>
@@ -10922,7 +11176,6 @@
10922
11176
  <xsl:if test="@type = 'editorial'">
10923
11177
  <xsl:attribute name="color">green</xsl:attribute>
10924
11178
  <xsl:attribute name="font-weight">normal</xsl:attribute>
10925
-
10926
11179
  <!-- <xsl:variable name="note-style">
10927
11180
  <style xsl:use-attribute-sets="note-style"></style>
10928
11181
  </xsl:variable>
@@ -11261,7 +11514,7 @@
11261
11514
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
11262
11515
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
11263
11516
  <!-- add &lt; and &gt; to \S -->
11264
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
11517
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
11265
11518
  <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable>
11266
11519
  <xsl:variable name="text3">
11267
11520
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -11283,7 +11536,8 @@
11283
11536
  <xsl:choose>
11284
11537
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
11285
11538
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
11286
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
11539
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
11540
+ <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
11287
11541
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
11288
11542
  <xsl:choose>
11289
11543
  <xsl:when test="self::text()">
@@ -11886,6 +12140,23 @@
11886
12140
  </xsl:if>
11887
12141
  </xsl:template>
11888
12142
 
12143
+ <xsl:template name="setBlockAttributes">
12144
+ <xsl:param name="text_align_default">left</xsl:param>
12145
+ <xsl:call-template name="setTextAlignment">
12146
+ <xsl:with-param name="default" select="$text_align_default"/>
12147
+ </xsl:call-template>
12148
+
12149
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
12150
+ <!-- Example: keep-lines-together="true" -->
12151
+ <xsl:if test="@keep-lines-together = 'true'">
12152
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
12153
+ </xsl:if>
12154
+ <!-- Example: keep-with-next="true" -->
12155
+ <xsl:if test="@keep-with-next = 'true'">
12156
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
12157
+ </xsl:if>
12158
+ </xsl:template>
12159
+
11889
12160
  <xsl:template name="number-to-words">
11890
12161
  <xsl:param name="number"/>
11891
12162
  <xsl:param name="first"/>