metanorma-itu 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
- <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
5
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure' or local-name() = 'localized-strings')] and not(ancestor::*[local-name() = 'name']))]" use="@reference"/>
6
6
 
7
7
  <xsl:variable name="debug">false</xsl:variable>
8
8
 
@@ -4667,7 +4667,7 @@
4667
4667
  </fn>
4668
4668
  -->
4669
4669
  <!-- footnotes in text (title, bibliography, main body, table's, figure's names), not for tables, figures -->
4670
- <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">
4670
+ <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">
4671
4671
 
4672
4672
  <!-- list of footnotes to calculate actual footnotes number -->
4673
4673
  <xsl:variable name="p_fn_">
@@ -4724,8 +4724,7 @@
4724
4724
  </fo:basic-link>
4725
4725
  </fo:inline>
4726
4726
  </xsl:variable>
4727
- <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
4728
- gen_id=<xsl:value-of select="$gen_id"/> -->
4727
+
4729
4728
  <xsl:choose>
4730
4729
  <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
4731
4730
  <xsl:copy-of select="$footnote_inline"/>
@@ -4784,7 +4783,7 @@
4784
4783
  <!-- commented:
4785
4784
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
4786
4785
  because 'fn' there is in biblio-tag -->
4787
- <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4786
+ <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4788
4787
  <!-- copy unique fn -->
4789
4788
  <fn gen_id="{generate-id(.)}">
4790
4789
  <xsl:copy-of select="@*"/>
@@ -7350,7 +7349,9 @@
7350
7349
 
7351
7350
  <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7352
7351
  <xsl:if test="number($scale) &lt; 100">
7353
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7352
+
7353
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7354
+
7354
7355
  </xsl:if>
7355
7356
 
7356
7357
  </xsl:if>
@@ -8365,6 +8366,12 @@
8365
8366
  </xsl:attribute>
8366
8367
  </xsl:for-each>
8367
8368
 
8369
+ <!-- remove margin between rows in the table with sourcecode line numbers -->
8370
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']">
8371
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8372
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8373
+ </xsl:if>
8374
+
8368
8375
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8369
8376
  </fo:block>
8370
8377
 
@@ -8413,7 +8420,7 @@
8413
8420
  </xsl:template>
8414
8421
 
8415
8422
  <!-- outer table with line numbers for sourcecode -->
8416
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
8423
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] | -->
8417
8424
  <fo:block>
8418
8425
  <fo:table width="100%" table-layout="fixed">
8419
8426
  <xsl:copy-of select="@id"/>
@@ -8425,16 +8432,16 @@
8425
8432
  </fo:table>
8426
8433
  </fo:block>
8427
8434
  </xsl:template>
8428
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
8435
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']/*[local-name() = 'tbody']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody'] | -->
8429
8436
  <xsl:apply-templates/>
8430
8437
  </xsl:template>
8431
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
8438
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr'] | -->
8432
8439
  <fo:table-row>
8433
8440
  <xsl:apply-templates/>
8434
8441
  </fo:table-row>
8435
8442
  </xsl:template>
8436
8443
  <!-- first td with line numbers -->
8437
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
8444
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8438
8445
  <fo:table-cell>
8439
8446
  <fo:block>
8440
8447
 
@@ -8454,8 +8461,9 @@
8454
8461
  </fo:block>
8455
8462
  </fo:table-cell>
8456
8463
  </xsl:template>
8464
+
8457
8465
  <!-- second td with sourcecode -->
8458
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
8466
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8459
8467
  <fo:table-cell>
8460
8468
  <fo:block>
8461
8469
  <xsl:apply-templates/>
@@ -8693,7 +8701,25 @@
8693
8701
  <xsl:template match="*[local-name()='pre']" name="pre">
8694
8702
  <fo:block xsl:use-attribute-sets="pre-style">
8695
8703
  <xsl:copy-of select="@id"/>
