metanorma-m3aawg 1.5.6 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,35 +1,18 @@
1
1
  require "isodoc"
2
+ require "isodoc/generic/html_convert"
2
3
  require_relative "base_convert"
3
4
  require_relative "init"
4
5
 
5
6
  module IsoDoc
6
7
  module M3AAWG
7
- # A {Converter} implementation that generates CSAND output, and a document
8
- # schema encapsulation of the document for validation
9
- class HtmlConvert < IsoDoc::HtmlConvert
10
- def initialize(options)
11
- @libdir = File.dirname(__FILE__)
12
- super
13
- end
14
-
15
- def default_fonts(options)
16
- {
17
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
18
- '"Overpass",sans-serif'),
19
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
20
- '"Overpass",sans-serif'),
21
- monospacefont: '"Space Mono",monospace'
22
- }
8
+ class HtmlConvert < IsoDoc::Generic::HtmlConvert
9
+ def configuration
10
+ Metanorma::M3AAWG.configuration
23
11
  end
24
12
 
25
- def default_file_locations(_options)
26
- {
27
- htmlstylesheet: html_doc_path("htmlstyle.scss"),
28
- htmlcoverpage: html_doc_path("html_m3d_titlepage.html"),
29
- htmlintropage: html_doc_path("html_m3d_intro.html"),
30
- standardstylesheet: nil,
31
- scripts: html_doc_path("scripts.html"),
32
- }
13
+ def initialize(options)
14
+ #require "byebug"; byebug
15
+ super
33
16
  end
34
17
 
35
18
  def colophon(body, docxml)
@@ -45,13 +28,6 @@ module IsoDoc
45
28
  end
46
29
  end
47
30
 
48
- def googlefonts()
49
- <<~HEAD.freeze
50
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
51
- <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
52
- HEAD
53
- end
54
-
55
31
  def make_body(xml, docxml)
56
32
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72",
57
33
  "xml:lang": "EN-US", class: "container" }
@@ -1,9 +1,8 @@
1
1
  module IsoDoc
2
2
  module M3AAWG
3
- class I18n < IsoDoc::I18n
4
- def load_yaml1(lang, script)
5
- y = YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
6
- super.merge(y)
3
+ class I18n < IsoDoc::Generic::I18n
4
+ def configuration
5
+ Metanorma::M3AAWG.configuration
7
6
  end
8
7
  end
9
8
  end
@@ -11,16 +11,13 @@ module IsoDoc
11
11
  end
12
12
 
13
13
  def xref_init(lang, script, klass, labels, options)
14
- @xrefs = Xref.new(lang, script, HtmlConvert.new(language: lang, script: script), labels, options)
14
+ html = HtmlConvert.new(language: lang, script: script)
15
+ @xrefs = Xref.new(lang, script, html, labels, options)
15
16
  end
16
17
 
17
18
  def i18n_init(lang, script, i18nyaml = nil)
18
19
  @i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
19
20
  end
20
-
21
- def fileloc(loc)
22
- File.join(File.dirname(__FILE__), loc)
23
- end
24
21
  end
25
22
  end
26
23
  end
@@ -218,55 +218,89 @@
218
218
  </xsl:call-template>
219
219
  </xsl:variable>
220
220
  <fo:block font-size="12pt" font-weight="bold" text-decoration="underline" margin-bottom="4pt"><xsl:value-of select="$title-toc"/></fo:block>
