metanorma-un 0.6.4 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -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>
@@ -1265,7 +1269,7 @@
1265
1269
 
1266
1270
 
1267
1271
 
1268
-
1272
+
1269
1273
  </xsl:attribute-set><xsl:attribute-set name="example-style">
1270
1274
 
1271
1275
 
@@ -1330,7 +1334,10 @@
1330
1334
 
1331
1335
 
1332
1336
 
1333
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1337
+
1338
+ </xsl:attribute-set><xsl:variable name="table-border_">
1339
+
1340
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1334
1341
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1335
1342
 
1336
1343
 
@@ -1353,6 +1360,8 @@
1353
1360
 
1354
1361
 
1355
1362
 
1363
+ </xsl:attribute-set><xsl:attribute-set name="table-footer-cell-style">
1364
+
1356
1365
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
1357
1366
 
1358
1367
 
@@ -1373,6 +1382,7 @@
1373
1382
 
1374
1383
 
1375
1384
 
1385
+
1376
1386
  </xsl:attribute-set><xsl:attribute-set name="note-style">
1377
1387
 
1378
1388
 
@@ -1393,6 +1403,7 @@
1393
1403
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
1394
1404
 
1395
1405
 
1406
+
1396
1407
  </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">
1397
1408
 
1398
1409
 
@@ -1436,10 +1447,12 @@
1436
1447
  <xsl:attribute name="margin-top">4pt</xsl:attribute>
1437
1448
 
1438
1449
 
1450
+
1439
1451
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1440
1452
 
1441
1453
 
1442
1454
 
1455
+
1443
1456
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1444
1457
 
1445
1458
 
@@ -1483,6 +1496,7 @@
1483
1496
 
1484
1497
 
1485
1498
 
1499
+
1486
1500
 
1487
1501
 
1488
1502
 
@@ -1561,6 +1575,8 @@
1561
1575
  <xsl:attribute name="font-family">STIX Two Math</xsl:attribute>
1562
1576
 
1563
1577
 
1578
+ </xsl:attribute-set><xsl:attribute-set name="list-style">
1579
+
1564
1580
  </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">
1565
1581
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
1566
1582
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -1571,14 +1587,15 @@
1571
1587
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1572
1588
 
1573
1589
  <!-- Normative references -->
1574
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1590
+ <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"/>
1575
1591
  <!-- Terms and definitions -->
1576
1592
  <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"/>
1577
1593
  <!-- Another main sections -->
1578
1594
  <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"/>
1579
1595
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1580
1596
  <!-- Bibliography -->
1581
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1597
+ <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"/>
1598
+
1582
1599
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1583
1600
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1584
1601
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -1614,13 +1631,15 @@
1614
1631
  <xsl:variable name="table">
1615
1632
 
1616
1633
  <xsl:variable name="simple-table">
1617
- <xsl:call-template name="getSimpleTable"/>
1634
+ <xsl:call-template name="getSimpleTable"/>
1618
1635
  </xsl:variable>
1619
1636
 
1620
1637
  <!-- <xsl:if test="$namespace = 'bipm'">
1621
- <fo:block>&#xA0;</fo:block>
1638
+ <fo:block>&#xA0;</fo:block>
1622
1639
  </xsl:if> -->
1623
1640
 
1641
+
1642
+ <!-- Display table's name before table as standalone block -->
1624
1643
  <!-- $namespace = 'iso' or -->
1625
1644
 
1626
1645
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -1701,6 +1720,12 @@
1701
1720
 
1702
1721
 
1703
1722
 
1723
+
1724
+
1725
+
1726
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
1727
+
1728
+
1704
1729
  <xsl:variable name="table_width">
1705
1730
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
1706
1731
 
@@ -1724,6 +1749,7 @@
1724
1749
 
1725
1750
 
1726
1751
 
1752
+
1727
1753
 
1728
1754
 
1729
1755
  <xsl:if test="ancestor::*[local-name()='sections']">
@@ -1735,6 +1761,7 @@
1735
1761
 
1736
1762
 
1737
1763
 
1764
+
1738
1765
  </xsl:variable>
1739
1766
 
1740
1767
 
@@ -1873,6 +1900,9 @@
1873
1900
  <fo:block xsl:use-attribute-sets="table-name-style">
1874
1901
 
1875
1902
 
1903
+
1904
+
1905
+
1876
1906
  <xsl:choose>
1877
1907
  <xsl:when test="$continued = 'true'">
