metanorma-un 0.12.5 → 0.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -745,17 +745,30 @@
745
745
  <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 -->
746
746
 
747
747
  <xsl:param name="table_if">false</xsl:param> <!-- generate extended table in IF for autolayout-algorithm -->
748
- <xsl:param name="table_widths"/> <!-- path to xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
748
+ <xsl:param name="table_widths"/> <!-- (debug: path to) xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
749
749
  <!-- Example: <tables>
750
- <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
751
- <tbody>
752
- <tr>
753
- <td id="tab-symdu_1_1">
754
- <p_len>6</p_len>
755
- <p_len>100</p_len> for 2nd paragraph
756
- <word_len>6</word_len>
757
- <word_len>20</word_len>
758
- ...
750
+ <table page-width="509103" id="table1" width_max="223561" width_min="223560">
751
+ <column width_max="39354" width_min="39354"/>
752
+ <column width_max="75394" width_min="75394"/>
753
+ <column width_max="108813" width_min="108813"/>
754
+ <tbody>
755
+ <tr>
756
+ <td width_max="39354" width_min="39354">
757
+ <p_len>39354</p_len>
758
+ <word_len>39354</word_len>
759
+ </td>
760
+
761
+ OLD:
762
+ <tables>
763
+ <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
764
+ <tbody>
765
+ <tr>
766
+ <td id="tab-symdu_1_1">
767
+ <p_len>6</p_len>
768
+ <p_len>100</p_len> for 2nd paragraph
769
+ <word_len>6</word_len>
770
+ <word_len>20</word_len>
771
+ ...
759
772
  -->
760
773
 
761
774
  <!-- for command line debug: <xsl:variable name="table_widths_from_if" select="document($table_widths)"/> -->
@@ -974,6 +987,10 @@
974
987
  <xsl:variable name="zero_width_space">​</xsl:variable>
975
988
  <xsl:variable name="hair_space"> </xsl:variable>
976
989
  <xsl:variable name="en_dash">–</xsl:variable>
990
+ <xsl:variable name="em_dash">—</xsl:variable>
991
+ <xsl:variable name="cr">&#13;</xsl:variable>
992
+ <xsl:variable name="lf">
993
+ </xsl:variable>
977
994
 
978
995
  <xsl:template name="getTitle">
979
996
  <xsl:param name="name"/>
@@ -1281,6 +1298,10 @@
1281
1298
 
1282
1299
  </xsl:attribute-set> <!-- example-name-style -->
1283
1300
 
1301
+ <xsl:template name="refine_example-name-style">
1302
+
1303
+ </xsl:template>
1304
+
1284
1305
  <xsl:attribute-set name="example-p-style">
1285
1306
 
1286
1307
  <xsl:attribute name="font-size">11pt</xsl:attribute>
@@ -1303,6 +1324,10 @@
1303
1324
 
1304
1325
  </xsl:attribute-set> <!-- termexample-name-style -->
1305
1326
 
1327
+ <xsl:template name="refine_termexample-name-style">
1328
+
1329
+ </xsl:template>
1330
+
1306
1331
  <!-- ========================== -->
1307
1332
  <!-- Table styles -->
1308
1333
  <!-- ========================== -->
@@ -1489,6 +1514,10 @@
1489
1514
 
1490
1515
  </xsl:attribute-set> <!-- table-fn-style -->
1491
1516
 
1517
+ <xsl:template name="refine_table-fn-style">
1518
+
1519
+ </xsl:template>
1520
+
1492
1521
  <xsl:attribute-set name="table-fn-number-style">
1493
1522
  <xsl:attribute name="font-size">80%</xsl:attribute>
1494
1523
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
@@ -1497,6 +1526,10 @@
1497
1526
 
1498
1527
  </xsl:attribute-set> <!-- table-fn-number-style -->
1499
1528
 
1529
+ <xsl:template name="refine_table-fn-number-style">
1530
+
1531
+ </xsl:template>
1532
+
1500
1533
  <xsl:attribute-set name="fn-container-body-style">
1501
1534
  <xsl:attribute name="text-indent">0</xsl:attribute>
1502
1535
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -2599,6 +2632,20 @@
2599
2632
  </xsl:for-each>
2600
2633
  </xsl:template>
2601
2634
 
