metanorma-bipm 2.4.4 → 2.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3883,17 +3883,30 @@
3883
3883
  <xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
3884
3884
 
3885
3885
  <xsl:param name="table_if">false</xsl:param> <!-- generate extended table in IF for autolayout-algorithm -->
3886
- <xsl:param name="table_widths"/> <!-- path to xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
3886
+ <xsl:param name="table_widths"/> <!-- (debug: path to) xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
3887
3887
  <!-- Example: <tables>
3888
- <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
3889
- <tbody>
3890
- <tr>
3891
- <td id="tab-symdu_1_1">
3892
- <p_len>6</p_len>
3893
- <p_len>100</p_len> for 2nd paragraph
3894
- <word_len>6</word_len>
3895
- <word_len>20</word_len>
3896
- ...
3888
+ <table page-width="509103" id="table1" width_max="223561" width_min="223560">
3889
+ <column width_max="39354" width_min="39354"/>
3890
+ <column width_max="75394" width_min="75394"/>
3891
+ <column width_max="108813" width_min="108813"/>
3892
+ <tbody>
3893
+ <tr>
3894
+ <td width_max="39354" width_min="39354">
3895
+ <p_len>39354</p_len>
3896
+ <word_len>39354</word_len>
3897
+ </td>
3898
+
3899
+ OLD:
3900
+ <tables>
3901
+ <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
3902
+ <tbody>
3903
+ <tr>
3904
+ <td id="tab-symdu_1_1">
3905
+ <p_len>6</p_len>
3906
+ <p_len>100</p_len> for 2nd paragraph
3907
+ <word_len>6</word_len>
3908
+ <word_len>20</word_len>
3909
+ ...
3897
3910
  -->
3898
3911
 
3899
3912
  <!-- for command line debug: <xsl:variable name="table_widths_from_if" select="document($table_widths)"/> -->
@@ -4116,6 +4129,10 @@
4116
4129
  <xsl:variable name="zero_width_space">​</xsl:variable>
4117
4130
  <xsl:variable name="hair_space"> </xsl:variable>
4118
4131
  <xsl:variable name="en_dash">–</xsl:variable>
4132
+ <xsl:variable name="em_dash">—</xsl:variable>
4133
+ <xsl:variable name="cr">&#13;</xsl:variable>
4134
+ <xsl:variable name="lf">
4135
+ </xsl:variable>
4119
4136
 
4120
4137
  <xsl:template name="getTitle">
4121
4138
  <xsl:param name="name"/>
@@ -4432,6 +4449,10 @@
4432
4449
 
4433
4450
  </xsl:attribute-set> <!-- example-name-style -->
4434
4451
 
4452
+ <xsl:template name="refine_example-name-style">
4453
+
4454
+ </xsl:template>
4455
+
4435
4456
  <xsl:attribute-set name="example-p-style">
4436
4457
 
4437
4458
  </xsl:attribute-set> <!-- example-p-style -->
@@ -4446,6 +4467,10 @@
4446
4467
 
4447
4468
  </xsl:attribute-set> <!-- termexample-name-style -->
4448
4469
 
4470
+ <xsl:template name="refine_termexample-name-style">
4471
+
4472
+ </xsl:template>
4473
+
4449
4474
  <!-- ========================== -->
4450
4475
  <!-- Table styles -->
4451
4476
  <!-- ========================== -->
@@ -4662,6 +4687,10 @@
4662
4687
 
4663
4688
  </xsl:attribute-set> <!-- table-fn-style -->
4664
4689
 
4690
+ <xsl:template name="refine_table-fn-style">
4691
+
4692
+ </xsl:template>
4693
+
4665
4694
  <xsl:attribute-set name="table-fn-number-style">
4666
4695
  <xsl:attribute name="font-size">80%</xsl:attribute>
4667
4696
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
@@ -4671,6 +4700,10 @@
4671
4700
 
4672
4701
  </xsl:attribute-set> <!-- table-fn-number-style -->
4673
4702
 
4703
+ <xsl:template name="refine_table-fn-number-style">
4704
+
4705
+ </xsl:template>
4706
+
4674
4707
  <xsl:attribute-set name="fn-container-body-style">
4675
4708
  <xsl:attribute name="text-indent">0</xsl:attribute>
4676
4709
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -5802,6 +5835,20 @@
5802
5835
  </xsl:for-each>
5803
5836
  </xsl:template>
5804
5837
 
5838
+ <xsl:param name="table_only_with_id"/><!-- Example: table1, for table auto-layout algorithm -->
5839
+
5840
+ <xsl:template match="*[local-name()='table']" priority="2">
5841
+ <xsl:choose>
5842
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
5843
+ <xsl:call-template name="table"/>
5844
+ </xsl:when>
5845
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
5846
+ <xsl:otherwise>
5847
+ <xsl:call-template name="table"/>
5848
+ </xsl:otherwise>
5849
+ </xsl:choose>
5850
+ </xsl:template>
5851
+
5805
5852
  <xsl:template match="*[local-name()='table']" name="table">
