metanorma-un 0.6.3 → 0.6.7

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="40"/>
18
+ <xsl:variable name="marginLeftRight2" select="40"/>
19
+ <xsl:variable name="marginTop" select="30"/>
20
+ <xsl:variable name="marginBottom" select="34"/>
17
21
 
18
22
  <xsl:variable name="contents">
19
23
  <contents>
@@ -44,7 +48,7 @@
44
48
  <fo:root font-family="Times New Roman, STIX Two Math, Source Han Sans" font-size="10pt" xml:lang="{$lang}">
45
49
  <fo:layout-master-set>
46
50
  <!-- Cover page -->
47
- <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}" page-height="{$pageHeight}">
51
+ <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
48
52
  <fo:region-body margin-top="20mm" margin-bottom="10mm" margin-left="50mm" margin-right="21mm"/>
49
53
  <fo:region-before extent="20mm"/>
50
54
  <fo:region-after extent="10mm"/>
@@ -52,25 +56,25 @@
52
56
  <fo:region-end extent="19mm"/>
53
57
  </fo:simple-page-master>
54
58
 
55
- <fo:simple-page-master master-name="document-preface" page-width="{$pageWidth}" page-height="{$pageHeight}">
56
- <fo:region-body margin-top="30mm" margin-bottom="34mm" margin-left="19.5mm" margin-right="19.5mm"/>
57
- <fo:region-before region-name="header" extent="30mm"/>
58
- <fo:region-after region-name="footer" extent="34mm"/>
59
+ <fo:simple-page-master master-name="document-preface" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
60
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="19.5mm" margin-right="19.5mm"/>
61
+ <fo:region-before region-name="header" extent="{$marginTop}mm"/>
62
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
59
63
  <fo:region-start region-name="left" extent="19.5mm"/>
60
64
  <fo:region-end region-name="right" extent="19.5mm"/>
61
65
  </fo:simple-page-master>
62
66
 
63
- <fo:simple-page-master master-name="blank" page-width="{$pageWidth}" page-height="{$pageHeight}">
64
- <fo:region-body margin-top="30mm" margin-bottom="34mm" margin-left="19.5mm" margin-right="19.5mm"/>
67
+ <fo:simple-page-master master-name="blank" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
68
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="19.5mm" margin-right="19.5mm"/>
65
69
  <fo:region-start region-name="left" extent="19.5mm"/>
66
70
  <fo:region-end region-name="right" extent="19.5mm"/>
67
71
  </fo:simple-page-master>
68
72
 
69
73
  <!-- Document pages -->
70
- <fo:simple-page-master master-name="document" page-width="{$pageWidth}" page-height="{$pageHeight}">
71
- <fo:region-body margin-top="30mm" margin-bottom="34mm" margin-left="40mm" margin-right="40mm"/>
72
- <fo:region-before region-name="header" extent="30mm"/>
73
- <fo:region-after region-name="footer" extent="34mm"/>
74
+ <fo:simple-page-master master-name="document" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
75
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
76
+ <fo:region-before region-name="header" extent="{$marginTop}mm"/>
77
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
74
78
  <fo:region-start region-name="left" extent="19.5mm"/>
75
79
  <fo:region-end region-name="right" extent="19.5mm"/>
76
80
  </fo:simple-page-master>
@@ -1219,6 +1223,7 @@
1219
1223
 
1220
1224
 
1221
1225
 
1226
+
1222
1227
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
1223
1228
  <xsl:attribute name="white-space">pre</xsl:attribute>
1224
1229
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
@@ -1264,7 +1269,7 @@
1264
1269
 
1265
1270
 
1266
1271
 
1267
-
1272
+
1268
1273
  </xsl:attribute-set><xsl:attribute-set name="example-style">
1269
1274
 
1270
1275
 
@@ -1277,6 +1282,7 @@
1277
1282
 
1278
1283
 
1279
1284
 
1285
+
1280
1286
  </xsl:attribute-set><xsl:attribute-set name="example-body-style">
1281
1287
 
1282
1288
 
@@ -1293,9 +1299,7 @@
1293
1299
 
1294
1300
 
1295
1301
 
1296
-
1297
-
1298
-
1302
+
1299
1303
 
1300
1304
  <xsl:attribute name="font-size">10pt</xsl:attribute>
1301
1305
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -1330,6 +1334,7 @@
1330
1334
 
1331
1335
 
1332
1336
 
1337
+
1333
1338
  </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1334
1339
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1335
1340
 
@@ -1352,6 +1357,9 @@
1352
1357
 
1353
1358
 
1354
1359
 
1360
+
1361
+ </xsl:attribute-set><xsl:attribute-set name="table-footer-cell-style">
1362
+
1355
1363
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1356
1364
 
1357
1365
 
@@ -1365,11 +1373,14 @@
1365
1373
 
1366
1374
 
1367
1375
 
1376
+
1368
1377
  </xsl:attribute-set><xsl:attribute-set name="eref-style">
1369
1378
 
1370
1379
 
1371
1380
 
1372
1381
 