221
- <fo:table table-layout="fixed" width="100%" font-size="10pt">
222
- <fo:table-column column-width="25mm"/>
223
- <fo:table-column column-width="155mm"/>
224
- <fo:table-body>
225
- <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
226
- <fo:table-row height="6mm">
227
- <fo:table-cell>
228
- <fo:block font-weight="bold">
229
- <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
230
- <xsl:choose>
231
- <xsl:when test="@section = ''">
232
- <xsl:apply-templates select="title"/>
233
- </xsl:when>
234
- <xsl:when test="@type = 'references' and @section = ''">
235
- <xsl:apply-templates select="title"/>
236
- </xsl:when>
237
- <xsl:when test="@level = 1">
238
- <xsl:value-of select="@section"/>
239
- </xsl:when>
240
- <xsl:otherwise/>
241
- </xsl:choose>
242
- </fo:basic-link>
243
- </fo:block>
244
- </fo:table-cell>
245
- <fo:table-cell>
246
- <fo:block text-align-last="justify">
247
- <xsl:if test="@level = 1">
248
- <xsl:attribute name="font-weight">bold</xsl:attribute>
249
- </xsl:if>
250
- <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
251
- <xsl:choose>
252
- <xsl:when test="@section = ''"/>
253
- <xsl:when test="@type = 'references' and @section = ''"/>
254
- <xsl:otherwise>
255
- <xsl:apply-templates select="title"/>
256
- </xsl:otherwise>
257
- </xsl:choose>
258
-
259
- <fo:inline keep-together.within-line="always">
260
- <fo:leader font-weight="normal" leader-pattern="dots"/>
261
- <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
262
- </fo:inline>
263
- </fo:basic-link>
264
- </fo:block>
265
- </fo:table-cell>
266
- </fo:table-row>
267
- </xsl:for-each>
268
- </fo:table-body>
269
- </fo:table>
221
+ <fo:block font-size="10pt">
222
+ <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"><!-- [not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->
223
+ <xsl:choose>
224
+ <xsl:when test="@section = ''">
225
+ <fo:table table-layout="fixed" width="100%">
226
+ <fo:table-column column-width="180mm"/>
227
+ <fo:table-body>
228
+ <fo:table-row height="6mm">
229
+ <fo:table-cell>
230
+ <fo:block text-align-last="justify">
231
+ <xsl:if test="@level = 1">
232
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
233
+ </xsl:if>
234
+ <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
235
+ <fo:inline font-weight="bold">
236
+ <xsl:apply-templates select="title"/><xsl:text> </xsl:text>
237
+ </fo:inline>
238
+ <fo:inline keep-together.within-line="always">
239
+ <fo:leader font-weight="normal" leader-pattern="dots"/>
240
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
241
+ </fo:inline>
242
+ </fo:basic-link>
243
+ </fo:block>
244
+ </fo:table-cell>
245
+ </fo:table-row>
246
+ </fo:table-body>
247
+ </fo:table>
248
+ </xsl:when>
249
+ <xsl:otherwise>
250
+ <fo:table table-layout="fixed" width="100%">
251
+ <fo:table-column column-width="5mm"/> <!-- 25mm -->
252
+ <fo:table-column column-width="175mm"/> <!-- 155mm -->
253
+ <fo:table-body>
254
+ <fo:table-row height="6mm">
255
+ <fo:table-cell>
256
+ <fo:block font-weight="bold">
257
+ <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
258
+ <xsl:choose>
259
+ <!-- <xsl:when test="@section = ''">
260
+ <xsl:apply-templates select="title"/>
261
+ </xsl:when> -->
262
+ <!-- <xsl:when test="@type = 'references' and @section = ''">
263
+ <xsl:apply-templates select="title"/>
264
+ </xsl:when> -->
265
+ <xsl:when test="@level = 1">
266
+ <xsl:value-of select="@section"/>
267
+ </xsl:when>
268
+ <xsl:otherwise/>
269
+ </xsl:choose>
270
+ </fo:basic-link>
271
+ </fo:block>
272
+ </fo:table-cell>
273
+ <fo:table-cell>
274
+ <fo:block text-align-last="justify">
275
+ <xsl:if test="@level = 1">
276
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
277
+ </xsl:if>
278
+ <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
279
+ <!-- <xsl:choose>
280
+ <xsl:when test="@section = ''"></xsl:when>
281
+ <xsl:otherwise>
282
+ <xsl:apply-templates select="title"/>
283
+ </xsl:otherwise>
284
+ </xsl:choose> -->
285
+ <xsl:apply-templates select="title"/><xsl:text> </xsl:text>
286
+ <fo:inline keep-together.within-line="always">
287
+ <fo:leader font-weight="normal" leader-pattern="dots"/>
288
+ <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
289
+ </fo:inline>
290
+ </fo:basic-link>
291
+ </fo:block>
292
+ </fo:table-cell>
293
+ </fo:table-row>
294
+ </fo:table-body>
295
+ </fo:table>
296
+ </xsl:otherwise>
297
+
298
+ </xsl:choose>
299
+
300
+
301
+
302
+ </xsl:for-each>
303
+ </fo:block>
270
304
  </fo:block-container>
271
305
 
272
306
  <fo:block break-after="page"/>
@@ -365,7 +399,7 @@
365
399
  <xsl:otherwise> <!-- for ordered lists -->
366
400
  <xsl:choose>
367
401
  <xsl:when test="../@type = 'arabic'">
368
- <xsl:number format="a)"/>
402
+ <xsl:number format="a)" lang="en"/>
369
403
  </xsl:when>
370
404
  <xsl:when test="../@type = 'alphabet'">
371
405
  <xsl:number format="1)"/>
@@ -908,13 +942,22 @@
908
942
  <title-part lang="en">
909
943
 
910
944
 
945
+
911
946
  </title-part>
912
947
  <title-part lang="fr">
913
948
 
914
949
 
950
+
915
951
  </title-part>
916
952
  <title-part lang="zh">第 # 部分:</title-part>
