metanorma-bipm 1.1.4 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,8 +76,13 @@
76
76
  <xsl:variable name="column_width" select="($page_width - $column_gap) div $docs_count"/>
77
77
 
78
78
  <xsl:variable name="debug">false</xsl:variable>
79
- <xsl:variable name="pageWidth" select="'210mm'"/>
80
- <xsl:variable name="pageHeight" select="'297mm'"/>
79
+ <xsl:variable name="pageWidth" select="210"/>
80
+ <xsl:variable name="pageHeight" select="297"/>
81
+ <xsl:variable name="marginLeftRight1" select="25"/>
82
+ <xsl:variable name="marginLeftRight2" select="15"/>
83
+ <xsl:variable name="marginTop" select="29.5"/>
84
+ <xsl:variable name="marginBottom" select="23.5"/>
85
+
81
86
 
82
87
  <xsl:variable name="all_rights_reserved">
83
88
  <xsl:call-template name="getLocalizedString">
@@ -161,7 +166,7 @@
161
166
  <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
162
167
  <fo:layout-master-set>
163
168
  <!-- cover page -->
164
- <fo:simple-page-master master-name="cover-page-jcgm" page-width="{$pageWidth}" page-height="{$pageHeight}">
169
+ <fo:simple-page-master master-name="cover-page-jcgm" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
165
170
  <fo:region-body margin-top="85mm" margin-bottom="30mm" margin-left="100mm" margin-right="19mm"/>
166
171
  <fo:region-before extent="85mm"/>
167
172
  <fo:region-after region-name="cover-page-jcgm-footer" extent="30mm"/>
@@ -169,7 +174,7 @@
169
174
  <fo:region-end extent="19mm"/>
170
175
  </fo:simple-page-master>
171
176
  <!-- internal cover page -->
172
- <fo:simple-page-master master-name="internal-cover-page-jcgm" page-width="{$pageWidth}" page-height="{$pageHeight}">
177
+ <fo:simple-page-master master-name="internal-cover-page-jcgm" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
173
178
  <fo:region-body margin-top="11mm" margin-bottom="21mm" margin-left="25mm" margin-right="19mm"/>
174
179
  <fo:region-before extent="11mm"/>
175
180
  <fo:region-after region-name="internal-cover-page-jcgm-footer" extent="21mm"/>
@@ -177,19 +182,19 @@
177
182
  <fo:region-end extent="19mm"/>
178
183
  </fo:simple-page-master>
179
184
 
180
- <fo:simple-page-master master-name="odd-jcgm" page-width="{$pageWidth}" page-height="{$pageHeight}">
181
- <fo:region-body margin-top="29.5mm" margin-bottom="23.5mm" margin-left="25mm" margin-right="15mm"/>
182
- <fo:region-before region-name="header-odd-jcgm" extent="29.5mm"/> <!-- display-align="center" -->
183
- <fo:region-after region-name="footer-odd-jcgm" extent="23.5mm"/>
184
- <fo:region-start region-name="left-region" extent="25mm"/>
185
- <fo:region-end region-name="right-region" extent="15mm"/>
185
+ <fo:simple-page-master master-name="odd-jcgm" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
186
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
187
+ <fo:region-before region-name="header-odd-jcgm" extent="{$marginTop}mm"/> <!-- display-align="center" -->
188
+ <fo:region-after region-name="footer-odd-jcgm" extent="{$marginBottom}mm"/>
189
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
190
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
186
191
  </fo:simple-page-master>
187
- <fo:simple-page-master master-name="even-jcgm" page-width="{$pageWidth}" page-height="{$pageHeight}">
188
- <fo:region-body margin-top="29.5mm" margin-bottom="23.5mm" margin-left="15mm" margin-right="25mm"/>
189
- <fo:region-before region-name="header-even-jcgm" extent="29.5mm"/> <!-- display-align="center" -->
190
- <fo:region-after region-name="footer-even-jcgm" extent="23.5mm"/>
191
- <fo:region-start region-name="left-region" extent="15mm"/>
192
- <fo:region-end region-name="right-region" extent="25mm"/>
192
+ <fo:simple-page-master master-name="even-jcgm" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
193
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
194
+ <fo:region-before region-name="header-even-jcgm" extent="{$marginTop}mm"/> <!-- display-align="center" -->
195
+ <fo:region-after region-name="footer-even-jcgm" extent="{$marginBottom}mm"/>
196
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight2}mm"/>
197
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight1}mm"/>
193
198
  </fo:simple-page-master>
194
199
  <fo:page-sequence-master master-name="document-jcgm">
195
200
  <fo:repeatable-page-master-alternatives>
@@ -1162,89 +1167,6 @@
1162
1167
  </fo:block>
1163
1168
  </xsl:template>
1164
1169
 