1382
+
1383
+
1373
1384
  </xsl:attribute-set><xsl:attribute-set name="note-style">
1374
1385
 
1375
1386
 
@@ -1390,6 +1401,7 @@
1390
1401
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
1391
1402
 
1392
1403
 
1404
+
1393
1405
  </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">
1394
1406
 
1395
1407
 
@@ -1433,10 +1445,12 @@
1433
1445
  <xsl:attribute name="margin-top">4pt</xsl:attribute>
1434
1446
 
1435
1447
 
1448
+
1436
1449
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1437
1450
 
1438
1451
 
1439
1452
 
1453
+
1440
1454
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1441
1455
 
1442
1456
 
@@ -1456,10 +1470,12 @@
1456
1470
 
1457
1471
 
1458
1472
 
1473
+
1459
1474
  </xsl:attribute-set><xsl:attribute-set name="origin-style">
1460
1475
 
1461
1476
 
1462
1477
 
1478
+
1463
1479
  </xsl:attribute-set><xsl:attribute-set name="term-style">
1464
1480
 
1465
1481
  </xsl:attribute-set><xsl:attribute-set name="figure-name-style">
@@ -1478,6 +1494,7 @@
1478
1494
 
1479
1495
 
1480
1496
 
1497
+
1481
1498
 
1482
1499
 
1483
1500
 
@@ -1530,8 +1547,10 @@
1530
1547
  </xsl:attribute-set><xsl:attribute-set name="admitted-style">
1531
1548
 
1532
1549
 
1550
+
1533
1551
  </xsl:attribute-set><xsl:attribute-set name="deprecates-style">
1534
1552
 
1553
+
1535
1554
  </xsl:attribute-set><xsl:attribute-set name="definition-style">
1536
1555
 
1537
1556
 
@@ -1554,6 +1573,8 @@
1554
1573
  <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
1555
1574
 
1556
1575
 
1576
+ </xsl:attribute-set><xsl:attribute-set name="list-style">
1577
+
1557
1578
  </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">
1558
1579
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
1559
1580
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -1564,14 +1585,15 @@
1564
1585
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1565
1586
 
1566
1587
  <!-- Normative references -->
1567
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1588
+ <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"/>
1568
1589
  <!-- Terms and definitions -->
1569
1590
  <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"/>
1570
1591
  <!-- Another main sections -->
1571
1592
  <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"/>
1572
1593
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1573
1594
  <!-- Bibliography -->
1574
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1595
+ <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"/>
1596
+
1575
1597
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1576
1598
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1577
1599
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -1607,11 +1629,11 @@
1607
1629
  <xsl:variable name="table">
1608
1630
 
1609
1631
  <xsl:variable name="simple-table">
1610
- <xsl:call-template name="getSimpleTable"/>
1632
+ <xsl:call-template name="getSimpleTable"/>
1611
1633
  </xsl:variable>
1612
1634
 
1613
1635
  <!-- <xsl:if test="$namespace = 'bipm'">
1614
- <fo:block>&#xA0;</fo:block>
1636
+ <fo:block>&#xA0;</fo:block>
1615
1637
  </xsl:if> -->
1616
1638
 
1617
1639
  <!-- $namespace = 'iso' or -->
@@ -1728,6 +1750,7 @@
1728
1750
 
1729
1751
 
1730
1752
 
1753
+
1731
1754
  </xsl:variable>
1732
1755
 
1733
1756
 
@@ -1866,6 +1889,9 @@
1866
1889
  <fo:block xsl:use-attribute-sets="table-name-style">
1867
1890
 
1868
1891
 
1892
+
1893
+
1894
+
1869
1895
  <xsl:choose>
1870
1896
  <xsl:when test="$continued = 'true'">
1871
1897
  <!-- <xsl:if test="$namespace = 'bsi'"></xsl:if> -->
@@ -2013,6 +2039,7 @@
2013
2039
  <!-- font-weight="bold" -->
2014
2040
  <fo:table-header>
2015
2041
 
2042
+
2016
2043
  <xsl:apply-templates/>
2017
2044
  </fo:table-header>
2018
2045
  </xsl:template><xsl:template name="table-header-title">
@@ -2163,6 +2190,7 @@
2163
2190
 
2164
2191
 
2165
2192
 
2193
+
2166
2194
  <!-- fn will be processed inside 'note' processing -->
2167
2195
 
2168
2196
 
@@ -2171,6 +2199,10 @@
2171
2199
 
2172
2200
 
2173
2201
 
2202
+
2203
+ <!-- for BSI (not PAS) display Notes before footnotes -->
2204
+
2205
+
2174
2206
  <!-- except gb -->
2175
2207
 
2176
2208
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -2196,6 +2228,10 @@
2196
2228
  <!-- fn processing -->
2197
2229
  <xsl:call-template name="fn_display"/>
2198
2230
 
2231
+
2232
+ <!-- for PAS display Notes after footnotes -->
2233
+
2234
+
2199
2235
  </fo:table-cell>
2200
2236
  </fo:table-row>
2201
2237
  </fo:table-body>
