metanorma-bipm 2.2.8 → 2.2.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -771,20 +771,20 @@
771
771
  <!-- if current li is first -->
772
772
  <xsl:if test="not(preceding-sibling::*[local-name() = 'li'])">
773
773
 
774
- <!-- move note for list (list level note) into first 'li' -->
775
- <xsl:for-each select="following-sibling::bipm:li[last()]/following-sibling::*">
776
- <xsl:choose>
777
- <xsl:when test="local-name() = 'note'">
778
- <xsl:call-template name="change_note_kind"/>
779
- </xsl:when>
780
- <xsl:otherwise>
781
- <xsl:copy-of select="."/>
782
- </xsl:otherwise>
783
- </xsl:choose>
784
- </xsl:for-each>
785
-
786
- <!-- move note(s) after ul/ol into first 'li' -->
787
774
  <xsl:if test="not(ancestor::bipm:quote)">
775
+ <!-- move note for list (list level note) into first 'li' -->
776
+ <xsl:for-each select="following-sibling::bipm:li[last()]/following-sibling::*">
777
+ <xsl:choose>
778
+ <xsl:when test="local-name() = 'note'">
779
+ <xsl:call-template name="change_note_kind"/>
780
+ </xsl:when>
781
+ <xsl:otherwise>
782
+ <xsl:copy-of select="."/>
783
+ </xsl:otherwise>
784
+ </xsl:choose>
785
+ </xsl:for-each>
786
+
787
+ <!-- move note(s) after ul/ol into first 'li' -->
788
788
  <xsl:variable name="list_id" select="generate-id(..)"/>
789
789
  <xsl:for-each select="../following-sibling::bipm:note[generate-id(preceding-sibling::*[not(local-name()='note') and not(local-name()='quote')][1]) = $list_id]">
790
790
  <xsl:call-template name="change_note_kind"/>
@@ -816,6 +816,13 @@
816
816
  </xsl:copy>
817
817
  </xsl:template>
818
818
 
819
+ <xsl:template match="bipm:note[ancestor::bipm:quote]" mode="flatxml_list">
820
+ <xsl:copy>
821
+ <xsl:attribute name="parent-type">quote</xsl:attribute>
822
+ <xsl:apply-templates select="@*|node()" mode="flatxml_list"/>
823
+ </xsl:copy>
824
+ </xsl:template>
825
+
819
826
  <xsl:template name="fn_to_note_side">
820
827
  <xsl:element name="note_side" namespace="https://www.metanorma.org/ns/bipm">
821
828
 
@@ -847,8 +854,8 @@
847
854
  </xsl:template>
848
855
 
849
856
  <!-- remove latest elements (after li), because they moved into latest 'li' -->
850
- <xsl:template match="bipm:ul/*[not(local-name() = 'li') and not(following-sibling::*[local-name() = 'li'])]" mode="flatxml_list"/>
851
- <xsl:template match="bipm:ol/*[not(local-name() = 'li') and not(following-sibling::*[local-name() = 'li'])]" mode="flatxml_list"/>
857
+ <xsl:template match="bipm:ul/*[not(local-name() = 'li') and not(following-sibling::*[local-name() = 'li']) and not(ancestor::bipm:quote)]" mode="flatxml_list"/>
858
+ <xsl:template match="bipm:ol/*[not(local-name() = 'li') and not(following-sibling::*[local-name() = 'li']) and not(ancestor::bipm:quote)]" mode="flatxml_list"/>
852
859
 
853
860
  <xsl:template name="setListItemLabel">
854
861
  <xsl:attribute name="label">
@@ -2900,61 +2907,69 @@
2900
2907
  </xsl:template>
2901
2908
 
2902
2909
  <xsl:template match="bipm:xref" priority="2">
2903
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">
2910
+ <xsl:call-template name="insert_basic_link">
2911
+ <xsl:with-param name="element">
2912
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">
2904
2913
 
2905
- <xsl:if test="parent::*[local-name() = 'title']">
2906
- <xsl:attribute name="font-weight">normal</xsl:attribute>
2907
- </xsl:if>
2908
-
2909
- <xsl:choose>
2910
- <xsl:when test="@pagenumber='true'"><!-- ToC in Appendix, and page in references like this: « Le BIPM et la Convention du Mètre » (page 5). -->
2911
- <fo:inline>
2912
- <!-- DEBUG -->
2913
- <xsl:if test="@id">
2914
- <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
2915
- </xsl:if>
2916
- <fo:page-number-citation ref-id="{@target}"/>
2917
- <!-- <xsl:if test="@to">&#x2013;<fo:page-number-citation ref-id="{@to}"/></xsl:if> -->
2918
- </fo:inline>
2919
- </xsl:when>
2920
- <xsl:when test="starts-with(normalize-space(following-sibling::node()[1]), ')')">
2921
- <!-- add , see p. N -->
2922
- <!-- add , voir p. N -->
2923
- <xsl:apply-templates/>
2924
-
2925
- <xsl:variable name="nopage" select="normalize-space(@nopage)"/>
2914
+ <xsl:if test="parent::*[local-name() = 'title']">
2915
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
2916
+ </xsl:if>
2926
2917
 
2927
- <xsl:if test="$nopage != 'true'">
2928
- <xsl:text>, </xsl:text>
2929
- <xsl:variable name="nosee" select="normalize-space(@nosee)"/>
2930
- <xsl:if test="$nosee != 'true'">
2931
- <xsl:variable name="curr_lang" select="ancestor::bipm:bipm-standard/bipm:bibdata/bipm:language[@current = 'true']"/>
2918
+ <xsl:choose>
2919
+ <xsl:when test="@pagenumber='true'"><!-- ToC in Appendix, and page in references like this: « Le BIPM et la Convention du Mètre » (page 5). -->
2932
2920
  <fo:inline>
2933
- <xsl:if test="ancestor::bipm:note_side">
2934
- <xsl:attribute name="font-style">italic</xsl:attribute>
2921
+ <!-- DEBUG -->
2922
+ <xsl:if test="@id">
2923
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
2935
2924
  </xsl:if>
2936
- <xsl:value-of select="ancestor::bipm:bipm-standard/bipm:localized-strings/bipm:localized-string[@key='see' and @language=$curr_lang]"/>
2925
+ <fo:page-number-citation ref-id="{@target}"/>
2926
+ <!-- <xsl:if test="@to">&#x2013;<fo:page-number-citation ref-id="{@to}"/></xsl:if> -->
2937
2927
  </fo:inline>
2938
- <xsl:text> </xsl:text>
2939
- </xsl:if>
2940
- <xsl:text>p. </xsl:text>
2941
- <fo:page-number-citation ref-id="{@target}"/>
2942
- </xsl:if>
2943
- </xsl:when>
2944
- <xsl:otherwise>
2945
- <fo:inline><xsl:apply-templates/></fo:inline>
2946
- </xsl:otherwise>
2947
- </xsl:choose>
2948
- </fo:basic-link>
2928
+ </xsl:when>
2929
+ <xsl:when test="starts-with(normalize-space(following-sibling::node()[1]), ')')">
2930
+ <!-- add , see p. N -->
2931
+ <!-- add , voir p. N -->
2932
+ <xsl:apply-templates/>
2933
+
2934
+ <xsl:variable name="nopage" select="normalize-space(@nopage)"/>
2935
+
2936
+ <xsl:if test="$nopage != 'true'">
2937
+ <xsl:text>, </xsl:text>
2938
+ <xsl:variable name="nosee" select="normalize-space(@nosee)"/>
2939
+ <xsl:if test="$nosee != 'true'">
2940
+ <xsl:variable name="curr_lang" select="ancestor::bipm:bipm-standard/bipm:bibdata/bipm:language[@current = 'true']"/>
2941
+ <fo:inline>
2942
+ <xsl:if test="ancestor::bipm:note_side">
2943
+ <xsl:attribute name="font-style">italic</xsl:attribute>
2944
+ </xsl:if>
2945
+ <xsl:value-of select="ancestor::bipm:bipm-standard/bipm:localized-strings/bipm:localized-string[@key='see' and @language=$curr_lang]"/>
2946
+ </fo:inline>
2947
+ <xsl:text> </xsl:text>
2948
+ </xsl:if>
2949
+ <xsl:text>p. </xsl:text>
2950
+ <fo:page-number-citation ref-id="{@target}"/>
2951
+ </xsl:if>
2952
+ </xsl:when>
2953
+ <xsl:otherwise>
2954
+ <fo:inline><xsl:apply-templates/></fo:inline>
2955
+ </xsl:otherwise>
2956
+ </xsl:choose>
2957
+ </fo:basic-link>
2958
+ </xsl:with-param>
2959
+ </xsl:call-template>
2949
2960
  </xsl:template>
2950
2961
 
2951
2962
  <xsl:template match="bipm:eref[.//bipm:locality[@type = 'anchor']]" priority="2">
2952
2963
  <xsl:variable name="target" select=".//bipm:locality[@type = 'anchor']/bipm:referenceFrom"/>
2953
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{$target}">
2954
- <xsl:if test="xalan:nodeset($ids)//id = $target">
2955
- <fo:page-number-citation ref-id="{$target}"/>
2956
- </xsl:if>
2957
- </fo:basic-link>
2964
+ <xsl:call-template name="insert_basic_link">
2965
+ <xsl:with-param name="element">
2966
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{$target}">
2967
+ <xsl:if test="xalan:nodeset($ids)//id = $target">
2968
+ <fo:page-number-citation ref-id="{$target}"/>
2969
+ </xsl:if>
2970
+ </fo:basic-link>
2971
+ </xsl:with-param>
2972
+ </xsl:call-template>
2958
2973
  </xsl:template>
2959
2974
 
2960
2975
  <xsl:template match="bipm:note[not(ancestor::bipm:preface)]/bipm:name" priority="2">
@@ -3109,7 +3124,7 @@
3109
3124
 
3110
3125
  <!-- Decrease height of / and | -->
3111
3126
  <!-- Decrease space before and after / -->
3112
- <xsl:template match="mathml:mo[normalize-space(text()) = '/' or normalize-space(text()) = '|']" mode="mathml">
3127
+ <xsl:template match="mathml:mo[normalize-space(text()) = '/' or normalize-space(text()) = '|']" mode="mathml" priority="2">
3113
3128
  <xsl:copy>
3114
3129
  <xsl:apply-templates select="@*" mode="mathml"/>
3115
3130
  <xsl:if test="not(@stretchy) and not(preceding-sibling::*[1][local-name() = 'mfrac'] and following-sibling::*[1][local-name() = 'mfrac'])">
@@ -3256,6 +3271,23 @@
3256
3271
  <xsl:template match="bipm:clause[@type = 'toc']//bipm:title/text()[1][not(preceding-sibling::bipm:tab) and following-sibling::*[1][self::bipm:tab]]"/>
3257
3272
  <xsl:template match="bipm:clause[@type = 'toc']//bipm:title/bipm:tab" priority="2"/>
3258
3273
 
3274
+ <xsl:template match="*[local-name() = 'xref']" mode="toc_table_width" priority="2">
3275
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
3276
+ <xsl:for-each select="*[local-name() = 'tab']">
3277
+ <xsl:variable name="pos" select="position()"/>
3278
+ <xsl:variable name="current_id" select="generate-id()"/>
3279
+ <td>
3280
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
3281
+ <xsl:choose>
3282
+ <xsl:when test="$pos = 1 and self::text()"><xsl:value-of select="translate(., ' ', ' ')"/></xsl:when>
3283
+ <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
3284
+ </xsl:choose>
3285
+ </xsl:for-each>
3286
+ </td>
3287
+ </xsl:for-each>
3288
+ <td>333</td> <!-- page number, just for fill -->
3289
+ </xsl:template>
3290
+
3259
3291
  <!-- =================== -->
3260
3292
  <!-- End Table of Contents (ToC) processing -->
3261
3293
  <!-- =================== -->
@@ -4554,6 +4586,7 @@
4554
4586
  </xsl:attribute-set>
4555
4587
 
4556
4588
  <xsl:attribute-set name="xref-style">
4589
+ <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
4557
4590
 
4558
4591
  </xsl:attribute-set>
4559
4592
 
@@ -6636,9 +6669,13 @@
6636
6669
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
6637
6670
  </xsl:if>
6638
6671
 
6639
- <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
6640
- <xsl:value-of select="$current_fn_number_text"/>
6641
- </fo:basic-link>
6672
+ <xsl:call-template name="insert_basic_link">
6673
+ <xsl:with-param name="element">
6674
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
6675
+ <xsl:value-of select="$current_fn_number_text"/>
6676
+ </fo:basic-link>
6677
+ </xsl:with-param>
6678
+ </xsl:call-template>
6642
6679
  </fo:inline>
6643
6680
  </xsl:variable>
6644
6681
 
@@ -6980,8 +7017,10 @@
6980
7017
  <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
6981
7018
  <xsl:text> </xsl:text>
6982
7019
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
6983
- <xsl:text/>
6984
- <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
7020
+ <xsl:if test="*[local-name()='dd']/node()[normalize-space() != ''][1][self::text()]">
7021
+ <xsl:text> </xsl:text>
7022
+ </xsl:if>
7023
+ <xsl:apply-templates select="*[local-name()='dd']/node()" mode="inline"/>
6985
7024
  </fo:block>
6986
7025
 
6987
7026
  </xsl:when> <!-- END: only one component -->
@@ -7468,8 +7507,18 @@
7468
7507
  </xsl:if>
7469
7508
  </xsl:template>
7470
7509
 
7471
- <xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
7472
- <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
7510
+ <xsl:template match="*[local-name()='dd']/*" mode="inline">
7511
+ <xsl:variable name="is_inline_element_after_where">
7512
+ <xsl:if test="(local-name() = 'p') and not(preceding-sibling::node()[normalize-space() != ''])">true</xsl:if>
7513
+ </xsl:variable>
7514
+ <xsl:choose>
7515
+ <xsl:when test="$is_inline_element_after_where = 'true'">
7516
+ <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
7517
+ </xsl:when>
7518
+ <xsl:otherwise>
7519
+ <xsl:apply-templates select="."/>
7520
+ </xsl:otherwise>
7521
+ </xsl:choose>
7473
7522
  </xsl:template>
7474
7523
 
7475
7524
  <!-- virtual html table for dl/[dt and dd] for IF (Intermediate Format) -->
@@ -8933,6 +8982,79 @@
8933
8982
  <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
8934
8983
  </xsl:template>
8935
8984
 
8985
+ <!-- special case for:
8986
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
8987
+ <mstyle displaystyle="true">
8988
+ <msup>
8989
+ <mi color="#00000000">C</mi>
8990
+ <mtext>R</mtext>
8991
+ </msup>
8992
+ <msubsup>
8993
+ <mtext>C</mtext>
8994
+ <mi>n</mi>
8995
+ <mi>k</mi>
8996
+ </msubsup>
8997
+ </mstyle>
8998
+ </math>
8999
+ -->
9000
+ <xsl:template match="mathml:msup/mathml:mi[. = '‌' or . = ''][not(preceding-sibling::*)][following-sibling::mathml:mtext]" mode="mathml">
9001
+ <xsl:copy>
9002
+ <xsl:copy-of select="@*"/>
9003
+ <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"/>
9004
+ <xsl:if test="string-length($next_mtext) != ''">
9005
+ <xsl:attribute name="color">#00000000</xsl:attribute>
9006
+ </xsl:if>
9007
+ <xsl:apply-templates/>
9008
+ <xsl:value-of select="$next_mtext"/>
9009
+ </xsl:copy>
9010
+ </xsl:template>
9011
+
9012
+ <!-- special case for:
9013
+ <msup>
9014
+ <mtext/>
9015
+ <mn>1</mn>
9016
+ </msup>
9017
+ convert to (add mspace after mtext and enclose them into mrow):
9018
+ <msup>
9019
+ <mrow>
9020
+ <mtext/>
9021
+ <mspace height="1.47ex"/>
9022
+ </mrow>
9023
+ <mn>1</mn>
9024
+ </msup>
9025
+ -->
9026
+ <xsl:template match="mathml:msup/mathml:mtext[not(preceding-sibling::*)]" mode="mathml">
9027
+ <mathml:mrow>
9028
+ <xsl:copy-of select="."/>
9029
+ <mathml:mspace height="1.47ex"/>
9030
+ </mathml:mrow>
9031
+ </xsl:template>
9032
+
9033
+ <!-- add space around vertical line -->
9034
+ <xsl:template match="mathml:mo[normalize-space(text()) = '|']" mode="mathml">
9035
+ <xsl:copy>
9036
+ <xsl:apply-templates select="@*" mode="mathml"/>
9037
+ <xsl:if test="not(@lspace)">
9038
+ <xsl:attribute name="lspace">0.4em</xsl:attribute>
9039
+ </xsl:if>
9040
+ <xsl:if test="not(@rspace)">
9041
+ <xsl:attribute name="rspace">0.4em</xsl:attribute>
9042
+ </xsl:if>
9043
+ <xsl:apply-templates mode="mathml"/>
9044
+ </xsl:copy>
9045
+ </xsl:template>
9046
+
9047
+ <!-- decrease fontsize for 'Circled Times' char -->
9048
+ <xsl:template match="mathml:mo[normalize-space(text()) = '⊗']" mode="mathml">
9049
+ <xsl:copy>
9050
+ <xsl:apply-templates select="@*" mode="mathml"/>
9051
+ <xsl:if test="not(@fontsize)">
9052
+ <xsl:attribute name="fontsize">55%</xsl:attribute>
9053
+ </xsl:if>
9054
+ <xsl:apply-templates mode="mathml"/>
9055
+ </xsl:copy>
9056
+ </xsl:template>
9057
+
8936
9058
  <!-- Examples:
8937
9059
  <stem type="AsciiMath">x = 1</stem>
8938
9060
  <stem type="AsciiMath"><asciimath>x = 1</asciimath></stem>
@@ -8994,19 +9116,23 @@
8994
9116
  <xsl:apply-templates/>
8995
9117
  </xsl:when>
8996
9118
  <xsl:otherwise>
8997
- <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
8998
- <xsl:choose>
8999
- <xsl:when test="normalize-space(.) = ''">
9000
- <xsl:call-template name="add-zero-spaces-link-java">
9001
- <xsl:with-param name="text" select="$target_text"/>
9002
- </xsl:call-template>
9003
- </xsl:when>
9004
- <xsl:otherwise>
9005
- <!-- output text from <link>text</link> -->
9006
- <xsl:apply-templates/>
9007
- </xsl:otherwise>
9008
- </xsl:choose>
9009
- </fo:basic-link>
9119
+ <xsl:call-template name="insert_basic_link">
9120
+ <xsl:with-param name="element">
9121
+ <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
9122
+ <xsl:choose>
9123
+ <xsl:when test="normalize-space(.) = ''">
9124
+ <xsl:call-template name="add-zero-spaces-link-java">
9125
+ <xsl:with-param name="text" select="$target_text"/>
9126
+ </xsl:call-template>
9127
+ </xsl:when>
9128
+ <xsl:otherwise>
9129
+ <!-- output text from <link>text</link> -->
9130
+ <xsl:apply-templates/>
9131
+ </xsl:otherwise>
9132
+ </xsl:choose>
9133
+ </fo:basic-link>
9134
+ </xsl:with-param>
9135
+ </xsl:call-template>
9010
9136
  </xsl:otherwise>
9011
9137
  </xsl:choose>
9012
9138
  </fo:inline>
@@ -9069,12 +9195,16 @@
9069
9195
  </xsl:template>
9070
9196
 
9071
9197
  <xsl:template match="*[local-name() = 'xref']">
9072
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
9073
- <xsl:if test="parent::*[local-name() = 'add']">
9074
- <xsl:call-template name="append_add-style"/>
9075
- </xsl:if>
9076
- <xsl:apply-templates/>
9077
- </fo:basic-link>
9198
+ <xsl:call-template name="insert_basic_link">
9199
+ <xsl:with-param name="element">
9200
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
9201
+ <xsl:if test="parent::*[local-name() = 'add']">
9202
+ <xsl:call-template name="append_add-style"/>
9203
+ </xsl:if>
9204
+ <xsl:apply-templates/>
9205
+ </fo:basic-link>
9206
+ </xsl:with-param>
9207
+ </xsl:call-template>
9078
9208
  </xsl:template>
9079
9209
 
9080
9210
  <!-- ====== -->
@@ -9485,7 +9615,7 @@
9485
9615
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
9486
9616
  </xsl:when>
9487
9617
  <xsl:when test="not(starts-with(@src, 'data:'))">
9488
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
9618
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9489
9619
  </xsl:when>
9490
9620
  <xsl:otherwise>
9491
9621
  <xsl:value-of select="@src"/>
@@ -9507,7 +9637,7 @@
9507
9637
  </xsl:when>
9508
9638
  <xsl:when test="not(starts-with(@src, 'data:'))">
9509
9639
  <xsl:variable name="src">
9510
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
9640
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
9511
9641
  </xsl:variable>
9512
9642
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
9513
9643
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -9893,15 +10023,19 @@
9893
10023
  <xsl:param name="dest"/>
9894
10024
  <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
9895
10025
  <fo:block font-size="1pt">
9896
- <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
9897
- <fo:inline-container inline-progression-dimension="100%">
9898
- <fo:block-container height="{$height - 1}px" width="100%">
9899
- <!-- DEBUG <xsl:if test="local-name()='polygon'">
9900
- <xsl:attribute name="background-color">magenta</xsl:attribute>
9901
- </xsl:if> -->
9902
- <fo:block> </fo:block></fo:block-container>
9903
- </fo:inline-container>
9904
- </fo:basic-link>
10026
+ <xsl:call-template name="insert_basic_link">
10027
+ <xsl:with-param name="element">
10028
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
10029
+ <fo:inline-container inline-progression-dimension="100%">
10030
+ <fo:block-container height="{$height - 1}px" width="100%">
10031
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
10032
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
10033
+ </xsl:if> -->
10034
+ <fo:block> </fo:block></fo:block-container>
10035
+ </fo:inline-container>
10036
+ </fo:basic-link>
10037
+ </xsl:with-param>
10038
+ </xsl:call-template>
9905
10039
  </fo:block>
9906
10040
  </fo:block-container>
9907
10041
  </xsl:template>
@@ -11459,14 +11593,18 @@
11459
11593
  </xsl:template>
11460
11594
 
11461
11595
  <xsl:template match="*[local-name() = 'origin']">
11462
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
11463
- <xsl:if test="normalize-space(@citeas) = ''">
11464
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
11465
- </xsl:if>
11466
- <fo:inline xsl:use-attribute-sets="origin-style">
11467
- <xsl:apply-templates/>
11468
- </fo:inline>
11469
- </fo:basic-link>
11596
+ <xsl:call-template name="insert_basic_link">
11597
+ <xsl:with-param name="element">
11598
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
11599
+ <xsl:if test="normalize-space(@citeas) = ''">
11600
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
11601
+ </xsl:if>
11602
+ <fo:inline xsl:use-attribute-sets="origin-style">
11603
+ <xsl:apply-templates/>
11604
+ </fo:inline>
11605
+ </fo:basic-link>
11606
+ </xsl:with-param>
11607
+ </xsl:call-template>
11470
11608
  </xsl:template>
11471
11609
 
11472
11610
  <!-- not using, see https://github.com/glossarist/iev-document/issues/23 -->
@@ -11540,9 +11678,13 @@
11540
11678
  <xsl:if test="../*[local-name() = 'author']">
11541
11679
  <xsl:text>, </xsl:text>
11542
11680
  </xsl:if>
11543
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
11544
- <xsl:apply-templates/>
11545
- </fo:basic-link>
11681
+ <xsl:call-template name="insert_basic_link">
11682
+ <xsl:with-param name="element">
11683
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
11684
+ <xsl:apply-templates/>
11685
+ </fo:basic-link>
11686
+ </xsl:with-param>
11687
+ </xsl:call-template>
11546
11688
  </xsl:template>
11547
11689
 
11548
11690
  <xsl:template match="*[local-name() = 'author']">
@@ -11591,34 +11733,38 @@
11591
11733
  <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
11592
11734
  <xsl:variable name="text" select="normalize-space()"/>
11593
11735
 
11594
- <fo:basic-link fox:alt-text="{@citeas}">
11595
- <xsl:if test="normalize-space(@citeas) = ''">
11596
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
11597
- </xsl:if>
11598
- <xsl:if test="@type = 'inline'">
11736
+ <xsl:call-template name="insert_basic_link">
11737
+ <xsl:with-param name="element">
11738
+ <fo:basic-link fox:alt-text="{@citeas}">
11739
+ <xsl:if test="normalize-space(@citeas) = ''">
11740
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
11741
+ </xsl:if>
11742
+ <xsl:if test="@type = 'inline'">
11599
11743
 
11600
- <xsl:attribute name="color">blue</xsl:attribute>
11601
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
11744
+ <xsl:attribute name="color">blue</xsl:attribute>
11745
+ <xsl:if test="not(parent::*[local-name() = 'title'])">
11746
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
11747
+ </xsl:if>
11748
+ <xsl:if test="parent::*[local-name() = 'title']">
11749
+ <xsl:attribute name="color">inherit</xsl:attribute>
11750
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
11751
+ </xsl:if>
11602
11752
 
11603
- <xsl:if test="parent::*[local-name() = 'title']">
11604
- <xsl:attribute name="color">inherit</xsl:attribute>
11605
- <xsl:attribute name="text-decoration">inherit</xsl:attribute>
11606
- <xsl:attribute name="font-weight">normal</xsl:attribute>
11607
11753
  </xsl:if>
11608
11754
 
11609
- </xsl:if>
11610
-
11611
- <xsl:choose>
11612
- <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
11613
- <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
11614
- </xsl:when>
11615
- <xsl:otherwise>
11616
- <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
11617
- </xsl:otherwise>
11618
- </xsl:choose>
11755
+ <xsl:choose>
11756
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
11757
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
11758
+ </xsl:when>
11759
+ <xsl:otherwise>
11760
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
11761
+ </xsl:otherwise>
11762
+ </xsl:choose>
11619
11763
 
11620
- <xsl:apply-templates/>
11621
- </fo:basic-link>
11764
+ <xsl:apply-templates/>
11765
+ </fo:basic-link>
11766
+ </xsl:with-param>
11767
+ </xsl:call-template>
11622
11768
 
11623
11769
  </fo:inline>
11624
11770
  </xsl:when>
@@ -11857,7 +12003,10 @@
11857
12003
  <xsl:variable name="ul_labels" select="xalan:nodeset($ul_labels_)"/>
11858
12004
 
11859
12005
  <xsl:template name="setULLabel">
11860
- <xsl:variable name="list_level_" select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
12006
+ <xsl:variable name="list_level__">
12007
+ <xsl:value-of select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
12008
+ </xsl:variable>
12009
+ <xsl:variable name="list_level_" select="number($list_level__)"/>
11861
12010
  <xsl:variable name="list_level">
11862
12011
  <xsl:choose>
11863
12012
  <xsl:when test="$list_level_ &lt;= 3"><xsl:value-of select="$list_level_"/></xsl:when>
@@ -11992,9 +12141,11 @@
11992
12141
  </fo:block-container>
11993
12142
  </xsl:when>
11994
12143
  <xsl:otherwise>
11995
- <fo:block>
11996
- <xsl:apply-templates select="." mode="list"/>
11997
- </fo:block>
12144
+
12145
+ <fo:block>
12146
+ <xsl:apply-templates select="." mode="list"/>
12147
+ </fo:block>
12148
+
11998
12149
  </xsl:otherwise>
11999
12150
  </xsl:choose>
12000
12151
  </xsl:template>
@@ -12676,24 +12827,32 @@
12676
12827
  <xsl:for-each select="*[local-name() = 'tab']">
12677
12828
  <xsl:variable name="current_id" select="generate-id()"/>
12678
12829
  <fo:table-cell>
12679
- <fo:block>
12680
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
12681
- <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
12682
- <xsl:choose>
12683
- <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
12684
- <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
12685
- </xsl:choose>
12686
- </xsl:for-each>
12687
- </fo:basic-link>
12830
+ <fo:block line-height-shift-adjustment="disregard-shifts">
12831
+ <xsl:call-template name="insert_basic_link">
12832
+ <xsl:with-param name="element">
12833
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
12834
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
12835
+ <xsl:choose>
12836
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
12837
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
12838
+ </xsl:choose>
12839
+ </xsl:for-each>
12840
+ </fo:basic-link>
12841
+ </xsl:with-param>
12842
+ </xsl:call-template>
12688
12843
  </fo:block>
12689
12844
  </fo:table-cell>
12690
12845
  </xsl:for-each>
12691
12846
  <!-- last column - for page numbers -->
12692
12847
  <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
12693
12848
  <fo:block>
12694
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
12695
- <fo:page-number-citation ref-id="{$target}"/>
12696
- </fo:basic-link>
12849
+ <xsl:call-template name="insert_basic_link">
12850
+ <xsl:with-param name="element">
12851
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
12852
+ <fo:page-number-citation ref-id="{$target}"/>
12853
+ </fo:basic-link>
12854
+ </xsl:with-param>
12855
+ </xsl:call-template>
12697
12856
  </fo:block>
12698
12857
  </fo:table-cell>
12699
12858
  </xsl:template>
@@ -12735,6 +12894,27 @@
12735
12894
  <!-- End Table of Contents (ToC) processing -->
12736
12895
  <!-- =================== -->
12737
12896
 
12897
+ <!-- insert fo:basic-link, if external-destination or internal-destination is non-empty, otherwise insert fo:inline -->
12898
+ <xsl:template name="insert_basic_link">
12899
+ <xsl:param name="element"/>
12900
+ <xsl:variable name="element_node" select="xalan:nodeset($element)"/>
12901
+ <xsl:variable name="external-destination" select="normalize-space(count($element_node/fo:basic-link/@external-destination[. != '']) = 1)"/>
12902
+ <xsl:variable name="internal-destination" select="normalize-space(count($element_node/fo:basic-link/@internal-destination[. != '']) = 1)"/>
12903
+ <xsl:choose>
12904
+ <xsl:when test="$external-destination = 'true' or $internal-destination = 'true'">
12905
+ <xsl:copy-of select="$element_node"/>
12906
+ </xsl:when>
12907
+ <xsl:otherwise>
12908
+ <fo:inline>
12909
+ <xsl:for-each select="$element_node/fo:basic-link/@*[local-name() != 'external-destination' and local-name() != 'internal-destination' and local-name() != 'alt-text']">
12910
+ <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
12911
+ </xsl:for-each>
12912
+ <xsl:copy-of select="$element_node/fo:basic-link/node()"/>
12913
+ </fo:inline>
12914
+ </xsl:otherwise>
12915
+ </xsl:choose>
12916
+ </xsl:template>
12917
+
12738
12918
  <xsl:template match="*[local-name() = 'variant-title']"/> <!-- [@type = 'sub'] -->
12739
12919
  <xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
12740
12920
  <fo:inline padding-right="5mm"> </fo:inline>