metanorma-un 0.6.5 → 0.6.9

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>
@@ -1228,7 +1232,7 @@
1228
1232
 
1229
1233
 
1230
1234
 
1231
- <xsl:attribute name="font-family">Courier</xsl:attribute>
1235
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
1232
1236
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
1233
1237
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
1234
1238
 
@@ -1317,6 +1321,7 @@
1317
1321
 
1318
1322
 
1319
1323
 
1324
+
1320
1325
  <xsl:attribute name="font-size">11pt</xsl:attribute>
1321
1326
  <xsl:attribute name="margin-top">12pt</xsl:attribute>
1322
1327
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
@@ -1331,7 +1336,9 @@
1331
1336
 
1332
1337
 
1333
1338
 
1334
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1339
+ </xsl:attribute-set><xsl:variable name="table-border_">
1340
+
1341
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1335
1342
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1336
1343
 
1337
1344
 
@@ -1376,6 +1383,7 @@
1376
1383
 
1377
1384
 
1378
1385
 
1386
+
1379
1387
  </xsl:attribute-set><xsl:attribute-set name="note-style">
1380
1388
 
1381
1389
 
@@ -1580,14 +1588,15 @@
1580
1588
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1581
1589
 
1582
1590
  <!-- Normative references -->
1583
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1591
+ <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"/>
1584
1592
  <!-- Terms and definitions -->
1585
1593
  <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"/>
1586
1594
  <!-- Another main sections -->
1587
1595
  <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"/>
1588
1596
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1589
1597
  <!-- Bibliography -->
1590
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1598
+ <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"/>
1599
+
1591
1600
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1592
1601
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1593
1602
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -1630,6 +1639,8 @@
1630
1639
  <fo:block>&#xA0;</fo:block>
1631
1640
  </xsl:if> -->
1632
1641
 
1642
+
1643
+ <!-- Display table's name before table as standalone block -->
1633
1644
  <!-- $namespace = 'iso' or -->
1634
1645
 
1635
1646
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -1710,6 +1721,12 @@
1710
1721
 
1711
1722
 
1712
1723
 
1724
+
1725
+
1726
+
1727
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
1728
+
1729
+
1713
1730
  <xsl:variable name="table_width">
1714
1731
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
1715
1732
 
@@ -1733,6 +1750,7 @@
1733
1750
 
1734
1751
 
1735
1752
 
1753
+
1736
1754
 
1737
1755
 
1738
1756
  <xsl:if test="ancestor::*[local-name()='sections']">
@@ -1761,6 +1779,8 @@
1761
1779
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
1762
1780
  </xsl:if>
1763
1781
 
1782
+
1783
+
1764
1784
  <xsl:choose>
1765
1785
  <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
1766
1786
  <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
@@ -2045,9 +2065,9 @@
2045
2065
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation">
2046
2066
  <xsl:with-param name="continued">true</xsl:with-param>
2047
2067
  </xsl:apply-templates>
2048
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
2049
- <xsl:call-template name="fn_name_display"/>
2050
- </xsl:for-each>
2068
+
2069
+
2070
+
2051
2071
 
2052
2072
  </fo:table-cell>
2053
2073
  </fo:table-row>
@@ -2129,7 +2149,11 @@
2129
2149
 
2130
2150
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
2131
2151
 
2132
- <xsl:if test="$isNoteOrFnExist = 'true'">
2152
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
2153
+
2154
+ </xsl:variable>
2155
+
2156
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
2133
2157
 
2134
2158
  <xsl:variable name="cols-count">
2135
2159
  <xsl:choose>
@@ -2158,6 +2182,8 @@
2158
2182
  </xsl:choose>
2159
2183
  </xsl:for-each>
2160
2184
 
2185
+
2186
+
2161
2187
  <xsl:choose>
2162
2188
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2163
2189
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -2184,6 +2210,7 @@
2184
2210
 
2185
2211
 
2186
2212
 
2213
+
2187
2214
  <!-- fn will be processed inside 'note' processing -->
2188
2215
 
2189
2216
 
@@ -2192,6 +2219,11 @@
2192
2219
 
2193
2220
 
