metanorma-un 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,12 @@
11
11
 
12
12
 
13
13
 
14
- <xsl:variable name="pageWidth" select="'210mm'"/>
15
- <xsl:variable name="pageHeight" select="'297mm'"/>
14
+ <xsl:variable name="pageWidth" select="210"/>
15
+ <xsl:variable name="pageHeight" select="297"/>
16
+ <xsl:variable name="marginLeftRight1" select="40"/>
17
+ <xsl:variable name="marginLeftRight2" select="40"/>
18
+ <xsl:variable name="marginTop" select="30"/>
19
+ <xsl:variable name="marginBottom" select="40"/>
16
20
 
17
21
  <xsl:variable name="debug">false</xsl:variable>
18
22
 
@@ -42,7 +46,7 @@
42
46
  <fo:root font-family="Times New Roman, STIX Two Math, Source Han Sans" font-size="10pt" xml:lang="{$lang}">
43
47
  <fo:layout-master-set>
44
48
  <!-- Cover page -->
45
- <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}" page-height="{$pageHeight}">
49
+ <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
46
50
  <fo:region-body margin-top="17.5mm" margin-bottom="10mm" margin-left="20mm" margin-right="20mm"/>
47
51
  <fo:region-before extent="17.5mm"/>
48
52
  <fo:region-after extent="10mm"/>
@@ -51,20 +55,20 @@
51
55
  </fo:simple-page-master>
52
56
 
53
57
  <!-- Document odd pages -->
54
- <fo:simple-page-master master-name="odd" page-width="{$pageWidth}" page-height="{$pageHeight}">
55
- <fo:region-body margin-top="30mm" margin-bottom="40mm" margin-left="40mm" margin-right="40mm"/>
58
+ <fo:simple-page-master master-name="odd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
59
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
56
60
  <fo:region-before region-name="header-odd" extent="26mm"/>
57
- <fo:region-after region-name="footer-odd" extent="40mm"/>
58
- <fo:region-start region-name="left-region" extent="40mm"/>
59
- <fo:region-end region-name="right-region" extent="40mm"/>
61
+ <fo:region-after region-name="footer-odd" extent="{$marginBottom}mm"/>
62
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
63
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
60
64
  </fo:simple-page-master>
61
65
  <!-- Document even pages -->
62
- <fo:simple-page-master master-name="even" page-width="{$pageWidth}" page-height="{$pageHeight}">
63
- <fo:region-body margin-top="30mm" margin-bottom="40mm" margin-left="40mm" margin-right="40mm"/>
66
+ <fo:simple-page-master master-name="even" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
67
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight2}mm" margin-right="{$marginLeftRight1}mm"/>
64
68
  <fo:region-before region-name="header-even" extent="26mm"/>
65
- <fo:region-after region-name="footer-even" extent="40mm"/>
66
- <fo:region-start region-name="left-region" extent="40mm"/>
67
- <fo:region-end region-name="right-region" extent="40mm"/>
69
+ <fo:region-after region-name="footer-even" extent="{$marginBottom}mm"/>
70
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight2}mm"/>
71
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight1}mm"/>
68
72
  </fo:simple-page-master>
69
73
  <fo:page-sequence-master master-name="document">
70
74
  <fo:repeatable-page-master-alternatives>
@@ -1516,6 +1520,7 @@
1516
1520
 
1517
1521
 
1518
1522
 
1523
+
1519
1524
  <xsl:attribute name="color">blue</xsl:attribute>
1520
1525
 
1521
1526
 
@@ -1720,14 +1725,15 @@
1720
1725
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1721
1726
 
1722
1727
  <!-- Normative references -->
1723
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1728
+ <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"/>
1724
1729
  <!-- Terms and definitions -->
1725
1730
  <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"/>
1726
1731
  <!-- Another main sections -->
1727
1732
  <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"/>
1728
1733
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1729
1734
  <!-- Bibliography -->
1730
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1735
+ <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"/>
1736
+
1731
1737
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1732
1738
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1733
1739
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -2515,6 +2521,7 @@
2515
2521
 
2516
2522
 
2517
2523
 
2524
+
2518
2525
  <xsl:attribute name="display-align">before</xsl:attribute>
2519
2526
  <xsl:attribute name="padding-left">0mm</xsl:attribute>
2520
2527
  <xsl:attribute name="padding-top">2mm</xsl:attribute>
@@ -2557,6 +2564,7 @@
2557
2564
 
2558
2565
 
2559
2566
 
2567
+
2560
2568
  <fo:inline padding-right="2mm">
2561
2569
 
2562
2570
 
@@ -2610,6 +2618,7 @@
2610
2618
 
