metanorma-csa 2.4.4 → 2.4.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22d4bfa3220b5d6efd0a74f14bc170f7bc5c2bedfa74a4b983a7199221722bd0
4
- data.tar.gz: 44e0c583faa3763e6cb12b246a67cbedacdf316e90fb670e56c203a2aad13ee5
3
+ metadata.gz: a36fcd0739fd84b4728aebd0f67176ef41ab9bd35758a118aaa22b04497429c3
4
+ data.tar.gz: d1922a54aa70a53be51731604d7d18dc870999d61856d5e6ccfe8fa0755eeb23
5
5
  SHA512:
6
- metadata.gz: 3c13778cd5fef2c2e7297a2f817cdf3d3fff5df5d070ce8b816000d90dd3587b928b634612a1166469984e0629e2c67abb14d594fef7211a7bfcd4bce0022567
7
- data.tar.gz: b6754ebcd7ce19a17be4548857980f2fd672fdbcf73d65630f862f96003e130f9c9b75ddc89918f1094c82097da45ad7dd9a4325463abe3dca3e4608480f7e07
6
+ metadata.gz: 5afa7e2ee289625315d4f1cd7d81dfdeb94112cfd9a2fd7410f0315d690ffd5cdf5fa60cd2610d38fab6e8663ea87290b8266a425917aaf0738043435a2724c5
7
+ data.tar.gz: a05f9e5b94467efd48feebf503977f480a348b9786ded6644203dee2ed26cd88430a921ea724dc6b3a0ebd01c95709280488c1e6e3de7cb7cc74c158760df463
@@ -590,17 +590,30 @@
590
590
  <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 -->
591
591
 
592
592
  <xsl:param name="table_if">false</xsl:param> <!-- generate extended table in IF for autolayout-algorithm -->
593
- <xsl:param name="table_widths"/> <!-- path to xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
593
+ <xsl:param name="table_widths"/> <!-- (debug: path to) xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
594
594
  <!-- Example: <tables>
595
- <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
596
- <tbody>
597
- <tr>
598
- <td id="tab-symdu_1_1">
599
- <p_len>6</p_len>
600
- <p_len>100</p_len> for 2nd paragraph
601
- <word_len>6</word_len>
602
- <word_len>20</word_len>
603
- ...
595
+ <table page-width="509103" id="table1" width_max="223561" width_min="223560">
596
+ <column width_max="39354" width_min="39354"/>
597
+ <column width_max="75394" width_min="75394"/>
598
+ <column width_max="108813" width_min="108813"/>
599
+ <tbody>
600
+ <tr>
601
+ <td width_max="39354" width_min="39354">
602
+ <p_len>39354</p_len>
603
+ <word_len>39354</word_len>
604
+ </td>
605
+
606
+ OLD:
607
+ <tables>
608
+ <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
609
+ <tbody>
610
+ <tr>
611
+ <td id="tab-symdu_1_1">
612
+ <p_len>6</p_len>
613
+ <p_len>100</p_len> for 2nd paragraph
614
+ <word_len>6</word_len>
615
+ <word_len>20</word_len>
616
+ ...
604
617
  -->
605
618
 
606
619
  <!-- for command line debug: <xsl:variable name="table_widths_from_if" select="document($table_widths)"/> -->
@@ -819,6 +832,10 @@
819
832
  <xsl:variable name="zero_width_space">​</xsl:variable>
820
833
  <xsl:variable name="hair_space"> </xsl:variable>
821
834
  <xsl:variable name="en_dash">–</xsl:variable>
835
+ <xsl:variable name="em_dash">—</xsl:variable>
836
+ <xsl:variable name="cr">&#13;</xsl:variable>
837
+ <xsl:variable name="lf">
838
+ </xsl:variable>
822
839
 
823
840
  <xsl:template name="getTitle">
824
841
  <xsl:param name="name"/>
@@ -1139,6 +1156,10 @@
1139
1156
 
1140
1157
  </xsl:attribute-set> <!-- example-name-style -->
1141
1158
 
1159
+ <xsl:template name="refine_example-name-style">
1160
+
1161
+ </xsl:template>
1162
+
1142
1163
  <xsl:attribute-set name="example-p-style">
1143
1164
 
1144
1165
  <xsl:attribute name="margin-bottom">14pt</xsl:attribute>
@@ -1155,6 +1176,10 @@
1155
1176
 
1156
1177
  </xsl:attribute-set> <!-- termexample-name-style -->
1157
1178
 
1179
+ <xsl:template name="refine_termexample-name-style">
1180
+
1181
+ </xsl:template>
1182
+
1158
1183
  <!-- ========================== -->
1159
1184
  <!-- Table styles -->
1160
1185
  <!-- ========================== -->
@@ -1311,12 +1336,20 @@
1311
1336
 
1312
1337
  </xsl:attribute-set> <!-- table-fn-style -->
