metanorma-itu 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.
@@ -733,11 +733,11 @@
733
733
  </fo:block>
734
734
  </xsl:if>
735
735
 
736
- <xsl:if test="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[@id='draft-warning']">
736
+ <xsl:if test="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[starts-with(@id, 'draft-warning')]">
737
737
  <fo:block-container margin-left="1mm" margin-right="1mm" border="0.7mm solid black" margin-top="5mm">
738
738
  <fo:block-container margin-left="1mm" margin-right="1mm">
739
739
  <fo:block padding-top="3mm">
740
- <xsl:apply-templates select="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[@id='draft-warning']" mode="caution"/>
740
+ <xsl:apply-templates select="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[starts-with(@id, 'draft-warning')]" mode="caution"/>
741
741
  </fo:block>
742
742
  </fo:block-container>
743
743
  </fo:block-container>
@@ -1354,10 +1354,10 @@
1354
1354
  <fo:block-container>
1355
1355
  <xsl:call-template name="setWritingMode"/>
1356
1356
  <xsl:choose>
1357
- <xsl:when test="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[@id='draft-warning']">
1357
+ <xsl:when test="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[starts-with(@id, 'draft-warning')]">
1358
1358
  <xsl:attribute name="border">0.7mm solid black</xsl:attribute>
1359
1359
  <fo:block font-family="Times New Roman" padding-top="3mm" margin-left="1mm" margin-right="1mm">
1360
- <xsl:apply-templates select="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[@id='draft-warning']" mode="caution"/>
1360
+ <xsl:apply-templates select="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[starts-with(@id, 'draft-warning')]" mode="caution"/>
1361
1361
  </fo:block>
1362
1362
  </xsl:when>
1363
1363
  <xsl:otherwise>
@@ -1375,7 +1375,7 @@
1375
1375
  <fo:block-container>
1376
1376
  <xsl:call-template name="setWritingMode"/>
1377
1377
  <fo:block font-size="16pt" margin-top="3pt">
1378
- <xsl:if test="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[@id='draft-warning']">
1378
+ <xsl:if test="/itu:metanorma/itu:boilerplate/itu:legal-statement/itu:clause[starts-with(@id, 'draft-warning')]">
1379
1379
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
1380
1380
  <xsl:if test="$doctype = 'recommendation-supplement'">
1381
1381
  <xsl:attribute name="margin-top">12pt</xsl:attribute>
@@ -1808,10 +1808,11 @@
1808
1808
  <xsl:if test="$doctype != 'resolution' and $doctype != 'service-publication'">
1809
1809
  <fo:block break-after="page"/>
1810
1810
  <fo:block-container>
1811
- <fo:block role="TOC">
1812
-
1811
+ <fo:block role="SKIP">
1813
1812
  <xsl:apply-templates/>
1813
+ </fo:block>
1814
1814
 
1815
+ <fo:block role="TOC">
1815
1816
  <xsl:if test="count(*) = 1 and *[local-name() = 'title']"> <!-- if there isn't user ToC -->
1816
1817
 
1817
1818
  <xsl:for-each select="$contents/doc[@num = $num]//item[@display = 'true']">
@@ -2159,7 +2160,7 @@
2159
2160
  <!-- ============================= -->
2160
2161
  <!-- ============================= -->
2161
2162
 
2162
- <xsl:template match="itu:clause[@id='draft-warning']/itu:title" mode="caution">
2163
+ <xsl:template match="itu:clause[starts-with(@id, 'draft-warning')]/itu:title" mode="caution">
2163
2164
  <fo:block font-size="16pt" font-style="italic" font-weight="bold" text-align="center" space-after="6pt" role="H1">
2164
2165
  <xsl:if test="$lang = 'ar'"> <!-- to prevent rendering `###` due the missing Arabic glyphs in the italic font (Times New Roman) -->
2165
2166
  <xsl:attribute name="font-style">normal</xsl:attribute>
@@ -2169,7 +2170,7 @@
2169
2170
  </fo:block>
2170
2171
  </xsl:template>
2171
2172
 
2172
- <xsl:template match="itu:clause[@id='draft-warning']/itu:p" mode="caution">
2173
+ <xsl:template match="itu:clause[starts-with(@id, 'draft-warning')]/itu:p" mode="caution">
2173
2174
  <fo:block font-size="12pt" text-align="justify">
2174
2175
  <xsl:apply-templates/>
2175
2176
  <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
@@ -3715,6 +3716,7 @@
3715
3716
  </xsl:template> <!-- refine_table-style -->
3716
3717
 
3717
3718
  <xsl:attribute-set name="table-name-style">
3719
+ <xsl:attribute name="role">Caption</xsl:attribute>
3718
3720
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
3719
3721
 
3720
3722
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -3725,6 +3727,9 @@
3725
3727
 
3726
3728
  <xsl:template name="refine_table-name-style">
3727
3729
  <xsl:param name="continued"/>
3730
+ <xsl:if test="$continued = 'true'">
3731
+ <xsl:attribute name="role">SKIP</xsl:attribute>
3732
+ </xsl:if>
3728
3733
 
3729
3734
  </xsl:template> <!-- refine_table-name-style -->
3730
3735
 
@@ -5400,8 +5405,14 @@
5400
5405
  </xsl:choose>
5401
5406
  </xsl:variable>
5402
5407
 
5408
+ <xsl:call-template name="setNamedDestination"/>
5409
+
5403
5410
  <fo:block-container xsl:use-attribute-sets="table-container-style" role="SKIP">
5404
5411
 
5412
+ <xsl:for-each select="*[local-name() = 'name']">
5413
+ <xsl:call-template name="setIDforNamedDestination"/>
5414
+ </xsl:for-each>
5415
+
5405
5416
  <xsl:call-template name="refine_table-container-style">
5406
5417
  <xsl:with-param name="margin-side" select="$margin-side"/>
5407
5418
  </xsl:call-template>
@@ -5545,7 +5556,7 @@
5545
5556
  </xsl:if>
5546
5557
 
5547
5558
  </fo:block-container>
5548
- </xsl:variable>
5559
+ </xsl:variable> <!-- END: variable name="table" -->
5549
5560
 
5550
5561
  <xsl:variable name="isAdded" select="@added"/>
5551
5562
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -5555,14 +5566,14 @@
5555
5566
 
