metanorma-mpfa 0.6.4 → 0.6.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.
@@ -12,8 +12,12 @@
12
12
 
13
13
 
14
14
  <xsl:variable name="debug">false</xsl:variable>
15
- <xsl:variable name="pageWidth" select="'210mm'"/>
16
- <xsl:variable name="pageHeight" select="'297mm'"/>
15
+ <xsl:variable name="pageWidth" select="210"/>
16
+ <xsl:variable name="pageHeight" select="297"/>
17
+ <xsl:variable name="marginLeftRight1" select="19"/>
18
+ <xsl:variable name="marginLeftRight2" select="19"/>
19
+ <xsl:variable name="marginTop" select="16.5"/>
20
+ <xsl:variable name="marginBottom" select="10"/>
17
21
 
18
22
  <xsl:variable name="copyrightHolder">Ribose Group Inc.</xsl:variable>
19
23
 
@@ -63,7 +67,7 @@
63
67
  <fo:layout-master-set>
64
68
 
65
69
  <!-- cover page -->
66
- <fo:simple-page-master master-name="cover" page-width="{$pageWidth}" page-height="{$pageHeight}">
70
+ <fo:simple-page-master master-name="cover" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
67
71
  <fo:region-body margin-top="24mm" margin-bottom="10mm" margin-left="19mm" margin-right="19mm"/>
68
72
  <fo:region-before region-name="cover-header" extent="24mm"/>
69
73
  <fo:region-after region-name="footer" extent="10mm"/>
@@ -72,19 +76,19 @@
72
76
  </fo:simple-page-master>
73
77
 
74
78
  <!-- document pages -->
75
- <fo:simple-page-master master-name="odd" page-width="{$pageWidth}" page-height="{$pageHeight}">
76
- <fo:region-body margin-top="16.5mm" margin-bottom="10mm" margin-left="19mm" margin-right="19mm"/>
77
- <fo:region-before region-name="header-odd" extent="16.5mm"/>
78
- <fo:region-after region-name="footer-odd" extent="10mm"/>
79
- <fo:region-start region-name="left-region" extent="19mm"/>
80
- <fo:region-end region-name="right-region" extent="19mm"/>
79
+ <fo:simple-page-master master-name="odd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
80
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
81
+ <fo:region-before region-name="header-odd" extent="{$marginTop}mm"/>
82
+ <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
83
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
84
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
81
85
  </fo:simple-page-master>
82
- <fo:simple-page-master master-name="even" page-width="{$pageWidth}" page-height="{$pageHeight}">
83
- <fo:region-body margin-top="16.5mm" margin-bottom="10mm" margin-left="19mm" margin-right="19mm"/>
84
- <fo:region-before region-name="header-even" extent="16.5mm"/>
85
- <fo:region-after region-name="footer-even" extent="10mm"/>
86
- <fo:region-start region-name="left-region" extent="19mm"/>
87
- <fo:region-end region-name="right-region" extent="19mm"/>
86
+ <fo:simple-page-master master-name="even" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
87
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
88
+ <fo:region-before region-name="header-even" extent="{$marginTop}mm"/>
89
+ <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
90
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight2}mm"/>
91
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight1}mm"/>
88
92
  </fo:simple-page-master>
89
93
 
90
94
  <fo:page-sequence-master master-name="document">
@@ -991,7 +995,7 @@
991
995
 
992
996
 
993
997
 
994
-
998
+
995
999
  </xsl:attribute-set><xsl:attribute-set name="example-style">
996
1000
 
997
1001
 
@@ -1057,7 +1061,10 @@
1057
1061
 
1058
1062
 
1059
1063
 
1060
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1064
+
1065
+ </xsl:attribute-set><xsl:variable name="table-border_">
1066
+
1067
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1061
1068
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1062
1069
 
1063
1070
 
@@ -1077,6 +1084,8 @@
1077
1084
 
1078
1085
 
1079
1086
 
1087
+ </xsl:attribute-set><xsl:attribute-set name="table-footer-cell-style">
1088
+
1080
1089
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1081
1090
 
1082
1091
 
@@ -1097,6 +1106,7 @@
1097
1106
  </xsl:attribute-set><xsl:attribute-set name="eref-style">
1098
1107
 
1099
1108
 
1109
+
1100
1110
  <xsl:attribute name="color">blue</xsl:attribute>
1101
1111
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
1102
1112
 
@@ -1119,6 +1129,7 @@
1119
1129
 
1120
1130
 
1121
1131
 
1132
+
1122
1133
  </xsl:attribute-set><xsl:variable name="note-body-indent">10mm</xsl:variable><xsl:variable name="note-body-indent-table">5mm</xsl:variable><xsl:attribute-set name="note-name-style">
1123
1134
 
1124
1135
 
@@ -1154,10 +1165,12 @@
1154
1165
 
1155
1166
 
1156
1167
 
1168
+
1157
1169
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1158
1170
 
1159
1171
 
1160
1172
 
1173
+
1161
1174
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1162
1175
 
1163
1176
 