5806
5853
 
5807
5854
  <xsl:variable name="table-preamble">
@@ -5811,9 +5858,11 @@
5811
5858
  <xsl:variable name="table">
5812
5859
 
5813
5860
  <xsl:variable name="simple-table">
5814
- <xsl:call-template name="getSimpleTable">
5815
- <xsl:with-param name="id" select="@id"/>
5816
- </xsl:call-template>
5861
+ <xsl:if test="$isGenerateTableIF = 'true' and $isApplyAutolayoutAlgorithm = 'true'">
5862
+ <xsl:call-template name="getSimpleTable">
5863
+ <xsl:with-param name="id" select="@id"/>
5864
+ </xsl:call-template>
5865
+ </xsl:if>
5817
5866
  </xsl:variable>
5818
5867
  <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
5819
5868
 
@@ -5915,9 +5964,9 @@
5915
5964
  </xsl:attribute>
5916
5965
  </xsl:for-each>
5917
5966
 
5918
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
5967
+ <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'][not(@type = 'units')] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
5919
5968
  <xsl:if test="$isNoteOrFnExist = 'true'">
5920
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
5969
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
5921
5970
  </xsl:if>
5922
5971
 
5923
5972
  <xsl:choose>
@@ -6085,6 +6134,17 @@
6085
6134
  </xsl:if>
6086
6135
  </xsl:template> <!-- table/name -->
6087
6136
 