@@ -2253,11 +2289,16 @@
2253
2289
  <xsl:if test="$parent-name = 'tfoot'">
2254
2290
 
2255
2291
 
2292
+
2256
2293
  </xsl:if>
2257
2294
 
2258
2295
 
2259
2296
 
2260
2297
 
2298
+
2299
+
2300
+
2301
+
2261
2302
  <!-- <xsl:if test="$namespace = 'bipm'">
2262
2303
  <xsl:attribute name="height">8mm</xsl:attribute>
2263
2304
  </xsl:if> -->
@@ -2303,6 +2344,7 @@
2303
2344
 
2304
2345
 
2305
2346
 
2347
+
2306
2348
  <xsl:if test="$lang = 'ar'">
2307
2349
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2308
2350
  </xsl:if>
@@ -2355,6 +2397,7 @@
2355
2397
 
2356
2398
 
2357
2399
 
2400
+
2358
2401
  <xsl:if test="ancestor::*[local-name()='sections']">
2359
2402
  <xsl:attribute name="border">solid black 0pt</xsl:attribute>
2360
2403
  <xsl:attribute name="padding-top">1mm</xsl:attribute>
@@ -2364,6 +2407,9 @@
2364
2407
 
2365
2408
 
2366
2409
 
2410
+
2411
+
2412
+
2367
2413
  <xsl:if test=".//*[local-name() = 'table']">
2368
2414
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2369
2415
  </xsl:if>
@@ -2393,8 +2439,14 @@
2393
2439
 
2394
2440
 
2395
2441
 
2442
+
2443
+
2444
+ <!-- Table's note name (NOTE, for example) -->
2445
+
2396
2446
  <fo:inline padding-right="2mm">
2397
2447
 
2448
+
2449
+
2398
2450
 
2399
2451
 
2400
2452
  <xsl:if test="@type = 'source' or @type = 'abbreviation'">
@@ -2412,6 +2464,8 @@
2412
2464
 
2413
2465
  </fo:inline>
2414
2466
 
2467
+
2468
+
2415
2469
  <xsl:apply-templates mode="process"/>
2416
2470
  </fo:block>
2417
2471
 
@@ -2431,6 +2485,8 @@
2431
2485
  <xsl:variable name="reference" select="@reference"/>
2432
2486
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
2433
2487
  <fo:block margin-bottom="12pt">
2488
+
2489
+
2434
2490
 
2435
2491
 
2436
2492
 
@@ -2446,9 +2502,11 @@
2446
2502
 
2447
2503
 
2448
2504
 
2505
+
2449
2506
  <xsl:value-of select="@reference"/>
2450
2507
 
2451
2508
 
2509
+
2452
2510
  </fo:inline>
2453
2511
  <fo:inline>
2454
2512
 
@@ -2589,11 +2647,16 @@
2589
2647
 
2590
2648
 
2591
2649
 
2650
+
2651
+
2652
+
2653
+
2592
2654
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2593
2655
 
2594
2656
 
2595
2657
  <xsl:value-of select="@reference"/>
2596
2658
 
2659
+
2597
2660
  </fo:basic-link>
2598
2661
  </fo:inline>
2599
2662
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -2680,6 +2743,7 @@
2680
2743
 
2681
2744
 
2682
2745
 
2746
+
2683
2747
  <xsl:variable name="title-key">
2684
2748
 
2685
2749
 
@@ -2890,6 +2954,7 @@
2890
2954
 
2891
2955
  <fo:table-row>
2892
2956
 
2957
+
2893
2958
  <fo:table-cell>
2894
2959
 
2895
2960
  <fo:block margin-top="6pt">
@@ -2905,6 +2970,7 @@
2905
2970
 
2906
2971
 
2907
2972
 
2973
+
2908
2974
  <xsl:apply-templates/>
2909
2975
  <!-- <xsl:if test="$namespace = 'gb'">
2910
2976
  <xsl:if test="ancestor::*[local-name()='formula']">
@@ -2961,6 +3027,8 @@
2961
3027
 
2962
3028
  <xsl:apply-templates/>
2963
3029
  </fo:inline>
3030
+ </xsl:template><xsl:template match="*[local-name()='padding']">
3031
+ <fo:inline padding-right="{@value}"> </fo:inline>
2964
3032
  </xsl:template><xsl:template match="*[local-name()='sup']">
2965
3033
  <fo:inline font-size="80%" vertical-align="super">
2966
3034
  <xsl:apply-templates/>
@@ -3450,9 +3518,27 @@
3450
3518
  <xsl:copy>
3451
3519
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
3452
3520
  </xsl:copy>
3453
- <mathml:mspace width="0.5ex"/>
3521
+ <xsl:choose>
3522
+ <!-- if in msub, then don't add space -->
3523
+ <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3524
+ <!-- if next char in digit, don't add space -->
3525
+ <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3526
+ <xsl:otherwise>
3527
+ <mathml:mspace width="0.5ex"/>
3528
+ </xsl:otherwise>
3529
+ </xsl:choose>
3454
3530
  </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">
3455
3531
  <xsl:variable name="target">
