metanorma-ribose 2.6.3 → 2.6.5

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.
@@ -2026,6 +2026,7 @@
2026
2026
  </xsl:template> <!-- refine_table-style -->
2027
2027
 
2028
2028
  <xsl:attribute-set name="table-name-style">
2029
+ <xsl:attribute name="role">Caption</xsl:attribute>
2029
2030
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2030
2031
 
2031
2032
  <xsl:attribute name="font-size">13pt</xsl:attribute>
@@ -2039,6 +2040,9 @@
2039
2040
 
2040
2041
  <xsl:template name="refine_table-name-style">
2041
2042
  <xsl:param name="continued"/>
2043
+ <xsl:if test="$continued = 'true'">
2044
+ <xsl:attribute name="role">SKIP</xsl:attribute>
2045
+ </xsl:if>
2042
2046
 
2043
2047
  </xsl:template> <!-- refine_table-name-style -->
2044
2048
 
@@ -3724,8 +3728,14 @@
3724
3728
  </xsl:choose>
3725
3729
  </xsl:variable>
3726
3730
 
3731
+ <xsl:call-template name="setNamedDestination"/>
3732
+
3727
3733
  <fo:block-container xsl:use-attribute-sets="table-container-style" role="SKIP">
3728
3734
 
3735
+ <xsl:for-each select="*[local-name() = 'name']">
3736
+ <xsl:call-template name="setIDforNamedDestination"/>
3737
+ </xsl:for-each>
3738
+
3729
3739
  <xsl:call-template name="refine_table-container-style">
3730
3740
  <xsl:with-param name="margin-side" select="$margin-side"/>
3731
3741
  </xsl:call-template>
@@ -3869,7 +3879,7 @@
3869
3879
  </xsl:if>
3870
3880
 
3871
3881
  </fo:block-container>
3872
- </xsl:variable>
3882
+ </xsl:variable> <!-- END: variable name="table" -->
3873
3883
 
3874
3884
  <xsl:variable name="isAdded" select="@added"/>
3875
3885
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -3879,14 +3889,14 @@
3879
3889
 
3880
3890
  <!-- centered table when table name is centered (see table-name-style) -->
3881
3891
 
3882
- <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
3892
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style" role="SKIP">
3883
3893
 
3884
3894
  <fo:table-column column-width="proportional-column-width(1)"/>
3885
3895
  <fo:table-column column-width="{@width}"/>
3886
3896
  <fo:table-column column-width="proportional-column-width(1)"/>
3887
- <fo:table-body>
3888
- <fo:table-row>
3889
- <fo:table-cell column-number="2">
3897
+ <fo:table-body role="SKIP">
3898
+ <fo:table-row role="SKIP">
3899
+ <fo:table-cell column-number="2" role="SKIP">
3890
3900
  <xsl:copy-of select="$table-preamble"/>
3891
3901
  <fo:block role="SKIP">
3892
3902
  <xsl:call-template name="setTrackChangesStyles">
@@ -3927,11 +3937,13 @@
3927
3937
 
3928
3938
  </xsl:template>
3929
3939
 
3940
+ <!-- table/name-->
3930
3941
  <xsl:template match="*[local-name()='table']/*[local-name() = 'name']">
3931
3942
  <xsl:param name="continued"/>
3943
+ <xsl:param name="cols-count"/>
3932
3944
  <xsl:if test="normalize-space() != ''">
3933
3945
 
3934
- <fo:block xsl:use-attribute-sets="table-name-style" role="SKIP">
3946
+ <fo:block xsl:use-attribute-sets="table-name-style">
3935
3947
 
3936
3948
  <xsl:call-template name="refine_table-name-style">
3937
3949
  <xsl:with-param name="continued" select="$continued"/>
@@ -3950,9 +3962,30 @@
3950
3962
 
3951
3963
  <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
3952
3964
  <xsl:if test="$continued = 'true'">
3953
- <fo:block text-align="right">
3954
- <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3955
- </fo:block>
3965
+
3966
+ <!-- to prevent the error 'THead element may contain only TR elements' -->
3967
+
3968
+ <xsl:choose>
3969
+ <xsl:when test="string(number($cols-count)) != 'NaN'">
3970
+ <fo:table width="100%" table-layout="fixed" role="SKIP">
3971
+ <fo:table-body role="SKIP">
3972
+ <fo:table-row>
3973
+ <fo:table-cell role="TH" number-columns-spanned="{$cols-count}">
3974
+ <fo:block text-align="right" role="SKIP">
3975
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3976
+ </fo:block>
3977
+ </fo:table-cell>
3978
+ </fo:table-row>
3979
+ </fo:table-body>
3980
+ </fo:table>
3981
+ </xsl:when>
3982
+ <xsl:otherwise>
3983
+ <fo:block text-align="right">
3984
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3985
+ </fo:block>
3986
+ </xsl:otherwise>
3987
+ </xsl:choose>
3988
+
3956
3989
  </xsl:if>
3957
3990
  <!-- </xsl:if> -->
3958
3991
 
@@ -4345,6 +4378,7 @@
4345
4378
 
4346
4379
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
4347
4380
  <xsl:with-param name="continued">true</xsl:with-param>
4381
+ <xsl:with-param name="cols-count" select="$cols-count"/>
4348
4382
  </xsl:apply-templates>
4349
4383
 
4350
4384
  <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
@@ -4408,7 +4442,7 @@
4408
4442
 
4409
4443
  <xsl:variable name="tableWithNotesAndFootnotes">
4410
4444
 
4411
- <fo:table keep-with-previous="always">
4445
+ <fo:table keep-with-previous="always" role="SKIP">
4412
4446
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
4413
4447
  <xsl:variable name="name" select="local-name()"/>
4414
4448
  <xsl:choose>
@@ -4439,9 +4473,9 @@
4439
4473
  </xsl:otherwise>
4440
4474
  </xsl:choose>
4441
4475
 
