metanorma-bipm 1.1.4 → 1.1.5

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>
@@ -2426,6 +2348,7 @@
2426
2348
 
2427
2349
 
2428
2350
 
2351
+
2429
2352
  </xsl:attribute-set><xsl:attribute-set name="note-style">
2430
2353
 
2431
2354
 
@@ -2648,14 +2571,15 @@
2648
2571
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
2649
2572
 
2650
2573
  <!-- Normative references -->
2651
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
2574
+ <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
2575
  <!-- Terms and definitions -->
2653
2576
  <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
2577
  <!-- Another main sections -->
2655
2578
  <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
2579
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
2657
2580
  <!-- Bibliography -->
2658
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
2581
+ <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"/>
2582
+
2659
2583
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2660
2584
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
2661
2585
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -3264,6 +3188,7 @@
3264
3188
  <fo:table-row>
3265
3189
  <fo:table-cell border="solid black 1pt" padding-left="1mm" padding-right="1mm" padding-top="1mm" number-columns-spanned="{$cols-count}">
3266
3190
 
3191
+
3267
3192
  <xsl:attribute name="border-top">solid black 0pt</xsl:attribute>
3268
3193
 
3269
3194
 
@@ -3276,6 +3201,10 @@
3276
3201
 
3277
3202
 
3278
3203
 
3204
+
3205
+ <!-- for BSI (not PAS) display Notes before footnotes -->
3206
+
3207
+
3279
3208
  <!-- except gb -->
3280
3209
 
3281
3210
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -3301,6 +3230,10 @@
3301
3230
  <!-- fn processing -->
3302
3231
  <xsl:call-template name="fn_display"/>
3303
3232
 
3233
+
3234
+ <!-- for PAS display Notes after footnotes -->
3235
+
3236
+
3304
3237
  </fo:table-cell>
3305
3238
  </fo:table-row>
3306
3239
  </fo:table-body>
@@ -3409,6 +3342,7 @@
3409
3342
  </xsl:if>
3410
3343
  <xsl:if test="$parent-name = 'tfoot'">
3411
3344
 
3345
+
3412
3346
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3413
3347
  <xsl:attribute name="border-left">solid black 1pt</xsl:attribute>
3414
3348
  <xsl:attribute name="border-right">solid black 1pt</xsl:attribute>
@@ -3502,6 +3436,7 @@
3502
3436
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
3503
3437
 
3504
3438
 
3439
+
3505
3440
  <xsl:if test="count(*) = 1 and (local-name(*[1]) = 'stem' or local-name(*[1]) = 'figure')">
3506
3441
  <xsl:attribute name="padding-left">0mm</xsl:attribute>
3507
3442
  </xsl:if>
@@ -3547,6 +3482,7 @@
3547
3482
 
3548
3483
  <fo:block font-size="10pt" margin-bottom="12pt">
3549
3484
 
3485
+
3550
3486
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3551
3487
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
3552
3488
 
@@ -3555,8 +3491,13 @@
3555
3491
 
3556
3492
 
3557
3493
 
3494
+
3495
+ <!-- Table's note name (NOTE, for example) -->
3496
+
3558
3497
  <fo:inline padding-right="2mm">
3559
3498
 
3499
+
3500
+
3560
3501
 
3561
3502
 
3562
3503
 
@@ -3564,6 +3505,8 @@
3564
3505
 
3565
3506
  </fo:inline>
3566
3507
 
3508
+
3509
+
3567
3510
  <xsl:apply-templates mode="process"/>
3568
3511
  </fo:block>
3569
3512
 
@@ -3583,6 +3526,8 @@
3583
3526
  <xsl:variable name="reference" select="@reference"/>
3584
3527
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3585
3528
  <fo:block margin-bottom="12pt">
3529
+
3530
+
3586
3531
 
3587
3532
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3588
3533
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
@@ -3601,9 +3546,11 @@
3601
3546
 
3602
3547
 
3603
3548
 
3549
+
3604
3550
  <xsl:value-of select="@reference"/>
3605
3551
 
3606
3552
 
3553
+
3607
3554
  </fo:inline>
3608
3555
  <fo:inline>
3609
3556
 
@@ -3739,6 +3686,8 @@
3739
3686
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
3740
3687
  <fo:inline font-size="80%" keep-with-previous.within-line="always">
3741
3688
 
3689
+
3690
+
3742
3691
  <xsl:if test="ancestor::*[local-name()='td']">