2635
+ <xsl:param name="table_only_with_id"/><!-- Example: table1, for table auto-layout algorithm -->
2636
+
2637
+ <xsl:template match="*[local-name()='table']" priority="2">
2638
+ <xsl:choose>
2639
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
2640
+ <xsl:call-template name="table"/>
2641
+ </xsl:when>
2642
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
2643
+ <xsl:otherwise>
2644
+ <xsl:call-template name="table"/>
2645
+ </xsl:otherwise>
2646
+ </xsl:choose>
2647
+ </xsl:template>
2648
+
2602
2649
  <xsl:template match="*[local-name()='table']" name="table">
2603
2650
 
2604
2651
  <xsl:variable name="table-preamble">
@@ -2608,9 +2655,11 @@
2608
2655
  <xsl:variable name="table">
2609
2656
 
2610
2657
  <xsl:variable name="simple-table">
2611
- <xsl:call-template name="getSimpleTable">
2612
- <xsl:with-param name="id" select="@id"/>
2613
- </xsl:call-template>
2658
+ <xsl:if test="$isGenerateTableIF = 'true' and $isApplyAutolayoutAlgorithm = 'true'">
2659
+ <xsl:call-template name="getSimpleTable">
2660
+ <xsl:with-param name="id" select="@id"/>
2661
+ </xsl:call-template>
2662
+ </xsl:if>
2614
2663
  </xsl:variable>
2615
2664
  <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
2616
2665
 
@@ -2712,9 +2761,9 @@
2712
2761
  </xsl:attribute>
2713
2762
  </xsl:for-each>
2714
2763
 
2715
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
2764
+ <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']"/>
2716
2765
  <xsl:if test="$isNoteOrFnExist = 'true'">
2717
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
2766
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
2718
2767
  </xsl:if>
2719
2768
 
2720
2769
  <xsl:choose>
@@ -2863,9 +2912,28 @@
2863
2912
 
2864
2913
  </fo:block>
2865
2914
 
2915
+ <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
2916
+ <xsl:if test="$continued = 'true'">
2917
+ <fo:block text-align="right">
2918
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
2919
+ </fo:block>
2920
+ </xsl:if>
2921
+ <!-- </xsl:if> -->
2922
+
2866
2923
  </xsl:if>
2867
2924
  </xsl:template> <!-- table/name -->
2868
2925
 
