metanorma-ogc 1.3.3 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,12 @@
7
7
  <xsl:variable name="images" select="document($svg_images)"/>
8
8
  <xsl:param name="basepath"/>
9
9
 
10
- <xsl:variable name="pageWidth" select="'215.9mm'"/>
11
- <xsl:variable name="pageHeight" select="'279.4mm'"/>
10
+ <xsl:variable name="pageWidth" select="215.9"/>
11
+ <xsl:variable name="pageHeight" select="279.4"/>
12
+ <xsl:variable name="marginLeftRight1" select="25.4"/>
13
+ <xsl:variable name="marginLeftRight2" select="25.4"/>
14
+ <xsl:variable name="marginTop" select="25.4"/>
15
+ <xsl:variable name="marginBottom" select="25.4"/>
12
16
 
13
17
 
14
18
 
@@ -97,12 +101,12 @@
97
101
  <fo:layout-master-set>
98
102
 
99
103
  <!-- Document pages -->
100
- <fo:simple-page-master master-name="document" page-width="{$pageWidth}" page-height="{$pageHeight}">
101
- <fo:region-body margin-top="1in" margin-bottom="1in" margin-left="1in" margin-right="1in"/>
102
- <fo:region-before region-name="header" extent="1in" precedence="true"/>
103
- <fo:region-after region-name="footer" extent="1in" precedence="true"/>
104
- <fo:region-start region-name="left" extent="1in"/>
105
- <fo:region-end region-name="right" extent="1in"/>
104
+ <fo:simple-page-master master-name="document" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
105
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
106
+ <fo:region-before region-name="header" extent="{$marginTop}mm" precedence="true"/>
107
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm" precedence="true"/>
108
+ <fo:region-start region-name="left" extent="{$marginLeftRight1}mm"/>
109
+ <fo:region-end region-name="right" extent="{$marginLeftRight2}mm"/>
106
110
  </fo:simple-page-master>
107
111
 
108
112
  </fo:layout-master-set>
@@ -1064,6 +1068,7 @@
1064
1068
 
1065
1069
 
1066
1070
 
1071
+
1067
1072
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
1068
1073
  <xsl:attribute name="white-space">pre</xsl:attribute>
1069
1074
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
@@ -1152,7 +1157,7 @@
1152
1157
 
1153
1158
 
1154
1159
 
1155
-
1160
+
1156
1161
  </xsl:attribute-set><xsl:attribute-set name="example-style">
1157
1162
 
1158
1163
 
@@ -1169,6 +1174,7 @@
1169
1174
 
1170
1175
 
1171
1176
 
1177
+
1172
1178
  </xsl:attribute-set><xsl:attribute-set name="example-body-style">
1173
1179
 
1174
1180
 
@@ -1192,9 +1198,7 @@
1192
1198
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1193
1199
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1194
1200
 
1195
-
1196
-
1197
-
1201
+
1198
1202
 
1199
1203
 
1200
1204
 
@@ -1223,6 +1227,7 @@
1223
1227
 
1224
1228
 
1225
1229
 
1230
+
1226
1231
  </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1227
1232
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1228
1233
 
@@ -1247,6 +1252,9 @@
1247
1252
 
1248
1253
 
1249
1254
 
1255
+
1256
+ </xsl:attribute-set><xsl:attribute-set name="table-footer-cell-style">
1257
+
1250
1258
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1251
1259
 
1252
1260
  <xsl:attribute name="font-size">12pt</xsl:attribute>
@@ -1272,14 +1280,17 @@
1272
1280
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
1273
1281
 
1274
1282
 
1283
+
1275
1284
  </xsl:attribute-set><xsl:attribute-set name="eref-style">
1276
1285
 
1277
1286
 
1287
+
1278
1288
  <xsl:attribute name="color">blue</xsl:attribute>
1279
1289
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
1280
1290
 
1281
1291
 
1282
1292
 
1293
+
1283
1294
  </xsl:attribute-set><xsl:attribute-set name="note-style">
1284
1295
 
1285
1296
 
@@ -1301,6 +1312,7 @@
1301
1312
 
1302
1313
 
1303
1314
 
1315
+
1304
1316
  </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">
1305
1317
 
1306
1318
 
@@ -1344,10 +1356,12 @@
1344
1356
 
1345
1357
 
1346
1358
 
1359
+
1347
1360
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1348
1361
 
1349
1362
 
1350
1363
 
1364
+
1351
1365
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1352
1366
 
1353
1367
  <xsl:attribute name="margin-top">12pt</xsl:attribute>
@@ -1377,6 +1391,7 @@
1377
1391
 
1378
1392
 
1379
1393
 
1394
+
1380
1395
  </xsl:attribute-set><xsl:attribute-set name="origin-style">
1381
1396
 
1382
1397
 
@@ -1384,6 +1399,7 @@
1384
1399
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
1385
1400
 
1386
1401
 
1402
+
1387
1403
  </xsl:attribute-set><xsl:attribute-set name="term-style">
1388
1404
 
1389
1405
  </xsl:attribute-set><xsl:attribute-set name="figure-name-style">