8696
- <xsl:apply-templates/>
8704
+ <xsl:choose>
8705
+
8706
+ <xsl:when test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name()='td'][1][not(preceding-sibling::*)]"> <!-- pre in the first td in the table with @linenums = 'true' -->
8707
+ <xsl:if test="ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']"> <!-- is current tr isn't last -->
8708
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8709
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8710
+ </xsl:if>
8711
+ <fo:instream-foreign-object fox:alt-text="{.}" content-width="95%">
8712
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
8713
+ <mtext><xsl:value-of select="."/></mtext>
8714
+ </math>
8715
+ </fo:instream-foreign-object>
8716
+ </xsl:when>
8717
+
8718
+ <xsl:otherwise>
8719
+ <xsl:apply-templates/>
8720
+ </xsl:otherwise>
8721
+
8722
+ </xsl:choose>
8697
8723
  </fo:block>
8698
8724
  </xsl:template>
8699
8725
  <!-- =============== -->
@@ -2,7 +2,7 @@
2
2
 
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
- <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
5
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure' or local-name() = 'localized-strings')] and not(ancestor::*[local-name() = 'name']))]" use="@reference"/>
6
6
 
7
7
  <xsl:variable name="debug">false</xsl:variable>
8
8
 
@@ -4667,7 +4667,7 @@
4667
4667
  </fn>
4668
4668
  -->
4669
4669
  <!-- footnotes in text (title, bibliography, main body, table's, figure's names), not for tables, figures -->
4670
- <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">
4670
+ <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">
4671
4671
 
4672
4672
  <!-- list of footnotes to calculate actual footnotes number -->
4673
4673
  <xsl:variable name="p_fn_">
@@ -4724,8 +4724,7 @@
4724
4724
  </fo:basic-link>
4725
4725
  </fo:inline>
4726
4726
  </xsl:variable>
4727
- <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
4728
- gen_id=<xsl:value-of select="$gen_id"/> -->
4727
+
4729
4728
  <xsl:choose>
4730
4729
  <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
4731
4730
  <xsl:copy-of select="$footnote_inline"/>
@@ -4784,7 +4783,7 @@
4784
4783
  <!-- commented:
4785
4784
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
4786
4785
  because 'fn' there is in biblio-tag -->
4787
- <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4786
+ <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4788
4787
  <!-- copy unique fn -->
4789
4788
  <fn gen_id="{generate-id(.)}">
4790
4789
  <xsl:copy-of select="@*"/>
@@ -7350,7 +7349,9 @@
7350
7349
 
7351
7350
  <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7352
7351
  <xsl:if test="number($scale) &lt; 100">
7353
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7352
+
7353
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7354
+
7354
7355
  </xsl:if>
7355
7356
 
7356
7357
  </xsl:if>
@@ -8365,6 +8366,12 @@
8365
8366
  </xsl:attribute>
8366
8367
  </xsl:for-each>
8367
8368
 
8369
+ <!-- remove margin between rows in the table with sourcecode line numbers -->
8370
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']">
8371
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8372
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8373
+ </xsl:if>
8374
+
8368
8375
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8369
8376
  </fo:block>
8370
8377
 
@@ -8413,7 +8420,7 @@
8413
8420
  </xsl:template>
8414
8421
 
8415
8422
  <!-- outer table with line numbers for sourcecode -->
8416
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
8423
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] | -->
8417
8424
  <fo:block>
8418
8425
  <fo:table width="100%" table-layout="fixed">
8419
8426
  <xsl:copy-of select="@id"/>
@@ -8425,16 +8432,16 @@
8425
8432
  </fo:table>
8426
8433
  </fo:block>
8427
8434
  </xsl:template>
8428
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
8435
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']/*[local-name() = 'tbody']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody'] | -->
8429
8436
  <xsl:apply-templates/>
8430
8437
  </xsl:template>
8431
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
8438
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr'] | -->
8432
8439
  <fo:table-row>
8433
8440
  <xsl:apply-templates/>
8434
8441
  </fo:table-row>
8435
8442
  </xsl:template>
8436
8443
  <!-- first td with line numbers -->
8437
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
8444
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8438
8445
  <fo:table-cell>
8439
8446
  <fo:block>
8440
8447
 
@@ -8454,8 +8461,9 @@
8454
8461
  </fo:block>
8455
8462
  </fo:table-cell>
8456
8463
  </xsl:template>
8464
+
8457
8465
  <!-- second td with sourcecode -->
8458
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
8466
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8459
8467
  <fo:table-cell>