1165
-
1166
-
1167
- <xsl:template name="number-to-words">
1168
- <xsl:param name="number"/>
1169
- <xsl:variable name="words">
1170
- <words>
1171
- <word cardinal="1">One-</word>
1172
- <word ordinal="1">First </word>
1173
- <word cardinal="2">Two-</word>
1174
- <word ordinal="2">Second </word>
1175
- <word cardinal="3">Three-</word>
1176
- <word ordinal="3">Third </word>
1177
- <word cardinal="4">Four-</word>
1178
- <word ordinal="4">Fourth </word>
1179
- <word cardinal="5">Five-</word>
1180
- <word ordinal="5">Fifth </word>
1181
- <word cardinal="6">Six-</word>
1182
- <word ordinal="6">Sixth </word>
1183
- <word cardinal="7">Seven-</word>
1184
- <word ordinal="7">Seventh </word>
1185
- <word cardinal="8">Eight-</word>
1186
- <word ordinal="8">Eighth </word>
1187
- <word cardinal="9">Nine-</word>
1188
- <word ordinal="9">Ninth </word>
1189
- <word ordinal="10">Tenth </word>
1190
- <word ordinal="11">Eleventh </word>
1191
- <word ordinal="12">Twelfth </word>
1192
- <word ordinal="13">Thirteenth </word>
1193
- <word ordinal="14">Fourteenth </word>
1194
- <word ordinal="15">Fifteenth </word>
1195
- <word ordinal="16">Sixteenth </word>
1196
- <word ordinal="17">Seventeenth </word>
1197
- <word ordinal="18">Eighteenth </word>
1198
- <word ordinal="19">Nineteenth </word>
1199
- <word cardinal="20">Twenty-</word>
1200
- <word ordinal="20">Twentieth </word>
1201
- <word cardinal="30">Thirty-</word>
1202
- <word ordinal="30">Thirtieth </word>
1203
- <word cardinal="40">Forty-</word>
1204
- <word ordinal="40">Fortieth </word>
1205
- <word cardinal="50">Fifty-</word>
1206
- <word ordinal="50">Fiftieth </word>
1207
- <word cardinal="60">Sixty-</word>
1208
- <word ordinal="60">Sixtieth </word>
1209
- <word cardinal="70">Seventy-</word>
1210
- <word ordinal="70">Seventieth </word>
1211
- <word cardinal="80">Eighty-</word>
1212
- <word ordinal="80">Eightieth </word>
1213
- <word cardinal="90">Ninety-</word>
1214
- <word ordinal="90">Ninetieth </word>
1215
- <word cardinal="100">Hundred-</word>
1216
- <word ordinal="100">Hundredth </word>
1217
- </words>
1218
- </xsl:variable>
1219
-
1220
- <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
1221
-
1222
- <xsl:choose>
1223
- <xsl:when test="$ordinal != ''">
1224
- <xsl:value-of select="$ordinal"/>
1225
- </xsl:when>
1226
- <xsl:otherwise>
1227
- <xsl:choose>
1228
- <xsl:when test="$number &lt; 100">
1229
- <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
1230
- <xsl:variable name="digit" select="substring($number,2)"/>
1231
- <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
1232
- <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
1233
- </xsl:when>
1234
- <xsl:otherwise>
1235
- <!-- more 100 -->
1236
- <xsl:variable name="hundred" select="substring($number,1,1)"/>
1237
- <xsl:variable name="digits" select="number(substring($number,2))"/>
1238
- <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
1239
- <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
1240
- <xsl:call-template name="number-to-words">
1241
- <xsl:with-param name="number" select="$digits"/>
1242
- </xsl:call-template>
1243
- </xsl:otherwise>
1244
- </xsl:choose>
1245
- </xsl:otherwise>
1246
- </xsl:choose>
1247
- </xsl:template>
1248
1170
 
1249
1171
  <xsl:template name="printEdition">
1250
1172
  <xsl:variable name="edition" select="normalize-space(//*[local-name()='bibdata']/*[local-name()='edition'])"/>
@@ -2084,7 +2006,7 @@
2084
2006
  <!-- grey opacity -->
2085
2007
  <fo:block-container absolute-position="fixed" left="0" top="0">
2086
2008
  <fo:block>
2087
- <fo:instream-foreign-object content-height="{$pageHeight}" fox:alt-text="Background color">
2009
+ <fo:instream-foreign-object content-height="{$pageHeight}mm" fox:alt-text="Background color">
2088
2010
  <svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="210mm" height="297mm">
2089
2011
  <rect width="210mm" height="297mm" style="fill:rgb(255,255,255);stroke-width:0;fill-opacity:0.73"/>
2090
2012
  </svg>
@@ -2256,7 +2178,7 @@
2256
2178
  <xsl:attribute name="white-space">pre</xsl:attribute>
2257
2179
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
2258
2180
 
2259
- <xsl:attribute name="font-family">Courier</xsl:attribute>
2181
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
2260
2182
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
2261
2183
 
2262
2184
 
@@ -2347,6 +2269,7 @@
2347
2269
 
2348
2270
 
2349
2271
 
2272
+
2350
2273
  <xsl:attribute name="font-size">10pt</xsl:attribute>
2351
2274
  <xsl:attribute name="margin-top">8pt</xsl:attribute>
2352
2275
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
@@ -2370,7 +2293,9 @@
2370
2293
 
2371
2294
 
2372
2295
 
2373
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
2296
+ </xsl:attribute-set><xsl:variable name="table-border_">
2297
+
2298
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
2374
2299
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2375
2300
 
2376
2301
 
@@ -2426,6 +2351,7 @@
2426
2351
 
2427
2352
 
2428
2353
 
2354
+
2429
2355
  </xsl:attribute-set><xsl:attribute-set name="note-style">
2430
2356
 
2431
2357
 
@@ -2591,7 +2517,7 @@
2591
2517
  </xsl:attribute-set><xsl:attribute-set name="tt-style">
2592
2518
 
2593
2519
 
2594
- <xsl:attribute name="font-family">Courier</xsl:attribute>
2520
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
2595
2521
 
2596
2522
 
2597
2523
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-name-style">
@@ -2648,14 +2574,15 @@
2648
2574
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
2649
2575
 
2650
2576
  <!-- Normative references -->
2651
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
2577
+ <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"/>
2652
2578
  <!-- Terms and definitions -->
2653
2579
  <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"/>
2654
2580
  <!-- Another main sections -->
2655
2581
  <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"/>
2656
2582
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
2657
2583
  <!-- Bibliography -->
2658
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
2584
+ <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"/>
2585
+
2659
2586
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2660
2587
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
2661
2588
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -2698,6 +2625,8 @@
2698
2625
  <fo:block>&#xA0;</fo:block>