@@ -1206,6 +1219,7 @@
1206
1219
 
1207
1220
 
1208
1221
 
1222
+
1209
1223
 
1210
1224
 
1211
1225
 
@@ -1282,6 +1296,8 @@
1282
1296
  <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
1283
1297
 
1284
1298
 
1299
+ </xsl:attribute-set><xsl:attribute-set name="list-style">
1300
+
1285
1301
  </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">
1286
1302
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
1287
1303
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -1292,14 +1308,15 @@
1292
1308
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1293
1309
 
1294
1310
  <!-- Normative references -->
1295
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1311
+ <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]" mode="contents"/>
1296
1312
  <!-- Terms and definitions -->
1297
1313
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='terms']] | /*/*[local-name()='sections']/*[local-name()='definitions'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='definitions']]" mode="contents"/>
1298
1314
  <!-- Another main sections -->
1299
1315
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope') and not(local-name() = 'clause' and .//*[local-name()='terms']) and not(local-name() = 'clause' and .//*[local-name()='definitions'])]" mode="contents"/>
1300
1316
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1301
1317
  <!-- Bibliography -->
1302
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1318
+ <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]" mode="contents"/>
1319
+
1303
1320
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1304
1321
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1305
1322
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -1335,13 +1352,15 @@
1335
1352
  <xsl:variable name="table">
1336
1353
 
1337
1354
  <xsl:variable name="simple-table">
1338
- <xsl:call-template name="getSimpleTable"/>
1355
+ <xsl:call-template name="getSimpleTable"/>
1339
1356
  </xsl:variable>
1340
1357
 
1341
1358
  <!-- <xsl:if test="$namespace = 'bipm'">
1342
- <fo:block>&#xA0;</fo:block>
1359
+ <fo:block>&#xA0;</fo:block>
1343
1360
  </xsl:if> -->
1344
1361
 
1362
+
1363
+ <!-- Display table's name before table as standalone block -->
1345
1364
  <!-- $namespace = 'iso' or -->
1346
1365
 
1347
1366
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -1421,6 +1440,12 @@
1421
1440
 
1422
1441
 
1423
1442
 
1443
+
1444
+
1445
+
1446
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
1447
+
1448
+
1424
1449
  <xsl:variable name="table_width">
1425
1450
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
1426
1451
  100%
@@ -1439,6 +1464,7 @@
1439
1464
 
1440
1465
 
1441
1466
 
1467
+
1442
1468
 
1443
1469
 
1444
1470
 
@@ -1448,6 +1474,7 @@
1448
1474
  <attribute name="border-bottom">2pt solid black</attribute>
1449
1475
 
1450
1476
 
1477
+
1451
1478
  </xsl:variable>
1452
1479
 
1453
1480
 
@@ -1589,6 +1616,9 @@
1589
1616
  <fo:block xsl:use-attribute-sets="table-name-style">
1590
1617
 
1591
1618
 
1619
+
1620
+
1621
+
1592
1622
  <xsl:choose>
1593
1623
  <xsl:when test="$continued = 'true'">
1594
1624
  <!-- <xsl:if test="$namespace = 'bsi'"></xsl:if> -->
@@ -1736,6 +1766,7 @@
1736
1766
  <!-- font-weight="bold" -->
1737
1767
  <fo:table-header>
1738
1768
 
1769
+
1739
1770
  <xsl:apply-templates/>
1740
1771
  </fo:table-header>
1741
1772
  </xsl:template><xsl:template name="table-header-title">
@@ -1860,6 +1891,8 @@
1860
1891
  </xsl:choose>
1861
1892
  </xsl:for-each>
1862
1893
 
1894
+
1895
+
1863
1896
  <xsl:choose>
1864
1897
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
1865
1898
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -1886,6 +1919,7 @@
1886
1919
 
1887
1920
 
1888
1921
 
1922
+
1889
1923
  <!-- fn will be processed inside 'note' processing -->
1890
1924
 
1891
1925
 
@@ -1894,6 +1928,11 @@
1894
1928
 
1895
1929
 
1896
1930
 
1931
+
1932
+
1933
+ <!-- for BSI (not PAS) display Notes before footnotes -->
1934
+
1935
+
1897
1936
  <!-- except gb -->
1898
1937
 
1899
1938
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -1919,6 +1958,10 @@
1919
1958
  <!-- fn processing -->
1920
1959
  <xsl:call-template name="fn_display"/>
1921
1960
 
1961
+
1962
+ <!-- for PAS display Notes after footnotes -->
1963
+
1964
+
1922
1965
  </fo:table-cell>
1923
1966
  </fo:table-row>
1924
1967
  </fo:table-body>
@@ -1972,15 +2015,24 @@
1972
2015
 
1973
2016
 
1974
2017
 
2018
+
2019
+
1975
2020
  </xsl:if>
1976
2021
  <xsl:if test="$parent-name = 'tfoot'">
1977
2022
 
1978
2023
 
2024
+
1979
2025
  </xsl:if>
1980
2026
 
1981
2027
 
1982
2028
 
1983
2029
 
2030
+
2031
+
2032
+
2033
+
2034
+
2035
+
1984
2036
  <!-- <xsl:if test="$namespace = 'bipm'">
1985
2037
  <xsl:attribute name="height">8mm</xsl:attribute>
1986
2038
  </xsl:if> -->
@@ -2069,6 +2121,10 @@
2069
2121
 
2070
2122
 
2071
2123
 
2124
+
2125
+
2126
+
2127
+
2072
2128
  <xsl:if test=".//*[local-name() = 'table']">
2073
2129
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2074
2130
  </xsl:if>
@@ -2098,8 +2154,14 @@
2098
2154
 
2099
2155
 
2100
2156
 
2157
+
2158
+
2159
+ <!-- Table's note name (NOTE, for example) -->
2160
+
2101
2161
  <fo:inline padding-right="2mm">
2102
2162
 
2163
+
2164
+
2103
2165
 
2104
2166
 
2105
2167
 
@@ -2107,6 +2169,8 @@
2107
2169
 
2108
2170
  </fo:inline>
2109
2171
 
2172
+
2173
+
2110
2174
  <xsl:apply-templates mode="process"/>
2111
2175
  </fo:block>
2112
2176
 
@@ -2126,6 +2190,8 @@
2126
2190
  <xsl:variable name="reference" select="@reference"/>
2127
2191
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
2128
2192
  <fo:block margin-bottom="12pt">
2193
+
2194
+
2129
2195
 
2130
2196
 
2131
2197
 
@@ -2139,9 +2205,11 @@
2139
2205
 
2140
2206
 
2141
2207
 
2208
+
2142
2209
  <xsl:value-of select="@reference"/>
2143
2210
 
2144
2211
 
2212
+
2145
2213
  </fo:inline>
2146
2214
  <fo:inline>
2147
2215
 
@@ -2282,11 +2350,16 @@
2282
2350
 
2283
2351
 
2284
2352
 
2353
+
2354
+
2355
+
2356
+
2285
2357
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2286
2358
 
2287
2359
 
2288
2360
  <xsl:value-of select="@reference"/>
2289
2361
 
2362
+
2290
2363
  </fo:basic-link>
2291
2364
  </fo:inline>
2292
2365
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -2584,6 +2657,7 @@
2584
2657
 
2585
2658
  <fo:table-row>
2586
2659
 
2660
+
2587
2661
  <fo:table-cell>
2588
2662
 
2589
2663
  <fo:block margin-top="6pt">
@@ -2599,6 +2673,7 @@
2599
2673
 
2600
2674
 
2601
2675
 
2676
+
2602
2677
  <xsl:apply-templates/>
2603
2678
  <!-- <xsl:if test="$namespace = 'gb'">
2604
2679
  <xsl:if test="ancestor::*[local-name()='formula']">
@@ -3146,7 +3221,15 @@
3146
3221
  <xsl:copy>
3147
3222
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
3148
3223
  </xsl:copy>
3149
- <mathml:mspace width="0.5ex"/>
3224
+ <xsl:choose>
3225
+ <!-- if in msub, then don't add space -->
3226
+ <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3227
+ <!-- if next char in digit, don't add space -->
3228
+ <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3229
+ <xsl:otherwise>
3230
+ <mathml:mspace width="0.5ex"/>
3231
+ </xsl:otherwise>
3232
+ </xsl:choose>
3150
3233
  </xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
3151
3234
  <xsl:variable name="target">
3152
3235
  <xsl:choose>
@@ -3170,6 +3253,8 @@
3170
3253
  </xsl:variable>
3171
3254
  <fo:inline xsl:use-attribute-sets="link-style">
3172
3255
 
3256
+
3257
+
3173
3258
  <xsl:choose>
3174
3259
  <xsl:when test="$target_text = ''">
3175
3260
  <xsl:apply-templates/>
@@ -3278,6 +3363,7 @@
3278
3363
 
3279
3364
 
3280
3365
 
3366
+
3281
3367
  <fo:block-container margin-left="0mm">
3282
3368
 
3283
3369
 
@@ -3321,6 +3407,7 @@
3321
3407
  </xsl:choose>
3322
3408
  </xsl:template><xsl:template match="*[local-name() = 'termnote']">
3323
3409
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
3410
+
3324
3411
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
3325
3412
 
3326
3413
  <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
@@ -3394,6 +3481,7 @@
3394
3481
  </xsl:call-template>
3395
3482
 
3396
3483
  <fo:block>
3484
+
3397
3485
  <xsl:apply-templates/>
3398
3486
  </fo:block>
3399
3487
  <xsl:call-template name="fn_display_figure"/>
@@ -3448,7 +3536,24 @@
3448
3536
  </fo:instream-foreign-object>
3449
3537
  </xsl:when>
3450
3538
  <xsl:otherwise>
3451
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
3539
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
3540
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
3541
+
3542
+ <xsl:variable name="img_src">
3543
+ <xsl:choose>
3544
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
3545
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
3546
+ </xsl:choose>
3547
+ </xsl:variable>
3548
+
3549
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
3550
+ <xsl:if test="number($scale) &lt; 100">
3551
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
3552
+ </xsl:if>
3553
+
3554
+ </xsl:if>
3555
+
3556
+ </fo:external-graphic>
3452
3557
  </xsl:otherwise>
3453
3558
  </xsl:choose>
3454
3559
 
@@ -3516,6 +3621,253 @@
3516
3621
  <xsl:param name="height"/>
3517
3622
  <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; "/>
3518
3623
  <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; "/>
3624
+ </xsl:template><xsl:variable name="figure_name_height">14</xsl:variable><xsl:variable name="width_effective" select="$pageWidth - $marginLeftRight1 - $marginLeftRight2"/><xsl:variable name="height_effective" select="$pageHeight - $marginTop - $marginBottom - $figure_name_height"/><xsl:variable name="image_dpi" select="96"/><xsl:variable name="width_effective_px" select="$width_effective div 25.4 * $image_dpi"/><xsl:variable name="height_effective_px" select="$height_effective div 25.4 * $image_dpi"/><xsl:template match="*[local-name() = 'figure'][not(*[local-name() = 'image']) and *[local-name() = 'svg']]/*[local-name() = 'name']/*[local-name() = 'bookmark']" priority="2"/><xsl:template match="*[local-name() = 'figure'][not(*[local-name() = 'image'])]/*[local-name() = 'svg']" priority="2" name="image_svg">
3625
+ <xsl:param name="name"/>
3626
+
3627
+ <xsl:variable name="svg_content">
3628
+ <xsl:apply-templates select="." mode="svg_update"/>
3629
+ </xsl:variable>
3630
+
3631
+ <xsl:variable name="alt-text">
3632
+ <xsl:choose>
3633
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3634
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3635
+ </xsl:when>
3636
+ <xsl:when test="normalize-space($name) != ''">
3637
+ <xsl:value-of select="$name"/>
3638
+ </xsl:when>
3639
+ <xsl:otherwise>Figure</xsl:otherwise>
3640
+ </xsl:choose>
3641
+ </xsl:variable>
3642
+
3643
+ <xsl:choose>
3644
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3645
+ <fo:block>
3646
+ <xsl:variable name="width" select="@width"/>
3647
+ <xsl:variable name="height" select="@height"/>
3648
+
3649
+ <xsl:variable name="scale_x">
3650
+ <xsl:choose>
3651
+ <xsl:when test="$width &gt; $width_effective_px">
3652
+ <xsl:value-of select="$width_effective_px div $width"/>
3653
+ </xsl:when>
3654
+ <xsl:otherwise>1</xsl:otherwise>
3655
+ </xsl:choose>
3656
+ </xsl:variable>
3657
+
3658
+ <xsl:variable name="scale_y">
3659
+ <xsl:choose>
3660
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
3661
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
3662
+ </xsl:when>
3663
+ <xsl:otherwise>1</xsl:otherwise>
3664
+ </xsl:choose>
3665
+ </xsl:variable>
3666
+
3667
+ <xsl:variable name="scale">
3668
+ <xsl:choose>
3669
+ <xsl:when test="$scale_y != 1">
3670
+ <xsl:value-of select="$scale_x * $scale_y"/>
3671
+ </xsl:when>
3672
+ <xsl:otherwise>
3673
+ <xsl:value-of select="$scale_x"/>
3674
+ </xsl:otherwise>
3675
+ </xsl:choose>
3676
+ </xsl:variable>
3677
+
3678
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
3679
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
3680
+
3681
+ <fo:table table-layout="fixed" width="100%">
3682
+ <fo:table-column column-width="proportional-column-width(1)"/>
3683
+ <fo:table-column column-width="{$width_scale}px"/>
3684
+ <fo:table-column column-width="proportional-column-width(1)"/>
3685
+ <fo:table-body>
3686
+ <fo:table-row>
3687
+ <fo:table-cell column-number="2">
3688
+ <fo:block>
3689
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
3690
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3691
+ <fo:block line-height="0" font-size="0">
3692
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3693
+ <xsl:call-template name="bookmark"/>
3694
+ </xsl:for-each>
3695
+ </fo:block>
3696
+ </xsl:if>
3697
+ <fo:block text-depth="0" line-height="0" font-size="0">
3698
+
3699
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3700
+ <xsl:attribute name="width">100%</xsl:attribute>
3701
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3702
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3703
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3704
+
3705
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
3706
+ </fo:instream-foreign-object>
3707
+ </fo:block>
3708
+
3709
+ <xsl:apply-templates select=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]" mode="svg_imagemap_links">
3710
+ <xsl:with-param name="scale" select="$scale"/>
3711
+ </xsl:apply-templates>
3712
+ </fo:block-container>
3713
+ </fo:block>
3714
+ </fo:table-cell>
3715
+ </fo:table-row>
3716
+ </fo:table-body>
3717
+ </fo:table>
3718
+ </fo:block>
3719
+
3720
+ </xsl:when>
3721
+ <xsl:otherwise>
3722
+ <fo:block xsl:use-attribute-sets="image-style">
3723
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3724
+ <xsl:attribute name="width">100%</xsl:attribute>
3725
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3726
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3727
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
3728
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
3729
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
3730
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
3731
+ <!-- effective height / width = 1.48, 1.4 - with title -->
3732
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
3733
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
3734
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
3735
+ </xsl:if>
3736
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3737
+ <xsl:copy-of select="$svg_content"/>
3738
+ </fo:instream-foreign-object>
3739
+ </fo:block>
3740
+ </xsl:otherwise>
3741
+ </xsl:choose>
3742
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
3743
+ <xsl:copy>
3744
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
3745
+ </xsl:copy>
3746
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
3747
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
3748
+ <xsl:value-of select="."/>
3749
+ </xsl:attribute>
3750
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
3751
+ <xsl:copy>
3752
+ <xsl:apply-templates select="@*" mode="svg_update"/>
3753
+ <xsl:variable name="viewbox">
3754
+ <xsl:call-template name="split">
3755
+ <xsl:with-param name="pText" select="@viewBox"/>
3756
+ <xsl:with-param name="sep" select="' '"/>
3757
+ </xsl:call-template>
3758
+ </xsl:variable>
3759
+ <xsl:attribute name="width">
3760
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
3761
+ </xsl:attribute>
3762
+ <xsl:attribute name="height">
3763
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
3764
+ </xsl:attribute>
3765
+ <xsl:apply-templates mode="svg_update"/>
3766
+ </xsl:copy>
3767
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
3768
+ <xsl:variable name="svg_content" select="document(@src)"/>
3769
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
3770
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
3771
+ <xsl:call-template name="image_svg">
3772
+ <xsl:with-param name="name" select="$name"/>
3773
+ </xsl:call-template>
3774
+ </xsl:for-each>
3775
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
3776
+ <xsl:copy>
3777
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
3778
+ </xsl:copy>
3779
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
3780
+ <xsl:apply-templates mode="svg_remove_a"/>
3781
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
3782
+ <xsl:param name="scale"/>
3783
+ <xsl:variable name="dest">
3784
+ <xsl:choose>
3785
+ <xsl:when test="starts-with(@href, '#')">
3786
+ <xsl:value-of select="substring-after(@href, '#')"/>
3787
+ </xsl:when>
3788
+ <xsl:otherwise>
3789
+ <xsl:value-of select="@href"/>
3790
+ </xsl:otherwise>
3791
+ </xsl:choose>
3792
+ </xsl:variable>
3793
+ <xsl:for-each select="./*[local-name() = 'rect']">
3794
+ <xsl:call-template name="insertSVGMapLink">
3795
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
3796
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
3797
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
3798
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
3799
+ <xsl:with-param name="dest" select="$dest"/>
3800
+ </xsl:call-template>
3801
+ </xsl:for-each>
3802
+
3803
+ <xsl:for-each select="./*[local-name() = 'polygon']">
3804
+ <xsl:variable name="points">
3805
+ <xsl:call-template name="split">
3806
+ <xsl:with-param name="pText" select="@points"/>
3807
+ </xsl:call-template>
3808
+ </xsl:variable>
3809
+ <xsl:variable name="x_coords">
3810
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
3811
+ <xsl:sort select="." data-type="number"/>
3812
+ <x><xsl:value-of select="."/></x>
3813
+ </xsl:for-each>
3814
+ </xsl:variable>
3815
+ <xsl:variable name="y_coords">
3816
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
3817
+ <xsl:sort select="." data-type="number"/>
3818
+ <y><xsl:value-of select="."/></y>
3819
+ </xsl:for-each>
3820
+ </xsl:variable>
3821
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
3822
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
3823
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
3824
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
3825
+ <xsl:call-template name="insertSVGMapLink">
3826
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
3827
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
3828
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
3829
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
3830
+ <xsl:with-param name="dest" select="$dest"/>
3831
+ </xsl:call-template>
3832
+ </xsl:for-each>
3833
+
3834
+ <xsl:for-each select="./*[local-name() = 'circle']">
3835
+ <xsl:call-template name="insertSVGMapLink">
3836
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
3837
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
3838
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
3839
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
3840
+ <xsl:with-param name="dest" select="$dest"/>
3841
+ </xsl:call-template>
3842
+ </xsl:for-each>
3843
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
3844
+ <xsl:call-template name="insertSVGMapLink">
3845
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
3846
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
3847
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
3848
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
3849
+ <xsl:with-param name="dest" select="$dest"/>
3850
+ </xsl:call-template>
3851
+ </xsl:for-each>
3852
+ </xsl:template><xsl:template name="insertSVGMapLink">
3853
+ <xsl:param name="left"/>
3854
+ <xsl:param name="top"/>
3855
+ <xsl:param name="width"/>
3856
+ <xsl:param name="height"/>
3857
+ <xsl:param name="dest"/>
3858
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
3859
+ <fo:block font-size="1pt">
3860
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
3861
+ <fo:inline-container inline-progression-dimension="100%">
3862
+ <fo:block-container height="{$height - 1}px" width="100%">
3863
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
3864
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
3865
+ </xsl:if> -->
3866
+ <fo:block> </fo:block></fo:block-container>
3867
+ </fo:inline-container>
3868
+ </fo:basic-link>
3869
+ </fo:block>
3870
+ </fo:block-container>
3519
3871
  </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">
3520
3872
  <xsl:apply-templates mode="contents"/>
3521
3873
  <xsl:text> </xsl:text>
@@ -3544,28 +3896,39 @@
3544
3896
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3545
3897
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3546
3898
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
3899
+ <xsl:if test="@bundle = 'true'">
3900
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
3901
+ </xsl:if>
3547
3902
  <fo:bookmark-title>
3548
- <xsl:variable name="bookmark-title_">
3549
- <xsl:call-template name="getLangVersion">
3550
- <xsl:with-param name="lang" select="@lang"/>
3551
- <xsl:with-param name="doctype" select="@doctype"/>
3552
- <xsl:with-param name="title" select="@title-part"/>
3553
- </xsl:call-template>
3554
- </xsl:variable>
3555
3903
  <xsl:choose>
3556
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3557
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3558
- </xsl:when>
3559
- <xsl:otherwise>
3904
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
3905
+ <xsl:variable name="bookmark-title_">
3906
+ <xsl:call-template name="getLangVersion">
3907
+ <xsl:with-param name="lang" select="@lang"/>
3908
+ <xsl:with-param name="doctype" select="@doctype"/>
3909
+ <xsl:with-param name="title" select="@title-part"/>
3910
+ </xsl:call-template>
3911
+ </xsl:variable>
3560
3912
  <xsl:choose>
3561
- <xsl:when test="@lang = 'en'">English</xsl:when>
3562
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3563
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3564
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
3913
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
3914
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
3915
+ </xsl:when>
3916
+ <xsl:otherwise>
3917
+ <xsl:choose>
3918
+ <xsl:when test="@lang = 'en'">English</xsl:when>
3919
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
3920
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3921
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
3922
+ </xsl:choose>
3923
+ </xsl:otherwise>
3565
3924
  </xsl:choose>
3925
+ </xsl:when>
3926
+ <xsl:otherwise>
3927
+ <xsl:value-of select="@title-part"/>
3566
3928
  </xsl:otherwise>
3567
3929
  </xsl:choose>
3568
3930
  </fo:bookmark-title>
3931
+
3569
3932
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3570
3933
 
3571
3934
  <xsl:call-template name="insertFigureBookmarks">
@@ -3664,20 +4027,28 @@
3664
4027
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
3665
4028
  </xsl:choose>
3666
4029
  </xsl:template><xsl:template match="item" mode="bookmark">
3667
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
3668
- <fo:bookmark-title>
3669
- <xsl:if test="@section != ''">
3670
- <xsl:value-of select="@section"/>
3671
- <xsl:text> </xsl:text>
3672
- </xsl:if>
3673
- <xsl:value-of select="normalize-space(title)"/>
3674
- </fo:bookmark-title>
3675
- <xsl:apply-templates mode="bookmark"/>
3676
- </fo:bookmark>
4030
+ <xsl:choose>
4031
+ <xsl:when test="@id != ''">
4032
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4033
+ <fo:bookmark-title>
4034
+ <xsl:if test="@section != ''">
4035
+ <xsl:value-of select="@section"/>
4036
+ <xsl:text> </xsl:text>
4037
+ </xsl:if>
4038
+ <xsl:value-of select="normalize-space(title)"/>
4039
+ </fo:bookmark-title>
4040
+ <xsl:apply-templates mode="bookmark"/>
4041
+ </fo:bookmark>
4042
+ </xsl:when>
4043
+ <xsl:otherwise>
4044
+ <xsl:apply-templates mode="bookmark"/>
4045
+ </xsl:otherwise>
4046
+ </xsl:choose>
3677
4047
  </xsl:template><xsl:template match="title" mode="bookmark"/><xsl:template match="text()" mode="bookmark"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'image']/*[local-name() = 'name']" mode="presentation">
3678
4048
  <xsl:if test="normalize-space() != ''">
3679
4049
  <fo:block xsl:use-attribute-sets="figure-name-style">
3680
4050
 
4051
+
3681
4052
  <xsl:apply-templates/>
3682
4053
  </fo:block>
3683
4054
  </xsl:if>
@@ -3758,6 +4129,7 @@
3758
4129
 
3759
4130
  <fo:block-container margin-left="0mm">
3760
4131
  <xsl:copy-of select="@id"/>
4132
+
3761
4133
  <xsl:if test="parent::*[local-name() = 'note']">
3762
4134
  <xsl:attribute name="margin-left">
3763
4135
  <xsl:choose>
@@ -3768,7 +4140,9 @@
3768
4140
 
3769
4141
  </xsl:if>
3770
4142
  <fo:block-container margin-left="0mm">
3771
-
4143
+
4144
+
4145
+
3772
4146
  <fo:block xsl:use-attribute-sets="sourcecode-style">
3773
4147
  <xsl:variable name="_font-size">
3774
4148
 
@@ -3797,10 +4171,14 @@
3797
4171
  </xsl:choose>
3798
4172
  </xsl:attribute>
3799
4173
  </xsl:if>
3800
- <xsl:apply-templates/>
3801
- </fo:block>
4174
+
4175
+ <xsl:apply-templates/>
4176
+ </fo:block>
4177
+
4178
+
3802
4179
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
3803
4180
 
4181
+
3804
4182
  </fo:block-container>
3805
4183
  </fo:block-container>
3806
4184
  </xsl:template><xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -4142,6 +4520,8 @@
4142
4520
 
4143
4521
 
4144
4522
 
4523
+
4524
+
4145
4525
  <xsl:call-template name="getTitle">
4146
4526
  <xsl:with-param name="name" select="'title-source'"/>
4147
4527
  </xsl:call-template>
@@ -4218,7 +4598,9 @@
4218
4598
 
4219
4599
 
4220
4600
  </xsl:if>
4221
-
4601
+
4602
+
4603
+
4222
4604
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4223
4605
  <xsl:if test="normalize-space(@citeas) = ''">
4224
4606
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -4230,6 +4612,7 @@
4230
4612
 
4231
4613
 
4232
4614
 
4615
+
4233
4616
  </xsl:if>
4234
4617
 
4235
4618
  <xsl:apply-templates/>
@@ -4365,6 +4748,7 @@
4365
4748
  <xsl:call-template name="setId"/>
4366
4749
 
4367
4750
 
4751
+
4368
4752
  <xsl:apply-templates/>
4369
4753
  </fo:block>
4370
4754
  </xsl:template><xsl:template match="*[local-name() = 'definitions']">
@@ -4611,17 +4995,17 @@
4611
4995
  <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/>
4612
4996
  <xsl:choose>
4613
4997
  <xsl:when test="normalize-space($_doc_ident) != ''">
4614
- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/>
4998
+ <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/>
4615
4999
  <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
4616
5000
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4617
- </xsl:if>
5001
+ </xsl:if> -->
4618
5002
  <xsl:value-of select="$_doc_ident"/>
4619
5003
  </xsl:when>
4620
5004
  <xsl:otherwise>
4621
- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
5005
+ <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
4622
5006
  <xsl:if test="$type != ''">
4623
5007
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4624
- </xsl:if>
5008
+ </xsl:if> -->
4625
5009
  <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]"/>
4626
5010
  </xsl:otherwise>
4627
5011
  </xsl:choose>
@@ -5055,20 +5439,40 @@
5055
5439
  </xsl:call-template>
5056
5440
  </xsl:if>
5057
5441
  </xsl:template><xsl:template name="getLocalizedString">
5058
- <xsl:param name="key"/>
5442
+ <xsl:param name="key"/>
5443
+ <xsl:param name="formatted">false</xsl:param>
5059
5444
 
5060
5445
  <xsl:variable name="curr_lang">
5061
5446
  <xsl:call-template name="getLang"/>
5062
5447
  </xsl:variable>
5063
5448
 
5064
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5449
+ <xsl:variable name="data_value">
5450
+ <xsl:choose>
5451
+ <xsl:when test="$formatted = 'true'">
5452
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5453
+ </xsl:when>
5454
+ <xsl:otherwise>
5455
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5456
+ </xsl:otherwise>
5457
+ </xsl:choose>
5458
+ </xsl:variable>
5065
5459
 
5066
5460
  <xsl:choose>
5067
- <xsl:when test="$data_value != ''">
5068
- <xsl:value-of select="$data_value"/>
5461
+ <xsl:when test="normalize-space($data_value) != ''">
5462
+ <xsl:choose>
5463
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
5464
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
5465
+ </xsl:choose>
5069
5466
  </xsl:when>
5070
5467
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5071
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5468
+ <xsl:choose>
5469
+ <xsl:when test="$formatted = 'true'">
5470
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5471
+ </xsl:when>
5472
+ <xsl:otherwise>
5473
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5474
+ </xsl:otherwise>
5475
+ </xsl:choose>
5072
5476
  </xsl:when>
5073
5477
  <xsl:otherwise>
5074
5478
  <xsl:variable name="key_">
@@ -5079,7 +5483,7 @@
5079
5483
  <xsl:value-of select="$key_"/>
5080
5484
  </xsl:otherwise>
5081
5485
  </xsl:choose>
5082
-
5486
+
5083
5487
  </xsl:template><xsl:template name="setTrackChangesStyles">
5084
5488
  <xsl:param name="isAdded"/>
5085
5489
  <xsl:param name="isDeleted"/>
@@ -5120,4 +5524,110 @@
5120
5524
  <xsl:value-of select="$align"/>
5121
5525
  </xsl:when>
5122
5526
  </xsl:choose>
5527
+ </xsl:template><xsl:template name="setTextAlignment">
5528
+ <xsl:param name="default">left</xsl:param>
5529
+ <xsl:attribute name="text-align">
5530
+ <xsl:choose>
5531
+ <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
5532
+ <xsl:when test="ancestor::*[local-name() = 'td']/@align"><xsl:value-of select="ancestor::*[local-name() = 'td']/@align"/></xsl:when>
5533
+ <xsl:when test="ancestor::*[local-name() = 'th']/@align"><xsl:value-of select="ancestor::*[local-name() = 'th']/@align"/></xsl:when>
5534
+ <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
5535
+ </xsl:choose>
5536
+ </xsl:attribute>
5537
+ </xsl:template><xsl:template name="number-to-words">
5538
+ <xsl:param name="number"/>
5539
+ <xsl:param name="first"/>
5540
+ <xsl:if test="$number != ''">
5541
+ <xsl:variable name="words">
5542
+ <words>
5543
+ <word cardinal="1">One-</word>
5544
+ <word ordinal="1">First </word>
5545
+ <word cardinal="2">Two-</word>
5546
+ <word ordinal="2">Second </word>
5547
+ <word cardinal="3">Three-</word>
5548
+ <word ordinal="3">Third </word>
5549
+ <word cardinal="4">Four-</word>
5550
+ <word ordinal="4">Fourth </word>
5551
+ <word cardinal="5">Five-</word>
5552
+ <word ordinal="5">Fifth </word>
5553
+ <word cardinal="6">Six-</word>
5554
+ <word ordinal="6">Sixth </word>
5555
+ <word cardinal="7">Seven-</word>
5556
+ <word ordinal="7">Seventh </word>
5557
+ <word cardinal="8">Eight-</word>
5558
+ <word ordinal="8">Eighth </word>
5559
+ <word cardinal="9">Nine-</word>
5560
+ <word ordinal="9">Ninth </word>
5561
+ <word ordinal="10">Tenth </word>
5562
+ <word ordinal="11">Eleventh </word>
5563
+ <word ordinal="12">Twelfth </word>
5564
+ <word ordinal="13">Thirteenth </word>
5565
+ <word ordinal="14">Fourteenth </word>
5566
+ <word ordinal="15">Fifteenth </word>
5567
+ <word ordinal="16">Sixteenth </word>
5568
+ <word ordinal="17">Seventeenth </word>
5569
+ <word ordinal="18">Eighteenth </word>
5570
+ <word ordinal="19">Nineteenth </word>
5571
+ <word cardinal="20">Twenty-</word>
5572
+ <word ordinal="20">Twentieth </word>
5573
+ <word cardinal="30">Thirty-</word>
5574
+ <word ordinal="30">Thirtieth </word>
5575
+ <word cardinal="40">Forty-</word>
5576
+ <word ordinal="40">Fortieth </word>
5577
+ <word cardinal="50">Fifty-</word>
5578
+ <word ordinal="50">Fiftieth </word>
5579
+ <word cardinal="60">Sixty-</word>
5580
+ <word ordinal="60">Sixtieth </word>
5581
+ <word cardinal="70">Seventy-</word>
5582
+ <word ordinal="70">Seventieth </word>
5583
+ <word cardinal="80">Eighty-</word>
5584
+ <word ordinal="80">Eightieth </word>
5585
+ <word cardinal="90">Ninety-</word>
5586
+ <word ordinal="90">Ninetieth </word>
5587
+ <word cardinal="100">Hundred-</word>
5588
+ <word ordinal="100">Hundredth </word>
5589
+ </words>
5590
+ </xsl:variable>
5591
+
5592
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
5593
+
5594
+ <xsl:variable name="value">
5595
+ <xsl:choose>
5596
+ <xsl:when test="$ordinal != ''">
5597
+ <xsl:value-of select="$ordinal"/>
5598
+ </xsl:when>
5599
+ <xsl:otherwise>
5600
+ <xsl:choose>
5601
+ <xsl:when test="$number &lt; 100">
5602
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
5603
+ <xsl:variable name="digit" select="substring($number,2)"/>
5604
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
5605
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
5606
+ </xsl:when>
5607
+ <xsl:otherwise>
5608
+ <!-- more 100 -->
5609
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
5610
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
5611
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
5612
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
5613
+ <xsl:call-template name="number-to-words">
5614
+ <xsl:with-param name="number" select="$digits"/>
5615
+ </xsl:call-template>
5616
+ </xsl:otherwise>
5617
+ </xsl:choose>
5618
+ </xsl:otherwise>
5619
+ </xsl:choose>
5620
+ </xsl:variable>
5621
+ <xsl:choose>
5622
+ <xsl:when test="$first = 'true'">
5623
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
5624
+ <xsl:call-template name="capitalize">
5625
+ <xsl:with-param name="str" select="$value_lc"/>
5626
+ </xsl:call-template>
5627
+ </xsl:when>
5628
+ <xsl:otherwise>
5629
+ <xsl:value-of select="$value"/>
5630
+ </xsl:otherwise>
5631
+ </xsl:choose>
5632
+ </xsl:if>
5123
5633
  </xsl:template></xsl:stylesheet>