1878
1908
  <!-- <xsl:if test="$namespace = 'bsi'"></xsl:if> -->
@@ -2020,6 +2050,7 @@
2020
2050
  <!-- font-weight="bold" -->
2021
2051
  <fo:table-header>
2022
2052
 
2053
+
2023
2054
  <xsl:apply-templates/>
2024
2055
  </fo:table-header>
2025
2056
  </xsl:template><xsl:template name="table-header-title">
@@ -2144,6 +2175,8 @@
2144
2175
  </xsl:choose>
2145
2176
  </xsl:for-each>
2146
2177
 
2178
+
2179
+
2147
2180
  <xsl:choose>
2148
2181
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2149
2182
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -2170,6 +2203,7 @@
2170
2203
 
2171
2204
 
2172
2205
 
2206
+
2173
2207
  <!-- fn will be processed inside 'note' processing -->
2174
2208
 
2175
2209
 
@@ -2178,6 +2212,11 @@
2178
2212
 
2179
2213
 
2180
2214
 
2215
+
2216
+
2217
+ <!-- for BSI (not PAS) display Notes before footnotes -->
2218
+
2219
+
2181
2220
  <!-- except gb -->
2182
2221
 
2183
2222
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -2203,6 +2242,10 @@
2203
2242
  <!-- fn processing -->
2204
2243
  <xsl:call-template name="fn_display"/>
2205
2244
 
2245
+
2246
+ <!-- for PAS display Notes after footnotes -->
2247
+
2248
+
2206
2249
  </fo:table-cell>
2207
2250
  </fo:table-row>
2208
2251
  </fo:table-body>
@@ -2256,15 +2299,24 @@
2256
2299
 
2257
2300
 
2258
2301
 
2302
+
2303
+
2259
2304
  </xsl:if>
2260
2305
  <xsl:if test="$parent-name = 'tfoot'">
2261
2306
 
2262
2307
 
2308
+
2263
2309
  </xsl:if>
2264
2310
 
2265
2311
 
2266
2312
 
2267
2313
 
2314
+
2315
+
2316
+
2317
+
2318
+
2319
+
2268
2320
  <!-- <xsl:if test="$namespace = 'bipm'">
2269
2321
  <xsl:attribute name="height">8mm</xsl:attribute>
2270
2322
  </xsl:if> -->
@@ -2363,6 +2415,7 @@
2363
2415
 
2364
2416
 
2365
2417
 
2418
+
2366
2419
  <xsl:if test="ancestor::*[local-name()='sections']">
2367
2420
  <xsl:attribute name="border">solid black 0pt</xsl:attribute>
2368
2421
  <xsl:attribute name="padding-top">1mm</xsl:attribute>
@@ -2372,6 +2425,9 @@
2372
2425
 
2373
2426
 
2374
2427
 
2428
+
2429
+
2430
+
2375
2431
  <xsl:if test=".//*[local-name() = 'table']">
2376
2432
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2377
2433
  </xsl:if>
@@ -2401,8 +2457,14 @@
2401
2457
 
2402
2458
 
2403
2459
 
2460
+
2461
+
2462
+ <!-- Table's note name (NOTE, for example) -->
2463
+
2404
2464
  <fo:inline padding-right="2mm">
2405
2465
 
2466
+
2467
+
2406
2468
 
2407
2469
 
2408
2470
  <xsl:if test="@type = 'source' or @type = 'abbreviation'">
@@ -2420,6 +2482,8 @@
2420
2482
 
2421
2483
  </fo:inline>
2422
2484
 
2485
+
2486
+
2423
2487
  <xsl:apply-templates mode="process"/>
2424
2488
  </fo:block>
2425
2489
 
@@ -2439,6 +2503,8 @@
2439
2503
  <xsl:variable name="reference" select="@reference"/>
2440
2504
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
2441
2505
  <fo:block margin-bottom="12pt">
2506
+
2507
+
2442
2508
 
2443
2509
 
2444
2510
 
@@ -2454,9 +2520,11 @@
2454
2520
 
2455
2521
 
2456
2522
 
2523
+
2457
2524
  <xsl:value-of select="@reference"/>
2458
2525
 
2459
2526
 
2527
+
2460
2528
  </fo:inline>
2461
2529
  <fo:inline>
2462
2530
 
@@ -2597,11 +2665,16 @@
2597
2665
 
2598
2666
 
2599
2667
 
2668
+
2669
+
2670
+
2671
+
2600
2672
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2601
2673
 
2602
2674
 