917
953
 
954
+ <title-subpart lang="en">
955
+
956
+ </title-subpart>
957
+ <title-subpart lang="fr">
958
+
959
+ </title-subpart>
960
+
918
961
  <title-modified lang="en">modified</title-modified>
919
962
  <title-modified lang="fr">modifiée</title-modified>
920
963
 
@@ -1226,6 +1269,7 @@
1226
1269
 
1227
1270
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1228
1271
 
1272
+
1229
1273
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1230
1274
 
1231
1275
 
@@ -1256,6 +1300,7 @@
1256
1300
  </xsl:attribute-set><xsl:attribute-set name="term-style">
1257
1301
 
1258
1302
  </xsl:attribute-set><xsl:attribute-set name="figure-name-style">
1303
+
1259
1304
 
1260
1305
 
1261
1306
 
@@ -1380,7 +1425,9 @@
1380
1425
 
1381
1426
 
1382
1427
 
1383
-
1428
+ <!-- <xsl:if test="$namespace = 'bipm'">
1429
+ <fo:block>&#xA0;</fo:block>
1430
+ </xsl:if> -->
1384
1431
 
1385
1432
  <!-- $namespace = 'iso' or -->
1386
1433
 
@@ -1414,10 +1461,12 @@
1414
1461
 
1415
1462
 
1416
1463
  <xsl:variable name="colwidths">
1417
- <xsl:call-template name="calculate-column-widths">
1418
- <xsl:with-param name="cols-count" select="$cols-count"/>
1419
- <xsl:with-param name="table" select="$simple-table"/>
1420
- </xsl:call-template>
1464
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
1465
+ <xsl:call-template name="calculate-column-widths">
1466
+ <xsl:with-param name="cols-count" select="$cols-count"/>
1467
+ <xsl:with-param name="table" select="$simple-table"/>
1468
+ </xsl:call-template>
1469
+ </xsl:if>
1421
1470
  </xsl:variable>
1422
1471
  <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
1423
1472
 
@@ -1456,7 +1505,12 @@
1456
1505
 
1457
1506
  <xsl:variable name="table_attributes">
1458
1507
  <attribute name="table-layout">fixed</attribute>
1459
- <attribute name="width">100%</attribute>
1508
+ <attribute name="width">
1509
+ <xsl:choose>
1510
+ <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
1511
+ <xsl:otherwise>100%</xsl:otherwise>
1512
+ </xsl:choose>
1513
+ </attribute>
1460
1514
  <attribute name="margin-left"><xsl:value-of select="$margin-left"/>mm</attribute>
1461
1515
  <attribute name="margin-right"><xsl:value-of select="$margin-left"/>mm</attribute>
1462
1516
 
@@ -1485,16 +1539,25 @@
1485
1539
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
1486
1540
  </xsl:if>
1487
1541
 
1488
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
1489
- <xsl:choose>
1490
- <xsl:when test=". = 1 or . = 0">
1491
- <fo:table-column column-width="proportional-column-width(2)"/>
1492
- </xsl:when>
1493
- <xsl:otherwise>
1494
- <fo:table-column column-width="proportional-column-width({.})"/>
1495
- </xsl:otherwise>
1496
- </xsl:choose>
1497
- </xsl:for-each>
1542
+ <xsl:choose>
1543
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
1544
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
1545
+ <fo:table-column column-width="{@width}"/>
1546
+ </xsl:for-each>
1547
+ </xsl:when>
1548
+ <xsl:otherwise>
1549
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
1550
+ <xsl:choose>
1551
+ <xsl:when test=". = 1 or . = 0">
1552
+ <fo:table-column column-width="proportional-column-width(2)"/>
1553
+ </xsl:when>
1554
+ <xsl:otherwise>
1555
+ <fo:table-column column-width="proportional-column-width({.})"/>
1556
+ </xsl:otherwise>
1557
+ </xsl:choose>
1558
+ </xsl:for-each>
1559
+ </xsl:otherwise>
1560
+ </xsl:choose>
1498
1561
 
1499
1562
  <xsl:choose>
1500
1563
  <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
@@ -1507,10 +1570,12 @@
1507
1570
 
1508
1571
  </fo:table>
1509
1572
 
1573
+ <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
1510
1574
  <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
1511
1575
  <xsl:call-template name="insertTableFooterInSeparateTable">
1512
1576
  <xsl:with-param name="table_attributes" select="$table_attributes"/>
1513
1577
  <xsl:with-param name="colwidths" select="$colwidths"/>
1578
+ <xsl:with-param name="colgroup" select="$colgroup"/>
1514
1579
  </xsl:call-template>
1515
1580
  </xsl:for-each>
1516
1581
 
@@ -1543,6 +1608,7 @@
1543
1608
  <xsl:if test="normalize-space() != ''">
1544
1609
  <fo:block xsl:use-attribute-sets="table-name-style">
1545
1610
 
1611
+
1546
1612
  <xsl:apply-templates/>
1547
1613
  </fo:block>
1548
1614
  </xsl:if>
@@ -1763,12 +1829,22 @@
1763
1829
  </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
1764
1830
  <xsl:param name="table_attributes"/>
1765
1831
  <xsl:param name="colwidths"/>
1832
+ <xsl:param name="colgroup"/>
1766
1833
 
1767
1834
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
1768
1835
 
1769
1836
  <xsl:if test="$isNoteOrFnExist = 'true'">
1770
1837
 
1771
- <xsl:variable name="cols-count" select="count(xalan:nodeset($colwidths)//column)"/>
1838
+ <xsl:variable name="cols-count">
1839
+ <xsl:choose>
1840
+ <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
1841
+ <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
1842
+ </xsl:when>
1843
+ <xsl:otherwise>
1844
+ <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/>
1845
+ </xsl:otherwise>
1846
+ </xsl:choose>
1847
+ </xsl:variable>
1772
1848
 
1773
1849
  <fo:table keep-with-previous="always">
1774
1850
  <xsl:for-each select="xalan:nodeset($table_attributes)/attribute">
@@ -1786,16 +1862,25 @@
1786
1862
  </xsl:choose>
1787
1863
  </xsl:for-each>
1788
1864
 
1789
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
1790
- <xsl:choose>
1791
- <xsl:when test=". = 1 or . = 0">
1792
- <fo:table-column column-width="proportional-column-width(2)"/>
1793
- </xsl:when>
1794
- <xsl:otherwise>
1795
- <fo:table-column column-width="proportional-column-width({.})"/>
1796
- </xsl:otherwise>
1797
- </xsl:choose>
1798
- </xsl:for-each>
1865
+ <xsl:choose>
1866
+ <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
1867
+ <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
1868
+ <fo:table-column column-width="{@width}"/>
1869
+ </xsl:for-each>
1870
+ </xsl:when>
1871
+ <xsl:otherwise>
1872
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
1873
+ <xsl:choose>
1874
+ <xsl:when test=". = 1 or . = 0">
1875
+ <fo:table-column column-width="proportional-column-width(2)"/>
1876
+ </xsl:when>
1877
+ <xsl:otherwise>
1878
+ <fo:table-column column-width="proportional-column-width({.})"/>
1879
+ </xsl:otherwise>
1880
+ </xsl:choose>
1881
+ </xsl:for-each>
1882
+ </xsl:otherwise>
1883
+ </xsl:choose>
1799
1884
 
1800
1885
  <fo:table-body>
1801
1886
  <fo:table-row>
@@ -1896,6 +1981,7 @@
1896
1981
 
1897
1982
 
1898
1983
 
1984
+
1899
1985
  <!-- <xsl:if test="$namespace = 'bipm'">
1900
1986
  <xsl:attribute name="height">8mm</xsl:attribute>
1901
1987
  </xsl:if> -->
@@ -1981,7 +2067,8 @@
1981
2067
  </xsl:attribute>
1982
2068
  </xsl:if>
1983
2069
  <xsl:call-template name="display-align"/>
1984
- <fo:block>
2070
+ <fo:block>
2071
+
1985
2072
  <xsl:apply-templates/>
1986
2073
  </fo:block>
1987
2074
  </fo:table-cell>
@@ -2193,7 +2280,13 @@
2193
2280
  <xsl:apply-templates/>
2194
2281
  </fo:inline>
2195
2282
  </xsl:template><xsl:template match="*[local-name()='dl']">
2196
- <fo:block-container margin-left="0mm">
2283
+ <fo:block-container>
2284
+
2285
+ <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
2286
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2287
+ </xsl:if>
2288
+
2289
+
2197
2290
  <xsl:if test="parent::*[local-name() = 'note']">
2198
2291
  <xsl:attribute name="margin-left">
2199
2292
  <xsl:choose>
@@ -2203,8 +2296,12 @@
2203
2296
  </xsl:attribute>
2204
2297
 
2205
2298
  </xsl:if>
2206
- <fo:block-container margin-left="0mm">
2207
-
2299
+ <fo:block-container>
2300
+
2301
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2302
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
2303
+
2304
+
2208
2305
  <xsl:variable name="parent" select="local-name(..)"/>
2209
2306
 
2210
2307
  <xsl:variable name="key_iso">
@@ -2218,9 +2315,12 @@
2218
2315
  <fo:block margin-bottom="12pt" text-align="left">
2219
2316
 
2220
2317
  <xsl:variable name="title-where">
2221
- <xsl:call-template name="getTitle">
2222
- <xsl:with-param name="name" select="'title-where'"/>
2223
- </xsl:call-template>
2318
+
2319
+
2320
+ <xsl:call-template name="getTitle">
2321
+ <xsl:with-param name="name" select="'title-where'"/>
2322
+ </xsl:call-template>
2323
+
2224
2324
  </xsl:variable>
2225
2325
  <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
2226
2326
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
@@ -2236,9 +2336,12 @@
2236
2336
 
2237
2337
 
2238
2338
  <xsl:variable name="title-where">
2239
- <xsl:call-template name="getTitle">
2240
- <xsl:with-param name="name" select="'title-where'"/>
2241
- </xsl:call-template>
2339
+
2340
+
2341
+ <xsl:call-template name="getTitle">
2342
+ <xsl:with-param name="name" select="'title-where'"/>
2343
+ </xsl:call-template>
2344
+
2242
2345
  </xsl:variable>
2243
2346
  <xsl:value-of select="$title-where"/>
2244
2347
  </fo:block>
@@ -2249,9 +2352,12 @@
2249
2352
 
2250
2353
 
2251
2354
  <xsl:variable name="title-key">
2252
- <xsl:call-template name="getTitle">
2253
- <xsl:with-param name="name" select="'title-key'"/>
2254
- </xsl:call-template>
2355
+
2356
+
2357
+ <xsl:call-template name="getTitle">
2358
+ <xsl:with-param name="name" select="'title-key'"/>
2359
+ </xsl:call-template>
2360
+
2255
2361
  </xsl:variable>
2256
2362
  <xsl:value-of select="$title-key"/>
2257
2363
  </fo:block>
@@ -2377,12 +2483,32 @@
2377
2483
  </xsl:otherwise>
2378
2484
  </xsl:choose>
2379
2485
  </xsl:template><xsl:template name="getMaxLength_dt">
2380
- <xsl:for-each select="*[local-name()='dt']">
2381
- <xsl:sort select="string-length(normalize-space(.))" data-type="number" order="descending"/>
2382
- <xsl:if test="position() = 1">
2383
- <xsl:value-of select="string-length(normalize-space(.))"/>
2384
- </xsl:if>
2385
- </xsl:for-each>
2486
+ <xsl:variable name="lengths">
2487
+ <xsl:for-each select="*[local-name()='dt']">
2488
+ <xsl:variable name="maintext_length" select="string-length(normalize-space(.))"/>
2489
+ <xsl:variable name="attributes">
2490
+ <xsl:for-each select=".//@open"><xsl:value-of select="."/></xsl:for-each>
2491
+ <xsl:for-each select=".//@close"><xsl:value-of select="."/></xsl:for-each>
2492
+ </xsl:variable>
2493
+ <length><xsl:value-of select="string-length(normalize-space(.)) + string-length($attributes)"/></length>
2494
+ </xsl:for-each>
2495
+ </xsl:variable>
2496
+ <xsl:variable name="maxLength">
2497
+ <!-- <xsl:for-each select="*[local-name()='dt']">
2498
+ <xsl:sort select="string-length(normalize-space(.))" data-type="number" order="descending"/>
2499
+ <xsl:if test="position() = 1">
2500
+ <xsl:value-of select="string-length(normalize-space(.))"/>
2501
+ </xsl:if>
2502
+ </xsl:for-each> -->
2503
+ <xsl:for-each select="xalan:nodeset($lengths)/length">
2504
+ <xsl:sort select="." data-type="number" order="descending"/>
2505
+ <xsl:if test="position() = 1">
2506
+ <xsl:value-of select="."/>
2507
+ </xsl:if>
2508
+ </xsl:for-each>
2509
+ </xsl:variable>
2510
+ <!-- <xsl:message>DEBUG:<xsl:value-of select="$maxLength"/></xsl:message> -->
2511
+ <xsl:value-of select="$maxLength"/>
2386
2512
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
2387
2513
  <xsl:param name="key_iso"/>
2388
2514
 
@@ -2494,6 +2620,7 @@
2494
2620
  </fo:inline>
2495
2621
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
2496
2622
  <fo:inline font-weight="bold">
2623
+
2497
2624
  <xsl:apply-templates/>
2498
2625
  </fo:inline>
2499
2626
  </xsl:template><xsl:template match="*[local-name()='sup']">
@@ -2538,6 +2665,10 @@
2538
2665
  </xsl:if>
2539
2666
  <xsl:apply-templates/>
2540
2667
  </fo:inline>
2668
+ </xsl:template><xsl:template match="*[local-name()='underline']">
2669
+ <fo:inline text-decoration="underline">
2670
+ <xsl:apply-templates/>
2671
+ </fo:inline>
2541
2672
  </xsl:template><xsl:template match="*[local-name()='del']">
2542
2673
  <fo:inline font-size="10pt" color="red" text-decoration="line-through">
2543
2674
  <xsl:apply-templates/>
@@ -2827,7 +2958,18 @@
2827
2958
  <xsl:with-param name="previousRow" select="$newRow"/>
2828
2959
  </xsl:apply-templates>
2829
2960
  </xsl:template><xsl:template name="getLang">
2830
- <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/>
2961
+ <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
2962
+ <xsl:variable name="language">
2963
+ <xsl:choose>
2964
+ <xsl:when test="$language_current != ''">
2965
+ <xsl:value-of select="$language_current"/>
2966
+ </xsl:when>
2967
+ <xsl:otherwise>
2968
+ <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
2969
+ </xsl:otherwise>
2970
+ </xsl:choose>
2971
+ </xsl:variable>
2972
+
2831
2973
  <xsl:choose>
2832
2974
  <xsl:when test="$language = 'English'">en</xsl:when>
2833
2975
  <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
@@ -2862,6 +3004,7 @@
2862
3004
  <xsl:value-of select="substring($str, 2)"/>
2863
3005
  </xsl:template><xsl:template match="mathml:math">
2864
3006
  <fo:inline font-family="STIX Two Math"> <!-- -->
3007
+
2865
3008
  <xsl:variable name="mathml">
2866
3009
  <xsl:apply-templates select="." mode="mathml"/>
2867
3010
  </xsl:variable>
@@ -2891,6 +3034,7 @@
2891
3034
  </xsl:choose>
2892
3035
  </xsl:variable>
2893
3036
  <fo:inline xsl:use-attribute-sets="link-style">
3037
+
2894
3038
  <xsl:choose>
2895
3039
  <xsl:when test="$target = ''">
2896
3040
  <xsl:apply-templates/>
@@ -2944,10 +3088,14 @@
2944
3088
  </fo:inline>
2945
3089
  </xsl:template><xsl:template match="*[local-name() = 'modification']">
2946
3090
  <xsl:variable name="title-modified">
2947
- <xsl:call-template name="getTitle">
2948
- <xsl:with-param name="name" select="'title-modified'"/>
2949
- </xsl:call-template>
3091
+
3092
+
3093
+ <xsl:call-template name="getTitle">
3094
+ <xsl:with-param name="name" select="'title-modified'"/>
3095
+ </xsl:call-template>
3096
+
2950
3097
  </xsl:variable>
3098
+
2951
3099
  <xsl:choose>
2952
3100
  <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:text>—</xsl:text></xsl:when>
2953
3101
  <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:text> — </xsl:text></xsl:otherwise>
@@ -3104,7 +3252,8 @@
3104
3252
  </fo:inline>
3105
3253
  </xsl:if>
3106
3254
  </xsl:template><xsl:template match="*[local-name() = 'figure']">
3107
- <fo:block-container id="{@id}">
3255
+ <fo:block-container id="{@id}">
3256
+
3108
3257
  <fo:block>
3109
3258
  <xsl:apply-templates/>
3110
3259
  </fo:block>
@@ -3155,7 +3304,7 @@
3155
3304
  <xsl:apply-templates mode="bookmarks"/>
3156
3305
  </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="contents">
3157
3306
  <xsl:apply-templates select="."/>
3158
- </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
3307
+ </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
3159
3308
  <xsl:apply-templates mode="bookmarks"/>
3160
3309
  </xsl:template><xsl:template name="addBookmarks">
3161
3310
  <xsl:param name="contents"/>
@@ -3171,6 +3320,8 @@
3171
3320
  <xsl:variable name="bookmark-title_">
3172
3321
  <xsl:call-template name="getLangVersion">
3173
3322
  <xsl:with-param name="lang" select="@lang"/>
3323
+ <xsl:with-param name="doctype" select="@doctype"/>
3324
+ <xsl:with-param name="title" select="@title-part"/>
3174
3325
  </xsl:call-template>
3175
3326
  </xsl:variable>
3176
3327
  <xsl:choose>
@@ -3188,13 +3339,34 @@
3188
3339
  </xsl:choose>
3189
3340
  </fo:bookmark-title>
3190
3341
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3342
+
3343
+ <xsl:call-template name="insertFigureBookmarks">
3344
+ <xsl:with-param name="contents" select="contents"/>
3345
+ </xsl:call-template>
3346
+
3347
+ <xsl:call-template name="insertTableBookmarks">
3348
+ <xsl:with-param name="contents" select="contents"/>
3349
+ <xsl:with-param name="lang" select="@lang"/>
3350
+ </xsl:call-template>
3351
+
3191
3352
  </fo:bookmark>
