metanorma-cc 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.
@@ -1340,6 +1340,7 @@
1340
1340
  </xsl:template> <!-- refine_table-style -->
1341
1341
 
1342
1342
  <xsl:attribute-set name="table-name-style">
1343
+ <xsl:attribute name="role">Caption</xsl:attribute>
1343
1344
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1344
1345
 
1345
1346
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -1350,6 +1351,9 @@
1350
1351
 
1351
1352
  <xsl:template name="refine_table-name-style">
1352
1353
  <xsl:param name="continued"/>
1354
+ <xsl:if test="$continued = 'true'">
1355
+ <xsl:attribute name="role">SKIP</xsl:attribute>
1356
+ </xsl:if>
1353
1357
 
1354
1358
  </xsl:template> <!-- refine_table-name-style -->
1355
1359
 
@@ -2936,8 +2940,14 @@
2936
2940
  </xsl:choose>
2937
2941
  </xsl:variable>
2938
2942
 
2943
+ <xsl:call-template name="setNamedDestination"/>
2944
+
2939
2945
  <fo:block-container xsl:use-attribute-sets="table-container-style" role="SKIP">
2940
2946
 
2947
+ <xsl:for-each select="*[local-name() = 'name']">
2948
+ <xsl:call-template name="setIDforNamedDestination"/>
2949
+ </xsl:for-each>
2950
+
2941
2951
  <xsl:call-template name="refine_table-container-style">
2942
2952
  <xsl:with-param name="margin-side" select="$margin-side"/>
2943
2953
  </xsl:call-template>
@@ -3081,7 +3091,7 @@
3081
3091
  </xsl:if>
3082
3092
 
3083
3093
  </fo:block-container>
3084
- </xsl:variable>
3094
+ </xsl:variable> <!-- END: variable name="table" -->
3085
3095
 
3086
3096
  <xsl:variable name="isAdded" select="@added"/>
3087
3097
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -3091,14 +3101,14 @@
3091
3101
 
3092
3102
  <!-- centered table when table name is centered (see table-name-style) -->
3093
3103
 
3094
- <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
3104
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style" role="SKIP">
3095
3105
 
3096
3106
  <fo:table-column column-width="proportional-column-width(1)"/>
3097
3107
  <fo:table-column column-width="{@width}"/>
3098
3108
  <fo:table-column column-width="proportional-column-width(1)"/>
3099
- <fo:table-body>
3100
- <fo:table-row>
3101
- <fo:table-cell column-number="2">
3109
+ <fo:table-body role="SKIP">
3110
+ <fo:table-row role="SKIP">
3111
+ <fo:table-cell column-number="2" role="SKIP">
3102
3112
  <xsl:copy-of select="$table-preamble"/>
3103
3113
  <fo:block role="SKIP">
3104
3114
  <xsl:call-template name="setTrackChangesStyles">
@@ -3139,11 +3149,13 @@
3139
3149
 
3140
3150
  </xsl:template>
3141
3151
 
3152
+ <!-- table/name-->
3142
3153
  <xsl:template match="*[local-name()='table']/*[local-name() = 'name']">
3143
3154
  <xsl:param name="continued"/>
3155
+ <xsl:param name="cols-count"/>
3144
3156
  <xsl:if test="normalize-space() != ''">
3145
3157
 
3146
- <fo:block xsl:use-attribute-sets="table-name-style" role="SKIP">
3158
+ <fo:block xsl:use-attribute-sets="table-name-style">
3147
3159
 
3148
3160
  <xsl:call-template name="refine_table-name-style">
3149
3161
  <xsl:with-param name="continued" select="$continued"/>
@@ -3162,9 +3174,30 @@
3162
3174
 
3163
3175
  <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
3164
3176
  <xsl:if test="$continued = 'true'">
3165
- <fo:block text-align="right">
3166
- <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3167
- </fo:block>
3177
+
3178
+ <!-- to prevent the error 'THead element may contain only TR elements' -->
3179
+
3180
+ <xsl:choose>
3181
+ <xsl:when test="string(number($cols-count)) != 'NaN'">
3182
+ <fo:table width="100%" table-layout="fixed" role="SKIP">
3183
+ <fo:table-body role="SKIP">
3184
+ <fo:table-row>
3185
+ <fo:table-cell role="TH" number-columns-spanned="{$cols-count}">
3186
+ <fo:block text-align="right" role="SKIP">
3187
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3188
+ </fo:block>
3189
+ </fo:table-cell>
3190
+ </fo:table-row>
3191
+ </fo:table-body>
3192
+ </fo:table>
3193
+ </xsl:when>
3194
+ <xsl:otherwise>
3195
+ <fo:block text-align="right">
3196
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3197
+ </fo:block>
3198
+ </xsl:otherwise>
3199
+ </xsl:choose>
3200
+
3168
3201
  </xsl:if>
3169
3202
  <!-- </xsl:if> -->
3170
3203
 
@@ -3557,6 +3590,7 @@
3557
3590
 
3558
3591
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
3559
3592
  <xsl:with-param name="continued">true</xsl:with-param>
3593
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3560
3594
  </xsl:apply-templates>
3561
3595
 
3562
3596
  <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
@@ -3620,7 +3654,7 @@
3620
3654
 
3621
3655
  <xsl:variable name="tableWithNotesAndFootnotes">
3622
3656
 
3623
- <fo:table keep-with-previous="always">
3657
+ <fo:table keep-with-previous="always" role="SKIP">
3624
3658
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
3625
3659
  <xsl:variable name="name" select="local-name()"/>
3626
3660
  <xsl:choose>