2603
2675
  <xsl:value-of select="@reference"/>
2604
2676
 
2677
+
2605
2678
  </fo:basic-link>
2606
2679
  </fo:inline>
2607
2680
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -2899,6 +2972,7 @@
2899
2972
 
2900
2973
  <fo:table-row>
2901
2974
 
2975
+
2902
2976
  <fo:table-cell>
2903
2977
 
2904
2978
  <fo:block margin-top="6pt">
@@ -2914,6 +2988,7 @@
2914
2988
 
2915
2989
 
2916
2990
 
2991
+
2917
2992
  <xsl:apply-templates/>
2918
2993
  <!-- <xsl:if test="$namespace = 'gb'">
2919
2994
  <xsl:if test="ancestor::*[local-name()='formula']">
@@ -3461,7 +3536,15 @@
3461
3536
  <xsl:copy>
3462
3537
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
3463
3538
  </xsl:copy>
3464
- <mathml:mspace width="0.5ex"/>
3539
+ <xsl:choose>
3540
+ <!-- if in msub, then don't add space -->
3541
+ <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3542
+ <!-- if next char in digit, don't add space -->
3543
+ <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3544
+ <xsl:otherwise>
3545
+ <mathml:mspace width="0.5ex"/>
3546
+ </xsl:otherwise>
3547
+ </xsl:choose>
3465
3548
  </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">
3466
3549
  <xsl:variable name="target">
3467
3550
  <xsl:choose>
@@ -3485,6 +3568,8 @@
3485
3568
  </xsl:variable>
3486
3569
  <fo:inline xsl:use-attribute-sets="link-style">
3487
3570
 
3571
+
3572
+
3488
3573
  <xsl:choose>
3489
3574
  <xsl:when test="$target_text = ''">
3490
3575
  <xsl:apply-templates/>
@@ -3597,6 +3682,7 @@
3597
3682
 
3598
3683
 
3599
3684
 
3685
+
3600
3686
  <fo:block-container margin-left="0mm">
3601
3687
 
3602
3688
 
@@ -3649,6 +3735,7 @@
3649
3735
  </xsl:choose>
3650
3736
  </xsl:template><xsl:template match="*[local-name() = 'termnote']">
3651
3737
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
3738
+
3652
3739
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
3653
3740
 
3654
3741
  <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
@@ -3726,6 +3813,7 @@
3726
3813
  </xsl:call-template>
3727
3814
 
3728
3815
  <fo:block>
3816
+
3729
3817
  <xsl:apply-templates/>
3730
3818
  </fo:block>
3731
3819
  <xsl:call-template name="fn_display_figure"/>
@@ -3785,7 +3873,24 @@
3785
3873
  </fo:instream-foreign-object>
3786
3874
  </xsl:when>
3787
3875
  <xsl:otherwise>
3788
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
3876
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
3877
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
3878
+
3879
+ <xsl:variable name="img_src">
3880
+ <xsl:choose>
3881
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
3882
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
3883
+ </xsl:choose>
3884
+ </xsl:variable>
3885
+
3886
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
3887
+ <xsl:if test="number($scale) &lt; 100">
3888
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
3889
+ </xsl:if>
3890
+
3891
+ </xsl:if>
3892
+
3893
+ </fo:external-graphic>
3789
3894
  </xsl:otherwise>
3790
3895
  </xsl:choose>
3791
3896
 
@@ -3853,6 +3958,253 @@
3853
3958
  <xsl:param name="height"/>
3854
3959
  <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; "/>
3855
3960
  <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; "/>