2611
2619
 
2612
2620
 
2621
+
2613
2622
  <xsl:value-of select="@reference"/>
2614
2623
 
2615
2624
 
@@ -2754,6 +2763,9 @@
2754
2763
 
2755
2764
 
2756
2765
 
2766
+
2767
+
2768
+
2757
2769
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2758
2770
 
2759
2771
 
@@ -3653,6 +3665,7 @@
3653
3665
  <fo:inline xsl:use-attribute-sets="link-style">
3654
3666
 
3655
3667
 
3668
+
3656
3669
  <xsl:choose>
3657
3670
  <xsl:when test="$target_text = ''">
3658
3671
  <xsl:apply-templates/>
@@ -4014,6 +4027,234 @@
4014
4027
  <xsl:param name="height"/>
4015
4028
  <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; "/>
4016
4029
  <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; "/>
4030
+ </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">
4031
+ <xsl:param name="name"/>
4032
+
4033
+ <xsl:variable name="svg_content">
4034
+ <xsl:apply-templates select="." mode="svg_update"/>
4035
+ </xsl:variable>
4036
+
4037
+ <xsl:variable name="alt-text">
4038
+ <xsl:choose>
4039
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
4040
+ <xsl:value-of select="../*[local-name() = 'name']"/>
4041
+ </xsl:when>
4042
+ <xsl:when test="normalize-space($name) != ''">
4043
+ <xsl:value-of select="$name"/>
4044
+ </xsl:when>
4045
+ <xsl:otherwise>Figure</xsl:otherwise>
4046
+ </xsl:choose>
4047
+ </xsl:variable>
4048
+
4049
+ <xsl:choose>
4050
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
4051
+ <fo:block>
4052
+ <xsl:variable name="width" select="@width"/>
4053
+ <xsl:variable name="height" select="@height"/>
4054
+
4055
+ <xsl:variable name="scale_x">
4056
+ <xsl:choose>
4057
+ <xsl:when test="$width &gt; $width_effective_px">
4058
+ <xsl:value-of select="$width_effective_px div $width"/>
4059
+ </xsl:when>
4060
+ <xsl:otherwise>1</xsl:otherwise>
4061
+ </xsl:choose>
4062
+ </xsl:variable>
4063
+
4064
+ <xsl:variable name="scale_y">
4065
+ <xsl:choose>
4066
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
4067
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
4068
+ </xsl:when>
4069
+ <xsl:otherwise>1</xsl:otherwise>
4070
+ </xsl:choose>
4071
+ </xsl:variable>
4072
+
4073
+ <xsl:variable name="scale">
4074
+ <xsl:choose>
4075
+ <xsl:when test="$scale_y != 1">
4076
+ <xsl:value-of select="$scale_x * $scale_y"/>
4077
+ </xsl:when>
4078
+ <xsl:otherwise>
4079
+ <xsl:value-of select="$scale_x"/>
4080
+ </xsl:otherwise>
4081
+ </xsl:choose>
4082
+ </xsl:variable>
4083
+
4084
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
4085
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
4086
+
4087
+ <fo:table table-layout="fixed" width="100%">
4088
+ <fo:table-column column-width="proportional-column-width(1)"/>
4089
+ <fo:table-column column-width="{$width_scale}px"/>
4090
+ <fo:table-column column-width="proportional-column-width(1)"/>
4091
+ <fo:table-body>
4092
+ <fo:table-row>
4093
+ <fo:table-cell column-number="2">
4094
+ <fo:block>
4095
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
4096
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
4097
+ <fo:block line-height="0" font-size="0">
4098
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
4099
+ <xsl:call-template name="bookmark"/>
4100
+ </xsl:for-each>
4101
+ </fo:block>
4102
+ </xsl:if>
4103
+ <fo:block text-depth="0" line-height="0" font-size="0">
4104
+
4105
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4106
+ <xsl:attribute name="width">100%</xsl:attribute>
4107
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4108
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4109
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4110
+
4111
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
4112
+ </fo:instream-foreign-object>
4113
+ </fo:block>
4114
+
4115
+ <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">
4116
+ <xsl:with-param name="scale" select="$scale"/>
4117
+ </xsl:apply-templates>
4118
+ </fo:block-container>
4119
+ </fo:block>
4120
+ </fo:table-cell>
4121
+ </fo:table-row>
4122
+ </fo:table-body>
4123
+ </fo:table>
4124
+ </fo:block>
4125
+
4126
+ </xsl:when>
4127
+ <xsl:otherwise>
4128
+ <fo:block xsl:use-attribute-sets="image-style">
4129
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4130
+ <xsl:attribute name="width">100%</xsl:attribute>
4131
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4132
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4133
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4134
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4135
+ <!-- effective height / width = 1.48, 1.4 - with title -->
4136
+ <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
4137
+ <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
4138
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4139
+ </xsl:if>
4140
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4141
+ <xsl:copy-of select="$svg_content"/>
4142
+ </fo:instream-foreign-object>
4143
+ </fo:block>
4144
+ </xsl:otherwise>
4145
+ </xsl:choose>
4146
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
4147
+ <xsl:copy>
4148
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
4149
+ </xsl:copy>
4150
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
4151
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4152
+ <xsl:value-of select="."/>
4153
+ </xsl:attribute>
4154
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4155
+ <xsl:variable name="svg_content" select="document(@src)"/>
4156
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
4157
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
4158
+ <xsl:call-template name="image_svg">
4159
+ <xsl:with-param name="name" select="$name"/>
4160
+ </xsl:call-template>
4161
+ </xsl:for-each>
4162
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
4163
+ <xsl:copy>
4164
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
4165
+ </xsl:copy>
4166
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
4167
+ <xsl:apply-templates mode="svg_remove_a"/>
4168
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
4169
+ <xsl:param name="scale"/>
4170
+ <xsl:variable name="dest">
4171
+ <xsl:choose>
4172
+ <xsl:when test="starts-with(@href, '#')">
4173
+ <xsl:value-of select="substring-after(@href, '#')"/>
4174
+ </xsl:when>
4175
+ <xsl:otherwise>
4176
+ <xsl:value-of select="@href"/>
4177
+ </xsl:otherwise>
4178
+ </xsl:choose>
4179
+ </xsl:variable>
4180
+ <xsl:for-each select="./*[local-name() = 'rect']">
4181
+ <xsl:call-template name="insertSVGMapLink">
4182
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
4183
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
4184
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
4185
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
4186
+ <xsl:with-param name="dest" select="$dest"/>
4187
+ </xsl:call-template>
4188
+ </xsl:for-each>
4189
+
4190
+ <xsl:for-each select="./*[local-name() = 'polygon']">
4191
+ <xsl:variable name="points">
4192
+ <xsl:call-template name="split">
4193
+ <xsl:with-param name="pText" select="@points"/>
4194
+ </xsl:call-template>
4195
+ </xsl:variable>
4196
+ <xsl:variable name="x_coords">
4197
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
4198
+ <xsl:sort select="." data-type="number"/>
4199
+ <x><xsl:value-of select="."/></x>
4200
+ </xsl:for-each>
4201
+ </xsl:variable>
4202
+ <xsl:variable name="y_coords">
4203
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
4204
+ <xsl:sort select="." data-type="number"/>
4205
+ <y><xsl:value-of select="."/></y>
4206
+ </xsl:for-each>
4207
+ </xsl:variable>
4208
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
4209
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
4210
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
4211
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
4212
+ <xsl:call-template name="insertSVGMapLink">
4213
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
4214
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
4215
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
4216
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
4217
+ <xsl:with-param name="dest" select="$dest"/>
4218
+ </xsl:call-template>
4219
+ </xsl:for-each>
4220
+
4221
+ <xsl:for-each select="./*[local-name() = 'circle']">
4222
+ <xsl:call-template name="insertSVGMapLink">
4223
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
4224
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
4225
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
4226
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
4227
+ <xsl:with-param name="dest" select="$dest"/>
4228
+ </xsl:call-template>
4229
+ </xsl:for-each>
4230
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
4231
+ <xsl:call-template name="insertSVGMapLink">
4232
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
4233
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
4234
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
4235
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
4236
+ <xsl:with-param name="dest" select="$dest"/>
4237
+ </xsl:call-template>
4238
+ </xsl:for-each>
4239
+ </xsl:template><xsl:template name="insertSVGMapLink">
4240
+ <xsl:param name="left"/>
4241
+ <xsl:param name="top"/>
4242
+ <xsl:param name="width"/>
4243
+ <xsl:param name="height"/>
4244
+ <xsl:param name="dest"/>
4245
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
4246
+ <fo:block font-size="1pt">
4247
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
4248
+ <fo:inline-container inline-progression-dimension="100%">
4249
+ <fo:block-container height="{$height - 1}px" width="100%">
4250
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
4251
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
4252
+ </xsl:if> -->
4253
+ <fo:block> </fo:block></fo:block-container>
4254
+ </fo:inline-container>
4255
+ </fo:basic-link>
4256
+ </fo:block>
4257
+ </fo:block-container>
4017
4258
  </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">