2699
2626
  </xsl:if> -->
2700
2627
 
2628
+
2629
+ <!-- Display table's name before table as standalone block -->
2701
2630
  <!-- $namespace = 'iso' or -->
2702
2631
 
2703
2632
 
@@ -2776,6 +2705,12 @@
2776
2705
 
2777
2706
 
2778
2707
 
2708
+
2709
+
2710
+
2711
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
2712
+
2713
+
2779
2714
  <xsl:variable name="table_width">
2780
2715
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
2781
2716
  100%
@@ -2799,6 +2734,7 @@
2799
2734
 
2800
2735
 
2801
2736
 
2737
+
2802
2738
  <attribute name="margin-left">0mm</attribute>
2803
2739
  <attribute name="margin-right">0mm</attribute>
2804
2740
 
@@ -2825,6 +2761,8 @@
2825
2761
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
2826
2762
  </xsl:if>
2827
2763
 
2764
+
2765
+
2828
2766
  <xsl:choose>
2829
2767
  <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
2830
2768
  <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
@@ -3120,9 +3058,13 @@
3120
3058
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation">
3121
3059
  <xsl:with-param name="continued">true</xsl:with-param>
3122
3060
  </xsl:apply-templates>
3123
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
3124
- <xsl:call-template name="fn_name_display"/>
3125
- </xsl:for-each>
3061
+
3062
+
3063
+ <xsl:for-each select="ancestor::*[local-name()='table'][1]">
3064
+ <xsl:call-template name="fn_name_display"/>
3065
+ </xsl:for-each>
3066
+
3067
+
3126
3068
 
3127
3069
  <fo:block text-align="right" font-style="italic">
3128
3070
  <xsl:text> </xsl:text>
@@ -3211,7 +3153,11 @@
3211
3153
 
3212
3154
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3213
3155
 
3214
- <xsl:if test="$isNoteOrFnExist = 'true'">
3156
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
3157
+
3158
+ </xsl:variable>
3159
+
3160
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
3215
3161
 
3216
3162
  <xsl:variable name="cols-count">
3217
3163
  <xsl:choose>
@@ -3240,6 +3186,8 @@
3240
3186
  </xsl:choose>
3241
3187
  </xsl:for-each>
3242
3188
 
3189
+
3190
+
3243
3191
  <xsl:choose>
3244
3192
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
3245
3193
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -3264,6 +3212,7 @@
3264
3212
  <fo:table-row>
3265
3213
  <fo:table-cell border="solid black 1pt" padding-left="1mm" padding-right="1mm" padding-top="1mm" number-columns-spanned="{$cols-count}">
3266
3214
 
3215
+
3267
3216
  <xsl:attribute name="border-top">solid black 0pt</xsl:attribute>
3268
3217
 
3269
3218
 
@@ -3276,6 +3225,11 @@
3276
3225
 
3277
3226
 
3278
3227
 
3228
+
3229
+
3230
+ <!-- for BSI (not PAS) display Notes before footnotes -->
3231
+
3232
+
3279
3233
  <!-- except gb -->
3280
3234
 
3281
3235
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -3301,6 +3255,10 @@
3301
3255
  <!-- fn processing -->
3302
3256
  <xsl:call-template name="fn_display"/>
3303
3257
 
3258
+
3259
+ <!-- for PAS display Notes after footnotes -->
3260
+
3261
+
3304
3262
  </fo:table-cell>
3305
3263
  </fo:table-row>
3306
3264
  </fo:table-body>
@@ -3345,21 +3303,29 @@
3345
3303
 
3346
3304
  <fo:table-body>
3347
3305
 
3348
- <xsl:variable name="title_continued">
3306
+ <xsl:variable name="title_continued_">
3349
3307
  <xsl:call-template name="getTitle">
3350
3308
  <xsl:with-param name="name" select="'title-continued'"/>
3351
3309
  </xsl:call-template>
3352
3310
  </xsl:variable>
3353
3311
 
3312
+ <xsl:variable name="title_continued">
3313
+ <xsl:value-of select="$title_continued_"/>
3314
+
3315
+ </xsl:variable>
3316
+
3354
3317
  <xsl:variable name="title_start" select="ancestor::*[local-name()='table'][1]/*[local-name()='name']/node()[1][self::text()]"/>
3355
3318
  <xsl:variable name="table_number" select="substring-before($title_start, '—')"/>
3356
3319
 
3357
3320
  <fo:table-row height="0" keep-with-next.within-page="always">
3358
3321
  <fo:table-cell>
3322
+
3323
+
3359
3324
 
3360
3325
 
3361
3326
  <fo:marker marker-class-name="table_continued"/>
3362
3327
 
3328
+
3363
3329
  <fo:block/>
3364
3330
  </fo:table-cell>
3365
3331
  </fo:table-row>
@@ -3379,6 +3345,19 @@
3379
3345
 
3380
3346
  </fo:table-body>
3381
3347
 
3348
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/text()[1]" priority="2" mode="presentation_name">
3349
+ <xsl:choose>
3350
+ <xsl:when test="substring-after(., '—') != ''">
3351
+ <xsl:text>—</xsl:text><xsl:value-of select="substring-after(., '—')"/>
3352
+ </xsl:when>
3353
+ <xsl:otherwise>
3354
+ <xsl:value-of select="."/>
3355
+ </xsl:otherwise>
3356
+ </xsl:choose>
3357
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']" mode="presentation_name">
3358
+ <xsl:apply-templates mode="presentation_name"/>
3359
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/node()" mode="presentation_name">
3360
+ <xsl:apply-templates select="."/>
3382
3361
  </xsl:template><xsl:template match="*[local-name()='tr']">
