metanorma-iec 1.3.5 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1927ece3a09c61d4d12c9f6daa48bbadf0168bee1bfcde52392123308c44edb6
4
- data.tar.gz: 1c92e46aa15e727af3438267cf5f9e72d78c00a959a8bcc354f384d0cc21102b
3
+ metadata.gz: d358626bded62b0caaab1e332d70df6345990e79bf8f7501f6b48125e8b65e6b
4
+ data.tar.gz: 208f83d9d0386b6899b9b0e68f3ab285ec942c92950063190f38b39f2433711d
5
5
  SHA512:
6
- metadata.gz: 98fd5f51acfe167d57c8f465d69d2f8fe7c4c24fd1393ed1377b27c36735066fbe1b71aeb6970e4e16ede2ed98f7143c602a4b3a091ad19f8b799dd3618639fb
7
- data.tar.gz: da6cd485af116325a064b085d0533a0f895129de6a240129b233d1b9ea278df14a8a4a3931218b3ab34c87250fbd88df2a94a2177d0925a37458c97c8c88b348
6
+ metadata.gz: bde2cf9571931d12d41b2c41a44ae5fbad6d23c043f89421e41b59ad6a198780460024c00fb6ebcec3580efee065a12fd6a5263bf89e3b9a4a6168ef79ffd965
7
+ data.tar.gz: d1d58bd85400d59d5a247b49fe3974de54839d336576ebd0ec7a42ed150d38b3062543403a4b18189581bbb5ea7a396f56bc34854ff173e8ef591d0ffc9c194a
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  steps:
@@ -6,7 +6,9 @@ module Asciidoctor
6
6
  csv_split(publishers)&.each do |p|
7
7
  xml.contributor do |c|
8
8
  c.role **{ type: "author" }
9
- c.organization { |a| organization(a, p, false, node, !node.attr("publisher")) }
9
+ c.organization do |a|
10
+ organization(a, p, false, node, !node.attr("publisher"))
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -16,7 +18,9 @@ module Asciidoctor
16
18
  csv_split(publishers)&.each do |p|
17
19
  xml.contributor do |c|
18
20
  c.role **{ type: "publisher" }
19
- c.organization { |a| organization(a, p, true, node, !node.attr("publisher")) }
21
+ c.organization do |a|
22
+ organization(a, p, true, node, !node.attr("publisher"))
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -47,24 +51,29 @@ module Asciidoctor
47
51
  xml.docidentifier dn, **attr_code(type: "ISO")
48
52
  end
49
53
 
50
- def id_edition_suffix(dn, node)
54
+ def id_edition_suffix(docnum, node)
51
55
  ed = node.attr("edition") || 1
52
- dn += " ED #{ed}"
53
- dn
56
+ docnum += " ED #{ed}"
57
+ docnum
54
58
  end
55
59
 
56
60
  STAGE_CODES = {
57
- "PNW" => "1000", "ANW" => "2000", "CAN" => "2098", "ACD" => "2099", "CD" => "3020",
58
- "BWG" => "3092", "A2CD" => "3099", "2CD" => "3520", "3CD" => "3520", "4CD" => "3520",
59
- "5CD" => "3520", "6CD" => "3520", "7CD" => "3520", "8CD" => "3520", "9CD" => "3520",
60
- "CDM" => "3591", "A3CD" => "3592", "A4CD" => "3592", "A5CD" => "3592", "A6CD" => "3592",
61
- "A7CD" => "3592", "A8CD" => "3592", "A9CD" => "3592", "ACDV" => "3599", "CCDV" => "4020",
62
- "CDVM" => "4091", "NCDV" => "4092", "NADIS" => "4093", "ADIS" => "4099", "ADTR" => "4099",
63
- "ADTS" => "4099", "RDISH" => "5000", "RFDIS" => "5000", "CDISH" => "5020", "CDPAS" => "5020",
64
- "CDTR" => "5020", "CDTS" => "5020", "CFDIS" => "5020", "DTRM" => "5092", "DTSM" => "5092",
65
- "NDTR" => "5092", "NDTS" => "5092", "NFDIS" => "5092", "APUB" => "5099", "BPUB" => "6000",
66
- "PPUB" => "6060", "RR" => "9092", "AMW" => "9220", "WPUB" => "9599", "DELPUB" => "9960",
67
- "PWI" => "0000", "NWIP" => "1000", "WD" => "2000", "CDV" => "4000", "FDIS" => "5000",
61
+ "PNW" => "1000", "ANW" => "2000", "CAN" => "2098", "ACD" => "2099",
62
+ "CD" => "3020", "BWG" => "3092", "A2CD" => "3099", "2CD" => "3520",
63
+ "3CD" => "3520", "4CD" => "3520", "5CD" => "3520", "6CD" => "3520",
64
+ "7CD" => "3520", "8CD" => "3520", "9CD" => "3520", "CDM" => "3591",
65
+ "A3CD" => "3592", "A4CD" => "3592", "A5CD" => "3592", "A6CD" => "3592",
66
+ "A7CD" => "3592", "A8CD" => "3592", "A9CD" => "3592", "ACDV" => "3599",
67
+ "CCDV" => "4020", "CDVM" => "4091", "NCDV" => "4092",
68
+ "NADIS" => "4093", "ADIS" => "4099", "ADTR" => "4099",
69
+ "ADTS" => "4099", "RDISH" => "5000", "RFDIS" => "5000",
70
+ "CDISH" => "5020", "CDPAS" => "5020", "CDTR" => "5020",
71
+ "CDTS" => "5020", "CFDIS" => "5020", "DTRM" => "5092",
72
+ "DTSM" => "5092", "NDTR" => "5092", "NDTS" => "5092",
73
+ "NFDIS" => "5092", "APUB" => "5099", "BPUB" => "6000",
74
+ "PPUB" => "6060", "RR" => "9092", "AMW" => "9220", "WPUB" => "9599",
75
+ "DELPUB" => "9960", "PWI" => "0000", "NWIP" => "1000", "WD" => "2000",
76
+ "CDV" => "4000", "FDIS" => "5000"
68
77
  }.freeze
69
78
 
70
79
  DOC_STAGE = {
@@ -82,19 +91,23 @@ module Asciidoctor
82
91
  }.freeze
83
92
 
84
93
  STAGE_ABBRS = {
85
- "00" => {"00" => "PWI"},
86
- "10" => {"00" => "PNW"},
87
- "20" => {"00" => "ANW", "98" => "CAN", "99" => "ACD"},
88
- "30" => {"00" => "CD", "20" => "CD", "92" => "BWG", "97" => "MERGED", "98" => "DREJ", "99" => "A2CD"},
89
- "35" => {"00" => "CD", "20" => "CD", "91" => "CDM", "92" => "ACD", "99" => "ACDV"},
90
- "40" => {"00" => "CCDV", "20" => "CCDV", "91" => "CDVM", "92" => "NCDV", "93" => "NADIS",
91
- "95" => "ADISSB", "99" => "ADIS"},
92
- "50" => {"00" => "RFDIS", "20" => "CFDIS", "92" => "NFDIS", "95" => "APUBSB", "99" => "APUB"},
93
- "60" => {"00" => "BPUB", "60" => "PPUB"},
94
- "90" => {"00" => "RR", "92" => "RR"},
95
- "92" => {"00" => "AMW", "20" => "AMW"},
96
- "95" => {"00" => "WPUB", "99" => "WPUB"},
97
- "99" => {"00" => "DELPUB", "60" => "DELPUB"},
94
+ "00" => { "00" => "PWI" },
95
+ "10" => { "00" => "PNW" },
96
+ "20" => { "00" => "ANW", "98" => "CAN", "99" => "ACD" },
97
+ "30" => { "00" => "CD", "20" => "CD", "92" => "BWG", "97" => "MERGED",
98
+ "98" => "DREJ", "99" => "A2CD" },
99
+ "35" => { "00" => "CD", "20" => "CD", "91" => "CDM", "92" => "ACD",
100
+ "99" => "ACDV" },
101
+ "40" => { "00" => "CCDV", "20" => "CCDV", "91" => "CDVM",
102
+ "92" => "NCDV", "93" => "NADIS",
103
+ "95" => "ADISSB", "99" => "ADIS" },
104
+ "50" => { "00" => "RFDIS", "20" => "CFDIS", "92" => "NFDIS",
105
+ "95" => "APUBSB", "99" => "APUB" },
106
+ "60" => { "00" => "BPUB", "60" => "PPUB" },
107
+ "90" => { "00" => "RR", "92" => "RR" },
108
+ "92" => { "00" => "AMW", "20" => "AMW" },
109
+ "95" => { "00" => "WPUB", "99" => "WPUB" },
110
+ "99" => { "00" => "DELPUB", "60" => "DELPUB" },
98
111
  }.freeze
