metanorma-m3aawg 1.7.5 → 1.7.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,8 +14,12 @@
14
14
 
15
15
 
16
16
  <xsl:variable name="debug">false</xsl:variable>
17
- <xsl:variable name="pageWidth" select="'215.9mm'"/>
18
- <xsl:variable name="pageHeight" select="'279.4mm'"/>
17
+ <xsl:variable name="pageWidth" select="215.9"/>
18
+ <xsl:variable name="pageHeight" select="279.4"/>
19
+ <xsl:variable name="marginLeftRight1" select="17.3"/>
20
+ <xsl:variable name="marginLeftRight2" select="17.3"/>
21
+ <xsl:variable name="marginTop" select="35"/>
22
+ <xsl:variable name="marginBottom" select="23"/>
19
23
 
20
24
  <xsl:variable name="title-en" select="/m3d:m3d-standard/m3d:bibdata/m3d:title[@language = 'en']"/>
21
25
  <!-- Example:
@@ -35,11 +39,11 @@
35
39
 
36
40
  <xsl:template match="/">
37
41
  <xsl:call-template name="namespaceCheck"/>
38
- <fo:root font-family="Garamond" font-size="12pt" xml:lang="{$lang}">
42
+ <fo:root font-family="EB Garamond 12" font-size="12pt" xml:lang="{$lang}">
39
43
  <fo:layout-master-set>
40
44
 
41
45
  <!-- cover page -->
42
- <fo:simple-page-master master-name="cover" page-width="{$pageWidth}" page-height="{$pageHeight}">
46
+ <fo:simple-page-master master-name="cover" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
43
47
  <fo:region-body margin-top="31mm" margin-bottom="32mm" margin-left="17.3mm" margin-right="22mm"/>
44
48
  <fo:region-before region-name="cover-header" extent="31mm"/>
45
49
  <fo:region-after region-name="cover-footer" extent="32mm"/>
@@ -48,17 +52,17 @@
48
52
  </fo:simple-page-master>
49
53
 
50
54
  <!-- contents pages -->
51
- <fo:simple-page-master master-name="page" page-width="{$pageWidth}" page-height="{$pageHeight}">
52
- <fo:region-body margin-top="20mm" margin-bottom="23mm" margin-left="17.3mm" margin-right="17.3mm"/>
53
- <fo:region-before region-name="header" extent="35mm"/>
54
- <fo:region-after region-name="footer" extent="23mm"/>
55
- <fo:region-start region-name="left-region" extent="17.3mm"/>
56
- <fo:region-end region-name="right-region" extent="17.3mm"/>
55
+ <fo:simple-page-master master-name="page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
56
+ <fo:region-body margin-top="20mm" margin-bottom="23mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
57
+ <fo:region-before region-name="header" extent="{$marginTop}mm"/>
58
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
59
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
60
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
57
61
  </fo:simple-page-master>
58
62
 
59
- <fo:simple-page-master master-name="last" page-width="{$pageWidth}" page-height="{$pageHeight}">
60
- <fo:region-body margin-top="20mm" margin-bottom="53mm" margin-left="17.3mm" margin-right="17.3mm"/>
61
- <fo:region-before region-name="header" extent="35mm"/>
63
+ <fo:simple-page-master master-name="last" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
64
+ <fo:region-body margin-top="20mm" margin-bottom="53mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
65
+ <fo:region-before region-name="header" extent="{$marginTop}mm"/>
62
66
  <fo:region-after region-name="footer-last" extent="53mm"/>
63
67
  <fo:region-start region-name="left-region" extent="17.3mm"/>
64
68
  <fo:region-end region-name="right-region" extent="17.3mm"/>
@@ -1068,7 +1072,7 @@
1068
1072
 
1069
1073
 
1070
1074
 
1071
- <xsl:attribute name="font-family">Courier</xsl:attribute>
1075
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
1072
1076
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
1073
1077
 
1074
1078
 
@@ -1156,6 +1160,7 @@
1156
1160
 
1157
1161
 
1158
1162
 
1163
+
1159
1164
  <xsl:attribute name="margin-top">8pt</xsl:attribute>
1160
1165
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
1161
1166
 
@@ -1175,7 +1180,9 @@
1175
1180
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1176
1181
 
1177
1182
 
1178
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
1183
+ </xsl:attribute-set><xsl:variable name="table-border_">
1184
+
1185
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
1179
1186
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1180
1187
 
1181
1188
 
@@ -1226,6 +1233,7 @@
1226
1233
 
1227
1234
 
1228
1235
 
1236
+
1229
1237
  </xsl:attribute-set><xsl:attribute-set name="note-style">
