metanorma-m3aawg 1.5.5 → 1.6.3

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
 
@@ -1184,6 +1227,7 @@
1184
1227
 
1185
1228
 
1186
1229
 
1230
+
1187
1231
  </xsl:attribute-set><xsl:variable name="note-body-indent">10mm</xsl:variable><xsl:variable name="note-body-indent-table">5mm</xsl:variable><xsl:attribute-set name="note-name-style">
1188
1232
 
1189
1233
 
@@ -1225,6 +1269,7 @@
1225
1269
 
1226
1270
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1227
1271
 
1272
+
1228
1273
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1229
1274
 
1230
1275
 
@@ -1255,6 +1300,7 @@
1255
1300
  </xsl:attribute-set><xsl:attribute-set name="term-style">
1256
1301
 
1257
1302
  </xsl:attribute-set><xsl:attribute-set name="figure-name-style">
1303
+
1258
1304
 
1259
1305
 
1260
1306
 
@@ -1379,7 +1425,9 @@
1379
1425
 
1380
1426
 
1381
1427
 
1382
-
1428
+ <!-- <xsl:if test="$namespace = 'bipm'">
1429
+ <fo:block>&#xA0;</fo:block>
1430
+ </xsl:if> -->
1383
1431
 
1384
1432
  <!-- $namespace = 'iso' or -->
1385
1433
 
@@ -1413,10 +1461,12 @@
1413
1461
 
1414
1462
 
1415
1463
  <xsl:variable name="colwidths">
1416
- <xsl:call-template name="calculate-column-widths">
1417
- <xsl:with-param name="cols-count" select="$cols-count"/>
1418
- <xsl:with-param name="table" select="$simple-table"/>
1419
- </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>
1420
1470
  </xsl:variable>
1421
1471
  <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
1422
1472
 
@@ -1484,16 +1534,25 @@
1484
1534
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
1485
1535
  </xsl:if>
1486
1536
 
1487
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
1488
- <xsl:choose>
1489
- <xsl:when test=". = 1 or . = 0">
1490
- <fo:table-column column-width="proportional-column-width(2)"/>
1491
- </xsl:when>
1492
- <xsl:otherwise>
1493
- <fo:table-column column-width="proportional-column-width({.})"/>
1494
- </xsl:otherwise>
1495
- </xsl:choose>
1496
- </xsl:for-each>
1537
+ <xsl:choose>
1538
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
1539
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
1540
+ <fo:table-column column-width="{@width}"/>
1541
+ </xsl:for-each>
1542
+ </xsl:when>
1543
+ <xsl:otherwise>
1544
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
1545
+ <xsl:choose>
1546
+ <xsl:when test=". = 1 or . = 0">
1547
+ <fo:table-column column-width="proportional-column-width(2)"/>
1548
+ </xsl:when>
1549
+ <xsl:otherwise>
1550
+ <fo:table-column column-width="proportional-column-width({.})"/>
1551
+ </xsl:otherwise>
1552
+ </xsl:choose>
1553
+ </xsl:for-each>
1554
+ </xsl:otherwise>
1555
+ </xsl:choose>
1497
1556
 
1498
1557
  <xsl:choose>
1499
1558
  <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
@@ -1506,10 +1565,12 @@
1506
1565
 
1507
1566
  </fo:table>
1508
1567
 
1568
+ <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
1509
1569
  <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
1510
1570
  <xsl:call-template name="insertTableFooterInSeparateTable">
1511
1571
  <xsl:with-param name="table_attributes" select="$table_attributes"/>
1512
1572
  <xsl:with-param name="colwidths" select="$colwidths"/>
1573
+ <xsl:with-param name="colgroup" select="$colgroup"/>
1513
1574
  </xsl:call-template>
1514
1575
  </xsl:for-each>
1515
1576
 
@@ -1542,6 +1603,7 @@
1542
1603
  <xsl:if test="normalize-space() != ''">
1543
1604
  <fo:block xsl:use-attribute-sets="table-name-style">
1544
1605
 