99
112
 
100
113
  STAGE_NAMES = {
@@ -112,7 +125,7 @@ module Asciidoctor
112
125
  "99": "Deleted",
113
126
  }.freeze
114
127
 
115
- def status_abbrev1(stage, substage, iter, doctype, draft)
128
+ def status_abbrev1(stage, substage, iter, doctype, _draft)
116
129
  return "" unless stage
117
130
 
118
131
  abbr = STAGE_ABBRS.dig(stage, substage) || "??"
@@ -121,30 +134,30 @@ module Asciidoctor
121
134
  end
122
135
  case doctype
123
136
  when "technical-report"
124
- stage = "ADTR" if stage == "40" && substage == "99"
125
- stage = "CDTR" if stage == "50" && substage == "20"
126
- stage = "DTRM" if stage == "50" && substage == "92"
137
+ abbr = "ADTR" if stage == "40" && substage == "99"
138
+ abbr = "CDTR" if stage == "50" && substage == "20"
139
+ abbr = "DTRM" if stage == "50" && substage == "92"
127
140
  when "technical-specification"
128
- stage = "ADTS" if stage == "40" && substage == "99"
129
- stage = "CDTS" if stage == "50" && substage == "20"
130
- stage = "DTSM" if stage == "50" && substage == "92"
141
+ abbr = "ADTS" if stage == "40" && substage == "99"
142
+ abbr = "CDTS" if stage == "50" && substage == "20"
143
+ abbr = "DTSM" if stage == "50" && substage == "92"
131
144
  when "interpretation-sheet"
132
- stage = "RDISH" if stage == "50" && substage == "00"
133
- stage = "CDISH" if stage == "50" && substage == "20"
145
+ abbr = "RDISH" if stage == "50" && substage == "00"
146
+ abbr = "CDISH" if stage == "50" && substage == "20"
134
147
  when "publicly-available-specification"
135
- stage = "CDPAS" if stage == "50" && substage == "20"
148
+ abbr = "CDPAS" if stage == "50" && substage == "20"
136
149
  end
137
150
  abbr = abbr.sub(/CD$/, "#{iter}CD") if iter
138
151
  abbr
139
152
  end
140
153
 
141
- def stage_abbr(stage, substage)
154
+ def stage_abbr(stage, _substage)
142
155
  return "PPUB" if stage == "60"
143
156
 
144
157
  DOC_STAGE[stage.to_sym] || "??"
145
158
  end
146
159
 
147
- def stage_name(stage, substage, _doctype, _iteration)
160
+ def stage_name(stage, _substage, _doctype, _iteration)
148
161
  STAGE_NAMES[stage.to_sym]
149
162
  end
150
163
 
@@ -159,11 +172,16 @@ module Asciidoctor
159
172
  st = node.attr("status") || node.attr("docstage")
160
173
  stage = get_stage(node)
161
174
  node.attr("docsubstage") ||
162
- ( stage == "60" ? "60" : STAGE_CODES[st] ? STAGE_CODES[st][2..3] : "00" )
175
+ (if stage == "60"
176
+ "60"
177
+ else
178
+ STAGE_CODES[st] ? STAGE_CODES[st][2..3] : "00"
179
+ end)
163
180
  end
164
181
 
165
- def id_stage_abbr(stage, substage, node)
182
+ def id_stage_abbr(stage, _substage, node)
166
183
  return "" if stage == "60"
184
+
167
185
  abbr = DOC_STAGE[stage.to_sym] || ""
168
186
  abbr = node.attr("iteration") + abbr if node.attr("iteration")
169
187
  abbr
@@ -174,9 +192,9 @@ module Asciidoctor
174
192
  substage = get_substage(node)
175
193
  xml.status do |s|
176
194
  s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage))
177
- s.substage substage,
178
- **attr_code(abbreviation: status_abbrev1(stage, substage, node.attr("iteration"),
179
- doctype(node),node.attr("draft")))
195
+ subst = status_abbrev1(stage, substage, node.attr("iteration"),
196
+ doctype(node), node.attr("draft"))
197
+ s.substage substage, **attr_code(abbreviation: subst)
180
198
  node.attr("iteration") && (s.iteration node.attr("iteration"))
181
199
  end
182
200
  end
@@ -204,6 +204,18 @@
204
204
  </zeroOrMore>
205
205
  </element>
206
206
  </define>
207
+ <define name="dt">
208
+ <element name="dt">
209
+ <optional>
210
+ <attribute name="id">
211
+ <data type="ID"/>
212
+ </attribute>
213
+ </optional>
214
+ <zeroOrMore>
215
+ <ref name="TextElement"/>
216
+ </zeroOrMore>
217
+ </element>
218
+ </define>
207
219
  <define name="example">
208
220
  <element name="example">
209
221
  <attribute name="id">
@@ -899,7 +911,7 @@
899
911
  </include>
900
912
  <!-- end overrides -->
901
913
  <define name="docsubtype">
902
- <element name="docsubtype">
914
+ <element name="subdoctype">
903
915
  <ref name="DocumentSubtype"/>
904
916
  </element>
905
917
  </define>
@@ -955,7 +967,34 @@
955
967
  <define name="concept">
956
968
  <element name="concept">
957
969
  <optional>
958
- <attribute name="term"/>
970
+ <attribute name="ital">
971
+ <data type="boolean"/>
972
+ </attribute>
973
+ </optional>
974
+ <optional>
975
+ <attribute name="ref">
976
+ <data type="boolean"/>
977
+ </attribute>
978
+ </optional>
979
+ <optional>
980
+ <element name="refterm">
981
+ <zeroOrMore>
982
+ <choice>
983
+ <ref name="PureTextElement"/>
984
+ <ref name="stem"/>
985
+ </choice>
986
+ </zeroOrMore>
987
+ </element>
988
+ </optional>
989
+ <optional>
990
+ <element name="renderterm">
991
+ <zeroOrMore>
992
+ <choice>
993
+ <ref name="PureTextElement"/>
994
+ <ref name="stem"/>
995
+ </choice>
996
+ </zeroOrMore>
997
+ </element>
959
998
  </optional>
960
999
  <choice>
961
1000
  <ref name="eref"/>
@@ -972,8 +1011,14 @@
972
1011
  <ref name="imagemap"/>
973
1012
  <ref name="svgmap"/>
974
1013
  <ref name="inputform"/>
1014
+ <ref name="toc"/>
975
1015
  </choice>
976
1016
  </define>
1017
+ <define name="toc">
1018
+ <element name="toc">
1019
+ <ref name="ul"/>
1020
+ </element>
1021
+ </define>
977
1022
  <define name="inputform">
978
1023
  <element name="form">
979
1024
  <attribute name="id">
@@ -981,6 +1026,9 @@
981
1026
  </attribute>
982
1027
  <attribute name="name"/>
983
1028
  <attribute name="action"/>
1029
+ <optional>
1030
+ <attribute name="class"/>
1031
+ </optional>
984
1032
  <zeroOrMore>
985
1033
  <choice>
986
1034
  <ref name="TextElement"/>
@@ -1212,6 +1260,12 @@
1212
1260
  <optional>
1213
1261
  <attribute name="type"/>
1214
1262
  </optional>
1263
+ <optional>
1264
+ <attribute name="identifier"/>
1265
+ </optional>
1266
+ <optional>
1267
+ <attribute name="prefix"/>
1268
+ </optional>
1215
1269
  <text/>
1216
1270
  </define>
1217
1271
  <define name="ics">
@@ -1473,26 +1527,26 @@
1473
1527
  <optional>
1474
1528
  <ref name="section-title"/>
1475
1529
  </optional>
1476
- <group>
1530
+ <choice>
1477
1531
  <choice>
1478
1532
  <group>
1479
- <zeroOrMore>
1533
+ <oneOrMore>
1480
1534
  <ref name="BasicBlock"/>