1230
1238
 
1231
1239
 
@@ -1381,7 +1389,7 @@
1381
1389
  </xsl:attribute-set><xsl:attribute-set name="tt-style">
1382
1390
 
1383
1391
 
1384
- <xsl:attribute name="font-family">Courier</xsl:attribute>
1392
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
1385
1393
 
1386
1394
 
1387
1395
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-name-style">
@@ -1434,14 +1442,15 @@
1434
1442
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1435
1443
 
1436
1444
  <!-- Normative references -->
1437
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1445
+ <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"/>
1438
1446
  <!-- Terms and definitions -->
1439
1447
  <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"/>
1440
1448
  <!-- Another main sections -->
1441
1449
  <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"/>
1442
1450
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1443
1451
  <!-- Bibliography -->
1444
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1452
+ <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"/>
1453
+
1445
1454
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1446
1455
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1447
1456
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -1488,6 +1497,8 @@
1488
1497
  <fo:block>&#xA0;</fo:block>
1489
1498
  </xsl:if> -->
1490
1499
 
1500
+
1501
+ <!-- Display table's name before table as standalone block -->
1491
1502
  <!-- $namespace = 'iso' or -->
1492
1503
 
1493
1504
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -1563,6 +1574,12 @@
1563
1574
 
1564
1575
 
1565
1576
 
1577
+
1578
+
1579
+
1580
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
1581
+
1582
+
1566
1583
  <xsl:variable name="table_width">
1567
1584
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
1568
1585
  100%
@@ -1581,6 +1598,7 @@
1581
1598
 
1582
1599
 
1583
1600
 
1601
+
1584
1602
 
1585
1603
 
1586
1604
 
@@ -1604,6 +1622,8 @@
1604
1622
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
1605
1623
  </xsl:if>
1606
1624
 
1625
+
1626
+
1607
1627
  <xsl:choose>
1608
1628
  <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
1609
1629
  <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
@@ -1891,9 +1911,9 @@
1891
1911
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation">
1892
1912
  <xsl:with-param name="continued">true</xsl:with-param>
1893
1913
  </xsl:apply-templates>
1894
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
1895
- <xsl:call-template name="fn_name_display"/>
1896
- </xsl:for-each>
1914
+
1915
+
1916
+
1897
1917
 
1898
1918
  </fo:table-cell>
1899
1919
  </fo:table-row>
@@ -1975,7 +1995,11 @@
1975
1995
 
1976
1996
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
1977
1997
 
1978
- <xsl:if test="$isNoteOrFnExist = 'true'">
1998
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
1999
+
2000
+ </xsl:variable>
2001
+
2002
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
1979
2003
 
1980
2004
  <xsl:variable name="cols-count">
1981
2005
  <xsl:choose>
@@ -2004,6 +2028,8 @@
2004
2028
  </xsl:choose>
2005
2029
  </xsl:for-each>
2006
2030
 
2031
+
2032
+
2007
2033
  <xsl:choose>
2008
2034
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
2009
2035
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -2030,6 +2056,7 @@
2030
2056
 
2031
2057
 
2032
2058
 
2059
+
2033
2060
  <!-- fn will be processed inside 'note' processing -->
2034
2061
 
2035
2062
 
@@ -2038,6 +2065,11 @@
2038
2065
 
2039
2066
 
2040
2067
 
2068
+
2069
+
2070
+ <!-- for BSI (not PAS) display Notes before footnotes -->
2071
+
2072
+
2041
2073
  <!-- except gb -->
2042
2074
 
2043
2075
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -2063,6 +2095,10 @@
2063
2095
  <!-- fn processing -->
2064
2096
  <xsl:call-template name="fn_display"/>
2065
2097
 
2098
+
2099
+ <!-- for PAS display Notes after footnotes -->
2100
+
2101
+
2066
2102
  </fo:table-cell>
2067
2103
  </fo:table-row>
2068
2104
  </fo:table-body>
@@ -2104,6 +2140,19 @@
2104
2140
 
2105
2141
  </fo:table-body>
2106
2142
 
2143
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/text()[1]" priority="2" mode="presentation_name">
2144
+ <xsl:choose>
2145
+ <xsl:when test="substring-after(., '—') != ''">
2146
+ <xsl:text>—</xsl:text><xsl:value-of select="substring-after(., '—')"/>
2147
+ </xsl:when>
2148
+ <xsl:otherwise>
2149
+ <xsl:value-of select="."/>
2150
+ </xsl:otherwise>
2151
+ </xsl:choose>
2152
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']" mode="presentation_name">
2153
+ <xsl:apply-templates mode="presentation_name"/>
2154
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/node()" mode="presentation_name">
2155
+ <xsl:apply-templates select="."/>
2107
2156
  </xsl:template><xsl:template match="*[local-name()='tr']">