5556
5567
  <!-- centered table when table name is centered (see table-name-style) -->
5557
5568
 
5558
- <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
5569
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style" role="SKIP">
5559
5570
 
5560
5571
  <fo:table-column column-width="proportional-column-width(1)"/>
5561
5572
  <fo:table-column column-width="{@width}"/>
5562
5573
  <fo:table-column column-width="proportional-column-width(1)"/>
5563
- <fo:table-body>
5564
- <fo:table-row>
5565
- <fo:table-cell column-number="2">
5574
+ <fo:table-body role="SKIP">
5575
+ <fo:table-row role="SKIP">
5576
+ <fo:table-cell column-number="2" role="SKIP">
5566
5577
  <xsl:copy-of select="$table-preamble"/>
5567
5578
  <fo:block role="SKIP">
5568
5579
  <xsl:call-template name="setTrackChangesStyles">
@@ -5603,11 +5614,13 @@
5603
5614
 
5604
5615
  </xsl:template>
5605
5616
 
5617
+ <!-- table/name-->
5606
5618
  <xsl:template match="*[local-name()='table']/*[local-name() = 'name']">
5607
5619
  <xsl:param name="continued"/>
5620
+ <xsl:param name="cols-count"/>
5608
5621
  <xsl:if test="normalize-space() != ''">
5609
5622
 
5610
- <fo:block xsl:use-attribute-sets="table-name-style" role="SKIP">
5623
+ <fo:block xsl:use-attribute-sets="table-name-style">
5611
5624
 
5612
5625
  <xsl:call-template name="refine_table-name-style">
5613
5626
  <xsl:with-param name="continued" select="$continued"/>
@@ -5626,9 +5639,30 @@
5626
5639
 
5627
5640
  <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
5628
5641
  <xsl:if test="$continued = 'true'">
5629
- <fo:block text-align="right">
5630
- <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
5631
- </fo:block>
5642
+
5643
+ <!-- to prevent the error 'THead element may contain only TR elements' -->
5644
+
5645
+ <xsl:choose>
5646
+ <xsl:when test="string(number($cols-count)) != 'NaN'">
5647
+ <fo:table width="100%" table-layout="fixed" role="SKIP">
5648
+ <fo:table-body role="SKIP">
5649
+ <fo:table-row>
5650
+ <fo:table-cell role="TH" number-columns-spanned="{$cols-count}">
5651
+ <fo:block text-align="right" role="SKIP">
5652
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
5653
+ </fo:block>
5654
+ </fo:table-cell>
5655
+ </fo:table-row>
5656
+ </fo:table-body>
5657
+ </fo:table>
5658
+ </xsl:when>
5659
+ <xsl:otherwise>
5660
+ <fo:block text-align="right">
5661
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
5662
+ </fo:block>
5663
+ </xsl:otherwise>
5664
+ </xsl:choose>
5665
+
5632
5666
  </xsl:if>
5633
5667
  <!-- </xsl:if> -->
5634
5668
 
@@ -6021,6 +6055,7 @@
6021
6055
 
6022
6056
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
6023
6057
  <xsl:with-param name="continued">true</xsl:with-param>
6058
+ <xsl:with-param name="cols-count" select="$cols-count"/>
6024
6059
  </xsl:apply-templates>
6025
6060
 
6026
6061
  <xsl:if test="not(ancestor::*[local-name()='table']/*[local-name()='name'])"> <!-- to prevent empty fo:table-cell in case of missing table's name -->
@@ -6084,7 +6119,7 @@
6084
6119
 
6085
6120
  <xsl:variable name="tableWithNotesAndFootnotes">
6086
6121
 
6087
- <fo:table keep-with-previous="always">
6122
+ <fo:table keep-with-previous="always" role="SKIP">
6088
6123
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
6089
6124
  <xsl:variable name="name" select="local-name()"/>
6090
6125
  <xsl:choose>
@@ -6122,9 +6157,9 @@
6122
6157
  </xsl:otherwise>
6123
6158
  </xsl:choose>
6124
6159
 
6125
- <fo:table-body>
6126
- <fo:table-row>
6127
- <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}">
6160
+ <fo:table-body role="SKIP">
6161
+ <fo:table-row role="SKIP">
6162
+ <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}" role="SKIP">
6128
6163
 
6129
6164
  <xsl:call-template name="refine_table-footer-cell-style"/>
6130
6165
 
@@ -6419,8 +6454,8 @@
6419
6454
  <xsl:for-each select="xalan:nodeset($styles__)/item">
6420
6455
  <xsl:variable name="key" select="normalize-space(substring-before(., ':'))"/>
6421
6456
  <xsl:variable name="value" select="normalize-space(substring-after(translate(.,$quot,''), ':'))"/>
6422
- <xsl:if test="$key = 'color' or $key = 'background-color'">
6423
- <style name="{$key}"><xsl:value-of select="$value"/></style>
6457
+ <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'">
6458
+ <style name="{$key}"><xsl:value-of select="java:replaceAll(java:java.lang.String.new($value), 'currentColor', 'inherit')"/></style>
6424
6459
  </xsl:if>
6425
6460
  </xsl:for-each>
6426
6461
  </xsl:variable>
@@ -6484,6 +6519,7 @@
6484
6519
  <!-- table/note, table/example, table/tfoot//note, table/tfoot//example -->
6485
6520
  <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">
6486
6521
 
6522
+ <xsl:call-template name="setNamedDestination"/>
6487
6523
  <fo:block xsl:use-attribute-sets="table-note-style">
6488
6524
  <xsl:copy-of select="@id"/>
6489
6525
 
@@ -6531,6 +6567,7 @@
6531
6567
  <!-- footnotes in text (title, bibliography, main body), not for tables, figures and names --> <!-- table's, figure's names -->
6532
6568
  <!-- fn in text -->
6533
6569
  <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">
6570
+ <xsl:param name="footnote_body_from_table">false</xsl:param>
6534
6571
 
6535
6572
  <!-- list of unique footnotes -->
6536
6573
  <xsl:variable name="p_fn_">
@@ -6596,7 +6633,7 @@
6596
6633
  <xsl:copy-of select="$footnote_inline"/>
6597
6634
  </xsl:when>