1481
- </zeroOrMore>
1535
+ </oneOrMore>
1482
1536
  <zeroOrMore>
1483
1537
  <ref name="note"/>
1484
1538
  </zeroOrMore>
1485
1539
  </group>
1486
1540
  <ref name="amend"/>
1487
1541
  </choice>
1488
- <zeroOrMore>
1542
+ <oneOrMore>
1489
1543
  <choice>
1490
1544
  <ref name="clause-subsection"/>
1491
1545
  <ref name="terms"/>
1492
1546
  <ref name="definitions"/>
1493
1547
  </choice>
1494
- </zeroOrMore>
1495
- </group>
1548
+ </oneOrMore>
1549
+ </choice>
1496
1550
  </define>
1497
1551
  <define name="Annex-Section">
1498
1552
  <optional>
@@ -101,7 +101,11 @@
101
101
  <ref name="definitions"/>
102
102
  </optional>
103
103
  <oneOrMore>
104
- <ref name="clause"/>
104
+ <choice>
105
+ <ref name="clause"/>
106
+ <ref name="term-clause"/>
107
+ <ref name="terms"/>
108
+ </choice>
105
109
  </oneOrMore>
106
110
  </element>
107
111
  </define>
@@ -136,7 +140,7 @@
136
140
  <optional>
137
141
  <ref name="section-title"/>
138
142
  </optional>
139
- <group>
143
+ <choice>
140
144
  <choice>
141
145
  <group>
142
146
  <oneOrMore>
@@ -151,7 +155,7 @@
151
155
  <oneOrMore>
152
156
  <ref name="clause-subsection"/>
153
157
  </oneOrMore>
154
- </group>
158
+ </choice>
155
159
  </define>
156
160
  <define name="term">
157
161
  <element name="term">
@@ -64,9 +64,9 @@
64
64
  <optional>
65
65
  <ref name="label"/>
66
66
  </optional>
67
- <optional>
67
+ <zeroOrMore>
68
68
  <ref name="subject"/>
69
- </optional>
69
+ </zeroOrMore>
70
70
  <zeroOrMore>
71
71
  <ref name="reqinherit"/>
72
72
  </zeroOrMore>
@@ -80,6 +80,7 @@
80
80
  <ref name="verification"/>
81
81
  <ref name="import"/>
82
82
  <ref name="description"/>
83
+ <ref name="component"/>
83
84
  </choice>
84
85
  </zeroOrMore>
85
86
  <optional>
@@ -105,12 +106,16 @@
105
106
  </define>
106
107
  <define name="subject">
107
108
  <element name="subject">
108
- <text/>
109
+ <oneOrMore>
110
+ <ref name="TextElement"/>
111
+ </oneOrMore>
109
112
  </element>
110
113
  </define>
111
114
  <define name="reqinherit">
112
115
  <element name="inherit">
113
- <text/>
116
+ <oneOrMore>
117
+ <ref name="TextElement"/>
118
+ </oneOrMore>
114
119
  </element>
115
120
  </define>
116
121
  <define name="measurementtarget">
@@ -138,6 +143,12 @@
138
143
  <ref name="RequirementSubpart"/>
139
144
  </element>
140
145
  </define>
146
+ <define name="component">
147
+ <element name="component">
148
+ <attribute name="class"/>
149
+ <ref name="RequirementSubpart"/>
150
+ </element>
151
+ </define>
141
152
  <define name="reqt_references">
142
153
  <element name="references">
143
154
  <oneOrMore>
@@ -20,8 +20,12 @@
20
20
 
21
21
 
22
22
  <xsl:variable name="debug">false</xsl:variable>
23
- <xsl:variable name="pageWidth" select="'210mm'"/>
24
- <xsl:variable name="pageHeight" select="'297mm'"/>
23
+ <xsl:variable name="pageWidth" select="210"/>
24
+ <xsl:variable name="pageHeight" select="297"/>
25
+ <xsl:variable name="marginLeftRight1" select="25"/>
26
+ <xsl:variable name="marginLeftRight2" select="25"/>
27
+ <xsl:variable name="marginTop" select="31"/>
28
+ <xsl:variable name="marginBottom" select="15"/>
25
29
 
26
30
  <xsl:variable name="copyrightText" select="concat('© ', //iec:iec-standard/iec:bibdata/iec:copyright/iec:owner/iec:organization/iec:abbreviation, ':', //iec:iec-standard/iec:bibdata/iec:copyright/iec:from)"/>
27
31
  <!-- <xsl:variable name="lang-1st-letter" select="concat('(', translate(substring(iec:iec-standard/iec:bibdata/iec:language,1,1),$lower, $upper), ')')"/> -->
@@ -160,14 +164,14 @@
160
164
  <fo:root font-family="Arial, Times New Roman, STIX Two Math, Source Han Sans" font-size="10pt" xml:lang="{$lang}">
161
165
  <fo:layout-master-set>
162
166
  <!-- cover pages -->
163
- <fo:simple-page-master master-name="cover" page-width="{$pageWidth}" page-height="{$pageHeight}">
167
+ <fo:simple-page-master master-name="cover" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
164
168
  <fo:region-body margin-top="17.5mm" margin-bottom="12.5mm" margin-left="18mm" margin-right="20.5mm"/>
165
169
  <fo:region-before region-name="header" extent="17.5mm"/>
166
170
  <fo:region-after region-name="footer" extent="12.5mm" precedence="true"/>
167
171
  <fo:region-start region-name="left-region" extent="18mm"/>
168
172
  <fo:region-end region-name="right-region" extent="20.5mm"/>
169
173
  </fo:simple-page-master>
170
- <fo:simple-page-master master-name="cover_2nd" page-width="{$pageWidth}" page-height="{$pageHeight}">
174
+ <fo:simple-page-master master-name="cover_2nd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
171
175
  <fo:region-body margin-top="17.5mm" margin-bottom="12.5mm" margin-left="25mm" margin-right="25mm" column-count="2" column-gap="5mm"/>
172
176
  <fo:region-before region-name="header" extent="17.5mm"/>
173
177
  <fo:region-after region-name="footer" extent="12.5mm" precedence="true"/>
@@ -175,7 +179,7 @@
175
179
  <fo:region-end region-name="right-region" extent="25mm"/>
176
180
  </fo:simple-page-master>
177
181
 
178
- <fo:simple-page-master master-name="cover-FDIS" page-width="{$pageWidth}" page-height="{$pageHeight}">
182
+ <fo:simple-page-master master-name="cover-FDIS" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
179
183
  <fo:region-body margin-top="17.5mm" margin-bottom="29mm" margin-left="18mm" margin-right="19mm"/>
180
184
  <fo:region-before region-name="header" extent="17.5mm"/>
181
185
  <fo:region-after region-name="footer-FDIS" extent="29mm"/>
@@ -184,20 +188,20 @@
184
188
  </fo:simple-page-master>
185
189
 
186
190
  <!-- odd pages -->
187
- <fo:simple-page-master master-name="odd" page-width="{$pageWidth}" page-height="{$pageHeight}">
188
- <fo:region-body margin-top="31mm" margin-bottom="15mm" margin-left="25mm" margin-right="25mm"/>
189
- <fo:region-before region-name="header-odd" extent="31mm"/>
190
- <fo:region-after region-name="footer" extent="15mm"/>
191
- <fo:region-start region-name="left-region" extent="25mm"/>
192
- <fo:region-end region-name="right-region" extent="25mm"/>
191
+ <fo:simple-page-master master-name="odd" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
192
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
193
+ <fo:region-before region-name="header-odd" extent="{$marginTop}mm"/>
194
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
195
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
196
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
193
197
  </fo:simple-page-master>
194
198
  <!-- even pages -->
195
- <fo:simple-page-master master-name="even" page-width="{$pageWidth}" page-height="{$pageHeight}">
196
- <fo:region-body margin-top="31mm" margin-bottom="15mm" margin-left="25mm" margin-right="25mm"/>
197
- <fo:region-before region-name="header-even" extent="31mm"/>
198
- <fo:region-after region-name="footer" extent="15mm"/>
199
- <fo:region-start region-name="left-region" extent="25mm"/>
200
- <fo:region-end region-name="right-region" extent="25mm"/>
199
+ <fo:simple-page-master master-name="even" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
200
+ <fo:region-body margin-top="{$marginTop}mm" margin-bottom="{$marginBottom}mm" margin-left="{$marginLeftRight1}mm" margin-right="{$marginLeftRight2}mm"/>
201
+ <fo:region-before region-name="header-even" extent="{$marginTop}mm"/>
202
+ <fo:region-after region-name="footer" extent="{$marginBottom}mm"/>
203
+ <fo:region-start region-name="left-region" extent="{$marginLeftRight1}mm"/>
204
+ <fo:region-end region-name="right-region" extent="{$marginLeftRight2}mm"/>
201
205
  </fo:simple-page-master>
