metanorma-un 0.10.7 → 0.10.8

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.
@@ -1442,6 +1442,7 @@
1442
1442
  </xsl:attribute-set>
1443
1443
 
1444
1444
  <xsl:attribute-set name="xref-style">
1445
+ <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
1445
1446
 
1446
1447
  </xsl:attribute-set>
1447
1448
 
@@ -3425,9 +3426,13 @@
3425
3426
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
3426
3427
  </xsl:if>
3427
3428
 
3428
- <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
3429
- <xsl:value-of select="$current_fn_number_text"/>
3430
- </fo:basic-link>
3429
+ <xsl:call-template name="insert_basic_link">
3430
+ <xsl:with-param name="element">
3431
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
3432
+ <xsl:value-of select="$current_fn_number_text"/>
3433
+ </fo:basic-link>
3434
+ </xsl:with-param>
3435
+ </xsl:call-template>
3431
3436
  </fo:inline>
3432
3437
  </xsl:variable>
3433
3438
 
@@ -3760,8 +3765,10 @@
3760
3765
  <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3761
3766
  <xsl:text> </xsl:text>
3762
3767
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3763
- <xsl:text/>
3764
- <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3768
+ <xsl:if test="*[local-name()='dd']/node()[normalize-space() != ''][1][self::text()]">
3769
+ <xsl:text> </xsl:text>
3770
+ </xsl:if>
3771
+ <xsl:apply-templates select="*[local-name()='dd']/node()" mode="inline"/>
3765
3772
  </fo:block>
3766
3773
 
3767
3774
  </xsl:when> <!-- END: only one component -->
@@ -4248,8 +4255,18 @@
4248
4255
  </xsl:if>
4249
4256
  </xsl:template>
4250
4257
 
4251
- <xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4252
- <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4258
+ <xsl:template match="*[local-name()='dd']/*" mode="inline">
4259
+ <xsl:variable name="is_inline_element_after_where">
4260
+ <xsl:if test="(local-name() = 'p') and not(preceding-sibling::node()[normalize-space() != ''])">true</xsl:if>
4261
+ </xsl:variable>
4262
+ <xsl:choose>
4263
+ <xsl:when test="$is_inline_element_after_where = 'true'">
4264
+ <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4265
+ </xsl:when>
4266
+ <xsl:otherwise>
4267
+ <xsl:apply-templates select="."/>
4268
+ </xsl:otherwise>
4269
+ </xsl:choose>
4253
4270
  </xsl:template>
4254
4271
 
4255
4272
  <!-- virtual html table for dl/[dt and dd] for IF (Intermediate Format) -->
@@ -5677,6 +5694,79 @@
5677
5694
  <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5678
5695
  </xsl:template>
5679
5696
 