1313
1338
 
1339
+ <xsl:template name="refine_table-fn-style">
1340
+
1341
+ </xsl:template>
1342
+
1314
1343
  <xsl:attribute-set name="table-fn-number-style">
1315
1344
  <xsl:attribute name="font-size">80%</xsl:attribute>
1316
1345
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
1317
1346
 
1318
1347
  </xsl:attribute-set> <!-- table-fn-number-style -->
1319
1348
 
1349
+ <xsl:template name="refine_table-fn-number-style">
1350
+
1351
+ </xsl:template>
1352
+
1320
1353
  <xsl:attribute-set name="fn-container-body-style">
1321
1354
  <xsl:attribute name="text-indent">0</xsl:attribute>
1322
1355
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -2439,6 +2472,20 @@
2439
2472
  </xsl:for-each>
2440
2473
  </xsl:template>
2441
2474
 
2475
+ <xsl:param name="table_only_with_id"/><!-- Example: table1, for table auto-layout algorithm -->
2476
+
2477
+ <xsl:template match="*[local-name()='table']" priority="2">
2478
+ <xsl:choose>
2479
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
2480
+ <xsl:call-template name="table"/>
2481
+ </xsl:when>
2482
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
2483
+ <xsl:otherwise>
2484
+ <xsl:call-template name="table"/>
2485
+ </xsl:otherwise>
2486
+ </xsl:choose>
2487
+ </xsl:template>
2488
+
2442
2489
  <xsl:template match="*[local-name()='table']" name="table">
2443
2490
 
2444
2491
  <xsl:variable name="table-preamble">
@@ -2448,9 +2495,11 @@
2448
2495
  <xsl:variable name="table">
2449
2496
 
2450
2497
  <xsl:variable name="simple-table">
2451
- <xsl:call-template name="getSimpleTable">
2452
- <xsl:with-param name="id" select="@id"/>
2453
- </xsl:call-template>
2498
+ <xsl:if test="$isGenerateTableIF = 'true' and $isApplyAutolayoutAlgorithm = 'true'">
2499
+ <xsl:call-template name="getSimpleTable">
2500
+ <xsl:with-param name="id" select="@id"/>
2501
+ </xsl:call-template>
2502
+ </xsl:if>
2454
2503
  </xsl:variable>
2455
2504
  <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
2456
2505
 
@@ -2544,9 +2593,9 @@
2544
2593
  </xsl:attribute>
2545
2594
  </xsl:for-each>
2546
2595
 
2547
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
2596
+ <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']"/>
2548
2597
  <xsl:if test="$isNoteOrFnExist = 'true'">
2549
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
2598
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
2550
2599
  </xsl:if>
2551
2600
 
2552
2601
  <xsl:choose>
@@ -2631,6 +2680,7 @@
2631
2680
  <!-- centered table when table name is centered (see table-name-style) -->
2632
2681
 
2633
2682
  <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
2683
+
2634
2684
  <fo:table-column column-width="proportional-column-width(1)"/>
2635
2685
  <fo:table-column column-width="{@width}"/>
2636
2686
  <fo:table-column column-width="proportional-column-width(1)"/>
@@ -2698,9 +2748,28 @@
2698
2748
 
2699
2749
  </fo:block>
2700
2750
 
2751
+ <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
2752
+ <xsl:if test="$continued = 'true'">
2753
+ <fo:block text-align="right">
2754
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
2755
+ </fo:block>
2756
+ </xsl:if>
2757
+ <!-- </xsl:if> -->
2758
+
2701
2759
  </xsl:if>
2702
2760
  </xsl:template> <!-- table/name -->
2703
2761
 