2194
2221
 
2222
+
2223
+
2224
+ <!-- for BSI (not PAS) display Notes before footnotes -->
2225
+
2226
+
2195
2227
  <!-- except gb -->
2196
2228
 
2197
2229
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -2217,6 +2249,10 @@
2217
2249
  <!-- fn processing -->
2218
2250
  <xsl:call-template name="fn_display"/>
2219
2251
 
2252
+
2253
+ <!-- for PAS display Notes after footnotes -->
2254
+
2255
+
2220
2256
  </fo:table-cell>
2221
2257
  </fo:table-row>
2222
2258
  </fo:table-body>
@@ -2258,6 +2294,19 @@
2258
2294
 
2259
2295
  </fo:table-body>
2260
2296
 
2297
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/text()[1]" priority="2" mode="presentation_name">
2298
+ <xsl:choose>
2299
+ <xsl:when test="substring-after(., '—') != ''">
2300
+ <xsl:text>—</xsl:text><xsl:value-of select="substring-after(., '—')"/>
2301
+ </xsl:when>
2302
+ <xsl:otherwise>
2303
+ <xsl:value-of select="."/>
2304
+ </xsl:otherwise>
2305
+ </xsl:choose>
2306
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']" mode="presentation_name">
2307
+ <xsl:apply-templates mode="presentation_name"/>
2308
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/node()" mode="presentation_name">
2309
+ <xsl:apply-templates select="."/>
2261
2310
  </xsl:template><xsl:template match="*[local-name()='tr']">
2262
2311
  <xsl:variable name="parent-name" select="local-name(..)"/>
2263
2312
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
@@ -2270,10 +2319,13 @@
2270
2319
 
2271
2320
 
2272
2321
 
2322
+
2323
+
2273
2324
  </xsl:if>
2274
2325
  <xsl:if test="$parent-name = 'tfoot'">
2275
2326
 
2276
2327
 
2328
+
2277
2329
  </xsl:if>
2278
2330
 
2279
2331
 
@@ -2283,6 +2335,8 @@
2283
2335
 
2284
2336
 
2285
2337
 
2338
+
2339
+
2286
2340
  <!-- <xsl:if test="$namespace = 'bipm'">
2287
2341
  <xsl:attribute name="height">8mm</xsl:attribute>
2288
2342
  </xsl:if> -->
@@ -2381,6 +2435,7 @@
2381
2435
 
2382
2436
 
2383
2437
 
2438
+
2384
2439
  <xsl:if test="ancestor::*[local-name()='sections']">
2385
2440
  <xsl:attribute name="border">solid black 0pt</xsl:attribute>
2386
2441
  <xsl:attribute name="padding-top">1mm</xsl:attribute>
@@ -2422,8 +2477,14 @@
2422
2477
 
2423
2478
 
2424
2479
 
2480
+
2481
+
2482
+ <!-- Table's note name (NOTE, for example) -->
2483
+
2425
2484
  <fo:inline padding-right="2mm">
2426
2485
 
2486
+
2487
+
2427
2488
 
2428
2489
 
2429
2490
  <xsl:if test="@type = 'source' or @type = 'abbreviation'">
@@ -2441,6 +2502,8 @@
2441
2502
 
2442
2503
  </fo:inline>
2443
2504
 
2505
+
2506
+
2444
2507
  <xsl:apply-templates mode="process"/>
2445
2508
  </fo:block>
2446
2509
 
@@ -2448,18 +2511,18 @@
2448
2511
  <xsl:apply-templates/>
2449
2512
  </xsl:template><xsl:template name="fn_display">
2450
2513
  <xsl:variable name="references">
2514
+
2451
2515
  <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
2452
- <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
2453
-
2454
-
2455
- <xsl:apply-templates/>
2456
- </fn>
2516
+ <xsl:call-template name="create_fn"/>
2457
2517
  </xsl:for-each>
2458
2518
  </xsl:variable>
2519
+
2459
2520
  <xsl:for-each select="xalan:nodeset($references)//fn">
2460
2521
  <xsl:variable name="reference" select="@reference"/>
2461
2522
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
2462
2523
  <fo:block margin-bottom="12pt">