@@ -3651,9 +3685,9 @@
3651
3685
  </xsl:otherwise>
3652
3686
  </xsl:choose>
3653
3687
 
3654
- <fo:table-body>
3655
- <fo:table-row>
3656
- <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}">
3688
+ <fo:table-body role="SKIP">
3689
+ <fo:table-row role="SKIP">
3690
+ <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}" role="SKIP">
3657
3691
 
3658
3692
  <xsl:call-template name="refine_table-footer-cell-style"/>
3659
3693
 
@@ -3938,8 +3972,8 @@
3938
3972
  <xsl:for-each select="xalan:nodeset($styles__)/item">
3939
3973
  <xsl:variable name="key" select="normalize-space(substring-before(., ':'))"/>
3940
3974
  <xsl:variable name="value" select="normalize-space(substring-after(translate(.,$quot,''), ':'))"/>
3941
- <xsl:if test="$key = 'color' or $key = 'background-color'">
3942
- <style name="{$key}"><xsl:value-of select="$value"/></style>
3975
+ <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'">
3976
+ <style name="{$key}"><xsl:value-of select="java:replaceAll(java:java.lang.String.new($value), 'currentColor', 'inherit')"/></style>
3943
3977
  </xsl:if>
3944
3978
  </xsl:for-each>
3945
3979
  </xsl:variable>
@@ -4003,6 +4037,7 @@
4003
4037
  <!-- table/note, table/example, table/tfoot//note, table/tfoot//example -->
4004
4038
  <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">
4005
4039
 
4040
+ <xsl:call-template name="setNamedDestination"/>
4006
4041
  <fo:block xsl:use-attribute-sets="table-note-style">
4007
4042
  <xsl:copy-of select="@id"/>
4008
4043
 
@@ -4050,6 +4085,7 @@
4050
4085
  <!-- footnotes in text (title, bibliography, main body), not for tables, figures and names --> <!-- table's, figure's names -->
4051
4086
  <!-- fn in text -->
4052
4087
  <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">
4088
+ <xsl:param name="footnote_body_from_table">false</xsl:param>
4053
4089
 
4054
4090
  <!-- list of unique footnotes -->
4055
4091
  <xsl:variable name="p_fn_">
@@ -4115,7 +4151,7 @@
4115
4151
  <xsl:copy-of select="$footnote_inline"/>
4116
4152
  </xsl:when>
4117
4153
  <!-- <xsl:when test="$footnotes//*[local-name() = 'fmt-fn-body'][@id = $ref_id] or normalize-space(@skip_footnote_body) = 'false'"> -->
4118
- <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
4154
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false' or $footnote_body_from_table = 'true'">
4119
4155
 
4120
4156
  <fo:footnote xsl:use-attribute-sets="fn-style" role="SKIP">
4121
4157
  <xsl:copy-of select="$footnote_inline"/>
@@ -4524,39 +4560,51 @@
4524
4560
  <!-- fn reference in the table rendering (for instance, 'some text 1) some text' ) -->
4525
4561
  <!-- fn --> <!-- in table --> <!-- for figure see <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/> -->
4526
4562
  <xsl:template match="*[local-name()='fn']">
4527
- <fo:inline xsl:use-attribute-sets="fn-reference-style">
4528
-
4529
- <xsl:call-template name="refine_fn-reference-style"/>
4563
+ <xsl:variable name="target" select="@target"/>
4564
+ <xsl:choose>
4565
+ <!-- case for footnotes in Requirement tables (https://github.com/metanorma/metanorma-ogc/issues/791) -->
4566
+ <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]">
4567
+ <xsl:call-template name="fn">
4568
+ <xsl:with-param name="footnote_body_from_table">true</xsl:with-param>
4569
+ </xsl:call-template>
4570
+ </xsl:when>
4571
+ <xsl:otherwise>
4530
4572
 
4531
- <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
4532
- <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
4533
- <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
4534
- <!-- <xsl:attribute name="internal-destination">
4535
- <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
4536
- </xsl:attribute>
4537
- </xsl:if>
4538
- <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
4539
- <xsl:attribute name="internal-destination">
4540
- <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
4541
- <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
4542
- </xsl:attribute>
4543
- </xsl:if> -->
4544
- <!-- <xsl:if test="$namespace = 'plateau'">
4545
- <xsl:text>※</xsl:text>
4546
- </xsl:if> -->
4547
- <!-- <xsl:value-of select="@reference"/> -->
4573
+ <fo:inline xsl:use-attribute-sets="fn-reference-style">
4548
4574
 
4549
- <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
4575
+ <xsl:call-template name="refine_fn-reference-style"/>
4550
4576
 
4551
- <!-- <xsl:if test="$namespace = 'bsi'">
4552
- <xsl:text>)</xsl:text>
4553
- </xsl:if> -->
4554
- <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
4555
- <!-- <xsl:if test="$namespace = 'jis'">
4556
- <fo:inline font-weight="normal">)</fo:inline>
4557
- </xsl:if> -->
4558
- </fo:basic-link>
4559
- </fo:inline>
4577
+ <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
4578
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
4579
+ <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
4580
+ <!-- <xsl:attribute name="internal-destination">
4581
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
4582
+ </xsl:attribute>
4583
+ </xsl:if>
4584
+ <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
4585
+ <xsl:attribute name="internal-destination">
4586
+ <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
4587
+ <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
4588
+ </xsl:attribute>
4589
+ </xsl:if> -->
4590
+ <!-- <xsl:if test="$namespace = 'plateau'">
4591
+ <xsl:text>※</xsl:text>
4592
+ </xsl:if> -->
4593
+ <!-- <xsl:value-of select="@reference"/> -->
4594
+
4595
+ <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
4596
+
4597
+ <!-- <xsl:if test="$namespace = 'bsi'">
4598
+ <xsl:text>)</xsl:text>
4599
+ </xsl:if> -->
4600
+ <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
4601
+ <!-- <xsl:if test="$namespace = 'jis'">
4602
+ <fo:inline font-weight="normal">)</fo:inline>
4603
+ </xsl:if> -->
4604
+ </fo:basic-link>
4605
+ </fo:inline>
4606
+ </xsl:otherwise>
4607
+ </xsl:choose>
4560
4608
  </xsl:template> <!-- fn -->