3961
+ </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">
3962
+ <xsl:param name="name"/>
3963
+
3964
+ <xsl:variable name="svg_content">
3965
+ <xsl:apply-templates select="." mode="svg_update"/>
3966
+ </xsl:variable>
3967
+
3968
+ <xsl:variable name="alt-text">
3969
+ <xsl:choose>
3970
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3971
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3972
+ </xsl:when>
3973
+ <xsl:when test="normalize-space($name) != ''">
3974
+ <xsl:value-of select="$name"/>
3975
+ </xsl:when>
3976
+ <xsl:otherwise>Figure</xsl:otherwise>
3977
+ </xsl:choose>
3978
+ </xsl:variable>
3979
+
3980
+ <xsl:choose>
3981
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3982
+ <fo:block>
3983
+ <xsl:variable name="width" select="@width"/>
3984
+ <xsl:variable name="height" select="@height"/>
3985
+
3986
+ <xsl:variable name="scale_x">
3987
+ <xsl:choose>
3988
+ <xsl:when test="$width &gt; $width_effective_px">
3989
+ <xsl:value-of select="$width_effective_px div $width"/>
3990
+ </xsl:when>
3991
+ <xsl:otherwise>1</xsl:otherwise>
3992
+ </xsl:choose>
3993
+ </xsl:variable>
3994
+
3995
+ <xsl:variable name="scale_y">
3996
+ <xsl:choose>
3997
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
3998
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
3999
+ </xsl:when>
4000
+ <xsl:otherwise>1</xsl:otherwise>
4001
+ </xsl:choose>
4002
+ </xsl:variable>
4003
+
4004
+ <xsl:variable name="scale">
4005
+ <xsl:choose>
4006
+ <xsl:when test="$scale_y != 1">
4007
+ <xsl:value-of select="$scale_x * $scale_y"/>
4008
+ </xsl:when>
4009
+ <xsl:otherwise>
4010
+ <xsl:value-of select="$scale_x"/>
4011
+ </xsl:otherwise>
4012
+ </xsl:choose>
4013
+ </xsl:variable>
4014
+
4015
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
4016
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
4017
+
4018
+ <fo:table table-layout="fixed" width="100%">
4019
+ <fo:table-column column-width="proportional-column-width(1)"/>
4020
+ <fo:table-column column-width="{$width_scale}px"/>
4021
+ <fo:table-column column-width="proportional-column-width(1)"/>
4022
+ <fo:table-body>
4023
+ <fo:table-row>
4024
+ <fo:table-cell column-number="2">
4025
+ <fo:block>
4026
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
4027
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
4028
+ <fo:block line-height="0" font-size="0">
4029
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
4030
+ <xsl:call-template name="bookmark"/>
4031
+ </xsl:for-each>
4032
+ </fo:block>
4033
+ </xsl:if>
4034
+ <fo:block text-depth="0" line-height="0" font-size="0">
4035
+
4036
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4037
+ <xsl:attribute name="width">100%</xsl:attribute>
4038
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4039
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4040
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4041
+
4042
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
4043
+ </fo:instream-foreign-object>
4044
+ </fo:block>
4045
+
4046
+ <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">
4047
+ <xsl:with-param name="scale" select="$scale"/>
4048
+ </xsl:apply-templates>
4049
+ </fo:block-container>
4050
+ </fo:block>
4051
+ </fo:table-cell>
4052
+ </fo:table-row>
4053
+ </fo:table-body>
4054
+ </fo:table>
4055
+ </fo:block>
4056
+
4057
+ </xsl:when>
4058
+ <xsl:otherwise>
4059
+ <fo:block xsl:use-attribute-sets="image-style">
4060
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4061
+ <xsl:attribute name="width">100%</xsl:attribute>
4062
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4063
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4064
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
4065
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
4066
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4067
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4068
+ <!-- effective height / width = 1.48, 1.4 - with title -->
4069
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
4070
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
4071
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4072
+ </xsl:if>
4073
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4074
+ <xsl:copy-of select="$svg_content"/>
4075
+ </fo:instream-foreign-object>
4076
+ </fo:block>
4077
+ </xsl:otherwise>
4078
+ </xsl:choose>
4079
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
4080
+ <xsl:copy>
4081
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
4082
+ </xsl:copy>
4083
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
4084
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4085
+ <xsl:value-of select="."/>
4086
+ </xsl:attribute>
4087
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4088
+ <xsl:copy>
4089
+ <xsl:apply-templates select="@*" mode="svg_update"/>
4090
+ <xsl:variable name="viewbox">
4091
+ <xsl:call-template name="split">
4092
+ <xsl:with-param name="pText" select="@viewBox"/>
4093
+ <xsl:with-param name="sep" select="' '"/>
4094
+ </xsl:call-template>
4095
+ </xsl:variable>
4096
+ <xsl:attribute name="width">
4097
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4098
+ </xsl:attribute>
4099
+ <xsl:attribute name="height">
4100
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4101
+ </xsl:attribute>
4102
+ <xsl:apply-templates mode="svg_update"/>
4103
+ </xsl:copy>
4104
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4105
+ <xsl:variable name="svg_content" select="document(@src)"/>
4106
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
4107
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
4108
+ <xsl:call-template name="image_svg">
4109
+ <xsl:with-param name="name" select="$name"/>
4110
+ </xsl:call-template>
4111
+ </xsl:for-each>
4112
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
4113
+ <xsl:copy>
4114
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
4115
+ </xsl:copy>
4116
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
4117
+ <xsl:apply-templates mode="svg_remove_a"/>
4118
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
4119
+ <xsl:param name="scale"/>
4120
+ <xsl:variable name="dest">
4121
+ <xsl:choose>
4122
+ <xsl:when test="starts-with(@href, '#')">
4123
+ <xsl:value-of select="substring-after(@href, '#')"/>
4124
+ </xsl:when>
4125
+ <xsl:otherwise>
4126
+ <xsl:value-of select="@href"/>
4127
+ </xsl:otherwise>
4128
+ </xsl:choose>
4129
+ </xsl:variable>
4130
+ <xsl:for-each select="./*[local-name() = 'rect']">
4131
+ <xsl:call-template name="insertSVGMapLink">
4132
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
4133
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
4134
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
4135
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
4136
+ <xsl:with-param name="dest" select="$dest"/>
4137
+ </xsl:call-template>
4138
+ </xsl:for-each>
4139
+
4140
+ <xsl:for-each select="./*[local-name() = 'polygon']">
4141
+ <xsl:variable name="points">
4142
+ <xsl:call-template name="split">
4143
+ <xsl:with-param name="pText" select="@points"/>
4144
+ </xsl:call-template>
4145
+ </xsl:variable>
4146
+ <xsl:variable name="x_coords">
4147
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
4148
+ <xsl:sort select="." data-type="number"/>
4149
+ <x><xsl:value-of select="."/></x>
4150
+ </xsl:for-each>
4151
+ </xsl:variable>
4152
+ <xsl:variable name="y_coords">
4153
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
4154
+ <xsl:sort select="." data-type="number"/>
4155
+ <y><xsl:value-of select="."/></y>
4156
+ </xsl:for-each>
4157
+ </xsl:variable>
4158
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
4159
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
4160
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
4161
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
4162
+ <xsl:call-template name="insertSVGMapLink">
4163
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
4164
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
4165
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
4166
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
4167
+ <xsl:with-param name="dest" select="$dest"/>
4168
+ </xsl:call-template>
4169
+ </xsl:for-each>
4170
+
4171
+ <xsl:for-each select="./*[local-name() = 'circle']">
4172
+ <xsl:call-template name="insertSVGMapLink">
4173
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
4174
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
4175
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
4176
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
4177
+ <xsl:with-param name="dest" select="$dest"/>
4178
+ </xsl:call-template>
4179
+ </xsl:for-each>
4180
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
4181
+ <xsl:call-template name="insertSVGMapLink">
4182
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
4183
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
4184
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
4185
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
4186
+ <xsl:with-param name="dest" select="$dest"/>
4187
+ </xsl:call-template>
4188
+ </xsl:for-each>
4189
+ </xsl:template><xsl:template name="insertSVGMapLink">
4190
+ <xsl:param name="left"/>
4191
+ <xsl:param name="top"/>
4192
+ <xsl:param name="width"/>
4193
+ <xsl:param name="height"/>
4194
+ <xsl:param name="dest"/>
4195
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
4196
+ <fo:block font-size="1pt">
4197
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
4198
+ <fo:inline-container inline-progression-dimension="100%">
4199
+ <fo:block-container height="{$height - 1}px" width="100%">
4200
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
4201
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
4202
+ </xsl:if> -->
4203
+ <fo:block> </fo:block></fo:block-container>
4204
+ </fo:inline-container>
4205
+ </fo:basic-link>
4206
+ </fo:block>
4207
+ </fo:block-container>
3856
4208
  </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">