8460
8468
  <fo:block>
8461
8469
  <xsl:apply-templates/>
@@ -8693,7 +8701,25 @@
8693
8701
  <xsl:template match="*[local-name()='pre']" name="pre">
8694
8702
  <fo:block xsl:use-attribute-sets="pre-style">
8695
8703
  <xsl:copy-of select="@id"/>
8696
- <xsl:apply-templates/>
8704
+ <xsl:choose>
8705
+
8706
+ <xsl:when test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name()='td'][1][not(preceding-sibling::*)]"> <!-- pre in the first td in the table with @linenums = 'true' -->
8707
+ <xsl:if test="ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']"> <!-- is current tr isn't last -->
8708
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8709
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8710
+ </xsl:if>
8711
+ <fo:instream-foreign-object fox:alt-text="{.}" content-width="95%">
8712
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
8713
+ <mtext><xsl:value-of select="."/></mtext>
8714
+ </math>
8715
+ </fo:instream-foreign-object>
8716
+ </xsl:when>
8717
+
8718
+ <xsl:otherwise>
8719
+ <xsl:apply-templates/>
8720
+ </xsl:otherwise>
8721
+
8722
+ </xsl:choose>
8697
8723
  </fo:block>
8698
8724
  </xsl:template>
8699
8725
  <!-- =============== -->
@@ -2,7 +2,7 @@
2
2
 
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
- <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
5
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure' or local-name() = 'localized-strings')] and not(ancestor::*[local-name() = 'name']))]" use="@reference"/>
6
6
 
7
7
  <xsl:variable name="debug">false</xsl:variable>
8
8
 
@@ -4667,7 +4667,7 @@
4667
4667
  </fn>
4668
4668
  -->
4669
4669
  <!-- footnotes in text (title, bibliography, main body, table's, figure's names), not for tables, figures -->
4670
- <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">
4670
+ <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">
4671
4671
 
4672
4672
  <!-- list of footnotes to calculate actual footnotes number -->
4673
4673
  <xsl:variable name="p_fn_">
@@ -4724,8 +4724,7 @@
4724
4724
  </fo:basic-link>
4725
4725
  </fo:inline>
4726
4726
  </xsl:variable>
4727
- <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
4728
- gen_id=<xsl:value-of select="$gen_id"/> -->
4727
+
4729
4728
  <xsl:choose>
4730
4729
  <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
4731
4730
  <xsl:copy-of select="$footnote_inline"/>
@@ -4784,7 +4783,7 @@
4784
4783
  <!-- commented:
4785
4784
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
4786
4785
  because 'fn' there is in biblio-tag -->
4787
- <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4786
+ <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4788
4787
  <!-- copy unique fn -->
4789
4788
  <fn gen_id="{generate-id(.)}">
4790
4789
  <xsl:copy-of select="@*"/>
@@ -7350,7 +7349,9 @@
7350
7349
 
7351
7350
  <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7352
7351
  <xsl:if test="number($scale) &lt; 100">
7353
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7352
+
7353
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7354
+
7354
7355
  </xsl:if>
7355
7356
 
7356
7357
  </xsl:if>
@@ -8365,6 +8366,12 @@
8365
8366
  </xsl:attribute>
8366
8367
  </xsl:for-each>
8367
8368
 
8369
+ <!-- remove margin between rows in the table with sourcecode line numbers -->
8370
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']">
8371
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8372
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8373
+ </xsl:if>
8374
+
8368
8375
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8369
8376
  </fo:block>
8370
8377
 
@@ -8413,7 +8420,7 @@
8413
8420
  </xsl:template>
8414
8421
 
8415
8422
  <!-- outer table with line numbers for sourcecode -->
8416
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
8423
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] | -->
8417
8424
  <fo:block>
8418
8425
  <fo:table width="100%" table-layout="fixed">
8419
8426
  <xsl:copy-of select="@id"/>
@@ -8425,16 +8432,16 @@
8425
8432
  </fo:table>
8426
8433
  </fo:block>
8427
8434
  </xsl:template>
8428
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
8435
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']/*[local-name() = 'tbody']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody'] | -->
8429
8436
  <xsl:apply-templates/>
8430
8437
  </xsl:template>