5697
+ <!-- special case for:
5698
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
5699
+ <mstyle displaystyle="true">
5700
+ <msup>
5701
+ <mi color="#00000000">C</mi>
5702
+ <mtext>R</mtext>
5703
+ </msup>
5704
+ <msubsup>
5705
+ <mtext>C</mtext>
5706
+ <mi>n</mi>
5707
+ <mi>k</mi>
5708
+ </msubsup>
5709
+ </mstyle>
5710
+ </math>
5711
+ -->
5712
+ <xsl:template match="mathml:msup/mathml:mi[. = '‌' or . = ''][not(preceding-sibling::*)][following-sibling::mathml:mtext]" mode="mathml">
5713
+ <xsl:copy>
5714
+ <xsl:copy-of select="@*"/>
5715
+ <xsl:variable name="next_mtext" select="ancestor::mathml:msup/following-sibling::*[1][self::mathml:msubsup or self::mathml:msub or self::mathml:msup]/mathml:mtext"/>
5716
+ <xsl:if test="string-length($next_mtext) != ''">
5717
+ <xsl:attribute name="color">#00000000</xsl:attribute>
5718
+ </xsl:if>
5719
+ <xsl:apply-templates/>
5720
+ <xsl:value-of select="$next_mtext"/>
5721
+ </xsl:copy>
5722
+ </xsl:template>
5723
+
5724
+ <!-- special case for:
5725
+ <msup>
5726
+ <mtext/>
5727
+ <mn>1</mn>
5728
+ </msup>
5729
+ convert to (add mspace after mtext and enclose them into mrow):
5730
+ <msup>
5731
+ <mrow>
5732
+ <mtext/>
5733
+ <mspace height="1.47ex"/>
5734
+ </mrow>
5735
+ <mn>1</mn>
5736
+ </msup>
5737
+ -->
5738
+ <xsl:template match="mathml:msup/mathml:mtext[not(preceding-sibling::*)]" mode="mathml">
5739
+ <mathml:mrow>
5740
+ <xsl:copy-of select="."/>
5741
+ <mathml:mspace height="1.47ex"/>
5742
+ </mathml:mrow>
5743
+ </xsl:template>
5744
+
5745
+ <!-- add space around vertical line -->
5746
+ <xsl:template match="mathml:mo[normalize-space(text()) = '|']" mode="mathml">
5747
+ <xsl:copy>
5748
+ <xsl:apply-templates select="@*" mode="mathml"/>
5749
+ <xsl:if test="not(@lspace)">
5750
+ <xsl:attribute name="lspace">0.4em</xsl:attribute>
5751
+ </xsl:if>
5752
+ <xsl:if test="not(@rspace)">
5753
+ <xsl:attribute name="rspace">0.4em</xsl:attribute>
5754
+ </xsl:if>
5755
+ <xsl:apply-templates mode="mathml"/>
5756
+ </xsl:copy>
5757
+ </xsl:template>
5758
+
5759
+ <!-- decrease fontsize for 'Circled Times' char -->
5760
+ <xsl:template match="mathml:mo[normalize-space(text()) = '⊗']" mode="mathml">
5761
+ <xsl:copy>
5762
+ <xsl:apply-templates select="@*" mode="mathml"/>
5763
+ <xsl:if test="not(@fontsize)">
5764
+ <xsl:attribute name="fontsize">55%</xsl:attribute>
5765
+ </xsl:if>
5766
+ <xsl:apply-templates mode="mathml"/>
5767
+ </xsl:copy>
5768
+ </xsl:template>
5769
+
5680
5770
  <!-- Examples:
5681
5771
  <stem type="AsciiMath">x = 1</stem>
5682
5772
  <stem type="AsciiMath"><asciimath>x = 1</asciimath></stem>
@@ -5734,19 +5824,23 @@
5734
5824
  <xsl:apply-templates/>
5735
5825
  </xsl:when>
5736
5826
  <xsl:otherwise>
5737
- <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
5738
- <xsl:choose>
5739
- <xsl:when test="normalize-space(.) = ''">
5740
- <xsl:call-template name="add-zero-spaces-link-java">
5741
- <xsl:with-param name="text" select="$target_text"/>
5742
- </xsl:call-template>
5743
- </xsl:when>
5744
- <xsl:otherwise>
5745
- <!-- output text from <link>text</link> -->
5746
- <xsl:apply-templates/>
5747
- </xsl:otherwise>
5748
- </xsl:choose>
5749
- </fo:basic-link>
5827
+ <xsl:call-template name="insert_basic_link">
5828
+ <xsl:with-param name="element">
5829
+ <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
5830
+ <xsl:choose>
5831
+ <xsl:when test="normalize-space(.) = ''">
5832
+ <xsl:call-template name="add-zero-spaces-link-java">
5833
+ <xsl:with-param name="text" select="$target_text"/>
5834
+ </xsl:call-template>
5835
+ </xsl:when>
5836
+ <xsl:otherwise>
5837
+ <!-- output text from <link>text</link> -->
5838
+ <xsl:apply-templates/>
5839
+ </xsl:otherwise>
5840
+ </xsl:choose>
5841
+ </fo:basic-link>
5842
+ </xsl:with-param>
5843
+ </xsl:call-template>
5750
5844
  </xsl:otherwise>
