metanorma-ogc 2.5.4 → 2.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1584,17 +1584,30 @@
1584
1584
  <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 -->
1585
1585
 
1586
1586
  <xsl:param name="table_if">false</xsl:param> <!-- generate extended table in IF for autolayout-algorithm -->
1587
- <xsl:param name="table_widths"/> <!-- path to xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
1587
+ <xsl:param name="table_widths"/> <!-- (debug: path to) xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
1588
1588
  <!-- Example: <tables>
1589
- <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
1590
- <tbody>
1591
- <tr>
1592
- <td id="tab-symdu_1_1">
1593
- <p_len>6</p_len>
1594
- <p_len>100</p_len> for 2nd paragraph
1595
- <word_len>6</word_len>
1596
- <word_len>20</word_len>
1597
- ...
1589
+ <table page-width="509103" id="table1" width_max="223561" width_min="223560">
1590
+ <column width_max="39354" width_min="39354"/>
1591
+ <column width_max="75394" width_min="75394"/>
1592
+ <column width_max="108813" width_min="108813"/>
1593
+ <tbody>
1594
+ <tr>
1595
+ <td width_max="39354" width_min="39354">
1596
+ <p_len>39354</p_len>
1597
+ <word_len>39354</word_len>
1598
+ </td>
1599
+
1600
+ OLD:
1601
+ <tables>
1602
+ <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
1603
+ <tbody>
1604
+ <tr>
1605
+ <td id="tab-symdu_1_1">
1606
+ <p_len>6</p_len>
1607
+ <p_len>100</p_len> for 2nd paragraph
1608
+ <word_len>6</word_len>
1609
+ <word_len>20</word_len>
1610
+ ...
1598
1611
  -->
1599
1612
 
1600
1613
  <!-- for command line debug: <xsl:variable name="table_widths_from_if" select="document($table_widths)"/> -->
@@ -1813,6 +1826,10 @@
1813
1826
  <xsl:variable name="zero_width_space">​</xsl:variable>
1814
1827
  <xsl:variable name="hair_space"> </xsl:variable>
1815
1828
  <xsl:variable name="en_dash">–</xsl:variable>
1829
+ <xsl:variable name="em_dash">—</xsl:variable>
1830
+ <xsl:variable name="cr">&#13;</xsl:variable>
1831
+ <xsl:variable name="lf">
1832
+ </xsl:variable>
1816
1833
 
1817
1834
  <xsl:template name="getTitle">
1818
1835
  <xsl:param name="name"/>
@@ -2193,6 +2210,10 @@
2193
2210
 
2194
2211
  </xsl:attribute-set> <!-- example-name-style -->
2195
2212
 
2213
+ <xsl:template name="refine_example-name-style">
2214
+
2215
+ </xsl:template>
2216
+
2196
2217
  <xsl:attribute-set name="example-p-style">
2197
2218
 
2198
2219
  <xsl:attribute name="margin-bottom">14pt</xsl:attribute>
@@ -2209,6 +2230,10 @@
2209
2230
 
2210
2231
  </xsl:attribute-set> <!-- termexample-name-style -->
2211
2232
 
2233
+ <xsl:template name="refine_termexample-name-style">
2234
+
2235
+ </xsl:template>
2236
+
2212
2237
  <!-- ========================== -->
2213
2238
  <!-- Table styles -->
2214
2239
  <!-- ========================== -->
@@ -2398,6 +2423,10 @@
2398
2423
 
2399
2424
  </xsl:attribute-set> <!-- table-fn-style -->
2400
2425
 
2426
+ <xsl:template name="refine_table-fn-style">
2427
+
2428
+ </xsl:template>
2429
+
2401
2430
  <xsl:attribute-set name="table-fn-number-style">
2402
2431
  <xsl:attribute name="font-size">80%</xsl:attribute>
2403
2432
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
@@ -2406,6 +2435,10 @@
2406
2435
 
2407
2436
  </xsl:attribute-set> <!-- table-fn-number-style -->
2408
2437
 
2438
+ <xsl:template name="refine_table-fn-number-style">
2439
+
2440
+ </xsl:template>
2441
+
2409
2442
  <xsl:attribute-set name="fn-container-body-style">
2410
2443
  <xsl:attribute name="text-indent">0</xsl:attribute>
2411
2444
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -3600,6 +3633,20 @@
3600
3633
  </xsl:for-each>
3601
3634
  </xsl:template>
3602
3635
 