3532
+ <xsl:choose>
3533
+ <xsl:when test="@updatetype = 'true'">
3534
+ <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
3535
+ </xsl:when>
3536
+ <xsl:otherwise>
3537
+ <xsl:value-of select="normalize-space(@target)"/>
3538
+ </xsl:otherwise>
3539
+ </xsl:choose>
3540
+ </xsl:variable>
3541
+ <xsl:variable name="target_text">
3456
3542
  <xsl:choose>
3457
3543
  <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
3458
3544
  <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
@@ -3464,20 +3550,22 @@
3464
3550
  </xsl:variable>
3465
3551
  <fo:inline xsl:use-attribute-sets="link-style">
3466
3552
 
3553
+
3554
+
3467
3555
  <xsl:choose>
3468
- <xsl:when test="$target = ''">
3556
+ <xsl:when test="$target_text = ''">
3469
3557
  <xsl:apply-templates/>
3470
3558
  </xsl:when>
3471
3559
  <xsl:otherwise>
3472
- <fo:basic-link external-destination="{@target}" fox:alt-text="{@target}">
3560
+ <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
3473
3561
  <xsl:choose>
3474
3562
  <xsl:when test="normalize-space(.) = ''">
3475
- <!-- <xsl:value-of select="$target"/> -->
3476
3563
  <xsl:call-template name="add-zero-spaces-link-java">
3477
- <xsl:with-param name="text" select="$target"/>
3564
+ <xsl:with-param name="text" select="$target_text"/>
3478
3565
  </xsl:call-template>
3479
3566
  </xsl:when>
3480
3567
  <xsl:otherwise>
3568
+ <!-- output text from <link>text</link> -->
3481
3569
  <xsl:apply-templates/>
3482
3570
  </xsl:otherwise>
3483
3571
  </xsl:choose>
@@ -3576,6 +3664,7 @@
3576
3664
 
3577
3665
 
3578
3666
 
3667
+
3579
3668
  <fo:block-container margin-left="0mm">
3580
3669
 
3581
3670
 
@@ -3628,6 +3717,7 @@
3628
3717
  </xsl:choose>
3629
3718
  </xsl:template><xsl:template match="*[local-name() = 'termnote']">
3630
3719
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
3720
+
3631
3721
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
3632
3722
 
3633
3723
  <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
@@ -3705,6 +3795,7 @@
3705
3795
  </xsl:call-template>
3706
3796
 
3707
3797
  <fo:block>
3798
+
3708
3799
  <xsl:apply-templates/>
3709
3800
  </fo:block>
3710
3801
  <xsl:call-template name="fn_display_figure"/>
@@ -3832,6 +3923,234 @@
3832
3923
  <xsl:param name="height"/>
3833
3924
  <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; "/>
3834
3925
  <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; "/>