4442
- <fo:table-body>
4443
- <fo:table-row>
4444
- <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}">
4476
+ <fo:table-body role="SKIP">
4477
+ <fo:table-row role="SKIP">
4478
+ <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}" role="SKIP">
4445
4479
 
4446
4480
  <xsl:call-template name="refine_table-footer-cell-style"/>
4447
4481
 
@@ -4726,8 +4760,8 @@
4726
4760
  <xsl:for-each select="xalan:nodeset($styles__)/item">
4727
4761
  <xsl:variable name="key" select="normalize-space(substring-before(., ':'))"/>
4728
4762
  <xsl:variable name="value" select="normalize-space(substring-after(translate(.,$quot,''), ':'))"/>
4729
- <xsl:if test="$key = 'color' or $key = 'background-color'">
4730
- <style name="{$key}"><xsl:value-of select="$value"/></style>
4763
+ <xsl:if test="$key = 'color' or $key = 'background-color' or $key = 'border' or $key = 'border-top' or $key = 'border-right' or $key = 'border-left' or $key = 'border-bottom' or $key = 'border-style' or $key = 'border-width' or $key = 'border-color' or $key = 'border-top-style' or $key = 'border-top-width' or $key = 'border-top-color' or $key = 'border-right-style' or $key = 'border-right-width' or $key = 'border-right-color' or $key = 'border-left-style' or $key = 'border-left-width' or $key = 'border-left-color' or $key = 'border-bottom-style' or $key = 'border-bottom-width' or $key = 'border-bottom-color'">
4764
+ <style name="{$key}"><xsl:value-of select="java:replaceAll(java:java.lang.String.new($value), 'currentColor', 'inherit')"/></style>
4731
4765
  </xsl:if>
4732
4766
  </xsl:for-each>
4733
4767
  </xsl:variable>
@@ -4791,6 +4825,7 @@
4791
4825
  <!-- table/note, table/example, table/tfoot//note, table/tfoot//example -->
4792
4826
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example'] | *[local-name()='table']/*[local-name()='tfoot']//*[local-name()='note' or local-name() = 'example']" priority="2">
4793
4827
 
4828
+ <xsl:call-template name="setNamedDestination"/>
4794
4829
  <fo:block xsl:use-attribute-sets="table-note-style">
4795
4830
  <xsl:copy-of select="@id"/>
4796
4831
 
@@ -4838,6 +4873,7 @@
4838
4873
  <!-- footnotes in text (title, bibliography, main body), not for tables, figures and names --> <!-- table's, figure's names -->
4839
4874
  <!-- fn in text -->
4840
4875
  <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" priority="2" name="fn">
4876
+ <xsl:param name="footnote_body_from_table">false</xsl:param>
4841
4877
 
4842
4878
  <!-- list of unique footnotes -->
4843
4879
  <xsl:variable name="p_fn_">
@@ -4903,7 +4939,7 @@
4903
4939
  <xsl:copy-of select="$footnote_inline"/>
4904
4940
  </xsl:when>
4905
4941
  <!-- <xsl:when test="$footnotes//*[local-name() = 'fmt-fn-body'][@id = $ref_id] or normalize-space(@skip_footnote_body) = 'false'"> -->
4906
- <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
4942
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false' or $footnote_body_from_table = 'true'">
4907
4943
 
4908
4944
  <fo:footnote xsl:use-attribute-sets="fn-style" role="SKIP">
4909
4945
  <xsl:copy-of select="$footnote_inline"/>
@@ -5312,39 +5348,51 @@
5312
5348
  <!-- fn reference in the table rendering (for instance, 'some text 1) some text' ) -->
5313
5349
  <!-- fn --> <!-- in table --> <!-- for figure see <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/> -->
5314
5350
  <xsl:template match="*[local-name()='fn']">
5315
- <fo:inline xsl:use-attribute-sets="fn-reference-style">
5316
-
5317
- <xsl:call-template name="refine_fn-reference-style"/>
5351
+ <xsl:variable name="target" select="@target"/>
5352
+ <xsl:choose>
5353
+ <!-- case for footnotes in Requirement tables (https://github.com/metanorma/metanorma-ogc/issues/791) -->
5354
+ <xsl:when test="not(ancestor::*[local-name() = 'table'][1]//*[local-name() = 'fmt-footnote-container']/*[local-name() = 'fmt-fn-body'][@id = $target]) and $footnotes/*[local-name() = 'fmt-fn-body'][@id = $target]">
5355
+ <xsl:call-template name="fn">
5356
+ <xsl:with-param name="footnote_body_from_table">true</xsl:with-param>
5357
+ </xsl:call-template>
5358
+ </xsl:when>
5359
+ <xsl:otherwise>
5318
5360
 
5319
- <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
5320
- <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
5321
- <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
5322
- <!-- <xsl:attribute name="internal-destination">
5323
- <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
5324
- </xsl:attribute>
5325
- </xsl:if>
5326
- <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
5327
- <xsl:attribute name="internal-destination">
5328
- <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
5329
- <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
5330
- </xsl:attribute>
5331
- </xsl:if> -->
5332
- <!-- <xsl:if test="$namespace = 'plateau'">
5333
- <xsl:text>※</xsl:text>
5334
- </xsl:if> -->
5335
- <!-- <xsl:value-of select="@reference"/> -->
5361
+ <fo:inline xsl:use-attribute-sets="fn-reference-style">
5336
5362
 
5337
- <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
5363
+ <xsl:call-template name="refine_fn-reference-style"/>
5338
5364
 
5339
- <!-- <xsl:if test="$namespace = 'bsi'">
5340
- <xsl:text>)</xsl:text>
5341
- </xsl:if> -->
5342
- <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
5343
- <!-- <xsl:if test="$namespace = 'jis'">
5344
- <fo:inline font-weight="normal">)</fo:inline>
5345
- </xsl:if> -->
5346
- </fo:basic-link>
5347
- </fo:inline>
5365
+ <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
5366
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
5367
+ <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
5368
+ <!-- <xsl:attribute name="internal-destination">
5369
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
5370
+ </xsl:attribute>
5371
+ </xsl:if>
5372
+ <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
5373
+ <xsl:attribute name="internal-destination">
5374
+ <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
5375
+ <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
5376
+ </xsl:attribute>
5377
+ </xsl:if> -->
5378
+ <!-- <xsl:if test="$namespace = 'plateau'">
5379
+ <xsl:text>※</xsl:text>
5380
+ </xsl:if> -->
5381
+ <!-- <xsl:value-of select="@reference"/> -->
5382
+
5383
+ <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
5384
+
5385
+ <!-- <xsl:if test="$namespace = 'bsi'">
5386
+ <xsl:text>)</xsl:text>
5387
+ </xsl:if> -->
5388
+ <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
5389
+ <!-- <xsl:if test="$namespace = 'jis'">
5390
+ <fo:inline font-weight="normal">)</fo:inline>
5391
+ </xsl:if> -->
5392
+ </fo:basic-link>
5393
+ </fo:inline>
5394
+ </xsl:otherwise>
5395
+ </xsl:choose>
5348
5396
  </xsl:template> <!-- fn -->