6598
6635
  <!-- <xsl:when test="$footnotes//*[local-name() = 'fmt-fn-body'][@id = $ref_id] or normalize-space(@skip_footnote_body) = 'false'"> -->
6599
- <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
6636
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false' or $footnote_body_from_table = 'true'">
6600
6637
 
6601
6638
  <fo:footnote xsl:use-attribute-sets="fn-style" role="SKIP">
6602
6639
  <xsl:copy-of select="$footnote_inline"/>
@@ -7007,39 +7044,51 @@
7007
7044
  <!-- fn reference in the table rendering (for instance, 'some text 1) some text' ) -->
7008
7045
  <!-- fn --> <!-- in table --> <!-- for figure see <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/> -->
7009
7046
  <xsl:template match="*[local-name()='fn']">
7010
- <fo:inline xsl:use-attribute-sets="fn-reference-style">
7011
-
7012
- <xsl:call-template name="refine_fn-reference-style"/>
7047
+ <xsl:variable name="target" select="@target"/>
7048
+ <xsl:choose>
7049
+ <!-- case for footnotes in Requirement tables (https://github.com/metanorma/metanorma-ogc/issues/791) -->
7050
+ <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]">
7051
+ <xsl:call-template name="fn">
7052
+ <xsl:with-param name="footnote_body_from_table">true</xsl:with-param>
7053
+ </xsl:call-template>
7054
+ </xsl:when>
7055
+ <xsl:otherwise>
7013
7056
 
7014
- <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
7015
- <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
7016
- <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
7017
- <!-- <xsl:attribute name="internal-destination">
7018
- <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
7019
- </xsl:attribute>
7020
- </xsl:if>
7021
- <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
7022
- <xsl:attribute name="internal-destination">
7023
- <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
7024
- <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
7025
- </xsl:attribute>
7026
- </xsl:if> -->
7027
- <!-- <xsl:if test="$namespace = 'plateau'">
7028
- <xsl:text>※</xsl:text>
7029
- </xsl:if> -->
7030
- <!-- <xsl:value-of select="@reference"/> -->
7057
+ <fo:inline xsl:use-attribute-sets="fn-reference-style">
7031
7058
 
7032
- <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
7059
+ <xsl:call-template name="refine_fn-reference-style"/>
7033
7060
 
7034
- <!-- <xsl:if test="$namespace = 'bsi'">
7035
- <xsl:text>)</xsl:text>
7036
- </xsl:if> -->
7037
- <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
7038
- <!-- <xsl:if test="$namespace = 'jis'">
7039
- <fo:inline font-weight="normal">)</fo:inline>
7040
- </xsl:if> -->
7041
- </fo:basic-link>
7042
- </fo:inline>
7061
+ <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
7062
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
7063
+ <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
7064
+ <!-- <xsl:attribute name="internal-destination">
7065
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
7066
+ </xsl:attribute>
7067
+ </xsl:if>
7068
+ <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
7069
+ <xsl:attribute name="internal-destination">
7070
+ <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
7071
+ <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
7072
+ </xsl:attribute>
7073
+ </xsl:if> -->
7074
+ <!-- <xsl:if test="$namespace = 'plateau'">
7075
+ <xsl:text>※</xsl:text>
7076
+ </xsl:if> -->
7077
+ <!-- <xsl:value-of select="@reference"/> -->
7078
+
7079
+ <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
7080
+
7081
+ <!-- <xsl:if test="$namespace = 'bsi'">
7082
+ <xsl:text>)</xsl:text>
7083
+ </xsl:if> -->
7084
+ <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
7085
+ <!-- <xsl:if test="$namespace = 'jis'">
7086
+ <fo:inline font-weight="normal">)</fo:inline>
7087
+ </xsl:if> -->
7088
+ </fo:basic-link>
7089
+ </fo:inline>
7090
+ </xsl:otherwise>
7091
+ </xsl:choose>
7043
7092
  </xsl:template> <!-- fn -->
7044
7093
 
7045
7094
  <!-- fn/text() -->
@@ -7128,6 +7177,10 @@
7128
7177
  <!-- <dl><xsl:copy-of select="."/></dl> -->
7129
7178
  <fo:block-container xsl:use-attribute-sets="dl-block-style" role="SKIP">
7130
7179
 
7180
+ <xsl:if test="@key = 'true' and ancestor::*[local-name() = 'figure']">
7181
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
7182
+ </xsl:if>
7183
+
7131
7184
  <xsl:call-template name="setBlockSpanAll"/>
7132
7185
 
7133
7186
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
@@ -7421,7 +7474,7 @@
7421
7474
 
7422
7475
  <!-- caption for figure key and another caption, https://github.com/metanorma/isodoc/issues/607 -->
7423
7476
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'p'][@keep-with-next = 'true' and *[local-name() = 'strong']]" priority="3">
7424
- <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always">
7477
+ <fo:block text-align="left" margin-bottom="12pt" keep-with-next="always" keep-with-previous="always">
7425
7478
  <xsl:call-template name="refine_figure_key_style"/>
7426
7479
  <xsl:apply-templates/>
7427
7480
  </fo:block>
@@ -7678,6 +7731,7 @@
7678
7731
 
7679
7732
  <xsl:call-template name="refine_dt-cell-style"/>
7680
7733
 
7734
+ <xsl:call-template name="setNamedDestination"/>
7681
7735
  <fo:block xsl:use-attribute-sets="dt-block-style" role="SKIP">
7682
7736
 
7683
7737
  <xsl:choose>
@@ -8118,7 +8172,7 @@
8118
8172
  <!-- ================= -->
8119
8173
 
8120
8174
  <!-- highlight text -->
8121
- <xsl:template match="*[local-name()='hi']">
8175
+ <xsl:template match="*[local-name()='hi'] | *[local-name() = 'span'][@class = 'fmt-hi']" priority="3">
8122
8176
  <fo:inline background-color="yellow">
8123
8177
  <xsl:apply-templates/>
8124
8178
  </fo:inline>
@@ -9713,6 +9767,7 @@
9713
9767
  <!-- Appendix processing -->
9714
9768
  <!-- ======================== -->
9715
9769
  <xsl:template match="*[local-name()='appendix']">
9770
+ <xsl:call-template name="setNamedDestination"/>
9716
9771
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-style">
9717
9772
  <xsl:apply-templates select="*[local-name()='title']"/>
9718
9773
  </fo:block>