5751
5845
  </xsl:choose>
5752
5846
  </fo:inline>
@@ -5809,12 +5903,16 @@
5809
5903
  </xsl:template>
5810
5904
 
5811
5905
  <xsl:template match="*[local-name() = 'xref']">
5812
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5813
- <xsl:if test="parent::*[local-name() = 'add']">
5814
- <xsl:call-template name="append_add-style"/>
5815
- </xsl:if>
5816
- <xsl:apply-templates/>
5817
- </fo:basic-link>
5906
+ <xsl:call-template name="insert_basic_link">
5907
+ <xsl:with-param name="element">
5908
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5909
+ <xsl:if test="parent::*[local-name() = 'add']">
5910
+ <xsl:call-template name="append_add-style"/>
5911
+ </xsl:if>
5912
+ <xsl:apply-templates/>
5913
+ </fo:basic-link>
5914
+ </xsl:with-param>
5915
+ </xsl:call-template>
5818
5916
  </xsl:template>
5819
5917
 
5820
5918
  <!-- ====== -->
@@ -6213,7 +6311,7 @@
6213
6311
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
6214
6312
  </xsl:when>
6215
6313
  <xsl:when test="not(starts-with(@src, 'data:'))">
6216
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
6314
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
6217
6315
  </xsl:when>
6218
6316
  <xsl:otherwise>
6219
6317
  <xsl:value-of select="@src"/>
@@ -6235,7 +6333,7 @@
6235
6333
  </xsl:when>
6236
6334
  <xsl:when test="not(starts-with(@src, 'data:'))">
6237
6335
  <xsl:variable name="src">
6238
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
6336
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
6239
6337
  </xsl:variable>
6240
6338
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
6241
6339
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -6621,15 +6719,19 @@
6621
6719
  <xsl:param name="dest"/>
6622
6720
  <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
6623
6721
  <fo:block font-size="1pt">
6624
- <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
6625
- <fo:inline-container inline-progression-dimension="100%">
6626
- <fo:block-container height="{$height - 1}px" width="100%">
6627
- <!-- DEBUG <xsl:if test="local-name()='polygon'">
6628
- <xsl:attribute name="background-color">magenta</xsl:attribute>
6629
- </xsl:if> -->
6630
- <fo:block> </fo:block></fo:block-container>
6631
- </fo:inline-container>
6632
- </fo:basic-link>
6722
+ <xsl:call-template name="insert_basic_link">
6723
+ <xsl:with-param name="element">
6724
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
6725
+ <fo:inline-container inline-progression-dimension="100%">
6726
+ <fo:block-container height="{$height - 1}px" width="100%">
6727
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
6728
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
6729
+ </xsl:if> -->
6730
+ <fo:block> </fo:block></fo:block-container>
6731
+ </fo:inline-container>
6732
+ </fo:basic-link>
6733
+ </xsl:with-param>
6734
+ </xsl:call-template>
6633
6735
  </fo:block>
6634
6736
  </fo:block-container>
6635
6737
  </xsl:template>
@@ -8178,14 +8280,18 @@
8178
8280
  </xsl:template>
8179
8281
 
8180
8282
  <xsl:template match="*[local-name() = 'origin']">