3383
3362
  <xsl:variable name="parent-name" select="local-name(..)"/>
3384
3363
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
@@ -3406,9 +3385,12 @@
3406
3385
 
3407
3386
 
3408
3387
 
3388
+
3389
+
3409
3390
  </xsl:if>
3410
3391
  <xsl:if test="$parent-name = 'tfoot'">
3411
3392
 
3393
+
3412
3394
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3413
3395
  <xsl:attribute name="border-left">solid black 1pt</xsl:attribute>
3414
3396
  <xsl:attribute name="border-right">solid black 1pt</xsl:attribute>
@@ -3423,6 +3405,8 @@
3423
3405
 
3424
3406
 
3425
3407
 
3408
+
3409
+
3426
3410
  <!-- <xsl:if test="$namespace = 'bipm'">
3427
3411
  <xsl:attribute name="height">8mm</xsl:attribute>
3428
3412
  </xsl:if> -->
@@ -3502,6 +3486,7 @@
3502
3486
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
3503
3487
 
3504
3488
 
3489
+
3505
3490
  <xsl:if test="count(*) = 1 and (local-name(*[1]) = 'stem' or local-name(*[1]) = 'figure')">
3506
3491
  <xsl:attribute name="padding-left">0mm</xsl:attribute>
3507
3492
  </xsl:if>
@@ -3547,6 +3532,7 @@
3547
3532
 
3548
3533
  <fo:block font-size="10pt" margin-bottom="12pt">
3549
3534
 
3535
+
3550
3536
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3551
3537
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
3552
3538
 
@@ -3555,8 +3541,13 @@
3555
3541
 
3556
3542
 
3557
3543
 
3544
+
3545
+ <!-- Table's note name (NOTE, for example) -->
3546
+
3558
3547
  <fo:inline padding-right="2mm">
3559
3548
 
3549
+
3550
+
3560
3551
 
3561
3552
 
3562
3553
 
@@ -3564,6 +3555,8 @@
3564
3555
 
3565
3556
  </fo:inline>
3566
3557
 
3558
+
3559
+
3567
3560
  <xsl:apply-templates mode="process"/>
3568
3561
  </fo:block>
3569
3562
 
@@ -3571,18 +3564,18 @@
3571
3564
  <xsl:apply-templates/>
3572
3565
  </xsl:template><xsl:template name="fn_display">
3573
3566
  <xsl:variable name="references">
3567
+
3574
3568
  <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
3575
- <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3576
-
3577
-
3578
- <xsl:apply-templates/>
3579
- </fn>
3569
+ <xsl:call-template name="create_fn"/>
3580
3570
  </xsl:for-each>
3581
3571
  </xsl:variable>
3572
+
3582
3573
  <xsl:for-each select="xalan:nodeset($references)//fn">
3583
3574
  <xsl:variable name="reference" select="@reference"/>
3584
3575
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3585
3576
  <fo:block margin-bottom="12pt">
3577
+
3578
+
3586
3579
 
3587
3580
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3588
3581
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
@@ -3601,9 +3594,11 @@
3601
3594
 
3602
3595
 
3603
3596
 
3597
+
3604
3598
  <xsl:value-of select="@reference"/>
3605
3599
 
3606
3600
 
3601
+
3607
3602
  </fo:inline>
3608
3603
  <fo:inline>
3609
3604
 
@@ -3613,6 +3608,12 @@
3613
3608
  </fo:block>
3614
3609
  </xsl:if>
3615
3610
  </xsl:for-each>
3611
+ </xsl:template><xsl:template name="create_fn">
3612
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3613
+
3614
+
3615
+ <xsl:apply-templates/>
3616
+ </fn>
3616
3617
  </xsl:template><xsl:template name="fn_name_display">
3617
3618
  <!-- <xsl:variable name="references">
3618
3619
  <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
@@ -3739,7 +3740,9 @@
3739
3740
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
3740
3741
  <fo:inline font-size="80%" keep-with-previous.within-line="always">
3741
3742
 
3742
- <xsl:if test="ancestor::*[local-name()='td']">
3743
+
3744
+
3745
+ <xsl:if test="ancestor::*[local-name()='table']">
3743
3746
  <xsl:attribute name="font-weight">normal</xsl:attribute>
3744
3747
  <!-- <xsl:attribute name="alignment-baseline">hanging</xsl:attribute> -->
3745
3748
  <xsl:attribute name="baseline-shift">15%</xsl:attribute>
@@ -3751,11 +3754,13 @@
3751
3754
 
3752
3755
 
3753
3756
 
3757
+
3754
3758
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
3755
3759
 
3756
3760
 
3757
3761
  <xsl:value-of select="@reference"/>
3758
3762
 
3763
+
3759
3764
  </fo:basic-link>
3760
3765
  </fo:inline>
3761
3766
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -4629,19 +4634,6 @@
4629
4634
  <!-- replace start and end spaces to non-break space -->
4630
4635
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4631
4636
  </xsl:copy>
4632
- </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml">
4633
- <xsl:copy>
4634
- <xsl:apply-templates select="@*|node()" mode="mathml"/>
4635
- </xsl:copy>
4636
- <xsl:choose>
4637
- <!-- if in msub, then don't add space -->
4638
- <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
4639
- <!-- if next char in digit, don't add space -->
4640
- <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
4641
- <xsl:otherwise>
4642
- <mathml:mspace width="0.5ex"/>
4643
- </xsl:otherwise>
4644
- </xsl:choose>
4645
4637
  </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">
4646
4638
  <xsl:variable name="target">
4647
4639
  <xsl:choose>
@@ -4666,6 +4658,7 @@
4666
4658
  <fo:inline xsl:use-attribute-sets="link-style">