2524
+
2525
+
2463
2526
 
2464
2527
 
2465
2528
 
@@ -2475,9 +2538,11 @@
2475
2538
 
2476
2539
 
2477
2540
 
2541
+
2478
2542
  <xsl:value-of select="@reference"/>
2479
2543
 
2480
2544
 
2545
+
2481
2546
  </fo:inline>
2482
2547
  <fo:inline>
2483
2548
 
@@ -2487,6 +2552,12 @@
2487
2552
  </fo:block>
2488
2553
  </xsl:if>
2489
2554
  </xsl:for-each>
2555
+ </xsl:template><xsl:template name="create_fn">
2556
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
2557
+
2558
+
2559
+ <xsl:apply-templates/>
2560
+ </fn>
2490
2561
  </xsl:template><xsl:template name="fn_name_display">
2491
2562
  <!-- <xsl:variable name="references">
2492
2563
  <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
@@ -2619,11 +2690,15 @@
2619
2690
 
2620
2691
 
2621
2692
 
2693
+
2694
+
2695
+
2622
2696
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2623
2697
 
2624
2698
 
2625
2699
  <xsl:value-of select="@reference"/>
2626
2700
 
2701
+
2627
2702
  </fo:basic-link>
2628
2703
  </fo:inline>
2629
2704
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -3481,19 +3556,6 @@
3481
3556
  <!-- replace start and end spaces to non-break space -->
3482
3557
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
3483
3558
  </xsl:copy>
3484
- </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml">
3485
- <xsl:copy>
3486
- <xsl:apply-templates select="@*|node()" mode="mathml"/>
3487
- </xsl:copy>
3488
- <xsl:choose>
3489
- <!-- if in msub, then don't add space -->
3490
- <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3491
- <!-- if next char in digit, don't add space -->
3492
- <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3493
- <xsl:otherwise>
3494
- <mathml:mspace width="0.5ex"/>
3495
- </xsl:otherwise>
3496
- </xsl:choose>
3497
3559
  </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">
3498
3560
  <xsl:variable name="target">
3499
3561
  <xsl:choose>
@@ -3518,6 +3580,7 @@
3518
3580
  <fo:inline xsl:use-attribute-sets="link-style">
3519
3581
 
3520
3582
 
3583
+
3521
3584
  <xsl:choose>
3522
3585
  <xsl:when test="$target_text = ''">
3523
3586
  <xsl:apply-templates/>
@@ -3630,6 +3693,7 @@
3630
3693
 
3631
3694
 
3632
3695
 
3696
+
3633
3697
  <fo:block-container margin-left="0mm">
3634
3698
 
3635
3699
 
@@ -3820,7 +3884,24 @@
3820
3884
  </fo:instream-foreign-object>
3821
3885
  </xsl:when>
3822
3886
  <xsl:otherwise>
3823
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
3887
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
3888
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
3889
+
3890
+ <xsl:variable name="img_src">
3891
+ <xsl:choose>
3892
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
3893
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
3894
+ </xsl:choose>
3895
+ </xsl:variable>
3896
+
3897
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
3898
+ <xsl:if test="number($scale) &lt; 100">
3899
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
3900
+ </xsl:if>
3901
+
3902
+ </xsl:if>
3903
+
3904
+ </fo:external-graphic>
3824
3905
  </xsl:otherwise>
3825
3906
  </xsl:choose>
3826
3907
 
@@ -3888,6 +3969,253 @@
3888
3969
  <xsl:param name="height"/>
3889
3970
  <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; "/>
3890
3971
  <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; "/>