2926
+ <!-- workaround solution for https://github.com/metanorma/metanorma-iso/issues/1151#issuecomment-2033087938 -->
2927
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'note'][@type = 'units']/*[local-name() = 'p']/text()" priority="4">
2928
+ <xsl:choose>
2929
+ <xsl:when test="preceding-sibling::*[local-name() = 'br']">
2930
+ <!-- remove CR or LF at start -->
2931
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'^(&#13;&#10;|&#13;|&#10;)', '')"/>
2932
+ </xsl:when>
2933
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
2934
+ </xsl:choose>
2935
+ </xsl:template>
2936
+
2869
2937
  <!-- SOURCE: ... -->
2870
2938
  <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
2871
2939
  <xsl:call-template name="termsource"/>
@@ -3276,7 +3344,7 @@
3276
3344
  <xsl:param name="colwidths"/>
3277
3345
  <xsl:param name="colgroup"/>
3278
3346
 
3279
- <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']"/>
3347
+ <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']"/>
3280
3348
 
3281
3349
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
3282
3350
 
@@ -3348,7 +3416,7 @@
3348
3416
 
3349
3417
  <xsl:apply-templates select="../*[local-name()='p']"/>
3350
3418
  <xsl:apply-templates select="../*[local-name()='dl']"/>
3351
- <xsl:apply-templates select="../*[local-name()='note']"/>
3419
+ <xsl:apply-templates select="../*[local-name()='note'][not(@type = 'units')]"/>
3352
3420
  <xsl:apply-templates select="../*[local-name()='example']"/>
3353
3421
  <xsl:apply-templates select="../*[local-name()='source']"/>
3354
3422
 
@@ -3358,7 +3426,7 @@
3358
3426
 
3359
3427
  <!-- horizontal row separator -->
3360
3428
  <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3361
- <xsl:if test="(../*[local-name()='note'] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
3429
+ <xsl:if test="(../*[local-name()='note'][not(@type = 'units')] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
3362
3430
  <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3363
3431
 
3364
3432
  <xsl:call-template name="setBordersTableArray"/>
@@ -3841,8 +3909,9 @@
3841
3909
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3842
3910
 
3843
3911
  <fo:block xsl:use-attribute-sets="table-fn-style">
3844
-
3912
+ <xsl:call-template name="refine_table-fn-style"/>
3845
3913
  <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3914
+ <xsl:call-template name="refine_table-fn-number-style"/>
3846
3915
 
3847
3916
  <xsl:value-of select="@reference"/>
3848
3917
 
@@ -4026,7 +4095,20 @@
4026
4095
  <!-- Definition List -->
4027
4096
  <!-- ===================== -->
4028
4097
 
4029
- <xsl:template match="*[local-name()='dl']">
4098
+ <!-- for table auto-layout algorithm -->
4099
+ <xsl:template match="*[local-name()='dl']" priority="2">
4100
+ <xsl:choose>
4101
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
4102
+ <xsl:call-template name="dl"/>
4103
+ </xsl:when>
4104
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
4105
+ <xsl:otherwise>
4106
+ <xsl:call-template name="dl"/>
4107
+ </xsl:otherwise>
4108
+ </xsl:choose>
4109
+ </xsl:template>
4110
+
4111
+ <xsl:template match="*[local-name()='dl']" name="dl">
4030
4112
  <xsl:variable name="isAdded" select="@added"/>
4031
4113
  <xsl:variable name="isDeleted" select="@deleted"/>
4032
4114
  <!-- <dl><xsl:copy-of select="."/></dl> -->
@@ -4980,11 +5062,16 @@
4980
5062
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
4981
5063
  <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
4982
5064
  <xsl:variable name="text" select="."/>
4983
- <fo:inline font-size="75%" role="SKIP">
5065
+ <xsl:variable name="ratio_">
5066
+ 0.75
5067
+ </xsl:variable>
5068
+ <xsl:variable name="ratio" select="number(normalize-space($ratio_))"/>
5069
+ <fo:inline font-size="{$ratio * 100}%" role="SKIP">
4984
5070
  <xsl:if test="string-length($text) &gt; 0">
4985
5071
  <xsl:variable name="smallCapsText">
4986
5072
  <xsl:call-template name="recursiveSmallCaps">
4987
5073
  <xsl:with-param name="text" select="$text"/>
5074
+ <xsl:with-param name="ratio" select="$ratio"/>
4988
5075
  </xsl:call-template>
4989
5076
  </xsl:variable>
4990
5077
  <!-- merge neighboring fo:inline -->
@@ -5021,12 +5108,13 @@
5021
5108
 
5022
5109
  <xsl:template name="recursiveSmallCaps">
5023
5110
  <xsl:param name="text"/>
5111
+ <xsl:param name="ratio"/>
5024
5112
  <xsl:variable name="char" select="substring($text,1,1)"/>
5025
5113
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
5026
5114
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
5027
5115
  <xsl:choose>
5028
5116
  <xsl:when test="$char=$upperCase">
5029
- <fo:inline font-size="{100 div 0.75}%" role="SKIP">
5117
+ <fo:inline font-size="{100 div $ratio}%" role="SKIP">
5030
5118
  <xsl:value-of select="$upperCase"/>
5031
5119
  </fo:inline>
5032
5120
  </xsl:when>
@@ -5037,6 +5125,7 @@
5037
5125
  <xsl:if test="string-length($text) &gt; 1">
5038
5126
  <xsl:call-template name="recursiveSmallCaps">
5039
5127
  <xsl:with-param name="text" select="substring($text,2)"/>
5128
+ <xsl:with-param name="ratio" select="$ratio"/>
5040
5129
  </xsl:call-template>
5041
5130
  </xsl:if>
5042
5131
  </xsl:template>
@@ -5073,6 +5162,9 @@
5073
5162
  <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color'">
5074
5163
  <style name="{$key}"><xsl:value-of select="$value"/></style>
5075
5164
  </xsl:if>
5165
+ <xsl:if test="$key = 'text-indent'">
5166
+ <style name="padding-left"><xsl:value-of select="$value"/></style>
5167
+ </xsl:if>
5076
5168
  </xsl:for-each>
5077
5169
  </xsl:variable>
5078
5170
  <xsl:variable name="styles" select="xalan:nodeset($styles_)"/>
@@ -5945,7 +6037,13 @@
5945
6037
  <xsl:value-of select="$language_current_2"/>
5946
6038
  </xsl:when>
5947
6039
  <xsl:otherwise>
5948
- <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
6040
+ <xsl:variable name="language_current_3" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'])"/>
6041
+ <xsl:choose>
6042
+ <xsl:when test="$language_current_3 != ''">
6043
+ <xsl:value-of select="$language_current_3"/>
6044
+ </xsl:when>
6045
+ <xsl:otherwise>en</xsl:otherwise>
6046
+ </xsl:choose>
5949
6047
  </xsl:otherwise>
5950
6048
  </xsl:choose>
5951
6049
  </xsl:otherwise>
@@ -6475,6 +6573,11 @@
6475
6573
  </xsl:call-template>
6476
6574
  </xsl:template>
6477
6575
 
6576
+ <!-- command between two xref points to non-standard bibitem -->
6577
+ <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']]]">
6578
+ <xsl:value-of select="."/>
6579
+ </xsl:template>
6580
+
6478
6581
  <!-- ====== -->
6479
6582
  <!-- formula -->
6480
6583
  <!-- ====== -->
@@ -6854,7 +6957,7 @@
6854
6957
  </xsl:when>
6855
6958
  <xsl:otherwise>
6856
6959
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
6857
- <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
6960
+ <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'])">
6858
6961
 
6859
6962
  <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
6860
6963
  <xsl:attribute name="width">
@@ -7189,6 +7292,8 @@
7189
7292
  </xsl:attribute>
7190
7293
  </xsl:template>
7191
7294
 
7295
+ <xsl:variable name="regex_starts_with_digit">^[0-9].*</xsl:variable>
7296
+
7192
7297
  <xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
7193
7298
  <xsl:copy>
7194
7299
  <xsl:apply-templates select="@*" mode="svg_update"/>
@@ -7207,7 +7312,8 @@
7207
7312
 
7208
7313
  <xsl:attribute name="width">
7209
7314
  <xsl:choose>
7210
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7315
+ <!-- width is non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
7316
+ <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>
7211
7317
  <xsl:when test="$width != ''">
7212
7318
  <xsl:value-of select="round($width)"/>
7213
7319
  </xsl:when>
@@ -7216,7 +7322,8 @@
7216
7322
  </xsl:attribute>
7217
7323
  <xsl:attribute name="height">
7218
7324
  <xsl:choose>
7219
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7325
+ <!-- height non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
7326
+ <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>
7220
7327
  <xsl:when test="$height != ''">
7221
7328
  <xsl:value-of select="round($height)"/>
7222
7329
  </xsl:when>
@@ -7233,7 +7340,7 @@
7233
7340
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7234
7341
  <xsl:attribute name="width">
7235
7342
  <xsl:choose>
7236
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7343
+ <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>
7237
7344
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7238
7345
  </xsl:choose>
7239
7346
  </xsl:attribute>
@@ -7244,7 +7351,7 @@
7244
7351
  <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7245
7352
  <xsl:attribute name="height">
7246
7353
  <xsl:choose>
7247
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7354
+ <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>
7248
7355
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7249
7356
  </xsl:choose>
7250
7357
  </xsl:attribute>
@@ -8706,6 +8813,7 @@
8706
8813
  <xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']">
8707
8814
  <xsl:if test="normalize-space() != ''">
8708
8815
  <fo:inline xsl:use-attribute-sets="termexample-name-style">
8816
+ <xsl:call-template name="refine_termexample-name-style"/>
8709
8817
  <xsl:apply-templates/>
8710
8818
  </fo:inline>
8711
8819
  </xsl:if>
@@ -8856,6 +8964,7 @@
8856
8964
  </xsl:when>
8857
8965
  <xsl:otherwise>
8858
8966
  <fo:inline xsl:use-attribute-sets="example-name-style">
8967
+ <xsl:call-template name="refine_example-name-style"/>
8859
8968
  <xsl:apply-templates/>
8860
8969
  </fo:inline>
8861
8970
  </xsl:otherwise>
@@ -10067,6 +10176,7 @@
10067
10176
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
10068
10177
 
10069
10178
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
10179
+
10070
10180
  <xsl:call-template name="processBibitem"/>
10071
10181
  </fo:block>
10072
10182
 
@@ -10087,6 +10197,7 @@
10087
10197
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
10088
10198
  <xsl:otherwise>
10089
10199
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
10200
+
10090
10201
  <fo:list-item-label end-indent="label-end()">
10091
10202
  <fo:block role="SKIP">
10092
10203
  <fo:inline role="SKIP">