@@ -1411,6 +1427,7 @@
1411
1427
 
1412
1428
 
1413
1429
 
1430
+
1414
1431
 
1415
1432
 
1416
1433
 
@@ -1461,8 +1478,10 @@
1461
1478
  <xsl:attribute name="font-size">11pt</xsl:attribute>
1462
1479
 
1463
1480
 
1481
+
1464
1482
  </xsl:attribute-set><xsl:attribute-set name="deprecates-style">
1465
1483
 
1484
+
1466
1485
  </xsl:attribute-set><xsl:attribute-set name="definition-style">
1467
1486
 
1468
1487
  <xsl:attribute name="space-after">6pt</xsl:attribute>
@@ -1487,6 +1506,8 @@
1487
1506
  <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
1488
1507
 
1489
1508
 
1509
+ </xsl:attribute-set><xsl:attribute-set name="list-style">
1510
+
1490
1511
  </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">
1491
1512
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
1492
1513
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -1497,14 +1518,15 @@
1497
1518
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1498
1519
 
1499
1520
  <!-- Normative references -->
1500
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1521
+ <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"/>
1501
1522
  <!-- Terms and definitions -->
1502
1523
  <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"/>
1503
1524
  <!-- Another main sections -->
1504
1525
  <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"/>
1505
1526
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1506
1527
  <!-- Bibliography -->
1507
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1528
+ <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"/>
1529
+
1508
1530
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1509
1531
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1510
1532
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -1540,11 +1562,11 @@
1540
1562
  <xsl:variable name="table">
1541
1563
 
1542
1564
  <xsl:variable name="simple-table">
1543
- <xsl:call-template name="getSimpleTable"/>
1565
+ <xsl:call-template name="getSimpleTable"/>
1544
1566
  </xsl:variable>
1545
1567
 
1546
1568
  <!-- <xsl:if test="$namespace = 'bipm'">
1547
- <fo:block>&#xA0;</fo:block>
1569
+ <fo:block>&#xA0;</fo:block>
1548
1570
  </xsl:if> -->
1549
1571
 
1550
1572
  <!-- $namespace = 'iso' or -->
@@ -1658,6 +1680,7 @@
1658
1680
 
1659
1681
 
1660
1682
 
1683
+
1661
1684
  </xsl:variable>
1662
1685
 
1663
1686
 
@@ -1798,6 +1821,9 @@
1798
1821
  <fo:block xsl:use-attribute-sets="table-name-style">
1799
1822
 
1800
1823
 
1824
+
1825
+
1826
+
1801
1827
  <xsl:choose>
1802
1828
  <xsl:when test="$continued = 'true'">
1803
1829
  <!-- <xsl:if test="$namespace = 'bsi'"></xsl:if> -->
@@ -1945,6 +1971,7 @@
1945
1971
  <!-- font-weight="bold" -->
1946
1972
  <fo:table-header>
1947
1973
 
1974
+
1948
1975
  <xsl:apply-templates/>
1949
1976
  </fo:table-header>
1950
1977
  </xsl:template><xsl:template name="table-header-title">
@@ -2095,6 +2122,7 @@
2095
2122
 
2096
2123
 
2097
2124
 
2125
+
2098
2126
  <!-- fn will be processed inside 'note' processing -->
2099
2127
 
2100
2128
 
@@ -2103,6 +2131,10 @@
2103
2131
 
2104
2132
 
2105
2133
 
2134
+
2135
+ <!-- for BSI (not PAS) display Notes before footnotes -->
2136
+
2137
+
2106
2138
  <!-- except gb -->
2107
2139
 
2108
2140
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -2128,6 +2160,10 @@
2128
2160
  <!-- fn processing -->
2129
2161
  <xsl:call-template name="fn_display"/>
2130
2162
 
2163
+
2164
+ <!-- for PAS display Notes after footnotes -->
2165
+
2166
+
2131
2167
  </fo:table-cell>
2132
2168
  </fo:table-row>
2133
2169
  </fo:table-body>
@@ -2185,11 +2221,16 @@
2185
2221
  <xsl:if test="$parent-name = 'tfoot'">
2186
2222
 
2187
2223
 
2224
+
2188
2225
  </xsl:if>
2189
2226
 
2190
2227
 
2191
2228
 
2192
2229
 
2230
+
2231
+
2232
+
2233
+
2193
2234
  <!-- <xsl:if test="$namespace = 'bipm'">
2194
2235
  <xsl:attribute name="height">8mm</xsl:attribute>
2195
2236
  </xsl:if> -->
@@ -2225,6 +2266,7 @@
2225
2266
 
2226
2267
 
2227
2268
 
2269
+
2228
2270
  <xsl:if test="$lang = 'ar'">
2229
2271
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2230
2272
  </xsl:if>
@@ -2276,6 +2318,7 @@
2276
2318
 
2277
2319
 
2278
2320
 
2321
+
2279
2322
  <xsl:attribute name="padding-top">1mm</xsl:attribute>