5349
5397
 
5350
5398
  <!-- fn/text() -->
@@ -5399,6 +5447,10 @@
5399
5447
  <!-- <dl><xsl:copy-of select="."/></dl> -->
5400
5448
  <fo:block-container xsl:use-attribute-sets="dl-block-style" role="SKIP">
5401
5449
 
5450
+ <xsl:if test="@key = 'true' and ancestor::*[local-name() = 'figure']">
5451
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
5452
+ </xsl:if>
5453
+
5402
5454
  <xsl:call-template name="setBlockSpanAll"/>
5403
5455
 
5404
5456
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
@@ -5692,7 +5744,7 @@
5692
5744
 
5693
5745
  <!-- caption for figure key and another caption, https://github.com/metanorma/isodoc/issues/607 -->
5694
5746
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'p'][@keep-with-next = 'true' and *[local-name() = 'strong']]" priority="3">
5695
- <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always">
5747
+ <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always" keep-with-previous="always">
5696
5748
  <xsl:call-template name="refine_figure_key_style"/>
5697
5749
  <xsl:apply-templates/>
5698
5750
  </fo:block>
@@ -5946,6 +5998,7 @@
5946
5998
 
5947
5999
  <xsl:call-template name="refine_dt-cell-style"/>
5948
6000
 
6001
+ <xsl:call-template name="setNamedDestination"/>
5949
6002
  <fo:block xsl:use-attribute-sets="dt-block-style" role="SKIP">
5950
6003
 
5951
6004
  <xsl:choose>
@@ -6390,7 +6443,7 @@
6390
6443
  <!-- ================= -->
6391
6444
 
6392
6445
  <!-- highlight text -->
6393
- <xsl:template match="*[local-name()='hi']">
6446
+ <xsl:template match="*[local-name()='hi'] | *[local-name() = 'span'][@class = 'fmt-hi']" priority="3">
6394
6447
  <fo:inline background-color="yellow">
6395
6448
  <xsl:apply-templates/>
6396
6449
  </fo:inline>
@@ -7985,6 +8038,7 @@
7985
8038
  <!-- Appendix processing -->
7986
8039
  <!-- ======================== -->
7987
8040
  <xsl:template match="*[local-name()='appendix']">
8041
+ <xsl:call-template name="setNamedDestination"/>
7988
8042
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-style">
7989
8043
  <xsl:apply-templates select="*[local-name()='title']"/>
7990
8044
  </fo:block>
@@ -7995,13 +8049,14 @@
7995
8049
  <xsl:variable name="level">
7996
8050
  <xsl:call-template name="getLevel"/>
7997
8051
  </xsl:variable>
7998
- <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
8052
+ <fo:inline role="H{$level}"><xsl:call-template name="setIDforNamedDestination"/><xsl:apply-templates/></fo:inline>
7999
8053
  </xsl:template>
8000
8054
  <!-- ======================== -->
8001
8055
  <!-- END Appendix processing -->
8002
8056
  <!-- ======================== -->
8003
8057
 
8004
8058
  <xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
8059
+ <xsl:call-template name="setNamedDestination"/>
8005
8060
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
8006
8061
  <xsl:apply-templates select="*[local-name()='name']"/>
8007
8062
  </fo:block>
@@ -8031,6 +8086,7 @@
8031
8086
  <xsl:template match="*[local-name() = 'annotation']/*[local-name() = 'p']">
8032
8087
  <xsl:param name="callout"/>
8033
8088
  <fo:inline id="{@id}">
8089
+ <xsl:call-template name="setNamedDestination"/>
8034
8090
  <!-- for first p in annotation, put <x> -->
8035
8091
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
8036
8092
  <xsl:apply-templates/>
@@ -8077,6 +8133,7 @@
8077
8133
 
8078
8134
  </xsl:if>
8079
8135
  <fo:block-container margin-left="0mm" role="SKIP">
8136
+ <xsl:call-template name="setNamedDestination"/>
8080
8137
  <fo:block id="{@id}">
8081
8138
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/> <!-- formula's number will be process in 'stem' template -->
8082
8139
  </fo:block>
@@ -8122,8 +8179,13 @@
8122
8179
  </fo:block>
8123
8180
  </fo:table-cell>
8124
8181
  <fo:table-cell display-align="center">
8182
+
8125
8183
  <fo:block xsl:use-attribute-sets="formula-stem-number-style" role="SKIP">
8126
8184
 
8185
+ <xsl:for-each select="../*[local-name() = 'name']">
8186
+ <xsl:call-template name="setIDforNamedDestination"/>
8187
+ </xsl:for-each>
8188
+
8127
8189
  <xsl:call-template name="refine_formula-stem-number-style"/>