3926
+ </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">
3927
+ <xsl:param name="name"/>
3928
+
3929
+ <xsl:variable name="svg_content">
3930
+ <xsl:apply-templates select="." mode="svg_update"/>
3931
+ </xsl:variable>
3932
+
3933
+ <xsl:variable name="alt-text">
3934
+ <xsl:choose>
3935
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3936
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3937
+ </xsl:when>
3938
+ <xsl:when test="normalize-space($name) != ''">
3939
+ <xsl:value-of select="$name"/>
3940
+ </xsl:when>
3941
+ <xsl:otherwise>Figure</xsl:otherwise>
3942
+ </xsl:choose>
3943
+ </xsl:variable>
3944
+
3945
+ <xsl:choose>
3946
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3947
+ <fo:block>
3948
+ <xsl:variable name="width" select="@width"/>
3949
+ <xsl:variable name="height" select="@height"/>
3950
+
3951
+ <xsl:variable name="scale_x">
3952
+ <xsl:choose>
3953
+ <xsl:when test="$width &gt; $width_effective_px">
3954
+ <xsl:value-of select="$width_effective_px div $width"/>
3955
+ </xsl:when>
3956
+ <xsl:otherwise>1</xsl:otherwise>
3957
+ </xsl:choose>
3958
+ </xsl:variable>
3959
+
3960
+ <xsl:variable name="scale_y">
3961
+ <xsl:choose>
3962
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
3963
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
3964
+ </xsl:when>
3965
+ <xsl:otherwise>1</xsl:otherwise>
3966
+ </xsl:choose>
3967
+ </xsl:variable>
3968
+
3969
+ <xsl:variable name="scale">
3970
+ <xsl:choose>
3971
+ <xsl:when test="$scale_y != 1">
3972
+ <xsl:value-of select="$scale_x * $scale_y"/>
3973
+ </xsl:when>
3974
+ <xsl:otherwise>
3975
+ <xsl:value-of select="$scale_x"/>
3976
+ </xsl:otherwise>
3977
+ </xsl:choose>
3978
+ </xsl:variable>
3979
+
3980
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
3981
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
3982
+
3983
+ <fo:table table-layout="fixed" width="100%">
3984
+ <fo:table-column column-width="proportional-column-width(1)"/>
3985
+ <fo:table-column column-width="{$width_scale}px"/>
3986
+ <fo:table-column column-width="proportional-column-width(1)"/>
3987
+ <fo:table-body>
3988
+ <fo:table-row>
3989
+ <fo:table-cell column-number="2">
3990
+ <fo:block>
3991
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
3992
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3993
+ <fo:block line-height="0" font-size="0">
3994
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3995
+ <xsl:call-template name="bookmark"/>
3996
+ </xsl:for-each>
3997
+ </fo:block>
3998
+ </xsl:if>
3999
+ <fo:block text-depth="0" line-height="0" font-size="0">
4000
+
4001
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4002
+ <xsl:attribute name="width">100%</xsl:attribute>
4003
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4004
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4005
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4006
+
4007
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
4008
+ </fo:instream-foreign-object>
4009
+ </fo:block>
4010
+
4011
+ <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">
4012
+ <xsl:with-param name="scale" select="$scale"/>
4013
+ </xsl:apply-templates>
4014
+ </fo:block-container>
4015
+ </fo:block>
4016
+ </fo:table-cell>
4017
+ </fo:table-row>
4018
+ </fo:table-body>
4019
+ </fo:table>
4020
+ </fo:block>
4021
+
4022
+ </xsl:when>
4023
+ <xsl:otherwise>
4024
+ <fo:block xsl:use-attribute-sets="image-style">
4025
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4026
+ <xsl:attribute name="width">100%</xsl:attribute>
4027
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4028
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4029
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4030
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4031
+ <!-- effective height / width = 1.48, 1.4 - with title -->
4032
+ <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
4033
+ <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
4034
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4035
+ </xsl:if>
4036
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4037
+ <xsl:copy-of select="$svg_content"/>
4038
+ </fo:instream-foreign-object>
4039
+ </fo:block>
4040
+ </xsl:otherwise>
4041
+ </xsl:choose>
4042
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
4043
+ <xsl:copy>
4044
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
4045
+ </xsl:copy>
4046
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
4047
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4048
+ <xsl:value-of select="."/>
4049
+ </xsl:attribute>
4050
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4051
+ <xsl:variable name="svg_content" select="document(@src)"/>
4052
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
4053
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
4054
+ <xsl:call-template name="image_svg">
4055
+ <xsl:with-param name="name" select="$name"/>
4056
+ </xsl:call-template>
4057
+ </xsl:for-each>
4058
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
4059
+ <xsl:copy>
4060
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
4061
+ </xsl:copy>
4062
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
4063
+ <xsl:apply-templates mode="svg_remove_a"/>
4064
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
4065
+ <xsl:param name="scale"/>
4066
+ <xsl:variable name="dest">
4067
+ <xsl:choose>
4068
+ <xsl:when test="starts-with(@href, '#')">
4069
+ <xsl:value-of select="substring-after(@href, '#')"/>
4070
+ </xsl:when>
4071
+ <xsl:otherwise>
4072
+ <xsl:value-of select="@href"/>
4073
+ </xsl:otherwise>
4074
+ </xsl:choose>
4075
+ </xsl:variable>
4076
+ <xsl:for-each select="./*[local-name() = 'rect']">
4077
+ <xsl:call-template name="insertSVGMapLink">
4078
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
4079
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
4080
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
4081
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
4082
+ <xsl:with-param name="dest" select="$dest"/>
4083
+ </xsl:call-template>
4084
+ </xsl:for-each>
4085
+
4086
+ <xsl:for-each select="./*[local-name() = 'polygon']">
4087
+ <xsl:variable name="points">
4088
+ <xsl:call-template name="split">
4089
+ <xsl:with-param name="pText" select="@points"/>
4090
+ </xsl:call-template>
4091
+ </xsl:variable>
4092
+ <xsl:variable name="x_coords">
4093
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
4094
+ <xsl:sort select="." data-type="number"/>
4095
+ <x><xsl:value-of select="."/></x>
4096
+ </xsl:for-each>
4097
+ </xsl:variable>
4098
+ <xsl:variable name="y_coords">
4099
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
4100
+ <xsl:sort select="." data-type="number"/>
4101
+ <y><xsl:value-of select="."/></y>
4102
+ </xsl:for-each>
4103
+ </xsl:variable>
4104
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
4105
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
4106
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
4107
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
4108
+ <xsl:call-template name="insertSVGMapLink">
4109
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
4110
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
4111
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
4112
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
4113
+ <xsl:with-param name="dest" select="$dest"/>
4114
+ </xsl:call-template>
4115
+ </xsl:for-each>
4116
+
4117
+ <xsl:for-each select="./*[local-name() = 'circle']">
4118
+ <xsl:call-template name="insertSVGMapLink">
4119
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
4120
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
4121
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
4122
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
4123
+ <xsl:with-param name="dest" select="$dest"/>
4124
+ </xsl:call-template>
4125
+ </xsl:for-each>
4126
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
4127
+ <xsl:call-template name="insertSVGMapLink">
4128
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
4129
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
4130
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
4131
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
4132
+ <xsl:with-param name="dest" select="$dest"/>
4133
+ </xsl:call-template>
4134
+ </xsl:for-each>
4135
+ </xsl:template><xsl:template name="insertSVGMapLink">
4136
+ <xsl:param name="left"/>
4137
+ <xsl:param name="top"/>
4138
+ <xsl:param name="width"/>
4139
+ <xsl:param name="height"/>
4140
+ <xsl:param name="dest"/>
4141
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
4142
+ <fo:block font-size="1pt">
4143
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
4144
+ <fo:inline-container inline-progression-dimension="100%">
4145
+ <fo:block-container height="{$height - 1}px" width="100%">
4146
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
4147
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
4148
+ </xsl:if> -->
4149
+ <fo:block> </fo:block></fo:block-container>
4150
+ </fo:inline-container>
4151
+ </fo:basic-link>
4152
+ </fo:block>
4153
+ </fo:block-container>
3835
4154
  </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">