3972
+ </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">
3973
+ <xsl:param name="name"/>
3974
+
3975
+ <xsl:variable name="svg_content">
3976
+ <xsl:apply-templates select="." mode="svg_update"/>
3977
+ </xsl:variable>
3978
+
3979
+ <xsl:variable name="alt-text">
3980
+ <xsl:choose>
3981
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3982
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3983
+ </xsl:when>
3984
+ <xsl:when test="normalize-space($name) != ''">
3985
+ <xsl:value-of select="$name"/>
3986
+ </xsl:when>
3987
+ <xsl:otherwise>Figure</xsl:otherwise>
3988
+ </xsl:choose>
3989
+ </xsl:variable>
3990
+
3991
+ <xsl:choose>
3992
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3993
+ <fo:block>
3994
+ <xsl:variable name="width" select="@width"/>
3995
+ <xsl:variable name="height" select="@height"/>
3996
+
3997
+ <xsl:variable name="scale_x">
3998
+ <xsl:choose>
3999
+ <xsl:when test="$width &gt; $width_effective_px">
4000
+ <xsl:value-of select="$width_effective_px div $width"/>
4001
+ </xsl:when>
4002
+ <xsl:otherwise>1</xsl:otherwise>
4003
+ </xsl:choose>
4004
+ </xsl:variable>
4005
+
4006
+ <xsl:variable name="scale_y">
4007
+ <xsl:choose>
4008
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
4009
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
4010
+ </xsl:when>
4011
+ <xsl:otherwise>1</xsl:otherwise>
4012
+ </xsl:choose>
4013
+ </xsl:variable>
4014
+
4015
+ <xsl:variable name="scale">
4016
+ <xsl:choose>
4017
+ <xsl:when test="$scale_y != 1">
4018
+ <xsl:value-of select="$scale_x * $scale_y"/>
4019
+ </xsl:when>
4020
+ <xsl:otherwise>
4021
+ <xsl:value-of select="$scale_x"/>
4022
+ </xsl:otherwise>
4023
+ </xsl:choose>
4024
+ </xsl:variable>
4025
+
4026
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
4027
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
4028
+
4029
+ <fo:table table-layout="fixed" width="100%">
4030
+ <fo:table-column column-width="proportional-column-width(1)"/>
4031
+ <fo:table-column column-width="{$width_scale}px"/>
4032
+ <fo:table-column column-width="proportional-column-width(1)"/>
4033
+ <fo:table-body>
4034
+ <fo:table-row>
4035
+ <fo:table-cell column-number="2">
4036
+ <fo:block>
4037
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
4038
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
4039
+ <fo:block line-height="0" font-size="0">
4040
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
4041
+ <xsl:call-template name="bookmark"/>
4042
+ </xsl:for-each>
4043
+ </fo:block>
4044
+ </xsl:if>
4045
+ <fo:block text-depth="0" line-height="0" font-size="0">
4046
+
4047
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4048
+ <xsl:attribute name="width">100%</xsl:attribute>
4049
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4050
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4051
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4052
+
4053
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
4054
+ </fo:instream-foreign-object>
4055
+ </fo:block>
4056
+
4057
+ <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">
4058
+ <xsl:with-param name="scale" select="$scale"/>
4059
+ </xsl:apply-templates>
4060
+ </fo:block-container>
4061
+ </fo:block>
4062
+ </fo:table-cell>
4063
+ </fo:table-row>
4064
+ </fo:table-body>
4065
+ </fo:table>
4066
+ </fo:block>
4067
+
4068
+ </xsl:when>
4069
+ <xsl:otherwise>
4070
+ <fo:block xsl:use-attribute-sets="image-style">
4071
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4072
+ <xsl:attribute name="width">100%</xsl:attribute>
4073
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4074
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4075
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
4076
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
4077
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4078
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4079
+ <!-- effective height / width = 1.48, 1.4 - with title -->
4080
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
4081
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
4082
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4083
+ </xsl:if>
4084
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4085
+ <xsl:copy-of select="$svg_content"/>
4086
+ </fo:instream-foreign-object>
4087
+ </fo:block>
4088
+ </xsl:otherwise>
4089
+ </xsl:choose>
4090
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
4091
+ <xsl:copy>
4092
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
4093
+ </xsl:copy>
4094
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
4095
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4096
+ <xsl:value-of select="."/>
4097
+ </xsl:attribute>
4098
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
4099
+ <xsl:copy>
4100
+ <xsl:apply-templates select="@*" mode="svg_update"/>
4101
+ <xsl:variable name="viewbox">
4102
+ <xsl:call-template name="split">
4103
+ <xsl:with-param name="pText" select="@viewBox"/>
4104
+ <xsl:with-param name="sep" select="' '"/>
4105
+ </xsl:call-template>
4106
+ </xsl:variable>
4107
+ <xsl:attribute name="width">
4108
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
4109
+ </xsl:attribute>
4110
+ <xsl:attribute name="height">
4111
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
4112
+ </xsl:attribute>
4113
+ <xsl:apply-templates mode="svg_update"/>
4114
+ </xsl:copy>
4115
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4116
+ <xsl:variable name="svg_content" select="document(@src)"/>
4117
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
4118
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
4119
+ <xsl:call-template name="image_svg">
4120
+ <xsl:with-param name="name" select="$name"/>
4121
+ </xsl:call-template>
4122
+ </xsl:for-each>
4123
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
4124
+ <xsl:copy>
4125
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
4126
+ </xsl:copy>
4127
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
4128
+ <xsl:apply-templates mode="svg_remove_a"/>
4129
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
4130
+ <xsl:param name="scale"/>
4131
+ <xsl:variable name="dest">
4132
+ <xsl:choose>
4133
+ <xsl:when test="starts-with(@href, '#')">
4134
+ <xsl:value-of select="substring-after(@href, '#')"/>
4135
+ </xsl:when>
4136
+ <xsl:otherwise>
4137
+ <xsl:value-of select="@href"/>
4138
+ </xsl:otherwise>
4139
+ </xsl:choose>
4140
+ </xsl:variable>
4141
+ <xsl:for-each select="./*[local-name() = 'rect']">
4142
+ <xsl:call-template name="insertSVGMapLink">
4143
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
4144
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
4145
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
4146
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
4147
+ <xsl:with-param name="dest" select="$dest"/>
4148
+ </xsl:call-template>
4149
+ </xsl:for-each>
4150
+
4151
+ <xsl:for-each select="./*[local-name() = 'polygon']">
4152
+ <xsl:variable name="points">
4153
+ <xsl:call-template name="split">
4154
+ <xsl:with-param name="pText" select="@points"/>
4155
+ </xsl:call-template>
4156
+ </xsl:variable>
4157
+ <xsl:variable name="x_coords">
4158
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
4159
+ <xsl:sort select="." data-type="number"/>
4160
+ <x><xsl:value-of select="."/></x>
4161
+ </xsl:for-each>
4162
+ </xsl:variable>
4163
+ <xsl:variable name="y_coords">
4164
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
4165
+ <xsl:sort select="." data-type="number"/>
4166
+ <y><xsl:value-of select="."/></y>
4167
+ </xsl:for-each>
4168
+ </xsl:variable>
4169
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
4170
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
4171
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
4172
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
4173
+ <xsl:call-template name="insertSVGMapLink">
4174
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
4175
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
4176
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
4177
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
4178
+ <xsl:with-param name="dest" select="$dest"/>
4179
+ </xsl:call-template>
4180
+ </xsl:for-each>
4181
+
4182
+ <xsl:for-each select="./*[local-name() = 'circle']">
4183
+ <xsl:call-template name="insertSVGMapLink">
4184
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
4185
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
4186
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
4187
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
4188
+ <xsl:with-param name="dest" select="$dest"/>
4189
+ </xsl:call-template>
4190
+ </xsl:for-each>
4191
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
4192
+ <xsl:call-template name="insertSVGMapLink">
4193
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
4194
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
4195
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
4196
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
4197
+ <xsl:with-param name="dest" select="$dest"/>
4198
+ </xsl:call-template>
4199
+ </xsl:for-each>
4200
+ </xsl:template><xsl:template name="insertSVGMapLink">
4201
+ <xsl:param name="left"/>
4202
+ <xsl:param name="top"/>
4203
+ <xsl:param name="width"/>
4204
+ <xsl:param name="height"/>
4205
+ <xsl:param name="dest"/>
4206
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
4207
+ <fo:block font-size="1pt">
4208
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
4209
+ <fo:inline-container inline-progression-dimension="100%">
4210
+ <fo:block-container height="{$height - 1}px" width="100%">
4211
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
4212
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
4213
+ </xsl:if> -->
4214
+ <fo:block> </fo:block></fo:block-container>
4215
+ </fo:inline-container>
4216
+ </fo:basic-link>
4217
+ </fo:block>
4218
+ </fo:block-container>
3891
4219
  </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">