4018
4259
  <xsl:apply-templates mode="contents"/>
4019
4260
  <xsl:text> </xsl:text>
@@ -4042,28 +4283,39 @@
4042
4283
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
4043
4284
  <xsl:for-each select="xalan:nodeset($contents)/doc">
4044
4285
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4286
+ <xsl:if test="@bundle = 'true'">
4287
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
4288
+ </xsl:if>
4045
4289
  <fo:bookmark-title>
4046
- <xsl:variable name="bookmark-title_">
4047
- <xsl:call-template name="getLangVersion">
4048
- <xsl:with-param name="lang" select="@lang"/>
4049
- <xsl:with-param name="doctype" select="@doctype"/>
4050
- <xsl:with-param name="title" select="@title-part"/>
4051
- </xsl:call-template>
4052
- </xsl:variable>
4053
4290
  <xsl:choose>
4054
- <xsl:when test="normalize-space($bookmark-title_) != ''">
4055
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
4056
- </xsl:when>
4057
- <xsl:otherwise>
4291
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
4292
+ <xsl:variable name="bookmark-title_">
4293
+ <xsl:call-template name="getLangVersion">
4294
+ <xsl:with-param name="lang" select="@lang"/>
4295
+ <xsl:with-param name="doctype" select="@doctype"/>
4296
+ <xsl:with-param name="title" select="@title-part"/>
4297
+ </xsl:call-template>
4298
+ </xsl:variable>
4058
4299
  <xsl:choose>