2280
2323
  <xsl:attribute name="border">solid 0.5pt rgb(153, 153, 153)</xsl:attribute>
2281
2324
  <xsl:attribute name="height">5mm</xsl:attribute>
@@ -2284,6 +2327,9 @@
2284
2327
 
2285
2328
 
2286
2329
 
2330
+
2331
+
2332
+
2287
2333
  <xsl:if test=".//*[local-name() = 'table']">
2288
2334
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2289
2335
  </xsl:if>
@@ -2313,8 +2359,14 @@
2313
2359
 
2314
2360
 
2315
2361
 
2362
+
2363
+
2364
+ <!-- Table's note name (NOTE, for example) -->
2365
+
2316
2366
  <fo:inline padding-right="2mm">
2317
2367
 
2368
+
2369
+
2318
2370
 
2319
2371
 
2320
2372
 
@@ -2322,6 +2374,8 @@
2322
2374
 
2323
2375
  </fo:inline>
2324
2376
 
2377
+
2378
+
2325
2379
  <xsl:apply-templates mode="process"/>
2326
2380
  </fo:block>
2327
2381
 
@@ -2347,6 +2401,8 @@
2347
2401
  <xsl:variable name="reference" select="@reference"/>
2348
2402
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
2349
2403
  <fo:block margin-bottom="12pt">
2404
+
2405
+
2350
2406
 
2351
2407
 
2352
2408
 
@@ -2362,9 +2418,11 @@
2362
2418
 
2363
2419
 
2364
2420
 
2421
+
2365
2422
  <xsl:value-of select="@reference"/>
2366
2423
 
2367
2424
 
2425
+
2368
2426
  </fo:inline>
2369
2427
  <fo:inline>
2370
2428
 
@@ -2503,6 +2561,9 @@
2503
2561
 
2504
2562
 
2505
2563
 
2564
+
2565
+
2566
+
2506
2567
  <xsl:attribute name="vertical-align">super</xsl:attribute>
2507
2568
  <xsl:attribute name="color">blue</xsl:attribute>
2508
2569
 
@@ -2510,6 +2571,7 @@
2510
2571
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
2511
2572
 
2512
2573
 
2574
+
2513
2575
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2514
2576
 
2515
2577
  <xsl:attribute name="internal-destination">
@@ -2520,6 +2582,7 @@
2520
2582
 
2521
2583
  <xsl:value-of select="@reference"/>
2522
2584
 
2585
+
2523
2586
  </fo:basic-link>
2524
2587
  </fo:inline>
2525
2588
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -2606,6 +2669,7 @@
2606
2669
 
2607
2670
 
2608
2671
 
2672
+
2609
2673
  <xsl:variable name="title-key">
2610
2674
 
2611
2675
 
@@ -2816,6 +2880,7 @@
2816
2880
 
2817
2881
  <fo:table-row>
2818
2882
 
2883
+
2819
2884
  <fo:table-cell>
2820
2885
 
2821
2886
  <fo:block margin-top="6pt">
@@ -2834,6 +2899,7 @@
2834
2899
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
2835
2900
 
2836
2901
 
2902
+
2837
2903
  <xsl:apply-templates/>
2838
2904
  <!-- <xsl:if test="$namespace = 'gb'">
2839
2905
  <xsl:if test="ancestor::*[local-name()='formula']">
@@ -2890,6 +2956,8 @@
2890
2956
 
2891
2957
  <xsl:apply-templates/>
2892
2958
  </fo:inline>
2959
+ </xsl:template><xsl:template match="*[local-name()='padding']">
2960
+ <fo:inline padding-right="{@value}"> </fo:inline>
2893
2961
  </xsl:template><xsl:template match="*[local-name()='sup']">
2894
2962
  <fo:inline font-size="80%" vertical-align="super">
2895
2963
  <xsl:apply-templates/>
@@ -3379,9 +3447,27 @@
3379
3447
  <xsl:copy>
3380
3448
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
3381
3449
  </xsl:copy>
3382
- <mathml:mspace width="0.5ex"/>
3450
+ <xsl:choose>
3451
+ <!-- if in msub, then don't add space -->
3452
+ <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3453
+ <!-- if next char in digit, don't add space -->
3454
+ <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3455
+ <xsl:otherwise>
3456
+ <mathml:mspace width="0.5ex"/>
3457
+ </xsl:otherwise>
3458
+ </xsl:choose>
3383
3459
  </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">
3384
3460
  <xsl:variable name="target">
3461
+ <xsl:choose>
3462
+ <xsl:when test="@updatetype = 'true'">
3463
+ <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
3464
+ </xsl:when>
3465
+ <xsl:otherwise>
3466
+ <xsl:value-of select="normalize-space(@target)"/>
3467
+ </xsl:otherwise>
3468
+ </xsl:choose>
3469
+ </xsl:variable>
3470
+ <xsl:variable name="target_text">
3385
3471
  <xsl:choose>
3386
3472
  <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
3387
3473
  <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
@@ -3393,20 +3479,22 @@
3393
3479
  </xsl:variable>
3394
3480
  <fo:inline xsl:use-attribute-sets="link-style">