2108
2157
  <xsl:variable name="parent-name" select="local-name(..)"/>
2109
2158
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
@@ -2116,10 +2165,13 @@
2116
2165
 
2117
2166
 
2118
2167
 
2168
+
2169
+
2119
2170
  </xsl:if>
2120
2171
  <xsl:if test="$parent-name = 'tfoot'">
2121
2172
 
2122
2173
 
2174
+
2123
2175
  </xsl:if>
2124
2176
 
2125
2177
 
@@ -2129,6 +2181,8 @@
2129
2181
 
2130
2182
 
2131
2183
 
2184
+
2185
+
2132
2186
  <!-- <xsl:if test="$namespace = 'bipm'">
2133
2187
  <xsl:attribute name="height">8mm</xsl:attribute>
2134
2188
  </xsl:if> -->
@@ -2217,6 +2271,7 @@
2217
2271
 
2218
2272
 
2219
2273
 
2274
+
2220
2275
  <xsl:if test=".//*[local-name() = 'table']">
2221
2276
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2222
2277
  </xsl:if>
@@ -2246,8 +2301,14 @@
2246
2301
 
2247
2302
 
2248
2303
 
2304
+
2305
+
2306
+ <!-- Table's note name (NOTE, for example) -->
2307
+
2249
2308
  <fo:inline padding-right="2mm">
2250
2309
 
2310
+
2311
+
2251
2312
 
2252
2313
 
2253
2314
 
@@ -2255,6 +2316,8 @@
2255
2316
 
2256
2317
  </fo:inline>
2257
2318
 
2319
+
2320
+
2258
2321
  <xsl:apply-templates mode="process"/>
2259
2322
  </fo:block>
2260
2323
 
@@ -2262,18 +2325,18 @@
2262
2325
  <xsl:apply-templates/>
2263
2326
  </xsl:template><xsl:template name="fn_display">
2264
2327
  <xsl:variable name="references">
2328
+
2265
2329
  <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
2266
- <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
2267
-
2268
-
2269
- <xsl:apply-templates/>
2270
- </fn>
2330
+ <xsl:call-template name="create_fn"/>
2271
2331
  </xsl:for-each>
2272
2332
  </xsl:variable>
2333
+
2273
2334
  <xsl:for-each select="xalan:nodeset($references)//fn">
2274
2335
  <xsl:variable name="reference" select="@reference"/>
2275
2336
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
2276
2337
  <fo:block margin-bottom="12pt">
2338
+
2339
+
2277
2340
 
2278
2341
 
2279
2342
 
@@ -2289,9 +2352,11 @@
2289
2352
 
2290
2353
 
2291
2354
 
2355
+
2292
2356
  <xsl:value-of select="@reference"/>
2293
2357
 
2294
2358
 
2359
+
2295
2360
  </fo:inline>
2296
2361
  <fo:inline>
2297
2362
 
@@ -2301,6 +2366,12 @@
2301
2366
  </fo:block>
2302
2367
  </xsl:if>
2303
2368
  </xsl:for-each>
2369
+ </xsl:template><xsl:template name="create_fn">
2370
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
2371
+
2372
+
2373
+ <xsl:apply-templates/>
2374
+ </fn>
2304
2375
  </xsl:template><xsl:template name="fn_name_display">
2305
2376
  <!-- <xsl:variable name="references">
2306
2377
  <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
@@ -2433,11 +2504,15 @@
2433
2504
 
2434
2505
 
2435
2506
 
2507
+
2508
+
2509
+
2436
2510
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2437
2511
 
2438
2512
 
2439
2513
  <xsl:value-of select="@reference"/>
2440
2514
 
2515
+
2441
2516
  </fo:basic-link>
2442
2517
  </fo:inline>
2443
2518
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -3300,19 +3375,6 @@
3300
3375
  <!-- replace start and end spaces to non-break space -->
3301
3376
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
3302
3377
  </xsl:copy>
3303
- </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml">
3304
- <xsl:copy>
3305
- <xsl:apply-templates select="@*|node()" mode="mathml"/>
3306
- </xsl:copy>
3307
- <xsl:choose>
3308
- <!-- if in msub, then don't add space -->
3309
- <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
3310
- <!-- if next char in digit, don't add space -->
3311
- <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
3312
- <xsl:otherwise>
3313
- <mathml:mspace width="0.5ex"/>
3314
- </xsl:otherwise>
3315
- </xsl:choose>
3316
3378
  </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">