8128
8190
 
8129
8191
  <xsl:apply-templates select="../*[local-name() = 'name']"/>
@@ -8158,6 +8220,8 @@
8158
8220
 
8159
8221
  <xsl:template match="*[local-name() = 'note']" name="note">
8160
8222
 
8223
+ <xsl:call-template name="setNamedDestination"/>
8224
+
8161
8225
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style" role="SKIP">
8162
8226
 
8163
8227
  <xsl:call-template name="setBlockSpanAll"/>
@@ -8222,6 +8286,7 @@
8222
8286
  </xsl:template>
8223
8287
 
8224
8288
  <xsl:template match="*[local-name() = 'termnote']">
8289
+ <xsl:call-template name="setNamedDestination"/>
8225
8290
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
8226
8291
 
8227
8292
  <xsl:call-template name="setBlockSpanAll"/>
@@ -8328,12 +8393,14 @@
8328
8393
 
8329
8394
  <xsl:template match="*[local-name() = 'terms']">
8330
8395
  <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
8396
+ <xsl:call-template name="setNamedDestination"/>
8331
8397
  <fo:block id="{@id}">
8332
8398
  <xsl:apply-templates/>
8333
8399
  </fo:block>
8334
8400
  </xsl:template>
8335
8401
 
8336
8402
  <xsl:template match="*[local-name() = 'term']">
8403
+ <xsl:call-template name="setNamedDestination"/>
8337
8404
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
8338
8405
 
8339
8406
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'term'])">
@@ -8365,6 +8432,7 @@
8365
8432
  <xsl:template match="*[local-name() = 'figure']" name="figure">
8366
8433
  <xsl:variable name="isAdded" select="@added"/>
8367
8434
  <xsl:variable name="isDeleted" select="@deleted"/>
8435
+ <xsl:call-template name="setNamedDestination"/>
8368
8436
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
8369
8437
  <xsl:call-template name="refine_figure-block-style"/>
8370
8438
 
@@ -8384,6 +8452,11 @@
8384
8452
  </xsl:variable>
8385
8453
 
8386
8454
  <fo:block xsl:use-attribute-sets="figure-style" role="SKIP">
8455
+
8456
+ <xsl:for-each select="*[local-name() = 'name']"> <!-- set context -->
8457
+ <xsl:call-template name="setIDforNamedDestination"/>
8458
+ </xsl:for-each>
8459
+
8387
8460
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
8388
8461
  </fo:block>
8389
8462
 
@@ -8414,6 +8487,7 @@
8414
8487
  </xsl:template>
8415
8488
 
8416
8489
  <xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']">
8490
+ <xsl:call-template name="setNamedDestination"/>
8417
8491
  <fo:block id="{@id}">
8418
8492
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8419
8493
  </fo:block>
@@ -8427,6 +8501,7 @@
8427
8501
  </xsl:template>
8428
8502
 
8429
8503
  <!-- SOURCE: ... -->
8504
+ <!-- figure/source -->
8430
8505
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
8431
8506
 
8432
8507
  <xsl:call-template name="termsource"/>
@@ -9352,6 +9427,13 @@
9352
9427
  <xsl:apply-templates select="."/>
9353
9428
  </xsl:template>
9354
9429
 
9430
+ <!-- prevent missing stem for table and figures in ToC -->
9431
+ <xsl:template match="*[local-name() = 'name' or local-name() = 'fmt-name']//*[local-name() = 'stem']" mode="contents">
9432
+ <xsl:if test="not(following-sibling::*[1][local-name() = 'fmt-stem'])">
9433
+ <xsl:apply-templates select="."/>
9434
+ </xsl:if>
9435
+ </xsl:template>
9436
+
9355
9437
  <xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/>
9356
9438
 
9357
9439
  <xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/>
@@ -9575,7 +9657,8 @@
9575
9657
 
9576
9658
  <xsl:for-each select="$contents_nodes//tables/table">
9577
9659
  <fo:bookmark internal-destination="{@id}">
9578
- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
9660
+ <!-- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title> -->
9661
+ <fo:bookmark-title><xsl:apply-templates mode="bookmark_clean"/></fo:bookmark-title>
9579
9662
  </fo:bookmark>
9580
9663
  </xsl:for-each>
9581
9664
  </fo:bookmark>
@@ -9584,6 +9667,26 @@
9584
9667
  </xsl:template> <!-- insertTableBookmarks -->
9585
9668
  <!-- End Bookmarks -->
9586
9669
 
9670
+ <!-- ============================ -->
9671
+ <!-- mode="bookmark_clean" -->
9672
+ <!-- ============================ -->
9673
+ <xsl:template match="node()" mode="bookmark_clean">
9674
+ <xsl:apply-templates select="node()" mode="bookmark_clean"/>
9675
+ </xsl:template>
9676
+
9677
+ <xsl:template match="text()" mode="bookmark_clean">
9678
+ <xsl:value-of select="."/>
9679
+ </xsl:template>
9680
+
9681
+ <xsl:template match="*[local-name() = 'math']" mode="bookmark_clean">
9682
+ <xsl:value-of select="normalize-space(.)"/>
9683
+ </xsl:template>
9684
+
9685
+ <xsl:template match="*[local-name() = 'asciimath']" mode="bookmark_clean"/>
9686
+ <!-- ============================ -->
9687
+ <!-- END: mode="bookmark_clean" -->
9688
+ <!-- ============================ -->
9689
+
9587
9690
  <xsl:template name="getLangVersion">
9588
9691
  <xsl:param name="lang"/>
9589
9692
  <xsl:param name="doctype" select="''"/>
@@ -9631,6 +9734,7 @@
9631
9734
  <xsl:template match="title" mode="bookmark"/>
9632
9735
  <xsl:template match="text()" mode="bookmark"/>
9633
9736
 