3395
3481
 
3482
+
3483
+
3396
3484
  <xsl:choose>
3397
- <xsl:when test="$target = ''">
3485
+ <xsl:when test="$target_text = ''">
3398
3486
  <xsl:apply-templates/>
3399
3487
  </xsl:when>
3400
3488
  <xsl:otherwise>
3401
- <fo:basic-link external-destination="{@target}" fox:alt-text="{@target}">
3489
+ <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
3402
3490
  <xsl:choose>
3403
3491
  <xsl:when test="normalize-space(.) = ''">
3404
- <!-- <xsl:value-of select="$target"/> -->
3405
3492
  <xsl:call-template name="add-zero-spaces-link-java">
3406
- <xsl:with-param name="text" select="$target"/>
3493
+ <xsl:with-param name="text" select="$target_text"/>
3407
3494
  </xsl:call-template>
3408
3495
  </xsl:when>
3409
3496
  <xsl:otherwise>
3497
+ <!-- output text from <link>text</link> -->
3410
3498
  <xsl:apply-templates/>
3411
3499
  </xsl:otherwise>
3412
3500
  </xsl:choose>
@@ -3505,6 +3593,7 @@
3505
3593
 
3506
3594
 
3507
3595
 
3596
+
3508
3597
  <fo:block-container margin-left="0mm">
3509
3598
 
3510
3599
 
@@ -3548,6 +3637,7 @@
3548
3637
  </xsl:choose>
3549
3638
  </xsl:template><xsl:template match="*[local-name() = 'termnote']">
3550
3639
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
3640
+
3551
3641
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
3552
3642
 
3553
3643
  <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
@@ -3623,6 +3713,7 @@
3623
3713
  </xsl:call-template>
3624
3714
 
3625
3715
  <fo:block>
3716
+
3626
3717
  <xsl:apply-templates/>
3627
3718
  </fo:block>
3628
3719
  <xsl:call-template name="fn_display_figure"/>
@@ -3745,6 +3836,234 @@
3745
3836
  <xsl:param name="height"/>
3746
3837
  <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; "/>
3747
3838
  <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; "/>