3317
3379
  <xsl:variable name="target">
3318
3380
  <xsl:choose>
@@ -3337,6 +3399,7 @@
3337
3399
  <fo:inline xsl:use-attribute-sets="link-style">
3338
3400
 
3339
3401
 
3402
+
3340
3403
  <xsl:choose>
3341
3404
  <xsl:when test="$target_text = ''">
3342
3405
  <xsl:apply-templates/>
@@ -3445,6 +3508,7 @@
3445
3508
 
3446
3509
 
3447
3510
 
3511
+
3448
3512
  <fo:block-container margin-left="0mm">
3449
3513
 
3450
3514
 
@@ -3623,7 +3687,24 @@
3623
3687
  </fo:instream-foreign-object>
3624
3688
  </xsl:when>
3625
3689
  <xsl:otherwise>
3626
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
3690
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
3691
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
3692
+
3693
+ <xsl:variable name="img_src">
3694
+ <xsl:choose>
3695
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
3696
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
3697
+ </xsl:choose>
3698
+ </xsl:variable>
3699
+
3700
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
3701
+ <xsl:if test="number($scale) &lt; 100">
3702
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
3703
+ </xsl:if>
3704
+
3705
+ </xsl:if>
3706
+
3707
+ </fo:external-graphic>
3627
3708
  </xsl:otherwise>
3628
3709
  </xsl:choose>
3629
3710
 
@@ -3691,6 +3772,253 @@
3691
3772
  <xsl:param name="height"/>
3692
3773
  <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; "/>
3693
3774
  <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; "/>