3636
+ <xsl:param name="table_only_with_id"/><!-- Example: table1, for table auto-layout algorithm -->
3637
+
3638
+ <xsl:template match="*[local-name()='table']" priority="2">
3639
+ <xsl:choose>
3640
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
3641
+ <xsl:call-template name="table"/>
3642
+ </xsl:when>
3643
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
3644
+ <xsl:otherwise>
3645
+ <xsl:call-template name="table"/>
3646
+ </xsl:otherwise>
3647
+ </xsl:choose>
3648
+ </xsl:template>
3649
+
3603
3650
  <xsl:template match="*[local-name()='table']" name="table">
3604
3651
 
3605
3652
  <xsl:variable name="table-preamble">
@@ -3611,9 +3658,11 @@
3611
3658
  <xsl:variable name="table">
3612
3659
 
3613
3660
  <xsl:variable name="simple-table">
3614
- <xsl:call-template name="getSimpleTable">
3615
- <xsl:with-param name="id" select="@id"/>
3616
- </xsl:call-template>
3661
+ <xsl:if test="$isGenerateTableIF = 'true' and $isApplyAutolayoutAlgorithm = 'true'">
3662
+ <xsl:call-template name="getSimpleTable">
3663
+ <xsl:with-param name="id" select="@id"/>
3664
+ </xsl:call-template>
3665
+ </xsl:if>
3617
3666
  </xsl:variable>
3618
3667
  <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3619
3668
 
@@ -3715,9 +3764,9 @@
3715
3764
  </xsl:attribute>
3716
3765
  </xsl:for-each>
3717
3766
 
3718
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
3767
+ <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']"/>
3719
3768
  <xsl:if test="$isNoteOrFnExist = 'true'">
3720
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
3769
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3721
3770
  </xsl:if>
3722
3771
 
3723
3772
  <xsl:choose>
@@ -3866,9 +3915,28 @@
3866
3915
 
3867
3916
  </fo:block>
3868
3917
 
3918
+ <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
3919
+ <xsl:if test="$continued = 'true'">
3920
+ <fo:block text-align="right">
3921
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3922
+ </fo:block>
3923
+ </xsl:if>
3924
+ <!-- </xsl:if> -->
3925
+
3869
3926
  </xsl:if>
3870
3927
  </xsl:template> <!-- table/name -->
3871
3928
 