1606
+
1545
1607
  <xsl:apply-templates/>
1546
1608
  </fo:block>
1547
1609
  </xsl:if>
@@ -1724,12 +1786,26 @@
1724
1786
 
1725
1787
 
1726
1788
 
1727
- <!-- except gb and bipm -->
1728
1789
 
1729
- <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
1730
1790
 
1731
1791
 
1792
+ <!-- except gb -->
1732
1793
 
1794
+ <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
1795
+
1796
+
1797
+ <!-- show Note under table in preface (ex. abstract) sections -->
1798
+ <!-- empty, because notes show at page side in main sections -->
1799
+ <!-- <xsl:if test="$namespace = 'bipm'">
1800
+ <xsl:choose>
1801
+ <xsl:when test="ancestor::*[local-name()='preface']">
1802
+ <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
1803
+ </xsl:when>
1804
+ <xsl:otherwise>
1805
+ <fo:block/>
1806
+ </xsl:otherwise>
1807
+ </xsl:choose>
1808
+ </xsl:if> -->
1733
1809
 
1734
1810
 
1735
1811
  <!-- horizontal row separator -->
@@ -1748,12 +1824,22 @@
1748
1824
  </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
1749
1825
  <xsl:param name="table_attributes"/>
1750
1826
  <xsl:param name="colwidths"/>
1827
+ <xsl:param name="colgroup"/>
1751
1828
 
1752
1829
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
1753
1830
 
1754
1831
  <xsl:if test="$isNoteOrFnExist = 'true'">
1755
1832
 
1756
- <xsl:variable name="cols-count" select="count(xalan:nodeset($colwidths)//column)"/>
1833
+ <xsl:variable name="cols-count">
1834
+ <xsl:choose>
1835
+ <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
1836
+ <xsl:value-of select="count(xalan:nodeset($colgroup)//*[local-name()='col'])"/>
1837
+ </xsl:when>
1838
+ <xsl:otherwise>
1839
+ <xsl:value-of select="count(xalan:nodeset($colwidths)//column)"/>
1840
+ </xsl:otherwise>
1841
+ </xsl:choose>
1842
+ </xsl:variable>
1757
1843
 
1758
1844
  <fo:table keep-with-previous="always">
1759
1845
  <xsl:for-each select="xalan:nodeset($table_attributes)/attribute">
@@ -1771,16 +1857,25 @@
1771
1857
  </xsl:choose>
1772
1858
  </xsl:for-each>
1773
1859
 
1774
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
1775
- <xsl:choose>
1776
- <xsl:when test=". = 1 or . = 0">
1777
- <fo:table-column column-width="proportional-column-width(2)"/>
1778
- </xsl:when>
1779
- <xsl:otherwise>
1780
- <fo:table-column column-width="proportional-column-width({.})"/>
1781
- </xsl:otherwise>
1782
- </xsl:choose>
1783
- </xsl:for-each>
1860
+ <xsl:choose>
1861
+ <xsl:when test="xalan:nodeset($colgroup)//*[local-name()='col']">
1862
+ <xsl:for-each select="xalan:nodeset($colgroup)//*[local-name()='col']">
1863
+ <fo:table-column column-width="{@width}"/>
1864
+ </xsl:for-each>
1865
+ </xsl:when>
1866
+ <xsl:otherwise>
1867
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
1868
+ <xsl:choose>
1869
+ <xsl:when test=". = 1 or . = 0">
1870
+ <fo:table-column column-width="proportional-column-width(2)"/>
1871
+ </xsl:when>
1872
+ <xsl:otherwise>
1873
+ <fo:table-column column-width="proportional-column-width({.})"/>
1874
+ </xsl:otherwise>
1875
+ </xsl:choose>
1876
+ </xsl:for-each>
1877
+ </xsl:otherwise>
1878
+ </xsl:choose>
1784
1879
 
1785
1880
  <fo:table-body>
1786
1881
  <fo:table-row>
@@ -1792,7 +1887,11 @@
1792
1887
 
1793
1888
 