202
206
  <fo:page-sequence-master master-name="document">
203
207
  <fo:repeatable-page-master-alternatives>
@@ -206,11 +210,11 @@
206
210
  </fo:repeatable-page-master-alternatives>
207
211
  </fo:page-sequence-master>
208
212
 
209
- <fo:simple-page-master master-name="blank-page" page-width="{$pageWidth}" page-height="{$pageHeight}">
213
+ <fo:simple-page-master master-name="blank-page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
210
214
  <fo:region-body margin-top="107mm" margin-bottom="0mm" margin-left="18mm" margin-right="0mm"/>
211
215
  </fo:simple-page-master>
212
216
 
213
- <fo:simple-page-master master-name="last-page" page-width="{$pageWidth}" page-height="{$pageHeight}">
217
+ <fo:simple-page-master master-name="last-page" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
214
218
  <fo:region-body margin-top="107mm" margin-bottom="0mm" margin-left="18mm" margin-right="0mm" background-color="rgb(236, 236, 236)"/>
215
219
  <fo:region-before region-name="header" extent="107mm"/>
216
220
  <fo:region-start region-name="left-region" extent="18mm"/>
@@ -2653,7 +2657,7 @@
2653
2657
 
2654
2658
 
2655
2659
 
2656
- <xsl:attribute name="font-family">Courier</xsl:attribute>
2660
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
2657
2661
  <xsl:attribute name="margin-top">5pt</xsl:attribute>
2658
2662
  <xsl:attribute name="margin-bottom">5pt</xsl:attribute>
2659
2663
 
@@ -2746,6 +2750,7 @@
2746
2750
 
2747
2751
 
2748
2752
 
2753
+
2749
2754
  </xsl:attribute-set><xsl:attribute-set name="termexample-name-style">
2750
2755
 
2751
2756
  <xsl:attribute name="padding-right">10mm</xsl:attribute>
@@ -2754,7 +2759,9 @@
2754
2759
 
2755
2760
 
2756
2761
 
2757
- </xsl:attribute-set><xsl:attribute-set name="table-name-style">
2762
+ </xsl:attribute-set><xsl:variable name="table-border_">
2763
+
2764
+ </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-name-style">
2758
2765
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2759
2766
 
2760
2767
 
@@ -2804,6 +2811,7 @@
2804
2811
 
2805
2812
 
2806
2813
 
2814
+
2807
2815
  </xsl:attribute-set><xsl:attribute-set name="note-style">
2808
2816
 
2809
2817
 
@@ -2967,7 +2975,7 @@
2967
2975
  </xsl:attribute-set><xsl:attribute-set name="tt-style">
2968
2976
 
2969
2977
 
2970
- <xsl:attribute name="font-family">Courier</xsl:attribute>
2978
+ <xsl:attribute name="font-family">Courier New</xsl:attribute>
2971
2979
 
2972
2980
 
2973
2981
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-name-style">
@@ -3026,14 +3034,15 @@
3026
3034
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
3027
3035
 
3028
3036
  <!-- Normative references -->
3029
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/>
3037
+ <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"/>
3030
3038
  <!-- Terms and definitions -->
3031
3039
  <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"/>
3032
3040
  <!-- Another main sections -->
3033
3041
  <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"/>
3034
3042
  <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/>
3035
3043
  <!-- Bibliography -->
3036
- <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/>
3044
+ <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"/>
3045
+
3037
3046
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
3038
3047
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
3039
3048
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
@@ -3076,6 +3085,8 @@
3076
3085
  <fo:block>&#xA0;</fo:block>
3077
3086
  </xsl:if> -->
3078
3087
 
3088
+
3089
+ <!-- Display table's name before table as standalone block -->
3079
3090
  <!-- $namespace = 'iso' or -->
3080
3091
 
3081
3092
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -3157,6 +3168,12 @@
3157
3168
 
3158
3169
 
3159
3170
 
3171
+
3172
+
3173
+
3174
+ <!-- display table's name before table for PAS inside block-container (2-columnn layout) -->
3175
+
3176
+
3160
3177
  <xsl:variable name="table_width">
3161
3178
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
3162
3179
  100%
@@ -3173,6 +3190,7 @@
3173
3190
 
3174
3191
 
3175
3192
 
3193
+
3176
3194
  <attribute name="border">0.5pt solid black</attribute>
3177
3195
 
3178
3196
 
@@ -3200,6 +3218,8 @@
3200
3218
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
3201
3219
  </xsl:if>
3202
3220
 
3221
+
3222
+
3203
3223
  <xsl:choose>
3204
3224
  <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
3205
3225
  <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
@@ -3487,9 +3507,9 @@
3487
3507
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation">
3488
3508
  <xsl:with-param name="continued">true</xsl:with-param>
3489
3509
  </xsl:apply-templates>
3490
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
3491
- <xsl:call-template name="fn_name_display"/>
3492
- </xsl:for-each>
3510
+
3511
+
3512
+
3493
3513
 
3494
3514
  </fo:table-cell>
3495
3515
  </fo:table-row>
@@ -3583,7 +3603,11 @@
3583
3603
 
3584
3604
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3585
3605
 
3586
- <xsl:if test="$isNoteOrFnExist = 'true'">
3606
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
3607
+
3608
+ </xsl:variable>
3609
+
3610
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
3587
3611
 
3588
3612
  <xsl:variable name="cols-count">
3589
3613
  <xsl:choose>
@@ -3612,6 +3636,8 @@
3612
3636
  </xsl:choose>
3613
3637
  </xsl:for-each>
3614
3638
 
3639
+
3640
+
3615
3641
  <xsl:choose>
3616
3642
  <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
3617
3643
  <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
@@ -3637,6 +3663,7 @@
3637
3663
  <fo:table-cell border="solid black 1pt" padding-left="1mm" padding-right="1mm" padding-top="1mm" number-columns-spanned="{$cols-count}">
3638
3664
 
3639
3665
 
3666
+
3640
3667
  <xsl:attribute name="border">solid black 0.5pt</xsl:attribute>
3641
3668
 
3642
3669
 
@@ -3652,6 +3679,11 @@
3652
3679
 
3653
3680
 
3654
3681
 
3682
+
3683
+
3684
+ <!-- for BSI (not PAS) display Notes before footnotes -->
3685
+
3686
+
3655
3687
  <!-- except gb -->
3656
3688
 
3657
3689
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
@@ -3683,6 +3715,10 @@
3683
3715
  <!-- fn processing -->
3684
3716
  <xsl:call-template name="fn_display"/>
3685
3717
 
3718
+
3719
+ <!-- for PAS display Notes after footnotes -->
3720
+
3721
+
3686
3722
  </fo:table-cell>
3687
3723
  </fo:table-row>
3688
3724
  </fo:table-body>
@@ -3724,6 +3760,19 @@
3724
3760
 
3725
3761
  </fo:table-body>
3726
3762
 
3763
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/text()[1]" priority="2" mode="presentation_name">
3764
+ <xsl:choose>
3765
+ <xsl:when test="substring-after(., '—') != ''">
3766
+ <xsl:text>—</xsl:text><xsl:value-of select="substring-after(., '—')"/>
3767
+ </xsl:when>
3768
+ <xsl:otherwise>
3769
+ <xsl:value-of select="."/>
3770
+ </xsl:otherwise>
3771
+ </xsl:choose>
3772
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']" mode="presentation_name">
3773
+ <xsl:apply-templates mode="presentation_name"/>
3774
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/node()" mode="presentation_name">
3775
+ <xsl:apply-templates select="."/>
3727
3776
  </xsl:template><xsl:template match="*[local-name()='tr']">
3728
3777
  <xsl:variable name="parent-name" select="local-name(..)"/>
3729
3778
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
@@ -3739,10 +3788,13 @@
3739
3788
  <xsl:attribute name="border-bottom">solid black 0.5pt</xsl:attribute>