3839
+ </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">
3840
+ <xsl:param name="name"/>
3841
+
3842
+ <xsl:variable name="svg_content">
3843
+ <xsl:apply-templates select="." mode="svg_update"/>
3844
+ </xsl:variable>
3845
+
3846
+ <xsl:variable name="alt-text">
3847
+ <xsl:choose>
3848
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3849
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3850
+ </xsl:when>
3851
+ <xsl:when test="normalize-space($name) != ''">
3852
+ <xsl:value-of select="$name"/>
3853
+ </xsl:when>
3854
+ <xsl:otherwise>Figure</xsl:otherwise>
3855
+ </xsl:choose>
3856
+ </xsl:variable>
3857
+
3858
+ <xsl:choose>
3859
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3860
+ <fo:block>
3861
+ <xsl:variable name="width" select="@width"/>
3862
+ <xsl:variable name="height" select="@height"/>
3863
+
3864
+ <xsl:variable name="scale_x">
3865
+ <xsl:choose>
3866
+ <xsl:when test="$width &gt; $width_effective_px">
3867
+ <xsl:value-of select="$width_effective_px div $width"/>
3868
+ </xsl:when>
3869
+ <xsl:otherwise>1</xsl:otherwise>
3870
+ </xsl:choose>
3871
+ </xsl:variable>
3872
+
3873
+ <xsl:variable name="scale_y">
3874
+ <xsl:choose>
3875
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
3876
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
3877
+ </xsl:when>
3878
+ <xsl:otherwise>1</xsl:otherwise>
3879
+ </xsl:choose>
3880
+ </xsl:variable>
3881
+
3882
+ <xsl:variable name="scale">
3883
+ <xsl:choose>
3884
+ <xsl:when test="$scale_y != 1">
3885
+ <xsl:value-of select="$scale_x * $scale_y"/>
3886
+ </xsl:when>
3887
+ <xsl:otherwise>
3888
+ <xsl:value-of select="$scale_x"/>
3889
+ </xsl:otherwise>
3890
+ </xsl:choose>
3891
+ </xsl:variable>
3892
+
3893
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
3894
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
3895
+
3896
+ <fo:table table-layout="fixed" width="100%">
3897
+ <fo:table-column column-width="proportional-column-width(1)"/>
3898
+ <fo:table-column column-width="{$width_scale}px"/>
3899
+ <fo:table-column column-width="proportional-column-width(1)"/>
3900
+ <fo:table-body>
3901
+ <fo:table-row>
3902
+ <fo:table-cell column-number="2">
3903
+ <fo:block>
3904
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
3905
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3906
+ <fo:block line-height="0" font-size="0">
3907
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3908
+ <xsl:call-template name="bookmark"/>
3909
+ </xsl:for-each>
3910
+ </fo:block>
3911
+ </xsl:if>
3912
+ <fo:block text-depth="0" line-height="0" font-size="0">
3913
+
3914
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3915
+ <xsl:attribute name="width">100%</xsl:attribute>
3916
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3917
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3918
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3919
+
3920
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
3921
+ </fo:instream-foreign-object>
3922
+ </fo:block>
3923
+
3924
+ <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">
3925
+ <xsl:with-param name="scale" select="$scale"/>
3926
+ </xsl:apply-templates>
3927
+ </fo:block-container>
3928
+ </fo:block>
3929
+ </fo:table-cell>
3930
+ </fo:table-row>
3931
+ </fo:table-body>
3932
+ </fo:table>
3933
+ </fo:block>
3934
+
3935
+ </xsl:when>
3936
+ <xsl:otherwise>
3937
+ <fo:block xsl:use-attribute-sets="image-style">
3938
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3939
+ <xsl:attribute name="width">100%</xsl:attribute>
3940
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3941
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3942
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
3943
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
3944
+ <!-- effective height / width = 1.48, 1.4 - with title -->
3945
+ <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
3946
+ <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
3947
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
3948
+ </xsl:if>
3949
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3950
+ <xsl:copy-of select="$svg_content"/>
3951
+ </fo:instream-foreign-object>
3952
+ </fo:block>
3953
+ </xsl:otherwise>
3954
+ </xsl:choose>
3955
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
3956
+ <xsl:copy>
3957
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
3958
+ </xsl:copy>
3959
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
3960
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
3961
+ <xsl:value-of select="."/>
3962
+ </xsl:attribute>
3963
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
3964
+ <xsl:variable name="svg_content" select="document(@src)"/>
3965
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
3966
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
3967
+ <xsl:call-template name="image_svg">
3968
+ <xsl:with-param name="name" select="$name"/>
3969
+ </xsl:call-template>
3970
+ </xsl:for-each>
3971
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
3972
+ <xsl:copy>
3973
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
3974
+ </xsl:copy>
3975
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
3976
+ <xsl:apply-templates mode="svg_remove_a"/>
3977
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
3978
+ <xsl:param name="scale"/>
3979
+ <xsl:variable name="dest">
3980
+ <xsl:choose>
3981
+ <xsl:when test="starts-with(@href, '#')">
3982
+ <xsl:value-of select="substring-after(@href, '#')"/>
3983
+ </xsl:when>
3984
+ <xsl:otherwise>
3985
+ <xsl:value-of select="@href"/>
3986
+ </xsl:otherwise>
3987
+ </xsl:choose>
3988
+ </xsl:variable>
3989
+ <xsl:for-each select="./*[local-name() = 'rect']">
3990
+ <xsl:call-template name="insertSVGMapLink">
3991
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
3992
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
3993
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
3994
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
3995
+ <xsl:with-param name="dest" select="$dest"/>
3996
+ </xsl:call-template>
3997
+ </xsl:for-each>
3998
+
3999
+ <xsl:for-each select="./*[local-name() = 'polygon']">
4000
+ <xsl:variable name="points">
4001
+ <xsl:call-template name="split">
4002
+ <xsl:with-param name="pText" select="@points"/>
4003
+ </xsl:call-template>
4004
+ </xsl:variable>
4005
+ <xsl:variable name="x_coords">
4006
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
4007
+ <xsl:sort select="." data-type="number"/>
4008
+ <x><xsl:value-of select="."/></x>
4009
+ </xsl:for-each>
4010
+ </xsl:variable>
4011
+ <xsl:variable name="y_coords">
4012
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
4013
+ <xsl:sort select="." data-type="number"/>
4014
+ <y><xsl:value-of select="."/></y>
4015
+ </xsl:for-each>
4016
+ </xsl:variable>
4017
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
4018
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
4019
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
4020
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
4021
+ <xsl:call-template name="insertSVGMapLink">
4022
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
4023
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
4024
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
4025
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
4026
+ <xsl:with-param name="dest" select="$dest"/>
4027
+ </xsl:call-template>
4028
+ </xsl:for-each>
4029
+
4030
+ <xsl:for-each select="./*[local-name() = 'circle']">
4031
+ <xsl:call-template name="insertSVGMapLink">
4032
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
4033
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
4034
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
4035
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
4036
+ <xsl:with-param name="dest" select="$dest"/>
4037
+ </xsl:call-template>
4038
+ </xsl:for-each>
4039
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
4040
+ <xsl:call-template name="insertSVGMapLink">
4041
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
4042
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
4043
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
4044
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
4045
+ <xsl:with-param name="dest" select="$dest"/>
4046
+ </xsl:call-template>
4047
+ </xsl:for-each>
4048
+ </xsl:template><xsl:template name="insertSVGMapLink">
4049
+ <xsl:param name="left"/>
4050
+ <xsl:param name="top"/>
4051
+ <xsl:param name="width"/>
4052
+ <xsl:param name="height"/>
4053
+ <xsl:param name="dest"/>
4054
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
4055
+ <fo:block font-size="1pt">
4056
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
4057
+ <fo:inline-container inline-progression-dimension="100%">
4058
+ <fo:block-container height="{$height - 1}px" width="100%">
4059
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
4060
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
4061
+ </xsl:if> -->
4062
+ <fo:block> </fo:block></fo:block-container>
4063
+ </fo:inline-container>
4064
+ </fo:basic-link>
4065
+ </fo:block>
4066
+ </fo:block-container>
3748
4067
  </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">