3743
3692
  <xsl:attribute name="font-weight">normal</xsl:attribute>
3744
3693
  <!-- <xsl:attribute name="alignment-baseline">hanging</xsl:attribute> -->
@@ -3751,11 +3700,13 @@
3751
3700
 
3752
3701
 
3753
3702
 
3703
+
3754
3704
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
3755
3705
 
3756
3706
 
3757
3707
  <xsl:value-of select="@reference"/>
3758
3708
 
3709
+
3759
3710
  </fo:basic-link>
3760
3711
  </fo:inline>
3761
3712
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -4666,6 +4617,7 @@
4666
4617
  <fo:inline xsl:use-attribute-sets="link-style">
4667
4618
 
4668
4619
 
4620
+
4669
4621
  <xsl:choose>
4670
4622
  <xsl:when test="$target_text = ''">
4671
4623
  <xsl:apply-templates/>
@@ -4774,6 +4726,7 @@
4774
4726
 
4775
4727
 
4776
4728
 
4729
+
4777
4730
  <fo:block-container margin-left="0mm">
4778
4731
 
4779
4732
 
@@ -5016,6 +4969,234 @@
5016
4969
  <xsl:param name="height"/>
5017
4970
  <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
4971
  <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; "/>
4972
+ </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">
4973
+ <xsl:param name="name"/>
4974
+
4975
+ <xsl:variable name="svg_content">
4976
+ <xsl:apply-templates select="." mode="svg_update"/>
4977
+ </xsl:variable>
4978
+
4979
+ <xsl:variable name="alt-text">
4980
+ <xsl:choose>
4981
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
4982
+ <xsl:value-of select="../*[local-name() = 'name']"/>
4983
+ </xsl:when>
4984
+ <xsl:when test="normalize-space($name) != ''">
4985
+ <xsl:value-of select="$name"/>
4986
+ </xsl:when>
4987
+ <xsl:otherwise>Figure</xsl:otherwise>
4988
+ </xsl:choose>
4989
+ </xsl:variable>
4990
+
4991
+ <xsl:choose>
4992
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
4993
+ <fo:block>
4994
+ <xsl:variable name="width" select="@width"/>
4995
+ <xsl:variable name="height" select="@height"/>
4996
+
4997
+ <xsl:variable name="scale_x">
4998
+ <xsl:choose>
4999
+ <xsl:when test="$width &gt; $width_effective_px">
5000
+ <xsl:value-of select="$width_effective_px div $width"/>
5001
+ </xsl:when>
5002
+ <xsl:otherwise>1</xsl:otherwise>
5003
+ </xsl:choose>
5004
+ </xsl:variable>
5005
+
5006
+ <xsl:variable name="scale_y">
5007
+ <xsl:choose>
5008
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
5009
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
5010
+ </xsl:when>
5011
+ <xsl:otherwise>1</xsl:otherwise>
5012
+ </xsl:choose>
5013
+ </xsl:variable>
5014
+
5015
+ <xsl:variable name="scale">
5016
+ <xsl:choose>
5017
+ <xsl:when test="$scale_y != 1">
5018
+ <xsl:value-of select="$scale_x * $scale_y"/>
5019
+ </xsl:when>
5020
+ <xsl:otherwise>
5021
+ <xsl:value-of select="$scale_x"/>
5022
+ </xsl:otherwise>
5023
+ </xsl:choose>
5024
+ </xsl:variable>
5025
+
5026
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
5027
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
5028
+
5029
+ <fo:table table-layout="fixed" width="100%">
5030
+ <fo:table-column column-width="proportional-column-width(1)"/>
5031
+ <fo:table-column column-width="{$width_scale}px"/>
5032
+ <fo:table-column column-width="proportional-column-width(1)"/>
5033
+ <fo:table-body>
5034
+ <fo:table-row>
5035
+ <fo:table-cell column-number="2">
5036
+ <fo:block>
5037
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
5038
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
5039
+ <fo:block line-height="0" font-size="0">
5040
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
5041
+ <xsl:call-template name="bookmark"/>
5042
+ </xsl:for-each>
5043
+ </fo:block>
5044
+ </xsl:if>
5045
+ <fo:block text-depth="0" line-height="0" font-size="0">
5046
+
5047
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
5048
+ <xsl:attribute name="width">100%</xsl:attribute>
5049
+ <xsl:attribute name="content-height">100%</xsl:attribute>
5050
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5051
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5052
+
5053
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
5054
+ </fo:instream-foreign-object>
5055
+ </fo:block>
5056
+
5057
+ <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">
5058
+ <xsl:with-param name="scale" select="$scale"/>
5059
+ </xsl:apply-templates>
5060
+ </fo:block-container>
5061
+ </fo:block>
5062
+ </fo:table-cell>
5063
+ </fo:table-row>
5064
+ </fo:table-body>
5065
+ </fo:table>
5066
+ </fo:block>
5067
+
5068
+ </xsl:when>
5069
+ <xsl:otherwise>
5070
+ <fo:block xsl:use-attribute-sets="image-style">
5071
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
5072
+ <xsl:attribute name="width">100%</xsl:attribute>
5073
+ <xsl:attribute name="content-height">100%</xsl:attribute>
5074
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5075
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
5076
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
5077
+ <!-- effective height / width = 1.48, 1.4 - with title -->
5078
+ <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
5079
+ <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
5080
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
5081
+ </xsl:if>
5082
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5083
+ <xsl:copy-of select="$svg_content"/>
5084
+ </fo:instream-foreign-object>
5085
+ </fo:block>
5086
+ </xsl:otherwise>
5087
+ </xsl:choose>
5088
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
5089
+ <xsl:copy>
5090
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
5091
+ </xsl:copy>
5092
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
5093
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
5094
+ <xsl:value-of select="."/>
5095
+ </xsl:attribute>
5096
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
5097
+ <xsl:variable name="svg_content" select="document(@src)"/>
5098
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
5099
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
5100
+ <xsl:call-template name="image_svg">
5101
+ <xsl:with-param name="name" select="$name"/>
5102
+ </xsl:call-template>
5103
+ </xsl:for-each>
5104
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
5105
+ <xsl:copy>
5106
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
5107
+ </xsl:copy>
5108
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
5109
+ <xsl:apply-templates mode="svg_remove_a"/>
5110
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
5111
+ <xsl:param name="scale"/>
5112
+ <xsl:variable name="dest">
5113
+ <xsl:choose>
5114
+ <xsl:when test="starts-with(@href, '#')">
5115
+ <xsl:value-of select="substring-after(@href, '#')"/>
5116
+ </xsl:when>
5117
+ <xsl:otherwise>
5118
+ <xsl:value-of select="@href"/>
5119
+ </xsl:otherwise>
5120
+ </xsl:choose>
5121
+ </xsl:variable>
5122
+ <xsl:for-each select="./*[local-name() = 'rect']">
5123
+ <xsl:call-template name="insertSVGMapLink">
5124
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
5125
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
5126
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
5127
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
5128
+ <xsl:with-param name="dest" select="$dest"/>
5129
+ </xsl:call-template>
5130
+ </xsl:for-each>
5131
+
5132
+ <xsl:for-each select="./*[local-name() = 'polygon']">
5133
+ <xsl:variable name="points">
5134
+ <xsl:call-template name="split">
5135
+ <xsl:with-param name="pText" select="@points"/>
5136
+ </xsl:call-template>
5137
+ </xsl:variable>
5138
+ <xsl:variable name="x_coords">
5139
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
5140
+ <xsl:sort select="." data-type="number"/>
5141
+ <x><xsl:value-of select="."/></x>
5142
+ </xsl:for-each>
5143
+ </xsl:variable>
5144
+ <xsl:variable name="y_coords">
5145
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
5146
+ <xsl:sort select="." data-type="number"/>
5147
+ <y><xsl:value-of select="."/></y>
5148
+ </xsl:for-each>
5149
+ </xsl:variable>
5150
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
5151
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
5152
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
5153
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
5154
+ <xsl:call-template name="insertSVGMapLink">
5155
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
5156
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
5157
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
5158
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
5159
+ <xsl:with-param name="dest" select="$dest"/>
5160
+ </xsl:call-template>
5161
+ </xsl:for-each>
5162
+
5163
+ <xsl:for-each select="./*[local-name() = 'circle']">
5164
+ <xsl:call-template name="insertSVGMapLink">
5165
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
5166
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
5167
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
5168
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
5169
+ <xsl:with-param name="dest" select="$dest"/>
5170
+ </xsl:call-template>
5171
+ </xsl:for-each>
5172
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
5173
+ <xsl:call-template name="insertSVGMapLink">
5174
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
5175
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
5176
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
5177
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
5178
+ <xsl:with-param name="dest" select="$dest"/>
5179
+ </xsl:call-template>
5180
+ </xsl:for-each>
5181
+ </xsl:template><xsl:template name="insertSVGMapLink">
5182
+ <xsl:param name="left"/>
5183
+ <xsl:param name="top"/>
5184
+ <xsl:param name="width"/>
5185
+ <xsl:param name="height"/>
5186
+ <xsl:param name="dest"/>
5187
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
5188
+ <fo:block font-size="1pt">
5189
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
5190
+ <fo:inline-container inline-progression-dimension="100%">
5191
+ <fo:block-container height="{$height - 1}px" width="100%">
5192
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
5193
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
5194
+ </xsl:if> -->
5195
+ <fo:block> </fo:block></fo:block-container>
5196
+ </fo:inline-container>
5197
+ </fo:basic-link>
5198
+ </fo:block>
5199
+ </fo:block-container>
5019
5200
  </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
5201
  <xsl:apply-templates mode="contents"/>
5021
5202
  <xsl:text> </xsl:text>
@@ -5044,28 +5225,39 @@
5044
5225
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5045
5226
  <xsl:for-each select="xalan:nodeset($contents)/doc">
5046
5227
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5228
+ <xsl:if test="@bundle = 'true'">
5229
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
5230
+ </xsl:if>
5047
5231
  <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
5232
  <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>
5233
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
5234
+ <xsl:variable name="bookmark-title_">
5235
+ <xsl:call-template name="getLangVersion">
5236
+ <xsl:with-param name="lang" select="@lang"/>
5237
+ <xsl:with-param name="doctype" select="@doctype"/>
5238
+ <xsl:with-param name="title" select="@title-part"/>
5239
+ </xsl:call-template>
5240
+ </xsl:variable>
5060
5241
  <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>
5242
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
5243
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
5244
+ </xsl:when>
5245
+ <xsl:otherwise>
5246
+ <xsl:choose>
5247
+ <xsl:when test="@lang = 'en'">English</xsl:when>
5248
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
5249
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
5250
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
5251
+ </xsl:choose>
5252
+ </xsl:otherwise>
5065
5253
  </xsl:choose>
5254
+ </xsl:when>
5255
+ <xsl:otherwise>
5256
+ <xsl:value-of select="@title-part"/>
5066
5257
  </xsl:otherwise>