4059
- <xsl:when test="@lang = 'en'">English</xsl:when>
4060
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
4061
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4062
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4300
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
4301
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
4302
+ </xsl:when>
4303
+ <xsl:otherwise>
4304
+ <xsl:choose>
4305
+ <xsl:when test="@lang = 'en'">English</xsl:when>
4306
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
4307
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4308
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4309
+ </xsl:choose>
4310
+ </xsl:otherwise>
4063
4311
  </xsl:choose>
4312
+ </xsl:when>
4313
+ <xsl:otherwise>
4314
+ <xsl:value-of select="@title-part"/>
4064
4315
  </xsl:otherwise>
4065
4316
  </xsl:choose>
4066
4317
  </fo:bookmark-title>
4318
+
4067
4319
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
4068
4320
 
4069
4321
  <xsl:call-template name="insertFigureBookmarks">
@@ -4162,16 +4414,23 @@
4162
4414
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
4163
4415
  </xsl:choose>
4164
4416
  </xsl:template><xsl:template match="item" mode="bookmark">
4165
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
4166
- <fo:bookmark-title>
4167
- <xsl:if test="@section != ''">
4168
- <xsl:value-of select="@section"/>
4169
- <xsl:text> </xsl:text>
4170
- </xsl:if>
4171
- <xsl:value-of select="normalize-space(title)"/>
4172
- </fo:bookmark-title>
4173
- <xsl:apply-templates mode="bookmark"/>
4174
- </fo:bookmark>
4417
+ <xsl:choose>
4418
+ <xsl:when test="@id != ''">
4419
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4420
+ <fo:bookmark-title>
4421
+ <xsl:if test="@section != ''">
4422
+ <xsl:value-of select="@section"/>
4423
+ <xsl:text> </xsl:text>
4424
+ </xsl:if>
4425
+ <xsl:value-of select="normalize-space(title)"/>
4426
+ </fo:bookmark-title>
4427
+ <xsl:apply-templates mode="bookmark"/>
4428
+ </fo:bookmark>
4429
+ </xsl:when>
4430
+ <xsl:otherwise>
4431
+ <xsl:apply-templates mode="bookmark"/>
4432
+ </xsl:otherwise>
4433
+ </xsl:choose>
4175
4434
  </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">
4176
4435
  <xsl:if test="normalize-space() != ''">
4177
4436
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -4722,6 +4981,7 @@
4722
4981
  </xsl:if>
4723
4982
 
4724
4983
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4984
+
4725
4985
  <xsl:if test="normalize-space(@citeas) = ''">
4726
4986
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
4727
4987
  </xsl:if>
@@ -12,8 +12,12 @@
12
12
 
13
13
 
14
14
  <xsl:variable name="debug">false</xsl:variable>
15
- <xsl:variable name="pageWidth" select="'210mm'"/>
16
- <xsl:variable name="pageHeight" select="'297mm'"/>
15
+ <xsl:variable name="pageWidth" select="210"/>
16
+ <xsl:variable name="pageHeight" select="297"/>
17
+ <xsl:variable name="marginLeftRight1" select="40"/>
18
+ <xsl:variable name="marginLeftRight2" select="40"/>
19
+ <xsl:variable name="marginTop" select="30"/>
20
+ <xsl:variable name="marginBottom" select="34"/>
17
21
 