4561
4609
 
4562
4610
  <!-- fn/text() -->
@@ -4611,6 +4659,10 @@
4611
4659
  <!-- <dl><xsl:copy-of select="."/></dl> -->
4612
4660
  <fo:block-container xsl:use-attribute-sets="dl-block-style" role="SKIP">
4613
4661
 
4662
+ <xsl:if test="@key = 'true' and ancestor::*[local-name() = 'figure']">
4663
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
4664
+ </xsl:if>
4665
+
4614
4666
  <xsl:call-template name="setBlockSpanAll"/>
4615
4667
 
4616
4668
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
@@ -4904,7 +4956,7 @@
4904
4956
 
4905
4957
  <!-- caption for figure key and another caption, https://github.com/metanorma/isodoc/issues/607 -->
4906
4958
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'p'][@keep-with-next = 'true' and *[local-name() = 'strong']]" priority="3">
4907
- <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always">
4959
+ <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always" keep-with-previous="always">
4908
4960
  <xsl:call-template name="refine_figure_key_style"/>
4909
4961
  <xsl:apply-templates/>
4910
4962
  </fo:block>
@@ -5155,6 +5207,7 @@
5155
5207
 
5156
5208
  <xsl:call-template name="refine_dt-cell-style"/>
5157
5209
 
5210
+ <xsl:call-template name="setNamedDestination"/>
5158
5211
  <fo:block xsl:use-attribute-sets="dt-block-style" role="SKIP">
5159
5212
 
5160
5213
  <xsl:choose>
@@ -5592,7 +5645,7 @@
5592
5645
  <!-- ================= -->
5593
5646
 
5594
5647
  <!-- highlight text -->
5595
- <xsl:template match="*[local-name()='hi']">
5648
+ <xsl:template match="*[local-name()='hi'] | *[local-name() = 'span'][@class = 'fmt-hi']" priority="3">
5596
5649
  <fo:inline background-color="yellow">
5597
5650
  <xsl:apply-templates/>
5598
5651
  </fo:inline>
@@ -7187,6 +7240,7 @@
7187
7240
  <!-- Appendix processing -->
7188
7241
  <!-- ======================== -->
7189
7242
  <xsl:template match="*[local-name()='appendix']">
7243
+ <xsl:call-template name="setNamedDestination"/>
7190
7244
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-style">
7191
7245
  <xsl:apply-templates select="*[local-name()='title']"/>
7192
7246
  </fo:block>
@@ -7197,13 +7251,14 @@
7197
7251
  <xsl:variable name="level">
7198
7252
  <xsl:call-template name="getLevel"/>
7199
7253
  </xsl:variable>
7200
- <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
7254
+ <fo:inline role="H{$level}"><xsl:call-template name="setIDforNamedDestination"/><xsl:apply-templates/></fo:inline>
7201
7255
  </xsl:template>
7202
7256
  <!-- ======================== -->
7203
7257
  <!-- END Appendix processing -->
7204
7258
  <!-- ======================== -->
7205
7259
 
7206
7260
  <xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
7261
+ <xsl:call-template name="setNamedDestination"/>
7207
7262
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
7208
7263
  <xsl:apply-templates select="*[local-name()='name']"/>
7209
7264
  </fo:block>
@@ -7233,6 +7288,7 @@
7233
7288
  <xsl:template match="*[local-name() = 'annotation']/*[local-name() = 'p']">
7234
7289
  <xsl:param name="callout"/>
7235
7290
  <fo:inline id="{@id}">
7291
+ <xsl:call-template name="setNamedDestination"/>
7236
7292
  <!-- for first p in annotation, put <x> -->
7237
7293
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
7238
7294
  <xsl:apply-templates/>
@@ -7279,6 +7335,7 @@
7279
7335
 
7280
7336
  </xsl:if>
7281
7337
  <fo:block-container margin-left="0mm" role="SKIP">
7338
+ <xsl:call-template name="setNamedDestination"/>
7282
7339
  <fo:block id="{@id}">
7283
7340
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/> <!-- formula's number will be process in 'stem' template -->
7284
7341
  </fo:block>
@@ -7324,8 +7381,13 @@
7324
7381
  </fo:block>
7325
7382
  </fo:table-cell>
7326
7383
  <fo:table-cell display-align="center">
7384
+
7327
7385
  <fo:block xsl:use-attribute-sets="formula-stem-number-style" role="SKIP">
7328
7386
 
7387
+ <xsl:for-each select="../*[local-name() = 'name']">
7388
+ <xsl:call-template name="setIDforNamedDestination"/>
7389
+ </xsl:for-each>
7390
+
7329
7391
  <xsl:call-template name="refine_formula-stem-number-style"/>
7330
7392
 
7331
7393
  <xsl:apply-templates select="../*[local-name() = 'name']"/>
@@ -7360,6 +7422,8 @@
7360
7422
 
7361
7423
  <xsl:template match="*[local-name() = 'note']" name="note">
7362
7424
 