3749
4068
  <xsl:apply-templates mode="contents"/>
3750
4069
  <xsl:text> </xsl:text>
@@ -3773,28 +4092,39 @@
3773
4092
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3774
4093
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3775
4094
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4095
+ <xsl:if test="@bundle = 'true'">
4096
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
4097
+ </xsl:if>
3776
4098
  <fo:bookmark-title>
3777
- <xsl:variable name="bookmark-title_">
3778
- <xsl:call-template name="getLangVersion">
3779
- <xsl:with-param name="lang" select="@lang"/>
3780
- <xsl:with-param name="doctype" select="@doctype"/>
3781
- <xsl:with-param name="title" select="@title-part"/>
3782
- </xsl:call-template>
3783
- </xsl:variable>
3784
4099
  <xsl:choose>
3785
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3786
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3787
- </xsl:when>
3788
- <xsl:otherwise>
4100
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
4101
+ <xsl:variable name="bookmark-title_">
4102
+ <xsl:call-template name="getLangVersion">
4103
+ <xsl:with-param name="lang" select="@lang"/>
4104
+ <xsl:with-param name="doctype" select="@doctype"/>
4105
+ <xsl:with-param name="title" select="@title-part"/>
4106
+ </xsl:call-template>
4107
+ </xsl:variable>
3789
4108
  <xsl:choose>
3790
- <xsl:when test="@lang = 'en'">English</xsl:when>
3791
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3792
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3793
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4109
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
4110
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
4111
+ </xsl:when>
4112
+ <xsl:otherwise>
4113
+ <xsl:choose>
4114
+ <xsl:when test="@lang = 'en'">English</xsl:when>
4115
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
4116
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4117
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4118
+ </xsl:choose>
4119
+ </xsl:otherwise>
3794
4120
  </xsl:choose>
4121
+ </xsl:when>
4122
+ <xsl:otherwise>
4123
+ <xsl:value-of select="@title-part"/>
3795
4124
  </xsl:otherwise>
3796
4125
  </xsl:choose>
3797
4126
  </fo:bookmark-title>
4127
+
3798
4128
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3799
4129
 
3800
4130
  <xsl:call-template name="insertFigureBookmarks">
@@ -3904,20 +4234,28 @@
3904
4234
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
3905
4235
  </xsl:choose>
3906
4236
  </xsl:template><xsl:template match="item" mode="bookmark">
3907
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
3908
- <fo:bookmark-title>
3909
- <xsl:if test="@section != ''">
3910
- <xsl:value-of select="@section"/>
3911
- <xsl:text> </xsl:text>
3912
- </xsl:if>
3913
- <xsl:value-of select="normalize-space(title)"/>
3914
- </fo:bookmark-title>
3915
- <xsl:apply-templates mode="bookmark"/>
3916
- </fo:bookmark>
4237
+ <xsl:choose>
4238
+ <xsl:when test="@id != ''">
4239
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4240
+ <fo:bookmark-title>
4241
+ <xsl:if test="@section != ''">
4242
+ <xsl:value-of select="@section"/>
4243
+ <xsl:text> </xsl:text>
4244
+ </xsl:if>
4245
+ <xsl:value-of select="normalize-space(title)"/>
4246
+ </fo:bookmark-title>
4247
+ <xsl:apply-templates mode="bookmark"/>
4248
+ </fo:bookmark>
4249
+ </xsl:when>
4250
+ <xsl:otherwise>
4251
+ <xsl:apply-templates mode="bookmark"/>
4252
+ </xsl:otherwise>
4253
+ </xsl:choose>
3917
4254
  </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">
3918
4255
  <xsl:if test="normalize-space() != ''">
3919
4256
  <fo:block xsl:use-attribute-sets="figure-name-style">
3920
4257
 
4258
+
3921
4259
  <xsl:apply-templates/>
3922
4260
  </fo:block>
3923
4261
  </xsl:if>
@@ -3997,6 +4335,8 @@
3997
4335
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
3998
4336
 
3999
4337
  <fo:block-container margin-left="0mm">
4338
+ <xsl:copy-of select="@id"/>
4339
+
4000
4340
  <xsl:if test="parent::*[local-name() = 'note']">
4001
4341
  <xsl:attribute name="margin-left">
4002
4342
  <xsl:choose>
@@ -4007,7 +4347,9 @@
4007
4347
 
4008
4348
  </xsl:if>
4009
4349
  <fo:block-container margin-left="0mm">
4010
-
4350
+
4351
+
4352
+
4011
4353
  <fo:block xsl:use-attribute-sets="sourcecode-style">
4012
4354
  <xsl:variable name="_font-size">
4013
4355
 
@@ -4036,10 +4378,14 @@
4036
4378
  </xsl:choose>
4037
4379
  </xsl:attribute>