@@ -9723,13 +9778,14 @@
9723
9778
  <xsl:variable name="level">
9724
9779
  <xsl:call-template name="getLevel"/>
9725
9780
  </xsl:variable>
9726
- <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
9781
+ <fo:inline role="H{$level}"><xsl:call-template name="setIDforNamedDestination"/><xsl:apply-templates/></fo:inline>
9727
9782
  </xsl:template>
9728
9783
  <!-- ======================== -->
9729
9784
  <!-- END Appendix processing -->
9730
9785
  <!-- ======================== -->
9731
9786
 
9732
9787
  <xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
9788
+ <xsl:call-template name="setNamedDestination"/>
9733
9789
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
9734
9790
  <xsl:apply-templates select="*[local-name()='name']"/>
9735
9791
  </fo:block>
@@ -9759,6 +9815,7 @@
9759
9815
  <xsl:template match="*[local-name() = 'annotation']/*[local-name() = 'p']">
9760
9816
  <xsl:param name="callout"/>
9761
9817
  <fo:inline id="{@id}">
9818
+ <xsl:call-template name="setNamedDestination"/>
9762
9819
  <!-- for first p in annotation, put <x> -->
9763
9820
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
9764
9821
  <xsl:apply-templates/>
@@ -9805,6 +9862,7 @@
9805
9862
 
9806
9863
  </xsl:if>
9807
9864
  <fo:block-container margin-left="0mm" role="SKIP">
9865
+ <xsl:call-template name="setNamedDestination"/>
9808
9866
  <fo:block id="{@id}">
9809
9867
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/> <!-- formula's number will be process in 'stem' template -->
9810
9868
  </fo:block>
@@ -9850,8 +9908,13 @@
9850
9908
  </fo:block>
9851
9909
  </fo:table-cell>
9852
9910
  <fo:table-cell display-align="center">
9911
+
9853
9912
  <fo:block xsl:use-attribute-sets="formula-stem-number-style" role="SKIP">
9854
9913
 
9914
+ <xsl:for-each select="../*[local-name() = 'name']">
9915
+ <xsl:call-template name="setIDforNamedDestination"/>
9916
+ </xsl:for-each>
9917
+
9855
9918
  <xsl:call-template name="refine_formula-stem-number-style"/>
9856
9919
 
9857
9920
  <xsl:apply-templates select="../*[local-name() = 'name']"/>
@@ -9886,6 +9949,8 @@
9886
9949
 
9887
9950
  <xsl:template match="*[local-name() = 'note']" name="note">
9888
9951
 
9952
+ <xsl:call-template name="setNamedDestination"/>
9953
+
9889
9954
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style" role="SKIP">
9890
9955
 
9891
9956
  <xsl:call-template name="setBlockSpanAll"/>
@@ -9954,6 +10019,7 @@
9954
10019
  </xsl:template>
9955
10020
 
9956
10021
  <xsl:template match="*[local-name() = 'termnote']">
10022
+ <xsl:call-template name="setNamedDestination"/>
9957
10023
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
9958
10024
 
9959
10025
  <xsl:call-template name="setBlockSpanAll"/>
@@ -10060,12 +10126,14 @@
10060
10126
 
10061
10127
  <xsl:template match="*[local-name() = 'terms']">
10062
10128
  <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
10129
+ <xsl:call-template name="setNamedDestination"/>
10063
10130
  <fo:block id="{@id}">
10064
10131
  <xsl:apply-templates/>
10065
10132
  </fo:block>
10066
10133
  </xsl:template>
10067
10134
 
10068
10135
  <xsl:template match="*[local-name() = 'term']">
10136
+ <xsl:call-template name="setNamedDestination"/>
10069
10137
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
10070
10138
 
10071
10139
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'term'])">
@@ -10097,6 +10165,7 @@
10097
10165
  <xsl:template match="*[local-name() = 'figure']" name="figure">
10098
10166
  <xsl:variable name="isAdded" select="@added"/>
10099
10167
  <xsl:variable name="isDeleted" select="@deleted"/>
10168
+ <xsl:call-template name="setNamedDestination"/>
10100
10169
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
10101
10170
  <xsl:call-template name="refine_figure-block-style"/>
10102
10171
 
@@ -10113,6 +10182,11 @@
10113
10182
  </xsl:variable>
10114
10183
 
10115
10184
  <fo:block xsl:use-attribute-sets="figure-style" role="SKIP">
10185
+
10186
+ <xsl:for-each select="*[local-name() = 'name']"> <!-- set context -->
10187
+ <xsl:call-template name="setIDforNamedDestination"/>
10188
+ </xsl:for-each>
10189
+
10116
10190
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
10117
10191
  </fo:block>
10118
10192
 
@@ -10145,6 +10219,7 @@
10145
10219
  </xsl:template>
10146
10220
 
10147
10221
  <xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']">
10222
+ <xsl:call-template name="setNamedDestination"/>
10148
10223
  <fo:block id="{@id}">
10149
10224
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
10150
10225
  </fo:block>
@@ -10158,6 +10233,7 @@
10158
10233
  </xsl:template>
10159
10234
 
10160
10235
  <!-- SOURCE: ... -->
10236
+ <!-- figure/source -->
10161
10237
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'source']" priority="2">
10162
10238
 
10163
10239
  <xsl:call-template name="termsource"/>
@@ -11083,6 +11159,13 @@
11083
11159
  <xsl:apply-templates select="."/>
11084
11160
  </xsl:template>
11085
11161
 
11162
+ <!-- prevent missing stem for table and figures in ToC -->
11163
+ <xsl:template match="*[local-name() = 'name' or local-name() = 'fmt-name']//*[local-name() = 'stem']" mode="contents">
11164
+ <xsl:if test="not(following-sibling::*[1][local-name() = 'fmt-stem'])">
11165
+ <xsl:apply-templates select="."/>
11166
+ </xsl:if>
11167
+ </xsl:template>
11168
+
11086
11169
  <xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/>
11087
11170
 
11088
11171
  <xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/>
@@ -11306,7 +11389,8 @@
11306
11389
 
11307
11390
  <xsl:for-each select="$contents_nodes//tables/table">
11308
11391
  <fo:bookmark internal-destination="{@id}">