1794
1889
 
1795
- <!-- except gb and bipm -->
1890
+
1891
+
1892
+
1893
+
1894
+ <!-- except gb -->
1796
1895
 
1797
1896
  <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
1798
1897
 
@@ -1878,6 +1977,10 @@
1878
1977
 
1879
1978
 
1880
1979
 
1980
+ <!-- <xsl:if test="$namespace = 'bipm'">
1981
+ <xsl:attribute name="height">8mm</xsl:attribute>
1982
+ </xsl:if> -->
1983
+
1881
1984
  <xsl:apply-templates/>
1882
1985
  </fo:table-row>
1883
1986
  </xsl:template><xsl:template match="*[local-name()='th']">
@@ -1959,7 +2062,8 @@
1959
2062
  </xsl:attribute>
1960
2063
  </xsl:if>
1961
2064
  <xsl:call-template name="display-align"/>
1962
- <fo:block>
2065
+ <fo:block>
2066
+
1963
2067
  <xsl:apply-templates/>
1964
2068
  </fo:block>
1965
2069
  </fo:table-cell>
@@ -2171,7 +2275,13 @@
2171
2275
  <xsl:apply-templates/>
2172
2276
  </fo:inline>
2173
2277
  </xsl:template><xsl:template match="*[local-name()='dl']">
2174
- <fo:block-container margin-left="0mm">
2278
+ <fo:block-container>
2279
+
2280
+ <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
2281
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2282
+ </xsl:if>
2283
+
2284
+
2175
2285
  <xsl:if test="parent::*[local-name() = 'note']">
2176
2286
  <xsl:attribute name="margin-left">
2177
2287
  <xsl:choose>
@@ -2181,8 +2291,12 @@
2181
2291
  </xsl:attribute>
2182
2292
 
2183
2293
  </xsl:if>
2184
- <fo:block-container margin-left="0mm">
2185
-
2294
+ <fo:block-container>
2295
+
2296
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2297
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
2298
+
2299
+
2186
2300
  <xsl:variable name="parent" select="local-name(..)"/>
2187
2301
 
2188
2302
  <xsl:variable name="key_iso">
@@ -2196,9 +2310,12 @@
2196
2310
  <fo:block margin-bottom="12pt" text-align="left">
2197
2311
 
2198
2312
  <xsl:variable name="title-where">
2199
- <xsl:call-template name="getTitle">
2200
- <xsl:with-param name="name" select="'title-where'"/>
2201
- </xsl:call-template>
2313
+
2314
+
2315
+ <xsl:call-template name="getTitle">
2316
+ <xsl:with-param name="name" select="'title-where'"/>
2317
+ </xsl:call-template>
2318
+
2202
2319
  </xsl:variable>
2203
2320
  <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
2204
2321
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
@@ -2214,9 +2331,12 @@
2214
2331
 
2215
2332
 
2216
2333
  <xsl:variable name="title-where">
2217
- <xsl:call-template name="getTitle">
2218
- <xsl:with-param name="name" select="'title-where'"/>
2219
- </xsl:call-template>
2334
+
2335
+
2336
+ <xsl:call-template name="getTitle">
2337
+ <xsl:with-param name="name" select="'title-where'"/>
2338
+ </xsl:call-template>
2339
+
2220
2340
  </xsl:variable>
2221
2341
  <xsl:value-of select="$title-where"/>
2222
2342
  </fo:block>
@@ -2227,9 +2347,12 @@
2227
2347
 
2228
2348
 
2229
2349
  <xsl:variable name="title-key">
2230
- <xsl:call-template name="getTitle">
2231
- <xsl:with-param name="name" select="'title-key'"/>
2232
- </xsl:call-template>
2350
+
2351
+
2352
+ <xsl:call-template name="getTitle">
2353
+ <xsl:with-param name="name" select="'title-key'"/>
2354
+ </xsl:call-template>
2355
+
2233
2356
  </xsl:variable>
2234
2357
  <xsl:value-of select="$title-key"/>
2235
2358
  </fo:block>