3192
3353
 
3193
3354
  </xsl:for-each>
3194
3355
  </xsl:when>
3195
3356
  <xsl:otherwise>
3196
3357
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3358
+
3197
3359
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3360
+
3361
+ <xsl:call-template name="insertFigureBookmarks">
3362
+ <xsl:with-param name="contents" select="contents"/>
3363
+ </xsl:call-template>
3364
+
3365
+ <xsl:call-template name="insertTableBookmarks">
3366
+ <xsl:with-param name="contents" select="contents"/>
3367
+ <xsl:with-param name="lang" select="@lang"/>
3368
+ </xsl:call-template>
3369
+
3198
3370
  </xsl:for-each>
3199
3371
  </xsl:otherwise>
3200
3372
  </xsl:choose>
@@ -3213,8 +3385,44 @@
3213
3385
 
3214
3386
  </fo:bookmark-tree>
3215
3387
  </xsl:if>
3388
+ </xsl:template><xsl:template name="insertFigureBookmarks">
3389
+ <xsl:param name="contents"/>
3390
+ <xsl:if test="xalan:nodeset($contents)/figure">
3391
+ <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
3392
+ <fo:bookmark-title>Figures</fo:bookmark-title>
3393
+ <xsl:for-each select="xalan:nodeset($contents)/figure">
3394
+ <fo:bookmark internal-destination="{@id}">
3395
+ <fo:bookmark-title>
3396
+ <xsl:value-of select="normalize-space(title)"/>
3397
+ </fo:bookmark-title>
3398
+ </fo:bookmark>
3399
+ </xsl:for-each>
3400
+ </fo:bookmark>
3401
+ </xsl:if>
3402
+ </xsl:template><xsl:template name="insertTableBookmarks">
3403
+ <xsl:param name="contents"/>
3404
+ <xsl:param name="lang"/>
3405
+ <xsl:if test="xalan:nodeset($contents)/table">
3406
+ <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
3407
+ <fo:bookmark-title>
3408
+ <xsl:choose>
3409
+ <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
3410
+ <xsl:otherwise>Tables</xsl:otherwise>
3411
+ </xsl:choose>
3412
+ </fo:bookmark-title>
3413
+ <xsl:for-each select="xalan:nodeset($contents)/table">
3414
+ <fo:bookmark internal-destination="{@id}">
3415
+ <fo:bookmark-title>
3416
+ <xsl:value-of select="normalize-space(title)"/>
3417
+ </fo:bookmark-title>
3418
+ </fo:bookmark>
3419
+ </xsl:for-each>
3420
+ </fo:bookmark>
3421
+ </xsl:if>
3216
3422
  </xsl:template><xsl:template name="getLangVersion">
3217
3423
  <xsl:param name="lang"/>
3424
+ <xsl:param name="doctype" select="''"/>
3425
+ <xsl:param name="title" select="''"/>
3218
3426
  <xsl:choose>
3219
3427
  <xsl:when test="$lang = 'en'">
3220
3428
 
@@ -3697,7 +3905,8 @@
3697
3905
  <fo:block-container margin-left="0mm">
3698
3906
 
3699
3907
  <fo:block xsl:use-attribute-sets="quote-style">
3700
- <xsl:apply-templates select=".//*[local-name() = 'p']"/>
3908
+ <!-- <xsl:apply-templates select=".//*[local-name() = 'p']"/> -->
3909
+ <xsl:apply-templates select="./*[not(local-name() = 'author') and not(local-name() = 'source')]"/> <!-- process all nested nodes, except author and source -->
3701
3910
  </fo:block>
3702
3911
  <xsl:if test="*[local-name() = 'author'] or *[local-name() = 'source']">
3703
3912
  <fo:block xsl:use-attribute-sets="quote-source-style">
@@ -3824,9 +4033,12 @@
3824
4033
  </fo:block>
3825
4034
  </xsl:template><xsl:template match="*[local-name() = 'deprecates']">
3826
4035
  <xsl:variable name="title-deprecated">
3827
- <xsl:call-template name="getTitle">
3828
- <xsl:with-param name="name" select="'title-deprecated'"/>
3829
- </xsl:call-template>
4036
+
4037
+
4038
+ <xsl:call-template name="getTitle">
4039
+ <xsl:with-param name="name" select="'title-deprecated'"/>
4040
+ </xsl:call-template>
4041
+
3830
4042
  </xsl:variable>
3831
4043
  <fo:block xsl:use-attribute-sets="deprecates-style">
3832
4044
  <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
@@ -3882,7 +4094,7 @@
3882
4094
  <fo:block id="{@id}">