7425
+ <xsl:call-template name="setNamedDestination"/>
7426
+
7363
7427
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style" role="SKIP">
7364
7428
 
7365
7429
  <xsl:call-template name="setBlockSpanAll"/>
@@ -7424,6 +7488,7 @@
7424
7488
  </xsl:template>
7425
7489
 
7426
7490
  <xsl:template match="*[local-name() = 'termnote']">
7491
+ <xsl:call-template name="setNamedDestination"/>
7427
7492
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
7428
7493
 
7429
7494
  <xsl:call-template name="setBlockSpanAll"/>
@@ -7530,12 +7595,14 @@
7530
7595
 
7531
7596
  <xsl:template match="*[local-name() = 'terms']">
7532
7597
  <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
7598
+ <xsl:call-template name="setNamedDestination"/>
7533
7599
  <fo:block id="{@id}">
7534
7600
  <xsl:apply-templates/>
7535
7601
  </fo:block>
7536
7602
  </xsl:template>
7537
7603
 
7538
7604
  <xsl:template match="*[local-name() = 'term']">
7605
+ <xsl:call-template name="setNamedDestination"/>
7539
7606
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
7540
7607
 
7541
7608
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'term'])">
@@ -7567,6 +7634,7 @@
7567
7634
  <xsl:template match="*[local-name() = 'figure']" name="figure">
7568
7635
  <xsl:variable name="isAdded" select="@added"/>
7569
7636
  <xsl:variable name="isDeleted" select="@deleted"/>
7637
+ <xsl:call-template name="setNamedDestination"/>
7570
7638
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
7571
7639
  <xsl:call-template name="refine_figure-block-style"/>
7572
7640
 
@@ -7583,6 +7651,11 @@
7583
7651
  </xsl:variable>
7584
7652
 
7585
7653
  <fo:block xsl:use-attribute-sets="figure-style" role="SKIP">
7654
+
7655
+ <xsl:for-each select="*[local-name() = 'name']"> <!-- set context -->
7656
+ <xsl:call-template name="setIDforNamedDestination"/>
7657
+ </xsl:for-each>
7658
+
7586
7659
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
7587
7660
  </fo:block>
7588
7661
 
@@ -7615,6 +7688,7 @@
7615
7688
  </xsl:template>
7616
7689
 
7617
7690
  <xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']">
7691
+ <xsl:call-template name="setNamedDestination"/>
7618
7692
  <fo:block id="{@id}">
7619
7693
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7620
7694
  </fo:block>
@@ -7628,6 +7702,7 @@
7628
7702
  </xsl:template>
7629
7703
 
7630
7704
  <!-- SOURCE: ... -->
7705
+ <!-- figure/source -->
7631
7706
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
7632
7707
 
7633
7708
  <xsl:call-template name="termsource"/>
@@ -8553,6 +8628,13 @@
8553
8628
  <xsl:apply-templates select="."/>
8554
8629
  </xsl:template>
8555
8630
 
8631
+ <!-- prevent missing stem for table and figures in ToC -->
8632
+ <xsl:template match="*[local-name() = 'name' or local-name() = 'fmt-name']//*[local-name() = 'stem']" mode="contents">
8633
+ <xsl:if test="not(following-sibling::*[1][local-name() = 'fmt-stem'])">
8634
+ <xsl:apply-templates select="."/>
8635
+ </xsl:if>
8636
+ </xsl:template>
8637
+
8556
8638
  <xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/>
8557
8639
 
8558
8640
  <xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/>
@@ -8776,7 +8858,8 @@
8776
8858
 
8777
8859
  <xsl:for-each select="$contents_nodes//tables/table">
8778
8860
  <fo:bookmark internal-destination="{@id}">
8779
- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
8861
+ <!-- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title> -->
8862
+ <fo:bookmark-title><xsl:apply-templates mode="bookmark_clean"/></fo:bookmark-title>
8780
8863
  </fo:bookmark>
8781
8864
  </xsl:for-each>
8782
8865
  </fo:bookmark>
@@ -8785,6 +8868,26 @@
8785
8868
  </xsl:template> <!-- insertTableBookmarks -->
8786
8869
  <!-- End Bookmarks -->
8787
8870
 
8871
+ <!-- ============================ -->
8872
+ <!-- mode="bookmark_clean" -->
8873
+ <!-- ============================ -->
8874
+ <xsl:template match="node()" mode="bookmark_clean">
8875
+ <xsl:apply-templates select="node()" mode="bookmark_clean"/>
8876
+ </xsl:template>
8877
+
8878
+ <xsl:template match="text()" mode="bookmark_clean">
8879
+ <xsl:value-of select="."/>
8880
+ </xsl:template>
8881
+
8882
+ <xsl:template match="*[local-name() = 'math']" mode="bookmark_clean">
8883
+ <xsl:value-of select="normalize-space(.)"/>
8884
+ </xsl:template>
8885
+
8886
+ <xsl:template match="*[local-name() = 'asciimath']" mode="bookmark_clean"/>
8887
+ <!-- ============================ -->
8888
+ <!-- END: mode="bookmark_clean" -->
8889
+ <!-- ============================ -->
8890
+
8788
8891
  <xsl:template name="getLangVersion">
8789
8892
  <xsl:param name="lang"/>
8790
8893
  <xsl:param name="doctype" select="''"/>
@@ -8832,6 +8935,7 @@
8832
8935
  <xsl:template match="title" mode="bookmark"/>
8833
8936
  <xsl:template match="text()" mode="bookmark"/>
8834
8937
 