5067
5258
  </xsl:choose>
5068
5259
  </fo:bookmark-title>
5260
+
5069
5261
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5070
5262
 
5071
5263
  <xsl:call-template name="insertFigureBookmarks">
@@ -5164,16 +5356,23 @@
5164
5356
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
5165
5357
  </xsl:choose>
5166
5358
  </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>
5359
+ <xsl:choose>
5360
+ <xsl:when test="@id != ''">
5361
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
5362
+ <fo:bookmark-title>
5363
+ <xsl:if test="@section != ''">
5364
+ <xsl:value-of select="@section"/>
5365
+ <xsl:text> </xsl:text>
5366
+ </xsl:if>
5367
+ <xsl:value-of select="normalize-space(title)"/>
5368
+ </fo:bookmark-title>
5369
+ <xsl:apply-templates mode="bookmark"/>
5370
+ </fo:bookmark>
5371
+ </xsl:when>
5372
+ <xsl:otherwise>
5373
+ <xsl:apply-templates mode="bookmark"/>
5374
+ </xsl:otherwise>
5375
+ </xsl:choose>
5177
5376
  </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
5377
  <xsl:if test="normalize-space() != ''">
5179
5378
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -5745,7 +5944,9 @@
5745
5944
 
5746
5945
 
5747
5946
  </xsl:if>
5748
-
5947
+
5948
+
5949
+
5749
5950
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
5750
5951
  <xsl:if test="normalize-space(@citeas) = ''">
5751
5952
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -5754,6 +5955,7 @@
5754
5955
 
5755
5956
 
5756
5957
 
5958
+
5757
5959
  </xsl:if>
5758
5960
 
5759
5961
  <xsl:apply-templates/>
@@ -6673,4 +6875,100 @@
6673
6875
  <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
6674
6876
  </xsl:choose>
6675
6877
  </xsl:attribute>