3775
+ </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">
3776
+ <xsl:param name="name"/>
3777
+
3778
+ <xsl:variable name="svg_content">
3779
+ <xsl:apply-templates select="." mode="svg_update"/>
3780
+ </xsl:variable>
3781
+
3782
+ <xsl:variable name="alt-text">
3783
+ <xsl:choose>
3784
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3785
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3786
+ </xsl:when>
3787
+ <xsl:when test="normalize-space($name) != ''">
3788
+ <xsl:value-of select="$name"/>
3789
+ </xsl:when>
3790
+ <xsl:otherwise>Figure</xsl:otherwise>
3791
+ </xsl:choose>
3792
+ </xsl:variable>
3793
+
3794
+ <xsl:choose>
3795
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3796
+ <fo:block>
3797
+ <xsl:variable name="width" select="@width"/>
3798
+ <xsl:variable name="height" select="@height"/>
3799
+
3800
+ <xsl:variable name="scale_x">
3801
+ <xsl:choose>
3802
+ <xsl:when test="$width &gt; $width_effective_px">
3803
+ <xsl:value-of select="$width_effective_px div $width"/>
3804
+ </xsl:when>
3805
+ <xsl:otherwise>1</xsl:otherwise>
3806
+ </xsl:choose>
3807
+ </xsl:variable>
3808
+
3809
+ <xsl:variable name="scale_y">
3810
+ <xsl:choose>
3811
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
3812
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
3813
+ </xsl:when>
3814
+ <xsl:otherwise>1</xsl:otherwise>
3815
+ </xsl:choose>
3816
+ </xsl:variable>
3817
+
3818
+ <xsl:variable name="scale">
3819
+ <xsl:choose>
3820
+ <xsl:when test="$scale_y != 1">
3821
+ <xsl:value-of select="$scale_x * $scale_y"/>
3822
+ </xsl:when>
3823
+ <xsl:otherwise>
3824
+ <xsl:value-of select="$scale_x"/>
3825
+ </xsl:otherwise>
3826
+ </xsl:choose>
3827
+ </xsl:variable>
3828
+
3829
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
3830
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
3831
+
3832
+ <fo:table table-layout="fixed" width="100%">
3833
+ <fo:table-column column-width="proportional-column-width(1)"/>
3834
+ <fo:table-column column-width="{$width_scale}px"/>
3835
+ <fo:table-column column-width="proportional-column-width(1)"/>
3836
+ <fo:table-body>
3837
+ <fo:table-row>
3838
+ <fo:table-cell column-number="2">
3839
+ <fo:block>
3840
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
3841
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3842
+ <fo:block line-height="0" font-size="0">
3843
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3844
+ <xsl:call-template name="bookmark"/>
3845
+ </xsl:for-each>
3846
+ </fo:block>
3847
+ </xsl:if>
3848
+ <fo:block text-depth="0" line-height="0" font-size="0">
3849
+
3850
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3851
+ <xsl:attribute name="width">100%</xsl:attribute>
3852
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3853
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3854
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3855
+
3856
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
3857
+ </fo:instream-foreign-object>
3858
+ </fo:block>
3859
+
3860
+ <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">
3861
+ <xsl:with-param name="scale" select="$scale"/>
3862
+ </xsl:apply-templates>
3863
+ </fo:block-container>
3864
+ </fo:block>
3865
+ </fo:table-cell>
3866
+ </fo:table-row>
3867
+ </fo:table-body>
3868
+ </fo:table>
3869
+ </fo:block>
3870
+
3871
+ </xsl:when>
3872
+ <xsl:otherwise>
3873
+ <fo:block xsl:use-attribute-sets="image-style">
3874
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3875
+ <xsl:attribute name="width">100%</xsl:attribute>
3876
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3877
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3878
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
3879
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
3880
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
3881
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
3882
+ <!-- effective height / width = 1.48, 1.4 - with title -->
3883
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
3884
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
3885
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
3886
+ </xsl:if>
3887
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3888
+ <xsl:copy-of select="$svg_content"/>
3889
+ </fo:instream-foreign-object>
3890
+ </fo:block>
3891
+ </xsl:otherwise>
3892
+ </xsl:choose>
3893
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
3894
+ <xsl:copy>
3895
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
3896
+ </xsl:copy>
3897
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
3898
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
3899
+ <xsl:value-of select="."/>
3900
+ </xsl:attribute>
3901
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
3902
+ <xsl:copy>
3903
+ <xsl:apply-templates select="@*" mode="svg_update"/>
3904
+ <xsl:variable name="viewbox">
3905
+ <xsl:call-template name="split">
3906
+ <xsl:with-param name="pText" select="@viewBox"/>
3907
+ <xsl:with-param name="sep" select="' '"/>
3908
+ </xsl:call-template>
3909
+ </xsl:variable>
3910
+ <xsl:attribute name="width">
3911
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
3912
+ </xsl:attribute>
3913
+ <xsl:attribute name="height">
3914
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
3915
+ </xsl:attribute>
3916
+ <xsl:apply-templates mode="svg_update"/>
3917
+ </xsl:copy>
3918
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
3919
+ <xsl:variable name="svg_content" select="document(@src)"/>
3920
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
3921
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
3922
+ <xsl:call-template name="image_svg">
3923
+ <xsl:with-param name="name" select="$name"/>
3924
+ </xsl:call-template>
3925
+ </xsl:for-each>
3926
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
3927
+ <xsl:copy>
3928
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
3929
+ </xsl:copy>
3930
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
3931
+ <xsl:apply-templates mode="svg_remove_a"/>
3932
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
3933
+ <xsl:param name="scale"/>
3934
+ <xsl:variable name="dest">
3935
+ <xsl:choose>
3936
+ <xsl:when test="starts-with(@href, '#')">
3937
+ <xsl:value-of select="substring-after(@href, '#')"/>
3938
+ </xsl:when>
3939
+ <xsl:otherwise>
3940
+ <xsl:value-of select="@href"/>
3941
+ </xsl:otherwise>
3942
+ </xsl:choose>
3943
+ </xsl:variable>
3944
+ <xsl:for-each select="./*[local-name() = 'rect']">
3945
+ <xsl:call-template name="insertSVGMapLink">
3946
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
3947
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
3948
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
3949
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
3950
+ <xsl:with-param name="dest" select="$dest"/>
3951
+ </xsl:call-template>
3952
+ </xsl:for-each>
3953
+
3954
+ <xsl:for-each select="./*[local-name() = 'polygon']">
3955
+ <xsl:variable name="points">
3956
+ <xsl:call-template name="split">
3957
+ <xsl:with-param name="pText" select="@points"/>
3958
+ </xsl:call-template>
3959
+ </xsl:variable>
3960
+ <xsl:variable name="x_coords">
3961
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
3962
+ <xsl:sort select="." data-type="number"/>
3963
+ <x><xsl:value-of select="."/></x>
3964
+ </xsl:for-each>
3965
+ </xsl:variable>
3966
+ <xsl:variable name="y_coords">
3967
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
3968
+ <xsl:sort select="." data-type="number"/>
3969
+ <y><xsl:value-of select="."/></y>
3970
+ </xsl:for-each>
3971
+ </xsl:variable>
3972
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
3973
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
3974
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
3975
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
3976
+ <xsl:call-template name="insertSVGMapLink">
3977
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
3978
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
3979
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
3980
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
3981
+ <xsl:with-param name="dest" select="$dest"/>
3982
+ </xsl:call-template>
3983
+ </xsl:for-each>
3984
+
3985
+ <xsl:for-each select="./*[local-name() = 'circle']">
3986
+ <xsl:call-template name="insertSVGMapLink">
3987
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
3988
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
3989
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
3990
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
3991
+ <xsl:with-param name="dest" select="$dest"/>
3992
+ </xsl:call-template>
3993
+ </xsl:for-each>
3994
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
3995
+ <xsl:call-template name="insertSVGMapLink">
3996
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
3997
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
3998
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
3999
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
4000
+ <xsl:with-param name="dest" select="$dest"/>
4001
+ </xsl:call-template>
4002
+ </xsl:for-each>
4003
+ </xsl:template><xsl:template name="insertSVGMapLink">
4004
+ <xsl:param name="left"/>
4005
+ <xsl:param name="top"/>
4006
+ <xsl:param name="width"/>
4007
+ <xsl:param name="height"/>
4008
+ <xsl:param name="dest"/>
4009
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
4010
+ <fo:block font-size="1pt">
4011
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
4012
+ <fo:inline-container inline-progression-dimension="100%">
4013
+ <fo:block-container height="{$height - 1}px" width="100%">
4014
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
4015
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
4016
+ </xsl:if> -->
4017
+ <fo:block> </fo:block></fo:block-container>
4018
+ </fo:inline-container>
4019
+ </fo:basic-link>
4020
+ </fo:block>
4021
+ </fo:block-container>
3694
4022
  </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">