3857
4209
  <xsl:apply-templates mode="contents"/>
3858
4210
  <xsl:text> </xsl:text>
@@ -3881,28 +4233,39 @@
3881
4233
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3882
4234
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3883
4235
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4236
+ <xsl:if test="@bundle = 'true'">
4237
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
4238
+ </xsl:if>
3884
4239
  <fo:bookmark-title>
3885
- <xsl:variable name="bookmark-title_">
3886
- <xsl:call-template name="getLangVersion">
3887
- <xsl:with-param name="lang" select="@lang"/>
3888
- <xsl:with-param name="doctype" select="@doctype"/>
3889
- <xsl:with-param name="title" select="@title-part"/>
3890
- </xsl:call-template>
3891
- </xsl:variable>
3892
4240
  <xsl:choose>
3893
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3894
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3895
- </xsl:when>
3896
- <xsl:otherwise>
4241
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
4242
+ <xsl:variable name="bookmark-title_">
4243
+ <xsl:call-template name="getLangVersion">
4244
+ <xsl:with-param name="lang" select="@lang"/>
4245
+ <xsl:with-param name="doctype" select="@doctype"/>
4246
+ <xsl:with-param name="title" select="@title-part"/>
4247
+ </xsl:call-template>
4248
+ </xsl:variable>
3897
4249
  <xsl:choose>