2762
+ <!-- workaround solution for https://github.com/metanorma/metanorma-iso/issues/1151#issuecomment-2033087938 -->
2763
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'note'][@type = 'units']/*[local-name() = 'p']/text()" priority="4">
2764
+ <xsl:choose>
2765
+ <xsl:when test="preceding-sibling::*[local-name() = 'br']">
2766
+ <!-- remove CR or LF at start -->
2767
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'^(&#13;&#10;|&#13;|&#10;)', '')"/>
2768
+ </xsl:when>
2769
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
2770
+ </xsl:choose>
2771
+ </xsl:template>
2772
+
2704
2773
  <!-- SOURCE: ... -->
2705
2774
  <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
2706
2775
  <xsl:call-template name="termsource"/>
@@ -3111,7 +3180,7 @@
3111
3180
  <xsl:param name="colwidths"/>
3112
3181
  <xsl:param name="colgroup"/>
3113
3182
 
3114
- <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']"/>
3183
+ <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']"/>
3115
3184
 
3116
3185
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
3117
3186
 
@@ -3183,7 +3252,7 @@
3183
3252
 
3184
3253
  <xsl:apply-templates select="../*[local-name()='p']"/>
3185
3254
  <xsl:apply-templates select="../*[local-name()='dl']"/>
3186
- <xsl:apply-templates select="../*[local-name()='note']"/>
3255
+ <xsl:apply-templates select="../*[local-name()='note'][not(@type = 'units')]"/>
3187
3256
  <xsl:apply-templates select="../*[local-name()='example']"/>
3188
3257
  <xsl:apply-templates select="../*[local-name()='source']"/>
3189
3258
 
@@ -3193,7 +3262,7 @@
3193
3262
 
3194
3263
  <!-- horizontal row separator -->
3195
3264
  <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3196
- <xsl:if test="(../*[local-name()='note'] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
3265
+ <xsl:if test="(../*[local-name()='note'][not(@type = 'units')] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
3197
3266
  <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3198
3267
 
3199
3268
  <xsl:call-template name="setBordersTableArray"/>
@@ -3672,8 +3741,9 @@
3672
3741
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3673
3742
 
3674
3743
  <fo:block xsl:use-attribute-sets="table-fn-style">
3675
-
3744
+ <xsl:call-template name="refine_table-fn-style"/>
3676
3745
  <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3746
+ <xsl:call-template name="refine_table-fn-number-style"/>
3677
3747
 
3678
3748
  <xsl:value-of select="@reference"/>
3679
3749
 
@@ -3857,7 +3927,20 @@
3857
3927
  <!-- Definition List -->
3858
3928
  <!-- ===================== -->
3859
3929
 
3860
- <xsl:template match="*[local-name()='dl']">
3930
+ <!-- for table auto-layout algorithm -->
3931
+ <xsl:template match="*[local-name()='dl']" priority="2">
3932
+ <xsl:choose>
3933
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
3934
+ <xsl:call-template name="dl"/>
3935
+ </xsl:when>
3936
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
3937
+ <xsl:otherwise>
3938
+ <xsl:call-template name="dl"/>
3939
+ </xsl:otherwise>
3940
+ </xsl:choose>
3941
+ </xsl:template>
3942
+
3943
+ <xsl:template match="*[local-name()='dl']" name="dl">
3861
3944
  <xsl:variable name="isAdded" select="@added"/>
3862
3945
  <xsl:variable name="isDeleted" select="@deleted"/>
3863
3946
  <!-- <dl><xsl:copy-of select="."/></dl> -->
@@ -4813,11 +4896,16 @@
4813
4896
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
4814
4897
  <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
4815
4898
  <xsl:variable name="text" select="."/>
4816
- <fo:inline font-size="75%" role="SKIP">
4899
+ <xsl:variable name="ratio_">
4900
+ 0.75
4901
+ </xsl:variable>
4902
+ <xsl:variable name="ratio" select="number(normalize-space($ratio_))"/>
4903
+ <fo:inline font-size="{$ratio * 100}%" role="SKIP">
4817
4904
  <xsl:if test="string-length($text) &gt; 0">
4818
4905
  <xsl:variable name="smallCapsText">
4819
4906
  <xsl:call-template name="recursiveSmallCaps">
4820
4907
  <xsl:with-param name="text" select="$text"/>
4908
+ <xsl:with-param name="ratio" select="$ratio"/>
4821
4909
  </xsl:call-template>
4822
4910
  </xsl:variable>
4823
4911
  <!-- merge neighboring fo:inline -->
@@ -4854,12 +4942,13 @@
4854
4942
 
4855
4943
  <xsl:template name="recursiveSmallCaps">
4856
4944
  <xsl:param name="text"/>
4945
+ <xsl:param name="ratio"/>
4857
4946
  <xsl:variable name="char" select="substring($text,1,1)"/>
4858
4947
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
4859
4948
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
4860
4949
  <xsl:choose>
4861
4950
  <xsl:when test="$char=$upperCase">
4862
- <fo:inline font-size="{100 div 0.75}%" role="SKIP">
4951
+ <fo:inline font-size="{100 div $ratio}%" role="SKIP">
4863
4952
  <xsl:value-of select="$upperCase"/>
4864
4953
  </fo:inline>
4865
4954
  </xsl:when>
@@ -4870,6 +4959,7 @@
4870
4959
  <xsl:if test="string-length($text) &gt; 1">
4871
4960
  <xsl:call-template name="recursiveSmallCaps">
4872
4961
  <xsl:with-param name="text" select="substring($text,2)"/>
4962
+ <xsl:with-param name="ratio" select="$ratio"/>
4873
4963
  </xsl:call-template>
4874
4964
  </xsl:if>
4875
4965
  </xsl:template>
@@ -4906,6 +4996,9 @@
4906
4996
  <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color'">
4907
4997
  <style name="{$key}"><xsl:value-of select="$value"/></style>
4908
4998
  </xsl:if>
4999
+ <xsl:if test="$key = 'text-indent'">
5000
+ <style name="padding-left"><xsl:value-of select="$value"/></style>
5001
+ </xsl:if>
4909
5002
  </xsl:for-each>
4910
5003
  </xsl:variable>
4911
5004
  <xsl:variable name="styles" select="xalan:nodeset($styles_)"/>
@@ -5778,7 +5871,13 @@
5778
5871
  <xsl:value-of select="$language_current_2"/>
5779
5872
  </xsl:when>
5780
5873
  <xsl:otherwise>
5781
- <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
5874
+ <xsl:variable name="language_current_3" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'])"/>
5875
+ <xsl:choose>
5876
+ <xsl:when test="$language_current_3 != ''">
5877
+ <xsl:value-of select="$language_current_3"/>
5878
+ </xsl:when>
5879
+ <xsl:otherwise>en</xsl:otherwise>
5880
+ </xsl:choose>
5782
5881
  </xsl:otherwise>
5783
5882
  </xsl:choose>
5784
5883
  </xsl:otherwise>
@@ -6308,6 +6407,11 @@
6308
6407
  </xsl:call-template>
6309
6408
  </xsl:template>
6310
6409
 
6410
+ <!-- command between two xref points to non-standard bibitem -->
6411
+ <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']]]">
6412
+ <xsl:value-of select="."/>
6413
+ </xsl:template>
6414
+
6311
6415
  <!-- ====== -->
6312
6416
  <!-- formula -->
6313
6417
  <!-- ====== -->
@@ -6639,10 +6743,11 @@
6639
6743
  </xsl:template>
6640
6744
 
6641
6745
  <xsl:template match="*[local-name() = 'image']">
6746
+ <xsl:param name="indent">0</xsl:param>
6642
6747
  <xsl:variable name="isAdded" select="../@added"/>
6643
6748
  <xsl:variable name="isDeleted" select="../@deleted"/>
6644
6749
  <xsl:choose>
6645
- <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6750
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']"> <!-- inline image ( 'image:path' in adoc, with one colon after image) -->
6646
6751
  <fo:inline padding-left="1mm" padding-right="1mm">
6647
6752
  <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6648
6753
  <xsl:attribute name="padding-left">0mm</xsl:attribute>
@@ -6651,7 +6756,43 @@
6651
6756
  <xsl:variable name="src">
6652
6757
  <xsl:call-template name="image_src"/>
6653
6758
  </xsl:variable>
6654
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/>
6759
+
6760
+ <xsl:variable name="scale">
6761
+ <xsl:call-template name="getImageScale">
6762
+ <xsl:with-param name="indent" select="$indent"/>
6763
+ </xsl:call-template>
6764
+ </xsl:variable>
6765
+
6766
+ <!-- debug scale='<xsl:value-of select="$scale"/>', indent='<xsl:value-of select="$indent"/>' -->
6767
+
6768
+ <!-- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/> -->
6769
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle">
6770
+
6771
+ <xsl:variable name="width">
6772
+ <xsl:call-template name="setImageWidth"/>
6773
+ </xsl:variable>
6774
+ <xsl:if test="$width != ''">
6775
+ <xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
6776
+ </xsl:if>
6777
+ <xsl:variable name="height">
6778
+ <xsl:call-template name="setImageHeight"/>
6779
+ </xsl:variable>
6780
+ <xsl:if test="$height != ''">
6781
+ <xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute>
6782
+ </xsl:if>
6783
+
6784
+ <xsl:if test="$width = '' and $height = ''">
6785
+ <xsl:if test="number($scale) &lt; 100">
6786
+ <xsl:attribute name="content-width"><xsl:value-of select="number($scale)"/>%</xsl:attribute>
6787
+ <!-- <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
6788
+ <xsl:attribute name="content-height">100%</xsl:attribute>
6789
+ <xsl:attribute name="width">100%</xsl:attribute>
6790
+ <xsl:attribute name="scaling">uniform</xsl:attribute> -->
6791
+ </xsl:if>
6792
+ </xsl:if>
6793
+
6794
+ </fo:external-graphic>
6795
+
6655
6796
  </fo:inline>
6656
6797
  </xsl:when>
6657
6798
  <xsl:otherwise>
@@ -6672,25 +6813,23 @@
6672
6813
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6673
6814
  <xsl:attribute name="scaling">uniform</xsl:attribute>
6674
6815
 
6675
- <xsl:apply-templates select="." mode="cross_image"/>
6816
+ <xsl:apply-templates select="." mode="cross_image"/>
6676
6817
 
6677
6818
  </fo:instream-foreign-object>
6678
6819
  </xsl:when>
6679
6820
  <xsl:otherwise>
6821
+ <!-- <fo:block>debug block image:
6822
+ <xsl:variable name="scale">
6823
+ <xsl:call-template name="getImageScale">
6824
+ <xsl:with-param name="indent" select="$indent"/>
6825
+ </xsl:call-template>
6826
+ </xsl:variable>
6827
+ <xsl:value-of select="concat('scale=', $scale,', indent=', $indent)"/>
6828
+ </fo:block> -->
6680
6829
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
6681
- <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
6830
+ <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'])">
6682
6831
 
6683
- <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
6684
- <xsl:attribute name="width">
6685
- <xsl:value-of select="@width"/>
6686
- </xsl:attribute>
6687
- </xsl:if>
6688
-
6689
- <xsl:if test="@height != '' and @height != 'auto'">
6690
- <xsl:attribute name="height">
6691
- <xsl:value-of select="@height"/>
6692
- </xsl:attribute>
6693
- </xsl:if>
6832
+ <xsl:call-template name="setImageWidthHeight"/>
6694
6833
 
6695
6834
  <xsl:choose>
6696
6835
  <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
@@ -6698,24 +6837,18 @@
6698
6837
  </xsl:when>
6699
6838
  <xsl:otherwise>
6700
6839
 
6701
- <xsl:variable name="img_src">
6702
- <xsl:choose>
6703
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6704
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6705
- </xsl:choose>
6840
+ <xsl:variable name="scale">
6841
+ <xsl:call-template name="getImageScale">
6842
+ <xsl:with-param name="indent" select="$indent"/>
6843
+ </xsl:call-template>
6706
6844
  </xsl:variable>
6707
6845
 
6708
- <xsl:variable name="image_width_effective">
6709
-
6710
- <xsl:value-of select="$width_effective"/>
6711
-
6846
+ <xsl:variable name="scaleRatio">
6847
+ 1
6712
6848
  </xsl:variable>
6713
6849
 
6714
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6715
6850
  <xsl:if test="number($scale) &lt; 100">
6716
-
6717
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
6718
-
6851
+ <xsl:attribute name="content-width"><xsl:value-of select="number($scale) * number($scaleRatio)"/>%</xsl:attribute>
6719
6852
  </xsl:if>
6720
6853
  </xsl:otherwise>
6721
6854
  </xsl:choose>
@@ -6731,6 +6864,62 @@
6731
6864
  </xsl:choose>
6732
6865
  </xsl:template>
6733
6866
 
6867
+ <xsl:template name="setImageWidth">
6868
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
6869
+ <xsl:value-of select="@width"/>
6870
+ </xsl:if>
6871
+ </xsl:template>
6872
+ <xsl:template name="setImageHeight">
6873
+ <xsl:if test="@height != '' and @height != 'auto'">
6874
+ <xsl:value-of select="@height"/>
6875
+ </xsl:if>
6876
+ </xsl:template>
6877
+ <xsl:template name="setImageWidthHeight">
6878
+ <xsl:variable name="width">
6879
+ <xsl:call-template name="setImageWidth"/>
6880
+ </xsl:variable>
6881
+ <xsl:if test="$width != ''">
6882
+ <xsl:attribute name="width">
6883
+ <xsl:value-of select="$width"/>
6884
+ </xsl:attribute>
6885
+ </xsl:if>
6886
+ <xsl:variable name="height">
6887
+ <xsl:call-template name="setImageHeight"/>
6888
+ </xsl:variable>
6889
+ <xsl:if test="$height != ''">
6890
+ <xsl:attribute name="height">
6891
+ <xsl:value-of select="$height"/>
6892
+ </xsl:attribute>
6893
+ </xsl:if>
6894
+ </xsl:template>
6895
+
6896
+ <xsl:template name="getImageScale">
6897
+ <xsl:param name="indent"/>
6898
+ <xsl:variable name="indent_left">
6899
+ <xsl:choose>
6900
+ <xsl:when test="$indent != ''"><xsl:value-of select="$indent"/></xsl:when>
6901
+ <xsl:otherwise>0</xsl:otherwise>
6902
+ </xsl:choose>
6903
+ </xsl:variable>
6904
+ <xsl:variable name="img_src">
6905
+ <xsl:choose>
6906
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6907
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6908
+ </xsl:choose>
6909
+ </xsl:variable>
6910
+
6911
+ <xsl:variable name="image_width_effective">
6912
+
6913
+ <xsl:value-of select="$width_effective - number($indent_left)"/>
6914
+
6915
+ </xsl:variable>
6916
+ <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
6917
+ <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
6918
+ <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
6919
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6920
+ <xsl:value-of select="$scale"/>
6921
+ </xsl:template>
6922
+
6734
6923
  <xsl:template name="image_src">
6735
6924
  <xsl:choose>
6736
6925
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
@@ -7013,6 +7202,8 @@
7013
7202
  </xsl:attribute>
7014
7203
  </xsl:template>
7015
7204
 
7205
+ <xsl:variable name="regex_starts_with_digit">^[0-9].*</xsl:variable>
7206
+
7016
7207
  <xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
7017
7208
  <xsl:copy>
7018
7209
  <xsl:apply-templates select="@*" mode="svg_update"/>
@@ -7031,7 +7222,8 @@
7031
7222
 
7032
7223
  <xsl:attribute name="width">
7033
7224
  <xsl:choose>
7034
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7225
+ <!-- width is non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
7226
+ <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>
7035
7227
  <xsl:when test="$width != ''">
7036
7228
  <xsl:value-of select="round($width)"/>
7037
7229
  </xsl:when>
@@ -7040,7 +7232,8 @@
7040
7232
  </xsl:attribute>
7041
7233
  <xsl:attribute name="height">
7042
7234
  <xsl:choose>
7043
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7235
+ <!-- height non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
7236
+ <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>
7044
7237
  <xsl:when test="$height != ''">
7045
7238
  <xsl:value-of select="round($height)"/>
7046
7239
  </xsl:when>
@@ -7057,7 +7250,7 @@
7057
7250
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7058
7251
  <xsl:attribute name="width">
7059
7252
  <xsl:choose>
7060
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7253
+ <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>
7061
7254
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7062
7255
  </xsl:choose>
7063
7256
  </xsl:attribute>
@@ -7068,7 +7261,7 @@
7068
7261
  <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7069
7262
  <xsl:attribute name="height">
7070
7263
  <xsl:choose>
7071
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7264
+ <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>
7072
7265
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7073
7266
  </xsl:choose>
7074
7267
  </xsl:attribute>
@@ -8531,6 +8724,7 @@
8531
8724
  <xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']">
8532
8725
  <xsl:if test="normalize-space() != ''">
8533
8726
  <fo:inline xsl:use-attribute-sets="termexample-name-style">
8727
+ <xsl:call-template name="refine_termexample-name-style"/>
8534
8728
  <xsl:apply-templates/>
8535
8729
  </fo:inline>
8536
8730
  </xsl:if>
@@ -8681,6 +8875,7 @@
8681
8875
  </xsl:when>
8682
8876
  <xsl:otherwise>
8683
8877
  <fo:inline xsl:use-attribute-sets="example-name-style">
8878
+ <xsl:call-template name="refine_example-name-style"/>
8684
8879
  <xsl:apply-templates/>
8685
8880
  </fo:inline>
8686
8881
  </xsl:otherwise>
@@ -9403,6 +9598,7 @@
9403
9598
  </xsl:template>
9404
9599
 
9405
9600
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
9601
+ <xsl:param name="indent">0</xsl:param>
9406
9602
  <xsl:choose>
9407
9603
  <xsl:when test="parent::*[local-name() = 'note'] or parent::*[local-name() = 'termnote']">
9408
9604
  <fo:block-container role="SKIP">
@@ -9417,7 +9613,9 @@
9417
9613
 
9418
9614
  <fo:block-container margin-left="0mm" role="SKIP">
9419
9615
  <fo:block>
9420
- <xsl:apply-templates select="." mode="list"/>
9616
+ <xsl:apply-templates select="." mode="list">
9617
+ <xsl:with-param name="indent" select="$indent"/>
9618
+ </xsl:apply-templates>
9421
9619
  </fo:block>
9422
9620
  </fo:block-container>
9423
9621
  </fo:block-container>
@@ -9425,7 +9623,9 @@
9425
9623
  <xsl:otherwise>
9426
9624
 
9427
9625
  <fo:block role="SKIP">
9428
- <xsl:apply-templates select="." mode="list"/>
9626
+ <xsl:apply-templates select="." mode="list">
9627
+ <xsl:with-param name="indent" select="$indent"/>
9628
+ </xsl:apply-templates>
9429
9629
  </fo:block>
9430
9630
 
9431
9631
  </xsl:otherwise>
@@ -9510,6 +9710,13 @@
9510
9710
  </xsl:template>
9511
9711
 
9512
9712
  <xsl:template match="*[local-name()='li']">
9713
+ <xsl:param name="indent">0</xsl:param>
9714
+ <!-- <fo:list-item xsl:use-attribute-sets="list-item-style">
9715
+ <fo:list-item-label end-indent="label-end()"><fo:block>x</fo:block></fo:list-item-label>
9716
+ <fo:list-item-body start-indent="body-start()" xsl:use-attribute-sets="list-item-body-style">
9717
+ <fo:block>debug li indent=<xsl:value-of select="$indent"/></fo:block>
9718
+ </fo:list-item-body>
9719
+ </fo:list-item> -->
9513
9720
  <fo:list-item xsl:use-attribute-sets="list-item-style">
9514
9721
  <xsl:copy-of select="@id"/>
9515
9722
 
@@ -9534,7 +9741,9 @@
9534
9741
 
9535
9742
  <xsl:call-template name="refine_list-item-body-style"/>
9536
9743
 
9537
- <xsl:apply-templates/>
9744
+ <xsl:apply-templates>
9745
+ <xsl:with-param name="indent" select="$indent"/>
9746
+ </xsl:apply-templates>
9538
9747
 
9539
9748
  <!-- <xsl:apply-templates select="node()[not(local-name() = 'note')]" />
9540
9749
 
@@ -9887,6 +10096,7 @@
9887
10096
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
9888
10097
 
9889
10098
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
10099
+
9890
10100
  <xsl:call-template name="processBibitem"/>
9891
10101
  </fo:block>
9892
10102
 
@@ -9910,6 +10120,7 @@
9910
10120
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
9911
10121
  <xsl:otherwise>
9912
10122
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
10123
+
9913
10124
  <fo:list-item-label end-indent="label-end()">
9914
10125
  <fo:block role="SKIP">
9915
10126
  <fo:inline role="SKIP">
@@ -208,7 +208,9 @@
208
208
  </define>
209
209
  <define name="roledescription">
210
210
  <element name="description">
211
- <ref name="FormattedString"/>
211
+ <oneOrMore>
212
+ <ref name="TextElement"/>
213
+ </oneOrMore>
212
214
  </element>
213
215
  </define>
214
216
  <define name="person">
@@ -333,7 +335,9 @@
333
335
  </define>
334
336
  <define name="affiliationdescription">
335
337
  <element name="description">
336
- <ref name="FormattedString"/>
338
+ <oneOrMore>
339
+ <ref name="TextElement"/>
340
+ </oneOrMore>
337
341
  </element>
338
342
  </define>
339
343
  <define name="organization">
@@ -897,7 +901,9 @@
897
901
  </define>
898
902
  <define name="formattedref">
899
903
  <element name="formattedref">
900
- <ref name="FormattedString"/>
904
+ <oneOrMore>
905
+ <ref name="TextElement"/>
906
+ </oneOrMore>
901
907
  </element>
902
908
  </define>
903
909
  <define name="license">
@@ -942,7 +948,9 @@
942
948
  <optional>
943
949
  <attribute name="type"/>
944
950
  </optional>
945
- <ref name="FormattedString"/>
951
+ <zeroOrMore>
952
+ <ref name="TextElement"/>
953
+ </zeroOrMore>
946
954
  </define>
947
955
  <!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
948
956
  <define name="TypedUri">
@@ -1042,7 +1050,9 @@
1042
1050
  <optional>
1043
1051
  <attribute name="script"/>
1044
1052
  </optional>
1045
- <text/>
1053
+ <oneOrMore>
1054
+ <ref name="TextElement"/>
1055
+ </oneOrMore>
1046
1056
  </element>
1047
1057
  </define>
1048
1058
  <define name="docnumber">
@@ -1267,12 +1277,16 @@
1267
1277
  <optional>
1268
1278
  <attribute name="type"/>
1269
1279
  </optional>
1270
- <ref name="FormattedString"/>
1280
+ <oneOrMore>
1281
+ <ref name="TextElement"/>
1282
+ </oneOrMore>
1271
1283
  </element>
1272
1284
  </define>
1273
1285
  <define name="bibabstract">
1274
1286
  <element name="abstract">
1275
- <ref name="FormattedString"/>
1287
+ <oneOrMore>
1288
+ <ref name="TextElement"/>
1289
+ </oneOrMore>
1276
1290
  </element>
1277
1291
  </define>
1278
1292
  <define name="copyright">
@@ -1377,7 +1391,9 @@
1377
1391
  </attribute>
1378
1392
  <optional>
1379
1393
  <element name="description">
1380
- <ref name="FormattedString"/>
1394
+ <oneOrMore>
1395
+ <ref name="TextElement"/>
1396
+ </oneOrMore>
1381
1397
  </element>
1382
1398
  </optional>
1383
1399
  <element name="bibitem">
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns='https://www.metanorma.org/ns/csa' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
2
+ <grammar ns='https://www.metanorma.org/ns/csa' xmlns="http://relaxng.org/ns/structure/1.0">
3
3
  <!--
4
4
  VERSION v1.2.1
5
5
  Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
@@ -13,23 +13,8 @@
13
13
  </start>
14
14
  <define name="figure">
15
15
  <element name="figure">
16
- <attribute name="id">
17
- <data type="ID"/>
18
- </attribute>
19
- <optional>
20
- <attribute name="unnumbered">
21
- <data type="boolean"/>
22
- </attribute>
23
- </optional>
24
- <optional>
25
- <attribute name="number"/>
26
- </optional>
27
- <optional>
28
- <attribute name="subsequence"/>
29
- </optional>
30
- <optional>
31
- <attribute name="class"/>
32
- </optional>
16
+ <ref name="FigureAttributes"/>
17
+ <ref name="BlockAttributes"/>
33
18
  <optional>
34
19
  <ref name="source"/>
35
20
  </optional>
@@ -156,44 +156,7 @@
156
156
  </define>
157
157
  <define name="xref">
158
158
  <element name="xref">
159
- <attribute name="target">
160
- <data type="string">
161
- <param name="pattern">\i\c*|\c+#\c+</param>
162
- </data>
163
- </attribute>
164
- <optional>
165
- <attribute name="to">
166
- <data type="string">
167
- <param name="pattern">\i\c*|\c+#\c+</param>
168
- </data>
169
- </attribute>
170
- </optional>
171
- <optional>
172
- <attribute name="type">
173
- <ref name="ReferenceFormat"/>
174
- </attribute>
175
- </optional>
176
- <optional>
177
- <attribute name="alt"/>
178
- </optional>
179
- <optional>
180
- <attribute name="case">
181
- <choice>
182
- <value>capital</value>
183
- <value>lowercase</value>
184
- </choice>
185
- </attribute>
186
- </optional>
187
- <optional>
188
- <attribute name="droploc">
189
- <data type="boolean"/>
190
- </attribute>
191
- </optional>
192
- <optional>
193
- <attribute name="style">
194
- <ref name="XrefStyleType"/>
195
- </attribute>
196
- </optional>
159
+ <ref name="XrefAttributes"/>
197
160
  <ref name="XrefBody"/>
198
161
  </element>
199
162
  </define>
@@ -407,23 +370,7 @@
407
370
  </define>
408
371
  <define name="figure">
409
372
  <element name="figure">
410
- <attribute name="id">
411
- <data type="ID"/>
412
- </attribute>
413
- <optional>
414
- <attribute name="unnumbered">
415
- <data type="boolean"/>
416
- </attribute>
417
- </optional>
418
- <optional>
419
- <attribute name="number"/>
420
- </optional>
421
- <optional>
422
- <attribute name="subsequence"/>
423
- </optional>
424
- <optional>
425
- <attribute name="class"/>
426
- </optional>
373
+ <ref name="FigureAttributes"/>
427
374
  <ref name="BlockAttributes"/>
428
375
  <optional>
429
376
  <ref name="tname"/>
@@ -2450,6 +2397,49 @@
2450
2397
  </zeroOrMore>
2451
2398
  </element>
2452
2399
  </define>
2400
+ <define name="XrefAttributes">
2401
+ <attribute name="target">
2402
+ <data type="string">
2403
+ <param name="pattern">\i\c*|\c+#\c+</param>
2404
+ </data>
2405
+ </attribute>
2406
+ <optional>
2407
+ <attribute name="to">
2408
+ <data type="string">
2409
+ <param name="pattern">\i\c*|\c+#\c+</param>
2410
+ </data>
2411
+ </attribute>
2412
+ </optional>
2413
+ <optional>
2414
+ <attribute name="type">
2415
+ <ref name="ReferenceFormat"/>
2416
+ </attribute>
2417
+ </optional>
2418
+ <optional>
2419
+ <attribute name="alt"/>
2420
+ </optional>
2421
+ <optional>
2422
+ <attribute name="case">
2423
+ <choice>
2424
+ <value>capital</value>
2425
+ <value>lowercase</value>
2426
+ </choice>
2427
+ </attribute>
2428
+ </optional>
2429
+ <optional>
2430
+ <attribute name="droploc">
2431
+ <data type="boolean"/>
2432
+ </attribute>
2433
+ </optional>
2434
+ <optional>
2435
+ <attribute name="style">
2436
+ <ref name="XrefStyleType"/>
2437
+ </attribute>
2438
+ </optional>
2439
+ <optional>
2440
+ <attribute name="label"/>
2441
+ </optional>
2442
+ </define>
2453
2443
  <define name="XrefBody">
2454
2444
  <zeroOrMore>
2455
2445
  <ref name="XrefTarget"/>
@@ -2528,6 +2518,28 @@
2528
2518
  <attribute name="columns"/>
2529
2519
  </optional>
2530
2520
  </define>
2521
+ <define name="FigureAttributes">
2522
+ <attribute name="id">
2523
+ <data type="ID"/>
2524
+ </attribute>
2525
+ <optional>
2526
+ <attribute name="unnumbered">
2527
+ <data type="boolean"/>
2528
+ </attribute>
2529
+ </optional>
2530
+ <optional>
2531
+ <attribute name="number"/>
2532
+ </optional>
2533
+ <optional>
2534
+ <attribute name="subsequence"/>
2535
+ </optional>
2536
+ <optional>
2537
+ <attribute name="class"/>
2538
+ </optional>
2539
+ <optional>
2540
+ <attribute name="width"/>
2541
+ </optional>
2542
+ </define>
2531
2543
  <start>
2532
2544
  <ref name="standard-document"/>
2533
2545
  </start>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Csa
3
- VERSION = "2.4.4".freeze
3
+ VERSION = "2.4.6".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-csa
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic