metanorma-bipm 1.1.0 → 1.1.1

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.
@@ -4,7 +4,7 @@ require "sterile"
4
4
  module IsoDoc
5
5
  module BIPM
6
6
  class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
7
- def add_id
7
+ def add_id
8
8
  %(id="_#{UUIDTools::UUID.random_create}")
9
9
  end
10
10
 
@@ -15,7 +15,8 @@ module IsoDoc
15
15
  end
16
16
  i = docxml.at(ns("//indexsect")) ||
17
17
  docxml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}</title></indexsect>").first
18
- index = sort_indexterms(docxml.xpath(ns("//index")), docxml.xpath(ns("//index-xref[@also = 'false']")),
18
+ index = sort_indexterms(docxml.xpath(ns("//index")),
19
+ docxml.xpath(ns("//index-xref[@also = 'false']")),
19
20
  docxml.xpath(ns("//index-xref[@also = 'true']")))
20
21
  index1(docxml, i, index)
21
22
  end
@@ -41,8 +42,11 @@ module IsoDoc
41
42
  end
42
43
 
43
44
  def index_entries(words, index, primary)
44
- ret = index_entries_head(words[primary], index.dig(words[primary], nil, nil), index_entries_opt)
45
- words2 = index[words[primary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
45
+ ret = index_entries_head(words[primary],
46
+ index.dig(words[primary], nil, nil),
47
+ index_entries_opt)
48
+ words2 = index[words[primary]]&.keys&.reject { |k| k.nil? }
49
+ &.each_with_object({}) { |w, v| v[w.downcase] = w }
46
50
  unless words2.empty?
47
51
  ret += "<ul>"
48
52
  words2.keys.localize(@lang.to_sym).sort.to_a.each do |w|
@@ -54,8 +58,11 @@ module IsoDoc
54
58
  end
55
59
 
56
60
  def index_entries2(words, index, secondary)
57
- ret = index_entries_head(words[secondary], index.dig(words[secondary], nil), index_entries_opt)
58
- words3 = index[words[secondary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
61
+ ret = index_entries_head(words[secondary],
62
+ index.dig(words[secondary], nil),
63
+ index_entries_opt)
64
+ words3 = index[words[secondary]]&.keys&.reject { |k| k.nil? }
65
+ &.each_with_object({}) { |w, v| v[w.downcase] = w }
59
66
  unless words3.empty?
60
67
  ret += "<ul>"
61
68
  words3.keys.localize(@lang.to_sym).sort.to_a.each do |w|
@@ -2239,6 +2239,7 @@
2239
2239
  <xsl:attribute name="font-family">Times New Roman, STIX Two Math, Source Han Sans</xsl:attribute>
2240
2240
  <xsl:attribute name="font-size">10.5pt</xsl:attribute>
2241
2241
 
2242
+
2242
2243
  </xsl:attribute-set><xsl:attribute-set name="link-style">
2243
2244
 
2244
2245
  <xsl:attribute name="color">blue</xsl:attribute>
@@ -2321,6 +2322,7 @@
2321
2322
 
2322
2323
 
2323
2324
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
2325
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2324
2326
 
2325
2327
 
2326
2328
 
@@ -2587,13 +2589,25 @@
2587
2589
 
2588
2590
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2589
2591
 
2590
- </xsl:attribute-set><xsl:attribute-set name="add-style">
2592
+ </xsl:attribute-set><xsl:variable name="color-added-text">
2593
+ <xsl:text>rgb(0, 255, 0)</xsl:text>
2594
+ </xsl:variable><xsl:attribute-set name="add-style">
2591
2595
  <xsl:attribute name="color">red</xsl:attribute>
2592
2596
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
2593
- </xsl:attribute-set><xsl:attribute-set name="del-style">
2594
- <xsl:attribute name="color">red</xsl:attribute>
2597
+ <!-- <xsl:attribute name="color">black</xsl:attribute>
2598
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
2599
+ <xsl:attribute name="padding-top">1mm</xsl:attribute>
2600
+ <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> -->
2601
+ </xsl:attribute-set><xsl:variable name="color-deleted-text">
2602
+ <xsl:text>red</xsl:text>
2603
+ </xsl:variable><xsl:attribute-set name="del-style">
2604
+ <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
2595
2605
  <xsl:attribute name="text-decoration">line-through</xsl:attribute>
2596
- </xsl:attribute-set><xsl:template name="processPrefaceSectionsDefault_Contents">
2606
+ </xsl:attribute-set><xsl:attribute-set name="mathml-style">
2607
+ <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
2608
+
2609
+
2610
+ </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
2597
2611
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
2598
2612
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
2599
2613
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
@@ -2638,16 +2652,17 @@
2638
2652
  <xsl:call-template name="add-zero-spaces-java"/>
2639
2653
  </xsl:template><xsl:template match="*[local-name()='table']" name="table">
2640
2654
 
2655
+ <xsl:variable name="table-preamble">
2656
+
2657
+
2658
+ </xsl:variable>
2659
+
2641
2660
  <xsl:variable name="table">
2642
2661
 
2643
2662
  <xsl:variable name="simple-table">
2644
2663
  <xsl:call-template name="getSimpleTable"/>
2645
2664
  </xsl:variable>
2646
2665
 
2647
-
2648
-
2649
-
2650
-
2651
2666
  <!-- <xsl:if test="$namespace = 'bipm'">
2652
2667
  <fo:block>&#xA0;</fo:block>
2653
2668
  </xsl:if> -->
@@ -2658,7 +2673,7 @@
2658
2673
 
2659
2674
 
2660
2675
 
2661
- <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
2676
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2662
2677
 
2663
2678
  <!-- <xsl:variable name="cols-count">
2664
2679
  <xsl:choose>
@@ -2677,8 +2692,6 @@
2677
2692
  <!-- cols-count=<xsl:copy-of select="$cols-count"/> -->
2678
2693
  <!-- cols-count2=<xsl:copy-of select="$cols-count2"/> -->
2679
2694
 
2680
-
2681
-
2682
2695
  <xsl:variable name="colwidths">
2683
2696
  <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2684
2697
  <xsl:call-template name="calculate-column-widths">
@@ -2706,6 +2719,7 @@
2706
2719
  </xsl:choose>
2707
2720
  </xsl:variable>
2708
2721
 
2722
+
2709
2723
  <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm">
2710
2724
 
2711
2725
  <xsl:attribute name="font-size">10pt</xsl:attribute>
@@ -2749,6 +2763,7 @@
2749
2763
 
2750
2764
 
2751
2765
 
2766
+
2752
2767
  <attribute name="margin-left">0mm</attribute>
2753
2768
  <attribute name="margin-right">0mm</attribute>
2754
2769
 
@@ -2841,7 +2856,8 @@
2841
2856
  </fo:block-container>
2842
2857
  </xsl:variable>
2843
2858
 
2844
-
2859
+ <xsl:variable name="isAdded" select="@added"/>
2860
+ <xsl:variable name="isDeleted" select="@deleted"/>
2845
2861
 
2846
2862
  <xsl:choose>
2847
2863
  <xsl:when test="@width">
@@ -2855,7 +2871,14 @@
2855
2871
  <fo:table-body>
2856
2872
  <fo:table-row>
2857
2873
  <fo:table-cell column-number="2">
2858
- <fo:block><xsl:copy-of select="$table"/></fo:block>
2874
+ <xsl:copy-of select="$table-preamble"/>
2875
+ <fo:block>
2876
+ <xsl:call-template name="setTrackChangesStyles">
2877
+ <xsl:with-param name="isAdded" select="$isAdded"/>
2878
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
2879
+ </xsl:call-template>
2880
+ <xsl:copy-of select="$table"/>
2881
+ </fo:block>
2859
2882
  </fo:table-cell>
2860
2883
  </fo:table-row>
2861
2884
  </fo:table-body>
@@ -2866,7 +2889,22 @@
2866
2889
 
2867
2890
  </xsl:when>
2868
2891
  <xsl:otherwise>
2869
- <xsl:copy-of select="$table"/>
2892
+ <xsl:choose>
2893
+ <xsl:when test="$isAdded = 'true' or $isDeleted = 'true'">
2894
+ <xsl:copy-of select="$table-preamble"/>
2895
+ <fo:block>
2896
+ <xsl:call-template name="setTrackChangesStyles">
2897
+ <xsl:with-param name="isAdded" select="$isAdded"/>
2898
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
2899
+ </xsl:call-template>
2900
+ <xsl:copy-of select="$table"/>
2901
+ </fo:block>
2902
+ </xsl:when>
2903
+ <xsl:otherwise>
2904
+ <xsl:copy-of select="$table-preamble"/>
2905
+ <xsl:copy-of select="$table"/>
2906
+ </xsl:otherwise>
2907
+ </xsl:choose>
2870
2908
  </xsl:otherwise>
2871
2909
  </xsl:choose>
2872
2910
 
@@ -2929,7 +2967,7 @@
2929
2967
  </xsl:for-each>
2930
2968
  </xsl:when>
2931
2969
  <xsl:otherwise>
2932
- <xsl:for-each select="xalan:nodeset($table)//tr">
2970
+ <xsl:for-each select="xalan:nodeset($table)/*/tr">
2933
2971
  <xsl:variable name="td_text">
2934
2972
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
2935
2973
 
@@ -3327,7 +3365,8 @@
3327
3365
  <xsl:attribute name="text-align">
3328
3366
  <xsl:choose>
3329
3367
  <xsl:when test="@align">
3330
- <xsl:value-of select="@align"/>
3368
+ <xsl:call-template name="setAlignment"/>
3369
+ <!-- <xsl:value-of select="@align"/> -->
3331
3370
  </xsl:when>
3332
3371
  <xsl:otherwise>center</xsl:otherwise>
3333
3372
  </xsl:choose>
@@ -3345,6 +3384,9 @@
3345
3384
 
3346
3385
 
3347
3386
 
3387
+ <xsl:if test="$lang = 'ar'">
3388
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
3389
+ </xsl:if>
3348
3390
  <xsl:if test="@colspan">
3349
3391
  <xsl:attribute name="number-columns-spanned">
3350
3392
  <xsl:value-of select="@colspan"/>
@@ -3376,11 +3418,15 @@
3376
3418
  <xsl:attribute name="text-align">
3377
3419
  <xsl:choose>
3378
3420
  <xsl:when test="@align">
3379
- <xsl:value-of select="@align"/>
3421
+ <xsl:call-template name="setAlignment"/>
3422
+ <!-- <xsl:value-of select="@align"/> -->
3380
3423
  </xsl:when>
3381
3424
  <xsl:otherwise>left</xsl:otherwise>
3382
3425
  </xsl:choose>
3383
3426
  </xsl:attribute>
3427
+ <xsl:if test="$lang = 'ar'">
3428
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
3429
+ </xsl:if>
3384
3430
  <!-- and ancestor::*[local-name() = 'thead'] -->
3385
3431
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
3386
3432
 
@@ -3398,6 +3444,9 @@
3398
3444
 
3399
3445
 
3400
3446
 
3447
+ <xsl:if test=".//*[local-name() = 'table']">
3448
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
3449
+ </xsl:if>
3401
3450
  <xsl:if test="@colspan">
3402
3451
  <xsl:attribute name="number-columns-spanned">
3403
3452
  <xsl:value-of select="@colspan"/>
@@ -3531,13 +3580,13 @@
3531
3580
  </xsl:choose>
3532
3581
  </xsl:variable>
3533
3582
  <!-- <xsl:variable name="ns" select="substring-before(name(/*), '-')"/> -->
3534
- <xsl:element name="{$ns}:table">
3583
+ <!-- <xsl:element name="{$ns}:table"> -->
3535
3584
  <xsl:for-each select="*[local-name() = 'dl'][1]">
3536
3585
  <tbody>
3537
3586
  <xsl:apply-templates mode="dl"/>
3538
3587
  </tbody>
3539
3588
  </xsl:for-each>
3540
- </xsl:element>
3589
+ <!-- </xsl:element> -->
3541
3590
  </xsl:variable>
3542
3591
 
3543
3592
  <xsl:call-template name="calculate-column-widths">
@@ -3634,6 +3683,8 @@
3634
3683
  <xsl:apply-templates/>
3635
3684
  </fo:inline>
3636
3685
  </xsl:template><xsl:template match="*[local-name()='dl']">
3686
+ <xsl:variable name="isAdded" select="@added"/>
3687
+ <xsl:variable name="isDeleted" select="@deleted"/>
3637
3688
  <fo:block-container>
3638
3689
 
3639
3690
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
@@ -3650,6 +3701,12 @@
3650
3701
  </xsl:attribute>
3651
3702
 
3652
3703
  </xsl:if>
3704
+
3705
+ <xsl:call-template name="setTrackChangesStyles">
3706
+ <xsl:with-param name="isAdded" select="$isAdded"/>
3707
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
3708
+ </xsl:call-template>
3709
+
3653
3710
  <fo:block-container>
3654
3711
 
3655
3712
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
@@ -3771,11 +3828,11 @@
3771
3828
  </xsl:choose>
3772
3829
  </xsl:variable>
3773
3830
  <!-- <xsl:variable name="ns" select="substring-before(name(/*), '-')"/> -->
3774
- <xsl:element name="{$ns}:table">
3831
+ <!-- <xsl:element name="{$ns}:table"> -->
3775
3832
  <tbody>
3776
3833
  <xsl:apply-templates mode="dl"/>
3777
3834
  </tbody>
3778
- </xsl:element>
3835
+ <!-- </xsl:element> -->
3779
3836
  </xsl:variable>
3780
3837
  <!-- html-table<xsl:copy-of select="$html-table"/> -->
3781
3838
  <xsl:variable name="colwidths">
@@ -4045,9 +4102,71 @@
4045
4102
  <xsl:apply-templates/>
4046
4103
  </fo:inline>
4047
4104
  </xsl:template><xsl:template match="*[local-name()='add']">
4048
- <fo:inline xsl:use-attribute-sets="add-style">
4049
- <xsl:apply-templates/>
4050
- </fo:inline>
4105
+ <xsl:choose>
4106
+ <xsl:when test="@amendment">
4107
+ <fo:inline>
4108
+ <xsl:call-template name="insertTag">
4109
+ <xsl:with-param name="kind">A</xsl:with-param>
4110
+ <xsl:with-param name="value"><xsl:value-of select="@amendment"/></xsl:with-param>
4111
+ </xsl:call-template>
4112
+ <xsl:apply-templates/>
4113
+ <xsl:call-template name="insertTag">
4114
+ <xsl:with-param name="type">closing</xsl:with-param>
4115
+ <xsl:with-param name="kind">A</xsl:with-param>
4116
+ <xsl:with-param name="value"><xsl:value-of select="@amendment"/></xsl:with-param>
4117
+ </xsl:call-template>
4118
+ </fo:inline>
4119
+ </xsl:when>
4120
+ <xsl:when test="@corrigenda">
4121
+ <fo:inline>
4122
+ <xsl:call-template name="insertTag">
4123
+ <xsl:with-param name="kind">C</xsl:with-param>
4124
+ <xsl:with-param name="value"><xsl:value-of select="@corrigenda"/></xsl:with-param>
4125
+ </xsl:call-template>
4126
+ <xsl:apply-templates/>
4127
+ <xsl:call-template name="insertTag">
4128
+ <xsl:with-param name="type">closing</xsl:with-param>
4129
+ <xsl:with-param name="kind">C</xsl:with-param>
4130
+ <xsl:with-param name="value"><xsl:value-of select="@corrigenda"/></xsl:with-param>
4131
+ </xsl:call-template>
4132
+ </fo:inline>
4133
+ </xsl:when>
4134
+ <xsl:otherwise>
4135
+ <fo:inline xsl:use-attribute-sets="add-style">
4136
+ <xsl:apply-templates/>
4137
+ </fo:inline>
4138
+ </xsl:otherwise>
4139
+ </xsl:choose>
4140
+
4141
+ </xsl:template><xsl:template name="insertTag">
4142
+ <xsl:param name="type"/>
4143
+ <xsl:param name="kind"/>
4144
+ <xsl:param name="value"/>
4145
+ <xsl:variable name="add_width" select="string-length($value) * 20"/>
4146
+ <xsl:variable name="maxwidth" select="60 + $add_width"/>
4147
+ <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" -->
4148
+ <!-- <xsl:attribute name="width">7mm</xsl:attribute>
4149
+ <xsl:attribute name="content-height">100%</xsl:attribute> -->
4150
+ <xsl:attribute name="height">5mm</xsl:attribute>
4151
+ <xsl:attribute name="content-width">100%</xsl:attribute>
4152
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4153
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4154
+ <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4155
+ <g>
4156
+ <xsl:if test="$type = 'closing'">
4157
+ <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
4158
+ </xsl:if>
4159
+ <polyline points="0,0 {$maxwidth},0 {$maxwidth + 30},40 {$maxwidth},80 0,80 " stroke="black" stroke-width="5" fill="white"/>
4160
+ <line x1="0" y1="0" x2="0" y2="80" stroke="black" stroke-width="20"/>
4161
+ </g>
4162
+ <text font-family="Arial" x="15" y="57" font-size="40pt">
4163
+ <xsl:if test="$type = 'closing'">
4164
+ <xsl:attribute name="x">25</xsl:attribute>
4165
+ </xsl:if>
4166
+ <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
4167
+ </text>
4168
+ </svg>
4169
+ </fo:instream-foreign-object>
4051
4170
  </xsl:template><xsl:template match="*[local-name()='del']">
4052
4171
  <fo:inline xsl:use-attribute-sets="del-style">
4053
4172
  <xsl:apply-templates/>
@@ -4390,13 +4509,23 @@
4390
4509
  <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(substring($str, 1, 1)))"/>
4391
4510
  <xsl:value-of select="substring($str, 2)"/>
4392
4511
  </xsl:template><xsl:template match="mathml:math">
4393
- <fo:inline font-family="STIX Two Math"> <!-- -->
4512
+ <xsl:variable name="isAdded" select="@added"/>
4513
+ <xsl:variable name="isDeleted" select="@deleted"/>
4514
+
4515
+ <fo:inline xsl:use-attribute-sets="mathml-style">
4516
+
4517
+
4518
+ <xsl:call-template name="setTrackChangesStyles">
4519
+ <xsl:with-param name="isAdded" select="$isAdded"/>
4520
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
4521
+ </xsl:call-template>
4394
4522
 
4395
4523
  <xsl:variable name="mathml">
4396
4524
  <xsl:apply-templates select="." mode="mathml"/>
4397
4525
  </xsl:variable>
4398
4526
  <fo:instream-foreign-object fox:alt-text="Math">
4399
4527
 
4528
+
4400
4529
  <!-- <xsl:copy-of select="."/> -->
4401
4530
  <xsl:copy-of select="xalan:nodeset($mathml)"/>
4402
4531
  </fo:instream-foreign-object>
@@ -4642,8 +4771,15 @@
4642
4771
  </fo:inline>
4643
4772
  </xsl:if>
4644
4773
  </xsl:template><xsl:template match="*[local-name() = 'figure']" name="figure">
4774
+ <xsl:variable name="isAdded" select="@added"/>
4775
+ <xsl:variable name="isDeleted" select="@deleted"/>
4645
4776
  <fo:block-container id="{@id}">
4646
4777
 
4778
+ <xsl:call-template name="setTrackChangesStyles">
4779
+ <xsl:with-param name="isAdded" select="$isAdded"/>
4780
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
4781
+ </xsl:call-template>
4782
+
4647
4783
  <fo:block>
4648
4784
  <xsl:apply-templates/>
4649
4785
  </fo:block>
@@ -4663,6 +4799,8 @@
4663
4799
  <xsl:apply-templates/>
4664
4800
  </fo:block>
4665
4801
  </xsl:template><xsl:template match="*[local-name() = 'image']">
4802
+ <xsl:variable name="isAdded" select="../@added"/>
4803
+ <xsl:variable name="isDeleted" select="../@deleted"/>
4666
4804
  <xsl:choose>
4667
4805
  <xsl:when test="ancestor::*[local-name() = 'title']">
4668
4806
  <fo:inline padding-left="1mm" padding-right="1mm">
@@ -4678,7 +4816,26 @@
4678
4816
  <xsl:variable name="src">
4679
4817
  <xsl:call-template name="image_src"/>
4680
4818
  </xsl:variable>
4681
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
4819
+
4820
+ <xsl:choose>
4821
+ <xsl:when test="$isDeleted = 'true'">
4822
+ <!-- enclose in svg -->
4823
+ <fo:instream-foreign-object fox:alt-text="Image {@alt}">
4824
+ <xsl:attribute name="width">100%</xsl:attribute>
4825
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4826
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4827
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4828
+
4829
+
4830
+ <xsl:apply-templates select="." mode="cross_image"/>
4831
+
4832
+ </fo:instream-foreign-object>
4833
+ </xsl:when>
4834
+ <xsl:otherwise>
4835
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
4836
+ </xsl:otherwise>
4837
+ </xsl:choose>
4838
+
4682
4839
  </fo:block>
4683
4840
  </xsl:otherwise>
4684
4841
  </xsl:choose>
@@ -4694,6 +4851,55 @@
4694
4851
  <xsl:value-of select="@src"/>
4695
4852
  </xsl:otherwise>
4696
4853
  </xsl:choose>
4854
+ </xsl:template><xsl:template match="*[local-name() = 'image']" mode="cross_image">
4855
+ <xsl:choose>
4856
+ <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
4857
+ <xsl:variable name="src">
4858
+ <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
4859
+ </xsl:variable>
4860
+ <xsl:variable name="width" select="document($src)/@width"/>
4861
+ <xsl:variable name="height" select="document($src)/@height"/>
4862
+ <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="enable-background:new 0 0 595.28 841.89;" height="{$height}" width="{$width}" viewBox="0 0 {$width} {$height}" y="0px" x="0px" id="Layer_1" version="1.1">
4863
+ <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{$src}" style="overflow:visible;"/>
4864
+ </svg>
4865
+ </xsl:when>
4866
+ <xsl:when test="not(starts-with(@src, 'data:'))">
4867
+ <xsl:variable name="src">
4868
+ <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
4869
+ </xsl:variable>
4870
+ <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
4871
+ <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
4872
+ <xsl:variable name="width" select="java:getWidth($bufferedImage)"/>
4873
+ <xsl:variable name="height" select="java:getHeight($bufferedImage)"/>
4874
+ <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="enable-background:new 0 0 595.28 841.89;" height="{$height}" width="{$width}" viewBox="0 0 {$width} {$height}" y="0px" x="0px" id="Layer_1" version="1.1">
4875
+ <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{$src}" style="overflow:visible;"/>
4876
+ </svg>
4877
+ </xsl:when>
4878
+ <xsl:otherwise>
4879
+ <xsl:variable name="base64String" select="substring-after(@src, 'base64,')"/>
4880
+ <xsl:variable name="decoder" select="java:java.util.Base64.getDecoder()"/>
4881
+ <xsl:variable name="fileContent" select="java:decode($decoder, $base64String)"/>
4882
+ <xsl:variable name="bis" select="java:java.io.ByteArrayInputStream.new($fileContent)"/>
4883
+ <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($bis)"/>
4884
+ <xsl:variable name="width" select="java:getWidth($bufferedImage)"/>
4885
+ <!-- width=<xsl:value-of select="$width"/> -->
4886
+ <xsl:variable name="height" select="java:getHeight($bufferedImage)"/>
4887
+ <!-- height=<xsl:value-of select="$height"/> -->
4888
+ <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="enable-background:new 0 0 595.28 841.89;" height="{$height}" width="{$width}" viewBox="0 0 {$width} {$height}" y="0px" x="0px" id="Layer_1" version="1.1">
4889
+ <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{@src}" height="{$height}" width="{$width}" style="overflow:visible;"/>
4890
+ <xsl:call-template name="svg_cross">
4891
+ <xsl:with-param name="width" select="$width"/>
4892
+ <xsl:with-param name="height" select="$height"/>
4893
+ </xsl:call-template>
4894
+ </svg>
4895
+ </xsl:otherwise>
4896
+ </xsl:choose>
4897
+
4898
+ </xsl:template><xsl:template name="svg_cross">
4899
+ <xsl:param name="width"/>
4900
+ <xsl:param name="height"/>
4901
+ <line xmlns="http://www.w3.org/2000/svg" x1="0" y1="0" x2="{$width}" y2="{$height}" style="stroke: rgb(255, 0, 0); stroke-width:4px; "/>
4902
+ <line xmlns="http://www.w3.org/2000/svg" x1="0" y1="{$height}" x2="{$width}" y2="0" style="stroke: rgb(255, 0, 0); stroke-width:4px; "/>
4697
4903
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
4698
4904
  <xsl:apply-templates mode="contents"/>
4699
4905
  <xsl:text> </xsl:text>
@@ -5236,6 +5442,7 @@
5236
5442
  <xsl:variable name="element">
5237
5443
 
5238
5444
  inline
5445
+ <xsl:if test="following-sibling::*[1][local-name() = 'table']">block</xsl:if>
5239
5446
  </xsl:variable>
5240
5447
  <xsl:choose>
5241
5448
  <xsl:when test="ancestor::*[local-name() = 'appendix']">
@@ -5243,7 +5450,7 @@
5243
5450
  <xsl:apply-templates/>
5244
5451
  </fo:inline>
5245
5452
  </xsl:when>
5246
- <xsl:when test="normalize-space($element) = 'block'">
5453
+ <xsl:when test="contains(normalize-space($element), 'block')">
5247
5454
  <fo:block xsl:use-attribute-sets="example-name-style">
5248
5455
  <xsl:apply-templates/>
5249
5456
  </fo:block>
@@ -5477,7 +5684,8 @@
5477
5684
  </fo:inline>
5478
5685
  </xsl:when>
5479
5686
  <xsl:otherwise>
5480
- <fo:inline padding-right="{$padding-right}mm">​</fo:inline>
5687
+ <xsl:variable name="direction"><xsl:if test="$lang = 'ar'"><xsl:value-of select="$RLM"/></xsl:if></xsl:variable>
5688
+ <fo:inline padding-right="{$padding-right}mm"><xsl:value-of select="$direction"/>​</fo:inline>
5481
5689
  </xsl:otherwise>
5482
5690
  </xsl:choose>
5483
5691
 
@@ -6187,4 +6395,44 @@
6187
6395
  <xsl:otherwise><xsl:value-of select="$key"/></xsl:otherwise>
6188
6396
  </xsl:choose>
6189
6397
 
6398
+ </xsl:template><xsl:template name="setTrackChangesStyles">
6399
+ <xsl:param name="isAdded"/>
6400
+ <xsl:param name="isDeleted"/>
6401
+ <xsl:choose>
6402
+ <xsl:when test="local-name() = 'math'">
6403
+ <xsl:if test="$isAdded = 'true'">
6404
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute>
6405
+ </xsl:if>
6406
+ <xsl:if test="$isDeleted = 'true'">
6407
+ <xsl:attribute name="background-color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute>
6408
+ </xsl:if>
6409
+ </xsl:when>
6410
+ <xsl:otherwise>
6411
+ <xsl:if test="$isAdded = 'true'">
6412
+ <xsl:attribute name="border"><xsl:value-of select="$border-block-added"/></xsl:attribute>
6413
+ <xsl:attribute name="padding">2mm</xsl:attribute>
6414
+ </xsl:if>
6415
+ <xsl:if test="$isDeleted = 'true'">
6416
+ <xsl:attribute name="border"><xsl:value-of select="$border-block-deleted"/></xsl:attribute>
6417
+ <xsl:if test="local-name() = 'table'">
6418
+ <xsl:attribute name="background-color">rgb(255, 185, 185)</xsl:attribute>
6419
+ </xsl:if>
6420
+ <!-- <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute> -->
6421
+ <xsl:attribute name="padding">2mm</xsl:attribute>
6422
+ </xsl:if>
6423
+ </xsl:otherwise>
6424
+ </xsl:choose>
6425
+ </xsl:template><xsl:variable name="LRM" select="'‎'"/><xsl:variable name="RLM" select="'‏'"/><xsl:template name="setWritingMode">
6426
+ <xsl:if test="$lang = 'ar'">
6427
+ <xsl:attribute name="writing-mode">rl-tb</xsl:attribute>
6428
+ </xsl:if>
6429
+ </xsl:template><xsl:template name="setAlignment">
6430
+ <xsl:param name="align" select="normalize-space(@align)"/>
6431
+ <xsl:choose>
6432
+ <xsl:when test="$lang = 'ar' and $align = 'left'">start</xsl:when>
6433
+ <xsl:when test="$lang = 'ar' and $align = 'right'">end</xsl:when>
6434
+ <xsl:when test="$align != ''">
6435
+ <xsl:value-of select="$align"/>
6436
+ </xsl:when>
6437
+ </xsl:choose>
6190
6438
  </xsl:template></xsl:stylesheet>