3836
4155
  <xsl:apply-templates mode="contents"/>
3837
4156
  <xsl:text> </xsl:text>
@@ -3860,28 +4179,39 @@
3860
4179
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3861
4180
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3862
4181
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4182
+ <xsl:if test="@bundle = 'true'">
4183
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
4184
+ </xsl:if>
3863
4185
  <fo:bookmark-title>
3864
- <xsl:variable name="bookmark-title_">
3865
- <xsl:call-template name="getLangVersion">
3866
- <xsl:with-param name="lang" select="@lang"/>
3867
- <xsl:with-param name="doctype" select="@doctype"/>
3868
- <xsl:with-param name="title" select="@title-part"/>
3869
- </xsl:call-template>
3870
- </xsl:variable>
3871
4186
  <xsl:choose>
3872
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3873
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3874
- </xsl:when>
3875
- <xsl:otherwise>
4187
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
4188
+ <xsl:variable name="bookmark-title_">
4189
+ <xsl:call-template name="getLangVersion">
4190
+ <xsl:with-param name="lang" select="@lang"/>
4191
+ <xsl:with-param name="doctype" select="@doctype"/>
4192
+ <xsl:with-param name="title" select="@title-part"/>
4193
+ </xsl:call-template>
4194
+ </xsl:variable>
3876
4195
  <xsl:choose>
3877
- <xsl:when test="@lang = 'en'">English</xsl:when>
3878
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3879
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3880
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4196
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
4197
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
4198
+ </xsl:when>
4199
+ <xsl:otherwise>
4200
+ <xsl:choose>
4201
+ <xsl:when test="@lang = 'en'">English</xsl:when>
4202
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
4203
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4204
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4205
+ </xsl:choose>
4206
+ </xsl:otherwise>
3881
4207
  </xsl:choose>
4208
+ </xsl:when>
4209
+ <xsl:otherwise>
4210
+ <xsl:value-of select="@title-part"/>
3882
4211
  </xsl:otherwise>
3883
4212
  </xsl:choose>
3884
4213
  </fo:bookmark-title>
4214
+
3885
4215
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3886
4216
 
3887
4217
  <xsl:call-template name="insertFigureBookmarks">
@@ -3980,20 +4310,28 @@
3980
4310
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
3981
4311
  </xsl:choose>
3982
4312
  </xsl:template><xsl:template match="item" mode="bookmark">
3983
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
3984
- <fo:bookmark-title>
3985
- <xsl:if test="@section != ''">
3986
- <xsl:value-of select="@section"/>
3987
- <xsl:text> </xsl:text>
3988
- </xsl:if>
3989
- <xsl:value-of select="normalize-space(title)"/>
3990
- </fo:bookmark-title>
3991
- <xsl:apply-templates mode="bookmark"/>
3992
- </fo:bookmark>
4313
+ <xsl:choose>
4314
+ <xsl:when test="@id != ''">
4315
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4316
+ <fo:bookmark-title>
4317
+ <xsl:if test="@section != ''">
4318
+ <xsl:value-of select="@section"/>
4319
+ <xsl:text> </xsl:text>
4320
+ </xsl:if>
4321
+ <xsl:value-of select="normalize-space(title)"/>
4322
+ </fo:bookmark-title>
4323
+ <xsl:apply-templates mode="bookmark"/>
4324
+ </fo:bookmark>
4325
+ </xsl:when>
4326
+ <xsl:otherwise>
4327
+ <xsl:apply-templates mode="bookmark"/>
4328
+ </xsl:otherwise>
4329
+ </xsl:choose>
3993
4330
  </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">
3994
4331
  <xsl:if test="normalize-space() != ''">
3995
4332
  <fo:block xsl:use-attribute-sets="figure-name-style">
3996
4333
 
4334
+
3997
4335
  <xsl:apply-templates/>
3998
4336
  </fo:block>
3999
4337
  </xsl:if>
@@ -4073,6 +4411,8 @@
4073
4411
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
4074
4412
 
4075
4413
  <fo:block-container margin-left="0mm">
4414
+ <xsl:copy-of select="@id"/>
4415
+
4076
4416
  <xsl:if test="parent::*[local-name() = 'note']">
4077
4417
  <xsl:attribute name="margin-left">