4038
4380
  </xsl:if>
4039
- <xsl:apply-templates/>
4040
- </fo:block>
4381
+
4382
+ <xsl:apply-templates/>
4383
+ </fo:block>
4384
+
4385
+
4041
4386
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
4042
4387
 
4388
+
4043
4389
  </fo:block-container>
4044
4390
  </fo:block-container>
4045
4391
  </xsl:template><xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -4282,6 +4628,7 @@
4282
4628
  </xsl:template><xsl:template match="*[local-name() = 'example']">
4283
4629
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
4284
4630
 
4631
+
4285
4632
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
4286
4633
 
4287
4634
  <xsl:variable name="element">
@@ -4391,12 +4738,15 @@
4391
4738
 
4392
4739
 
4393
4740
 
4741
+
4742
+
4743
+
4394
4744
  <xsl:call-template name="getTitle">
4395
4745
  <xsl:with-param name="name" select="'title-source'"/>
4396
4746
  </xsl:call-template>
4747
+ <xsl:text>: </xsl:text>
4397
4748
 
4398
4749
 
4399
- <xsl:text>: </xsl:text>
4400
4750
  </fo:inline>
4401
4751
 
4402
4752
  <fo:inline xsl:use-attribute-sets="origin-style">
@@ -4467,7 +4817,9 @@
4467
4817
 
4468
4818
 
4469
4819
  </xsl:if>
4470
-
4820
+
4821
+
4822
+
4471
4823
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4472
4824
  <xsl:if test="normalize-space(@citeas) = ''">
4473
4825
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -4479,6 +4831,7 @@
4479
4831
 
4480
4832
 
4481
4833
 
4834
+
4482
4835
  </xsl:if>
4483
4836
 
4484
4837
  <xsl:apply-templates/>
@@ -4512,6 +4865,7 @@
4512
4865
 
4513
4866
 
4514
4867
 
4868
+
4515
4869
  <xsl:choose>
4516
4870
  <xsl:when test="$depth &gt;= 5"/>
4517
4871
  <xsl:when test="$depth &gt;= 4">5</xsl:when>
@@ -4627,6 +4981,7 @@
4627
4981
  <xsl:call-template name="setId"/>
4628
4982
 
4629
4983
 
4984
+
4630
4985
  <xsl:apply-templates/>
4631
4986
  </fo:block>
4632
4987
  </xsl:template><xsl:template match="*[local-name() = 'definitions']">
@@ -5013,17 +5368,17 @@
5013
5368
  <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')]"/>
5014
5369
  <xsl:choose>
5015
5370
  <xsl:when test="normalize-space($_doc_ident) != ''">
5016
- <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"/>
5371
+ <!-- <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"/>
5017
5372
  <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
5018
5373
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
5019
- </xsl:if>
5374
+ </xsl:if> -->
5020
5375
  <xsl:value-of select="$_doc_ident"/>
5021
5376
  </xsl:when>
5022
5377
  <xsl:otherwise>
5023
- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
5378
+ <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
5024
5379
  <xsl:if test="$type != ''">
5025
5380
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
5026
- </xsl:if>
5381
+ </xsl:if> -->
5027
5382
  <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]"/>
5028
5383
  </xsl:otherwise>
5029
5384
  </xsl:choose>
@@ -5336,6 +5691,9 @@
5336
5691
  <xsl:when test="parent::*[local-name() = 'preface']">
5337
5692
  <xsl:value-of select="$level_total - 1"/>
5338
5693
  </xsl:when>
5694
+ <xsl:when test="ancestor::*[local-name() = 'preface'] and not(ancestor::*[local-name() = 'foreword']) and not(ancestor::*[local-name() = 'introduction'])"> <!-- for preface/clause -->
5695
+ <xsl:value-of select="$level_total - 1"/>
5696
+ </xsl:when>
5339
5697
  <xsl:when test="ancestor::*[local-name() = 'preface']">
5340
5698
  <xsl:value-of select="$level_total - 2"/>
5341
5699
  </xsl:when>
@@ -5476,7 +5834,14 @@
5476
5834
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5477
5835
  <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5478
5836
  </xsl:when>
5479
- <xsl:otherwise><xsl:value-of select="$key"/></xsl:otherwise>
5837
+ <xsl:otherwise>
5838
+ <xsl:variable name="key_">
5839
+ <xsl:call-template name="capitalize">
5840
+ <xsl:with-param name="str" select="translate($key, '_', ' ')"/>
5841
+ </xsl:call-template>
5842
+ </xsl:variable>
5843
+ <xsl:value-of select="$key_"/>
5844
+ </xsl:otherwise>
5480
5845
  </xsl:choose>
5481
5846
 
5482
5847
  </xsl:template><xsl:template name="setTrackChangesStyles">
@@ -5519,4 +5884,110 @@
5519
5884
  <xsl:value-of select="$align"/>
5520
5885
  </xsl:when>
5521
5886
  </xsl:choose>