3892
4220
  <xsl:apply-templates mode="contents"/>
3893
4221
  <xsl:text> </xsl:text>
@@ -3916,28 +4244,39 @@
3916
4244
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3917
4245
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3918
4246
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4247
+ <xsl:if test="@bundle = 'true'">
4248
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
4249
+ </xsl:if>
3919
4250
  <fo:bookmark-title>
3920
- <xsl:variable name="bookmark-title_">
3921
- <xsl:call-template name="getLangVersion">
3922
- <xsl:with-param name="lang" select="@lang"/>
3923
- <xsl:with-param name="doctype" select="@doctype"/>
3924
- <xsl:with-param name="title" select="@title-part"/>
3925
- </xsl:call-template>
3926
- </xsl:variable>
3927
4251
  <xsl:choose>
3928
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3929
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3930
- </xsl:when>
3931
- <xsl:otherwise>
4252
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
4253
+ <xsl:variable name="bookmark-title_">
4254
+ <xsl:call-template name="getLangVersion">
4255
+ <xsl:with-param name="lang" select="@lang"/>
4256
+ <xsl:with-param name="doctype" select="@doctype"/>
4257
+ <xsl:with-param name="title" select="@title-part"/>
4258
+ </xsl:call-template>
4259
+ </xsl:variable>
3932
4260
  <xsl:choose>