3695
4023
  <xsl:apply-templates mode="contents"/>
3696
4024
  <xsl:text> </xsl:text>
@@ -3719,28 +4047,39 @@
3719
4047
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3720
4048
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3721
4049
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4050
+ <xsl:if test="@bundle = 'true'">
4051
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
4052
+ </xsl:if>
3722
4053
  <fo:bookmark-title>
3723
- <xsl:variable name="bookmark-title_">
3724
- <xsl:call-template name="getLangVersion">
3725
- <xsl:with-param name="lang" select="@lang"/>
3726
- <xsl:with-param name="doctype" select="@doctype"/>
3727
- <xsl:with-param name="title" select="@title-part"/>
3728
- </xsl:call-template>
3729
- </xsl:variable>
3730
4054
  <xsl:choose>
3731
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3732
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3733
- </xsl:when>
3734
- <xsl:otherwise>
4055
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
4056
+ <xsl:variable name="bookmark-title_">
4057
+ <xsl:call-template name="getLangVersion">
4058
+ <xsl:with-param name="lang" select="@lang"/>
4059
+ <xsl:with-param name="doctype" select="@doctype"/>
4060
+ <xsl:with-param name="title" select="@title-part"/>
4061
+ </xsl:call-template>
4062
+ </xsl:variable>
3735
4063
  <xsl:choose>
3736
- <xsl:when test="@lang = 'en'">English</xsl:when>
3737
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3738
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3739
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4064
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
4065
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
4066
+ </xsl:when>
4067
+ <xsl:otherwise>
4068
+ <xsl:choose>
4069
+ <xsl:when test="@lang = 'en'">English</xsl:when>
4070
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
4071
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4072
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4073
+ </xsl:choose>
4074
+ </xsl:otherwise>
3740
4075
  </xsl:choose>
4076
+ </xsl:when>
4077
+ <xsl:otherwise>
4078
+ <xsl:value-of select="@title-part"/>
3741
4079
  </xsl:otherwise>
3742
4080
  </xsl:choose>
3743
4081
  </fo:bookmark-title>
4082
+
3744
4083
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3745
4084
 
3746
4085
  <xsl:call-template name="insertFigureBookmarks">
@@ -3839,16 +4178,23 @@
3839
4178
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
3840
4179
  </xsl:choose>
3841
4180
  </xsl:template><xsl:template match="item" mode="bookmark">
3842
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
3843
- <fo:bookmark-title>
3844
- <xsl:if test="@section != ''">
3845
- <xsl:value-of select="@section"/>
3846
- <xsl:text> </xsl:text>
3847
- </xsl:if>
3848
- <xsl:value-of select="normalize-space(title)"/>
3849
- </fo:bookmark-title>
3850
- <xsl:apply-templates mode="bookmark"/>
3851
- </fo:bookmark>
4181
+ <xsl:choose>
4182
+ <xsl:when test="@id != ''">
4183
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4184
+ <fo:bookmark-title>
4185
+ <xsl:if test="@section != ''">
4186
+ <xsl:value-of select="@section"/>
4187
+ <xsl:text> </xsl:text>
4188
+ </xsl:if>
4189
+ <xsl:value-of select="normalize-space(title)"/>
4190
+ </fo:bookmark-title>
4191
+ <xsl:apply-templates mode="bookmark"/>
4192
+ </fo:bookmark>
4193
+ </xsl:when>
4194
+ <xsl:otherwise>
4195
+ <xsl:apply-templates mode="bookmark"/>
4196
+ </xsl:otherwise>
4197
+ </xsl:choose>
3852
4198
  </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">