4078
4418
  <xsl:choose>
@@ -4083,7 +4423,9 @@
4083
4423
 
4084
4424
  </xsl:if>
4085
4425
  <fo:block-container margin-left="0mm">
4086
-
4426
+
4427
+
4428
+
4087
4429
  <fo:block xsl:use-attribute-sets="sourcecode-style">
4088
4430
  <xsl:variable name="_font-size">
4089
4431
 
@@ -4112,10 +4454,14 @@
4112
4454
  </xsl:choose>
4113
4455
  </xsl:attribute>
4114
4456
  </xsl:if>
4115
- <xsl:apply-templates/>
4116
- </fo:block>
4457
+
4458
+ <xsl:apply-templates/>
4459
+ </fo:block>
4460
+
4461
+
4117
4462
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
4118
4463
 
4464
+
4119
4465
  </fo:block-container>
4120
4466
  </fo:block-container>
4121
4467
  </xsl:template><xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -4350,6 +4696,7 @@
4350
4696
  </xsl:template><xsl:template match="*[local-name() = 'example']">
4351
4697
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
4352
4698
 
4699
+
4353
4700
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
4354
4701
 
4355
4702
  <xsl:variable name="element">
@@ -4528,7 +4875,9 @@
4528
4875
 
4529
4876
 
4530
4877
  </xsl:if>
4531
-
4878
+
4879
+
4880
+
4532
4881
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4533
4882
  <xsl:if test="normalize-space(@citeas) = ''">
4534
4883
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -4537,6 +4886,7 @@
4537
4886
 
4538
4887
 
4539
4888
 
4889
+
4540
4890
  </xsl:if>
4541
4891
 
4542
4892
  <xsl:apply-templates/>
@@ -4573,6 +4923,7 @@
4573
4923
 
4574
4924
 
4575
4925
 
4926
+
4576
4927
  <xsl:choose>
4577
4928
  <xsl:when test="ancestor::un:annex and $depth &gt;= 2">9.5</xsl:when>
4578
4929
  <xsl:when test="ancestor::un:sections">9.5</xsl:when>
@@ -4683,6 +5034,7 @@
4683
5034
  <xsl:call-template name="setId"/>
4684
5035
 
4685
5036
 
5037
+
4686
5038
  <xsl:apply-templates/>
4687
5039
  </fo:block>
4688
5040
  </xsl:template><xsl:template match="*[local-name() = 'definitions']">
@@ -4934,17 +5286,17 @@
4934
5286
  <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')]"/>
4935
5287
  <xsl:choose>
4936
5288
  <xsl:when test="normalize-space($_doc_ident) != ''">
4937
- <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"/>
5289
+ <!-- <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"/>
4938
5290
  <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
4939
5291
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4940
- </xsl:if>
5292
+ </xsl:if> -->
4941
5293
  <xsl:value-of select="$_doc_ident"/>
4942
5294
  </xsl:when>
4943
5295
  <xsl:otherwise>
4944
- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
5296
+ <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
4945
5297
  <xsl:if test="$type != ''">
4946
5298
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4947
- </xsl:if>
5299
+ </xsl:if> -->
4948
5300
  <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]"/>
4949
5301
  </xsl:otherwise>
4950
5302
  </xsl:choose>
@@ -5257,6 +5609,9 @@
5257
5609
  <xsl:when test="parent::*[local-name() = 'preface']">
5258
5610
  <xsl:value-of select="$level_total - 1"/>
5259
5611
  </xsl:when>
5612
+ <xsl:when test="ancestor::*[local-name() = 'preface'] and not(ancestor::*[local-name() = 'foreword']) and not(ancestor::*[local-name() = 'introduction'])"> <!-- for preface/clause -->
5613
+ <xsl:value-of select="$level_total - 1"/>
5614
+ </xsl:when>
5260
5615
  <xsl:when test="ancestor::*[local-name() = 'preface']">
5261
5616
  <xsl:value-of select="$level_total - 2"/>
5262
5617
  </xsl:when>
@@ -5397,7 +5752,14 @@
5397
5752
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5398
5753
  <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5399
5754
  </xsl:when>
5400
- <xsl:otherwise><xsl:value-of select="$key"/></xsl:otherwise>
5755
+ <xsl:otherwise>
5756
+ <xsl:variable name="key_">
5757
+ <xsl:call-template name="capitalize">
5758
+ <xsl:with-param name="str" select="translate($key, '_', ' ')"/>
5759
+ </xsl:call-template>
5760
+ </xsl:variable>
5761
+ <xsl:value-of select="$key_"/>
5762
+ </xsl:otherwise>
5401
5763
  </xsl:choose>
5402
5764
 
5403
5765
  </xsl:template><xsl:template name="setTrackChangesStyles">
@@ -5440,4 +5802,110 @@
5440
5802
  <xsl:value-of select="$align"/>
5441
5803
  </xsl:when>
5442
5804
  </xsl:choose>