3933
- <xsl:when test="@lang = 'en'">English</xsl:when>
3934
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3935
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3936
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4261
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
4262
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
4263
+ </xsl:when>
4264
+ <xsl:otherwise>
4265
+ <xsl:choose>
4266
+ <xsl:when test="@lang = 'en'">English</xsl:when>
4267
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
4268
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4269
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4270
+ </xsl:choose>
4271
+ </xsl:otherwise>
3937
4272
  </xsl:choose>
4273
+ </xsl:when>
4274
+ <xsl:otherwise>
4275
+ <xsl:value-of select="@title-part"/>
3938
4276
  </xsl:otherwise>
3939
4277
  </xsl:choose>
3940
4278
  </fo:bookmark-title>
4279
+
3941
4280
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3942
4281
 
3943
4282
  <xsl:call-template name="insertFigureBookmarks">
@@ -4036,16 +4375,23 @@
4036
4375
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
4037
4376
  </xsl:choose>
4038
4377
  </xsl:template><xsl:template match="item" mode="bookmark">
4039
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
4040
- <fo:bookmark-title>
4041
- <xsl:if test="@section != ''">
4042
- <xsl:value-of select="@section"/>
4043
- <xsl:text> </xsl:text>
4044
- </xsl:if>
4045
- <xsl:value-of select="normalize-space(title)"/>
4046
- </fo:bookmark-title>
4047
- <xsl:apply-templates mode="bookmark"/>
4048
- </fo:bookmark>
4378
+ <xsl:choose>
4379
+ <xsl:when test="@id != ''">
4380
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4381
+ <fo:bookmark-title>
4382
+ <xsl:if test="@section != ''">
4383
+ <xsl:value-of select="@section"/>
4384
+ <xsl:text> </xsl:text>
4385
+ </xsl:if>
4386
+ <xsl:value-of select="normalize-space(title)"/>
4387
+ </fo:bookmark-title>
4388
+ <xsl:apply-templates mode="bookmark"/>
4389
+ </fo:bookmark>
4390
+ </xsl:when>
4391
+ <xsl:otherwise>
4392
+ <xsl:apply-templates mode="bookmark"/>
4393
+ </xsl:otherwise>
4394
+ </xsl:choose>
4049
4395
  </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">
4050
4396
  <xsl:if test="normalize-space() != ''">
4051
4397
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -4411,7 +4757,19 @@
4411
4757
  </fo:inline>
4412
4758
  </xsl:if>
4413
4759
  </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'p']">