3929
+ <!-- workaround solution for https://github.com/metanorma/metanorma-iso/issues/1151#issuecomment-2033087938 -->
3930
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'note'][@type = 'units']/*[local-name() = 'p']/text()" priority="4">
3931
+ <xsl:choose>
3932
+ <xsl:when test="preceding-sibling::*[local-name() = 'br']">
3933
+ <!-- remove CR or LF at start -->
3934
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'^(&#13;&#10;|&#13;|&#10;)', '')"/>
3935
+ </xsl:when>
3936
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
3937
+ </xsl:choose>
3938
+ </xsl:template>
3939
+
3872
3940
  <!-- SOURCE: ... -->
3873
3941
  <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
3874
3942
  <xsl:call-template name="termsource"/>
@@ -4279,7 +4347,7 @@
4279
4347
  <xsl:param name="colwidths"/>
4280
4348
  <xsl:param name="colgroup"/>
4281
4349
 
4282
- <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']"/>
4350
+ <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']"/>
4283
4351
 
4284
4352
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
4285
4353
 
@@ -4351,7 +4419,7 @@
4351
4419
 
4352
4420
  <xsl:apply-templates select="../*[local-name()='p']"/>
4353
4421
  <xsl:apply-templates select="../*[local-name()='dl']"/>
4354
- <xsl:apply-templates select="../*[local-name()='note']"/>
4422
+ <xsl:apply-templates select="../*[local-name()='note'][not(@type = 'units')]"/>
4355
4423
  <xsl:apply-templates select="../*[local-name()='example']"/>
4356
4424
  <xsl:apply-templates select="../*[local-name()='source']"/>
4357
4425
 
@@ -4361,7 +4429,7 @@
4361
4429
 
4362
4430
  <!-- horizontal row separator -->
4363
4431
  <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
4364
- <xsl:if test="(../*[local-name()='note'] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
4432
+ <xsl:if test="(../*[local-name()='note'][not(@type = 'units')] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
4365
4433
  <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
4366
4434
 
4367
4435
  <xsl:call-template name="setBordersTableArray"/>
@@ -4840,8 +4908,9 @@
4840
4908
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
4841
4909
 
4842
4910
  <fo:block xsl:use-attribute-sets="table-fn-style">
4843
-
4911
+ <xsl:call-template name="refine_table-fn-style"/>
4844
4912
  <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
4913
+ <xsl:call-template name="refine_table-fn-number-style"/>
4845
4914
 
4846
4915
  <xsl:value-of select="@reference"/>
4847
4916
 
@@ -5036,7 +5105,20 @@
5036
5105
  <!-- Definition List -->
5037
5106
  <!-- ===================== -->
5038
5107
 
5039
- <xsl:template match="*[local-name()='dl']">
5108
+ <!-- for table auto-layout algorithm -->
5109
+ <xsl:template match="*[local-name()='dl']" priority="2">
5110
+ <xsl:choose>
5111
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
5112
+ <xsl:call-template name="dl"/>
5113
+ </xsl:when>
5114
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
5115
+ <xsl:otherwise>
5116
+ <xsl:call-template name="dl"/>
5117
+ </xsl:otherwise>
5118
+ </xsl:choose>
5119
+ </xsl:template>
5120
+
5121
+ <xsl:template match="*[local-name()='dl']" name="dl">
5040
5122
  <xsl:variable name="isAdded" select="@added"/>
5041
5123
  <xsl:variable name="isDeleted" select="@deleted"/>
5042
5124
  <!-- <dl><xsl:copy-of select="."/></dl> -->
@@ -6002,11 +6084,16 @@
6002
6084
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
6003
6085
  <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
6004
6086
  <xsl:variable name="text" select="."/>
6005
- <fo:inline font-size="75%" role="SKIP">
6087
+ <xsl:variable name="ratio_">
6088
+ 0.75
6089
+ </xsl:variable>
6090
+ <xsl:variable name="ratio" select="number(normalize-space($ratio_))"/>
6091
+ <fo:inline font-size="{$ratio * 100}%" role="SKIP">
6006
6092
  <xsl:if test="string-length($text) &gt; 0">
6007
6093
  <xsl:variable name="smallCapsText">
6008
6094
  <xsl:call-template name="recursiveSmallCaps">
6009
6095
  <xsl:with-param name="text" select="$text"/>
6096
+ <xsl:with-param name="ratio" select="$ratio"/>
6010
6097
  </xsl:call-template>
6011
6098
  </xsl:variable>
6012
6099
  <!-- merge neighboring fo:inline -->
@@ -6043,12 +6130,13 @@
6043
6130
 
6044
6131
  <xsl:template name="recursiveSmallCaps">
6045
6132
  <xsl:param name="text"/>
6133
+ <xsl:param name="ratio"/>
6046
6134
  <xsl:variable name="char" select="substring($text,1,1)"/>
6047
6135
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
6048
6136
  <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
6049
6137
  <xsl:choose>
6050
6138
  <xsl:when test="$char=$upperCase">
6051
- <fo:inline font-size="{100 div 0.75}%" role="SKIP">
6139
+ <fo:inline font-size="{100 div $ratio}%" role="SKIP">
6052
6140
  <xsl:value-of select="$upperCase"/>
6053
6141
  </fo:inline>
6054
6142
  </xsl:when>
@@ -6059,6 +6147,7 @@
6059
6147
  <xsl:if test="string-length($text) &gt; 1">
6060
6148
  <xsl:call-template name="recursiveSmallCaps">
6061
6149
  <xsl:with-param name="text" select="substring($text,2)"/>
6150
+ <xsl:with-param name="ratio" select="$ratio"/>
6062
6151
  </xsl:call-template>
6063
6152
  </xsl:if>
6064
6153
  </xsl:template>
@@ -6095,6 +6184,9 @@
6095
6184
  <xsl:if test="$key = 'font-family' or $key = 'font-size' or $key = 'color'">
6096
6185
  <style name="{$key}"><xsl:value-of select="$value"/></style>
6097
6186
  </xsl:if>
6187
+ <xsl:if test="$key = 'text-indent'">
6188
+ <style name="padding-left"><xsl:value-of select="$value"/></style>
6189
+ </xsl:if>
6098
6190
  </xsl:for-each>
6099
6191
  </xsl:variable>
6100
6192
  <xsl:variable name="styles" select="xalan:nodeset($styles_)"/>
@@ -6967,7 +7059,13 @@
6967
7059
  <xsl:value-of select="$language_current_2"/>
6968
7060
  </xsl:when>
6969
7061
  <xsl:otherwise>
6970
- <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
7062
+ <xsl:variable name="language_current_3" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'])"/>
7063
+ <xsl:choose>
7064
+ <xsl:when test="$language_current_3 != ''">
7065
+ <xsl:value-of select="$language_current_3"/>
7066
+ </xsl:when>
7067
+ <xsl:otherwise>en</xsl:otherwise>
7068
+ </xsl:choose>
6971
7069
  </xsl:otherwise>
6972
7070
  </xsl:choose>
6973
7071
  </xsl:otherwise>
@@ -7501,6 +7599,11 @@
7501
7599
  </xsl:call-template>
7502
7600
  </xsl:template>
7503
7601
 
7602
+ <!-- command between two xref points to non-standard bibitem -->
7603
+ <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']]]">
7604
+ <xsl:value-of select="."/>
7605
+ </xsl:template>
7606
+
7504
7607
  <!-- ====== -->
7505
7608
  <!-- formula -->
7506
7609
  <!-- ====== -->
@@ -7871,7 +7974,7 @@
7871
7974
  </xsl:when>
7872
7975
  <xsl:otherwise>
7873
7976
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
7874
- <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
7977
+ <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'])">
7875
7978
 
7876
7979
  <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
7877
7980
  <xsl:attribute name="width">
@@ -8206,6 +8309,8 @@
8206
8309
  </xsl:attribute>
8207
8310
  </xsl:template>
8208
8311
 
8312
+ <xsl:variable name="regex_starts_with_digit">^[0-9].*</xsl:variable>
8313
+
8209
8314
  <xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
8210
8315
  <xsl:copy>
8211
8316
  <xsl:apply-templates select="@*" mode="svg_update"/>
@@ -8224,7 +8329,8 @@
8224
8329
 
8225
8330
  <xsl:attribute name="width">
8226
8331
  <xsl:choose>
8227
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
8332
+ <!-- width is non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
8333
+ <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>
8228
8334
  <xsl:when test="$width != ''">
8229
8335
  <xsl:value-of select="round($width)"/>
8230
8336
  </xsl:when>
@@ -8233,7 +8339,8 @@
8233
8339
  </xsl:attribute>
8234
8340
  <xsl:attribute name="height">
8235
8341
  <xsl:choose>
8236
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
8342
+ <!-- height non 'auto', 'text-width', 'full-page-width' or 'narrow' -->
8343
+ <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>
8237
8344
  <xsl:when test="$height != ''">
8238
8345
  <xsl:value-of select="round($height)"/>
8239
8346
  </xsl:when>
@@ -8250,7 +8357,7 @@
8250
8357
  <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
8251
8358
  <xsl:attribute name="width">
8252
8359
  <xsl:choose>
8253
- <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
8360
+ <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>
8254
8361
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
8255
8362
  </xsl:choose>
8256
8363
  </xsl:attribute>
@@ -8261,7 +8368,7 @@
8261
8368
  <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
8262
8369
  <xsl:attribute name="height">
8263
8370
  <xsl:choose>
8264
- <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
8371
+ <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>
8265
8372
  <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
8266
8373
  </xsl:choose>
8267
8374
  </xsl:attribute>
@@ -9775,6 +9882,7 @@
9775
9882
  <xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']">
9776
9883
  <xsl:if test="normalize-space() != ''">
9777
9884
  <fo:inline xsl:use-attribute-sets="termexample-name-style">
9885
+ <xsl:call-template name="refine_termexample-name-style"/>
9778
9886
  <xsl:apply-templates/>
9779
9887
  </fo:inline>
9780
9888
  </xsl:if>
@@ -9925,6 +10033,7 @@
9925
10033
  </xsl:when>
9926
10034
  <xsl:otherwise>
9927
10035
  <fo:inline xsl:use-attribute-sets="example-name-style">
10036
+ <xsl:call-template name="refine_example-name-style"/>
9928
10037
  <xsl:apply-templates/>:
9929
10038
  </fo:inline>
9930
10039
  </xsl:otherwise>
@@ -11128,6 +11237,7 @@
11128
11237
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
11129
11238
 
11130
11239
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
11240
+
11131
11241
  <xsl:call-template name="processBibitem"/>
11132
11242
  </fo:block>
11133
11243
 
@@ -11169,6 +11279,7 @@
11169
11279
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
11170
11280
  <xsl:otherwise>
11171
11281
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
11282
+
11172
11283
  <fo:list-item-label end-indent="label-end()">
11173
11284
  <fo:block role="SKIP">
11174
11285
  <fo:inline role="SKIP">