metanorma-ogc 2.3.8 → 2.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -2250,6 +2250,7 @@
2250
2250
  </xsl:attribute-set>
2251
2251
 
2252
2252
  <xsl:attribute-set name="xref-style">
2253
+ <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
2253
2254
 
2254
2255
  </xsl:attribute-set>
2255
2256
 
@@ -4286,9 +4287,13 @@
4286
4287
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
4287
4288
  </xsl:if>
4288
4289
 
4289
- <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
4290
- <xsl:value-of select="$current_fn_number_text"/>
4291
- </fo:basic-link>
4290
+ <xsl:call-template name="insert_basic_link">
4291
+ <xsl:with-param name="element">
4292
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
4293
+ <xsl:value-of select="$current_fn_number_text"/>
4294
+ </fo:basic-link>
4295
+ </xsl:with-param>
4296
+ </xsl:call-template>
4292
4297
  </fo:inline>
4293
4298
  </xsl:variable>
4294
4299
 
@@ -4632,8 +4637,10 @@
4632
4637
  <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
4633
4638
  <xsl:text> </xsl:text>
4634
4639
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
4635
- <xsl:text/>
4636
- <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
4640
+ <xsl:if test="*[local-name()='dd']/node()[normalize-space() != ''][1][self::text()]">
4641
+ <xsl:text> </xsl:text>
4642
+ </xsl:if>
4643
+ <xsl:apply-templates select="*[local-name()='dd']/node()" mode="inline"/>
4637
4644
  </fo:block>
4638
4645
 
4639
4646
  </xsl:when> <!-- END: only one component -->
@@ -5143,8 +5150,18 @@
5143
5150
  </xsl:if>
5144
5151
  </xsl:template>
5145
5152
 
5146
- <xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
5147
- <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
5153
+ <xsl:template match="*[local-name()='dd']/*" mode="inline">
5154
+ <xsl:variable name="is_inline_element_after_where">
5155
+ <xsl:if test="(local-name() = 'p') and not(preceding-sibling::node()[normalize-space() != ''])">true</xsl:if>
5156
+ </xsl:variable>
5157
+ <xsl:choose>
5158
+ <xsl:when test="$is_inline_element_after_where = 'true'">
5159
+ <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
5160
+ </xsl:when>
5161
+ <xsl:otherwise>
5162
+ <xsl:apply-templates select="."/>
5163
+ </xsl:otherwise>
5164
+ </xsl:choose>
5148
5165
  </xsl:template>
5149
5166
 
5150
5167
  <!-- virtual html table for dl/[dt and dd] for IF (Intermediate Format) -->
@@ -6577,6 +6594,79 @@
6577
6594
  <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
6578
6595
  </xsl:template>
6579
6596
 
6597
+ <!-- special case for:
6598
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
6599
+ <mstyle displaystyle="true">
6600
+ <msup>
6601
+ <mi color="#00000000">C</mi>
6602
+ <mtext>R</mtext>
6603
+ </msup>
6604
+ <msubsup>
6605
+ <mtext>C</mtext>
6606
+ <mi>n</mi>
6607
+ <mi>k</mi>
6608
+ </msubsup>
6609
+ </mstyle>
6610
+ </math>
6611
+ -->
6612
+ <xsl:template match="mathml:msup/mathml:mi[. = '‌' or . = ''][not(preceding-sibling::*)][following-sibling::mathml:mtext]" mode="mathml">
6613
+ <xsl:copy>
6614
+ <xsl:copy-of select="@*"/>
6615
+ <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"/>
6616
+ <xsl:if test="string-length($next_mtext) != ''">
6617
+ <xsl:attribute name="color">#00000000</xsl:attribute>
6618
+ </xsl:if>
6619
+ <xsl:apply-templates/>
6620
+ <xsl:value-of select="$next_mtext"/>
6621
+ </xsl:copy>
6622
+ </xsl:template>
6623
+
6624
+ <!-- special case for:
6625
+ <msup>
6626
+ <mtext/>
6627
+ <mn>1</mn>
6628
+ </msup>
6629
+ convert to (add mspace after mtext and enclose them into mrow):
6630
+ <msup>
6631
+ <mrow>
6632
+ <mtext/>
6633
+ <mspace height="1.47ex"/>
6634
+ </mrow>
6635
+ <mn>1</mn>
6636
+ </msup>
6637
+ -->
6638
+ <xsl:template match="mathml:msup/mathml:mtext[not(preceding-sibling::*)]" mode="mathml">
6639
+ <mathml:mrow>
6640
+ <xsl:copy-of select="."/>
6641
+ <mathml:mspace height="1.47ex"/>
6642
+ </mathml:mrow>
6643
+ </xsl:template>
6644
+
6645
+ <!-- add space around vertical line -->
6646
+ <xsl:template match="mathml:mo[normalize-space(text()) = '|']" mode="mathml">
6647
+ <xsl:copy>
6648
+ <xsl:apply-templates select="@*" mode="mathml"/>
6649
+ <xsl:if test="not(@lspace)">
6650
+ <xsl:attribute name="lspace">0.4em</xsl:attribute>
6651
+ </xsl:if>
6652
+ <xsl:if test="not(@rspace)">
6653
+ <xsl:attribute name="rspace">0.4em</xsl:attribute>
6654
+ </xsl:if>
6655
+ <xsl:apply-templates mode="mathml"/>
6656
+ </xsl:copy>
6657
+ </xsl:template>
6658
+
6659
+ <!-- decrease fontsize for 'Circled Times' char -->
6660
+ <xsl:template match="mathml:mo[normalize-space(text()) = '⊗']" mode="mathml">
6661
+ <xsl:copy>
6662
+ <xsl:apply-templates select="@*" mode="mathml"/>
6663
+ <xsl:if test="not(@fontsize)">
6664
+ <xsl:attribute name="fontsize">55%</xsl:attribute>
6665
+ </xsl:if>
6666
+ <xsl:apply-templates mode="mathml"/>
6667
+ </xsl:copy>
6668
+ </xsl:template>
6669
+
6580
6670
  <!-- Examples:
6581
6671
  <stem type="AsciiMath">x = 1</stem>
6582
6672
  <stem type="AsciiMath"><asciimath>x = 1</asciimath></stem>
@@ -6634,19 +6724,23 @@
6634
6724
  <xsl:apply-templates/>
6635
6725
  </xsl:when>
6636
6726
  <xsl:otherwise>
6637
- <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
6638
- <xsl:choose>
6639
- <xsl:when test="normalize-space(.) = ''">
6640
- <xsl:call-template name="add-zero-spaces-link-java">
6641
- <xsl:with-param name="text" select="$target_text"/>
6642
- </xsl:call-template>
6643
- </xsl:when>
6644
- <xsl:otherwise>
6645
- <!-- output text from <link>text</link> -->
6646
- <xsl:apply-templates/>
6647
- </xsl:otherwise>
6648
- </xsl:choose>
6649
- </fo:basic-link>
6727
+ <xsl:call-template name="insert_basic_link">
6728
+ <xsl:with-param name="element">
6729
+ <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
6730
+ <xsl:choose>
6731
+ <xsl:when test="normalize-space(.) = ''">
6732
+ <xsl:call-template name="add-zero-spaces-link-java">
6733
+ <xsl:with-param name="text" select="$target_text"/>
6734
+ </xsl:call-template>
6735
+ </xsl:when>
6736
+ <xsl:otherwise>
6737
+ <!-- output text from <link>text</link> -->
6738
+ <xsl:apply-templates/>
6739
+ </xsl:otherwise>
6740
+ </xsl:choose>
6741
+ </fo:basic-link>
6742
+ </xsl:with-param>
6743
+ </xsl:call-template>
6650
6744
  </xsl:otherwise>
6651
6745
  </xsl:choose>
6652
6746
  </fo:inline>
@@ -6713,12 +6807,16 @@
6713
6807
  </xsl:template>
6714
6808
 
6715
6809
  <xsl:template match="*[local-name() = 'xref']">
6716
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
6717
- <xsl:if test="parent::*[local-name() = 'add']">
6718
- <xsl:call-template name="append_add-style"/>
6719
- </xsl:if>
6720
- <xsl:apply-templates/>
6721
- </fo:basic-link>
6810
+ <xsl:call-template name="insert_basic_link">
6811
+ <xsl:with-param name="element">
6812
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
6813
+ <xsl:if test="parent::*[local-name() = 'add']">
6814
+ <xsl:call-template name="append_add-style"/>
6815
+ </xsl:if>
6816
+ <xsl:apply-templates/>
6817
+ </fo:basic-link>
6818
+ </xsl:with-param>
6819
+ </xsl:call-template>
6722
6820
  </xsl:template>
6723
6821
 
6724
6822
  <!-- ====== -->
@@ -7107,7 +7205,7 @@
7107
7205
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
7108
7206
  </xsl:when>
7109
7207
  <xsl:when test="not(starts-with(@src, 'data:'))">
7110
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
7208
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7111
7209
  </xsl:when>
7112
7210
  <xsl:otherwise>
7113
7211
  <xsl:value-of select="@src"/>
@@ -7129,7 +7227,7 @@
7129
7227
  </xsl:when>
7130
7228
  <xsl:when test="not(starts-with(@src, 'data:'))">
7131
7229
  <xsl:variable name="src">
7132
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
7230
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
7133
7231
  </xsl:variable>
7134
7232
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
7135
7233
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -7515,15 +7613,19 @@
7515
7613
  <xsl:param name="dest"/>
7516
7614
  <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
7517
7615
  <fo:block font-size="1pt">
7518
- <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
7519
- <fo:inline-container inline-progression-dimension="100%">
7520
- <fo:block-container height="{$height - 1}px" width="100%">
7521
- <!-- DEBUG <xsl:if test="local-name()='polygon'">
7522
- <xsl:attribute name="background-color">magenta</xsl:attribute>
7523
- </xsl:if> -->
7524
- <fo:block> </fo:block></fo:block-container>
7525
- </fo:inline-container>
7526
- </fo:basic-link>
7616
+ <xsl:call-template name="insert_basic_link">
7617
+ <xsl:with-param name="element">
7618
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
7619
+ <fo:inline-container inline-progression-dimension="100%">
7620
+ <fo:block-container height="{$height - 1}px" width="100%">
7621
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
7622
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
7623
+ </xsl:if> -->
7624
+ <fo:block> </fo:block></fo:block-container>
7625
+ </fo:inline-container>
7626
+ </fo:basic-link>
7627
+ </xsl:with-param>
7628
+ </xsl:call-template>
7527
7629
  </fo:block>
7528
7630
  </fo:block-container>
7529
7631
  </xsl:template>
@@ -9124,14 +9226,18 @@
9124
9226
  </xsl:template>
9125
9227
 
9126
9228
  <xsl:template match="*[local-name() = 'origin']">
9127
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
9128
- <xsl:if test="normalize-space(@citeas) = ''">
9129
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
9130
- </xsl:if>
9131
- <fo:inline xsl:use-attribute-sets="origin-style">
9132
- <xsl:apply-templates/>
9133
- </fo:inline>
9134
- </fo:basic-link>
9229
+ <xsl:call-template name="insert_basic_link">
9230
+ <xsl:with-param name="element">
9231
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
9232
+ <xsl:if test="normalize-space(@citeas) = ''">
9233
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
9234
+ </xsl:if>
9235
+ <fo:inline xsl:use-attribute-sets="origin-style">
9236
+ <xsl:apply-templates/>
9237
+ </fo:inline>
9238
+ </fo:basic-link>
9239
+ </xsl:with-param>
9240
+ </xsl:call-template>
9135
9241
  </xsl:template>
9136
9242
 
9137
9243
  <!-- not using, see https://github.com/glossarist/iev-document/issues/23 -->
@@ -9205,9 +9311,13 @@
9205
9311
  <xsl:if test="../*[local-name() = 'author']">
9206
9312
  <xsl:text>, </xsl:text>
9207
9313
  </xsl:if>
9208
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
9209
- <xsl:apply-templates/>
9210
- </fo:basic-link>
9314
+ <xsl:call-template name="insert_basic_link">
9315
+ <xsl:with-param name="element">
9316
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
9317
+ <xsl:apply-templates/>
9318
+ </fo:basic-link>
9319
+ </xsl:with-param>
9320
+ </xsl:call-template>
9211
9321
  </xsl:template>
9212
9322
 
9213
9323
  <xsl:template match="*[local-name() = 'author']">
@@ -9256,25 +9366,29 @@
9256
9366
  <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
9257
9367
  <xsl:variable name="text" select="normalize-space()"/>
9258
9368
 
9259
- <fo:basic-link fox:alt-text="{@citeas}">
9260
- <xsl:if test="normalize-space(@citeas) = ''">
9261
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
9262
- </xsl:if>
9263
- <xsl:if test="@type = 'inline'">
9369
+ <xsl:call-template name="insert_basic_link">
9370
+ <xsl:with-param name="element">
9371
+ <fo:basic-link fox:alt-text="{@citeas}">
9372
+ <xsl:if test="normalize-space(@citeas) = ''">
9373
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
9374
+ </xsl:if>
9375
+ <xsl:if test="@type = 'inline'">
9264
9376
 
9265
- </xsl:if>
9377
+ </xsl:if>
9266
9378
 
9267
- <xsl:choose>
9268
- <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
9269
- <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
9270
- </xsl:when>
9271
- <xsl:otherwise>
9272
- <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
9273
- </xsl:otherwise>
9274
- </xsl:choose>
9379
+ <xsl:choose>
9380
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
9381
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
9382
+ </xsl:when>
9383
+ <xsl:otherwise>
9384
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
9385
+ </xsl:otherwise>
9386
+ </xsl:choose>
9275
9387
 
9276
- <xsl:apply-templates/>
9277
- </fo:basic-link>
9388
+ <xsl:apply-templates/>
9389
+ </fo:basic-link>
9390
+ </xsl:with-param>
9391
+ </xsl:call-template>
9278
9392
 
9279
9393
  </fo:inline>
9280
9394
  </xsl:when>