@@ -2355,12 +2478,32 @@
2355
2478
  </xsl:otherwise>
2356
2479
  </xsl:choose>
2357
2480
  </xsl:template><xsl:template name="getMaxLength_dt">
2358
- <xsl:for-each select="*[local-name()='dt']">
2359
- <xsl:sort select="string-length(normalize-space(.))" data-type="number" order="descending"/>
2360
- <xsl:if test="position() = 1">
2361
- <xsl:value-of select="string-length(normalize-space(.))"/>
2362
- </xsl:if>
2363
- </xsl:for-each>
2481
+ <xsl:variable name="lengths">
2482
+ <xsl:for-each select="*[local-name()='dt']">
2483
+ <xsl:variable name="maintext_length" select="string-length(normalize-space(.))"/>
2484
+ <xsl:variable name="attributes">
2485
+ <xsl:for-each select=".//@open"><xsl:value-of select="."/></xsl:for-each>
2486
+ <xsl:for-each select=".//@close"><xsl:value-of select="."/></xsl:for-each>
2487
+ </xsl:variable>
2488
+ <length><xsl:value-of select="string-length(normalize-space(.)) + string-length($attributes)"/></length>
2489
+ </xsl:for-each>
2490
+ </xsl:variable>
2491
+ <xsl:variable name="maxLength">
2492
+ <!-- <xsl:for-each select="*[local-name()='dt']">
2493
+ <xsl:sort select="string-length(normalize-space(.))" data-type="number" order="descending"/>
2494
+ <xsl:if test="position() = 1">
2495
+ <xsl:value-of select="string-length(normalize-space(.))"/>
2496
+ </xsl:if>
2497
+ </xsl:for-each> -->
2498
+ <xsl:for-each select="xalan:nodeset($lengths)/length">
2499
+ <xsl:sort select="." data-type="number" order="descending"/>
2500
+ <xsl:if test="position() = 1">
2501
+ <xsl:value-of select="."/>
2502
+ </xsl:if>
2503
+ </xsl:for-each>
2504
+ </xsl:variable>
2505
+ <!-- <xsl:message>DEBUG:<xsl:value-of select="$maxLength"/></xsl:message> -->
2506
+ <xsl:value-of select="$maxLength"/>
2364
2507
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
2365
2508
  <xsl:param name="key_iso"/>
2366
2509
 
@@ -2472,6 +2615,7 @@
2472
2615
  </fo:inline>
2473
2616
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
2474
2617
  <fo:inline font-weight="bold">
2618
+
2475
2619
  <xsl:apply-templates/>
2476
2620
  </fo:inline>
2477
2621
  </xsl:template><xsl:template match="*[local-name()='sup']">
@@ -2805,7 +2949,18 @@
2805
2949
  <xsl:with-param name="previousRow" select="$newRow"/>
2806
2950
  </xsl:apply-templates>
2807
2951
  </xsl:template><xsl:template name="getLang">
2808
- <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/>
2952
+ <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
2953
+ <xsl:variable name="language">
2954
+ <xsl:choose>
2955
+ <xsl:when test="$language_current != ''">
2956
+ <xsl:value-of select="$language_current"/>
2957
+ </xsl:when>
2958
+ <xsl:otherwise>
2959
+ <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
2960
+ </xsl:otherwise>
2961
+ </xsl:choose>
2962
+ </xsl:variable>
2963
+
2809
2964
  <xsl:choose>
2810
2965
  <xsl:when test="$language = 'English'">en</xsl:when>
2811
2966
  <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
@@ -2840,6 +2995,7 @@
2840
2995
  <xsl:value-of select="substring($str, 2)"/>
2841
2996
  </xsl:template><xsl:template match="mathml:math">
2842
2997
  <fo:inline font-family="STIX Two Math"> <!-- -->
2998
+
2843
2999
  <xsl:variable name="mathml">
2844
3000
  <xsl:apply-templates select="." mode="mathml"/>
2845
3001
  </xsl:variable>
@@ -2869,6 +3025,7 @@
2869
3025
  </xsl:choose>