3740
3789
 
3741
3790
 
3791
+
3792
+
3742
3793
  </xsl:if>
3743
3794
  <xsl:if test="$parent-name = 'tfoot'">
3744
3795
 
3745
3796
 
3797
+
3746
3798
  <xsl:attribute name="border-left">solid black 0.5pt</xsl:attribute>
3747
3799
  <xsl:attribute name="border-right">solid black 0.5pt</xsl:attribute>
3748
3800
 
@@ -3755,6 +3807,8 @@
3755
3807
 
3756
3808
 
3757
3809
 
3810
+
3811
+
3758
3812
  <!-- <xsl:if test="$namespace = 'bipm'">
3759
3813
  <xsl:attribute name="height">8mm</xsl:attribute>
3760
3814
  </xsl:if> -->
@@ -3842,6 +3896,7 @@
3842
3896
 
3843
3897
 
3844
3898
 
3899
+
3845
3900
  <xsl:if test="ancestor::*[local-name() = 'tfoot']">
3846
3901
  <xsl:attribute name="border">solid black 0</xsl:attribute>
3847
3902
  </xsl:if>
@@ -3888,14 +3943,20 @@
3888
3943
 
3889
3944
 
3890
3945
 
3946
+
3891
3947
  <xsl:attribute name="font-size">8pt</xsl:attribute>
3892
3948
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
3893
3949
 
3894
3950
 
3895
3951
 
3896
3952
 
3953
+
3954
+ <!-- Table's note name (NOTE, for example) -->
3955
+
3897
3956
  <fo:inline padding-right="2mm">
3898
3957
 
3958
+
3959
+
3899
3960
 
3900
3961
 
3901
3962
 
@@ -3903,6 +3964,8 @@
3903
3964
 
3904
3965
  </fo:inline>
3905
3966
 
3967
+
3968
+
3906
3969
  <xsl:apply-templates mode="process"/>
3907
3970
  </fo:block>
3908
3971
 
@@ -3910,18 +3973,18 @@
3910
3973
  <xsl:apply-templates/>
3911
3974
  </xsl:template><xsl:template name="fn_display">
3912
3975
  <xsl:variable name="references">
3976
+
3913
3977
  <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
3914
- <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3915
-
3916
-
3917
- <xsl:apply-templates/>
3918
- </fn>
3978
+ <xsl:call-template name="create_fn"/>
3919
3979
  </xsl:for-each>
3920
3980
  </xsl:variable>
3981
+
3921
3982
  <xsl:for-each select="xalan:nodeset($references)//fn">
3922
3983
  <xsl:variable name="reference" select="@reference"/>
3923
3984
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3924
3985
  <fo:block margin-bottom="12pt">
3986
+
3987
+
3925
3988
 
3926
3989
 
3927
3990
 
@@ -3936,6 +3999,7 @@
3936
3999
 
3937
4000
 
3938
4001
 
4002
+
3939
4003
  <xsl:attribute name="baseline-shift">30%</xsl:attribute>
3940
4004
  <xsl:attribute name="font-size">70%</xsl:attribute>
3941
4005
 
@@ -3946,6 +4010,7 @@
3946
4010
  <xsl:value-of select="@reference"/>
3947
4011
 
3948
4012
 
4013
+
3949
4014
  </fo:inline>
3950
4015
  <fo:inline>
3951
4016
 
@@ -3955,6 +4020,12 @@
3955
4020
  </fo:block>
3956
4021
  </xsl:if>
3957
4022
  </xsl:for-each>
4023
+ </xsl:template><xsl:template name="create_fn">
4024
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
4025
+
4026
+
4027
+ <xsl:apply-templates/>
4028
+ </fn>
3958
4029
  </xsl:template><xsl:template name="fn_name_display">
3959
4030
  <!-- <xsl:variable name="references">
3960
4031
  <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
@@ -4090,7 +4161,9 @@
4090
4161
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
4091
4162
  <fo:inline font-size="80%" keep-with-previous.within-line="always">
4092
4163
 
4093
- <xsl:if test="ancestor::*[local-name()='td']">
4164
+
4165
+
4166
+ <xsl:if test="ancestor::*[local-name()='table']">
4094
4167
  <xsl:attribute name="font-weight">normal</xsl:attribute>
4095
4168
  <!-- <xsl:attribute name="alignment-baseline">hanging</xsl:attribute> -->
4096
4169
  <xsl:attribute name="baseline-shift">15%</xsl:attribute>
@@ -4102,11 +4175,13 @@
4102
4175
 
4103
4176
 
4104
4177
 
4178
+
4105
4179
  <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
4106
4180
 
4107
4181
 
4108
4182
  <xsl:value-of select="@reference"/>
4109
4183
 
4184
+
4110
4185
  </fo:basic-link>
4111
4186
  </fo:inline>
4112
4187
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
@@ -4984,19 +5059,6 @@
4984
5059
  <!-- replace start and end spaces to non-break space -->
4985
5060
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
4986
5061
  </xsl:copy>
4987
- </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml">
4988
- <xsl:copy>
4989
- <xsl:apply-templates select="@*|node()" mode="mathml"/>
4990
- </xsl:copy>
4991
- <xsl:choose>
4992
- <!-- if in msub, then don't add space -->
4993
- <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
4994
- <!-- if next char in digit, don't add space -->
4995
- <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
4996
- <xsl:otherwise>
4997
- <mathml:mspace width="0.5ex"/>
4998
- </xsl:otherwise>
4999
- </xsl:choose>
5000
5062
  </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">
5001
5063
  <xsl:variable name="target">
5002
5064
  <xsl:choose>
@@ -5025,6 +5087,7 @@
5025
5087
  </xsl:if>
5026
5088
 
5027
5089
 
5090
+
5028
5091
  <xsl:choose>
5029
5092
  <xsl:when test="$target_text = ''">
5030
5093
  <xsl:apply-templates/>
@@ -5133,6 +5196,7 @@
5133
5196
 
5134
5197
 
5135
5198
 
5199
+
5136
5200
  <fo:block-container margin-left="0mm">
5137
5201
 
5138
5202
 
@@ -5307,7 +5371,24 @@
5307
5371
  </fo:instream-foreign-object>
5308
5372
  </xsl:when>
5309
5373
  <xsl:otherwise>
5310
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/>
5374
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
5375
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
5376
+
5377
+ <xsl:variable name="img_src">
5378
+ <xsl:choose>
5379
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
5380
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
5381
+ </xsl:choose>
5382
+ </xsl:variable>
5383
+
5384
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
5385
+ <xsl:if test="number($scale) &lt; 100">
5386
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
5387
+ </xsl:if>
5388
+
5389
+ </xsl:if>
5390
+
5391
+ </fo:external-graphic>
5311
5392
  </xsl:otherwise>
5312
5393
  </xsl:choose>
5313
5394
 
@@ -5375,6 +5456,253 @@
5375
5456
  <xsl:param name="height"/>
5376
5457
  <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; "/>
5377
5458
  <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; "/>