3853
4199
  <xsl:if test="normalize-space() != ''">
3854
4200
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -4214,7 +4560,19 @@
4214
4560
  </fo:inline>
4215
4561
  </xsl:if>
4216
4562
  </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'p']">
4217
- <fo:inline><xsl:apply-templates/></fo:inline>
4563
+ <xsl:variable name="element">inline
4564
+
4565
+ </xsl:variable>
4566
+ <xsl:choose>
4567
+ <xsl:when test="contains($element, 'block')">
4568
+ <fo:block xsl:use-attribute-sets="example-p-style">
4569
+ <xsl:apply-templates/>
4570
+ </fo:block>
4571
+ </xsl:when>
4572
+ <xsl:otherwise>
4573
+ <fo:inline><xsl:apply-templates/></fo:inline>
4574
+ </xsl:otherwise>
4575
+ </xsl:choose>
4218
4576
  </xsl:template><xsl:template match="*[local-name() = 'example']">
4219
4577
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
4220
4578
 
@@ -4392,7 +4750,9 @@
4392
4750
  <xsl:attribute name="vertical-align">super</xsl:attribute>
4393
4751
 
4394
4752
  </xsl:if>
4395
-
4753
+
4754
+
4755
+
4396
4756
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4397
4757
  <xsl:if test="normalize-space(@citeas) = ''">
4398
4758
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -4401,6 +4761,7 @@
4401
4761
 
4402
4762
 
4403
4763
 
4764
+
4404
4765
  </xsl:if>
4405
4766
 
4406
4767
  <xsl:apply-templates/>
@@ -4784,7 +5145,6 @@
4784
5145
  </xsl:template><xsl:template name="processBibitem">
4785
5146
 
4786
5147
 
4787
- <!-- end BIPM bibitem processing-->
4788
5148
 
4789
5149
 
4790
5150
 
@@ -5249,20 +5609,40 @@
5249
5609
  </xsl:call-template>
5250
5610
  </xsl:if>
5251
5611
  </xsl:template><xsl:template name="getLocalizedString">
5252
- <xsl:param name="key"/>
5612
+ <xsl:param name="key"/>
5613
+ <xsl:param name="formatted">false</xsl:param>
5253
5614
 
5254
5615
  <xsl:variable name="curr_lang">
5255
5616
  <xsl:call-template name="getLang"/>
5256
5617
  </xsl:variable>
5257
5618
 
5258
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5619
+ <xsl:variable name="data_value">
5620
+ <xsl:choose>
5621
+ <xsl:when test="$formatted = 'true'">
5622
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5623
+ </xsl:when>
5624
+ <xsl:otherwise>
5625
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
5626
+ </xsl:otherwise>
5627
+ </xsl:choose>
5628
+ </xsl:variable>
5259
5629
 
5260
5630
  <xsl:choose>
5261
- <xsl:when test="$data_value != ''">
5262
- <xsl:value-of select="$data_value"/>
5631
+ <xsl:when test="normalize-space($data_value) != ''">
5632
+ <xsl:choose>
5633
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
5634
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
5635
+ </xsl:choose>
5263
5636
  </xsl:when>
5264
5637
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
5265
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5638
+ <xsl:choose>
5639
+ <xsl:when test="$formatted = 'true'">
5640
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5641
+ </xsl:when>
5642
+ <xsl:otherwise>
5643
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
5644
+ </xsl:otherwise>
5645
+ </xsl:choose>
5266
5646
  </xsl:when>
5267
5647
  <xsl:otherwise>
5268
5648
  <xsl:variable name="key_">
@@ -5273,7 +5653,7 @@
5273
5653
  <xsl:value-of select="$key_"/>
5274
5654
  </xsl:otherwise>
5275
5655
  </xsl:choose>
5276
-
5656
+
5277
5657
  </xsl:template><xsl:template name="setTrackChangesStyles">
5278
5658
  <xsl:param name="isAdded"/>
5279
5659
  <xsl:param name="isDeleted"/>
@@ -5324,4 +5704,100 @@
5324
5704
  <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