2870
3026
  </xsl:variable>
2871
3027
  <fo:inline xsl:use-attribute-sets="link-style">
3028
+
2872
3029
  <xsl:choose>
2873
3030
  <xsl:when test="$target = ''">
2874
3031
  <xsl:apply-templates/>
@@ -2922,10 +3079,14 @@
2922
3079
  </fo:inline>
2923
3080
  </xsl:template><xsl:template match="*[local-name() = 'modification']">
2924
3081
  <xsl:variable name="title-modified">
2925
- <xsl:call-template name="getTitle">
2926
- <xsl:with-param name="name" select="'title-modified'"/>
2927
- </xsl:call-template>
3082
+
3083
+
3084
+ <xsl:call-template name="getTitle">
3085
+ <xsl:with-param name="name" select="'title-modified'"/>
3086
+ </xsl:call-template>
3087
+
2928
3088
  </xsl:variable>
3089
+
2929
3090
  <xsl:choose>
2930
3091
  <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:text>—</xsl:text></xsl:when>
2931
3092
  <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:text> — </xsl:text></xsl:otherwise>
@@ -2986,6 +3147,8 @@
2986
3147
 
2987
3148
 
2988
3149
 
3150
+
3151
+
2989
3152
  <fo:inline xsl:use-attribute-sets="note-name-style">
2990
3153
  <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
2991
3154
  </fo:inline>
@@ -3080,7 +3243,8 @@
3080
3243
  </fo:inline>
3081
3244
  </xsl:if>
3082
3245
  </xsl:template><xsl:template match="*[local-name() = 'figure']">
3083
- <fo:block-container id="{@id}">
3246
+ <fo:block-container id="{@id}">
3247
+
3084
3248
  <fo:block>
3085
3249
  <xsl:apply-templates/>
3086
3250
  </fo:block>
@@ -3131,7 +3295,7 @@
3131
3295
  <xsl:apply-templates mode="bookmarks"/>
3132
3296
  </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="contents">
3133
3297
  <xsl:apply-templates select="."/>
3134
- </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
3298
+ </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
3135
3299
  <xsl:apply-templates mode="bookmarks"/>
3136
3300
  </xsl:template><xsl:template name="addBookmarks">
3137
3301
  <xsl:param name="contents"/>
@@ -3147,6 +3311,8 @@
3147
3311
  <xsl:variable name="bookmark-title_">
3148
3312
  <xsl:call-template name="getLangVersion">
3149
3313
  <xsl:with-param name="lang" select="@lang"/>
3314
+ <xsl:with-param name="doctype" select="@doctype"/>
3315
+ <xsl:with-param name="title" select="@title-part"/>
3150
3316
  </xsl:call-template>
3151
3317
  </xsl:variable>
3152
3318
  <xsl:choose>
@@ -3164,13 +3330,34 @@
3164
3330
  </xsl:choose>
3165
3331
  </fo:bookmark-title>
3166
3332
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3333
+
3334
+ <xsl:call-template name="insertFigureBookmarks">
3335
+ <xsl:with-param name="contents" select="contents"/>
3336
+ </xsl:call-template>
3337
+
3338
+ <xsl:call-template name="insertTableBookmarks">
3339
+ <xsl:with-param name="contents" select="contents"/>
3340
+ <xsl:with-param name="lang" select="@lang"/>
3341
+ </xsl:call-template>
3342
+
3167
3343
  </fo:bookmark>
3168
3344
 
3169
3345
  </xsl:for-each>
3170
3346
  </xsl:when>
3171
3347
  <xsl:otherwise>
3172
3348
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3349
+
3173
3350
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3351
+
3352
+ <xsl:call-template name="insertFigureBookmarks">
3353
+ <xsl:with-param name="contents" select="contents"/>
3354
+ </xsl:call-template>
3355
+
3356
+ <xsl:call-template name="insertTableBookmarks">
3357
+ <xsl:with-param name="contents" select="contents"/>
3358
+ <xsl:with-param name="lang" select="@lang"/>
3359
+ </xsl:call-template>
3360
+
3174
3361
  </xsl:for-each>