8938
+ <!-- figure/name -->
8835
8939
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'image']/*[local-name() = 'name']">
8836
8940
  <xsl:if test="normalize-space() != ''">
8837
8941
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -9549,6 +9653,7 @@
9549
9653
  <!-- permission -->
9550
9654
  <!-- ========== -->
9551
9655
  <xsl:template match="*[local-name() = 'permission']">
9656
+ <xsl:call-template name="setNamedDestination"/>
9552
9657
  <fo:block id="{@id}" xsl:use-attribute-sets="permission-style">
9553
9658
  <xsl:apply-templates select="*[local-name()='name']"/>
9554
9659
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -9557,10 +9662,12 @@
9557
9662
 
9558
9663
  <xsl:template match="*[local-name() = 'permission']/*[local-name() = 'name']">
9559
9664
  <xsl:if test="normalize-space() != ''">
9560
- <fo:block xsl:use-attribute-sets="permission-name-style">
9561
- <xsl:apply-templates/>
9562
9665
 
9563
- </fo:block>
9666
+ <fo:block xsl:use-attribute-sets="permission-name-style">
9667
+ <xsl:apply-templates/>
9668
+
9669
+ </fo:block>
9670
+
9564
9671
  </xsl:if>
9565
9672
  </xsl:template>
9566
9673
 
@@ -9576,6 +9683,7 @@
9576
9683
  <!-- requirement -->
9577
9684
  <!-- ========== -->
9578
9685
  <xsl:template match="*[local-name() = 'requirement']">
9686
+ <xsl:call-template name="setNamedDestination"/>
9579
9687
  <fo:block id="{@id}" xsl:use-attribute-sets="requirement-style">
9580
9688
  <xsl:apply-templates select="*[local-name()='name']"/>
9581
9689
  <xsl:apply-templates select="*[local-name()='label']"/>
@@ -9587,11 +9695,13 @@
9587
9695
 
9588
9696
  <xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'name']">
9589
9697
  <xsl:if test="normalize-space() != ''">
9590
- <fo:block xsl:use-attribute-sets="requirement-name-style">
9591
9698
 
9592
- <xsl:apply-templates/>
9699
+ <fo:block xsl:use-attribute-sets="requirement-name-style">
9700
+
9701
+ <xsl:apply-templates/>
9702
+
9703
+ </fo:block>
9593
9704
 
9594
- </fo:block>
9595
9705
  </xsl:if>
9596
9706
  </xsl:template>
9597
9707
 
@@ -9620,6 +9730,7 @@
9620
9730
  <!-- recommendation -->
9621
9731
  <!-- ========== -->
9622
9732
  <xsl:template match="*[local-name() = 'recommendation']">
9733
+ <xsl:call-template name="setNamedDestination"/>
9623
9734
  <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">
9624
9735
  <xsl:apply-templates select="*[local-name()='name']"/>
9625
9736
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -9628,10 +9739,12 @@
9628
9739
 
9629
9740
  <xsl:template match="*[local-name() = 'recommendation']/*[local-name() = 'name']">
9630
9741
  <xsl:if test="normalize-space() != ''">
9631
- <fo:block xsl:use-attribute-sets="recommendation-name-style">
9632
- <xsl:apply-templates/>
9633
9742
 
9634
- </fo:block>
9743
+ <fo:block xsl:use-attribute-sets="recommendation-name-style">
9744
+ <xsl:apply-templates/>
9745
+
9746
+ </fo:block>
9747
+
9635
9748
  </xsl:if>
9636
9749
  </xsl:template>
9637
9750
 
@@ -9710,6 +9823,7 @@
9710
9823
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
9711
9824
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
9712
9825
  </xsl:if>
9826
+ <xsl:call-template name="setNamedDestination"/>
9713
9827
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
9714
9828
  <fo:table id="{@id}" table-layout="fixed" width="100%"> <!-- border="1pt solid black" -->
9715
9829
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
@@ -9819,6 +9933,7 @@
9819
9933
  <!-- termexample -->
9820
9934
  <!-- ====== -->
9821
9935
  <xsl:template match="*[local-name() = 'termexample']">
9936
+ <xsl:call-template name="setNamedDestination"/>
9822
9937
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
9823
9938
  <xsl:call-template name="refine_termexample-style"/>
9824
9939
  <xsl:call-template name="setBlockSpanAll"/>
@@ -9873,6 +9988,7 @@
9873
9988
  -->
9874
9989
  <xsl:template match="*[local-name() = 'example']" name="example">
9875
9990
 
9991
+ <xsl:call-template name="setNamedDestination"/>
9876
9992
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style" role="SKIP">
9877
9993
 
9878
9994
  <xsl:call-template name="setBlockSpanAll"/>
@@ -10398,8 +10514,13 @@
10398
10514
  <fo:block font-size="{normalize-space($font-size)}" role="H{$levelTerm}" xsl:use-attribute-sets="preferred-block-style">
10399
10515
 
10400
10516
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'preferred'])"> <!-- if first preffered in term, then display term's name -->
10517
+
10401
10518
  <fo:block xsl:use-attribute-sets="term-name-style" role="SKIP">
10402
10519
 
10520
+ <xsl:for-each select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"><!-- change context -->
10521
+ <xsl:call-template name="setIDforNamedDestination"/>
10522
+ </xsl:for-each>
10523
+
10403
10524
  <xsl:apply-templates select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"/>
10404
10525
  </fo:block>
10405
10526
  </xsl:if>
@@ -10519,6 +10640,7 @@
10519
10640
  <!-- main sections -->
10520
10641
  <xsl:template match="/*/*[local-name() = 'sections']/*" name="sections_node" priority="2">
10521
10642
 
10643
+ <xsl:call-template name="setNamedDestination"/>
10522
10644
  <fo:block>
10523
10645
  <xsl:call-template name="setId"/>
10524
10646
 
@@ -10564,6 +10686,7 @@
10564
10686
 
10565
10687
  <fo:block break-after="page"/>
10566
10688
 
10689
+ <xsl:call-template name="setNamedDestination"/>
10567
10690
  <fo:block>
10568
10691
  <xsl:call-template name="setId"/>
10569
10692
  <xsl:call-template name="addReviewHelper"/>
@@ -10592,6 +10715,7 @@
10592
10715
  </xsl:template>
10593
10716
 
10594
10717
  <xsl:template match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty -->
10718
+ <xsl:call-template name="setNamedDestination"/>
10595
10719
  <fo:block>
10596
10720
  <xsl:if test="parent::*[local-name() = 'copyright-statement']">
10597
10721
  <xsl:attribute name="role">SKIP</xsl:attribute>
@@ -10614,6 +10738,7 @@
10614
10738
  </xsl:template> <!-- refine_clause_style -->
10615
10739
 
10616
10740
  <xsl:template match="*[local-name() = 'definitions']">
10741
+ <xsl:call-template name="setNamedDestination"/>
10617
10742
  <fo:block id="{@id}">
10618
10743
  <xsl:apply-templates/>
10619
10744
  </fo:block>
@@ -10629,6 +10754,8 @@
10629
10754
  <xsl:otherwise>
10630
10755
 
10631
10756
  <fo:block break-after="page"/>
10757
+ <xsl:call-template name="setNamedDestination"/>
10758
+
10632
10759
  <fo:block id="{@id}">
10633
10760
 
10634
10761
  <xsl:call-template name="setBlockSpanAll"/>
@@ -10700,6 +10827,7 @@
10700
10827
  <!-- following-sibling::node()[1][local-name() = 'bookmark'][@id = $source] and
10701
10828
  following-sibling::node()[2][local-name() = 'fmt-review-end'][@source = $source] -->
10702
10829
  <!-- <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> -->
10830
+ <xsl:call-template name="setNamedDestination"/>
10703
10831
  <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>
10704
10832
  <!-- </xsl:if> -->
10705
10833
  </xsl:if>
@@ -10799,9 +10927,15 @@
10799
10927
  <xsl:when test="local-name(..) = 'ul'">
10800
10928
  <xsl:choose>
10801
10929
  <xsl:when test="normalize-space($processing_instruction_type) = 'simple'"/>
10930
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
10931
+ <xsl:when test="@label"><xsl:value-of select="@label"/></xsl:when>
10802
10932
  <xsl:otherwise><xsl:call-template name="setULLabel"/></xsl:otherwise>
10803
10933
  </xsl:choose>
10804
10934
  </xsl:when>
10935
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
10936
+ <xsl:when test="local-name(..) = 'ol' and @label and @full = 'true'"> <!-- @full added in the template li/fmt-name -->
10937
+ <xsl:value-of select="@label"/>
10938
+ </xsl:when>
10805
10939
  <xsl:when test="local-name(..) = 'ol' and @label"> <!-- for ordered lists 'ol', and if there is @label, for instance label="1.1.2" -->
10806
10940
 
10807
10941
  <xsl:variable name="type" select="../@type"/>
@@ -10926,7 +11060,7 @@
10926
11060
 
10927
11061
  </xsl:otherwise>
10928
11062
  </xsl:choose>
10929
- </xsl:template>
11063
+ </xsl:template> <!-- getListItemFormat -->
10930
11064
 
10931
11065
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
10932
11066
  <xsl:param name="indent">0</xsl:param>
@@ -11058,6 +11192,11 @@
11058
11192
 
11059
11193
  <xsl:call-template name="refine_list-item-label-style"/>
11060
11194
 
11195
+ <xsl:if test="local-name(..) = 'ul'">
11196
+ <xsl:variable name="li_label" select="@label"/>
11197
+ <xsl:copy-of select="$ul_labels//label[. = $li_label]/@*[not(local-name() = 'level')]"/>
11198
+ </xsl:if>
11199
+
11061
11200
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
11062
11201
  <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
11063
11202
  <xsl:call-template name="append_add-style"/>
@@ -11404,6 +11543,7 @@
11404
11543
  <!-- Normative references -->
11405
11544
  <xsl:template match="*[local-name() = 'references'][@normative='true']" priority="2">
11406
11545
 
11546
+ <xsl:call-template name="setNamedDestination"/>
11407
11547
  <fo:block id="{@id}">
11408
11548
  <xsl:apply-templates/>
11409
11549
 
@@ -11424,6 +11564,7 @@
11424
11564
  </xsl:if>
11425
11565
  </xsl:if> -->
11426
11566
 
11567
+ <xsl:call-template name="setNamedDestination"/>
11427
11568
  <fo:block id="{@id}"/>
11428
11569
 
11429
11570
  <xsl:apply-templates select="*[local-name() = 'title'][@columns = 1]"/>
@@ -11443,6 +11584,7 @@
11443
11584
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
11444
11585
  <xsl:param name="skip" select="normalize-space(preceding-sibling::*[1][local-name() = 'bibitem'] and 1 = 1)"/> <!-- current bibiitem is non-first -->
11445
11586
 
11587
+ <xsl:call-template name="setNamedDestination"/>
11446
11588
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
11447
11589
 
11448
11590
  <xsl:call-template name="processBibitem"/>
@@ -11456,6 +11598,7 @@
11456
11598
  <!-- $namespace = 'csd' or $namespace = 'gb' or $namespace = 'iec' or $namespace = 'ieee' or $namespace = 'iso' or $namespace = 'jcgm' or $namespace = 'm3d' or
11457
11599
  $namespace = 'mpfd' or $namespace = 'ogc' or $namespace = 'ogc-white-paper' -->
11458
11600
  <!-- Example: [1] ISO 9:1995, Information and documentation – Transliteration of Cyrillic characters into Latin characters – Slavic and non-Slavic languages -->
11601
+ <xsl:call-template name="setNamedDestination"/>
11459
11602
  <fo:list-block id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-style">
11460
11603
 
11461
11604
  <fo:list-item>
@@ -11485,6 +11628,7 @@
11485
11628
  <xsl:choose>
11486
11629
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
11487
11630
  <xsl:otherwise>
11631
+ <xsl:call-template name="setNamedDestination"/>
11488
11632
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
11489
11633
 
11490
11634
  <fo:list-item-label end-indent="label-end()">
@@ -12139,7 +12283,7 @@
12139
12283
  </xsl:template>
12140
12284
 
12141
12285
  <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
12142
- <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">
12286
+ <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">
12143
12287
  <xsl:copy>
12144
12288
  <xsl:copy-of select="@*"/>
12145
12289
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -12171,28 +12315,56 @@
12171
12315
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_step1"/>
12172
12316
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_pres"/>
12173
12317
 
12174
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_step1">
12318
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_step1">
12175
12319
  <xsl:element name="stem" namespace="{$namespace_full}">
12176
12320
  <xsl:copy-of select="@*"/>
12177
12321
  <xsl:choose>
12178
12322
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
12179
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
12323
+ <xsl:choose>
12324
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
12325
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
12326
+ </xsl:when>
12327
+ <xsl:otherwise>
12328
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_step1"/>
12329
+ </xsl:otherwise>
12330
+ </xsl:choose>
12180
12331
  </xsl:when>
12181
12332
  <xsl:otherwise>
12182
- <xsl:copy-of select="node()"/>
12333
+ <xsl:choose>
12334
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
12335
+ <xsl:copy-of select="node()"/>
12336
+ </xsl:when>
12337
+ <xsl:otherwise>
12338
+ <xsl:apply-templates select="node()" mode="update_xml_step1"/>
12339
+ </xsl:otherwise>
12340
+ </xsl:choose>
12183
12341
  </xsl:otherwise>
12184
12342
  </xsl:choose>
12185
12343
  </xsl:element>
12186
12344
  </xsl:template>
12187
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_pres">
12345
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_pres">
12188
12346
  <xsl:element name="stem" namespace="{$namespace_full}">
12189
12347
  <xsl:copy-of select="@*"/>
12190
12348
  <xsl:choose>
12191
12349
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
12192
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
12350
+ <xsl:choose>
12351
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
12352
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
12353
+ </xsl:when>
12354
+ <xsl:otherwise>
12355
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_pres"/>
12356
+ </xsl:otherwise>
12357
+ </xsl:choose>
12193
12358
  </xsl:when>
12194
12359
  <xsl:otherwise>
12195
- <xsl:copy-of select="node()"/>
12360
+ <xsl:choose>
12361
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
12362
+ <xsl:copy-of select="node()"/>
12363
+ </xsl:when>
12364
+ <xsl:otherwise>
12365
+ <xsl:apply-templates select="node()" mode="update_xml_pres"/>
12366
+ </xsl:otherwise>
12367
+ </xsl:choose>
12196
12368
  </xsl:otherwise>
12197
12369
  </xsl:choose>
12198
12370
  </xsl:element>
@@ -12421,16 +12593,24 @@
12421
12593
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_step1">
12422
12594
  <xsl:element name="title" namespace="{$namespace_full}">
12423
12595
  <xsl:copy-of select="@*"/>
12596
+ <xsl:call-template name="addNamedDestinationAttribute"/>
12597
+
12424
12598
  <xsl:apply-templates mode="update_xml_step1"/>
12425
12599
  </xsl:element>
12426
12600
  </xsl:template>
12427
12601
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_pres">
12428
12602
  <xsl:element name="title" namespace="{$namespace_full}">
12429
12603
  <xsl:copy-of select="@*"/>
12604
+ <xsl:call-template name="addNamedDestinationAttribute"/>
12605
+
12430
12606
  <xsl:apply-templates mode="update_xml_pres"/>
12431
12607
  </xsl:element>
12432
12608
  </xsl:template>
12433
12609
 
12610
+ <xsl:template name="addNamedDestinationAttribute">
12611
+
12612
+ </xsl:template>
12613
+
12434
12614
  <xsl:template match="*[local-name() = 'fmt-name']"/>
12435
12615
  <xsl:template match="*[local-name() = 'fmt-name']" mode="update_xml_step1">
12436
12616
  <xsl:choose>
@@ -12440,6 +12620,8 @@
12440
12620
  <xsl:otherwise>
12441
12621
  <xsl:element name="name" namespace="{$namespace_full}">
12442
12622
  <xsl:copy-of select="@*"/>
12623
+ <xsl:call-template name="addNamedDestinationAttribute"/>
12624
+
12443
12625
  <xsl:apply-templates mode="update_xml_step1"/>
12444
12626
  </xsl:element>
12445
12627
  </xsl:otherwise>
@@ -12453,12 +12635,24 @@
12453
12635
  <xsl:otherwise>
12454
12636
  <xsl:element name="name" namespace="{$namespace_full}">
12455
12637
  <xsl:copy-of select="@*"/>
12638
+ <xsl:call-template name="addNamedDestinationAttribute"/>
12639
+
12456
12640
  <xsl:apply-templates mode="update_xml_pres"/>
12457
12641
  </xsl:element>
12458
12642
  </xsl:otherwise>
12459
12643
  </xsl:choose>
12460
12644
  </xsl:template>
12461
12645
 
12646
+ <!-- li/fmt-name -->
12647
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_step1">
12648
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
12649
+ <xsl:attribute name="full">true</xsl:attribute>
12650
+ </xsl:template>
12651
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_pres">
12652
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
12653
+ <xsl:attribute name="full">true</xsl:attribute>
12654
+ </xsl:template>
12655
+
12462
12656
  <xsl:template match="*[local-name() = 'fmt-preferred']"/>
12463
12657
  <xsl:template match="*[local-name() = 'fmt-preferred'][*[local-name() = 'p']]" mode="update_xml_step1">
12464
12658
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -13273,6 +13467,64 @@
13273
13467
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
13274
13468
  </xsl:template>
13275
13469
 
13470
+ <!-- ===================================== -->
13471
+ <!-- ===================================== -->
13472
+ <!-- Ruby text (CJK languages) rendering -->
13473
+ <!-- ===================================== -->
13474
+ <!-- ===================================== -->
13475
+ <xsl:template match="*[local-name() = 'ruby']">
13476
+ <fo:inline-container text-indent="0mm" last-line-end-indent="0mm">
13477
+ <xsl:if test="not(ancestor::*[local-name() = 'ruby'])">
13478
+ <xsl:attribute name="alignment-baseline">central</xsl:attribute>
13479
+ </xsl:if>
13480
+ <xsl:variable name="rt_text" select="*[local-name() = 'rt']"/>
13481
+ <xsl:variable name="rb_text" select=".//*[local-name() = 'rb'][not(*[local-name() = 'ruby'])]"/>
13482
+ <!-- Example: width="2em" -->
13483
+ <xsl:variable name="text_rt_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rt_text, $font_main, 6)"/>
13484
+ <xsl:variable name="text_rb_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rb_text, $font_main, 10)"/>
13485
+ <xsl:variable name="text_width">
13486
+ <xsl:choose>
13487
+ <xsl:when test="$text_rt_width &gt;= $text_rb_width"><xsl:value-of select="$text_rt_width"/></xsl:when>
13488
+ <xsl:otherwise><xsl:value-of select="$text_rb_width"/></xsl:otherwise>
13489
+ </xsl:choose>
13490
+ </xsl:variable>
13491
+ <xsl:attribute name="width"><xsl:value-of select="$text_width div 10"/>em</xsl:attribute>
13492
+
13493
+ <xsl:choose>
13494
+ <xsl:when test="ancestor::*[local-name() = 'ruby']">
13495
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
13496
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
13497
+ </xsl:when>
13498
+ <xsl:otherwise>
13499
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
13500
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
13501
+ </xsl:otherwise>
13502
+ </xsl:choose>
13503
+
13504
+ <xsl:apply-templates select="node()[not(local-name() = 'rt') and not(local-name() = 'rb')]"/>
13505
+ </fo:inline-container>
13506
+ </xsl:template>
13507
+
13508
+ <xsl:template match="*[local-name() = 'rb']">
13509
+ <fo:block line-height="1em" text-align="center"><xsl:apply-templates/></fo:block>
13510
+ </xsl:template>
13511
+
13512
+ <xsl:template match="*[local-name() = 'rt']">
13513
+ <fo:block font-size="0.5em" text-align="center" line-height="1.2em" space-before="-1.4em" space-before.conditionality="retain"> <!-- -->
13514
+ <xsl:if test="ancestor::*[local-name() = 'ruby'][last()]//*[local-name() = 'ruby'] or ancestor::*[local-name() = 'rb']">
13515
+ <xsl:attribute name="space-before">0em</xsl:attribute>
13516
+ </xsl:if>
13517
+ <xsl:apply-templates/>
13518
+ </fo:block>
13519
+
13520
+ </xsl:template>
13521
+
13522
+ <!-- ===================================== -->
13523
+ <!-- ===================================== -->
13524
+ <!-- END: Ruby text (CJK languages) rendering -->
13525
+ <!-- ===================================== -->
13526
+ <!-- ===================================== -->
13527
+
13276
13528
  <xsl:template name="printEdition">
13277
13529
  <xsl:variable name="edition_i18n" select="normalize-space((//*[local-name() = 'metanorma'])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
13278
13530
 
@@ -13842,6 +14094,24 @@
13842
14094
  </xsl:attribute>
13843
14095
  </xsl:template>
13844
14096
 
14097
+ <xsl:template name="setIDforNamedDestination">
14098
+ <xsl:if test="@named_dest">
14099
+ <xsl:attribute name="id"><xsl:value-of select="@named_dest"/></xsl:attribute>
14100
+ </xsl:if>
14101
+ </xsl:template>
14102
+
14103
+ <xsl:template name="setNamedDestination">
14104
+ <!-- skip GUID, e.g. _33eac3cb-9663-4291-ae26-1d4b6f4635fc -->
14105
+ <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'">
14106
+ <fox:destination internal-destination="{@id}"/>
14107
+ </xsl:if>
14108
+ <xsl:for-each select=". | *[local-name() = 'title'] | *[local-name() = 'name']">
14109
+ <xsl:if test="@named_dest">
14110
+ <fox:destination internal-destination="{@named_dest}"/>
14111
+ </xsl:if>
14112
+ </xsl:for-each>
14113
+ </xsl:template>
14114
+
13845
14115
  <xsl:template name="add-letter-spacing">
13846
14116
  <xsl:param name="text"/>
13847
14117
  <xsl:param name="letter-spacing" select="'0.15'"/>