8431
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
8438
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr'] | -->
8432
8439
  <fo:table-row>
8433
8440
  <xsl:apply-templates/>
8434
8441
  </fo:table-row>
8435
8442
  </xsl:template>
8436
8443
  <!-- first td with line numbers -->
8437
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
8444
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8438
8445
  <fo:table-cell>
8439
8446
  <fo:block>
8440
8447
 
@@ -8454,8 +8461,9 @@
8454
8461
  </fo:block>
8455
8462
  </fo:table-cell>
8456
8463
  </xsl:template>
8464
+
8457
8465
  <!-- second td with sourcecode -->
8458
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
8466
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8459
8467
  <fo:table-cell>
8460
8468
  <fo:block>
8461
8469
  <xsl:apply-templates/>
@@ -8693,7 +8701,25 @@
8693
8701
  <xsl:template match="*[local-name()='pre']" name="pre">
8694
8702
  <fo:block xsl:use-attribute-sets="pre-style">
8695
8703
  <xsl:copy-of select="@id"/>
8696
- <xsl:apply-templates/>
8704
+ <xsl:choose>
8705
+
8706
+ <xsl:when test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name()='td'][1][not(preceding-sibling::*)]"> <!-- pre in the first td in the table with @linenums = 'true' -->
8707
+ <xsl:if test="ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']"> <!-- is current tr isn't last -->
8708
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8709
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8710
+ </xsl:if>
8711
+ <fo:instream-foreign-object fox:alt-text="{.}" content-width="95%">
8712
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
8713
+ <mtext><xsl:value-of select="."/></mtext>
8714
+ </math>
8715
+ </fo:instream-foreign-object>
8716
+ </xsl:when>
8717
+
8718
+ <xsl:otherwise>
8719
+ <xsl:apply-templates/>
8720
+ </xsl:otherwise>
8721
+
8722
+ </xsl:choose>
8697
8723
  </fo:block>
8698
8724
  </xsl:template>
8699
8725
  <!-- =============== -->
@@ -2,7 +2,7 @@
2
2
 
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
- <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
5
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure' or local-name() = 'localized-strings')] and not(ancestor::*[local-name() = 'name']))]" use="@reference"/>
6
6
 
7
7
  <xsl:variable name="debug">false</xsl:variable>
8
8
 
@@ -4667,7 +4667,7 @@
4667
4667
  </fn>
4668
4668
  -->
4669
4669
  <!-- footnotes in text (title, bibliography, main body, table's, figure's names), not for tables, figures -->
4670
- <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">
4670
+ <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">
4671
4671
 
4672
4672
  <!-- list of footnotes to calculate actual footnotes number -->
4673
4673
  <xsl:variable name="p_fn_">
@@ -4724,8 +4724,7 @@
4724
4724
  </fo:basic-link>
4725
4725
  </fo:inline>
4726
4726
  </xsl:variable>
4727
- <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
4728
- gen_id=<xsl:value-of select="$gen_id"/> -->
4727
+
4729
4728
  <xsl:choose>
4730
4729
  <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
4731
4730
  <xsl:copy-of select="$footnote_inline"/>
@@ -4784,7 +4783,7 @@
4784
4783
  <!-- commented:
4785
4784
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
4786
4785
  because 'fn' there is in biblio-tag -->
4787
- <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4786
+ <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4788
4787
  <!-- copy unique fn -->
4789
4788
  <fn gen_id="{generate-id(.)}">
4790
4789
  <xsl:copy-of select="@*"/>
@@ -7350,7 +7349,9 @@
7350
7349
 
7351
7350
  <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7352
7351
  <xsl:if test="number($scale) &lt; 100">
7353
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7352
+
7353
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7354
+
7354
7355
  </xsl:if>
7355
7356
 
7356
7357
  </xsl:if>
@@ -8365,6 +8366,12 @@
8365
8366
  </xsl:attribute>
8366
8367
  </xsl:for-each>
8367
8368
 
8369
+ <!-- remove margin between rows in the table with sourcecode line numbers -->
8370
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']">
8371
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8372
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8373
+ </xsl:if>
8374
+
8368
8375
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8369
8376
  </fo:block>
8370
8377
 