11309
- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
11392
+ <!-- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title> -->
11393
+ <fo:bookmark-title><xsl:apply-templates mode="bookmark_clean"/></fo:bookmark-title>
11310
11394
  </fo:bookmark>
11311
11395
  </xsl:for-each>
11312
11396
  </fo:bookmark>
@@ -11315,6 +11399,26 @@
11315
11399
  </xsl:template> <!-- insertTableBookmarks -->
11316
11400
  <!-- End Bookmarks -->
11317
11401
 
11402
+ <!-- ============================ -->
11403
+ <!-- mode="bookmark_clean" -->
11404
+ <!-- ============================ -->
11405
+ <xsl:template match="node()" mode="bookmark_clean">
11406
+ <xsl:apply-templates select="node()" mode="bookmark_clean"/>
11407
+ </xsl:template>
11408
+
11409
+ <xsl:template match="text()" mode="bookmark_clean">
11410
+ <xsl:value-of select="."/>
11411
+ </xsl:template>
11412
+
11413
+ <xsl:template match="*[local-name() = 'math']" mode="bookmark_clean">
11414
+ <xsl:value-of select="normalize-space(.)"/>
11415
+ </xsl:template>
11416
+
11417
+ <xsl:template match="*[local-name() = 'asciimath']" mode="bookmark_clean"/>
11418
+ <!-- ============================ -->
11419
+ <!-- END: mode="bookmark_clean" -->
11420
+ <!-- ============================ -->
11421
+
11318
11422
  <xsl:template name="getLangVersion">
11319
11423
  <xsl:param name="lang"/>
11320
11424
  <xsl:param name="doctype" select="''"/>
@@ -11362,6 +11466,7 @@
11362
11466
  <xsl:template match="title" mode="bookmark"/>
11363
11467
  <xsl:template match="text()" mode="bookmark"/>
11364
11468
 