3898
- <xsl:when test="@lang = 'en'">English</xsl:when>
3899
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3900
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3901
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4250
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
4251
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
4252
+ </xsl:when>
4253
+ <xsl:otherwise>
4254
+ <xsl:choose>
4255
+ <xsl:when test="@lang = 'en'">English</xsl:when>
4256
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
4257
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4258
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4259
+ </xsl:choose>
4260
+ </xsl:otherwise>
3902
4261
  </xsl:choose>
4262
+ </xsl:when>
4263
+ <xsl:otherwise>
4264
+ <xsl:value-of select="@title-part"/>
3903
4265
  </xsl:otherwise>
3904
4266
  </xsl:choose>
3905
4267
  </fo:bookmark-title>
4268
+
3906
4269
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3907
4270
 
3908
4271
  <xsl:call-template name="insertFigureBookmarks">
@@ -4001,20 +4364,28 @@
4001
4364
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
4002
4365
  </xsl:choose>
4003
4366
  </xsl:template><xsl:template match="item" mode="bookmark">
4004
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
4005
- <fo:bookmark-title>
4006
- <xsl:if test="@section != ''">
4007
- <xsl:value-of select="@section"/>
4008
- <xsl:text> </xsl:text>
4009
- </xsl:if>
4010
- <xsl:value-of select="normalize-space(title)"/>
4011
- </fo:bookmark-title>
4012
- <xsl:apply-templates mode="bookmark"/>
4013
- </fo:bookmark>
4367
+ <xsl:choose>
4368
+ <xsl:when test="@id != ''">
4369
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4370
+ <fo:bookmark-title>
4371
+ <xsl:if test="@section != ''">
4372
+ <xsl:value-of select="@section"/>
4373
+ <xsl:text> </xsl:text>
4374
+ </xsl:if>
4375
+ <xsl:value-of select="normalize-space(title)"/>
4376
+ </fo:bookmark-title>
4377
+ <xsl:apply-templates mode="bookmark"/>
4378
+ </fo:bookmark>
4379
+ </xsl:when>
4380
+ <xsl:otherwise>
4381
+ <xsl:apply-templates mode="bookmark"/>
4382
+ </xsl:otherwise>
4383
+ </xsl:choose>
4014
4384
  </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">
4015
4385
  <xsl:if test="normalize-space() != ''">
4016
4386
  <fo:block xsl:use-attribute-sets="figure-name-style">
4017
4387
 
4388
+
4018
4389
  <xsl:apply-templates/>
4019
4390
  </fo:block>
4020
4391
  </xsl:if>
@@ -4095,6 +4466,7 @@
4095
4466
 
4096
4467
  <fo:block-container margin-left="0mm">
4097
4468
  <xsl:copy-of select="@id"/>
4469
+
4098
4470
  <xsl:if test="parent::*[local-name() = 'note']">
4099
4471
  <xsl:attribute name="margin-left">
4100
4472
  <xsl:choose>
@@ -4105,7 +4477,9 @@
4105
4477
 
4106
4478
  </xsl:if>
4107
4479
  <fo:block-container margin-left="0mm">
4108
-
4480
+
4481
+
4482
+
4109
4483
  <fo:block xsl:use-attribute-sets="sourcecode-style">
4110
4484
  <xsl:variable name="_font-size">
4111
4485
 
@@ -4134,10 +4508,14 @@
4134
4508
  </xsl:choose>
4135
4509
  </xsl:attribute>
4136
4510
  </xsl:if>
4137
- <xsl:apply-templates/>
4138
- </fo:block>
4511
+
4512
+ <xsl:apply-templates/>
4513
+ </fo:block>
4514
+
4515
+
4139
4516
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
4140
4517
 
4518
+
4141
4519
  </fo:block-container>
4142
4520
  </fo:block-container>
4143
4521
  </xsl:template><xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -4551,7 +4929,9 @@
4551
4929
 
4552
4930
 
4553
4931
  </xsl:if>
4554
-
4932
+
4933
+
4934
+
4555
4935
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4556
4936
  <xsl:if test="normalize-space(@citeas) = ''">