4667
4659
 
4668
4660
 
4661
+
4669
4662
  <xsl:choose>
4670
4663
  <xsl:when test="$target_text = ''">
4671
4664
  <xsl:apply-templates/>
@@ -4774,6 +4767,7 @@
4774
4767
 
4775
4768
 
4776
4769
 
4770
+
4777
4771
  <fo:block-container margin-left="0mm">
4778
4772
 
4779
4773
 
@@ -4948,7 +4942,24 @@
4948
4942
  </fo:instream-foreign-object>
4949
4943
  </xsl:when>
4950
4944
  <xsl:otherwise>
4951
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
4945
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
4946
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
4947
+
4948
+ <xsl:variable name="img_src">
4949
+ <xsl:choose>
4950
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
4951
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
4952
+ </xsl:choose>
4953
+ </xsl:variable>
4954
+
4955
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
4956
+ <xsl:if test="number($scale) &lt; 100">
4957
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
4958
+ </xsl:if>
4959
+
4960
+ </xsl:if>
4961
+
4962
+ </fo:external-graphic>
4952
4963
  </xsl:otherwise>
4953
4964
  </xsl:choose>
4954
4965
 
@@ -5016,6 +5027,253 @@
5016
5027
  <xsl:param name="height"/>
5017
5028
  <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; "/>
5018
5029
  <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; "/>