4414
- <fo:inline><xsl:apply-templates/></fo:inline>
4760
+ <xsl:variable name="element">inline
4761
+
4762
+ </xsl:variable>
4763
+ <xsl:choose>
4764
+ <xsl:when test="contains($element, 'block')">
4765
+ <fo:block xsl:use-attribute-sets="example-p-style">
4766
+ <xsl:apply-templates/>
4767
+ </fo:block>
4768
+ </xsl:when>
4769
+ <xsl:otherwise>
4770
+ <fo:inline><xsl:apply-templates/></fo:inline>
4771
+ </xsl:otherwise>
4772
+ </xsl:choose>
4415
4773
  </xsl:template><xsl:template match="*[local-name() = 'example']">
4416
4774
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
4417
4775
 
@@ -4594,7 +4952,9 @@
4594
4952
 
4595
4953
 
4596
4954
  </xsl:if>
4597
-
4955
+
4956
+
4957
+
4598
4958
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4599
4959
  <xsl:if test="normalize-space(@citeas) = ''">
4600
4960
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -4603,6 +4963,7 @@
4603
4963
 
4604
4964
 
4605
4965
 
4966
+
4606
4967
  </xsl:if>
4607
4968
 
4608
4969
  <xsl:apply-templates/>
@@ -4988,7 +5349,6 @@
4988
5349
  </xsl:template><xsl:template name="processBibitem">
4989
5350
 
4990
5351
 
4991
- <!-- end BIPM bibitem processing-->
4992
5352
 
4993
5353
 
4994
5354
 
@@ -5453,20 +5813,40 @@
5453
5813
  </xsl:call-template>
5454
5814
  </xsl:if>
5455
5815
  </xsl:template><xsl:template name="getLocalizedString">
5456
- <xsl:param name="key"/>
5816
+ <xsl:param name="key"/>
5817
+ <xsl:param name="formatted">false</xsl:param>
5457
5818
 
5458
5819
  <xsl:variable name="curr_lang">
5459
5820
  <xsl:call-template name="getLang"/>
5460
5821
  </xsl:variable>
5461
5822
 
5462
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5823
+ <xsl:variable name="data_value">
5824
+ <xsl:choose>
5825
+ <xsl:when test="$formatted = 'true'">
5826
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5827
+ </xsl:when>
5828
+ <xsl:otherwise>
5829
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5830
+ </xsl:otherwise>
5831
+ </xsl:choose>
5832
+ </xsl:variable>
5463
5833
 
5464
5834
  <xsl:choose>
5465
- <xsl:when test="$data_value != ''">
5466
- <xsl:value-of select="$data_value"/>
5835
+ <xsl:when test="normalize-space($data_value) != ''">
5836
+ <xsl:choose>
5837
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
5838
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
5839
+ </xsl:choose>
5467
5840
  </xsl:when>
5468
5841
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5469
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5842
+ <xsl:choose>
5843
+ <xsl:when test="$formatted = 'true'">
5844
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5845
+ </xsl:when>
5846
+ <xsl:otherwise>
5847
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5848
+ </xsl:otherwise>
5849
+ </xsl:choose>
5470
5850
  </xsl:when>
5471
5851
  <xsl:otherwise>
5472
5852
  <xsl:variable name="key_">
@@ -5477,7 +5857,7 @@
5477
5857
  <xsl:value-of select="$key_"/>
5478
5858
  </xsl:otherwise>
5479
5859
  </xsl:choose>
5480
-
5860
+
5481
5861
  </xsl:template><xsl:template name="setTrackChangesStyles">
5482
5862
  <xsl:param name="isAdded"/>
5483
5863
  <xsl:param name="isDeleted"/>
@@ -5528,4 +5908,100 @@
5528
5908
  <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
5529
5909
  </xsl:choose>
5530
5910
  </xsl:attribute>