6137
+ <!-- workaround solution for https://github.com/metanorma/metanorma-iso/issues/1151#issuecomment-2033087938 -->
6138
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'note'][@type = 'units']/*[local-name() = 'p']/text()" priority="4">
6139
+ <xsl:choose>
6140
+ <xsl:when test="preceding-sibling::*[local-name() = 'br']">
6141
+ <!-- remove CR or LF at start -->
6142
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'^(&#13;&#10;|&#13;|&#10;)', '')"/>
6143
+ </xsl:when>
6144
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
6145
+ </xsl:choose>
6146
+ </xsl:template>
6147
+
6088
6148
  <!-- SOURCE: ... -->
6089
6149
  <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
6090
6150
  <xsl:call-template name="termsource"/>
@@ -6495,7 +6555,7 @@
6495
6555
  <xsl:param name="colwidths"/>
6496
6556
  <xsl:param name="colgroup"/>
6497
6557
 
6498
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='example'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source'] or ../*[local-name()='p']"/>
6558
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'][not(@type = 'units')] or ../*[local-name()='example'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source'] or ../*[local-name()='p']"/>
6499
6559
 
6500
6560
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
6501
6561
 
@@ -6561,7 +6621,7 @@
6561
6621
 
6562
6622
  <!-- fn will be processed inside 'note' processing -->
6563
6623
 
6564
- <xsl:if test="count(ancestor::bipm:table//*[local-name()='note']) &gt; 1">
6624
+ <xsl:if test="count(ancestor::bipm:table//*[local-name()='note'][not(@type = 'units')]) &gt; 1">
6565
6625
  <fo:block font-weight="bold" role="SKIP">
6566
6626
  <xsl:variable name="curr_lang" select="ancestor::bipm:bipm-standard/bipm:bibdata/bipm:language"/>
6567
6627
  <xsl:choose>
@@ -6577,7 +6637,7 @@
6577
6637
 
6578
6638
  <xsl:apply-templates select="../*[local-name()='p']"/>
6579
6639
  <xsl:apply-templates select="../*[local-name()='dl']"/>
6580
- <xsl:apply-templates select="../*[local-name()='note']"/>
6640
+ <xsl:apply-templates select="../*[local-name()='note'][not(@type = 'units')]"/>
6581
6641
  <xsl:apply-templates select="../*[local-name()='example']"/>
6582
6642
  <xsl:apply-templates select="../*[local-name()='source']"/>
6583
6643
 
@@ -6587,7 +6647,7 @@
6587
6647
 
6588
6648
  <!-- horizontal row separator -->
6589
6649
  <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
6590
- <xsl:if test="(../*[local-name()='note'] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
6650
+ <xsl:if test="(../*[local-name()='note'][not(@type = 'units')] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
6591
6651
  <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
6592
6652
 
6593
6653
  <xsl:call-template name="setBordersTableArray"/>
@@ -7086,8 +7146,9 @@
7086
7146
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
7087
7147
 
7088
7148
  <fo:block xsl:use-attribute-sets="table-fn-style">
7089
-
7149
+ <xsl:call-template name="refine_table-fn-style"/>
7090
7150
  <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
7151
+ <xsl:call-template name="refine_table-fn-number-style"/>
7091
7152
 
7092
7153
  <fo:inline font-style="normal">(</fo:inline>
7093
7154
 
@@ -7279,7 +7340,20 @@
7279
7340
  <!-- Definition List -->
7280
7341
  <!-- ===================== -->
7281
7342
 
7282
- <xsl:template match="*[local-name()='dl']">
7343
+ <!-- for table auto-layout algorithm -->
7344
+ <xsl:template match="*[local-name()='dl']" priority="2">
7345
+ <xsl:choose>
7346
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
7347
+ <xsl:call-template name="dl"/>
7348
+ </xsl:when>
7349
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
7350
+ <xsl:otherwise>
7351
+ <xsl:call-template name="dl"/>
7352
+ </xsl:otherwise>
7353
+ </xsl:choose>
7354
+ </xsl:template>
7355
+
7356
+ <xsl:template match="*[local-name()='dl']" name="dl">
7283
7357
  <xsl:variable name="isAdded" select="@added"/>
7284
7358
  <xsl:variable name="isDeleted" select="@deleted"/>
7285
7359
  <!-- <dl><xsl:copy-of select="."/></dl> -->
@@ -8234,11 +8308,16 @@
8234
8308
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
8235
8309
  <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
8236
8310
  <xsl:variable name="text" select="."/>
8237
- <fo:inline font-size="75%" role="SKIP">
8311
+ <xsl:variable name="ratio_">
8312
+ 0.75
8313
+ </xsl:variable>
8314
+ <xsl:variable name="ratio" select="number(normalize-space($ratio_))"/>
8315
+ <fo:inline font-size="{$ratio * 100}%" role="SKIP">
8238
8316
  <xsl:if test="string-length($text) &gt; 0">
8239
8317
  <xsl:variable name="smallCapsText">
8240
8318
  <xsl:call-template name="recursiveSmallCaps">
8241
8319
  <xsl:with-param name="text" select="$text"/>
8320
+ <xsl:with-param name="ratio" select="$ratio"/>
8242
8321
  </xsl:call-template>
8243
8322
  </xsl:variable>
8244
8323
  <!-- merge neighboring fo:inline -->
@@ -8275,12 +8354,13 @@
8275
8354
 
8276
8355
  <xsl:template name="recursiveSmallCaps">
8277
8356
  <xsl:param name="text"/>
8357
+ <xsl:param name="ratio"/>
8278
8358
  <xsl:variable name="char" select="substring($text,1,1)"/>
8279
8359
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
8280
8360
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
8281
8361
  <xsl:choose>
8282
8362
  <xsl:when test="$char=$upperCase">
8283
- <fo:inline font-size="{100 div 0.75}%" role="SKIP">
8363
+ <fo:inline font-size="{100 div $ratio}%" role="SKIP">
8284
8364
  <xsl:value-of select="$upperCase"/>
8285
8365
  </fo:inline>
8286
8366
  </xsl:when>
@@ -8291,6 +8371,7 @@
8291
8371
  <xsl:if test="string-length($text) &gt; 1">
8292
8372
  <xsl:call-template name="recursiveSmallCaps">
8293
8373
  <xsl:with-param name="text" select="substring($text,2)"/>
8374
+ <xsl:with-param name="ratio" select="$ratio"/>
8294
8375
  </xsl:call-template>
8295
8376
  </xsl:if>
8296
8377
  </xsl:template>
@@ -8327,6 +8408,9 @@
8327
8408
  <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color'">
8328
8409
  <style name="{$key}"><xsl:value-of select="$value"/></style>
8329
8410
  </xsl:if>
8411
+ <xsl:if test="$key = 'text-indent'">
8412
+ <style name="padding-left"><xsl:value-of select="$value"/></style>
8413
+ </xsl:if>
8330
8414
  </xsl:for-each>
8331
8415
  </xsl:variable>
8332
8416
  <xsl:variable name="styles" select="xalan:nodeset($styles_)"/>
@@ -9199,7 +9283,13 @@
9199
9283
  <xsl:value-of select="$language_current_2"/>
9200
9284
  </xsl:when>
9201
9285
  <xsl:otherwise>
9202
- <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
9286
+ <xsl:variable name="language_current_3" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'])"/>
9287
+ <xsl:choose>
9288
+ <xsl:when test="$language_current_3 != ''">
9289
+ <xsl:value-of select="$language_current_3"/>
9290
+ </xsl:when>
9291
+ <xsl:otherwise>en</xsl:otherwise>
9292
+ </xsl:choose>
9203
9293
  </xsl:otherwise>
9204
9294
  </xsl:choose>
9205
9295
  </xsl:otherwise>
@@ -9761,6 +9851,11 @@
9761
9851
  </xsl:call-template>
9762
9852
  </xsl:template>
9763
9853
 
9854
+ <!-- command between two xref points to non-standard bibitem -->
9855
+ <xsl:template match="text()[. = ','][preceding-sibling::node()[1][local-name() = 'sup'][*[local-name() = 'xref'][@type = 'footnote']] and following-sibling::node()[1][local-name() = 'sup'][*[local-name() = 'xref'][@type = 'footnote']]]">
9856
+ <xsl:value-of select="."/>
9857
+ </xsl:template>
9858
+
9764
9859
  <!-- ====== -->
9765
9860
  <!-- formula -->
9766
9861
  <!-- ====== -->
@@ -10148,7 +10243,7 @@
10148
10243
  </xsl:when>
10149
10244
  <xsl:otherwise>
10150
10245
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
10151
- <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
10246
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and (../*[local-name() = 'name'] or parent::*[local-name() = 'figure'][@unnumbered = 'true']) and not(ancestor::*[local-name() = 'table'])">
10152
10247
 
10153
10248
  <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
10154
10249
  <xsl:attribute name="width">
@@ -10483,6 +10578,8 @@
10483
10578
  </xsl:attribute>
10484
10579
  </xsl:template>
10485
10580
 
10581
+ <xsl:variable name="regex_starts_with_digit">^[0-9].*</xsl:variable>
10582
+
10486
10583
  <xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
10487
10584
  <xsl:copy>
10488
10585
  <xsl:apply-templates select="@*" mode="svg_update"/>
@@ -10501,7 +10598,8 @@
10501
10598
 
10502
10599
  <xsl:attribute name="width">
10503
10600
  <xsl:choose>
10504
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10601
+ <!-- width is non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
10602
+ <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10505
10603
  <xsl:when test="$width != ''">
10506
10604
  <xsl:value-of select="round($width)"/>
10507
10605
  </xsl:when>
@@ -10510,7 +10608,8 @@
10510
10608
  </xsl:attribute>
10511
10609
  <xsl:attribute name="height">
10512
10610
  <xsl:choose>
10513
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10611
+ <!-- height non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
10612
+ <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10514
10613
  <xsl:when test="$height != ''">
10515
10614
  <xsl:value-of select="round($height)"/>
10516
10615
  </xsl:when>
@@ -10527,7 +10626,7 @@
10527
10626
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
10528
10627
  <xsl:attribute name="width">
10529
10628
  <xsl:choose>
10530
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10629
+ <xsl:when test="$parent_image_width != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_width), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_width"/></xsl:when>
10531
10630
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10532
10631
  </xsl:choose>
10533
10632
  </xsl:attribute>
@@ -10538,7 +10637,7 @@
10538
10637
  <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
10539
10638
  <xsl:attribute name="height">
10540
10639
  <xsl:choose>
10541
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10640
+ <xsl:when test="$parent_image_height != '' and normalize-space(java:matches(java:java.lang.String.new($parent_image_height), $regex_starts_with_digit)) = 'true'"><xsl:value-of select="$parent_image_height"/></xsl:when>
10542
10641
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10543
10642
  </xsl:choose>
10544
10643
  </xsl:attribute>
@@ -12013,6 +12112,7 @@
12013
12112
  <xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']">
12014
12113
  <xsl:if test="normalize-space() != ''">
12015
12114
  <fo:inline xsl:use-attribute-sets="termexample-name-style">
12115
+ <xsl:call-template name="refine_termexample-name-style"/>
12016
12116
  <xsl:apply-templates/>
12017
12117
  </fo:inline>
12018
12118
  </xsl:if>
@@ -12163,6 +12263,7 @@
12163
12263
  </xsl:when>
12164
12264
  <xsl:otherwise>
12165
12265
  <fo:inline xsl:use-attribute-sets="example-name-style">
12266
+ <xsl:call-template name="refine_example-name-style"/>
12166
12267
  <xsl:apply-templates/>
12167
12268
  </fo:inline>
12168
12269
  </xsl:otherwise>
@@ -13375,6 +13476,7 @@
13375
13476
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
13376
13477
 
13377
13478
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
13479
+
13378
13480
  <xsl:call-template name="processBibitem"/>
13379
13481
  </fo:block>
13380
13482
 
@@ -13414,6 +13516,7 @@
13414
13516
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
13415
13517
  <xsl:otherwise>
13416
13518
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
13519
+
13417
13520
  <fo:list-item-label end-indent="label-end()">
13418
13521
  <fo:block role="SKIP">
13419
13522
  <fo:inline role="SKIP">