18
22
  <xsl:variable name="contents">
19
23
  <contents>
@@ -44,7 +48,7 @@
44
48
  <fo:root font-family="Times New Roman, STIX Two Math, Source Han Sans" font-size="10pt" xml:lang="{$lang}">
45
49
  <fo:layout-master-set>
46
50
  <!-- Cover page -->
47
- <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}" page-height="{$pageHeight}">
51
+ <fo:simple-page-master master-name="cover-page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
48
52
  <fo:region-body margin-top="20mm" margin-bottom="10mm" margin-left="50mm" margin-right="21mm"/>
49
53
  <fo:region-before extent="20mm"/>
50
54
  <fo:region-after extent="10mm"/>
@@ -52,25 +56,25 @@
52
56
  <fo:region-end extent="19mm"/>
53
57
  </fo:simple-page-master>
54
58
 
55
- <fo:simple-page-master master-name="document-preface" page-width="{$pageWidth}" page-height="{$pageHeight}">
56
- <fo:region-body margin-top="30mm" margin-bottom="34mm" margin-left="19.5mm" margin-right="19.5mm"/>
57
- <fo:region-before region-name="header" extent="30mm"/>
58
- <fo:region-after region-name="footer" extent="34mm"/>
59
+ <fo:simple-page-master master-name="document-preface" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
60
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="19.5mm" margin-right="19.5mm"/>
61
+ <fo:region-before region-name="header" extent="{$marginTop}mm"/>
62
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
59
63
  <fo:region-start region-name="left" extent="19.5mm"/>
60
64
  <fo:region-end region-name="right" extent="19.5mm"/>
61
65
  </fo:simple-page-master>
62
66
 
63
- <fo:simple-page-master master-name="blank" page-width="{$pageWidth}" page-height="{$pageHeight}">
64
- <fo:region-body margin-top="30mm" margin-bottom="34mm" margin-left="19.5mm" margin-right="19.5mm"/>
67
+ <fo:simple-page-master master-name="blank" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
68
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="19.5mm" margin-right="19.5mm"/>
65
69
  <fo:region-start region-name="left" extent="19.5mm"/>
66
70
  <fo:region-end region-name="right" extent="19.5mm"/>
67
71
  </fo:simple-page-master>
68
72
 
69
73
  <!-- Document pages -->
70
- <fo:simple-page-master master-name="document" page-width="{$pageWidth}" page-height="{$pageHeight}">
71
- <fo:region-body margin-top="30mm" margin-bottom="34mm" margin-left="40mm" margin-right="40mm"/>
72
- <fo:region-before region-name="header" extent="30mm"/>
73
- <fo:region-after region-name="footer" extent="34mm"/>
74
+ <fo:simple-page-master master-name="document" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
75
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
76
+ <fo:region-before region-name="header" extent="{$marginTop}mm"/>
77
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
74
78
  <fo:region-start region-name="left" extent="19.5mm"/>
75
79
  <fo:region-end region-name="right" extent="19.5mm"/>
76
80
  </fo:simple-page-master>
@@ -1376,6 +1380,7 @@
1376
1380
 
1377
1381
 
1378
1382
 
1383
+
1379
1384
  </xsl:attribute-set><xsl:attribute-set name="note-style">
1380
1385
 
1381
1386
 
@@ -1580,14 +1585,15 @@
1580
1585
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
1581
1586
 
1582
1587
  <!-- Normative references -->
1583
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
1588
+ <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]" mode="contents"/>
1584
1589
  <!-- Terms and definitions -->