3175
3362
  </xsl:otherwise>
3176
3363
  </xsl:choose>
@@ -3189,8 +3376,44 @@
3189
3376
 
3190
3377
  </fo:bookmark-tree>
3191
3378
  </xsl:if>
3379
+ </xsl:template><xsl:template name="insertFigureBookmarks">
3380
+ <xsl:param name="contents"/>
3381
+ <xsl:if test="xalan:nodeset($contents)/figure">
3382
+ <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
3383
+ <fo:bookmark-title>Figures</fo:bookmark-title>
3384
+ <xsl:for-each select="xalan:nodeset($contents)/figure">
3385
+ <fo:bookmark internal-destination="{@id}">
3386
+ <fo:bookmark-title>
3387
+ <xsl:value-of select="normalize-space(title)"/>
3388
+ </fo:bookmark-title>
3389
+ </fo:bookmark>
3390
+ </xsl:for-each>
3391
+ </fo:bookmark>
3392
+ </xsl:if>
3393
+ </xsl:template><xsl:template name="insertTableBookmarks">
3394
+ <xsl:param name="contents"/>
3395
+ <xsl:param name="lang"/>
3396
+ <xsl:if test="xalan:nodeset($contents)/table">
3397
+ <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
3398
+ <fo:bookmark-title>
3399
+ <xsl:choose>
3400
+ <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
3401
+ <xsl:otherwise>Tables</xsl:otherwise>
3402
+ </xsl:choose>
3403
+ </fo:bookmark-title>
3404
+ <xsl:for-each select="xalan:nodeset($contents)/table">
3405
+ <fo:bookmark internal-destination="{@id}">
3406
+ <fo:bookmark-title>
3407
+ <xsl:value-of select="normalize-space(title)"/>
3408
+ </fo:bookmark-title>
3409
+ </fo:bookmark>
3410
+ </xsl:for-each>
3411
+ </fo:bookmark>
3412
+ </xsl:if>
3192
3413
  </xsl:template><xsl:template name="getLangVersion">
3193
3414
  <xsl:param name="lang"/>
3415
+ <xsl:param name="doctype" select="''"/>
3416
+ <xsl:param name="title" select="''"/>
3194
3417
  <xsl:choose>
3195
3418
  <xsl:when test="$lang = 'en'">
3196
3419
 
@@ -3673,7 +3896,8 @@
3673
3896
  <fo:block-container margin-left="0mm">
3674
3897
 
3675
3898
  <fo:block xsl:use-attribute-sets="quote-style">
3676
- <xsl:apply-templates select=".//*[local-name() = 'p']"/>
3899
+ <!-- <xsl:apply-templates select=".//*[local-name() = 'p']"/> -->
3900
+ <xsl:apply-templates select="./*[not(local-name() = 'author') and not(local-name() = 'source')]"/> <!-- process all nested nodes, except author and source -->
3677
3901
  </fo:block>
3678
3902
  <xsl:if test="*[local-name() = 'author'] or *[local-name() = 'source']">
3679
3903
  <fo:block xsl:use-attribute-sets="quote-source-style">
@@ -3800,9 +4024,12 @@
3800
4024
  </fo:block>
3801
4025
  </xsl:template><xsl:template match="*[local-name() = 'deprecates']">
3802
4026
  <xsl:variable name="title-deprecated">
3803
- <xsl:call-template name="getTitle">
3804
- <xsl:with-param name="name" select="'title-deprecated'"/>
3805
- </xsl:call-template>
4027
+
4028
+
4029
+ <xsl:call-template name="getTitle">
4030
+ <xsl:with-param name="name" select="'title-deprecated'"/>
4031
+ </xsl:call-template>
4032
+
3806
4033
  </xsl:variable>
3807
4034
  <fo:block xsl:use-attribute-sets="deprecates-style">
3808
4035
  <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
@@ -3858,7 +4085,7 @@
3858
4085
  <fo:block id="{@id}">