5325
5705
  </xsl:choose>
5326
5706
  </xsl:attribute>
5707
+ </xsl:template><xsl:template name="number-to-words">
5708
+ <xsl:param name="number"/>
5709
+ <xsl:param name="first"/>
5710
+ <xsl:if test="$number != ''">
5711
+ <xsl:variable name="words">
5712
+ <words>
5713
+ <word cardinal="1">One-</word>
5714
+ <word ordinal="1">First </word>
5715
+ <word cardinal="2">Two-</word>
5716
+ <word ordinal="2">Second </word>
5717
+ <word cardinal="3">Three-</word>
5718
+ <word ordinal="3">Third </word>
5719
+ <word cardinal="4">Four-</word>
5720
+ <word ordinal="4">Fourth </word>
5721
+ <word cardinal="5">Five-</word>
5722
+ <word ordinal="5">Fifth </word>
5723
+ <word cardinal="6">Six-</word>
5724
+ <word ordinal="6">Sixth </word>
5725
+ <word cardinal="7">Seven-</word>
5726
+ <word ordinal="7">Seventh </word>
5727
+ <word cardinal="8">Eight-</word>
5728
+ <word ordinal="8">Eighth </word>
5729
+ <word cardinal="9">Nine-</word>
5730
+ <word ordinal="9">Ninth </word>
5731
+ <word ordinal="10">Tenth </word>
5732
+ <word ordinal="11">Eleventh </word>
5733
+ <word ordinal="12">Twelfth </word>
5734
+ <word ordinal="13">Thirteenth </word>
5735
+ <word ordinal="14">Fourteenth </word>
5736
+ <word ordinal="15">Fifteenth </word>
5737
+ <word ordinal="16">Sixteenth </word>
5738
+ <word ordinal="17">Seventeenth </word>
5739
+ <word ordinal="18">Eighteenth </word>
5740
+ <word ordinal="19">Nineteenth </word>
5741
+ <word cardinal="20">Twenty-</word>
5742
+ <word ordinal="20">Twentieth </word>
5743
+ <word cardinal="30">Thirty-</word>
5744
+ <word ordinal="30">Thirtieth </word>
5745
+ <word cardinal="40">Forty-</word>
5746
+ <word ordinal="40">Fortieth </word>
5747
+ <word cardinal="50">Fifty-</word>
5748
+ <word ordinal="50">Fiftieth </word>
5749
+ <word cardinal="60">Sixty-</word>
5750
+ <word ordinal="60">Sixtieth </word>
5751
+ <word cardinal="70">Seventy-</word>
5752
+ <word ordinal="70">Seventieth </word>
5753
+ <word cardinal="80">Eighty-</word>
5754
+ <word ordinal="80">Eightieth </word>
5755
+ <word cardinal="90">Ninety-</word>
5756
+ <word ordinal="90">Ninetieth </word>
5757
+ <word cardinal="100">Hundred-</word>
5758
+ <word ordinal="100">Hundredth </word>
5759
+ </words>
5760
+ </xsl:variable>
5761
+
5762
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
5763
+
5764
+ <xsl:variable name="value">
5765
+ <xsl:choose>
5766
+ <xsl:when test="$ordinal != ''">
5767
+ <xsl:value-of select="$ordinal"/>
5768
+ </xsl:when>
5769
+ <xsl:otherwise>
5770
+ <xsl:choose>
5771
+ <xsl:when test="$number &lt; 100">
5772
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
5773
+ <xsl:variable name="digit" select="substring($number,2)"/>
5774
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
5775
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
5776
+ </xsl:when>
5777
+ <xsl:otherwise>
5778
+ <!-- more 100 -->
5779
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
5780
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
5781
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
5782
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
5783
+ <xsl:call-template name="number-to-words">
5784
+ <xsl:with-param name="number" select="$digits"/>
5785
+ </xsl:call-template>
5786
+ </xsl:otherwise>
5787
+ </xsl:choose>
5788
+ </xsl:otherwise>
5789
+ </xsl:choose>
5790
+ </xsl:variable>
5791
+ <xsl:choose>
5792
+ <xsl:when test="$first = 'true'">
5793
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
5794
+ <xsl:call-template name="capitalize">
5795
+ <xsl:with-param name="str" select="$value_lc"/>
5796
+ </xsl:call-template>
5797
+ </xsl:when>
5798
+ <xsl:otherwise>
5799
+ <xsl:value-of select="$value"/>
5800
+ </xsl:otherwise>
5801
+ </xsl:choose>
5802
+ </xsl:if>
5327
5803
  </xsl:template></xsl:stylesheet>