1585
1590
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='terms']] | /*/*[local-name()='sections']/*[local-name()='definitions'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='definitions']]" mode="contents"/>
1586
1591
  <!-- Another main sections -->
1587
1592
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope') and not(local-name() = 'clause' and .//*[local-name()='terms']) and not(local-name() = 'clause' and .//*[local-name()='definitions'])]" mode="contents"/>
1588
1593
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
1589
1594
  <!-- Bibliography -->
1590
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
1595
+ <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"/>
1596
+
1591
1597
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
1592
1598
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
1593
1599
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -2381,6 +2387,7 @@
2381
2387
 
2382
2388
 
2383
2389
 
2390
+
2384
2391
  <xsl:if test="ancestor::*[local-name()='sections']">
2385
2392
  <xsl:attribute name="border">solid black 0pt</xsl:attribute>
2386
2393
  <xsl:attribute name="padding-top">1mm</xsl:attribute>
@@ -2422,6 +2429,7 @@
2422
2429
 
2423
2430
 
2424
2431
 
2432
+
2425
2433
  <fo:inline padding-right="2mm">
2426
2434
 
2427
2435
 
@@ -2475,6 +2483,7 @@
2475
2483
 
2476
2484
 
2477
2485
 
2486
+
2478
2487
  <xsl:value-of select="@reference"/>
2479
2488
 
2480
2489
 
@@ -2619,6 +2628,9 @@
2619
2628
 
2620
2629
 
2621
2630
 
2631
+
2632
+
2633
+
2622
2634
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
2623
2635
 
2624
2636
 
@@ -3518,6 +3530,7 @@
3518
3530
  <fo:inline xsl:use-attribute-sets="link-style">
3519
3531
 
3520
3532
 
3533
+
3521
3534
  <xsl:choose>
3522
3535
  <xsl:when test="$target_text = ''">
3523
3536
  <xsl:apply-templates/>
@@ -3888,6 +3901,234 @@
3888
3901
  <xsl:param name="height"/>
3889
3902
  <line xmlns="http://www.w3.org/2000/svg" x1="0" y1="0" x2="{$width}" y2="{$height}" style="stroke: rgb(255, 0, 0); stroke-width:4px; "/>
3890
3903
  <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; "/>
3904
+ </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">
3905
+ <xsl:param name="name"/>
3906
+
3907
+ <xsl:variable name="svg_content">
3908
+ <xsl:apply-templates select="." mode="svg_update"/>
3909
+ </xsl:variable>
3910
+
3911
+ <xsl:variable name="alt-text">
3912
+ <xsl:choose>
3913
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
3914
+ <xsl:value-of select="../*[local-name() = 'name']"/>
3915
+ </xsl:when>
3916
+ <xsl:when test="normalize-space($name) != ''">
3917
+ <xsl:value-of select="$name"/>
3918
+ </xsl:when>
3919
+ <xsl:otherwise>Figure</xsl:otherwise>
3920
+ </xsl:choose>
3921
+ </xsl:variable>
3922
+
3923
+ <xsl:choose>
3924
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
3925
+ <fo:block>
3926
+ <xsl:variable name="width" select="@width"/>
3927
+ <xsl:variable name="height" select="@height"/>
3928
+
3929
+ <xsl:variable name="scale_x">
3930
+ <xsl:choose>
3931
+ <xsl:when test="$width &gt; $width_effective_px">
3932
+ <xsl:value-of select="$width_effective_px div $width"/>
3933
+ </xsl:when>
3934
+ <xsl:otherwise>1</xsl:otherwise>
3935
+ </xsl:choose>
3936
+ </xsl:variable>
3937
+
3938
+ <xsl:variable name="scale_y">
3939
+ <xsl:choose>
3940
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
3941
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
3942
+ </xsl:when>
3943
+ <xsl:otherwise>1</xsl:otherwise>
3944
+ </xsl:choose>
3945
+ </xsl:variable>
3946
+
3947
+ <xsl:variable name="scale">
3948
+ <xsl:choose>
3949
+ <xsl:when test="$scale_y != 1">
3950
+ <xsl:value-of select="$scale_x * $scale_y"/>
3951
+ </xsl:when>
3952
+ <xsl:otherwise>
3953
+ <xsl:value-of select="$scale_x"/>
3954
+ </xsl:otherwise>
3955
+ </xsl:choose>
3956
+ </xsl:variable>
3957
+
3958
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
3959
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
3960
+
3961
+ <fo:table table-layout="fixed" width="100%">
3962
+ <fo:table-column column-width="proportional-column-width(1)"/>
3963
+ <fo:table-column column-width="{$width_scale}px"/>
3964
+ <fo:table-column column-width="proportional-column-width(1)"/>
3965
+ <fo:table-body>
3966
+ <fo:table-row>
3967
+ <fo:table-cell column-number="2">
3968
+ <fo:block>
3969
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
3970
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3971
+ <fo:block line-height="0" font-size="0">
3972
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
3973
+ <xsl:call-template name="bookmark"/>
3974
+ </xsl:for-each>
3975
+ </fo:block>
3976
+ </xsl:if>
3977
+ <fo:block text-depth="0" line-height="0" font-size="0">
3978
+
3979
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
3980
+ <xsl:attribute name="width">100%</xsl:attribute>
3981
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3982
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3983
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3984
+
3985
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
3986
+ </fo:instream-foreign-object>
3987
+ </fo:block>
3988
+
3989
+ <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">
3990
+ <xsl:with-param name="scale" select="$scale"/>
3991
+ </xsl:apply-templates>
3992
+ </fo:block-container>
3993
+ </fo:block>
3994
+ </fo:table-cell>
3995
+ </fo:table-row>
3996
+ </fo:table-body>
3997
+ </fo:table>
3998
+ </fo:block>
3999
+
4000
+ </xsl:when>
4001
+ <xsl:otherwise>
4002
+ <fo:block xsl:use-attribute-sets="image-style">
4003
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
4004
+ <xsl:attribute name="width">100%</xsl:attribute>
4005
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4006
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4007
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
4008
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
4009
+ <!-- effective height / width = 1.48, 1.4 - with title -->
4010
+ <xsl:if test="@height &gt; (@width * 1.4)"> <!-- for images with big height -->
4011
+ <xsl:variable name="width" select="((@width * 1.4) div @height) * 100"/>
4012
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
4013
+ </xsl:if>
4014
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4015
+ <xsl:copy-of select="$svg_content"/>
4016
+ </fo:instream-foreign-object>
4017
+ </fo:block>
4018
+ </xsl:otherwise>
4019
+ </xsl:choose>
4020
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
4021
+ <xsl:copy>
4022
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
4023
+ </xsl:copy>
4024
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
4025
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
4026
+ <xsl:value-of select="."/>
4027
+ </xsl:attribute>
4028
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
4029
+ <xsl:variable name="svg_content" select="document(@src)"/>
4030
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
4031
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
4032
+ <xsl:call-template name="image_svg">
4033
+ <xsl:with-param name="name" select="$name"/>
4034
+ </xsl:call-template>
4035
+ </xsl:for-each>
4036
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
4037
+ <xsl:copy>
4038
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
4039
+ </xsl:copy>
4040
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
4041
+ <xsl:apply-templates mode="svg_remove_a"/>
4042
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
4043
+ <xsl:param name="scale"/>
4044
+ <xsl:variable name="dest">
4045
+ <xsl:choose>
4046
+ <xsl:when test="starts-with(@href, '#')">
4047
+ <xsl:value-of select="substring-after(@href, '#')"/>
4048
+ </xsl:when>
4049
+ <xsl:otherwise>
4050
+ <xsl:value-of select="@href"/>
4051
+ </xsl:otherwise>
4052
+ </xsl:choose>
4053
+ </xsl:variable>
4054
+ <xsl:for-each select="./*[local-name() = 'rect']">
4055
+ <xsl:call-template name="insertSVGMapLink">
4056
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
4057
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
4058
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
4059
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
4060
+ <xsl:with-param name="dest" select="$dest"/>
4061
+ </xsl:call-template>
4062
+ </xsl:for-each>
4063
+
4064
+ <xsl:for-each select="./*[local-name() = 'polygon']">
4065
+ <xsl:variable name="points">
4066
+ <xsl:call-template name="split">
4067
+ <xsl:with-param name="pText" select="@points"/>
4068
+ </xsl:call-template>
4069
+ </xsl:variable>
4070
+ <xsl:variable name="x_coords">
4071
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
4072
+ <xsl:sort select="." data-type="number"/>
4073
+ <x><xsl:value-of select="."/></x>
4074
+ </xsl:for-each>
4075
+ </xsl:variable>
4076
+ <xsl:variable name="y_coords">
4077
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
4078
+ <xsl:sort select="." data-type="number"/>
4079
+ <y><xsl:value-of select="."/></y>
4080
+ </xsl:for-each>
4081
+ </xsl:variable>
4082
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
4083
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
4084
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
4085
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
4086
+ <xsl:call-template name="insertSVGMapLink">
4087
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
4088
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
4089
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
4090
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
4091
+ <xsl:with-param name="dest" select="$dest"/>
4092
+ </xsl:call-template>
4093
+ </xsl:for-each>
4094
+
4095
+ <xsl:for-each select="./*[local-name() = 'circle']">
4096
+ <xsl:call-template name="insertSVGMapLink">
4097
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
4098
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
4099
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
4100
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
4101
+ <xsl:with-param name="dest" select="$dest"/>
4102
+ </xsl:call-template>
4103
+ </xsl:for-each>
4104
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
4105
+ <xsl:call-template name="insertSVGMapLink">
4106
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
4107
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
4108
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
4109
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
4110
+ <xsl:with-param name="dest" select="$dest"/>
4111
+ </xsl:call-template>
4112
+ </xsl:for-each>
4113
+ </xsl:template><xsl:template name="insertSVGMapLink">
4114
+ <xsl:param name="left"/>
4115
+ <xsl:param name="top"/>
4116
+ <xsl:param name="width"/>
4117
+ <xsl:param name="height"/>
4118
+ <xsl:param name="dest"/>
4119
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
4120
+ <fo:block font-size="1pt">
4121
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
4122
+ <fo:inline-container inline-progression-dimension="100%">
4123
+ <fo:block-container height="{$height - 1}px" width="100%">
4124
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
4125
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
4126
+ </xsl:if> -->
4127
+ <fo:block> </fo:block></fo:block-container>
4128
+ </fo:inline-container>
4129
+ </fo:basic-link>
4130
+ </fo:block>
4131
+ </fo:block-container>
3891
4132
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
3892
4133
  <xsl:apply-templates mode="contents"/>
3893
4134
  <xsl:text> </xsl:text>
@@ -3916,28 +4157,39 @@
3916
4157
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
3917
4158
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3918
4159
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
4160
+ <xsl:if test="@bundle = 'true'">
4161
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
4162
+ </xsl:if>
3919
4163
  <fo:bookmark-title>
3920
- <xsl:variable name="bookmark-title_">
3921
- <xsl:call-template name="getLangVersion">
3922
- <xsl:with-param name="lang" select="@lang"/>
3923
- <xsl:with-param name="doctype" select="@doctype"/>
3924
- <xsl:with-param name="title" select="@title-part"/>
3925
- </xsl:call-template>
3926
- </xsl:variable>
3927
4164
  <xsl:choose>
3928
- <xsl:when test="normalize-space($bookmark-title_) != ''">
3929
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
3930
- </xsl:when>
3931
- <xsl:otherwise>
4165
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
4166
+ <xsl:variable name="bookmark-title_">
4167
+ <xsl:call-template name="getLangVersion">
4168
+ <xsl:with-param name="lang" select="@lang"/>
4169
+ <xsl:with-param name="doctype" select="@doctype"/>
4170
+ <xsl:with-param name="title" select="@title-part"/>
4171
+ </xsl:call-template>
4172
+ </xsl:variable>
3932
4173
  <xsl:choose>
3933
- <xsl:when test="@lang = 'en'">English</xsl:when>
3934
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
3935
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
3936
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4174
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
4175
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
4176
+ </xsl:when>
4177
+ <xsl:otherwise>
4178
+ <xsl:choose>
4179
+ <xsl:when test="@lang = 'en'">English</xsl:when>
4180
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
4181
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
4182
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
4183
+ </xsl:choose>
4184
+ </xsl:otherwise>
3937
4185
  </xsl:choose>
4186
+ </xsl:when>
4187
+ <xsl:otherwise>
4188
+ <xsl:value-of select="@title-part"/>
3938
4189
  </xsl:otherwise>
3939
4190
  </xsl:choose>
3940
4191
  </fo:bookmark-title>
4192
+
3941
4193
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3942
4194
 
3943
4195
  <xsl:call-template name="insertFigureBookmarks">
@@ -4036,16 +4288,23 @@
4036
4288
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
4037
4289
  </xsl:choose>
4038
4290
  </xsl:template><xsl:template match="item" mode="bookmark">
4039
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
4040
- <fo:bookmark-title>
4041
- <xsl:if test="@section != ''">
4042
- <xsl:value-of select="@section"/>
4043
- <xsl:text> </xsl:text>
4044
- </xsl:if>
4045
- <xsl:value-of select="normalize-space(title)"/>
4046
- </fo:bookmark-title>
4047
- <xsl:apply-templates mode="bookmark"/>
4048
- </fo:bookmark>
4291
+ <xsl:choose>
4292
+ <xsl:when test="@id != ''">
4293
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
4294
+ <fo:bookmark-title>
4295
+ <xsl:if test="@section != ''">
4296
+ <xsl:value-of select="@section"/>
4297
+ <xsl:text> </xsl:text>
4298
+ </xsl:if>
4299
+ <xsl:value-of select="normalize-space(title)"/>
4300
+ </fo:bookmark-title>
4301
+ <xsl:apply-templates mode="bookmark"/>
4302
+ </fo:bookmark>
4303
+ </xsl:when>
4304
+ <xsl:otherwise>
4305
+ <xsl:apply-templates mode="bookmark"/>
4306
+ </xsl:otherwise>
4307
+ </xsl:choose>
4049
4308
  </xsl:template><xsl:template match="title" mode="bookmark"/><xsl:template match="text()" mode="bookmark"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'image']/*[local-name() = 'name']" mode="presentation">
4050
4309
  <xsl:if test="normalize-space() != ''">
4051
4310
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -4596,6 +4855,7 @@
4596
4855
  </xsl:if>
4597
4856
 
4598
4857
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4858
+
4599
4859
  <xsl:if test="normalize-space(@citeas) = ''">
4600
4860
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
4601
4861
  </xsl:if>