3859
4086
  <xsl:apply-templates/>
3860
4087
  </fo:block>
3861
- </xsl:template><xsl:template match="/*/*[local-name() = 'bibliography']/*[local-name() = 'references'][@normative='true']">
4088
+ </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']">
3862
4089
 
3863
4090
  <fo:block id="{@id}">
3864
4091
  <xsl:apply-templates/>
@@ -3915,7 +4142,8 @@
3915
4142
  <fo:table-column column-width="107mm"/>
3916
4143
  <fo:table-column column-width="15mm"/>
3917
4144
  <fo:table-body>
3918
- <fo:table-row font-family="Arial" text-align="center" font-weight="bold" background-color="black" color="white">
4145
+ <fo:table-row text-align="center" font-weight="bold" background-color="black" color="white">
4146
+
3919
4147
  <fo:table-cell border="1pt solid black"><fo:block>Date</fo:block></fo:table-cell>
3920
4148
  <fo:table-cell border="1pt solid black"><fo:block>Type</fo:block></fo:table-cell>
3921
4149
  <fo:table-cell border="1pt solid black"><fo:block>Change</fo:block></fo:table-cell>
@@ -3933,6 +4161,10 @@
3933
4161
  <fo:block><xsl:apply-templates/></fo:block>
3934
4162
  </fo:table-cell>
3935
4163
  </xsl:template><xsl:template name="processBibitem">
4164
+
4165
+
4166
+ <!-- end BIPM bibitem processing-->
4167
+
3936
4168
 
3937
4169
 
3938
4170
 
@@ -4170,13 +4402,22 @@
4170
4402
  </xsl:template><xsl:template name="split">
4171
4403
  <xsl:param name="pText" select="."/>
4172
4404
  <xsl:param name="sep" select="','"/>
4405
+ <xsl:param name="normalize-space" select="'true'"/>
4173
4406
  <xsl:if test="string-length($pText) &gt;0">
4174
4407
  <item>
4175
- <xsl:value-of select="normalize-space(substring-before(concat($pText, ','), $sep))"/>
4408
+ <xsl:choose>
4409
+ <xsl:when test="$normalize-space = 'true'">
4410
+ <xsl:value-of select="normalize-space(substring-before(concat($pText, $sep), $sep))"/>
4411
+ </xsl:when>
4412
+ <xsl:otherwise>
4413
+ <xsl:value-of select="substring-before(concat($pText, $sep), $sep)"/>
4414
+ </xsl:otherwise>
4415
+ </xsl:choose>
4176
4416
  </item>
4177
4417
  <xsl:call-template name="split">
4178
4418
  <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
4179
4419
  <xsl:with-param name="sep" select="$sep"/>
4420
+ <xsl:with-param name="normalize-space" select="$normalize-space"/>
4180
4421
  </xsl:call-template>
4181
4422
  </xsl:if>
4182
4423
  </xsl:template><xsl:template name="getDocumentId">
@@ -4242,4 +4483,23 @@
4242
4483
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
4243
4484
  </xsl:call-template>
4244
4485
  </xsl:if>
4486
+ </xsl:template><xsl:template name="repeat">
4487
+ <xsl:param name="char" select="'*'"/>
4488
+ <xsl:param name="count"/>
4489
+ <xsl:if test="$count &gt; 0">
4490
+ <xsl:value-of select="$char"/>
4491
+ <xsl:call-template name="repeat">
4492
+ <xsl:with-param name="char" select="$char"/>
4493
+ <xsl:with-param name="count" select="$count - 1"/>
4494
+ </xsl:call-template>
4495
+ </xsl:if>
4496
+ </xsl:template><xsl:template name="getLocalizedString">
4497
+ <xsl:param name="key"/>
4498
+
4499
+ <xsl:variable name="curr_lang">
4500
+ <xsl:call-template name="getLang"/>
4501
+ </xsl:variable>
4502
+
4503
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
4504
+
4245
4505
  </xsl:template></xsl:stylesheet>