6878
+ </xsl:template><xsl:template name="number-to-words">
6879
+ <xsl:param name="number"/>
6880
+ <xsl:param name="first"/>
6881
+ <xsl:if test="$number != ''">
6882
+ <xsl:variable name="words">
6883
+ <words>
6884
+ <word cardinal="1">One-</word>
6885
+ <word ordinal="1">First </word>
6886
+ <word cardinal="2">Two-</word>
6887
+ <word ordinal="2">Second </word>
6888
+ <word cardinal="3">Three-</word>
6889
+ <word ordinal="3">Third </word>
6890
+ <word cardinal="4">Four-</word>
6891
+ <word ordinal="4">Fourth </word>
6892
+ <word cardinal="5">Five-</word>
6893
+ <word ordinal="5">Fifth </word>
6894
+ <word cardinal="6">Six-</word>
6895
+ <word ordinal="6">Sixth </word>
6896
+ <word cardinal="7">Seven-</word>
6897
+ <word ordinal="7">Seventh </word>
6898
+ <word cardinal="8">Eight-</word>
6899
+ <word ordinal="8">Eighth </word>
6900
+ <word cardinal="9">Nine-</word>
6901
+ <word ordinal="9">Ninth </word>
6902
+ <word ordinal="10">Tenth </word>
6903
+ <word ordinal="11">Eleventh </word>
6904
+ <word ordinal="12">Twelfth </word>
6905
+ <word ordinal="13">Thirteenth </word>
6906
+ <word ordinal="14">Fourteenth </word>
6907
+ <word ordinal="15">Fifteenth </word>
6908
+ <word ordinal="16">Sixteenth </word>
6909
+ <word ordinal="17">Seventeenth </word>
6910
+ <word ordinal="18">Eighteenth </word>
6911
+ <word ordinal="19">Nineteenth </word>
6912
+ <word cardinal="20">Twenty-</word>
6913
+ <word ordinal="20">Twentieth </word>
6914
+ <word cardinal="30">Thirty-</word>
6915
+ <word ordinal="30">Thirtieth </word>
6916
+ <word cardinal="40">Forty-</word>
6917
+ <word ordinal="40">Fortieth </word>
6918
+ <word cardinal="50">Fifty-</word>
6919
+ <word ordinal="50">Fiftieth </word>
6920
+ <word cardinal="60">Sixty-</word>
6921
+ <word ordinal="60">Sixtieth </word>
6922
+ <word cardinal="70">Seventy-</word>
6923
+ <word ordinal="70">Seventieth </word>
6924
+ <word cardinal="80">Eighty-</word>
6925
+ <word ordinal="80">Eightieth </word>
6926
+ <word cardinal="90">Ninety-</word>
6927
+ <word ordinal="90">Ninetieth </word>
6928
+ <word cardinal="100">Hundred-</word>
6929
+ <word ordinal="100">Hundredth </word>
6930
+ </words>
6931
+ </xsl:variable>
6932
+
6933
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
6934
+
6935
+ <xsl:variable name="value">
6936
+ <xsl:choose>
6937
+ <xsl:when test="$ordinal != ''">
6938
+ <xsl:value-of select="$ordinal"/>
6939
+ </xsl:when>
6940
+ <xsl:otherwise>
6941
+ <xsl:choose>
6942
+ <xsl:when test="$number &lt; 100">
6943
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
6944
+ <xsl:variable name="digit" select="substring($number,2)"/>
6945
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
6946
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
6947
+ </xsl:when>
6948
+ <xsl:otherwise>
6949
+ <!-- more 100 -->
6950
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
6951
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
6952
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
6953
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
6954
+ <xsl:call-template name="number-to-words">
6955
+ <xsl:with-param name="number" select="$digits"/>
6956
+ </xsl:call-template>
6957
+ </xsl:otherwise>
6958
+ </xsl:choose>
6959
+ </xsl:otherwise>
6960
+ </xsl:choose>
6961
+ </xsl:variable>
6962
+ <xsl:choose>
6963
+ <xsl:when test="$first = 'true'">
6964
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
6965
+ <xsl:call-template name="capitalize">
6966
+ <xsl:with-param name="str" select="$value_lc"/>
6967
+ </xsl:call-template>
6968
+ </xsl:when>
6969
+ <xsl:otherwise>
6970
+ <xsl:value-of select="$value"/>
6971
+ </xsl:otherwise>
6972
+ </xsl:choose>
6973
+ </xsl:if>
6676
6974
  </xsl:template></xsl:stylesheet>