5030
+ </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">
5031
+ <xsl:param name="name"/>
5032
+
5033
+ <xsl:variable name="svg_content">
5034
+ <xsl:apply-templates select="." mode="svg_update"/>
5035
+ </xsl:variable>
5036
+
5037
+ <xsl:variable name="alt-text">
5038
+ <xsl:choose>
5039
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
5040
+ <xsl:value-of select="../*[local-name() = 'name']"/>
5041
+ </xsl:when>
5042
+ <xsl:when test="normalize-space($name) != ''">
5043
+ <xsl:value-of select="$name"/>
5044
+ </xsl:when>
5045
+ <xsl:otherwise>Figure</xsl:otherwise>
5046
+ </xsl:choose>
5047
+ </xsl:variable>
5048
+
5049
+ <xsl:choose>
5050
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
5051
+ <fo:block>
5052
+ <xsl:variable name="width" select="@width"/>
5053
+ <xsl:variable name="height" select="@height"/>
5054
+
5055
+ <xsl:variable name="scale_x">
5056
+ <xsl:choose>
5057
+ <xsl:when test="$width &gt; $width_effective_px">
5058
+ <xsl:value-of select="$width_effective_px div $width"/>
5059
+ </xsl:when>
5060
+ <xsl:otherwise>1</xsl:otherwise>
5061
+ </xsl:choose>
5062
+ </xsl:variable>
5063
+
5064
+ <xsl:variable name="scale_y">
5065
+ <xsl:choose>
5066
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
5067
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
5068
+ </xsl:when>
5069
+ <xsl:otherwise>1</xsl:otherwise>
5070
+ </xsl:choose>
5071
+ </xsl:variable>
5072
+
5073
+ <xsl:variable name="scale">
5074
+ <xsl:choose>
5075
+ <xsl:when test="$scale_y != 1">
5076
+ <xsl:value-of select="$scale_x * $scale_y"/>
5077
+ </xsl:when>
5078
+ <xsl:otherwise>
5079
+ <xsl:value-of select="$scale_x"/>
5080
+ </xsl:otherwise>
5081
+ </xsl:choose>
5082
+ </xsl:variable>
5083
+
5084
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
5085
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
5086
+
5087
+ <fo:table table-layout="fixed" width="100%">
5088
+ <fo:table-column column-width="proportional-column-width(1)"/>
5089
+ <fo:table-column column-width="{$width_scale}px"/>
5090
+ <fo:table-column column-width="proportional-column-width(1)"/>
5091
+ <fo:table-body>
5092
+ <fo:table-row>
5093
+ <fo:table-cell column-number="2">
5094
+ <fo:block>
5095
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
5096
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
5097
+ <fo:block line-height="0" font-size="0">
5098
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
5099
+ <xsl:call-template name="bookmark"/>
5100
+ </xsl:for-each>
5101
+ </fo:block>
5102
+ </xsl:if>
5103
+ <fo:block text-depth="0" line-height="0" font-size="0">
5104
+
5105
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
5106
+ <xsl:attribute name="width">100%</xsl:attribute>
5107
+ <xsl:attribute name="content-height">100%</xsl:attribute>
5108
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5109
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5110
+
5111
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
5112
+ </fo:instream-foreign-object>
5113
+ </fo:block>
5114
+
5115
+ <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">
5116
+ <xsl:with-param name="scale" select="$scale"/>
5117
+ </xsl:apply-templates>
5118
+ </fo:block-container>
5119
+ </fo:block>
5120
+ </fo:table-cell>
5121
+ </fo:table-row>
5122
+ </fo:table-body>
5123
+ </fo:table>
5124
+ </fo:block>
5125
+
5126
+ </xsl:when>
5127
+ <xsl:otherwise>
5128
+ <fo:block xsl:use-attribute-sets="image-style">
5129
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
5130
+ <xsl:attribute name="width">100%</xsl:attribute>
5131
+ <xsl:attribute name="content-height">100%</xsl:attribute>
5132
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5133
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
5134
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
5135
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
5136
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
5137
+ <!-- effective height / width = 1.48, 1.4 - with title -->
5138
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
5139
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
5140
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
5141
+ </xsl:if>
5142
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5143
+ <xsl:copy-of select="$svg_content"/>
5144
+ </fo:instream-foreign-object>
5145
+ </fo:block>
5146
+ </xsl:otherwise>
5147
+ </xsl:choose>
5148
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
5149
+ <xsl:copy>
5150
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
5151
+ </xsl:copy>
5152
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
5153
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
5154
+ <xsl:value-of select="."/>
5155
+ </xsl:attribute>
5156
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5157
+ <xsl:copy>
5158
+ <xsl:apply-templates select="@*" mode="svg_update"/>
5159
+ <xsl:variable name="viewbox">
5160
+ <xsl:call-template name="split">
5161
+ <xsl:with-param name="pText" select="@viewBox"/>
5162
+ <xsl:with-param name="sep" select="' '"/>
5163
+ </xsl:call-template>
5164
+ </xsl:variable>
5165
+ <xsl:attribute name="width">
5166
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
5167
+ </xsl:attribute>
5168
+ <xsl:attribute name="height">
5169
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
5170
+ </xsl:attribute>
5171
+ <xsl:apply-templates mode="svg_update"/>
5172
+ </xsl:copy>
5173
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
5174
+ <xsl:variable name="svg_content" select="document(@src)"/>
5175
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
5176
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
5177
+ <xsl:call-template name="image_svg">
5178
+ <xsl:with-param name="name" select="$name"/>
5179
+ </xsl:call-template>
5180
+ </xsl:for-each>
5181
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
5182
+ <xsl:copy>
5183
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
5184
+ </xsl:copy>
5185
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
5186
+ <xsl:apply-templates mode="svg_remove_a"/>
5187
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
5188
+ <xsl:param name="scale"/>
5189
+ <xsl:variable name="dest">
5190
+ <xsl:choose>
5191
+ <xsl:when test="starts-with(@href, '#')">
5192
+ <xsl:value-of select="substring-after(@href, '#')"/>
5193
+ </xsl:when>
5194
+ <xsl:otherwise>
5195
+ <xsl:value-of select="@href"/>
5196
+ </xsl:otherwise>
5197
+ </xsl:choose>
5198
+ </xsl:variable>
5199
+ <xsl:for-each select="./*[local-name() = 'rect']">
5200
+ <xsl:call-template name="insertSVGMapLink">
5201
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
5202
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
5203
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
5204
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
5205
+ <xsl:with-param name="dest" select="$dest"/>
5206
+ </xsl:call-template>
5207
+ </xsl:for-each>
5208
+
5209
+ <xsl:for-each select="./*[local-name() = 'polygon']">
5210
+ <xsl:variable name="points">
5211
+ <xsl:call-template name="split">
5212
+ <xsl:with-param name="pText" select="@points"/>
5213
+ </xsl:call-template>
5214
+ </xsl:variable>
5215
+ <xsl:variable name="x_coords">
5216
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
5217
+ <xsl:sort select="." data-type="number"/>
5218
+ <x><xsl:value-of select="."/></x>
5219
+ </xsl:for-each>
5220
+ </xsl:variable>
5221
+ <xsl:variable name="y_coords">
5222
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
5223
+ <xsl:sort select="." data-type="number"/>
5224
+ <y><xsl:value-of select="."/></y>
5225
+ </xsl:for-each>
5226
+ </xsl:variable>
5227
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
5228
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
5229
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
5230
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
5231
+ <xsl:call-template name="insertSVGMapLink">
5232
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
5233
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
5234
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
5235
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
5236
+ <xsl:with-param name="dest" select="$dest"/>
5237
+ </xsl:call-template>
5238
+ </xsl:for-each>
5239
+
5240
+ <xsl:for-each select="./*[local-name() = 'circle']">
5241
+ <xsl:call-template name="insertSVGMapLink">
5242
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
5243
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
5244
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
5245
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
5246
+ <xsl:with-param name="dest" select="$dest"/>
5247
+ </xsl:call-template>
5248
+ </xsl:for-each>
5249
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
5250
+ <xsl:call-template name="insertSVGMapLink">
5251
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
5252
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
5253
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
5254
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
5255
+ <xsl:with-param name="dest" select="$dest"/>
5256
+ </xsl:call-template>
5257
+ </xsl:for-each>
5258
+ </xsl:template><xsl:template name="insertSVGMapLink">
5259
+ <xsl:param name="left"/>
5260
+ <xsl:param name="top"/>
5261
+ <xsl:param name="width"/>
5262
+ <xsl:param name="height"/>
5263
+ <xsl:param name="dest"/>
5264
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
5265
+ <fo:block font-size="1pt">
5266
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
5267
+ <fo:inline-container inline-progression-dimension="100%">
5268
+ <fo:block-container height="{$height - 1}px" width="100%">
5269
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
5270
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
5271
+ </xsl:if> -->
5272
+ <fo:block> </fo:block></fo:block-container>
5273
+ </fo:inline-container>
5274
+ </fo:basic-link>
5275
+ </fo:block>
5276
+ </fo:block-container>
5019
5277
  </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">
5020
5278
  <xsl:apply-templates mode="contents"/>
5021
5279
  <xsl:text> </xsl:text>
@@ -5044,28 +5302,39 @@
5044
5302
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5045
5303
  <xsl:for-each select="xalan:nodeset($contents)/doc">
5046
5304
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5305
+ <xsl:if test="@bundle = 'true'">
5306
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
5307
+ </xsl:if>
5047
5308
  <fo:bookmark-title>
5048
- <xsl:variable name="bookmark-title_">
5049
- <xsl:call-template name="getLangVersion">
5050
- <xsl:with-param name="lang" select="@lang"/>
5051
- <xsl:with-param name="doctype" select="@doctype"/>
5052
- <xsl:with-param name="title" select="@title-part"/>
5053
- </xsl:call-template>
5054
- </xsl:variable>
5055
5309
  <xsl:choose>