5459
+ </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">
5460
+ <xsl:param name="name"/>
5461
+
5462
+ <xsl:variable name="svg_content">
5463
+ <xsl:apply-templates select="." mode="svg_update"/>
5464
+ </xsl:variable>
5465
+
5466
+ <xsl:variable name="alt-text">
5467
+ <xsl:choose>
5468
+ <xsl:when test="normalize-space(../*[local-name() = 'name']) != ''">
5469
+ <xsl:value-of select="../*[local-name() = 'name']"/>
5470
+ </xsl:when>
5471
+ <xsl:when test="normalize-space($name) != ''">
5472
+ <xsl:value-of select="$name"/>
5473
+ </xsl:when>
5474
+ <xsl:otherwise>Figure</xsl:otherwise>
5475
+ </xsl:choose>
5476
+ </xsl:variable>
5477
+
5478
+ <xsl:choose>
5479
+ <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]">
5480
+ <fo:block>
5481
+ <xsl:variable name="width" select="@width"/>
5482
+ <xsl:variable name="height" select="@height"/>
5483
+
5484
+ <xsl:variable name="scale_x">
5485
+ <xsl:choose>
5486
+ <xsl:when test="$width &gt; $width_effective_px">
5487
+ <xsl:value-of select="$width_effective_px div $width"/>
5488
+ </xsl:when>
5489
+ <xsl:otherwise>1</xsl:otherwise>
5490
+ </xsl:choose>
5491
+ </xsl:variable>
5492
+
5493
+ <xsl:variable name="scale_y">
5494
+ <xsl:choose>
5495
+ <xsl:when test="$height * $scale_x &gt; $height_effective_px">
5496
+ <xsl:value-of select="$height_effective_px div ($height * $scale_x)"/>
5497
+ </xsl:when>
5498
+ <xsl:otherwise>1</xsl:otherwise>
5499
+ </xsl:choose>
5500
+ </xsl:variable>
5501
+
5502
+ <xsl:variable name="scale">
5503
+ <xsl:choose>
5504
+ <xsl:when test="$scale_y != 1">
5505
+ <xsl:value-of select="$scale_x * $scale_y"/>
5506
+ </xsl:when>
5507
+ <xsl:otherwise>
5508
+ <xsl:value-of select="$scale_x"/>
5509
+ </xsl:otherwise>
5510
+ </xsl:choose>
5511
+ </xsl:variable>
5512
+
5513
+ <xsl:variable name="width_scale" select="round($width * $scale)"/>
5514
+ <xsl:variable name="height_scale" select="round($height * $scale)"/>
5515
+
5516
+ <fo:table table-layout="fixed" width="100%">
5517
+ <fo:table-column column-width="proportional-column-width(1)"/>
5518
+ <fo:table-column column-width="{$width_scale}px"/>
5519
+ <fo:table-column column-width="proportional-column-width(1)"/>
5520
+ <fo:table-body>
5521
+ <fo:table-row>
5522
+ <fo:table-cell column-number="2">
5523
+ <fo:block>
5524
+ <fo:block-container width="{$width_scale}px" height="{$height_scale}px">
5525
+ <xsl:if test="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
5526
+ <fo:block line-height="0" font-size="0">
5527
+ <xsl:for-each select="../*[local-name() = 'name']/*[local-name() = 'bookmark']">
5528
+ <xsl:call-template name="bookmark"/>
5529
+ </xsl:for-each>
5530
+ </fo:block>
5531
+ </xsl:if>
5532
+ <fo:block text-depth="0" line-height="0" font-size="0">
5533
+
5534
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
5535
+ <xsl:attribute name="width">100%</xsl:attribute>
5536
+ <xsl:attribute name="content-height">100%</xsl:attribute>
5537
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5538
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5539
+
5540
+ <xsl:apply-templates select="xalan:nodeset($svg_content)" mode="svg_remove_a"/>
5541
+ </fo:instream-foreign-object>
5542
+ </fo:block>
5543
+
5544
+ <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">
5545
+ <xsl:with-param name="scale" select="$scale"/>
5546
+ </xsl:apply-templates>
5547
+ </fo:block-container>
5548
+ </fo:block>
5549
+ </fo:table-cell>
5550
+ </fo:table-row>
5551
+ </fo:table-body>
5552
+ </fo:table>
5553
+ </fo:block>
5554
+
5555
+ </xsl:when>
5556
+ <xsl:otherwise>
5557
+ <fo:block xsl:use-attribute-sets="image-style">
5558
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
5559
+ <xsl:attribute name="width">100%</xsl:attribute>
5560
+ <xsl:attribute name="content-height">100%</xsl:attribute>
5561
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
5562
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
5563
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
5564
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
5565
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
5566
+ <!-- effective height / width = 1.48, 1.4 - with title -->
5567
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
5568
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
5569
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
5570
+ </xsl:if>
5571
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
5572
+ <xsl:copy-of select="$svg_content"/>
5573
+ </fo:instream-foreign-object>
5574
+ </fo:block>
5575
+ </xsl:otherwise>
5576
+ </xsl:choose>
5577
+ </xsl:template><xsl:template match="@*|node()" mode="svg_update">
5578
+ <xsl:copy>
5579
+ <xsl:apply-templates select="@*|node()" mode="svg_update"/>
5580
+ </xsl:copy>
5581
+ </xsl:template><xsl:template match="*[local-name() = 'image']/@href" mode="svg_update">
5582
+ <xsl:attribute name="href" namespace="http://www.w3.org/1999/xlink">
5583
+ <xsl:value-of select="."/>
5584
+ </xsl:attribute>
5585
+ </xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
5586
+ <xsl:copy>
5587
+ <xsl:apply-templates select="@*" mode="svg_update"/>
5588
+ <xsl:variable name="viewbox">
5589
+ <xsl:call-template name="split">
5590
+ <xsl:with-param name="pText" select="@viewBox"/>
5591
+ <xsl:with-param name="sep" select="' '"/>
5592
+ </xsl:call-template>
5593
+ </xsl:variable>
5594
+ <xsl:attribute name="width">
5595
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[3])"/>
5596
+ </xsl:attribute>
5597
+ <xsl:attribute name="height">
5598
+ <xsl:value-of select="round(xalan:nodeset($viewbox)//item[4])"/>
5599
+ </xsl:attribute>
5600
+ <xsl:apply-templates mode="svg_update"/>
5601
+ </xsl:copy>
5602
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
5603
+ <xsl:variable name="svg_content" select="document(@src)"/>
5604
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
5605
+ <xsl:for-each select="xalan:nodeset($svg_content)/node()">
5606
+ <xsl:call-template name="image_svg">
5607
+ <xsl:with-param name="name" select="$name"/>
5608
+ </xsl:call-template>
5609
+ </xsl:for-each>
5610
+ </xsl:template><xsl:template match="@*|node()" mode="svg_remove_a">
5611
+ <xsl:copy>
5612
+ <xsl:apply-templates select="@*|node()" mode="svg_remove_a"/>
5613
+ </xsl:copy>
5614
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_remove_a">
5615
+ <xsl:apply-templates mode="svg_remove_a"/>
5616
+ </xsl:template><xsl:template match="*[local-name() = 'a']" mode="svg_imagemap_links">
5617
+ <xsl:param name="scale"/>
5618
+ <xsl:variable name="dest">
5619
+ <xsl:choose>
5620
+ <xsl:when test="starts-with(@href, '#')">
5621
+ <xsl:value-of select="substring-after(@href, '#')"/>
5622
+ </xsl:when>
5623
+ <xsl:otherwise>
5624
+ <xsl:value-of select="@href"/>
5625
+ </xsl:otherwise>
5626
+ </xsl:choose>
5627
+ </xsl:variable>
5628
+ <xsl:for-each select="./*[local-name() = 'rect']">
5629
+ <xsl:call-template name="insertSVGMapLink">
5630
+ <xsl:with-param name="left" select="floor(@x * $scale)"/>
5631
+ <xsl:with-param name="top" select="floor(@y * $scale)"/>
5632
+ <xsl:with-param name="width" select="floor(@width * $scale)"/>
5633
+ <xsl:with-param name="height" select="floor(@height * $scale)"/>
5634
+ <xsl:with-param name="dest" select="$dest"/>
5635
+ </xsl:call-template>
5636
+ </xsl:for-each>
5637
+
5638
+ <xsl:for-each select="./*[local-name() = 'polygon']">
5639
+ <xsl:variable name="points">
5640
+ <xsl:call-template name="split">
5641
+ <xsl:with-param name="pText" select="@points"/>
5642
+ </xsl:call-template>
5643
+ </xsl:variable>
5644
+ <xsl:variable name="x_coords">
5645
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 1]">
5646
+ <xsl:sort select="." data-type="number"/>
5647
+ <x><xsl:value-of select="."/></x>
5648
+ </xsl:for-each>
5649
+ </xsl:variable>
5650
+ <xsl:variable name="y_coords">
5651
+ <xsl:for-each select="xalan:nodeset($points)//item[position() mod 2 = 0]">
5652
+ <xsl:sort select="." data-type="number"/>
5653
+ <y><xsl:value-of select="."/></y>
5654
+ </xsl:for-each>
5655
+ </xsl:variable>
5656
+ <xsl:variable name="x" select="xalan:nodeset($x_coords)//x[1]"/>
5657
+ <xsl:variable name="y" select="xalan:nodeset($y_coords)//y[1]"/>
5658
+ <xsl:variable name="width" select="xalan:nodeset($x_coords)//x[last()] - $x"/>
5659
+ <xsl:variable name="height" select="xalan:nodeset($y_coords)//y[last()] - $y"/>
5660
+ <xsl:call-template name="insertSVGMapLink">
5661
+ <xsl:with-param name="left" select="floor($x * $scale)"/>
5662
+ <xsl:with-param name="top" select="floor($y * $scale)"/>
5663
+ <xsl:with-param name="width" select="floor($width * $scale)"/>
5664
+ <xsl:with-param name="height" select="floor($height * $scale)"/>
5665
+ <xsl:with-param name="dest" select="$dest"/>
5666
+ </xsl:call-template>
5667
+ </xsl:for-each>
5668
+
5669
+ <xsl:for-each select="./*[local-name() = 'circle']">
5670
+ <xsl:call-template name="insertSVGMapLink">
5671
+ <xsl:with-param name="left" select="floor((@cx - @r) * $scale)"/>
5672
+ <xsl:with-param name="top" select="floor((@cy - @r) * $scale)"/>
5673
+ <xsl:with-param name="width" select="floor(@r * 2 * $scale)"/>
5674
+ <xsl:with-param name="height" select="floor(@r * 2 * $scale)"/>
5675
+ <xsl:with-param name="dest" select="$dest"/>
5676
+ </xsl:call-template>
5677
+ </xsl:for-each>
5678
+ <xsl:for-each select="./*[local-name() = 'ellipse']">
5679
+ <xsl:call-template name="insertSVGMapLink">
5680
+ <xsl:with-param name="left" select="floor((@cx - @rx) * $scale)"/>
5681
+ <xsl:with-param name="top" select="floor((@cy - @ry) * $scale)"/>
5682
+ <xsl:with-param name="width" select="floor(@rx * 2 * $scale)"/>
5683
+ <xsl:with-param name="height" select="floor(@ry * 2 * $scale)"/>
5684
+ <xsl:with-param name="dest" select="$dest"/>
5685
+ </xsl:call-template>
5686
+ </xsl:for-each>
5687
+ </xsl:template><xsl:template name="insertSVGMapLink">
5688
+ <xsl:param name="left"/>
5689
+ <xsl:param name="top"/>
5690
+ <xsl:param name="width"/>
5691
+ <xsl:param name="height"/>
5692
+ <xsl:param name="dest"/>
5693
+ <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
5694
+ <fo:block font-size="1pt">
5695
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
5696
+ <fo:inline-container inline-progression-dimension="100%">
5697
+ <fo:block-container height="{$height - 1}px" width="100%">
5698
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
5699
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
5700
+ </xsl:if> -->
5701
+ <fo:block> </fo:block></fo:block-container>
5702
+ </fo:inline-container>
5703
+ </fo:basic-link>
5704
+ </fo:block>
5705
+ </fo:block-container>
5378
5706
  </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">
5379
5707
  <xsl:apply-templates mode="contents"/>
5380
5708
  <xsl:text> </xsl:text>
@@ -5403,28 +5731,39 @@
5403
5731
  <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
5404
5732
  <xsl:for-each select="xalan:nodeset($contents)/doc">
5405
5733
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
5734
+ <xsl:if test="@bundle = 'true'">
5735
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute>
5736
+ </xsl:if>
5406
5737
  <fo:bookmark-title>
5407
- <xsl:variable name="bookmark-title_">
5408
- <xsl:call-template name="getLangVersion">
5409
- <xsl:with-param name="lang" select="@lang"/>
5410
- <xsl:with-param name="doctype" select="@doctype"/>
5411
- <xsl:with-param name="title" select="@title-part"/>
5412
- </xsl:call-template>
5413
- </xsl:variable>
5414
5738
  <xsl:choose>
5415
- <xsl:when test="normalize-space($bookmark-title_) != ''">
5416
- <xsl:value-of select="normalize-space($bookmark-title_)"/>
5417
- </xsl:when>
5418
- <xsl:otherwise>
5739
+ <xsl:when test="not(normalize-space(@bundle) = 'true')"> <!-- 'bundle' means several different documents (not language versions) in one xml -->
5740
+ <xsl:variable name="bookmark-title_">
5741
+ <xsl:call-template name="getLangVersion">
5742
+ <xsl:with-param name="lang" select="@lang"/>
5743
+ <xsl:with-param name="doctype" select="@doctype"/>
5744
+ <xsl:with-param name="title" select="@title-part"/>
5745
+ </xsl:call-template>
5746
+ </xsl:variable>
5419
5747
  <xsl:choose>
5420
- <xsl:when test="@lang = 'en'">English</xsl:when>
5421
- <xsl:when test="@lang = 'fr'">Français</xsl:when>
5422
- <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
5423
- <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
5748
+ <xsl:when test="normalize-space($bookmark-title_) != ''">
5749
+ <xsl:value-of select="normalize-space($bookmark-title_)"/>
5750
+ </xsl:when>
5751
+ <xsl:otherwise>
5752
+ <xsl:choose>
5753
+ <xsl:when test="@lang = 'en'">English</xsl:when>
5754
+ <xsl:when test="@lang = 'fr'">Français</xsl:when>
5755
+ <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
5756
+ <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
5757
+ </xsl:choose>
5758
+ </xsl:otherwise>
5424
5759
  </xsl:choose>
5760
+ </xsl:when>
5761
+ <xsl:otherwise>
5762
+ <xsl:value-of select="@title-part"/>
5425
5763
  </xsl:otherwise>
5426
5764
  </xsl:choose>
5427
5765
  </fo:bookmark-title>
5766
+
5428
5767
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
5429
5768
 
5430
5769
  <xsl:call-template name="insertFigureBookmarks">
@@ -5523,16 +5862,23 @@
5523
5862
  <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
5524
5863
  </xsl:choose>
5525
5864
  </xsl:template><xsl:template match="item" mode="bookmark">
5526
- <fo:bookmark internal-destination="{@id}" starting-state="hide">
5527
- <fo:bookmark-title>
5528
- <xsl:if test="@section != ''">
5529
- <xsl:value-of select="@section"/>
5530
- <xsl:text> </xsl:text>
5531
- </xsl:if>
5532
- <xsl:value-of select="normalize-space(title)"/>
5533
- </fo:bookmark-title>
5534
- <xsl:apply-templates mode="bookmark"/>
5535
- </fo:bookmark>
5865
+ <xsl:choose>
5866
+ <xsl:when test="@id != ''">
5867
+ <fo:bookmark internal-destination="{@id}" starting-state="hide">
5868
+ <fo:bookmark-title>
5869
+ <xsl:if test="@section != ''">
5870
+ <xsl:value-of select="@section"/>
5871
+ <xsl:text> </xsl:text>
5872
+ </xsl:if>
5873
+ <xsl:value-of select="normalize-space(title)"/>
5874
+ </fo:bookmark-title>
5875
+ <xsl:apply-templates mode="bookmark"/>
5876
+ </fo:bookmark>
5877
+ </xsl:when>
5878
+ <xsl:otherwise>
5879
+ <xsl:apply-templates mode="bookmark"/>
5880
+ </xsl:otherwise>
5881
+ </xsl:choose>
5536
5882
  </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">
5537
5883
  <xsl:if test="normalize-space() != ''">
5538
5884
  <fo:block xsl:use-attribute-sets="figure-name-style">
@@ -5898,7 +6244,19 @@
5898
6244
  </fo:inline>
5899
6245
  </xsl:if>
5900
6246
  </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'p']">
5901
- <fo:inline><xsl:apply-templates/></fo:inline>
6247
+ <xsl:variable name="element">inline
6248
+
6249
+ </xsl:variable>
6250
+ <xsl:choose>
6251
+ <xsl:when test="contains($element, 'block')">
6252
+ <fo:block xsl:use-attribute-sets="example-p-style">
6253
+ <xsl:apply-templates/>
6254
+ </fo:block>
6255
+ </xsl:when>
6256
+ <xsl:otherwise>
6257
+ <fo:inline><xsl:apply-templates/></fo:inline>
6258
+ </xsl:otherwise>
6259
+ </xsl:choose>
5902
6260
  </xsl:template><xsl:template match="*[local-name() = 'example']">
5903
6261
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
5904
6262
 
@@ -6091,7 +6449,9 @@
6091
6449
 
6092
6450
 
6093
6451
  </xsl:if>