8181
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8182
- <xsl:if test="normalize-space(@citeas) = ''">
8183
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8184
- </xsl:if>
8185
- <fo:inline xsl:use-attribute-sets="origin-style">
8186
- <xsl:apply-templates/>
8187
- </fo:inline>
8188
- </fo:basic-link>
8283
+ <xsl:call-template name="insert_basic_link">
8284
+ <xsl:with-param name="element">
8285
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8286
+ <xsl:if test="normalize-space(@citeas) = ''">
8287
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8288
+ </xsl:if>
8289
+ <fo:inline xsl:use-attribute-sets="origin-style">
8290
+ <xsl:apply-templates/>
8291
+ </fo:inline>
8292
+ </fo:basic-link>
8293
+ </xsl:with-param>
8294
+ </xsl:call-template>
8189
8295
  </xsl:template>
8190
8296
 
8191
8297
  <!-- not using, see https://github.com/glossarist/iev-document/issues/23 -->
@@ -8259,9 +8365,13 @@
8259
8365
  <xsl:if test="../*[local-name() = 'author']">
8260
8366
  <xsl:text>, </xsl:text>
8261
8367
  </xsl:if>
8262
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8263
- <xsl:apply-templates/>
8264
- </fo:basic-link>
8368
+ <xsl:call-template name="insert_basic_link">
8369
+ <xsl:with-param name="element">
8370
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8371
+ <xsl:apply-templates/>
8372
+ </fo:basic-link>
8373
+ </xsl:with-param>
8374
+ </xsl:call-template>
8265
8375
  </xsl:template>
8266
8376
 
8267
8377
  <xsl:template match="*[local-name() = 'author']">
@@ -8310,27 +8420,31 @@
8310
8420
  <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
8311
8421
  <xsl:variable name="text" select="normalize-space()"/>
8312
8422
 
8313
- <fo:basic-link fox:alt-text="{@citeas}">
8314
- <xsl:if test="normalize-space(@citeas) = ''">
8315
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
8316
- </xsl:if>
8317
- <xsl:if test="@type = 'inline'">
8423
+ <xsl:call-template name="insert_basic_link">
8424
+ <xsl:with-param name="element">
8425
+ <fo:basic-link fox:alt-text="{@citeas}">
8426
+ <xsl:if test="normalize-space(@citeas) = ''">
8427
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
8428
+ </xsl:if>
8429
+ <xsl:if test="@type = 'inline'">
8318
8430
 
8319
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
8431
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
8320
8432
 
8321
- </xsl:if>
8433
+ </xsl:if>
8322
8434
 
8323
- <xsl:choose>
8324
- <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
8325
- <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
8326
- </xsl:when>
8327
- <xsl:otherwise>
8328
- <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8329
- </xsl:otherwise>
8330
- </xsl:choose>
8435
+ <xsl:choose>
8436
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
8437
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
8438
+ </xsl:when>
8439
+ <xsl:otherwise>
8440
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8441
+ </xsl:otherwise>
8442
+ </xsl:choose>
8331
8443
 
8332
- <xsl:apply-templates/>
8333
- </fo:basic-link>
8444
+ <xsl:apply-templates/>
8445
+ </fo:basic-link>
8446
+ </xsl:with-param>
8447
+ </xsl:call-template>
8334
8448
 
8335
8449
  </fo:inline>
8336
8450
  </xsl:when>
@@ -8575,7 +8689,10 @@
8575
8689
  <xsl:variable name="ul_labels" select="xalan:nodeset($ul_labels_)"/>
8576
8690
 
8577
8691
  <xsl:template name="setULLabel">
8578
- <xsl:variable name="list_level_" select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
8692
+ <xsl:variable name="list_level__">
8693
+ <xsl:value-of select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
8694
+ </xsl:variable>
8695
+ <xsl:variable name="list_level_" select="number($list_level__)"/>
8579
8696
  <xsl:variable name="list_level">
8580
8697
  <xsl:choose>
8581
8698
  <xsl:when test="$list_level_ &lt;= 3"><xsl:value-of select="$list_level_"/></xsl:when>
@@ -8708,9 +8825,11 @@
8708
8825
  </fo:block-container>
8709
8826
  </xsl:when>
8710
8827
  <xsl:otherwise>