5056
- <xsl:when test="normalize-space($bookmark-title_) != ''">
5057
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
5058
- </xsl:when>
5059
- <xsl:otherwise>
5310
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
5311
+ <xsl:variable name="bookmark-title_">
5312
+ <xsl:call-template name="getLangVersion">
5313
+ <xsl:with-param name="lang" select="@lang"/>
5314
+ <xsl:with-param name="doctype" select="@doctype"/>
5315
+ <xsl:with-param name="title" select="@title-part"/>
5316
+ </xsl:call-template>
5317
+ </xsl:variable>
5060
5318
  <xsl:choose>
5061
- <xsl:when test="@lang = 'en'">English</xsl:when>
5062
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
5063
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
5064
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
5319
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
5320
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
5321
+ </xsl:when>
5322
+ <xsl:otherwise>
5323
+ <xsl:choose>
5324
+ <xsl:when test="@lang = 'en'">English</xsl:when>
5325
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
5326
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
5327
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
5328
+ </xsl:choose>
5329
+ </xsl:otherwise>
5065
5330
  </xsl:choose>
5331
+ </xsl:when>
5332
+ <xsl:otherwise>
5333
+ <xsl:value-of select="@title-part"/>
5066
5334
  </xsl:otherwise>
5067
5335
  </xsl:choose>
5068
5336
  </fo:bookmark-title>
5337
+
5069
5338
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5070
5339
 
5071
5340
  <xsl:call-template name="insertFigureBookmarks">
@@ -5164,16 +5433,23 @@
5164
5433
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
5165
5434
  </xsl:choose>
5166
5435
  </xsl:template><xsl:template match="item" mode="bookmark">
5167
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
5168
- <fo:bookmark-title>
5169
- <xsl:if test="@section != ''">
5170
- <xsl:value-of select="@section"/>
5171
- <xsl:text> </xsl:text>
5172
- </xsl:if>
5173
- <xsl:value-of select="normalize-space(title)"/>
5174
- </fo:bookmark-title>
5175
- <xsl:apply-templates mode="bookmark"/>
5176
- </fo:bookmark>
5436
+ <xsl:choose>
5437
+ <xsl:when test="@id != ''">
5438
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
5439
+ <fo:bookmark-title>
5440
+ <xsl:if test="@section != ''">
5441
+ <xsl:value-of select="@section"/>
5442
+ <xsl:text> </xsl:text>
5443
+ </xsl:if>
5444
+ <xsl:value-of select="normalize-space(title)"/>
5445
+ </fo:bookmark-title>
5446
+ <xsl:apply-templates mode="bookmark"/>
5447
+ </fo:bookmark>
5448
+ </xsl:when>
5449
+ <xsl:otherwise>
5450
+ <xsl:apply-templates mode="bookmark"/>
5451
+ </xsl:otherwise>
5452
+ </xsl:choose>
5177
5453
  </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">
5178
5454
  <xsl:if test="normalize-space() != ''">
5179
5455
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -5539,7 +5815,19 @@
5539
5815
  </fo:inline>
5540
5816
  </xsl:if>
5541
5817
  </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'p']">
5542
- <fo:inline><xsl:apply-templates/></fo:inline>
5818
+ <xsl:variable name="element">inline
5819
+
5820
+ </xsl:variable>
5821
+ <xsl:choose>
5822
+ <xsl:when test="contains($element, 'block')">
5823
+ <fo:block xsl:use-attribute-sets="example-p-style">
5824
+ <xsl:apply-templates/>
5825
+ </fo:block>
5826
+ </xsl:when>
5827
+ <xsl:otherwise>
5828
+ <fo:inline><xsl:apply-templates/></fo:inline>
5829
+ </xsl:otherwise>
5830
+ </xsl:choose>
5543
5831
  </xsl:template><xsl:template match="*[local-name() = 'example']">
5544
5832
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
5545
5833
 
@@ -5745,7 +6033,9 @@
5745
6033
 
5746
6034
 
5747
6035
  </xsl:if>
5748
-
6036
+
6037
+
6038
+
5749
6039
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5750
6040
  <xsl:if test="normalize-space(@citeas) = ''">
5751
6041
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -5754,6 +6044,7 @@
5754
6044
 
5755
6045
 
5756
6046
 
6047
+
5757
6048
  </xsl:if>
5758
6049
 
5759
6050
  <xsl:apply-templates/>
@@ -6136,7 +6427,6 @@
6136
6427
  </xsl:template><xsl:template name="processBibitem">
6137
6428
 
6138
6429
 
6139
- <!-- end BIPM bibitem processing-->
6140
6430
 
6141
6431
 
6142
6432
 
@@ -6598,20 +6888,40 @@
6598
6888
  </xsl:call-template>
6599
6889
  </xsl:if>
6600
6890
  </xsl:template><xsl:template name="getLocalizedString">
6601
- <xsl:param name="key"/>
6891
+ <xsl:param name="key"/>
6892
+ <xsl:param name="formatted">false</xsl:param>
6602
6893
 
6603
6894
  <xsl:variable name="curr_lang">
6604
6895
  <xsl:call-template name="getLang"/>
6605
6896
  </xsl:variable>
6606
6897
 
6607
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
6898
+ <xsl:variable name="data_value">
6899
+ <xsl:choose>
6900
+ <xsl:when test="$formatted = 'true'">
6901
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6902
+ </xsl:when>
6903
+ <xsl:otherwise>
6904
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
6905
+ </xsl:otherwise>
6906
+ </xsl:choose>
6907
+ </xsl:variable>
6608
6908
 
6609
6909
  <xsl:choose>