11469
+ <!-- figure/name -->
11365
11470
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'image']/*[local-name() = 'name']">
11366
11471
  <xsl:if test="normalize-space() != ''">
11367
11472
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -12078,6 +12183,7 @@
12078
12183
  <!-- permission -->
12079
12184
  <!-- ========== -->
12080
12185
  <xsl:template match="*[local-name() = 'permission']">
12186
+ <xsl:call-template name="setNamedDestination"/>
12081
12187
  <fo:block id="{@id}" xsl:use-attribute-sets="permission-style">
12082
12188
  <xsl:apply-templates select="*[local-name()='name']"/>
12083
12189
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -12086,10 +12192,12 @@
12086
12192
 
12087
12193
  <xsl:template match="*[local-name() = 'permission']/*[local-name() = 'name']">
12088
12194
  <xsl:if test="normalize-space() != ''">
12089
- <fo:block xsl:use-attribute-sets="permission-name-style">
12090
- <xsl:apply-templates/>
12091
12195
 
12092
- </fo:block>
12196
+ <fo:block xsl:use-attribute-sets="permission-name-style">
12197
+ <xsl:apply-templates/>
12198
+
12199
+ </fo:block>
12200
+
12093
12201
  </xsl:if>
12094
12202
  </xsl:template>
12095
12203
 
@@ -12105,6 +12213,7 @@
12105
12213
  <!-- requirement -->
12106
12214
  <!-- ========== -->
12107
12215
  <xsl:template match="*[local-name() = 'requirement']">
12216
+ <xsl:call-template name="setNamedDestination"/>
12108
12217
  <fo:block id="{@id}" xsl:use-attribute-sets="requirement-style">
12109
12218
  <xsl:apply-templates select="*[local-name()='name']"/>
12110
12219
  <xsl:apply-templates select="*[local-name()='label']"/>
@@ -12116,11 +12225,13 @@
12116
12225
 
12117
12226
  <xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'name']">
12118
12227
  <xsl:if test="normalize-space() != ''">
12119
- <fo:block xsl:use-attribute-sets="requirement-name-style">
12120
12228
 
12121
- <xsl:apply-templates/>
12229
+ <fo:block xsl:use-attribute-sets="requirement-name-style">
12230
+
12231
+ <xsl:apply-templates/>
12232
+
12233
+ </fo:block>
12122
12234
 
12123
- </fo:block>
12124
12235
  </xsl:if>
12125
12236
  </xsl:template>
12126
12237
 
@@ -12149,6 +12260,7 @@
12149
12260
  <!-- recommendation -->
12150
12261
  <!-- ========== -->
12151
12262
  <xsl:template match="*[local-name() = 'recommendation']">
12263
+ <xsl:call-template name="setNamedDestination"/>
12152
12264
  <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">
12153
12265
  <xsl:apply-templates select="*[local-name()='name']"/>
12154
12266
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
@@ -12157,10 +12269,12 @@
12157
12269
 
12158
12270
  <xsl:template match="*[local-name() = 'recommendation']/*[local-name() = 'name']">
12159
12271
  <xsl:if test="normalize-space() != ''">
12160
- <fo:block xsl:use-attribute-sets="recommendation-name-style">
12161
- <xsl:apply-templates/>
12162
12272
 
12163
- </fo:block>
12273
+ <fo:block xsl:use-attribute-sets="recommendation-name-style">
12274
+ <xsl:apply-templates/>
12275
+
12276
+ </fo:block>
12277
+
12164
12278
  </xsl:if>
12165
12279
  </xsl:template>
12166
12280
 
@@ -12239,6 +12353,7 @@
12239
12353
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
12240
12354
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
12241
12355
  </xsl:if>
12356
+ <xsl:call-template name="setNamedDestination"/>
12242
12357
  <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP">
12243
12358
  <fo:table id="{@id}" table-layout="fixed" width="100%"> <!-- border="1pt solid black" -->
12244
12359
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
@@ -12348,6 +12463,7 @@
12348
12463
  <!-- termexample -->
12349
12464
  <!-- ====== -->
12350
12465
  <xsl:template match="*[local-name() = 'termexample']">
12466
+ <xsl:call-template name="setNamedDestination"/>
12351
12467
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
12352
12468
  <xsl:call-template name="refine_termexample-style"/>
12353
12469
  <xsl:call-template name="setBlockSpanAll"/>
@@ -12402,6 +12518,7 @@
12402
12518
  -->
12403
12519
  <xsl:template match="*[local-name() = 'example']" name="example">
12404
12520
 
12521
+ <xsl:call-template name="setNamedDestination"/>
12405
12522
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style" role="SKIP">
12406
12523
 
12407
12524
  <xsl:call-template name="setBlockSpanAll"/>
@@ -12919,8 +13036,13 @@
12919
13036
  <fo:block font-size="{normalize-space($font-size)}" role="H{$levelTerm}" xsl:use-attribute-sets="preferred-block-style">
12920
13037
 
12921
13038
  <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'preferred'])"> <!-- if first preffered in term, then display term's name -->
13039
+
12922
13040
  <fo:block xsl:use-attribute-sets="term-name-style" role="SKIP">
12923
13041
 
13042
+ <xsl:for-each select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"><!-- change context -->
13043
+ <xsl:call-template name="setIDforNamedDestination"/>
13044
+ </xsl:for-each>
13045
+
12924
13046
  <xsl:apply-templates select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"/>
12925
13047
  </fo:block>
12926
13048
  </xsl:if>
@@ -13040,6 +13162,7 @@
13040
13162
  <!-- main sections -->
13041
13163
  <xsl:template match="/*/*[local-name() = 'sections']/*" name="sections_node" priority="2">
13042
13164
 
13165
+ <xsl:call-template name="setNamedDestination"/>
13043
13166
  <fo:block>
13044
13167
  <xsl:call-template name="setId"/>
13045
13168
 
@@ -13087,6 +13210,7 @@
13087
13210
 
13088
13211
  <fo:block break-after="page"/>
13089
13212
 
13213
+ <xsl:call-template name="setNamedDestination"/>
13090
13214
  <fo:block>
13091
13215
  <xsl:call-template name="setId"/>
13092
13216
  <xsl:call-template name="addReviewHelper"/>
@@ -13115,6 +13239,7 @@
13115
13239
  </xsl:template>
13116
13240
 
13117
13241
  <xsl:template match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty -->
13242
+ <xsl:call-template name="setNamedDestination"/>
13118
13243
  <fo:block>
13119
13244
  <xsl:if test="parent::*[local-name() = 'copyright-statement']">
13120
13245
  <xsl:attribute name="role">SKIP</xsl:attribute>
@@ -13141,6 +13266,7 @@
13141
13266
  </xsl:template> <!-- refine_clause_style -->
13142
13267
 
13143
13268
  <xsl:template match="*[local-name() = 'definitions']">
13269
+ <xsl:call-template name="setNamedDestination"/>
13144
13270
  <fo:block id="{@id}">
13145
13271
  <xsl:apply-templates/>
13146
13272
  </fo:block>
@@ -13156,6 +13282,8 @@
13156
13282
  <xsl:otherwise>
13157
13283
 
13158
13284
  <fo:block break-after="page"/>
13285
+ <xsl:call-template name="setNamedDestination"/>
13286
+
13159
13287
  <fo:block id="{@id}">
13160
13288
 
13161
13289
  <xsl:call-template name="setBlockSpanAll"/>
@@ -13227,6 +13355,7 @@
13227
13355
  <!-- following-sibling::node()[1][local-name() = 'bookmark'][@id = $source] and
13228
13356
  following-sibling::node()[2][local-name() = 'fmt-review-end'][@source = $source] -->
13229
13357
  <!-- <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> -->
13358
+ <xsl:call-template name="setNamedDestination"/>
13230
13359
  <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>
13231
13360
  <!-- </xsl:if> -->
13232
13361
  </xsl:if>
@@ -13328,9 +13457,15 @@
13328
13457
  <xsl:when test="local-name(..) = 'ul'">
13329
13458
  <xsl:choose>
13330
13459
  <xsl:when test="normalize-space($processing_instruction_type) = 'simple'"/>
13460
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
13461
+ <xsl:when test="@label"><xsl:value-of select="@label"/></xsl:when>
13331
13462
  <xsl:otherwise><xsl:call-template name="setULLabel"/></xsl:otherwise>
13332
13463
  </xsl:choose>
13333
13464
  </xsl:when>
13465
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
13466
+ <xsl:when test="local-name(..) = 'ol' and @label and @full = 'true'"> <!-- @full added in the template li/fmt-name -->
13467
+ <xsl:value-of select="@label"/>
13468
+ </xsl:when>
13334
13469
  <xsl:when test="local-name(..) = 'ol' and @label"> <!-- for ordered lists 'ol', and if there is @label, for instance label="1.1.2" -->
13335
13470
 
13336
13471
  <xsl:variable name="type" select="../@type"/>
@@ -13455,7 +13590,7 @@
13455
13590
 
13456
13591
  </xsl:otherwise>
13457
13592
  </xsl:choose>
13458
- </xsl:template>
13593
+ </xsl:template> <!-- getListItemFormat -->
13459
13594
 
13460
13595
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
13461
13596
  <xsl:param name="indent">0</xsl:param>
@@ -13587,6 +13722,11 @@
13587
13722
 
13588
13723
  <xsl:call-template name="refine_list-item-label-style"/>
13589
13724
 
13725
+ <xsl:if test="local-name(..) = 'ul'">
13726
+ <xsl:variable name="li_label" select="@label"/>
13727
+ <xsl:copy-of select="$ul_labels//label[. = $li_label]/@*[not(local-name() = 'level')]"/>
13728
+ </xsl:if>
13729
+
13590
13730
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
13591
13731
  <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
13592
13732
  <xsl:call-template name="append_add-style"/>
@@ -13933,6 +14073,7 @@
13933
14073
  <!-- Normative references -->
13934
14074
  <xsl:template match="*[local-name() = 'references'][@normative='true']" priority="2">
13935
14075
 
14076
+ <xsl:call-template name="setNamedDestination"/>
13936
14077
  <fo:block id="{@id}">
13937
14078
  <xsl:apply-templates/>
13938
14079
 
@@ -13953,6 +14094,7 @@
13953
14094
  </xsl:if>
13954
14095
  </xsl:if> -->
13955
14096
 
14097
+ <xsl:call-template name="setNamedDestination"/>
13956
14098
  <fo:block id="{@id}"/>
13957
14099
 
13958
14100
  <xsl:apply-templates select="*[local-name() = 'title'][@columns = 1]"/>
@@ -13975,6 +14117,7 @@
13975
14117
  <xsl:choose>
13976
14118
  <xsl:when test="$skip = 'true'"><!-- skip bibitem --></xsl:when>
13977
14119
  <xsl:otherwise>
14120
+ <xsl:call-template name="setNamedDestination"/>
13978
14121
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-normative-style">
13979
14122
  <xsl:call-template name="processBibitem"/>
13980
14123
  </fo:block>
@@ -13990,6 +14133,7 @@
13990
14133
  <xsl:choose>
13991
14134
  <xsl:when test="$skip = 'true'"><!-- skip bibitem --></xsl:when>
13992
14135
  <xsl:otherwise>
14136
+ <xsl:call-template name="setNamedDestination"/>
13993
14137
  <fo:block id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-style">
13994
14138
  <xsl:call-template name="processBibitem"/>
13995
14139
  </fo:block>
@@ -14002,6 +14146,7 @@
14002
14146
  <xsl:choose>
14003
14147
  <xsl:when test="@hidden = 'true'"><!-- skip --></xsl:when>
14004
14148
  <xsl:otherwise>
14149
+ <xsl:call-template name="setNamedDestination"/>
14005
14150
  <fo:list-item id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-item-style">
14006
14151
 
14007
14152
  <fo:list-item-label end-indent="label-end()">
@@ -14446,6 +14591,7 @@
14446
14591
  <xsl:template match="*[local-name() = 'admonition']">
14447
14592
 
14448
14593
  <!-- text in the box -->
14594
+ <xsl:call-template name="setNamedDestination"/>
14449
14595
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
14450
14596
 
14451
14597
  <xsl:call-template name="setBlockSpanAll"/>
@@ -14702,7 +14848,7 @@
14702
14848
  </xsl:template>
14703
14849
 
14704
14850
  <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
14705
- <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">
14851
+ <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">
14706
14852
  <xsl:copy>
14707
14853
  <xsl:copy-of select="@*"/>
14708
14854
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -14734,28 +14880,56 @@
14734
14880
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_step1"/>
14735
14881
  <xsl:template match="*[local-name() = 'stem']" mode="update_xml_pres"/>
14736
14882
 
14737
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_step1">
14883
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_step1">
14738
14884
  <xsl:element name="stem" namespace="{$namespace_full}">
14739
14885
  <xsl:copy-of select="@*"/>
14740
14886
  <xsl:choose>
14741
14887
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
14742
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14888
+ <xsl:choose>
14889
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14890
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14891
+ </xsl:when>
14892
+ <xsl:otherwise>
14893
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_step1"/>
14894
+ </xsl:otherwise>
14895
+ </xsl:choose>
14743
14896
  </xsl:when>
14744
14897
  <xsl:otherwise>
14745
- <xsl:copy-of select="node()"/>
14898
+ <xsl:choose>
14899
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14900
+ <xsl:copy-of select="node()"/>
14901
+ </xsl:when>
14902
+ <xsl:otherwise>
14903
+ <xsl:apply-templates select="node()" mode="update_xml_step1"/>
14904
+ </xsl:otherwise>
14905
+ </xsl:choose>
14746
14906
  </xsl:otherwise>
14747
14907
  </xsl:choose>
14748
14908
  </xsl:element>
14749
14909
  </xsl:template>
14750
- <xsl:template match="*[local-name() = 'fmt-stem'][not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])]" mode="update_xml_pres">
14910
+ <xsl:template match="*[local-name() = 'fmt-stem']" mode="update_xml_pres">
14751
14911
  <xsl:element name="stem" namespace="{$namespace_full}">
14752
14912
  <xsl:copy-of select="@*"/>
14753
14913
  <xsl:choose>
14754
14914
  <xsl:when test="*[local-name() = 'semx'] and count(node()) = 1">
14755
- <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14915
+ <xsl:choose>
14916
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14917
+ <xsl:copy-of select="*[local-name() = 'semx']/node()"/>
14918
+ </xsl:when>
14919
+ <xsl:otherwise>
14920
+ <xsl:apply-templates select="*[local-name() = 'semx']/node()" mode="update_xml_pres"/>
14921
+ </xsl:otherwise>
14922
+ </xsl:choose>
14756
14923
  </xsl:when>
14757
14924
  <xsl:otherwise>
14758
- <xsl:copy-of select="node()"/>
14925
+ <xsl:choose>
14926
+ <xsl:when test="not(.//*[local-name() = 'passthrough']) and not(.//*[@linebreak])">
14927
+ <xsl:copy-of select="node()"/>
14928
+ </xsl:when>
14929
+ <xsl:otherwise>
14930
+ <xsl:apply-templates select="node()" mode="update_xml_pres"/>
14931
+ </xsl:otherwise>
14932
+ </xsl:choose>
14759
14933
  </xsl:otherwise>
14760
14934
  </xsl:choose>
14761
14935
  </xsl:element>
@@ -14984,16 +15158,24 @@
14984
15158
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_step1">
14985
15159
  <xsl:element name="title" namespace="{$namespace_full}">
14986
15160
  <xsl:copy-of select="@*"/>
15161
+ <xsl:call-template name="addNamedDestinationAttribute"/>
15162
+
14987
15163
  <xsl:apply-templates mode="update_xml_step1"/>
14988
15164
  </xsl:element>
14989
15165
  </xsl:template>
14990
15166
  <xsl:template match="*[local-name() = 'fmt-title']" mode="update_xml_pres">
14991
15167
  <xsl:element name="title" namespace="{$namespace_full}">
14992
15168
  <xsl:copy-of select="@*"/>
15169
+ <xsl:call-template name="addNamedDestinationAttribute"/>
15170
+
14993
15171
  <xsl:apply-templates mode="update_xml_pres"/>
14994
15172
  </xsl:element>
14995
15173
  </xsl:template>
14996
15174
 
15175
+ <xsl:template name="addNamedDestinationAttribute">
15176
+
15177
+ </xsl:template>
15178
+
14997
15179
  <xsl:template match="*[local-name() = 'fmt-name']"/>
14998
15180
  <xsl:template match="*[local-name() = 'fmt-name']" mode="update_xml_step1">
14999
15181
  <xsl:choose>
@@ -15003,6 +15185,8 @@
15003
15185
  <xsl:otherwise>
15004
15186
  <xsl:element name="name" namespace="{$namespace_full}">
15005
15187
  <xsl:copy-of select="@*"/>
15188
+ <xsl:call-template name="addNamedDestinationAttribute"/>
15189
+
15006
15190
  <xsl:apply-templates mode="update_xml_step1"/>
15007
15191
  </xsl:element>
15008
15192
  </xsl:otherwise>
@@ -15016,12 +15200,24 @@
15016
15200
  <xsl:otherwise>
15017
15201
  <xsl:element name="name" namespace="{$namespace_full}">
15018
15202
  <xsl:copy-of select="@*"/>
15203
+ <xsl:call-template name="addNamedDestinationAttribute"/>
15204
+
15019
15205
  <xsl:apply-templates mode="update_xml_pres"/>
15020
15206
  </xsl:element>
15021
15207
  </xsl:otherwise>
15022
15208
  </xsl:choose>
15023
15209
  </xsl:template>
15024
15210
 
15211
+ <!-- li/fmt-name -->
15212
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_step1">
15213
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
15214
+ <xsl:attribute name="full">true</xsl:attribute>
15215
+ </xsl:template>
15216
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_pres">
15217
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
15218
+ <xsl:attribute name="full">true</xsl:attribute>
15219
+ </xsl:template>
15220
+
15025
15221
  <xsl:template match="*[local-name() = 'fmt-preferred']"/>
15026
15222
  <xsl:template match="*[local-name() = 'fmt-preferred'][*[local-name() = 'p']]" mode="update_xml_step1">
15027
15223
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -15836,6 +16032,64 @@
15836
16032
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
15837
16033
  </xsl:template>
15838
16034
 
16035
+ <!-- ===================================== -->
16036
+ <!-- ===================================== -->
16037
+ <!-- Ruby text (CJK languages) rendering -->
16038
+ <!-- ===================================== -->
16039
+ <!-- ===================================== -->
16040
+ <xsl:template match="*[local-name() = 'ruby']">
16041
+ <fo:inline-container text-indent="0mm" last-line-end-indent="0mm">
16042
+ <xsl:if test="not(ancestor::*[local-name() = 'ruby'])">
16043
+ <xsl:attribute name="alignment-baseline">central</xsl:attribute>
16044
+ </xsl:if>
16045
+ <xsl:variable name="rt_text" select="*[local-name() = 'rt']"/>
16046
+ <xsl:variable name="rb_text" select=".//*[local-name() = 'rb'][not(*[local-name() = 'ruby'])]"/>
16047
+ <!-- Example: width="2em" -->
16048
+ <xsl:variable name="text_rt_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rt_text, $font_main, 6)"/>
16049
+ <xsl:variable name="text_rb_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rb_text, $font_main, 10)"/>
16050
+ <xsl:variable name="text_width">
16051
+ <xsl:choose>
16052
+ <xsl:when test="$text_rt_width &gt;= $text_rb_width"><xsl:value-of select="$text_rt_width"/></xsl:when>
16053
+ <xsl:otherwise><xsl:value-of select="$text_rb_width"/></xsl:otherwise>
16054
+ </xsl:choose>
16055
+ </xsl:variable>
16056
+ <xsl:attribute name="width"><xsl:value-of select="$text_width div 10"/>em</xsl:attribute>
16057
+
16058
+ <xsl:choose>
16059
+ <xsl:when test="ancestor::*[local-name() = 'ruby']">
16060
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
16061
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
16062
+ </xsl:when>
16063
+ <xsl:otherwise>
16064
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
16065
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
16066
+ </xsl:otherwise>
16067
+ </xsl:choose>
16068
+
16069
+ <xsl:apply-templates select="node()[not(local-name() = 'rt') and not(local-name() = 'rb')]"/>
16070
+ </fo:inline-container>
16071
+ </xsl:template>
16072
+
16073
+ <xsl:template match="*[local-name() = 'rb']">
16074
+ <fo:block line-height="1em" text-align="center"><xsl:apply-templates/></fo:block>
16075
+ </xsl:template>
16076
+
16077
+ <xsl:template match="*[local-name() = 'rt']">
16078
+ <fo:block font-size="0.5em" text-align="center" line-height="1.2em" space-before="-1.4em" space-before.conditionality="retain"> <!-- -->
16079
+ <xsl:if test="ancestor::*[local-name() = 'ruby'][last()]//*[local-name() = 'ruby'] or ancestor::*[local-name() = 'rb']">
16080
+ <xsl:attribute name="space-before">0em</xsl:attribute>
16081
+ </xsl:if>
16082
+ <xsl:apply-templates/>
16083
+ </fo:block>
16084
+
16085
+ </xsl:template>
16086
+
16087
+ <!-- ===================================== -->
16088
+ <!-- ===================================== -->
16089
+ <!-- END: Ruby text (CJK languages) rendering -->
16090
+ <!-- ===================================== -->
16091
+ <!-- ===================================== -->
16092
+
15839
16093
  <xsl:template name="printEdition">
15840
16094
  <xsl:variable name="edition_i18n" select="normalize-space((//*[local-name() = 'metanorma'])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
15841
16095
 
@@ -16405,6 +16659,24 @@
16405
16659
  </xsl:attribute>
16406
16660
  </xsl:template>
16407
16661
 
16662
+ <xsl:template name="setIDforNamedDestination">
16663
+ <xsl:if test="@named_dest">
16664
+ <xsl:attribute name="id"><xsl:value-of select="@named_dest"/></xsl:attribute>
16665
+ </xsl:if>
16666
+ </xsl:template>
16667
+
16668
+ <xsl:template name="setNamedDestination">
16669
+ <!-- skip GUID, e.g. _33eac3cb-9663-4291-ae26-1d4b6f4635fc -->
16670
+ <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'">
16671
+ <fox:destination internal-destination="{@id}"/>
16672
+ </xsl:if>
16673
+ <xsl:for-each select=". | *[local-name() = 'title'] | *[local-name() = 'name']">
16674
+ <xsl:if test="@named_dest">
16675
+ <fox:destination internal-destination="{@named_dest}"/>
16676
+ </xsl:if>
16677
+ </xsl:for-each>
16678
+ </xsl:template>
16679
+
16408
16680
  <xsl:template name="add-letter-spacing">
16409
16681
  <xsl:param name="text"/>
16410
16682
  <xsl:param name="letter-spacing" select="'0.15'"/>