@@ -8413,7 +8420,7 @@
8413
8420
  </xsl:template>
8414
8421
 
8415
8422
  <!-- outer table with line numbers for sourcecode -->
8416
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
8423
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] | -->
8417
8424
  <fo:block>
8418
8425
  <fo:table width="100%" table-layout="fixed">
8419
8426
  <xsl:copy-of select="@id"/>
@@ -8425,16 +8432,16 @@
8425
8432
  </fo:table>
8426
8433
  </fo:block>
8427
8434
  </xsl:template>
8428
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
8435
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']/*[local-name() = 'tbody']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody'] | -->
8429
8436
  <xsl:apply-templates/>
8430
8437
  </xsl:template>
8431
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
8438
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr'] | -->
8432
8439
  <fo:table-row>
8433
8440
  <xsl:apply-templates/>
8434
8441
  </fo:table-row>
8435
8442
  </xsl:template>
8436
8443
  <!-- first td with line numbers -->
8437
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
8444
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8438
8445
  <fo:table-cell>
8439
8446
  <fo:block>
8440
8447
 
@@ -8454,8 +8461,9 @@
8454
8461
  </fo:block>
8455
8462
  </fo:table-cell>
8456
8463
  </xsl:template>
8464
+
8457
8465
  <!-- second td with sourcecode -->
8458
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
8466
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8459
8467
  <fo:table-cell>
8460
8468
  <fo:block>
8461
8469
  <xsl:apply-templates/>
@@ -8693,7 +8701,25 @@
8693
8701
  <xsl:template match="*[local-name()='pre']" name="pre">
8694
8702
  <fo:block xsl:use-attribute-sets="pre-style">
8695
8703
  <xsl:copy-of select="@id"/>
8696
- <xsl:apply-templates/>
8704
+ <xsl:choose>
8705
+
8706
+ <xsl:when test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name()='td'][1][not(preceding-sibling::*)]"> <!-- pre in the first td in the table with @linenums = 'true' -->
8707
+ <xsl:if test="ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']"> <!-- is current tr isn't last -->
8708
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8709
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8710
+ </xsl:if>
8711
+ <fo:instream-foreign-object fox:alt-text="{.}" content-width="95%">
8712
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
8713
+ <mtext><xsl:value-of select="."/></mtext>
8714
+ </math>
8715
+ </fo:instream-foreign-object>
8716
+ </xsl:when>
8717
+
8718
+ <xsl:otherwise>
8719
+ <xsl:apply-templates/>
8720
+ </xsl:otherwise>
8721
+
8722
+ </xsl:choose>
8697
8723
  </fo:block>
8698
8724
  </xsl:template>
8699
8725
  <!-- =============== -->
@@ -2,7 +2,7 @@
2
2
 
3
3
  <xsl:output method="xml" encoding="UTF-8" indent="no"/>
4
4
 
5
- <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
5
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure' or local-name() = 'localized-strings')] and not(ancestor::*[local-name() = 'name']))]" use="@reference"/>
6
6
 
7
7
  <xsl:variable name="debug">false</xsl:variable>
8
8
 
@@ -4667,7 +4667,7 @@
4667
4667
  </fn>
4668
4668
  -->
4669
4669
  <!-- footnotes in text (title, bibliography, main body, table's, figure's names), not for tables, figures -->
4670
- <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">
4670
+ <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">
4671
4671
 
4672
4672
  <!-- list of footnotes to calculate actual footnotes number -->
4673
4673
  <xsl:variable name="p_fn_">
@@ -4724,8 +4724,7 @@
4724
4724
  </fo:basic-link>
4725
4725
  </fo:inline>
4726
4726
  </xsl:variable>
4727
- <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
4728
- gen_id=<xsl:value-of select="$gen_id"/> -->
4727
+
4729
4728
  <xsl:choose>
4730
4729
  <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
4731
4730
  <xsl:copy-of select="$footnote_inline"/>
@@ -4784,7 +4783,7 @@
4784
4783
  <!-- commented:
4785
4784
  .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] |
4786
4785
  because 'fn' there is in biblio-tag -->
4787
- <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4786
+ <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
4788
4787
  <!-- copy unique fn -->
