metanorma-iec 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.
@@ -2872,6 +2872,7 @@
2872
2872
  </xsl:template> <!-- refine_table-style -->
2873
2873
 
2874
2874
  <xsl:attribute-set name="table-name-style">
2875
+ <xsl:attribute name="role">Caption</xsl:attribute>
2875
2876
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2876
2877
 
2877
2878
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -2884,6 +2885,9 @@
2884
2885
 
2885
2886
  <xsl:template name="refine_table-name-style">
2886
2887
  <xsl:param name="continued"/>
2888
+ <xsl:if test="$continued = 'true'">
2889
+ <xsl:attribute name="role">SKIP</xsl:attribute>
2890
+ </xsl:if>
2887
2891
 
2888
2892
  <xsl:if test="$continued = 'true'">
2889
2893
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -4564,8 +4568,14 @@
4564
4568
  </xsl:choose>
4565
4569
  </xsl:variable>
4566
4570
 
4571
+ <xsl:call-template name="setNamedDestination"/>
4572
+
4567
4573
  <fo:block-container xsl:use-attribute-sets="table-container-style" role="SKIP">
4568
4574
 
4575
+ <xsl:for-each select="*[local-name() = 'name']">
4576
+ <xsl:call-template name="setIDforNamedDestination"/>
4577
+ </xsl:for-each>
4578
+
4569
4579
  <xsl:call-template name="refine_table-container-style">
4570
4580
  <xsl:with-param name="margin-side" select="$margin-side"/>
4571
4581
  </xsl:call-template>
@@ -4709,7 +4719,7 @@
4709
4719
  </xsl:if>
4710
4720
 
4711
4721
  </fo:block-container>
4712
- </xsl:variable>
4722
+ </xsl:variable> <!-- END: variable name="table" -->
4713
4723
 
4714
4724
  <xsl:variable name="isAdded" select="@added"/>
4715
4725
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4719,14 +4729,14 @@
4719
4729
 
4720
4730
  <!-- centered table when table name is centered (see table-name-style) -->
4721
4731
 
4722
- <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
4732
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style" role="SKIP">
4723
4733
 
4724
4734
  <fo:table-column column-width="proportional-column-width(1)"/>
4725
4735
  <fo:table-column column-width="{@width}"/>
4726
4736
  <fo:table-column column-width="proportional-column-width(1)"/>
4727
- <fo:table-body>
4728
- <fo:table-row>
4729
- <fo:table-cell column-number="2">
4737
+ <fo:table-body role="SKIP">
4738
+ <fo:table-row role="SKIP">
4739
+ <fo:table-cell column-number="2" role="SKIP">
4730
4740
  <xsl:copy-of select="$table-preamble"/>
4731
4741
  <fo:block role="SKIP">
4732
4742
  <xsl:call-template name="setTrackChangesStyles">
@@ -4772,11 +4782,13 @@
4772
4782
 
4773
4783
  </xsl:template>
4774
4784
 
4785
+ <!-- table/name-->
4775
4786
  <xsl:template match="*[local-name()='table']/*[local-name() = 'name']">
4776
4787
  <xsl:param name="continued"/>
4788
+ <xsl:param name="cols-count"/>
4777
4789
  <xsl:if test="normalize-space() != ''">
4778
4790
 
4779
- <fo:block xsl:use-attribute-sets="table-name-style" role="SKIP">
4791
+ <fo:block xsl:use-attribute-sets="table-name-style">
4780
4792
 
4781
4793
  <xsl:call-template name="refine_table-name-style">
4782
4794
  <xsl:with-param name="continued" select="$continued"/>
@@ -4805,9 +4817,30 @@
4805
4817
 
4806
4818
  <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
4807
4819
  <xsl:if test="$continued = 'true'">
4808
- <fo:block text-align="right">
4809
- <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
4810
- </fo:block>
4820
+
4821
+ <!-- to prevent the error 'THead element may contain only TR elements' -->
4822
+
4823
+ <xsl:choose>
4824
+ <xsl:when test="string(number($cols-count)) != 'NaN'">
4825
+ <fo:table width="100%" table-layout="fixed" role="SKIP">
4826
+ <fo:table-body role="SKIP">
4827
+ <fo:table-row>
4828
+ <fo:table-cell role="TH" number-columns-spanned="{$cols-count}">
4829
+ <fo:block text-align="right" role="SKIP">
4830
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
4831
+ </fo:block>
4832
+ </fo:table-cell>
4833
+ </fo:table-row>
4834
+ </fo:table-body>
4835
+ </fo:table>
4836
+ </xsl:when>
4837
+ <xsl:otherwise>
4838
+ <fo:block text-align="right">
4839
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
4840
+ </fo:block>
4841
+ </xsl:otherwise>
4842
+ </xsl:choose>
4843
+
4811
4844
  </xsl:if>
4812
4845
  <!-- </xsl:if> -->
4813
4846
 
@@ -5204,6 +5237,7 @@
5204
5237
 
5205
5238
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
5206
5239
  <xsl:with-param name="continued">true</xsl:with-param>
5240
+ <xsl:with-param name="cols-count" select="$cols-count"/>
5207
5241
  </xsl:apply-templates>
5208
5242
 
5209
5243
  <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
@@ -5272,7 +5306,7 @@
5272
5306
 
5273
5307
  <xsl:variable name="tableWithNotesAndFootnotes">
5274
5308
 
5275
- <fo:table keep-with-previous="always">
5309
+ <fo:table keep-with-previous="always" role="SKIP">
5276
5310
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
5277
5311
  <xsl:variable name="name" select="local-name()"/>
5278
5312
  <xsl:choose>
@@ -5303,9 +5337,9 @@
5303
5337
  </xsl:otherwise>