4557
4937
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -4560,6 +4940,7 @@
4560
4940
 
4561
4941
 
4562
4942
 
4943
+
4563
4944
  </xsl:if>
4564
4945
 
4565
4946
  <xsl:apply-templates/>
@@ -4707,6 +5088,7 @@
4707
5088
  <xsl:call-template name="setId"/>
4708
5089
 
4709
5090
 
5091
+
4710
5092
  <xsl:apply-templates/>
4711
5093
  </fo:block>
4712
5094
  </xsl:template><xsl:template match="*[local-name() = 'definitions']">
@@ -4958,17 +5340,17 @@
4958
5340
  <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')]"/>
4959
5341
  <xsl:choose>
4960
5342
  <xsl:when test="normalize-space($_doc_ident) != ''">
4961
- <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"/>
5343
+ <!-- <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"/>
4962
5344
  <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
4963
5345
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4964
- </xsl:if>
5346
+ </xsl:if> -->
4965
5347
  <xsl:value-of select="$_doc_ident"/>
4966
5348
  </xsl:when>
4967
5349
  <xsl:otherwise>
4968
- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
5350
+ <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
4969
5351
  <xsl:if test="$type != ''">
4970
5352
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
4971
- </xsl:if>
5353
+ </xsl:if> -->
4972
5354
  <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]"/>
4973
5355
  </xsl:otherwise>
4974
5356
  </xsl:choose>
@@ -5409,20 +5791,40 @@
5409
5791
  </xsl:call-template>
5410
5792
  </xsl:if>
5411
5793
  </xsl:template><xsl:template name="getLocalizedString">
5412
- <xsl:param name="key"/>
5794
+ <xsl:param name="key"/>
5795
+ <xsl:param name="formatted">false</xsl:param>
5413
5796
 
5414
5797
  <xsl:variable name="curr_lang">
5415
5798
  <xsl:call-template name="getLang"/>
5416
5799
  </xsl:variable>
5417
5800
 
5418
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5801
+ <xsl:variable name="data_value">
5802
+ <xsl:choose>
5803
+ <xsl:when test="$formatted = 'true'">
5804
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5805
+ </xsl:when>
5806
+ <xsl:otherwise>
5807
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5808
+ </xsl:otherwise>
5809
+ </xsl:choose>
5810
+ </xsl:variable>
5419
5811
 
5420
5812
  <xsl:choose>
5421
- <xsl:when test="$data_value != ''">
5422
- <xsl:value-of select="$data_value"/>
5813
+ <xsl:when test="normalize-space($data_value) != ''">
5814
+ <xsl:choose>
5815
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
5816
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
5817
+ </xsl:choose>
5423
5818
  </xsl:when>
5424
5819
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5425
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5820
+ <xsl:choose>
5821
+ <xsl:when test="$formatted = 'true'">
5822
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5823
+ </xsl:when>
5824
+ <xsl:otherwise>
5825
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5826
+ </xsl:otherwise>
5827
+ </xsl:choose>
5426
5828
  </xsl:when>
5427
5829
  <xsl:otherwise>
5428
5830
  <xsl:variable name="key_">
@@ -5433,7 +5835,7 @@
5433
5835
  <xsl:value-of select="$key_"/>
5434
5836
  </xsl:otherwise>
5435
5837
  </xsl:choose>
5436
-
5838
+
5437
5839
  </xsl:template><xsl:template name="setTrackChangesStyles">
5438
5840
  <xsl:param name="isAdded"/>
5439
5841
  <xsl:param name="isDeleted"/>
@@ -5474,4 +5876,110 @@
5474
5876
  <xsl:value-of select="$align"/>
5475
5877
  </xsl:when>
5476
5878
  </xsl:choose>