5805
+ </xsl:template><xsl:template name="setTextAlignment">
5806
+ <xsl:param name="default">left</xsl:param>
5807
+ <xsl:attribute name="text-align">
5808
+ <xsl:choose>
5809
+ <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
5810
+ <xsl:when test="ancestor::*[local-name() = 'td']/@align"><xsl:value-of select="ancestor::*[local-name() = 'td']/@align"/></xsl:when>
5811
+ <xsl:when test="ancestor::*[local-name() = 'th']/@align"><xsl:value-of select="ancestor::*[local-name() = 'th']/@align"/></xsl:when>
5812
+ <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
5813
+ </xsl:choose>
5814
+ </xsl:attribute>
5815
+ </xsl:template><xsl:template name="number-to-words">
5816
+ <xsl:param name="number"/>
5817
+ <xsl:param name="first"/>
5818
+ <xsl:if test="$number != ''">
5819
+ <xsl:variable name="words">
5820
+ <words>
5821
+ <word cardinal="1">One-</word>
5822
+ <word ordinal="1">First </word>
5823
+ <word cardinal="2">Two-</word>
5824
+ <word ordinal="2">Second </word>
5825
+ <word cardinal="3">Three-</word>
5826
+ <word ordinal="3">Third </word>
5827
+ <word cardinal="4">Four-</word>
5828
+ <word ordinal="4">Fourth </word>
5829
+ <word cardinal="5">Five-</word>
5830
+ <word ordinal="5">Fifth </word>
5831
+ <word cardinal="6">Six-</word>
5832
+ <word ordinal="6">Sixth </word>
5833
+ <word cardinal="7">Seven-</word>
5834
+ <word ordinal="7">Seventh </word>
5835
+ <word cardinal="8">Eight-</word>
5836
+ <word ordinal="8">Eighth </word>
5837
+ <word cardinal="9">Nine-</word>
5838
+ <word ordinal="9">Ninth </word>
5839
+ <word ordinal="10">Tenth </word>
5840
+ <word ordinal="11">Eleventh </word>
5841
+ <word ordinal="12">Twelfth </word>
5842
+ <word ordinal="13">Thirteenth </word>
5843
+ <word ordinal="14">Fourteenth </word>
5844
+ <word ordinal="15">Fifteenth </word>
5845
+ <word ordinal="16">Sixteenth </word>
5846
+ <word ordinal="17">Seventeenth </word>
5847
+ <word ordinal="18">Eighteenth </word>
5848
+ <word ordinal="19">Nineteenth </word>
5849
+ <word cardinal="20">Twenty-</word>
5850
+ <word ordinal="20">Twentieth </word>
5851
+ <word cardinal="30">Thirty-</word>
5852
+ <word ordinal="30">Thirtieth </word>
5853
+ <word cardinal="40">Forty-</word>
5854
+ <word ordinal="40">Fortieth </word>
5855
+ <word cardinal="50">Fifty-</word>
5856
+ <word ordinal="50">Fiftieth </word>
5857
+ <word cardinal="60">Sixty-</word>
5858
+ <word ordinal="60">Sixtieth </word>
5859
+ <word cardinal="70">Seventy-</word>
5860
+ <word ordinal="70">Seventieth </word>
5861
+ <word cardinal="80">Eighty-</word>
5862
+ <word ordinal="80">Eightieth </word>
5863
+ <word cardinal="90">Ninety-</word>
5864
+ <word ordinal="90">Ninetieth </word>
5865
+ <word cardinal="100">Hundred-</word>
5866
+ <word ordinal="100">Hundredth </word>
5867
+ </words>
5868
+ </xsl:variable>
5869
+
5870
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
5871
+
5872
+ <xsl:variable name="value">
5873
+ <xsl:choose>
5874
+ <xsl:when test="$ordinal != ''">
5875
+ <xsl:value-of select="$ordinal"/>
5876
+ </xsl:when>
5877
+ <xsl:otherwise>
5878
+ <xsl:choose>
5879
+ <xsl:when test="$number &lt; 100">
5880
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
5881
+ <xsl:variable name="digit" select="substring($number,2)"/>
5882
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
5883
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
5884
+ </xsl:when>
5885
+ <xsl:otherwise>
5886
+ <!-- more 100 -->
5887
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
5888
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
5889
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
5890
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
5891
+ <xsl:call-template name="number-to-words">
5892
+ <xsl:with-param name="number" select="$digits"/>
5893
+ </xsl:call-template>
5894
+ </xsl:otherwise>
5895
+ </xsl:choose>
5896
+ </xsl:otherwise>
5897
+ </xsl:choose>
5898
+ </xsl:variable>
5899
+ <xsl:choose>
5900
+ <xsl:when test="$first = 'true'">
5901
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
5902
+ <xsl:call-template name="capitalize">
5903
+ <xsl:with-param name="str" select="$value_lc"/>
5904
+ </xsl:call-template>
5905
+ </xsl:when>
5906
+ <xsl:otherwise>
5907
+ <xsl:value-of select="$value"/>
5908
+ </xsl:otherwise>
5909
+ </xsl:choose>
5910
+ </xsl:if>
5443
5911
  </xsl:template></xsl:stylesheet>