4789
4788
  <fn gen_id="{generate-id(.)}">
4790
4789
  <xsl:copy-of select="@*"/>
@@ -7350,7 +7349,9 @@
7350
7349
 
7351
7350
  <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7352
7351
  <xsl:if test="number($scale) &lt; 100">
7353
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7352
+
7353
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7354
+
7354
7355
  </xsl:if>
7355
7356
 
7356
7357
  </xsl:if>
@@ -8365,6 +8366,12 @@
8365
8366
  </xsl:attribute>
8366
8367
  </xsl:for-each>
8367
8368
 
8369
+ <!-- remove margin between rows in the table with sourcecode line numbers -->
8370
+ <xsl:if test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']">
8371
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8372
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8373
+ </xsl:if>
8374
+
8368
8375
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8369
8376
  </fo:block>
8370
8377
 
@@ -8413,7 +8420,7 @@
8413
8420
  </xsl:template>
8414
8421
 
8415
8422
  <!-- outer table with line numbers for sourcecode -->
8416
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']" priority="2">
8423
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] | -->
8417
8424
  <fo:block>
8418
8425
  <fo:table width="100%" table-layout="fixed">
8419
8426
  <xsl:copy-of select="@id"/>
@@ -8425,16 +8432,16 @@
8425
8432
  </fo:table>
8426
8433
  </fo:block>
8427
8434
  </xsl:template>
8428
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody']" priority="2">
8435
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']/*[local-name() = 'tbody']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']/*[local-name() = 'tbody'] | -->
8429
8436
  <xsl:apply-templates/>
8430
8437
  </xsl:template>
8431
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']" priority="2">
8438
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr'] | -->
8432
8439
  <fo:table-row>
8433
8440
  <xsl:apply-templates/>
8434
8441
  </fo:table-row>
8435
8442
  </xsl:template>
8436
8443
  <!-- first td with line numbers -->
8437
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2">
8444
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][not(preceding-sibling::*)]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8438
8445
  <fo:table-cell>
8439
8446
  <fo:block>
8440
8447
 
@@ -8454,8 +8461,9 @@
8454
8461
  </fo:block>
8455
8462
  </fo:table-cell>
8456
8463
  </xsl:template>
8464
+
8457
8465
  <!-- second td with sourcecode -->
8458
- <xsl:template match="*[local-name()='table'][@type = 'sourcecode']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2">
8466
+ <xsl:template match="*[local-name() = 'sourcecode'][@linenums = 'true']/*[local-name()='table']//*[local-name()='tr']/*[local-name()='td'][preceding-sibling::*]" priority="2"> <!-- *[local-name()='table'][@type = 'sourcecode'] -->
8459
8467
  <fo:table-cell>
8460
8468
  <fo:block>
8461
8469
  <xsl:apply-templates/>
@@ -8693,7 +8701,25 @@
8693
8701
  <xsl:template match="*[local-name()='pre']" name="pre">
8694
8702
  <fo:block xsl:use-attribute-sets="pre-style">
8695
8703
  <xsl:copy-of select="@id"/>
8696
- <xsl:apply-templates/>
8704
+ <xsl:choose>
8705
+
8706
+ <xsl:when test="ancestor::*[local-name() = 'sourcecode'][@linenums = 'true'] and ancestor::*[local-name()='td'][1][not(preceding-sibling::*)]"> <!-- pre in the first td in the table with @linenums = 'true' -->
8707
+ <xsl:if test="ancestor::*[local-name() = 'tr'][1]/following-sibling::*[local-name() = 'tr']"> <!-- is current tr isn't last -->
8708
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
8709
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
8710
+ </xsl:if>
8711
+ <fo:instream-foreign-object fox:alt-text="{.}" content-width="95%">
8712
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
8713
+ <mtext><xsl:value-of select="."/></mtext>
8714
+ </math>
8715
+ </fo:instream-foreign-object>
8716
+ </xsl:when>
8717
+
8718
+ <xsl:otherwise>
8719
+ <xsl:apply-templates/>
8720
+ </xsl:otherwise>
8721
+
8722
+ </xsl:choose>
8697
8723
  </fo:block>
8698
8724
  </xsl:template>
8699
8725
  <!-- =============== -->