5911
+ </xsl:template><xsl:template name="number-to-words">
5912
+ <xsl:param name="number"/>
5913
+ <xsl:param name="first"/>
5914
+ <xsl:if test="$number != ''">
5915
+ <xsl:variable name="words">
5916
+ <words>
5917
+ <word cardinal="1">One-</word>
5918
+ <word ordinal="1">First </word>
5919
+ <word cardinal="2">Two-</word>
5920
+ <word ordinal="2">Second </word>
5921
+ <word cardinal="3">Three-</word>
5922
+ <word ordinal="3">Third </word>
5923
+ <word cardinal="4">Four-</word>
5924
+ <word ordinal="4">Fourth </word>
5925
+ <word cardinal="5">Five-</word>
5926
+ <word ordinal="5">Fifth </word>
5927
+ <word cardinal="6">Six-</word>
5928
+ <word ordinal="6">Sixth </word>
5929
+ <word cardinal="7">Seven-</word>
5930
+ <word ordinal="7">Seventh </word>
5931
+ <word cardinal="8">Eight-</word>
5932
+ <word ordinal="8">Eighth </word>
5933
+ <word cardinal="9">Nine-</word>
5934
+ <word ordinal="9">Ninth </word>
5935
+ <word ordinal="10">Tenth </word>
5936
+ <word ordinal="11">Eleventh </word>
5937
+ <word ordinal="12">Twelfth </word>
5938
+ <word ordinal="13">Thirteenth </word>
5939
+ <word ordinal="14">Fourteenth </word>
5940
+ <word ordinal="15">Fifteenth </word>
5941
+ <word ordinal="16">Sixteenth </word>
5942
+ <word ordinal="17">Seventeenth </word>
5943
+ <word ordinal="18">Eighteenth </word>
5944
+ <word ordinal="19">Nineteenth </word>
5945
+ <word cardinal="20">Twenty-</word>
5946
+ <word ordinal="20">Twentieth </word>
5947
+ <word cardinal="30">Thirty-</word>
5948
+ <word ordinal="30">Thirtieth </word>
5949
+ <word cardinal="40">Forty-</word>
5950
+ <word ordinal="40">Fortieth </word>
5951
+ <word cardinal="50">Fifty-</word>
5952
+ <word ordinal="50">Fiftieth </word>
5953
+ <word cardinal="60">Sixty-</word>
5954
+ <word ordinal="60">Sixtieth </word>
5955
+ <word cardinal="70">Seventy-</word>
5956
+ <word ordinal="70">Seventieth </word>
5957
+ <word cardinal="80">Eighty-</word>
5958
+ <word ordinal="80">Eightieth </word>
5959
+ <word cardinal="90">Ninety-</word>
5960
+ <word ordinal="90">Ninetieth </word>
5961
+ <word cardinal="100">Hundred-</word>
5962
+ <word ordinal="100">Hundredth </word>
5963
+ </words>
5964
+ </xsl:variable>
5965
+
5966
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
5967
+
5968
+ <xsl:variable name="value">
5969
+ <xsl:choose>
5970
+ <xsl:when test="$ordinal != ''">
5971
+ <xsl:value-of select="$ordinal"/>
5972
+ </xsl:when>
5973
+ <xsl:otherwise>
5974
+ <xsl:choose>
5975
+ <xsl:when test="$number &lt; 100">
5976
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
5977
+ <xsl:variable name="digit" select="substring($number,2)"/>
5978
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
5979
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
5980
+ </xsl:when>
5981
+ <xsl:otherwise>
5982
+ <!-- more 100 -->
5983
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
5984
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
5985
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
5986
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
5987
+ <xsl:call-template name="number-to-words">
5988
+ <xsl:with-param name="number" select="$digits"/>
5989
+ </xsl:call-template>
5990
+ </xsl:otherwise>
5991
+ </xsl:choose>
5992
+ </xsl:otherwise>
5993
+ </xsl:choose>
5994
+ </xsl:variable>
5995
+ <xsl:choose>
5996
+ <xsl:when test="$first = 'true'">
5997
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
5998
+ <xsl:call-template name="capitalize">
5999
+ <xsl:with-param name="str" select="$value_lc"/>
6000
+ </xsl:call-template>
6001
+ </xsl:when>
6002
+ <xsl:otherwise>
6003
+ <xsl:value-of select="$value"/>
6004
+ </xsl:otherwise>
6005
+ </xsl:choose>
6006
+ </xsl:if>
5531
6007
  </xsl:template></xsl:stylesheet>