3883
4095
  <xsl:apply-templates/>
3884
4096
  </fo:block>
3885
- </xsl:template><xsl:template match="/*/*[local-name() = 'bibliography']/*[local-name() = 'references'][@normative='true']">
4097
+ </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" priority="3"/><xsl:template match="*[local-name() = 'bibitem'][@hidden='true']" priority="3"/><xsl:template match="/*/*[local-name() = 'bibliography']/*[local-name() = 'references'][@normative='true']">
3886
4098
 
3887
4099
  <fo:block id="{@id}">
3888
4100
  <xsl:apply-templates/>
@@ -3939,7 +4151,8 @@
3939
4151
  <fo:table-column column-width="107mm"/>
3940
4152
  <fo:table-column column-width="15mm"/>
3941
4153
  <fo:table-body>
3942
- <fo:table-row font-family="Arial" text-align="center" font-weight="bold" background-color="black" color="white">
4154
+ <fo:table-row text-align="center" font-weight="bold" background-color="black" color="white">
4155
+
3943
4156
  <fo:table-cell border="1pt solid black"><fo:block>Date</fo:block></fo:table-cell>
3944
4157
  <fo:table-cell border="1pt solid black"><fo:block>Type</fo:block></fo:table-cell>
3945
4158
  <fo:table-cell border="1pt solid black"><fo:block>Change</fo:block></fo:table-cell>
@@ -3957,6 +4170,10 @@
3957
4170
  <fo:block><xsl:apply-templates/></fo:block>
3958
4171
  </fo:table-cell>
3959
4172
  </xsl:template><xsl:template name="processBibitem">
4173
+
4174
+
4175
+ <!-- end BIPM bibitem processing-->
4176
+
3960
4177
 
3961
4178
 
3962
4179
 
@@ -4015,6 +4232,8 @@
4015
4232
  <xsl:value-of select="translate(.,'. ','')"/>
4016
4233
  </xsl:template><xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip">
4017
4234
  <xsl:value-of select="substring(.,1,1)"/>
4235
+ </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
4236
+ <fo:inline><xsl:apply-templates/></fo:inline>
4018
4237
  </xsl:template><xsl:template name="convertDate">
4019
4238
  <xsl:param name="date"/>
4020
4239
  <xsl:param name="format" select="'short'"/>
@@ -4194,13 +4413,22 @@
4194
4413
  </xsl:template><xsl:template name="split">
4195
4414
  <xsl:param name="pText" select="."/>
4196
4415
  <xsl:param name="sep" select="','"/>
4416
+ <xsl:param name="normalize-space" select="'true'"/>
4197
4417
  <xsl:if test="string-length($pText) &gt;0">
4198
4418
  <item>
4199
- <xsl:value-of select="normalize-space(substring-before(concat($pText, ','), $sep))"/>
4419
+ <xsl:choose>
4420
+ <xsl:when test="$normalize-space = 'true'">
4421
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
4422
+ </xsl:when>
4423
+ <xsl:otherwise>
4424
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
4425
+ </xsl:otherwise>
4426
+ </xsl:choose>
4200
4427
  </item>
4201
4428
  <xsl:call-template name="split">
4202
4429
  <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
4203
4430
  <xsl:with-param name="sep" select="$sep"/>
4431
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
4204
4432
  </xsl:call-template>
4205
4433
  </xsl:if>
4206
4434
  </xsl:template><xsl:template name="getDocumentId">
@@ -4266,4 +4494,28 @@
4266
4494
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
4267
4495
  </xsl:call-template>
4268
4496
  </xsl:if>
4497
+ </xsl:template><xsl:template name="repeat">
4498
+ <xsl:param name="char" select="'*'"/>
4499
+ <xsl:param name="count"/>
4500
+ <xsl:if test="$count &gt; 0">
4501
+ <xsl:value-of select="$char"/>
4502
+ <xsl:call-template name="repeat">
4503
+ <xsl:with-param name="char" select="$char"/>
4504
+ <xsl:with-param name="count" select="$count - 1"/>
4505
+ </xsl:call-template>
4506
+ </xsl:if>
4507
+ </xsl:template><xsl:template name="getLocalizedString">
4508
+ <xsl:param name="key"/>
4509
+
4510
+ <xsl:variable name="curr_lang">
4511
+ <xsl:call-template name="getLang"/>
4512
+ </xsl:variable>
4513
+
4514
+ <xsl:choose>
4515
+ <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
4516
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
4517
+ </xsl:when>
4518
+ <xsl:otherwise><xsl:value-of select="$key"/></xsl:otherwise>
4519
+ </xsl:choose>
4520
+
4269
4521
  </xsl:template></xsl:stylesheet>