@@ -9515,7 +9629,10 @@
9515
9629
  <xsl:variable name="ul_labels" select="xalan:nodeset($ul_labels_)"/>
9516
9630
 
9517
9631
  <xsl:template name="setULLabel">
9518
- <xsl:variable name="list_level_" select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
9632
+ <xsl:variable name="list_level__">
9633
+ <xsl:value-of select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
9634
+ </xsl:variable>
9635
+ <xsl:variable name="list_level_" select="number($list_level__)"/>
9519
9636
  <xsl:variable name="list_level">
9520
9637
  <xsl:choose>
9521
9638
  <xsl:when test="$list_level_ &lt;= 3"><xsl:value-of select="$list_level_"/></xsl:when>
@@ -9648,9 +9765,11 @@
9648
9765
  </fo:block-container>
9649
9766
  </xsl:when>
9650
9767
  <xsl:otherwise>
9651
- <fo:block>
9652
- <xsl:apply-templates select="." mode="list"/>
9653
- </fo:block>
9768
+
9769
+ <fo:block>
9770
+ <xsl:apply-templates select="." mode="list"/>
9771
+ </fo:block>
9772
+
9654
9773
  </xsl:otherwise>
9655
9774
  </xsl:choose>
9656
9775
  </xsl:template>
@@ -10342,24 +10461,32 @@
10342
10461
  <xsl:for-each select="*[local-name() = 'tab']">
10343
10462
  <xsl:variable name="current_id" select="generate-id()"/>
10344
10463
  <fo:table-cell>
10345
- <fo:block>
10346
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
10347
- <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
10348
- <xsl:choose>
10349
- <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
10350
- <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
10351
- </xsl:choose>
10352
- </xsl:for-each>
10353
- </fo:basic-link>
10464
+ <fo:block line-height-shift-adjustment="disregard-shifts">
10465
+ <xsl:call-template name="insert_basic_link">
10466
+ <xsl:with-param name="element">
10467
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
10468
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
10469
+ <xsl:choose>
10470
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
10471
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
10472
+ </xsl:choose>
10473
+ </xsl:for-each>
10474
+ </fo:basic-link>
10475
+ </xsl:with-param>
10476
+ </xsl:call-template>
10354
10477
  </fo:block>
10355
10478
  </fo:table-cell>
10356
10479
  </xsl:for-each>
10357
10480
  <!-- last column - for page numbers -->
10358
10481
  <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
10359
10482
  <fo:block>
10360
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
10361
- <fo:page-number-citation ref-id="{$target}"/>
10362
- </fo:basic-link>
10483
+ <xsl:call-template name="insert_basic_link">
10484
+ <xsl:with-param name="element">
10485
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
10486
+ <fo:page-number-citation ref-id="{$target}"/>
10487
+ </fo:basic-link>
10488
+ </xsl:with-param>
10489
+ </xsl:call-template>
10363
10490
  </fo:block>
10364
10491
  </fo:table-cell>
10365
10492
  </xsl:template>
@@ -10401,6 +10528,27 @@
10401
10528
  <!-- End Table of Contents (ToC) processing -->
10402
10529
  <!-- =================== -->
10403
10530
 
10531
+ <!-- insert fo:basic-link, if external-destination or internal-destination is non-empty, otherwise insert fo:inline -->
10532
+ <xsl:template name="insert_basic_link">
10533
+ <xsl:param name="element"/>
10534
+ <xsl:variable name="element_node" select="xalan:nodeset($element)"/>
10535
+ <xsl:variable name="external-destination" select="normalize-space(count($element_node/fo:basic-link/@external-destination[. != '']) = 1)"/>
10536
+ <xsl:variable name="internal-destination" select="normalize-space(count($element_node/fo:basic-link/@internal-destination[. != '']) = 1)"/>
10537
+ <xsl:choose>
10538
+ <xsl:when test="$external-destination = 'true' or $internal-destination = 'true'">
10539
+ <xsl:copy-of select="$element_node"/>
10540
+ </xsl:when>
10541
+ <xsl:otherwise>
10542
+ <fo:inline>
10543
+ <xsl:for-each select="$element_node/fo:basic-link/@*[local-name() != 'external-destination' and local-name() != 'internal-destination' and local-name() != 'alt-text']">
10544
+ <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
10545
+ </xsl:for-each>
10546
+ <xsl:copy-of select="$element_node/fo:basic-link/node()"/>
10547
+ </fo:inline>
10548
+ </xsl:otherwise>
10549
+ </xsl:choose>
10550
+ </xsl:template>
10551
+
10404
10552
  <xsl:template match="*[local-name() = 'variant-title']"/> <!-- [@type = 'sub'] -->
10405
10553
  <xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
10406
10554
  <fo:inline padding-right="5mm"> </fo:inline>