5304
5338
  </xsl:choose>
5305
5339
 
5306
- <fo:table-body>
5307
- <fo:table-row>
5308
- <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}">
5340
+ <fo:table-body role="SKIP">
5341
+ <fo:table-row role="SKIP">
5342
+ <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}" role="SKIP">
5309
5343
 
5310
5344
  <xsl:call-template name="refine_table-footer-cell-style"/>
5311
5345
 
@@ -5384,6 +5418,7 @@
5384
5418
  <!-- if there isn't 'thead' and there is a table's title -->
5385
5419
  <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='thead']) and ancestor::*[local-name()='table']/*[local-name()='name']">
5386
5420
  <fo:table-header>
5421
+
5387
5422
  <xsl:call-template name="table-header-title">
5388
5423
  <xsl:with-param name="cols-count" select="$cols-count"/>
5389
5424
  </xsl:call-template>
@@ -5640,8 +5675,8 @@
5640
5675
  <xsl:for-each select="xalan:nodeset($styles__)/item">
5641
5676
  <xsl:variable name="key" select="normalize-space(substring-before(., ':'))"/>
5642
5677
  <xsl:variable name="value" select="normalize-space(substring-after(translate(.,$quot,''), ':'))"/>
5643
- <xsl:if test="$key = 'color' or $key = 'background-color'">
5644
- <style name="{$key}"><xsl:value-of select="$value"/></style>
5678
+ <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'">
5679
+ <style name="{$key}"><xsl:value-of select="java:replaceAll(java:java.lang.String.new($value), 'currentColor', 'inherit')"/></style>
5645
5680
  </xsl:if>
5646
5681
  </xsl:for-each>
5647
5682
  </xsl:variable>
@@ -5705,6 +5740,7 @@
5705
5740
  <!-- table/note, table/example, table/tfoot//note, table/tfoot//example -->
5706
5741
  <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">
5707
5742
 
5743
+ <xsl:call-template name="setNamedDestination"/>
5708
5744
  <fo:block xsl:use-attribute-sets="table-note-style">
5709
5745
  <xsl:copy-of select="@id"/>
5710
5746
 
@@ -5752,6 +5788,7 @@
5752
5788
  <!-- footnotes in text (title, bibliography, main body), not for tables, figures and names --> <!-- table's, figure's names -->
5753
5789
  <!-- fn in text -->
5754
5790
  <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">
5791
+ <xsl:param name="footnote_body_from_table">false</xsl:param>
5755
5792
 
5756
5793
  <!-- list of unique footnotes -->
5757
5794
  <xsl:variable name="p_fn_">
@@ -5817,7 +5854,7 @@
5817
5854
  <xsl:copy-of select="$footnote_inline"/>
5818
5855
  </xsl:when>
5819
5856
  <!-- <xsl:when test="$footnotes//*[local-name() = 'fmt-fn-body'][@id = $ref_id] or normalize-space(@skip_footnote_body) = 'false'"> -->
5820
- <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
5857
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false' or $footnote_body_from_table = 'true'">
5821
5858
 
5822
5859
  <fo:footnote xsl:use-attribute-sets="fn-style" role="SKIP">
5823
5860
  <xsl:copy-of select="$footnote_inline"/>
@@ -6228,39 +6265,51 @@
6228
6265
  <!-- fn reference in the table rendering (for instance, 'some text 1) some text' ) -->
6229
6266
  <!-- fn --> <!-- in table --> <!-- for figure see <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/> -->
6230
6267
  <xsl:template match="*[local-name()='fn']">
6231
- <fo:inline xsl:use-attribute-sets="fn-reference-style">
6232
-
6233
- <xsl:call-template name="refine_fn-reference-style"/>
6268
+ <xsl:variable name="target" select="@target"/>
6269
+ <xsl:choose>
6270
+ <!-- case for footnotes in Requirement tables (https://github.com/metanorma/metanorma-ogc/issues/791) -->
6271
+ <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]">
6272
+ <xsl:call-template name="fn">
6273
+ <xsl:with-param name="footnote_body_from_table">true</xsl:with-param>
6274
+ </xsl:call-template>
6275
+ </xsl:when>
6276
+ <xsl:otherwise>
6234
6277
 
6235
- <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
6236
- <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
6237
- <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
6238
- <!-- <xsl:attribute name="internal-destination">
6239
- <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
6240
- </xsl:attribute>
6241
- </xsl:if>
6242
- <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
6243
- <xsl:attribute name="internal-destination">
6244
- <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
6245
- <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
6246
- </xsl:attribute>
6247
- </xsl:if> -->
6248
- <!-- <xsl:if test="$namespace = 'plateau'">
6249
- <xsl:text>※</xsl:text>
6250
- </xsl:if> -->
6251
- <!-- <xsl:value-of select="@reference"/> -->
6278
+ <fo:inline xsl:use-attribute-sets="fn-reference-style">
6252
6279
 
6253
- <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
6280
+ <xsl:call-template name="refine_fn-reference-style"/>
6254
6281
 
6255
- <!-- <xsl:if test="$namespace = 'bsi'">
6256
- <xsl:text>)</xsl:text>
6257
- </xsl:if> -->
6258
- <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
6259
- <!-- <xsl:if test="$namespace = 'jis'">
6260
- <fo:inline font-weight="normal">)</fo:inline>
6261
- </xsl:if> -->
6262
- </fo:basic-link>
6263
- </fo:inline>
6282
+ <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
6283
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
6284
+ <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
6285
+ <!-- <xsl:attribute name="internal-destination">
6286
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
6287
+ </xsl:attribute>
6288
+ </xsl:if>
6289
+ <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
6290
+ <xsl:attribute name="internal-destination">
6291
+ <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
6292
+ <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
6293
+ </xsl:attribute>
6294
+ </xsl:if> -->
6295
+ <!-- <xsl:if test="$namespace = 'plateau'">
6296
+ <xsl:text>※</xsl:text>
6297
+ </xsl:if> -->
6298
+ <!-- <xsl:value-of select="@reference"/> -->
6299
+
6300
+ <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
6301
+
6302
+ <!-- <xsl:if test="$namespace = 'bsi'">
6303
+ <xsl:text>)</xsl:text>
6304
+ </xsl:if> -->
6305
+ <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
6306
+ <!-- <xsl:if test="$namespace = 'jis'">
6307
+ <fo:inline font-weight="normal">)</fo:inline>
6308
+ </xsl:if> -->
6309
+ </fo:basic-link>
6310
+ </fo:inline>
6311
+ </xsl:otherwise>
6312
+ </xsl:choose>
6264
6313
  </xsl:template> <!-- fn -->
6265
6314
 
6266
6315
  <!-- fn/text() -->
@@ -6315,6 +6364,10 @@
6315
6364
  <!-- <dl><xsl:copy-of select="."/></dl> -->
6316
6365
  <fo:block-container xsl:use-attribute-sets="dl-block-style" role="SKIP">
6317
6366
 
6367
+ <xsl:if test="@key = 'true' and ancestor::*[local-name() = 'figure']">
6368
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
6369
+ </xsl:if>
6370
+
6318
6371
  <xsl:call-template name="setBlockSpanAll"/>
6319
6372
 
6320
6373
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
@@ -6615,7 +6668,7 @@
6615
6668
 
6616
6669
  <!-- caption for figure key and another caption, https://github.com/metanorma/isodoc/issues/607 -->
6617
6670
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'p'][@keep-with-next = 'true' and *[local-name() = 'strong']]" priority="3">
6618
- <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always">
6671
+ <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always" keep-with-previous="always">
6619
6672
  <xsl:call-template name="refine_figure_key_style"/>
6620
6673
  <xsl:apply-templates/>
6621
6674
  </fo:block>
@@ -6871,6 +6924,7 @@
6871
6924
 
6872
6925
  <xsl:call-template name="refine_dt-cell-style"/>
6873
6926
 
6927
+ <xsl:call-template name="setNamedDestination"/>
6874
6928
  <fo:block xsl:use-attribute-sets="dt-block-style" role="SKIP">
6875
6929
 
6876
6930
  <xsl:choose>
@@ -7307,7 +7361,7 @@
7307
7361
  <!-- ================= -->
7308
7362
 
7309
7363
  <!-- highlight text -->
7310
- <xsl:template match="*[local-name()='hi']">
7364
+ <xsl:template match="*[local-name()='hi'] | *[local-name() = 'span'][@class = 'fmt-hi']" priority="3">
7311
7365
  <fo:inline background-color="yellow">
7312
7366
  <xsl:apply-templates/>
7313
7367
  </fo:inline>
@@ -8973,6 +9027,7 @@
8973
9027
  <!-- Appendix processing -->
8974
9028
  <!-- ======================== -->
8975
9029
  <xsl:template match="*[local-name()='appendix']">
9030
+ <xsl:call-template name="setNamedDestination"/>
8976
9031
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-style">
8977
9032
  <xsl:apply-templates select="*[local-name()='title']"/>
8978
9033
  </fo:block>
@@ -8983,13 +9038,14 @@
8983
9038
  <xsl:variable name="level">
8984
9039
  <xsl:call-template name="getLevel"/>
8985
9040
  </xsl:variable>
8986
- <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
9041
+ <fo:inline role="H{$level}"><xsl:call-template name="setIDforNamedDestination"/><xsl:apply-templates/></fo:inline>
8987
9042
  </xsl:template>
8988
9043
  <!-- ======================== -->
8989
9044
  <!-- END Appendix processing -->
8990
9045
  <!-- ======================== -->
8991
9046
 
8992
9047
  <xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
9048
+ <xsl:call-template name="setNamedDestination"/>
8993
9049
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
8994
9050
  <xsl:apply-templates select="*[local-name()='name']"/>
8995
9051
  </fo:block>
@@ -9019,6 +9075,7 @@
9019
9075
  <xsl:template match="*[local-name() = 'annotation']/*[local-name() = 'p']">
9020
9076
  <xsl:param name="callout"/>
9021
9077
  <fo:inline id="{@id}">
9078
+ <xsl:call-template name="setNamedDestination"/>
9022
9079
  <!-- for first p in annotation, put <x> -->
9023
9080
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
9024
9081
  <xsl:apply-templates/>
@@ -9065,6 +9122,7 @@
9065
9122
 
9066
9123
  </xsl:if>
9067
9124
  <fo:block-container margin-left="0mm" role="SKIP">
9125
+ <xsl:call-template name="setNamedDestination"/>
9068
9126
  <fo:block id="{@id}">
9069
9127
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/> <!-- formula's number will be process in 'stem' template -->
9070
9128
  </fo:block>
@@ -9110,8 +9168,13 @@
9110
9168
  </fo:block>
9111
9169
  </fo:table-cell>
9112
9170
  <fo:table-cell display-align="center">
9171
+
9113
9172
  <fo:block xsl:use-attribute-sets="formula-stem-number-style" role="SKIP">
9114
9173
 
9174
+ <xsl:for-each select="../*[local-name() = 'name']">
9175
+ <xsl:call-template name="setIDforNamedDestination"/>
9176
+ </xsl:for-each>
9177
+
9115
9178
  <xsl:call-template name="refine_formula-stem-number-style"/>
9116
9179
 
9117
9180
  <xsl:apply-templates select="../*[local-name() = 'name']"/>
@@ -9146,6 +9209,8 @@
9146
9209
 
9147
9210
  <xsl:template match="*[local-name() = 'note']" name="note">
9148
9211
 
9212
+ <xsl:call-template name="setNamedDestination"/>
9213
+
9149
9214
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style" role="SKIP">
9150
9215
 
9151
9216
  <xsl:call-template name="setBlockSpanAll"/>
@@ -9210,6 +9275,7 @@
9210
9275
  </xsl:template>
9211
9276
 
9212
9277
  <xsl:template match="*[local-name() = 'termnote']">
9278
+ <xsl:call-template name="setNamedDestination"/>
9213
9279
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
9214
9280
 
9215
9281
  <xsl:call-template name="setBlockSpanAll"/>
@@ -9316,12 +9382,14 @@
9316
9382
 
9317
9383
  <xsl:template match="*[local-name() = 'terms']">
9318
9384
  <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
9385
+ <xsl:call-template name="setNamedDestination"/>
9319
9386
  <fo:block id="{@id}">
9320
9387
  <xsl:apply-templates/>
9321
9388
  </fo:block>
9322
9389
  </xsl:template>
9323
9390
 
9324
9391
  <xsl:template match="*[local-name() = 'term']">
9392
+ <xsl:call-template name="setNamedDestination"/>
9325
9393
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
9326
9394
 
9327
9395
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'term'])">
@@ -9353,6 +9421,7 @@
9353
9421
  <xsl:template match="*[local-name() = 'figure']" name="figure">
9354
9422
  <xsl:variable name="isAdded" select="@added"/>
9355
9423
  <xsl:variable name="isDeleted" select="@deleted"/>
9424
+ <xsl:call-template name="setNamedDestination"/>
9356
9425
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
9357
9426
  <xsl:call-template name="refine_figure-block-style"/>
9358
9427
 
@@ -9369,6 +9438,11 @@
9369
9438
  </xsl:variable>
9370
9439
 
9371
9440
  <fo:block xsl:use-attribute-sets="figure-style" role="SKIP">
9441
+
9442
+ <xsl:for-each select="*[local-name() = 'name']"> <!-- set context -->
9443
+ <xsl:call-template name="setIDforNamedDestination"/>
9444
+ </xsl:for-each>
9445
+
9372
9446
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
9373
9447
  </fo:block>
9374
9448
 
@@ -9401,6 +9475,7 @@
9401
9475
  </xsl:template>
9402
9476
 
9403
9477
  <xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']">
9478
+ <xsl:call-template name="setNamedDestination"/>
9404
9479
  <fo:block id="{@id}">
9405
9480
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
9406
9481
  </fo:block>
@@ -9414,6 +9489,7 @@
9414
9489
  </xsl:template>
9415
9490
 
9416
9491
  <!-- SOURCE: ... -->
9492
+ <!-- figure/source -->
9417
9493
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
9418
9494
 
9419
9495
  <fo:block xsl:use-attribute-sets="figure-source-style">
@@ -10341,6 +10417,13 @@
10341
10417
  <xsl:apply-templates select="."/>
10342
10418
  </xsl:template>
10343
10419
 
10420
+ <!-- prevent missing stem for table and figures in ToC -->
10421
+ <xsl:template match="*[local-name() = 'name' or local-name() = 'fmt-name']//*[local-name() = 'stem']" mode="contents">
10422
+ <xsl:if test="not(following-sibling::*[1][local-name() = 'fmt-stem'])">
10423
+ <xsl:apply-templates select="."/>
10424
+ </xsl:if>
10425
+ </xsl:template>
10426
+
10344
10427
  <xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/>
10345
10428
 
10346
10429
  <xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/>
@@ -10573,7 +10656,8 @@
10573
10656
 
10574
10657
  <xsl:for-each select="$contents_nodes//tables/table">
10575
10658
  <fo:bookmark internal-destination="{@id}">
10576
- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
10659
+ <!-- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title> -->
10660
+ <fo:bookmark-title><xsl:apply-templates mode="bookmark_clean"/></fo:bookmark-title>
10577
10661
  </fo:bookmark>
10578
10662
  </xsl:for-each>
10579
10663
  </fo:bookmark>
@@ -10582,6 +10666,26 @@
10582
10666
  </xsl:template> <!-- insertTableBookmarks -->
10583
10667
  <!-- End Bookmarks -->
10584
10668
 
10669
+ <!-- ============================ -->
10670
+ <!-- mode="bookmark_clean" -->
10671
+ <!-- ============================ -->
10672
+ <xsl:template match="node()" mode="bookmark_clean">
10673
+ <xsl:apply-templates select="node()" mode="bookmark_clean"/>
10674
+ </xsl:template>
10675
+
10676
+ <xsl:template match="text()" mode="bookmark_clean">
10677
+ <xsl:value-of select="."/>
10678
+ </xsl:template>
10679
+
10680
+ <xsl:template match="*[local-name() = 'math']" mode="bookmark_clean">
10681
+ <xsl:value-of select="normalize-space(.)"/>
10682
+ </xsl:template>
10683
+
10684
+ <xsl:template match="*[local-name() = 'asciimath']" mode="bookmark_clean"/>
10685
+ <!-- ============================ -->
10686
+ <!-- END: mode="bookmark_clean" -->
10687
+ <!-- ============================ -->
10688
+
10585
10689
  <xsl:template name="getLangVersion">
10586
10690
  <xsl:param name="lang"/>
10587
10691
  <xsl:param name="doctype" select="''"/>
@@ -10631,6 +10735,7 @@
10631
10735
  <xsl:template match="title" mode="bookmark"/>
10632
10736
  <xsl:template match="text()" mode="bookmark"/>
10633
10737
 
10738
+ <!-- figure/name -->
10634
10739
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'image']/*[local-name() = 'name']">
10635
10740
  <xsl:if test="normalize-space() != ''">
10636
10741
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -11347,6 +11452,7 @@
11347
11452
  <!-- permission -->
11348
11453
  <!-- ========== -->
11349
11454
  <xsl:template match="*[local-name() = 'permission']">
11455
+ <xsl:call-template name="setNamedDestination"/>
11350
11456
  <fo:block id="{@id}" xsl:use-attribute-sets="permission-style">
11351
11457
  <xsl:apply-templates select="*[local-name()='name']"/>
11352
11458
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -11355,10 +11461,12 @@
11355
11461
 
11356
11462
  <xsl:template match="*[local-name() = 'permission']/*[local-name() = 'name']">
11357
11463
  <xsl:if test="normalize-space() != ''">
11358
- <fo:block xsl:use-attribute-sets="permission-name-style">
11359
- <xsl:apply-templates/>
11360
11464
 
11361
- </fo:block>
11465
+ <fo:block xsl:use-attribute-sets="permission-name-style">
11466
+ <xsl:apply-templates/>
11467
+
11468
+ </fo:block>
11469
+
11362
11470
  </xsl:if>
11363
11471
  </xsl:template>
11364
11472
 
@@ -11374,6 +11482,7 @@
11374
11482
  <!-- requirement -->
11375
11483
  <!-- ========== -->
11376
11484
  <xsl:template match="*[local-name() = 'requirement']">
11485
+ <xsl:call-template name="setNamedDestination"/>
11377
11486
  <fo:block id="{@id}" xsl:use-attribute-sets="requirement-style">
11378
11487
  <xsl:apply-templates select="*[local-name()='name']"/>
11379
11488
  <xsl:apply-templates select="*[local-name()='label']"/>
@@ -11385,11 +11494,13 @@
11385
11494
 
11386
11495
  <xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'name']">
11387
11496
  <xsl:if test="normalize-space() != ''">
11388
- <fo:block xsl:use-attribute-sets="requirement-name-style">
11389
11497
 
11390
- <xsl:apply-templates/>
11498
+ <fo:block xsl:use-attribute-sets="requirement-name-style">
11499
+
11500
+ <xsl:apply-templates/>
11501
+
11502
+ </fo:block>
11391
11503
 
11392
- </fo:block>
11393
11504
  </xsl:if>
11394
11505
  </xsl:template>
11395
11506
 
@@ -11418,6 +11529,7 @@
11418
11529
  <!-- recommendation -->
11419
11530
  <!-- ========== -->
11420
11531
  <xsl:template match="*[local-name() = 'recommendation']">
11532
+ <xsl:call-template name="setNamedDestination"/>
11421
11533
  <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">
11422
11534
  <xsl:apply-templates select="*[local-name()='name']"/>
11423
11535
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -11426,10 +11538,12 @@
11426
11538
 
11427
11539
  <xsl:template match="*[local-name() = 'recommendation']/*[local-name() = 'name']">
11428
11540
  <xsl:if test="normalize-space() != ''">
11429
- <fo:block xsl:use-attribute-sets="recommendation-name-style">
11430
- <xsl:apply-templates/>
11431
11541
 
11432
- </fo:block>
11542
+ <fo:block xsl:use-attribute-sets="recommendation-name-style">
11543
+ <xsl:apply-templates/>
11544
+
11545
+ </fo:block>
11546
+
11433
11547
  </xsl:if>
11434
11548
  </xsl:template>
11435
11549
 
@@ -11508,6 +11622,7 @@
11508
11622
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
11509
11623
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
11510
11624
  </xsl:if>
11625
+ <xsl:call-template name="setNamedDestination"/>
11511
11626
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
11512
11627
  <fo:table id="{@id}" table-layout="fixed" width="100%"> <!-- border="1pt solid black" -->
11513
11628
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
@@ -11617,6 +11732,7 @@
11617
11732
  <!-- termexample -->
11618
11733
  <!-- ====== -->
11619
11734
  <xsl:template match="*[local-name() = 'termexample']">
11735
+ <xsl:call-template name="setNamedDestination"/>
11620
11736
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
11621
11737
  <xsl:call-template name="refine_termexample-style"/>
11622
11738
  <xsl:call-template name="setBlockSpanAll"/>
@@ -11671,6 +11787,7 @@
11671
11787
  -->
11672
11788
  <xsl:template match="*[local-name() = 'example']" name="example">
11673
11789
 
11790
+ <xsl:call-template name="setNamedDestination"/>
11674
11791
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style" role="SKIP">
11675
11792
 
11676
11793
  <xsl:call-template name="setBlockSpanAll"/>
@@ -12199,8 +12316,13 @@
12199
12316
  </xsl:if>
12200
12317
 
12201
12318
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'preferred'])"> <!-- if first preffered in term, then display term's name -->
12319
+
12202
12320
  <fo:block xsl:use-attribute-sets="term-name-style" role="SKIP">
12203
12321
 
12322
+ <xsl:for-each select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"><!-- change context -->
12323
+ <xsl:call-template name="setIDforNamedDestination"/>
12324
+ </xsl:for-each>
12325
+
12204
12326
  <xsl:apply-templates select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"/>
12205
12327
  </fo:block>
12206
12328
  </xsl:if>
@@ -12320,6 +12442,7 @@
12320
12442
  <!-- main sections -->
12321
12443
  <xsl:template match="/*/*[local-name() = 'sections']/*" name="sections_node" priority="2">
12322
12444
 
12445
+ <xsl:call-template name="setNamedDestination"/>
12323
12446
  <fo:block>
12324
12447
  <xsl:call-template name="setId"/>
12325
12448
 
@@ -12360,6 +12483,7 @@
12360
12483
 
12361
12484
  <fo:block break-after="page"/>
12362
12485
 
12486
+ <xsl:call-template name="setNamedDestination"/>
12363
12487
  <fo:block>
12364
12488
  <xsl:call-template name="setId"/>
12365
12489
  <xsl:call-template name="addReviewHelper"/>
@@ -12388,6 +12512,7 @@
12388
12512
  </xsl:template>
12389
12513
 
12390
12514
  <xsl:template match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty -->
12515
+ <xsl:call-template name="setNamedDestination"/>
12391
12516
  <fo:block>
12392
12517
  <xsl:if test="parent::*[local-name() = 'copyright-statement']">
12393
12518
  <xsl:attribute name="role">SKIP</xsl:attribute>
@@ -12410,6 +12535,7 @@
12410
12535
  </xsl:template> <!-- refine_clause_style -->
12411
12536
 
12412
12537
  <xsl:template match="*[local-name() = 'definitions']">
12538
+ <xsl:call-template name="setNamedDestination"/>
12413
12539
  <fo:block id="{@id}">
12414
12540
  <xsl:apply-templates/>
12415
12541
  </fo:block>
@@ -12425,6 +12551,8 @@
12425
12551
  <xsl:otherwise>
12426
12552
 
12427
12553
  <fo:block break-after="page"/>
12554
+ <xsl:call-template name="setNamedDestination"/>
12555
+
12428
12556
  <fo:block id="{@id}">
12429
12557
 
12430
12558
  <xsl:call-template name="setBlockSpanAll"/>
@@ -12496,6 +12624,7 @@
12496
12624
  <!-- following-sibling::node()[1][local-name() = 'bookmark'][@id = $source] and
12497
12625
  following-sibling::node()[2][local-name() = 'fmt-review-end'][@source = $source] -->
12498
12626
  <!-- <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> -->
12627
+ <xsl:call-template name="setNamedDestination"/>
12499
12628
  <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>
12500
12629
  <!-- </xsl:if> -->
12501
12630
  </xsl:if>
@@ -12597,9 +12726,15 @@
12597
12726
  <xsl:when test="local-name(..) = 'ul'">
12598
12727
  <xsl:choose>
12599
12728
  <xsl:when test="normalize-space($processing_instruction_type) = 'simple'"/>
12729
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
12730
+ <xsl:when test="@label"><xsl:value-of select="@label"/></xsl:when>
12600
12731
  <xsl:otherwise><xsl:call-template name="setULLabel"/></xsl:otherwise>
12601
12732
  </xsl:choose>
12602
12733
  </xsl:when>
12734
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
12735
+ <xsl:when test="local-name(..) = 'ol' and @label and @full = 'true'"> <!-- @full added in the template li/fmt-name -->
12736
+ <xsl:value-of select="@label"/>
12737
+ </xsl:when>
12603
12738
  <xsl:when test="local-name(..) = 'ol' and @label"> <!-- for ordered lists 'ol', and if there is @label, for instance label="1.1.2" -->
12604
12739
 
12605
12740
  <xsl:variable name="type" select="../@type"/>
@@ -12724,7 +12859,7 @@
12724
12859
 
12725
12860
  </xsl:otherwise>
12726
12861
  </xsl:choose>
12727
- </xsl:template>
12862
+ </xsl:template> <!-- getListItemFormat -->
12728
12863
 
12729
12864
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
12730
12865
  <xsl:param name="indent">0</xsl:param>
@@ -12860,6 +12995,11 @@
12860
12995
 
12861
12996
  <xsl:call-template name="refine_list-item-label-style"/>
12862
12997
 
12998
+ <xsl:if test="local-name(..) = 'ul'">
12999
+ <xsl:variable name="li_label" select="@label"/>
13000
+ <xsl:copy-of select="$ul_labels//label[. = $li_label]/@*[not(local-name() = 'level')]"/>
13001
+ </xsl:if>
13002
+
12863
13003
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
12864
13004
  <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
12865
13005
  <xsl:call-template name="append_add-style"/>
@@ -13206,6 +13346,7 @@
13206
13346
  <!-- Normative references -->
13207
13347
  <xsl:template match="*[local-name() = 'references'][@normative='true']" priority="2">
13208
13348
 
13349
+ <xsl:call-template name="setNamedDestination"/>
13209
13350
  <fo:block id="{@id}">
13210
13351
  <xsl:apply-templates/>
13211
13352
 
@@ -13226,6 +13367,7 @@
13226
13367
  </xsl:if>
13227
13368
  </xsl:if> -->
13228
13369
 
13370
+ <xsl:call-template name="setNamedDestination"/>
13229
13371
  <fo:block id="{@id}"/>
13230
13372
 
13231
13373
  <xsl:apply-templates select="*[local-name() = 'title'][@columns = 1]"/>
@@ -13250,6 +13392,7 @@
13250
13392
  <xsl:template match="*[local-name() = 'references'][@normative='true']/*[local-name() = 'bibitem']" name="bibitem" priority="2">
13251
13393
  <xsl:param name="skip" select="normalize-space(preceding-sibling::*[1][local-name() = 'bibitem'] and 1 = 1)"/> <!-- current bibiitem is non-first -->
13252
13394
 
13395
+ <xsl:call-template name="setNamedDestination"/>
13253
13396
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
13254
13397
 
13255
13398
  <xsl:call-template name="processBibitem"/>
@@ -13263,6 +13406,7 @@
13263
13406
  <!-- $namespace = 'csd' or $namespace = 'gb' or $namespace = 'iec' or $namespace = 'ieee' or $namespace = 'iso' or $namespace = 'jcgm' or $namespace = 'm3d' or
13264
13407
  $namespace = 'mpfd' or $namespace = 'ogc' or $namespace = 'ogc-white-paper' -->
13265
13408
  <!-- Example: [1] ISO 9:1995, Information and documentation – Transliteration of Cyrillic characters into Latin characters – Slavic and non-Slavic languages -->
13409
+ <xsl:call-template name="setNamedDestination"/>
13266
13410
  <fo:list-block id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-style">
13267
13411
 
13268
13412
  <fo:list-item>
@@ -13292,6 +13436,7 @@
13292
13436
  <xsl:choose>
13293
13437
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
13294
13438
  <xsl:otherwise>
13439
+ <xsl:call-template name="setNamedDestination"/>
13295
13440
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
13296
13441
 
13297
13442
  <fo:list-item-label end-indent="label-end()">
@@ -13686,6 +13831,7 @@
13686
13831
  <xsl:template match="*[local-name() = 'admonition']">
13687
13832
 
13688
13833
  <!-- text in the box -->
13834
+ <xsl:call-template name="setNamedDestination"/>
13689
13835
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
13690
13836
 
13691
13837
  <xsl:call-template name="setBlockSpanAll"/>
@@ -13941,7 +14087,7 @@
13941
14087
  </xsl:template>
13942
14088
 
13943
14089
  <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
13944
- <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">
14090
+ <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">
13945
14091
  <xsl:copy>
13946
14092
  <xsl:copy-of select="@*"/>
13947
14093
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -13973,28 +14119,56 @@
13973
14119
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_step1"/>
13974
14120
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_pres"/>
13975
14121
 
13976
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_step1">
14122
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_step1">
13977
14123
  <xsl:element name="stem" namespace="{$namespace_full}">
13978
14124
  <xsl:copy-of select="@*"/>
13979
14125
  <xsl:choose>
13980
14126
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
13981
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14127
+ <xsl:choose>
14128
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14129
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14130
+ </xsl:when>
14131
+ <xsl:otherwise>
14132
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_step1"/>
14133
+ </xsl:otherwise>
14134
+ </xsl:choose>
13982
14135
  </xsl:when>
13983
14136
  <xsl:otherwise>
13984
- <xsl:copy-of select="node()"/>
14137
+ <xsl:choose>
14138
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14139
+ <xsl:copy-of select="node()"/>
14140
+ </xsl:when>
14141
+ <xsl:otherwise>
14142
+ <xsl:apply-templates select="node()" mode="update_xml_step1"/>
14143
+ </xsl:otherwise>
14144
+ </xsl:choose>
13985
14145
  </xsl:otherwise>
13986
14146
  </xsl:choose>
13987
14147
  </xsl:element>
13988
14148
  </xsl:template>
13989
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_pres">
14149
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_pres">
13990
14150
  <xsl:element name="stem" namespace="{$namespace_full}">
13991
14151
  <xsl:copy-of select="@*"/>
13992
14152
  <xsl:choose>
13993
14153
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
13994
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14154
+ <xsl:choose>
14155
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14156
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14157
+ </xsl:when>
14158
+ <xsl:otherwise>
14159
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_pres"/>
14160
+ </xsl:otherwise>
14161
+ </xsl:choose>
13995
14162
  </xsl:when>
13996
14163
  <xsl:otherwise>
13997
- <xsl:copy-of select="node()"/>
14164
+ <xsl:choose>
14165
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14166
+ <xsl:copy-of select="node()"/>
14167
+ </xsl:when>
14168
+ <xsl:otherwise>
14169
+ <xsl:apply-templates select="node()" mode="update_xml_pres"/>
14170
+ </xsl:otherwise>
14171
+ </xsl:choose>
13998
14172
  </xsl:otherwise>
13999
14173
  </xsl:choose>
14000
14174
  </xsl:element>
@@ -14223,16 +14397,24 @@
14223
14397
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_step1">
14224
14398
  <xsl:element name="title" namespace="{$namespace_full}">
14225
14399
  <xsl:copy-of select="@*"/>
14400
+ <xsl:call-template name="addNamedDestinationAttribute"/>
14401
+
14226
14402
  <xsl:apply-templates mode="update_xml_step1"/>
14227
14403
  </xsl:element>
14228
14404
  </xsl:template>
14229
14405
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_pres">
14230
14406
  <xsl:element name="title" namespace="{$namespace_full}">
14231
14407
  <xsl:copy-of select="@*"/>
14408
+ <xsl:call-template name="addNamedDestinationAttribute"/>
14409
+
14232
14410
  <xsl:apply-templates mode="update_xml_pres"/>
14233
14411
  </xsl:element>
14234
14412
  </xsl:template>
14235
14413
 
14414
+ <xsl:template name="addNamedDestinationAttribute">
14415
+
14416
+ </xsl:template>
14417
+
14236
14418
  <xsl:template match="*[local-name() = 'fmt-name']"/>
14237
14419
  <xsl:template match="*[local-name() = 'fmt-name']" mode="update_xml_step1">
14238
14420
  <xsl:choose>
@@ -14242,6 +14424,8 @@
14242
14424
  <xsl:otherwise>
14243
14425
  <xsl:element name="name" namespace="{$namespace_full}">
14244
14426
  <xsl:copy-of select="@*"/>
14427
+ <xsl:call-template name="addNamedDestinationAttribute"/>
14428
+
14245
14429
  <xsl:apply-templates mode="update_xml_step1"/>
14246
14430
  </xsl:element>
14247
14431
  </xsl:otherwise>
@@ -14255,12 +14439,24 @@
14255
14439
  <xsl:otherwise>
14256
14440
  <xsl:element name="name" namespace="{$namespace_full}">
14257
14441
  <xsl:copy-of select="@*"/>
14442
+ <xsl:call-template name="addNamedDestinationAttribute"/>
14443
+
14258
14444
  <xsl:apply-templates mode="update_xml_pres"/>
14259
14445
  </xsl:element>
14260
14446
  </xsl:otherwise>
14261
14447
  </xsl:choose>
14262
14448
  </xsl:template>
14263
14449
 
14450
+ <!-- li/fmt-name -->
14451
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_step1">
14452
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
14453
+ <xsl:attribute name="full">true</xsl:attribute>
14454
+ </xsl:template>
14455
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_pres">
14456
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
14457
+ <xsl:attribute name="full">true</xsl:attribute>
14458
+ </xsl:template>
14459
+
14264
14460
  <xsl:template match="*[local-name() = 'fmt-preferred']"/>
14265
14461
  <xsl:template match="*[local-name() = 'fmt-preferred'][*[local-name() = 'p']]" mode="update_xml_step1">
14266
14462
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -15075,6 +15271,64 @@
15075
15271
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
15076
15272
  </xsl:template>
15077
15273
 
15274
+ <!-- ===================================== -->
15275
+ <!-- ===================================== -->
15276
+ <!-- Ruby text (CJK languages) rendering -->
15277
+ <!-- ===================================== -->
15278
+ <!-- ===================================== -->
15279
+ <xsl:template match="*[local-name() = 'ruby']">
15280
+ <fo:inline-container text-indent="0mm" last-line-end-indent="0mm">
15281
+ <xsl:if test="not(ancestor::*[local-name() = 'ruby'])">
15282
+ <xsl:attribute name="alignment-baseline">central</xsl:attribute>
15283
+ </xsl:if>
15284
+ <xsl:variable name="rt_text" select="*[local-name() = 'rt']"/>
15285
+ <xsl:variable name="rb_text" select=".//*[local-name() = 'rb'][not(*[local-name() = 'ruby'])]"/>
15286
+ <!-- Example: width="2em" -->
15287
+ <xsl:variable name="text_rt_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rt_text, $font_main, 6)"/>
15288
+ <xsl:variable name="text_rb_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rb_text, $font_main, 10)"/>
15289
+ <xsl:variable name="text_width">
15290
+ <xsl:choose>
15291
+ <xsl:when test="$text_rt_width &gt;= $text_rb_width"><xsl:value-of select="$text_rt_width"/></xsl:when>
15292
+ <xsl:otherwise><xsl:value-of select="$text_rb_width"/></xsl:otherwise>
15293
+ </xsl:choose>
15294
+ </xsl:variable>
15295
+ <xsl:attribute name="width"><xsl:value-of select="$text_width div 10"/>em</xsl:attribute>
15296
+
15297
+ <xsl:choose>
15298
+ <xsl:when test="ancestor::*[local-name() = 'ruby']">
15299
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
15300
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
15301
+ </xsl:when>
15302
+ <xsl:otherwise>
15303
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
15304
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
15305
+ </xsl:otherwise>
15306
+ </xsl:choose>
15307
+
15308
+ <xsl:apply-templates select="node()[not(local-name() = 'rt') and not(local-name() = 'rb')]"/>
15309
+ </fo:inline-container>
15310
+ </xsl:template>
15311
+
15312
+ <xsl:template match="*[local-name() = 'rb']">
15313
+ <fo:block line-height="1em" text-align="center"><xsl:apply-templates/></fo:block>
15314
+ </xsl:template>
15315
+
15316
+ <xsl:template match="*[local-name() = 'rt']">
15317
+ <fo:block font-size="0.5em" text-align="center" line-height="1.2em" space-before="-1.4em" space-before.conditionality="retain"> <!-- -->
15318
+ <xsl:if test="ancestor::*[local-name() = 'ruby'][last()]//*[local-name() = 'ruby'] or ancestor::*[local-name() = 'rb']">
15319
+ <xsl:attribute name="space-before">0em</xsl:attribute>
15320
+ </xsl:if>
15321
+ <xsl:apply-templates/>
15322
+ </fo:block>
15323
+
15324
+ </xsl:template>
15325
+
15326
+ <!-- ===================================== -->
15327
+ <!-- ===================================== -->
15328
+ <!-- END: Ruby text (CJK languages) rendering -->
15329
+ <!-- ===================================== -->
15330
+ <!-- ===================================== -->
15331
+
15078
15332
  <xsl:template name="printEdition">
15079
15333
  <xsl:variable name="edition_i18n" select="normalize-space((//*[local-name() = 'metanorma'])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
15080
15334
 
@@ -15651,6 +15905,24 @@
15651
15905
  </xsl:attribute>
15652
15906
  </xsl:template>
15653
15907
 
15908
+ <xsl:template name="setIDforNamedDestination">
15909
+ <xsl:if test="@named_dest">
15910
+ <xsl:attribute name="id"><xsl:value-of select="@named_dest"/></xsl:attribute>
15911
+ </xsl:if>
15912
+ </xsl:template>
15913
+
15914
+ <xsl:template name="setNamedDestination">
15915
+ <!-- skip GUID, e.g. _33eac3cb-9663-4291-ae26-1d4b6f4635fc -->
15916
+ <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'">
15917
+ <fox:destination internal-destination="{@id}"/>
15918
+ </xsl:if>
15919
+ <xsl:for-each select=". | *[local-name() = 'title'] | *[local-name() = 'name']">
15920
+ <xsl:if test="@named_dest">
15921
+ <fox:destination internal-destination="{@named_dest}"/>
15922
+ </xsl:if>
15923
+ </xsl:for-each>
15924
+ </xsl:template>
15925
+
15654
15926
  <xsl:template name="add-letter-spacing">
15655
15927
  <xsl:param name="text"/>
15656
15928
  <xsl:param name="letter-spacing" select="'0.15'"/>