6610
- <xsl:when test="$data_value != ''">
6611
- <xsl:value-of select="$data_value"/>
6910
+ <xsl:when test="normalize-space($data_value) != ''">
6911
+ <xsl:choose>
6912
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
6913
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
6914
+ </xsl:choose>
6612
6915
  </xsl:when>
6613
6916
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
6614
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6917
+ <xsl:choose>
6918
+ <xsl:when test="$formatted = 'true'">
6919
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6920
+ </xsl:when>
6921
+ <xsl:otherwise>
6922
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
6923
+ </xsl:otherwise>
6924
+ </xsl:choose>
6615
6925
  </xsl:when>
6616
6926
  <xsl:otherwise>
6617
6927
  <xsl:variable name="key_">
@@ -6622,7 +6932,7 @@
6622
6932
  <xsl:value-of select="$key_"/>
6623
6933
  </xsl:otherwise>
6624
6934
  </xsl:choose>
6625
-
6935
+
6626
6936
  </xsl:template><xsl:template name="setTrackChangesStyles">
6627
6937
  <xsl:param name="isAdded"/>
6628
6938
  <xsl:param name="isDeleted"/>
@@ -6673,4 +6983,100 @@
6673
6983
  <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
6674
6984
  </xsl:choose>
6675
6985
  </xsl:attribute>
6986
+ </xsl:template><xsl:template name="number-to-words">
6987
+ <xsl:param name="number"/>
6988
+ <xsl:param name="first"/>
6989
+ <xsl:if test="$number != ''">
6990
+ <xsl:variable name="words">
6991
+ <words>
6992
+ <word cardinal="1">One-</word>
6993
+ <word ordinal="1">First </word>
6994
+ <word cardinal="2">Two-</word>
6995
+ <word ordinal="2">Second </word>
6996
+ <word cardinal="3">Three-</word>
6997
+ <word ordinal="3">Third </word>
6998
+ <word cardinal="4">Four-</word>
6999
+ <word ordinal="4">Fourth </word>
7000
+ <word cardinal="5">Five-</word>
7001
+ <word ordinal="5">Fifth </word>
7002
+ <word cardinal="6">Six-</word>
7003
+ <word ordinal="6">Sixth </word>
7004
+ <word cardinal="7">Seven-</word>
7005
+ <word ordinal="7">Seventh </word>
7006
+ <word cardinal="8">Eight-</word>
7007
+ <word ordinal="8">Eighth </word>
7008
+ <word cardinal="9">Nine-</word>
7009
+ <word ordinal="9">Ninth </word>
7010
+ <word ordinal="10">Tenth </word>
7011
+ <word ordinal="11">Eleventh </word>
7012
+ <word ordinal="12">Twelfth </word>
7013
+ <word ordinal="13">Thirteenth </word>
7014
+ <word ordinal="14">Fourteenth </word>
7015
+ <word ordinal="15">Fifteenth </word>
7016
+ <word ordinal="16">Sixteenth </word>
7017
+ <word ordinal="17">Seventeenth </word>
7018
+ <word ordinal="18">Eighteenth </word>
7019
+ <word ordinal="19">Nineteenth </word>
7020
+ <word cardinal="20">Twenty-</word>
7021
+ <word ordinal="20">Twentieth </word>
7022
+ <word cardinal="30">Thirty-</word>
7023
+ <word ordinal="30">Thirtieth </word>
7024
+ <word cardinal="40">Forty-</word>
7025
+ <word ordinal="40">Fortieth </word>
7026
+ <word cardinal="50">Fifty-</word>
7027
+ <word ordinal="50">Fiftieth </word>
7028
+ <word cardinal="60">Sixty-</word>
7029
+ <word ordinal="60">Sixtieth </word>
7030
+ <word cardinal="70">Seventy-</word>
7031
+ <word ordinal="70">Seventieth </word>
7032
+ <word cardinal="80">Eighty-</word>
7033
+ <word ordinal="80">Eightieth </word>
7034
+ <word cardinal="90">Ninety-</word>
7035
+ <word ordinal="90">Ninetieth </word>
7036
+ <word cardinal="100">Hundred-</word>
7037
+ <word ordinal="100">Hundredth </word>
7038
+ </words>
7039
+ </xsl:variable>
7040
+
7041
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
7042
+
7043
+ <xsl:variable name="value">
7044
+ <xsl:choose>
7045
+ <xsl:when test="$ordinal != ''">
7046
+ <xsl:value-of select="$ordinal"/>
7047
+ </xsl:when>
7048
+ <xsl:otherwise>
7049
+ <xsl:choose>
7050
+ <xsl:when test="$number &lt; 100">
7051
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
7052
+ <xsl:variable name="digit" select="substring($number,2)"/>
7053
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
7054
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
7055
+ </xsl:when>
7056
+ <xsl:otherwise>
7057
+ <!-- more 100 -->
7058
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
7059
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
7060
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
7061
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
7062
+ <xsl:call-template name="number-to-words">
7063
+ <xsl:with-param name="number" select="$digits"/>
7064
+ </xsl:call-template>
7065
+ </xsl:otherwise>
7066
+ </xsl:choose>
7067
+ </xsl:otherwise>
7068
+ </xsl:choose>
7069
+ </xsl:variable>
7070
+ <xsl:choose>
7071
+ <xsl:when test="$first = 'true'">
7072
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
7073
+ <xsl:call-template name="capitalize">
7074
+ <xsl:with-param name="str" select="$value_lc"/>
7075
+ </xsl:call-template>
7076
+ </xsl:when>
7077
+ <xsl:otherwise>
7078
+ <xsl:value-of select="$value"/>
7079
+ </xsl:otherwise>
7080
+ </xsl:choose>
7081
+ </xsl:if>
6676
7082
  </xsl:template></xsl:stylesheet>