8711
- <fo:block>
8712
- <xsl:apply-templates select="." mode="list"/>
8713
- </fo:block>
8828
+
8829
+ <fo:block>
8830
+ <xsl:apply-templates select="." mode="list"/>
8831
+ </fo:block>
8832
+
8714
8833
  </xsl:otherwise>
8715
8834
  </xsl:choose>
8716
8835
  </xsl:template>
@@ -9377,24 +9496,32 @@
9377
9496
  <xsl:for-each select="*[local-name() = 'tab']">
9378
9497
  <xsl:variable name="current_id" select="generate-id()"/>
9379
9498
  <fo:table-cell>
9380
- <fo:block>
9381
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9382
- <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
9383
- <xsl:choose>
9384
- <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
9385
- <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
9386
- </xsl:choose>
9387
- </xsl:for-each>
9388
- </fo:basic-link>
9499
+ <fo:block line-height-shift-adjustment="disregard-shifts">
9500
+ <xsl:call-template name="insert_basic_link">
9501
+ <xsl:with-param name="element">
9502
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9503
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
9504
+ <xsl:choose>
9505
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
9506
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
9507
+ </xsl:choose>
9508
+ </xsl:for-each>
9509
+ </fo:basic-link>
9510
+ </xsl:with-param>
9511
+ </xsl:call-template>
9389
9512
  </fo:block>
9390
9513
  </fo:table-cell>
9391
9514
  </xsl:for-each>
9392
9515
  <!-- last column - for page numbers -->
9393
9516
  <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
9394
9517
  <fo:block>
9395
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9396
- <fo:page-number-citation ref-id="{$target}"/>
9397
- </fo:basic-link>
9518
+ <xsl:call-template name="insert_basic_link">
9519
+ <xsl:with-param name="element">
9520
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9521
+ <fo:page-number-citation ref-id="{$target}"/>
9522
+ </fo:basic-link>
9523
+ </xsl:with-param>
9524
+ </xsl:call-template>
9398
9525
  </fo:block>
9399
9526
  </fo:table-cell>
9400
9527
  </xsl:template>
@@ -9436,6 +9563,27 @@
9436
9563
  <!-- End Table of Contents (ToC) processing -->
9437
9564
  <!-- =================== -->
9438
9565
 
9566
+ <!-- insert fo:basic-link, if external-destination or internal-destination is non-empty, otherwise insert fo:inline -->
9567
+ <xsl:template name="insert_basic_link">
9568
+ <xsl:param name="element"/>
9569
+ <xsl:variable name="element_node" select="xalan:nodeset($element)"/>
9570
+ <xsl:variable name="external-destination" select="normalize-space(count($element_node/fo:basic-link/@external-destination[. != '']) = 1)"/>
9571
+ <xsl:variable name="internal-destination" select="normalize-space(count($element_node/fo:basic-link/@internal-destination[. != '']) = 1)"/>
9572
+ <xsl:choose>
9573
+ <xsl:when test="$external-destination = 'true' or $internal-destination = 'true'">
9574
+ <xsl:copy-of select="$element_node"/>
9575
+ </xsl:when>
9576
+ <xsl:otherwise>
9577
+ <fo:inline>
9578
+ <xsl:for-each select="$element_node/fo:basic-link/@*[local-name() != 'external-destination' and local-name() != 'internal-destination' and local-name() != 'alt-text']">
9579
+ <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
9580
+ </xsl:for-each>
9581
+ <xsl:copy-of select="$element_node/fo:basic-link/node()"/>
9582
+ </fo:inline>
9583
+ </xsl:otherwise>
9584
+ </xsl:choose>
9585
+ </xsl:template>
9586
+
9439
9587
  <xsl:template match="*[local-name() = 'variant-title']"/> <!-- [@type = 'sub'] -->
9440
9588
  <xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
9441
9589
  <fo:inline padding-right="5mm"> </fo:inline>