9737
+ <!-- figure/name -->
9634
9738
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'image']/*[local-name() = 'name']">
9635
9739
  <xsl:if test="normalize-space() != ''">
9636
9740
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -10350,6 +10454,7 @@
10350
10454
  <!-- permission -->
10351
10455
  <!-- ========== -->
10352
10456
  <xsl:template match="*[local-name() = 'permission']">
10457
+ <xsl:call-template name="setNamedDestination"/>
10353
10458
  <fo:block id="{@id}" xsl:use-attribute-sets="permission-style">
10354
10459
  <xsl:apply-templates select="*[local-name()='name']"/>
10355
10460
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -10358,10 +10463,12 @@
10358
10463
 
10359
10464
  <xsl:template match="*[local-name() = 'permission']/*[local-name() = 'name']">
10360
10465
  <xsl:if test="normalize-space() != ''">
10361
- <fo:block xsl:use-attribute-sets="permission-name-style">
10362
- <xsl:apply-templates/>
10363
10466
 
10364
- </fo:block>
10467
+ <fo:block xsl:use-attribute-sets="permission-name-style">
10468
+ <xsl:apply-templates/>
10469
+
10470
+ </fo:block>
10471
+
10365
10472
  </xsl:if>
10366
10473
  </xsl:template>
10367
10474
 
@@ -10377,6 +10484,7 @@
10377
10484
  <!-- requirement -->
10378
10485
  <!-- ========== -->
10379
10486
  <xsl:template match="*[local-name() = 'requirement']">
10487
+ <xsl:call-template name="setNamedDestination"/>
10380
10488
  <fo:block id="{@id}" xsl:use-attribute-sets="requirement-style">
10381
10489
  <xsl:apply-templates select="*[local-name()='name']"/>
10382
10490
  <xsl:apply-templates select="*[local-name()='label']"/>
@@ -10388,11 +10496,13 @@
10388
10496
 
10389
10497
  <xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'name']">
10390
10498
  <xsl:if test="normalize-space() != ''">
10391
- <fo:block xsl:use-attribute-sets="requirement-name-style">
10392
10499
 
10393
- <xsl:apply-templates/>
10500
+ <fo:block xsl:use-attribute-sets="requirement-name-style">
10501
+
10502
+ <xsl:apply-templates/>
10503
+
10504
+ </fo:block>
10394
10505
 
10395
- </fo:block>
10396
10506
  </xsl:if>
10397
10507
  </xsl:template>
10398
10508
 
@@ -10421,6 +10531,7 @@
10421
10531
  <!-- recommendation -->
10422
10532
  <!-- ========== -->
10423
10533
  <xsl:template match="*[local-name() = 'recommendation']">
10534
+ <xsl:call-template name="setNamedDestination"/>
10424
10535
  <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">
10425
10536
  <xsl:apply-templates select="*[local-name()='name']"/>
10426
10537
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -10429,10 +10540,12 @@
10429
10540
 
10430
10541
  <xsl:template match="*[local-name() = 'recommendation']/*[local-name() = 'name']">
10431
10542
  <xsl:if test="normalize-space() != ''">
10432
- <fo:block xsl:use-attribute-sets="recommendation-name-style">
10433
- <xsl:apply-templates/>
10434
10543
 
10435
- </fo:block>
10544
+ <fo:block xsl:use-attribute-sets="recommendation-name-style">
10545
+ <xsl:apply-templates/>
10546
+
10547
+ </fo:block>
10548
+
10436
10549
  </xsl:if>
10437
10550
  </xsl:template>
10438
10551
 
@@ -10511,6 +10624,7 @@
10511
10624
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
10512
10625
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
10513
10626
  </xsl:if>
10627
+ <xsl:call-template name="setNamedDestination"/>
10514
10628
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
10515
10629
  <fo:table id="{@id}" table-layout="fixed" width="100%"> <!-- border="1pt solid black" -->
10516
10630
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
@@ -10620,6 +10734,7 @@
10620
10734
  <!-- termexample -->
10621
10735
  <!-- ====== -->
10622
10736
  <xsl:template match="*[local-name() = 'termexample']">
10737
+ <xsl:call-template name="setNamedDestination"/>
10623
10738
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
10624
10739
  <xsl:call-template name="refine_termexample-style"/>
10625
10740
  <xsl:call-template name="setBlockSpanAll"/>
@@ -10674,6 +10789,7 @@
10674
10789
  -->
10675
10790
  <xsl:template match="*[local-name() = 'example']" name="example">
10676
10791
 
10792
+ <xsl:call-template name="setNamedDestination"/>
10677
10793
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style" role="SKIP">
10678
10794
 
10679
10795
  <xsl:call-template name="setBlockSpanAll"/>
@@ -11193,8 +11309,13 @@
11193
11309
  <fo:block font-size="{normalize-space($font-size)}" role="H{$levelTerm}" xsl:use-attribute-sets="preferred-block-style">
11194
11310
 
11195
11311
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'preferred'])"> <!-- if first preffered in term, then display term's name -->
11312
+
11196
11313
  <fo:block xsl:use-attribute-sets="term-name-style" role="SKIP">
11197
11314
 
11315
+ <xsl:for-each select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"><!-- change context -->
11316
+ <xsl:call-template name="setIDforNamedDestination"/>
11317
+ </xsl:for-each>
11318
+
11198
11319
  <xsl:apply-templates select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"/>
11199
11320
  </fo:block>
11200
11321
  </xsl:if>
@@ -11313,6 +11434,7 @@
11313
11434
  <!-- main sections -->
11314
11435
  <xsl:template match="/*/*[local-name() = 'sections']/*" name="sections_node" priority="2">
11315
11436
 
11437
+ <xsl:call-template name="setNamedDestination"/>
11316
11438
  <fo:block>
11317
11439
  <xsl:call-template name="setId"/>
11318
11440
 
@@ -11358,6 +11480,7 @@
11358
11480
 
11359
11481
  <fo:block break-after="page"/>
11360
11482
 
11483
+ <xsl:call-template name="setNamedDestination"/>
11361
11484
  <fo:block>
11362
11485
  <xsl:call-template name="setId"/>
11363
11486
  <xsl:call-template name="addReviewHelper"/>
@@ -11386,6 +11509,7 @@
11386
11509
  </xsl:template>
11387
11510
 
11388
11511
  <xsl:template match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty -->
11512
+ <xsl:call-template name="setNamedDestination"/>
11389
11513
  <fo:block>
11390
11514
  <xsl:if test="parent::*[local-name() = 'copyright-statement']">
11391
11515
  <xsl:attribute name="role">SKIP</xsl:attribute>
@@ -11408,6 +11532,7 @@
11408
11532
  </xsl:template> <!-- refine_clause_style -->
11409
11533
 
11410
11534
  <xsl:template match="*[local-name() = 'definitions']">
11535
+ <xsl:call-template name="setNamedDestination"/>
11411
11536
  <fo:block id="{@id}">
11412
11537
  <xsl:apply-templates/>
11413
11538
  </fo:block>
@@ -11423,6 +11548,8 @@
11423
11548
  <xsl:otherwise>
11424
11549
 
11425
11550
  <fo:block break-after="page"/>
11551
+ <xsl:call-template name="setNamedDestination"/>
11552
+
11426
11553
  <fo:block id="{@id}">
11427
11554
 
11428
11555
  <xsl:call-template name="setBlockSpanAll"/>
@@ -11494,6 +11621,7 @@
11494
11621
  <!-- following-sibling::node()[1][local-name() = 'bookmark'][@id = $source] and
11495
11622
  following-sibling::node()[2][local-name() = 'fmt-review-end'][@source = $source] -->
11496
11623
  <!-- <fo:block id="{$source}" font-size="1pt" role="SKIP"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{$source}" fox:alt-text="Annot___{$source}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block> -->
11624
+ <xsl:call-template name="setNamedDestination"/>
11497
11625
  <fo:block id="{@id}" font-size="1pt" role="SKIP" keep-with-next="always" line-height="0.1"><xsl:value-of select="$hair_space"/><fo:basic-link internal-destination="{@id}" fox:alt-text="Annot___{@id}" role="Annot"><xsl:value-of select="$hair_space"/></fo:basic-link></fo:block>
11498
11626
  <!-- </xsl:if> -->
11499
11627
  </xsl:if>
@@ -11595,9 +11723,15 @@
11595
11723
  <xsl:when test="local-name(..) = 'ul'">
11596
11724
  <xsl:choose>
11597
11725
  <xsl:when test="normalize-space($processing_instruction_type) = 'simple'"/>
11726
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
11727
+ <xsl:when test="@label"><xsl:value-of select="@label"/></xsl:when>
11598
11728
  <xsl:otherwise><xsl:call-template name="setULLabel"/></xsl:otherwise>
11599
11729
  </xsl:choose>
11600
11730
  </xsl:when>
11731
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
11732
+ <xsl:when test="local-name(..) = 'ol' and @label and @full = 'true'"> <!-- @full added in the template li/fmt-name -->
11733
+ <xsl:value-of select="@label"/>
11734
+ </xsl:when>
11601
11735
  <xsl:when test="local-name(..) = 'ol' and @label"> <!-- for ordered lists 'ol', and if there is @label, for instance label="1.1.2" -->
11602
11736
 
11603
11737
  <xsl:variable name="type" select="../@type"/>
@@ -11722,7 +11856,7 @@
11722
11856
 
11723
11857
  </xsl:otherwise>
11724
11858
  </xsl:choose>
11725
- </xsl:template>
11859
+ </xsl:template> <!-- getListItemFormat -->
11726
11860
 
11727
11861
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
11728
11862
  <xsl:param name="indent">0</xsl:param>
@@ -11854,6 +11988,11 @@
11854
11988
 
11855
11989
  <xsl:call-template name="refine_list-item-label-style"/>
11856
11990
 
11991
+ <xsl:if test="local-name(..) = 'ul'">
11992
+ <xsl:variable name="li_label" select="@label"/>
11993
+ <xsl:copy-of select="$ul_labels//label[. = $li_label]/@*[not(local-name() = 'level')]"/>
11994
+ </xsl:if>
11995
+
11857
11996
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
11858
11997
  <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
11859
11998
  <xsl:call-template name="append_add-style"/>
@@ -12200,6 +12339,7 @@
12200
12339
  <!-- Normative references -->
12201
12340
  <xsl:template match="*[local-name() = 'references'][@normative='true']" priority="2">
12202
12341
 
12342
+ <xsl:call-template name="setNamedDestination"/>
12203
12343
  <fo:block id="{@id}">
12204
12344
  <xsl:apply-templates/>
12205
12345
 
@@ -12220,6 +12360,7 @@
12220
12360
  </xsl:if>
12221
12361
  </xsl:if> -->
12222
12362
 
12363
+ <xsl:call-template name="setNamedDestination"/>
12223
12364
  <fo:block id="{@id}"/>
12224
12365
 
12225
12366
  <xsl:apply-templates select="*[local-name() = 'title'][@columns = 1]"/>
@@ -12239,6 +12380,7 @@
12239
12380
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
12240
12381
  <xsl:param name="skip" select="normalize-space(preceding-sibling::*[1][local-name() = 'bibitem'] and 1 = 1)"/> <!-- current bibiitem is non-first -->
12241
12382
 
12383
+ <xsl:call-template name="setNamedDestination"/>
12242
12384
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
12243
12385
 
12244
12386
  <xsl:call-template name="processBibitem"/>
@@ -12250,6 +12392,7 @@
12250
12392
  <xsl:template match="*[local-name() = 'references'][not(@normative='true')]/*[local-name() = 'bibitem']" name="bibitem_non_normative" priority="2">
12251
12393
  <xsl:param name="skip" select="normalize-space(preceding-sibling::*[1][local-name() = 'bibitem'] and 1 = 1)"/> <!-- current bibiitem is non-first -->
12252
12394
 
12395
+ <xsl:call-template name="setNamedDestination"/>
12253
12396
  <fo:list-block id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-style">
12254
12397
  <fo:list-item>
12255
12398
  <fo:list-item-label end-indent="label-end()">
@@ -12277,6 +12420,7 @@
12277
12420
  <xsl:choose>
12278
12421
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
12279
12422
  <xsl:otherwise>
12423
+ <xsl:call-template name="setNamedDestination"/>
12280
12424
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
12281
12425
 
12282
12426
  <fo:list-item-label end-indent="label-end()">
@@ -12671,6 +12815,7 @@
12671
12815
  <xsl:template match="*[local-name() = 'admonition']">
12672
12816
 
12673
12817
  <!-- text in the box -->
12818
+ <xsl:call-template name="setNamedDestination"/>
12674
12819
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
12675
12820
 
12676
12821
  <xsl:call-template name="setBlockSpanAll"/>
@@ -12927,7 +13072,7 @@
12927
13072
  </xsl:template>
12928
13073
 
12929
13074
  <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
12930
- <xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear' or @class = 'horizontal' or @class = 'norotate' or @class = 'halffontsize']" mode="update_xml_step1" priority="2">
13075
+ <xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear' or @class = 'fmt-hi' or @class = 'horizontal' or @class = 'norotate' or @class = 'halffontsize']" mode="update_xml_step1" priority="2">
12931
13076
  <xsl:copy>
12932
13077
  <xsl:copy-of select="@*"/>
12933
13078
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -12959,28 +13104,56 @@
12959
13104
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_step1"/>
12960
13105
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_pres"/>
12961
13106
 
12962
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_step1">
13107
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_step1">
12963
13108
  <xsl:element name="stem" namespace="{$namespace_full}">
12964
13109
  <xsl:copy-of select="@*"/>
12965
13110
  <xsl:choose>
12966
13111
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
12967
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
13112
+ <xsl:choose>
13113
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
13114
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
13115
+ </xsl:when>
13116
+ <xsl:otherwise>
13117
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_step1"/>
13118
+ </xsl:otherwise>
13119
+ </xsl:choose>
12968
13120
  </xsl:when>
12969
13121
  <xsl:otherwise>
12970
- <xsl:copy-of select="node()"/>
13122
+ <xsl:choose>
13123
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
13124
+ <xsl:copy-of select="node()"/>
13125
+ </xsl:when>
13126
+ <xsl:otherwise>
13127
+ <xsl:apply-templates select="node()" mode="update_xml_step1"/>
13128
+ </xsl:otherwise>
13129
+ </xsl:choose>
12971
13130
  </xsl:otherwise>
12972
13131
  </xsl:choose>
12973
13132
  </xsl:element>
12974
13133
  </xsl:template>
12975
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_pres">
13134
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_pres">
12976
13135
  <xsl:element name="stem" namespace="{$namespace_full}">
12977
13136
  <xsl:copy-of select="@*"/>
12978
13137
  <xsl:choose>
12979
13138
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
12980
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
13139
+ <xsl:choose>
13140
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
13141
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
13142
+ </xsl:when>
13143
+ <xsl:otherwise>
13144
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_pres"/>
13145
+ </xsl:otherwise>
13146
+ </xsl:choose>
12981
13147
  </xsl:when>
12982
13148
  <xsl:otherwise>
12983
- <xsl:copy-of select="node()"/>
13149
+ <xsl:choose>
13150
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
13151
+ <xsl:copy-of select="node()"/>
13152
+ </xsl:when>
13153
+ <xsl:otherwise>
13154
+ <xsl:apply-templates select="node()" mode="update_xml_pres"/>
13155
+ </xsl:otherwise>
13156
+ </xsl:choose>
12984
13157
  </xsl:otherwise>
12985
13158
  </xsl:choose>
12986
13159
  </xsl:element>
@@ -13209,16 +13382,24 @@
13209
13382
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_step1">
13210
13383
  <xsl:element name="title" namespace="{$namespace_full}">
13211
13384
  <xsl:copy-of select="@*"/>
13385
+ <xsl:call-template name="addNamedDestinationAttribute"/>
13386
+
13212
13387
  <xsl:apply-templates mode="update_xml_step1"/>
13213
13388
  </xsl:element>
13214
13389
  </xsl:template>
13215
13390
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_pres">
13216
13391
  <xsl:element name="title" namespace="{$namespace_full}">
13217
13392
  <xsl:copy-of select="@*"/>
13393
+ <xsl:call-template name="addNamedDestinationAttribute"/>
13394
+
13218
13395
  <xsl:apply-templates mode="update_xml_pres"/>
13219
13396
  </xsl:element>
13220
13397
  </xsl:template>
13221
13398
 
13399
+ <xsl:template name="addNamedDestinationAttribute">
13400
+
13401
+ </xsl:template>
13402
+
13222
13403
  <xsl:template match="*[local-name() = 'fmt-name']"/>
13223
13404
  <xsl:template match="*[local-name() = 'fmt-name']" mode="update_xml_step1">
13224
13405
  <xsl:choose>
@@ -13228,6 +13409,8 @@
13228
13409
  <xsl:otherwise>
13229
13410
  <xsl:element name="name" namespace="{$namespace_full}">
13230
13411
  <xsl:copy-of select="@*"/>
13412
+ <xsl:call-template name="addNamedDestinationAttribute"/>
13413
+
13231
13414
  <xsl:apply-templates mode="update_xml_step1"/>
13232
13415
  </xsl:element>
13233
13416
  </xsl:otherwise>
@@ -13241,12 +13424,24 @@
13241
13424
  <xsl:otherwise>
13242
13425
  <xsl:element name="name" namespace="{$namespace_full}">
13243
13426
  <xsl:copy-of select="@*"/>
13427
+ <xsl:call-template name="addNamedDestinationAttribute"/>
13428
+
13244
13429
  <xsl:apply-templates mode="update_xml_pres"/>
13245
13430
  </xsl:element>
13246
13431
  </xsl:otherwise>
13247
13432
  </xsl:choose>
13248
13433
  </xsl:template>
13249
13434
 
13435
+ <!-- li/fmt-name -->
13436
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_step1">
13437
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
13438
+ <xsl:attribute name="full">true</xsl:attribute>
13439
+ </xsl:template>
13440
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_pres">
13441
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
13442
+ <xsl:attribute name="full">true</xsl:attribute>
13443
+ </xsl:template>
13444
+
13250
13445
  <xsl:template match="*[local-name() = 'fmt-preferred']"/>
13251
13446
  <xsl:template match="*[local-name() = 'fmt-preferred'][*[local-name() = 'p']]" mode="update_xml_step1">
13252
13447
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -14061,6 +14256,64 @@
14061
14256
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
14062
14257
  </xsl:template>
14063
14258
 
14259
+ <!-- ===================================== -->
14260
+ <!-- ===================================== -->
14261
+ <!-- Ruby text (CJK languages) rendering -->
14262
+ <!-- ===================================== -->
14263
+ <!-- ===================================== -->
14264
+ <xsl:template match="*[local-name() = 'ruby']">
14265
+ <fo:inline-container text-indent="0mm" last-line-end-indent="0mm">
14266
+ <xsl:if test="not(ancestor::*[local-name() = 'ruby'])">
14267
+ <xsl:attribute name="alignment-baseline">central</xsl:attribute>
14268
+ </xsl:if>
14269
+ <xsl:variable name="rt_text" select="*[local-name() = 'rt']"/>
14270
+ <xsl:variable name="rb_text" select=".//*[local-name() = 'rb'][not(*[local-name() = 'ruby'])]"/>
14271
+ <!-- Example: width="2em" -->
14272
+ <xsl:variable name="text_rt_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rt_text, $font_main, 6)"/>
14273
+ <xsl:variable name="text_rb_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rb_text, $font_main, 10)"/>
14274
+ <xsl:variable name="text_width">
14275
+ <xsl:choose>
14276
+ <xsl:when test="$text_rt_width &gt;= $text_rb_width"><xsl:value-of select="$text_rt_width"/></xsl:when>
14277
+ <xsl:otherwise><xsl:value-of select="$text_rb_width"/></xsl:otherwise>
14278
+ </xsl:choose>
14279
+ </xsl:variable>
14280
+ <xsl:attribute name="width"><xsl:value-of select="$text_width div 10"/>em</xsl:attribute>
14281
+
14282
+ <xsl:choose>
14283
+ <xsl:when test="ancestor::*[local-name() = 'ruby']">
14284
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
14285
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
14286
+ </xsl:when>
14287
+ <xsl:otherwise>
14288
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
14289
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
14290
+ </xsl:otherwise>
14291
+ </xsl:choose>
14292
+
14293
+ <xsl:apply-templates select="node()[not(local-name() = 'rt') and not(local-name() = 'rb')]"/>
14294
+ </fo:inline-container>
14295
+ </xsl:template>
14296
+
14297
+ <xsl:template match="*[local-name() = 'rb']">
14298
+ <fo:block line-height="1em" text-align="center"><xsl:apply-templates/></fo:block>
14299
+ </xsl:template>
14300
+
14301
+ <xsl:template match="*[local-name() = 'rt']">
14302
+ <fo:block font-size="0.5em" text-align="center" line-height="1.2em" space-before="-1.4em" space-before.conditionality="retain"> <!-- -->
14303
+ <xsl:if test="ancestor::*[local-name() = 'ruby'][last()]//*[local-name() = 'ruby'] or ancestor::*[local-name() = 'rb']">
14304
+ <xsl:attribute name="space-before">0em</xsl:attribute>
14305
+ </xsl:if>
14306
+ <xsl:apply-templates/>
14307
+ </fo:block>
14308
+
14309
+ </xsl:template>
14310
+
14311
+ <!-- ===================================== -->
14312
+ <!-- ===================================== -->
14313
+ <!-- END: Ruby text (CJK languages) rendering -->
14314
+ <!-- ===================================== -->
14315
+ <!-- ===================================== -->
14316
+
14064
14317
  <xsl:template name="printEdition">
14065
14318
  <xsl:variable name="edition_i18n" select="normalize-space((//*[local-name() = 'metanorma'])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
14066
14319
 
@@ -14630,6 +14883,24 @@
14630
14883
  </xsl:attribute>
14631
14884
  </xsl:template>
14632
14885
 
14886
+ <xsl:template name="setIDforNamedDestination">
14887
+ <xsl:if test="@named_dest">
14888
+ <xsl:attribute name="id"><xsl:value-of select="@named_dest"/></xsl:attribute>
14889
+ </xsl:if>
14890
+ </xsl:template>
14891
+
14892
+ <xsl:template name="setNamedDestination">
14893
+ <!-- skip GUID, e.g. _33eac3cb-9663-4291-ae26-1d4b6f4635fc -->
14894
+ <xsl:if test="@id and normalize-space(java:matches(java:java.lang.String.new(@id), '_[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}')) = 'false'">
14895
+ <fox:destination internal-destination="{@id}"/>
14896
+ </xsl:if>
14897
+ <xsl:for-each select=". | *[local-name() = 'title'] | *[local-name() = 'name']">
14898
+ <xsl:if test="@named_dest">
14899
+ <fox:destination internal-destination="{@named_dest}"/>
14900
+ </xsl:if>
14901
+ </xsl:for-each>
14902
+ </xsl:template>
14903
+
14633
14904
  <xsl:template name="add-letter-spacing">
14634
14905
  <xsl:param name="text"/>
14635
14906
  <xsl:param name="letter-spacing" select="'0.15'"/>