6094
-
6452
+
6453
+
6454
+
6095
6455
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6096
6456
  <xsl:if test="normalize-space(@citeas) = ''">
6097
6457
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
@@ -6100,6 +6460,7 @@
6100
6460
 
6101
6461
 
6102
6462
 
6463
+
6103
6464
  </xsl:if>
6104
6465
 
6105
6466
  <xsl:apply-templates/>
@@ -6475,7 +6836,6 @@
6475
6836
  </xsl:template><xsl:template name="processBibitem">
6476
6837
 
6477
6838
 
6478
- <!-- end BIPM bibitem processing-->
6479
6839
 
6480
6840
 
6481
6841
 
@@ -6940,20 +7300,40 @@
6940
7300
  </xsl:call-template>
6941
7301
  </xsl:if>
6942
7302
  </xsl:template><xsl:template name="getLocalizedString">
6943
- <xsl:param name="key"/>
7303
+ <xsl:param name="key"/>
7304
+ <xsl:param name="formatted">false</xsl:param>
6944
7305
 
6945
7306
  <xsl:variable name="curr_lang">
6946
7307
  <xsl:call-template name="getLang"/>
6947
7308
  </xsl:variable>
6948
7309
 
6949
- <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
7310
+ <xsl:variable name="data_value">
7311
+ <xsl:choose>
7312
+ <xsl:when test="$formatted = 'true'">
7313
+ <xsl:apply-templates select="xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
7314
+ </xsl:when>
7315
+ <xsl:otherwise>
7316
+ <xsl:value-of select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/>
7317
+ </xsl:otherwise>
7318
+ </xsl:choose>
7319
+ </xsl:variable>
6950
7320
 
6951
7321
  <xsl:choose>
6952
- <xsl:when test="$data_value != ''">
6953
- <xsl:value-of select="$data_value"/>
7322
+ <xsl:when test="normalize-space($data_value) != ''">
7323
+ <xsl:choose>
7324
+ <xsl:when test="$formatted = 'true'"><xsl:copy-of select="$data_value"/></xsl:when>
7325
+ <xsl:otherwise><xsl:value-of select="$data_value"/></xsl:otherwise>
7326
+ </xsl:choose>
6954
7327
  </xsl:when>
6955
7328
  <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
6956
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
7329
+ <xsl:choose>
7330
+ <xsl:when test="$formatted = 'true'">
7331
+ <xsl:apply-templates select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
7332
+ </xsl:when>
7333
+ <xsl:otherwise>
7334
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
7335
+ </xsl:otherwise>
7336
+ </xsl:choose>
6957
7337
  </xsl:when>
6958
7338
  <xsl:otherwise>
6959
7339
  <xsl:variable name="key_">
@@ -6964,7 +7344,7 @@
6964
7344
  <xsl:value-of select="$key_"/>
6965
7345
  </xsl:otherwise>
6966
7346
  </xsl:choose>
6967
-
7347
+
6968
7348
  </xsl:template><xsl:template name="setTrackChangesStyles">
6969
7349
  <xsl:param name="isAdded"/>
6970
7350
  <xsl:param name="isDeleted"/>
@@ -7015,4 +7395,100 @@
7015
7395
  <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise>
7016
7396
  </xsl:choose>
7017
7397
  </xsl:attribute>
7398
+ </xsl:template><xsl:template name="number-to-words">
7399
+ <xsl:param name="number"/>
7400
+ <xsl:param name="first"/>
7401
+ <xsl:if test="$number != ''">
7402
+ <xsl:variable name="words">
7403
+ <words>
7404
+ <word cardinal="1">One-</word>
7405
+ <word ordinal="1">First </word>
7406
+ <word cardinal="2">Two-</word>
7407
+ <word ordinal="2">Second </word>
7408
+ <word cardinal="3">Three-</word>
7409
+ <word ordinal="3">Third </word>
7410
+ <word cardinal="4">Four-</word>
7411
+ <word ordinal="4">Fourth </word>
7412
+ <word cardinal="5">Five-</word>
7413
+ <word ordinal="5">Fifth </word>
7414
+ <word cardinal="6">Six-</word>
7415
+ <word ordinal="6">Sixth </word>
7416
+ <word cardinal="7">Seven-</word>
7417
+ <word ordinal="7">Seventh </word>
7418
+ <word cardinal="8">Eight-</word>
7419
+ <word ordinal="8">Eighth </word>
7420
+ <word cardinal="9">Nine-</word>
7421
+ <word ordinal="9">Ninth </word>
7422
+ <word ordinal="10">Tenth </word>
7423
+ <word ordinal="11">Eleventh </word>
7424
+ <word ordinal="12">Twelfth </word>
7425
+ <word ordinal="13">Thirteenth </word>
7426
+ <word ordinal="14">Fourteenth </word>
7427
+ <word ordinal="15">Fifteenth </word>
7428
+ <word ordinal="16">Sixteenth </word>
7429
+ <word ordinal="17">Seventeenth </word>
7430
+ <word ordinal="18">Eighteenth </word>
7431
+ <word ordinal="19">Nineteenth </word>
7432
+ <word cardinal="20">Twenty-</word>
7433
+ <word ordinal="20">Twentieth </word>
7434
+ <word cardinal="30">Thirty-</word>
7435
+ <word ordinal="30">Thirtieth </word>
7436
+ <word cardinal="40">Forty-</word>
7437
+ <word ordinal="40">Fortieth </word>
7438
+ <word cardinal="50">Fifty-</word>
7439
+ <word ordinal="50">Fiftieth </word>
7440
+ <word cardinal="60">Sixty-</word>
7441
+ <word ordinal="60">Sixtieth </word>
7442
+ <word cardinal="70">Seventy-</word>
7443
+ <word ordinal="70">Seventieth </word>
7444
+ <word cardinal="80">Eighty-</word>
7445
+ <word ordinal="80">Eightieth </word>
7446
+ <word cardinal="90">Ninety-</word>
7447
+ <word ordinal="90">Ninetieth </word>
7448
+ <word cardinal="100">Hundred-</word>
7449
+ <word ordinal="100">Hundredth </word>
7450
+ </words>
7451
+ </xsl:variable>
7452
+
7453
+ <xsl:variable name="ordinal" select="xalan:nodeset($words)//word[@ordinal = $number]/text()"/>
7454
+
7455
+ <xsl:variable name="value">
7456
+ <xsl:choose>
7457
+ <xsl:when test="$ordinal != ''">
7458
+ <xsl:value-of select="$ordinal"/>
7459
+ </xsl:when>
7460
+ <xsl:otherwise>
7461
+ <xsl:choose>
7462
+ <xsl:when test="$number &lt; 100">
7463
+ <xsl:variable name="decade" select="concat(substring($number,1,1), '0')"/>
7464
+ <xsl:variable name="digit" select="substring($number,2)"/>
7465
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $decade]/text()"/>
7466
+ <xsl:value-of select="xalan:nodeset($words)//word[@ordinal = $digit]/text()"/>
7467
+ </xsl:when>
7468
+ <xsl:otherwise>
7469
+ <!-- more 100 -->
7470
+ <xsl:variable name="hundred" select="substring($number,1,1)"/>
7471
+ <xsl:variable name="digits" select="number(substring($number,2))"/>
7472
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = $hundred]/text()"/>
7473
+ <xsl:value-of select="xalan:nodeset($words)//word[@cardinal = '100']/text()"/>
7474
+ <xsl:call-template name="number-to-words">
7475
+ <xsl:with-param name="number" select="$digits"/>
7476
+ </xsl:call-template>
7477
+ </xsl:otherwise>
7478
+ </xsl:choose>
7479
+ </xsl:otherwise>
7480
+ </xsl:choose>
7481
+ </xsl:variable>
7482
+ <xsl:choose>
7483
+ <xsl:when test="$first = 'true'">
7484
+ <xsl:variable name="value_lc" select="java:toLowerCase(java:java.lang.String.new($value))"/>
7485
+ <xsl:call-template name="capitalize">
7486
+ <xsl:with-param name="str" select="$value_lc"/>
7487
+ </xsl:call-template>
7488
+ </xsl:when>
7489
+ <xsl:otherwise>
7490
+ <xsl:value-of select="$value"/>
7491
+ </xsl:otherwise>
7492
+ </xsl:choose>
7493
+ </xsl:if>
7018
7494
  </xsl:template></xsl:stylesheet>