5887
+ </xsl:template><xsl:template name="setTextAlignment">
5888
+ <xsl:param name="default">left</xsl:param>
5889
+ <xsl:attribute name="text-align">
5890
+ <xsl:choose>
5891
+ <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
5892
+ <xsl:when test="ancestor::*[local-name() = 'td']/@align"><xsl:value-of select="ancestor::*[local-name() = 'td']/@align"/></xsl:when>
5893
+ <xsl:when test="ancestor::*[local-name() = 'th']/@align"><xsl:value-of select="ancestor::*[local-name() = 'th']/@align"/></xsl:when>
5894
+ <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
5895
+ </xsl:choose>
5896
+ </xsl:attribute>
5897
+ </xsl:template><xsl:template name="number-to-words">
5898
+ <xsl:param name="number"/>
5899
+ <xsl:param name="first"/>
5900
+ <xsl:if test="$number != ''">
5901
+ <xsl:variable name="words">
5902
+ <words>
5903
+ <word cardinal="1">One-</word>
5904
+ <word ordinal="1">First </word>
5905
+ <word cardinal="2">Two-</word>
5906
+ <word ordinal="2">Second </word>
5907
+ <word cardinal="3">Three-</word>
5908
+ <word ordinal="3">Third </word>
5909
+ <word cardinal="4">Four-</word>
5910
+ <word ordinal="4">Fourth </word>
5911
+ <word cardinal="5">Five-</word>
5912
+ <word ordinal="5">Fifth </word>
5913
+ <word cardinal="6">Six-</word>
5914
+ <word ordinal="6">Sixth </word>
5915
+ <word cardinal="7">Seven-</word>
5916
+ <word ordinal="7">Seventh </word>
5917
+ <word cardinal="8">Eight-</word>
5918
+ <word ordinal="8">Eighth </word>
5919
+ <word cardinal="9">Nine-</word>
5920
+ <word ordinal="9">Ninth </word>
5921
+ <word ordinal="10">Tenth </word>
5922
+ <word ordinal="11">Eleventh </word>
5923
+ <word ordinal="12">Twelfth </word>
5924
+ <word ordinal="13">Thirteenth </word>
5925
+ <word ordinal="14">Fourteenth </word>
5926
+ <word ordinal="15">Fifteenth </word>
5927
+ <word ordinal="16">Sixteenth </word>
5928
+ <word ordinal="17">Seventeenth </word>
5929
+ <word ordinal="18">Eighteenth </word>
5930
+ <word ordinal="19">Nineteenth </word>
5931
+ <word cardinal="20">Twenty-</word>
5932
+ <word ordinal="20">Twentieth </word>
5933
+ <word cardinal="30">Thirty-</word>
5934
+ <word ordinal="30">Thirtieth </word>
5935
+ <word cardinal="40">Forty-</word>
5936
+ <word ordinal="40">Fortieth </word>
5937
+ <word cardinal="50">Fifty-</word>
5938
+ <word ordinal="50">Fiftieth </word>
5939
+ <word cardinal="60">Sixty-</word>
5940
+ <word ordinal="60">Sixtieth </word>
5941
+ <word cardinal="70">Seventy-</word>
5942
+ <word ordinal="70">Seventieth </word>
5943
+ <word cardinal="80">Eighty-</word>
5944
+ <word ordinal="80">Eightieth </word>
5945
+ <word cardinal="90">Ninety-</word>
5946
+ <word ordinal="90">Ninetieth </word>
5947
+ <word cardinal="100">Hundred-</word>
5948
+ <word ordinal="100">Hundredth </word>
5949
+ </words>
5950
+ </xsl:variable>
5951
+
5952
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
5953
+
5954
+ <xsl:variable name="value">
5955
+ <xsl:choose>
5956
+ <xsl:when test="$ordinal != ''">
5957
+ <xsl:value-of select="$ordinal"/>
5958
+ </xsl:when>
5959
+ <xsl:otherwise>
5960
+ <xsl:choose>
5961
+ <xsl:when test="$number &lt; 100">
5962
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
5963
+ <xsl:variable name="digit" select="substring($number,2)"/>
5964
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
5965
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
5966
+ </xsl:when>
5967
+ <xsl:otherwise>
5968
+ <!-- more 100 -->
5969
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
5970
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
5971
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
5972
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
5973
+ <xsl:call-template name="number-to-words">
5974
+ <xsl:with-param name="number" select="$digits"/>
5975
+ </xsl:call-template>
5976
+ </xsl:otherwise>
5977
+ </xsl:choose>
5978
+ </xsl:otherwise>
5979
+ </xsl:choose>
5980
+ </xsl:variable>
5981
+ <xsl:choose>
5982
+ <xsl:when test="$first = 'true'">
5983
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
5984
+ <xsl:call-template name="capitalize">
5985
+ <xsl:with-param name="str" select="$value_lc"/>
5986
+ </xsl:call-template>
5987
+ </xsl:when>
5988
+ <xsl:otherwise>
5989
+ <xsl:value-of select="$value"/>
5990
+ </xsl:otherwise>
5991
+ </xsl:choose>
5992
+ </xsl:if>
5522
5993
  </xsl:template></xsl:stylesheet>