5879
+ </xsl:template><xsl:template name="setTextAlignment">
5880
+ <xsl:param name="default">left</xsl:param>
5881
+ <xsl:attribute name="text-align">
5882
+ <xsl:choose>
5883
+ <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
5884
+ <xsl:when test="ancestor::*[local-name() = 'td']/@align"><xsl:value-of select="ancestor::*[local-name() = 'td']/@align"/></xsl:when>
5885
+ <xsl:when test="ancestor::*[local-name() = 'th']/@align"><xsl:value-of select="ancestor::*[local-name() = 'th']/@align"/></xsl:when>
5886
+ <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
5887
+ </xsl:choose>
5888
+ </xsl:attribute>
5889
+ </xsl:template><xsl:template name="number-to-words">
5890
+ <xsl:param name="number"/>
5891
+ <xsl:param name="first"/>
5892
+ <xsl:if test="$number != ''">
5893
+ <xsl:variable name="words">
5894
+ <words>
5895
+ <word cardinal="1">One-</word>
5896
+ <word ordinal="1">First </word>
5897
+ <word cardinal="2">Two-</word>
5898
+ <word ordinal="2">Second </word>
5899
+ <word cardinal="3">Three-</word>
5900
+ <word ordinal="3">Third </word>
5901
+ <word cardinal="4">Four-</word>
5902
+ <word ordinal="4">Fourth </word>
5903
+ <word cardinal="5">Five-</word>
5904
+ <word ordinal="5">Fifth </word>
5905
+ <word cardinal="6">Six-</word>
5906
+ <word ordinal="6">Sixth </word>
5907
+ <word cardinal="7">Seven-</word>
5908
+ <word ordinal="7">Seventh </word>
5909
+ <word cardinal="8">Eight-</word>
5910
+ <word ordinal="8">Eighth </word>
5911
+ <word cardinal="9">Nine-</word>
5912
+ <word ordinal="9">Ninth </word>
5913
+ <word ordinal="10">Tenth </word>
5914
+ <word ordinal="11">Eleventh </word>
5915
+ <word ordinal="12">Twelfth </word>
5916
+ <word ordinal="13">Thirteenth </word>
5917
+ <word ordinal="14">Fourteenth </word>
5918
+ <word ordinal="15">Fifteenth </word>
5919
+ <word ordinal="16">Sixteenth </word>
5920
+ <word ordinal="17">Seventeenth </word>
5921
+ <word ordinal="18">Eighteenth </word>
5922
+ <word ordinal="19">Nineteenth </word>
5923
+ <word cardinal="20">Twenty-</word>
5924
+ <word ordinal="20">Twentieth </word>
5925
+ <word cardinal="30">Thirty-</word>
5926
+ <word ordinal="30">Thirtieth </word>
5927
+ <word cardinal="40">Forty-</word>
5928
+ <word ordinal="40">Fortieth </word>
5929
+ <word cardinal="50">Fifty-</word>
5930
+ <word ordinal="50">Fiftieth </word>
5931
+ <word cardinal="60">Sixty-</word>
5932
+ <word ordinal="60">Sixtieth </word>
5933
+ <word cardinal="70">Seventy-</word>
5934
+ <word ordinal="70">Seventieth </word>
5935
+ <word cardinal="80">Eighty-</word>
5936
+ <word ordinal="80">Eightieth </word>
5937
+ <word cardinal="90">Ninety-</word>
5938
+ <word ordinal="90">Ninetieth </word>
5939
+ <word cardinal="100">Hundred-</word>
5940
+ <word ordinal="100">Hundredth </word>
5941
+ </words>
5942
+ </xsl:variable>
5943
+
5944
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
5945
+
5946
+ <xsl:variable name="value">
5947
+ <xsl:choose>
5948
+ <xsl:when test="$ordinal != ''">
5949
+ <xsl:value-of select="$ordinal"/>
5950
+ </xsl:when>
5951
+ <xsl:otherwise>
5952
+ <xsl:choose>
5953
+ <xsl:when test="$number &lt; 100">
5954
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
5955
+ <xsl:variable name="digit" select="substring($number,2)"/>
5956
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
5957
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
5958
+ </xsl:when>
5959
+ <xsl:otherwise>
5960
+ <!-- more 100 -->
5961
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
5962
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
5963
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
5964
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
5965
+ <xsl:call-template name="number-to-words">
5966
+ <xsl:with-param name="number" select="$digits"/>
5967
+ </xsl:call-template>
5968
+ </xsl:otherwise>
5969
+ </xsl:choose>
5970
+ </xsl:otherwise>
5971
+ </xsl:choose>
5972
+ </xsl:variable>
5973
+ <xsl:choose>
5974
+ <xsl:when test="$first = 'true'">
5975
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
5976
+ <xsl:call-template name="capitalize">
5977
+ <xsl:with-param name="str" select="$value_lc"/>
5978
+ </xsl:call-template>
5979
+ </xsl:when>
5980
+ <xsl:otherwise>
5981
+ <xsl:value-of select="$value"/>
5982
+ </xsl:otherwise>
5983
+ </xsl:choose>
5984
+ </xsl:if>
5477
5985
  </xsl:template></xsl:stylesheet>