metanorma-bipm 1.1.6 → 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:bipm="https://www.metanorma.org/ns/bipm" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java" version="1.0">
1
+ <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:bipm="https://www.metanorma.org/ns/bipm" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java" version="1.0">
2
2
 
3
3
  <xsl:output version="1.0" method="xml" encoding="UTF-8" indent="no"/>
4
4
 
@@ -13,6 +13,10 @@
13
13
  <!-- param for second pass -->
14
14
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
15
15
 
16
+ <xsl:param name="add_math_as_text">true</xsl:param>
17
+
18
+ <xsl:param name="add_math_as_attachment">true</xsl:param>
19
+
16
20
  <xsl:variable name="first_pass" select="count($index//item) = 0"/>
17
21
 
18
22
  <xsl:variable name="pageWidth" select="210"/>
@@ -196,7 +200,9 @@
196
200
  <xsl:apply-templates select="/*/bipm:sections/*" mode="contents"/>
197
201
  <xsl:apply-templates select="/*/bipm:bibliography/bipm:references[@normative='true']" mode="contents"/>
198
202
  <xsl:apply-templates select="/*/bipm:annex" mode="contents"/>
199
- <xsl:apply-templates select="/*/bipm:bibliography/bipm:references[not(@normative='true')]" mode="contents"/>
203
+ <xsl:if test="/*/bipm:bibliography/bipm:references[not(@normative='true')]/bipm:bibitem[not(contains(bipm:docidentifier, 'si-brochure-'))]">
204
+ <xsl:apply-templates select="/*/bipm:bibliography/bipm:references[not(@normative='true')]" mode="contents"/>
205
+ </xsl:if>
200
206
 
201
207
  <!-- Index -->
202
208
  <!-- <xsl:apply-templates select="//bipm:clause[@type = 'index']" mode="contents"/> -->
@@ -206,6 +212,37 @@
206
212
  </xsl:template>
207
213
 
208
214
 
215
+ <xsl:variable name="mathml_attachments">
216
+ <xsl:if test="$add_math_as_attachment = 'true'">
217
+ <xsl:for-each select="//mathml:math">
218
+
219
+ <xsl:variable name="sequence_number"><xsl:number level="any" format="00001"/></xsl:variable>
220
+
221
+ <xsl:variable name="clause_title_number" select="ancestor-or-self::bipm:clause[bipm:title[bipm:tab]][1]/bipm:title/node()[1]"/>
222
+
223
+ <xsl:variable name="mathml_filename">
224
+ <xsl:text>math</xsl:text>
225
+ <xsl:if test="$clause_title_number != '' and translate($clause_title_number, '.123456789', '') = ''">
226
+ <xsl:text>_</xsl:text>
227
+ <xsl:value-of select="$clause_title_number"/>
228
+ <xsl:text>_</xsl:text>
229
+ </xsl:if>
230
+ <xsl:value-of select="$sequence_number"/>
231
+ <xsl:text>.mml</xsl:text>
232
+ </xsl:variable>
233
+
234
+ <xsl:variable name="mathml_content">
235
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
236
+ </xsl:variable>
237
+
238
+ <attachment filename="{$mathml_filename}">
239
+ <xsl:value-of select="$mathml_content"/>
240
+ </attachment>
241
+
242
+ </xsl:for-each>
243
+ </xsl:if>
244
+ </xsl:variable>
245
+
209
246
 
210
247
  <xsl:template match="/">
211
248
  <fo:root xsl:use-attribute-sets="root-style" xml:lang="{$lang}">
@@ -308,6 +345,24 @@
308
345
 
309
346
  <fo:declarations>
310
347
  <xsl:call-template name="addPDFUAmeta"/>
348
+
349
+ <xsl:if test="$add_math_as_attachment = 'true'">
350
+ <!-- DEBUG: mathml_attachments=<xsl:copy-of select="$mathml_attachments"/> -->
351
+ <xsl:for-each select="xalan:nodeset($mathml_attachments)//attachment">
352
+
353
+ <xsl:variable name="mathml_filename" select="@filename"/>
354
+ <xsl:variable name="mathml_content" select="."/>
355
+
356
+ <xsl:variable name="basepath" select="java:org.metanorma.fop.Util.saveFileToDisk($mathml_filename,$mathml_content)"/>
357
+
358
+ <xsl:variable name="url" select="concat('url(file:',$basepath, ')')"/>
359
+
360
+ <xsl:if test="normalize-space($url) != ''">
361
+ <pdf:embedded-file src="{$url}" filename="{$mathml_filename}"/>
362
+ </xsl:if>
363
+ </xsl:for-each>
364
+ </xsl:if>
365
+
311
366
  </fo:declarations>
312
367
 
313
368
  <xsl:call-template name="addBookmarks">
@@ -475,6 +530,10 @@
475
530
  <xsl:apply-templates select="@*|node()" mode="flatxml"/>
476
531
  </xsl:copy>
477
532
  </xsl:template>
533
+
534
+ <xsl:template match="mathml:math" mode="flatxml" priority="2">
535
+ <xsl:copy-of select="."/>
536
+ </xsl:template>
478
537
 
479
538
  <!-- enclosing starting elements annex/... in clause -->
480
539
  <xsl:template match="bipm:annex" mode="flatxml">
@@ -740,6 +799,10 @@
740
799
  </xsl:copy>
741
800
  </xsl:template>
742
801
 
802
+ <xsl:template match="mathml:math" mode="flatxml_list" priority="2">
803
+ <xsl:copy-of select="."/>
804
+ </xsl:template>
805
+
743
806
  <!-- copy 'ol' 'ul' properties to each 'li' -->
744
807
  <!-- OBSOLETE: move note for list (list level note) into latest 'li' -->
745
808
  <!-- NOW: move note for list (list level note) into first 'li' -->
@@ -1066,7 +1129,7 @@
1066
1129
  </fo:block-container>
1067
1130
 
1068
1131
  <fo:block-container font-size="18pt" font-weight="bold" text-align="center">
1069
- <fo:block>
1132
+ <fo:block role="H1">
1070
1133
  <xsl:value-of select="//bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type='cover']"/>
1071
1134
  </fo:block>
1072
1135
  </fo:block-container>
@@ -1165,7 +1228,7 @@
1165
1228
 
1166
1229
  <fo:block-container margin-left="-14mm" margin-right="0mm">
1167
1230
  <fo:block-container margin-left="0mm" margin-right="0mm">
1168
- <fo:block font-family="Arial" font-size="16pt" font-weight="bold" text-align-last="justify" margin-bottom="82pt">
1231
+ <fo:block font-family="Arial" font-size="16pt" font-weight="bold" text-align-last="justify" margin-bottom="82pt" role="H1">
1169
1232
  <!-- <fo:marker marker-class-name="header-title"><xsl:value-of select="$title-toc"/></fo:marker> -->
1170
1233
  <fo:inline><xsl:value-of select="//bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type='main']"/></fo:inline>
1171
1234
  <fo:inline keep-together.within-line="always">
@@ -1179,7 +1242,7 @@
1179
1242
  </fo:block-container>
1180
1243
 
1181
1244
  <fo:block-container line-height="135%">
1182
- <fo:block>
1245
+ <fo:block role="TOC">
1183
1246
  <!-- <xsl:copy-of select="$contents"/> -->
1184
1247
 
1185
1248
  <xsl:if test="xalan:nodeset($contents)/doc[@id = $docid]//item[@display='true']">
@@ -1231,7 +1294,9 @@
1231
1294
  <xsl:apply-templates select="bipm:annex" mode="sections"/>
1232
1295
 
1233
1296
  <!-- Bibliography -->
1234
- <xsl:apply-templates select="bipm:bibliography/bipm:references[not(@normative='true')]" mode="sections"/>
1297
+ <xsl:if test="bipm:bibliography/bipm:references[not(@normative='true')]/bipm:bibitem[not(contains(bipm:docidentifier, 'si-brochure-'))]">
1298
+ <xsl:apply-templates select="bipm:bibliography/bipm:references[not(@normative='true')]" mode="sections"/>
1299
+ </xsl:if>
1235
1300
 
1236
1301
  <!-- Document Control -->
1237
1302
  <xsl:apply-templates select="bipm:doccontrol" mode="sections"/>
@@ -1280,7 +1345,7 @@
1280
1345
  </fo:block-container>
1281
1346
 
1282
1347
  <fo:block-container font-size="18pt" font-weight="bold" text-align="center">
1283
- <fo:block>
1348
+ <fo:block role="H1">
1284
1349
 
1285
1350
  <!-- <xsl:variable name="title"> -->
1286
1351
  <xsl:choose>
@@ -1315,7 +1380,7 @@
1315
1380
 
1316
1381
  <xsl:variable name="part_num" select="normalize-space(/bipm:bipm-standard/bipm:bibdata/bipm:ext/bipm:structuredidentifier/bipm:part)"/>
1317
1382
  <xsl:if test="/bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type = 'part']">
1318
- <fo:block>
1383
+ <fo:block role="H2">
1319
1384
  <xsl:if test="$part_num != ''">
1320
1385
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-part[@lang=$curr_lang]),'#',$part_num)"/>
1321
1386
  </xsl:if>
@@ -1325,7 +1390,7 @@
1325
1390
  </xsl:if>
1326
1391
  <xsl:variable name="subpart_num" select="normalize-space(/bipm:bipm-standard/bipm:bibdata/bipm:ext/bipm:structuredidentifier/bipm:subpart)"/>
1327
1392
  <xsl:if test="/bipm:bipm-standard/bipm:bibdata/bipm:title[@language = $curr_lang and @type = 'subpart']">
1328
- <fo:block>
1393
+ <fo:block role="H3">
1329
1394
  <xsl:if test="$subpart_num != ''">
1330
1395
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-subpart[@lang=$curr_lang]),'#',$subpart_num)"/>
1331
1396
  </xsl:if>
@@ -1397,8 +1462,9 @@
1397
1462
 
1398
1463
  <xsl:apply-templates select="bipm:annex" mode="sections"/>
1399
1464
 
1400
-
1401
- <xsl:apply-templates select="bipm:bibliography/bipm:references[not(@normative='true')]" mode="sections"/>
1465
+ <xsl:if test="bipm:bibliography/bipm:references[not(@normative='true')]/bipm:bibitem[not(contains(bipm:docidentifier, 'si-brochure-'))]">
1466
+ <xsl:apply-templates select="bipm:bibliography/bipm:references[not(@normative='true')]" mode="sections"/>
1467
+ </xsl:if>
1402
1468
 
1403
1469
  <!-- Document Control -->
1404
1470
  <xsl:apply-templates select="bipm:doccontrol" mode="sections"/>
@@ -1464,7 +1530,7 @@
1464
1530
  <xsl:otherwise>400</xsl:otherwise>
1465
1531
  </xsl:choose>
1466
1532
  </xsl:variable>
1467
- <fo:block>
1533
+ <fo:block role="H1">
1468
1534
  <xsl:if test="$title_num != 1">
1469
1535
  <xsl:attribute name="text-align">right</xsl:attribute>
1470
1536
  </xsl:if>
@@ -1504,8 +1570,8 @@
1504
1570
 
1505
1571
  <fo:block-container absolute-position="fixed" left="12.5mm" top="60mm">
1506
1572
 
1507
- <fo:block font-size="22.2pt" font-weight="{$weight-normal}"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'fr' and @type = 'main']"/></fo:block>
1508
- <fo:block font-size="22.2pt" font-weight="{$weight-bold}" margin-top="1mm"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'en' and @type = 'main']"/></fo:block>
1573
+ <fo:block font-size="22.2pt" font-weight="{$weight-normal}" role="H1"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'fr' and @type = 'main']"/></fo:block>
1574
+ <fo:block font-size="22.2pt" font-weight="{$weight-bold}" margin-top="1mm" role="H1"><xsl:value-of select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'en' and @type = 'main']"/></fo:block>
1509
1575
 
1510
1576
  <xsl:variable name="edition_str">édition</xsl:variable>
1511
1577
  <!-- <xsl:choose>
@@ -1518,7 +1584,7 @@
1518
1584
 
1519
1585
  <!-- <fo:block-container height="98%" display-align="center"> -->
1520
1586
  <fo:block-container absolute-position="fixed" left="12.5mm" top="92mm" height="170mm" width="144mm" display-align="center">
1521
- <fo:block>
1587
+ <fo:block role="H1">
1522
1588
 
1523
1589
  <xsl:variable name="title_appendix_fr">
1524
1590
  <xsl:apply-templates select="(//bipm:bipm-standard)[1]/bipm:bibdata/bipm:title[@language = 'fr' and @type = 'appendix']" mode="title"/>
@@ -1823,7 +1889,7 @@
1823
1889
  </xsl:call-template>
1824
1890
  </fo:block>
1825
1891
  <fo:block-container font-size="12pt" font-weight="bold" border-top="0.5pt solid black" padding-top="2mm" width="45mm">
1826
- <fo:block>
1892
+ <fo:block role="H1">
1827
1893
  <xsl:call-template name="add-letter-spacing">
1828
1894
  <xsl:with-param name="text" select="$title"/>
1829
1895
  <xsl:with-param name="letter-spacing" select="0.09"/>
@@ -1932,7 +1998,7 @@
1932
1998
  <xsl:if test="normalize-space($space-after) != ''">
1933
1999
  <xsl:attribute name="padding-bottom"><xsl:value-of select="normalize-space($space-after)"/></xsl:attribute>
1934
2000
  </xsl:if>
1935
- <fo:block>
2001
+ <fo:block role="TOCI">
1936
2002
  <xsl:if test="@level = 1">
1937
2003
  <!-- <xsl:attribute name="space-after">6pt</xsl:attribute> -->
1938
2004
  <xsl:attribute name="font-family">Arial</xsl:attribute>
@@ -2247,7 +2313,10 @@
2247
2313
  </xsl:template>
2248
2314
 
2249
2315
  <xsl:template match="bipm:license-statement//bipm:title">
2250
- <fo:block text-decoration="underline" margin-bottom="6pt">
2316
+ <xsl:variable name="level">
2317
+ <xsl:call-template name="getLevel"/>
2318
+ </xsl:variable>
2319
+ <fo:block text-decoration="underline" margin-bottom="6pt" role="H{$level}">
2251
2320
  <xsl:apply-templates/>
2252
2321
  </fo:block>
2253
2322
  </xsl:template>
@@ -2305,8 +2374,10 @@
2305
2374
  <!-- <xsl:when test="$level = 1 and $independentAppendix != ''">11.5pt</xsl:when>
2306
2375
  <xsl:when test="$level &gt;= 2 and $independentAppendix != ''">10.5pt</xsl:when> -->
2307
2376
  <xsl:when test="$level = 1">16pt</xsl:when>
2377
+ <xsl:when test="$level = 2 and ancestor::bipm:annex and ../@type = 'toc'">16pt</xsl:when>
2308
2378
  <xsl:when test="$level = 2 and ancestor::bipm:annex">10.5pt</xsl:when>
2309
2379
  <xsl:when test="$level = 2">14pt</xsl:when>
2380
+ <xsl:when test="$level &gt;= 3 and ancestor::bipm:annex and ../@type = 'toc'">9pt</xsl:when>
2310
2381
  <xsl:when test="$level = 3 and ancestor::bipm:annex">10pt</xsl:when>
2311
2382
  <xsl:when test="$level &gt;= 4 and ancestor::bipm:annex">9pt</xsl:when>
2312
2383
  <xsl:when test="$level = 3">12pt</xsl:when>
@@ -2330,6 +2401,7 @@
2330
2401
  <xsl:choose>
2331
2402
  <xsl:when test="$level = 1 and (parent::bipm:annex or ancestor::bipm:annex or parent::bipm:abstract or ancestor::bipm:preface)">84pt</xsl:when>
2332
2403
  <xsl:when test="$level = 1">6pt</xsl:when>
2404
+ <xsl:when test="$level = 2 and ancestor::bipm:annex and ../@type = 'toc'">29mm</xsl:when>
2333
2405
  <xsl:when test="$level = 2 and ancestor::bipm:annex">6pt</xsl:when> <!-- 6pt 12pt -->
2334
2406
  <!-- <xsl:when test="$level = 2 and $independentAppendix != ''">6pt</xsl:when> -->
2335
2407
  <xsl:when test="$level = 2">10pt</xsl:when>
@@ -2360,6 +2432,14 @@
2360
2432
  <xsl:attribute name="space-before">20pt</xsl:attribute>
2361
2433
  </xsl:if>
2362
2434
 
2435
+ <xsl:if test="$level &gt;= 3 and ancestor::bipm:annex and ../@type = 'toc'">
2436
+ <xsl:attribute name="space-before">0pt</xsl:attribute>
2437
+ </xsl:if>
2438
+
2439
+ <xsl:if test="@type = 'quoted'">
2440
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
2441
+ </xsl:if>
2442
+
2363
2443
  <fo:block-container margin-left="0mm">
2364
2444
 
2365
2445
  <!-- marker not working for math -->
@@ -2378,19 +2458,20 @@
2378
2458
 
2379
2459
  <xsl:choose>
2380
2460
  <xsl:when test="*[local-name() = 'tab'] and not(ancestor::bipm:annex) "><!-- split number and title --> <!-- and $independentAppendix = '' -->
2381
- <fo:table table-layout="fixed" width="100%">
2461
+ <fo:table table-layout="fixed" width="100%" role="H{$level}">
2382
2462
  <fo:table-column column-width="14mm"/>
2383
2463
  <fo:table-column column-width="136mm"/>
2384
2464
  <fo:table-body>
2385
2465
  <fo:table-row>
2386
2466
  <fo:table-cell>
2387
- <fo:block>
2467
+ <fo:block role="H{$level}">
2388
2468
  <xsl:value-of select="*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
2389
2469
  </fo:block>
2390
2470
  </fo:table-cell>
2391
2471
  <fo:table-cell>
2392
- <fo:block line-height-shift-adjustment="disregard-shifts">
2472
+ <fo:block line-height-shift-adjustment="disregard-shifts" role="H{$level}">
2393
2473
  <xsl:call-template name="extractTitle"/>
2474
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
2394
2475
  </fo:block>
2395
2476
  </fo:table-cell>
2396
2477
  </fo:table-row>
@@ -2398,7 +2479,7 @@
2398
2479
  </fo:table>
2399
2480
  </xsl:when>
2400
2481
  <xsl:otherwise>
2401
- <fo:block>
2482
+ <fo:block role="H{$level}">
2402
2483
  <!-- <xsl:if test="$independentAppendix != ''">
2403
2484
  <xsl:attribute name="margin-left">14mm</xsl:attribute>
2404
2485
  </xsl:if> -->
@@ -2407,24 +2488,23 @@
2407
2488
  <xsl:if test="$level &gt;= 3">
2408
2489
  <xsl:attribute name="margin-left">14mm</xsl:attribute>
2409
2490
  </xsl:if>
2410
- <xsl:if test="$level = 3">
2411
- <fo:inline padding-right="2.5mm" baseline-shift="15%">
2412
- <fo:instream-foreign-object content-height="2mm" content-width="2mm" fox:alt-text="Quad">
2413
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" viewBox="0 0 2 2">
2414
- <rect x="0" y="0" width="2" height="2" fill="black"/>
2415
- </svg>
2416
- </fo:instream-foreign-object>
2417
- </fo:inline>
2491
+ <xsl:if test="$level = 3 and not(../@type = 'toc')">
2492
+ <!-- <xsl:call-template name="blacksquare"/> -->
2418
2493
  </xsl:if>
2419
2494
  <xsl:if test="$level = 4">
2420
2495
  <xsl:attribute name="text-align">center</xsl:attribute>
2421
2496
  </xsl:if>
2497
+ <xsl:if test="../@type = 'toc'">
2498
+ <xsl:attribute name="text-align">left</xsl:attribute>
2499
+ </xsl:if>
2422
2500
  <xsl:call-template name="extractTitle"/>
2501
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
2423
2502
  </xsl:when>
2424
2503
  <xsl:otherwise>
2425
2504
  <!-- <xsl:choose>
2426
2505
  <xsl:when test="$independentAppendix = ''"> -->
2427
2506
  <xsl:apply-templates/>
2507
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
2428
2508
  <!-- </xsl:when>
2429
2509
  <xsl:otherwise>
2430
2510
  <xsl:variable name="section" select="*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
@@ -2447,6 +2527,7 @@
2447
2527
 
2448
2528
  </xsl:template>
2449
2529
 
2530
+
2450
2531
  <xsl:template match="*" mode="header">
2451
2532
  <xsl:apply-templates mode="header"/>
2452
2533
  </xsl:template>
@@ -3039,6 +3120,7 @@
3039
3120
  <xsl:attribute name="font-family">Arial</xsl:attribute>
3040
3121
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3041
3122
  <xsl:attribute name="line-height">130%</xsl:attribute>
3123
+ <xsl:attribute name="role">BlockQuote</xsl:attribute>
3042
3124
  </xsl:if>
3043
3125
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
3044
3126
  <xsl:apply-templates/>
@@ -3083,6 +3165,7 @@
3083
3165
  <xsl:attribute name="font-family">Arial</xsl:attribute>
3084
3166
  <xsl:attribute name="font-size">9pt</xsl:attribute>
3085
3167
  <xsl:attribute name="line-height">130%</xsl:attribute>
3168
+ <xsl:attribute name="role">BlockQuote</xsl:attribute>
3086
3169
  </xsl:if>
3087
3170
 
3088
3171
  <!-- last item -->
@@ -3240,16 +3323,19 @@
3240
3323
  </fo:block>
3241
3324
  </xsl:template>
3242
3325
 
3243
- <xsl:template match="bipm:preferred">
3244
- <fo:block font-weight="bold" keep-with-next="always" space-before="8pt" margin-bottom="6pt">
3245
- <xsl:if test="ancestor::bipm:term/bipm:name">
3246
- <fo:inline>
3247
- <xsl:attribute name="padding-right">2mm</xsl:attribute>
3248
- <xsl:apply-templates select="ancestor::bipm:term/bipm:name" mode="presentation"/>
3249
- </fo:inline>
3250
- </xsl:if>
3251
- <xsl:apply-templates/>
3252
- </fo:block>
3326
+ <xsl:template match="bipm:preferred">
3327
+ <fo:block font-weight="bold" keep-with-next="always" space-before="8pt" margin-bottom="6pt">
3328
+ <xsl:if test="ancestor::bipm:term/bipm:name">
3329
+ <xsl:variable name="level">
3330
+ <xsl:call-template name="getLevelTermName"/>
3331
+ </xsl:variable>
3332
+ <fo:inline role="H{$level}">
3333
+ <xsl:attribute name="padding-right">2mm</xsl:attribute>
3334
+ <xsl:apply-templates select="ancestor::bipm:term/bipm:name" mode="presentation"/>
3335
+ </fo:inline>
3336
+ </xsl:if>
3337
+ <xsl:apply-templates/>
3338
+ </fo:block>
3253
3339
  </xsl:template>
3254
3340
 
3255
3341
  <xsl:template match="bipm:bibitem">
@@ -3647,10 +3733,181 @@
3647
3733
  <xsl:value-of select="translate(., ' ', ' ')"/>
3648
3734
  </xsl:template>
3649
3735
 
3736
+ <xsl:template match="mathml:math" priority="2">
3737
+ <xsl:variable name="isAdded" select="@added"/>
3738
+ <xsl:variable name="isDeleted" select="@deleted"/>
3739
+
3740
+ <fo:inline xsl:use-attribute-sets="mathml-style">
3741
+
3742
+ <xsl:if test="ancestor::*[local-name()='table']">
3743
+ <xsl:attribute name="font-size">95%</xsl:attribute> <!-- base font in table is 10pt -->
3744
+ </xsl:if>
3745
+
3746
+ <xsl:call-template name="setTrackChangesStyles">
3747
+ <xsl:with-param name="isAdded" select="$isAdded"/>
3748
+ <xsl:with-param name="isDeleted" select="$isDeleted"/>
3749
+ </xsl:call-template>
3750
+
3751
+ <xsl:if test="$add_math_as_text = 'true'">
3752
+ <!-- set unique font-size (fiction) -->
3753
+ <xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
3754
+ <fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal">​</fo:inline> <!-- zero width space -->
3755
+ </xsl:if>
3756
+
3757
+ <!-- <fo:wrapper role="artifact"> -->
3758
+
3759
+ <xsl:variable name="mathml_content">
3760
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
3761
+ </xsl:variable>
3762
+ <!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
3763
+
3764
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
3765
+ <xsl:variable name="comment_text_">
3766
+ <xsl:choose>
3767
+ <xsl:when test="normalize-space($comment_text_following) != ''">
3768
+ <xsl:value-of select="$comment_text_following"/>
3769
+ </xsl:when>
3770
+ <xsl:otherwise>
3771
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
3772
+ </xsl:otherwise>
3773
+ </xsl:choose>
3774
+ </xsl:variable>
3775
+ <xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
3776
+ <xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
3777
+
3778
+ <xsl:variable name="filename" select="xalan:nodeset($mathml_attachments)//attachment[. = $mathml_content]/@filename"/>
3779
+ <xsl:choose>
3780
+ <xsl:when test="$add_math_as_attachment = 'true' and normalize-space($filename) != ''">
3781
+ <xsl:variable name="url" select="concat('url(embedded-file:', $filename, ')')"/>
3782
+ <fo:basic-link external-destination="{$url}" fox:alt-text="MathLink">
3783
+ <xsl:if test="normalize-space($comment_text) != ''">
3784
+ <!-- put Mathin Alternate Text -->
3785
+ <xsl:attribute name="fox:alt-text">
3786
+ <xsl:value-of select="$comment_text"/>
3787
+ </xsl:attribute>
3788
+ </xsl:if>
3789
+ <xsl:call-template name="mathml_instream_object">
3790
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
3791
+ <xsl:with-param name="comment_text" select="$comment_text"/>
3792
+ </xsl:call-template>
3793
+ </fo:basic-link>
3794
+ <!-- </xsl:if> -->
3795
+ </xsl:when>
3796
+ <xsl:otherwise>
3797
+ <xsl:call-template name="mathml_instream_object">
3798
+ <xsl:with-param name="mathml_content" select="$mathml_content"/>
3799
+ <xsl:with-param name="comment_text" select="$comment_text"/>
3800
+ </xsl:call-template>
3801
+ </xsl:otherwise>
3802
+ </xsl:choose>
3803
+ <!-- </fo:wrapper> -->
3804
+ </fo:inline>
3805
+ </xsl:template>
3806
+
3807
+ <xsl:template name="mathml_instream_object">
3808
+ <xsl:param name="mathml_content"/>
3809
+ <xsl:param name="comment_text"/>
3810
+
3811
+ <xsl:variable name="mathml">
3812
+ <xsl:apply-templates select="." mode="mathml"/>
3813
+ </xsl:variable>
3814
+
3815
+ <fo:instream-foreign-object fox:alt-text="Math">
3816
+
3817
+ <xsl:if test="local-name(../..) = 'formula'">
3818
+ <xsl:attribute name="width">95%</xsl:attribute>
3819
+ <xsl:attribute name="content-height">100%</xsl:attribute>
3820
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
3821
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
3822
+ </xsl:if>
3823
+
3824
+ <!-- put MathML in Actual Text -->
3825
+ <xsl:attribute name="fox:actual-text">
3826
+ <xsl:value-of select="$mathml_content"/>
3827
+ </xsl:attribute>
3828
+
3829
+ <xsl:if test="$add_math_as_text = 'true'">
3830
+ <xsl:if test="normalize-space($comment_text) != ''">
3831
+ <!-- put Mathin Alternate Text -->
3832
+ <xsl:attribute name="fox:alt-text">
3833
+ <xsl:value-of select="$comment_text"/>
3834
+ </xsl:attribute>
3835
+ </xsl:if>
3836
+ </xsl:if>
3837
+
3838
+ <xsl:copy-of select="xalan:nodeset($mathml)"/>
3839
+ </fo:instream-foreign-object>
3840
+ </xsl:template>
3841
+
3842
+
3843
+ <!-- =================== -->
3844
+ <!-- Table of Contents (ToC) processing -->
3845
+ <!-- =================== -->
3846
+ <xsl:template match="bipm:clause[@type = 'toc']" priority="3">
3847
+ <fo:block role="TOC">
3848
+ <xsl:copy-of select="@id"/>
3849
+ <xsl:apply-templates select="bipm:title[1]"/>
3850
+
3851
+ <!-- create virtual table to determine column's width -->
3852
+ <xsl:variable name="toc_table_simple">
3853
+ <tbody>
3854
+ <xsl:apply-templates mode="toc_table_width"/>
3855
+ </tbody>
3856
+ </xsl:variable>
3857
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($toc_table_simple)/*/tr[1]/td)"/>
3858
+ <xsl:variable name="colwidths">
3859
+ <xsl:call-template name="calculate-column-widths">
3860
+ <xsl:with-param name="cols-count" select="$cols-count"/>
3861
+ <xsl:with-param name="table" select="$toc_table_simple"/>
3862
+ </xsl:call-template>
3863
+ </xsl:variable>
3864
+
3865
+ <fo:table width="100%" table-layout="fixed">
3866
+ <fo:table-column column-width="100%"/>
3867
+ <fo:table-header>
3868
+ <fo:table-row font-weight="bold">
3869
+ <fo:table-cell text-align="right" font-size="9pt" font-family="Arial">
3870
+ <fo:block>
3871
+ <xsl:variable name="page">
3872
+ <xsl:call-template name="getLocalizedString">
3873
+ <xsl:with-param name="key">Page.sg</xsl:with-param>
3874
+ </xsl:call-template>
3875
+ </xsl:variable>
3876
+ <xsl:value-of select="java:toLowerCase(java:java.lang.String.new($page))"/>
3877
+ </fo:block>
3878
+ </fo:table-cell>
3879
+ </fo:table-row>
3880
+ </fo:table-header>
3881
+ <fo:table-body>
3882
+ <fo:table-row>
3883
+ <fo:table-cell>
3884
+ <fo:block>
3885
+ <xsl:variable name="title_id" select="generate-id(bipm:title[1])"/>
3886
+ <xsl:apply-templates select="*[not(generate-id() = $title_id)]">
3887
+ <xsl:with-param name="colwidths" select="$colwidths"/>
3888
+ </xsl:apply-templates>
3889
+ </fo:block>
3890
+ </fo:table-cell>
3891
+ </fo:table-row>
3892
+ </fo:table-body>
3893
+ </fo:table>
3894
+ </fo:block>
3895
+ </xsl:template>
3896
+
3897
+
3898
+ <!-- ignore section number before tab -->
3899
+ <xsl:template match="bipm:clause[@type = 'toc']//bipm:title/text()[1][not(preceding-sibling::bipm:tab) and following-sibling::*[1][self::bipm:tab]]"/>
3900
+ <xsl:template match="bipm:clause[@type = 'toc']//bipm:title/bipm:tab" priority="2"/>
3901
+
3902
+ <!-- =================== -->
3903
+ <!-- End Table of Contents (ToC) processing -->
3904
+ <!-- =================== -->
3905
+
3906
+
3650
3907
  <xsl:template name="insertHeaderFooter">
3651
3908
  <xsl:param name="header-title"/>
3652
3909
  <xsl:param name="orientation"/>
3653
- <fo:static-content flow-name="header-odd">
3910
+ <fo:static-content flow-name="header-odd" role="artifact">
3654
3911
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3655
3912
  <fo:block text-align="right">
3656
3913
  <xsl:copy-of select="$header-title"/>
@@ -3670,7 +3927,7 @@
3670
3927
  <fo:block> </fo:block>
3671
3928
  </fo:block-container>
3672
3929
  </fo:static-content>
3673
- <fo:static-content flow-name="header-even">
3930
+ <fo:static-content flow-name="header-even" role="artifact">
3674
3931
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3675
3932
  <fo:block>
3676
3933
  <fo:inline font-weight="bold"><fo:page-number/></fo:inline>
@@ -3851,7 +4108,7 @@
3851
4108
  <fo:block id="{@id}" span="all">
3852
4109
  <xsl:apply-templates select="bipm:title"/>
3853
4110
  </fo:block>
3854
- <fo:block>
4111
+ <fo:block role="Index">
3855
4112
  <xsl:apply-templates select="*[not(local-name() = 'title')]"/>
3856
4113
 
3857
4114
  <!-- TEST <xsl:variable name="alphabet" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
@@ -3877,7 +4134,7 @@
3877
4134
 
3878
4135
  <!-- <xsl:template match="bipm:clause[@type = 'index']/bipm:title" priority="4"> -->
3879
4136
  <xsl:template match="bipm:indexsect/bipm:title" priority="4">
3880
- <fo:block font-size="16pt" font-weight="bold" margin-bottom="84pt" margin-left="-18mm">
4137
+ <fo:block font-size="16pt" font-weight="bold" margin-bottom="84pt" margin-left="-18mm" role="H1">
3881
4138
  <!-- Index -->
3882
4139
  <xsl:apply-templates/>
3883
4140
  </fo:block>
@@ -4470,6 +4727,7 @@
4470
4727
  </xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
4471
4728
  <xsl:attribute name="white-space">pre</xsl:attribute>
4472
4729
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
4730
+ <xsl:attribute name="role">Code</xsl:attribute>
4473
4731
 
4474
4732
 
4475
4733
 
@@ -4491,8 +4749,13 @@
4491
4749
 
4492
4750
  </xsl:attribute-set><xsl:attribute-set name="requirement-label-style">
4493
4751
 
4494
- </xsl:attribute-set><xsl:attribute-set name="requirement-subject-style">
4495
- </xsl:attribute-set><xsl:attribute-set name="requirement-inherit-style">
4752
+ </xsl:attribute-set><xsl:attribute-set name="subject-style">
4753
+ </xsl:attribute-set><xsl:attribute-set name="inherit-style">
4754
+ </xsl:attribute-set><xsl:attribute-set name="description-style">
4755
+ </xsl:attribute-set><xsl:attribute-set name="specification-style">
4756
+ </xsl:attribute-set><xsl:attribute-set name="measurement-target-style">
4757
+ </xsl:attribute-set><xsl:attribute-set name="verification-style">
4758
+ </xsl:attribute-set><xsl:attribute-set name="import-style">
4496
4759
  </xsl:attribute-set><xsl:attribute-set name="recommendation-style">
4497
4760
 
4498
4761
 
@@ -4563,6 +4826,7 @@
4563
4826
 
4564
4827
 
4565
4828
 
4829
+
4566
4830
  </xsl:attribute-set><xsl:attribute-set name="termexample-name-style">
4567
4831
 
4568
4832
 
@@ -4681,7 +4945,8 @@
4681
4945
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
4682
4946
 
4683
4947
 
4684
- </xsl:attribute-set><xsl:attribute-set name="quote-style">
4948
+ </xsl:attribute-set><xsl:attribute-set name="quote-style">
4949
+ <xsl:attribute name="role">BlockQuote</xsl:attribute>
4685
4950
 
4686
4951
 
4687
4952
 
@@ -4802,13 +5067,20 @@
4802
5067
 
4803
5068
  </xsl:attribute-set><xsl:attribute-set name="list-style">
4804
5069
 
4805
- </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
5070
+ </xsl:attribute-set><xsl:attribute-set name="toc-style">
5071
+ <xsl:attribute name="line-height">135%</xsl:attribute>
5072
+ </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="OLD_processPrefaceSectionsDefault_Contents">
4806
5073
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
4807
5074
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
4808
5075
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
4809
5076
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']" mode="contents"/>
4810
5077
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']" mode="contents"/>
4811
- </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
5078
+ </xsl:template><xsl:template name="processPrefaceSectionsDefault_Contents">
5079
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
5080
+ <xsl:sort select="@displayorder" data-type="number"/>
5081
+ <xsl:apply-templates select="." mode="contents"/>
5082
+ </xsl:for-each>
5083
+ </xsl:template><xsl:template name="OLD_processMainSectionsDefault_Contents">
4812
5084
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
4813
5085
 
4814
5086
  <!-- Normative references -->
@@ -4821,13 +5093,33 @@
4821
5093
  <!-- Bibliography -->
4822
5094
  <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"/>
4823
5095
 
4824
- </xsl:template><xsl:template name="processPrefaceSectionsDefault">
5096
+ </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
5097
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5098
+ <xsl:sort select="@displayorder" data-type="number"/>
5099
+ <xsl:apply-templates select="." mode="contents"/>
5100
+ </xsl:for-each>
5101
+
5102
+ <xsl:for-each select="/*/*[local-name()='annex']">
5103
+ <xsl:sort select="@displayorder" data-type="number"/>
5104
+ <xsl:apply-templates select="." mode="contents"/>
5105
+ </xsl:for-each>
5106
+
5107
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5108
+ <xsl:sort select="@displayorder" data-type="number"/>
5109
+ <xsl:apply-templates select="." mode="contents"/>
5110
+ </xsl:for-each>
5111
+ </xsl:template><xsl:template name="OLD_processPrefaceSectionsDefault">
4825
5112
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
4826
5113
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
4827
5114
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']"/>
4828
5115
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']"/>
4829
5116
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']"/>
4830
- </xsl:template><xsl:template name="processMainSectionsDefault">
5117
+ </xsl:template><xsl:template name="processPrefaceSectionsDefault">
5118
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
5119
+ <xsl:sort select="@displayorder" data-type="number"/>
5120
+ <xsl:apply-templates select="."/>
5121
+ </xsl:for-each>
5122
+ </xsl:template><xsl:template name="OLD_processMainSectionsDefault">
4831
5123
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']"/>
4832
5124
 
4833
5125
  <!-- Normative references -->
@@ -4839,6 +5131,22 @@
4839
5131
  <xsl:apply-templates select="/*/*[local-name()='annex']"/>
4840
5132
  <!-- Bibliography -->
4841
5133
  <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]"/>
5134
+ </xsl:template><xsl:template name="processMainSectionsDefault">
5135
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
5136
+ <xsl:sort select="@displayorder" data-type="number"/>
5137
+ <xsl:apply-templates select="."/>
5138
+
5139
+ </xsl:for-each>
5140
+
5141
+ <xsl:for-each select="/*/*[local-name()='annex']">
5142
+ <xsl:sort select="@displayorder" data-type="number"/>
5143
+ <xsl:apply-templates select="."/>
5144
+ </xsl:for-each>
5145
+
5146
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
5147
+ <xsl:sort select="@displayorder" data-type="number"/>
5148
+ <xsl:apply-templates select="."/>
5149
+ </xsl:for-each>
4842
5150
  </xsl:template><xsl:template match="text()">
4843
5151
  <xsl:value-of select="."/>
4844
5152
  </xsl:template><xsl:template match="*[local-name()='br']">
@@ -4869,7 +5177,9 @@
4869
5177
 
4870
5178
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
4871
5179
 
4872
-
5180
+
5181
+
5182
+
4873
5183
 
4874
5184
  <xsl:call-template name="fn_name_display"/>
4875
5185
 
@@ -5013,6 +5323,8 @@
5013
5323
  <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
5014
5324
  </xsl:if>
5015
5325
 
5326
+
5327
+
5016
5328
  <xsl:choose>
5017
5329
  <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
5018
5330
  <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
@@ -5304,9 +5616,9 @@
5304
5616
  <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation">
5305
5617
  <xsl:with-param name="continued">true</xsl:with-param>
5306
5618
  </xsl:apply-templates>
5307
- <xsl:for-each select="ancestor::*[local-name()='table'][1]">
5308
- <xsl:call-template name="fn_name_display"/>
5309
- </xsl:for-each>
5619
+
5620
+
5621
+
5310
5622
 
5311
5623
  </fo:table-cell>
5312
5624
  </fo:table-row>
@@ -5390,7 +5702,11 @@
5390
5702
 
5391
5703
  <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
5392
5704
 
5393
- <xsl:if test="$isNoteOrFnExist = 'true'">
5705
+ <xsl:variable name="isNoteOrFnExistShowAfterTable">
5706
+
5707
+ </xsl:variable>
5708
+
5709
+ <xsl:if test="$isNoteOrFnExist = 'true' or normalize-space($isNoteOrFnExistShowAfterTable) = 'true'">
5394
5710
 
5395
5711
  <xsl:variable name="cols-count">
5396
5712
  <xsl:choose>
@@ -5543,6 +5859,19 @@
5543
5859
 
5544
5860
  </fo:table-body>
5545
5861
 
5862
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/text()[1]" priority="2" mode="presentation_name">
5863
+ <xsl:choose>
5864
+ <xsl:when test="substring-after(., '—') != ''">
5865
+ <xsl:text>—</xsl:text><xsl:value-of select="substring-after(., '—')"/>
5866
+ </xsl:when>
5867
+ <xsl:otherwise>
5868
+ <xsl:value-of select="."/>
5869
+ </xsl:otherwise>
5870
+ </xsl:choose>
5871
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']" mode="presentation_name">
5872
+ <xsl:apply-templates mode="presentation_name"/>
5873
+ </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='name']/node()" mode="presentation_name">
5874
+ <xsl:apply-templates select="."/>
5546
5875
  </xsl:template><xsl:template match="*[local-name()='tr']">
5547
5876
  <xsl:variable name="parent-name" select="local-name(..)"/>
5548
5877
  <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
@@ -5781,14 +6110,12 @@
5781
6110
  <xsl:apply-templates/>
5782
6111
  </xsl:template><xsl:template name="fn_display">
5783
6112
  <xsl:variable name="references">
6113
+
5784
6114
  <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
5785
- <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
5786
-
5787
-
5788
- <xsl:apply-templates/>
5789
- </fn>
6115
+ <xsl:call-template name="create_fn"/>
5790
6116
  </xsl:for-each>
5791
6117
  </xsl:variable>
6118
+
5792
6119
  <xsl:for-each select="xalan:nodeset($references)//fn">
5793
6120
  <xsl:variable name="reference" select="@reference"/>
5794
6121
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
@@ -5834,6 +6161,12 @@
5834
6161
  </fo:block>
5835
6162
  </xsl:if>
5836
6163
  </xsl:for-each>
6164
+ </xsl:template><xsl:template name="create_fn">
6165
+ <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
6166
+
6167
+
6168
+ <xsl:apply-templates/>
6169
+ </fn>
5837
6170
  </xsl:template><xsl:template name="fn_name_display">
5838
6171
  <!-- <xsl:variable name="references">
5839
6172
  <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
@@ -6832,6 +7165,12 @@
6832
7165
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
6833
7166
  </xsl:call-template>
6834
7167
 
7168
+ <!-- insert helper tag -->
7169
+ <xsl:if test="$add_math_as_text = 'true'">
7170
+ <fo:inline color="white" font-size="1pt" font-style="normal" font-weight="normal">​</fo:inline> <!-- zero width space -->
7171
+ </xsl:if>
7172
+
7173
+
6835
7174
  <xsl:variable name="mathml">
6836
7175
  <xsl:apply-templates select="." mode="mathml"/>
6837
7176
  </xsl:variable>
@@ -6843,15 +7182,75 @@
6843
7182
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6844
7183
  <xsl:attribute name="scaling">uniform</xsl:attribute>
6845
7184
  </xsl:if>
6846
- <!-- <xsl:attribute name="fox:alt-text">
6847
- put AsciiMath/LaTeX math
6848
- </xsl:attribute> -->
7185
+
7186
+ <xsl:if test="$add_math_as_text = 'true'">
7187
+ <!-- <xsl:variable name="comment_text" select="following-sibling::node()[1][self::comment()]"/> -->
7188
+ <xsl:variable name="comment_text" select="normalize-space(translate(.,' ⁢',' '))"/>
7189
+ <!-- <xsl:variable name="comment_text" select="normalize-space(.)"/> -->
7190
+ <xsl:if test="normalize-space($comment_text) != ''">
7191
+ <!-- put Mathin Alternate Text -->
7192
+ <xsl:attribute name="fox:alt-text">
7193
+ <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7194
+ <!-- <xsl:value-of select="$comment_text"/> -->
7195
+ </xsl:attribute>
7196
+ </xsl:if>
7197
+ </xsl:if>
7198
+
7199
+
7200
+ <xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
7201
+ <xsl:variable name="comment_text_">
7202
+ <xsl:choose>
7203
+ <xsl:when test="normalize-space($comment_text_following) != ''">
7204
+ <xsl:value-of select="$comment_text_following"/>
7205
+ </xsl:when>
7206
+ <xsl:otherwise>
7207
+ <xsl:value-of select="normalize-space(translate(.,' ⁢',' '))"/>
7208
+ </xsl:otherwise>
7209
+ </xsl:choose>
7210
+ </xsl:variable>
7211
+ <xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
7212
+
7213
+ <xsl:if test="normalize-space($comment_text) != ''">
7214
+ <!-- put Mathin Alternate Text -->
7215
+ <xsl:attribute name="fox:alt-text">
7216
+ <xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
7217
+ </xsl:attribute>
7218
+ </xsl:if>
7219
+
7220
+ <xsl:variable name="mathml_content">
7221
+ <xsl:apply-templates select="." mode="mathml_actual_text"/>
7222
+ </xsl:variable>
7223
+ <!-- put MathML in Actual Text -->
7224
+ <xsl:attribute name="fox:actual-text">
7225
+ <xsl:value-of select="$mathml_content"/>
7226
+ </xsl:attribute>
6849
7227
 
6850
7228
 
6851
7229
  <!-- <xsl:copy-of select="."/> -->
6852
7230
  <xsl:copy-of select="xalan:nodeset($mathml)"/>
6853
7231
  </fo:instream-foreign-object>
6854
7232
  </fo:inline>
7233
+ </xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
7234
+ <!-- <xsl:text>a+b</xsl:text> -->
7235
+ <xsl:text>&lt;</xsl:text>
7236
+ <xsl:value-of select="local-name()"/>
7237
+ <xsl:if test="local-name() = 'math'">
7238
+ <xsl:text> xmlns="http://www.w3.org/1998/Math/MathML"</xsl:text>
7239
+ </xsl:if>
7240
+ <xsl:for-each select="@*">
7241
+ <xsl:text> </xsl:text>
7242
+ <xsl:value-of select="local-name()"/>
7243
+ <xsl:text>="</xsl:text>
7244
+ <xsl:value-of select="."/>
7245
+ <xsl:text>"</xsl:text>
7246
+ </xsl:for-each>
7247
+ <xsl:text>&gt;</xsl:text>
7248
+ <xsl:apply-templates mode="mathml_actual_text"/>
7249
+ <xsl:text>&lt;/</xsl:text>
7250
+ <xsl:value-of select="local-name()"/>
7251
+ <xsl:text>&gt;</xsl:text>
7252
+ </xsl:template><xsl:template match="text()" mode="mathml_actual_text">
7253
+ <xsl:value-of select="normalize-space()"/>
6855
7254
  </xsl:template><xsl:template match="@*|node()" mode="mathml">
6856
7255
  <xsl:copy>
6857
7256
  <xsl:apply-templates select="@*|node()" mode="mathml"/>
@@ -6861,19 +7260,6 @@
6861
7260
  <!-- replace start and end spaces to non-break space -->
6862
7261
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
6863
7262
  </xsl:copy>
6864
- </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml">
6865
- <xsl:copy>
6866
- <xsl:apply-templates select="@*|node()" mode="mathml"/>
6867
- </xsl:copy>
6868
- <xsl:choose>
6869
- <!-- if in msub, then don't add space -->
6870
- <xsl:when test="ancestor::mathml:mrow[parent::mathml:msub and preceding-sibling::*[1][self::mathml:mrow]]"/>
6871
- <!-- if next char in digit, don't add space -->
6872
- <xsl:when test="translate(substring(following-sibling::*[1]/text(),1,1),'0123456789','') = ''"/>
6873
- <xsl:otherwise>
6874
- <mathml:mspace width="0.5ex"/>
6875
- </xsl:otherwise>
6876
- </xsl:choose>
6877
7263
  </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">
6878
7264
  <xsl:variable name="target">
6879
7265
  <xsl:choose>
@@ -6926,7 +7312,10 @@
6926
7312
  </fo:block>
6927
7313
  <xsl:apply-templates/>
6928
7314
  </xsl:template><xsl:template match="*[local-name()='appendix']/*[local-name()='title']"/><xsl:template match="*[local-name()='appendix']/*[local-name()='title']" mode="process">
6929
- <fo:inline><xsl:apply-templates/></fo:inline>
7315
+ <xsl:variable name="level">
7316
+ <xsl:call-template name="getLevel"/>
7317
+ </xsl:variable>
7318
+ <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
6930
7319
  </xsl:template><xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
6931
7320
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
6932
7321
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -6961,9 +7350,10 @@
6961
7350
 
6962
7351
  </xsl:variable>
6963
7352
 
7353
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
6964
7354
  <xsl:choose>
6965
- <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:text>—</xsl:text></xsl:when>
6966
- <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:text> — </xsl:text></xsl:otherwise>
7355
+ <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text>—</xsl:text></xsl:if></xsl:when>
7356
+ <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:if test="normalize-space($text) != ''"><xsl:text> — </xsl:text></xsl:if></xsl:otherwise>
6967
7357
  </xsl:choose>
6968
7358
  <xsl:apply-templates/>
6969
7359
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
@@ -7123,7 +7513,10 @@
7123
7513
  </fo:block>
7124
7514
  </xsl:template><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']" mode="presentation">
7125
7515
  <xsl:if test="normalize-space() != ''">
7126
- <fo:inline>
7516
+ <xsl:variable name="level">
7517
+ <xsl:call-template name="getLevelTermName"/>
7518
+ </xsl:variable>
7519
+ <fo:inline role="H{$level}">
7127
7520
  <xsl:apply-templates/>
7128
7521
  <!-- <xsl:if test="$namespace = 'gb' or $namespace = 'ogc'">
7129
7522
  <xsl:text>.</xsl:text>
@@ -7428,6 +7821,13 @@
7428
7821
  </xsl:attribute>
7429
7822
  <xsl:apply-templates mode="svg_update"/>
7430
7823
  </xsl:copy>
7824
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
7825
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
7826
+ <xsl:for-each select="*[local-name() = 'svg']">
7827
+ <xsl:call-template name="image_svg">
7828
+ <xsl:with-param name="name" select="$name"/>
7829
+ </xsl:call-template>
7830
+ </xsl:for-each>
7431
7831
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
7432
7832
  <xsl:variable name="svg_content" select="document(@src)"/>
7433
7833
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -7532,7 +7932,7 @@
7532
7932
  </fo:basic-link>
7533
7933
  </fo:block>
7534
7934
  </fo:block-container>
7535
- </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">
7935
+ </xsl:template><xsl:template match="*[local-name() = 'emf']"/><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">
7536
7936
  <xsl:apply-templates mode="contents"/>
7537
7937
  <xsl:text> </xsl:text>
7538
7938
  </xsl:template><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="bookmarks">
@@ -7772,6 +8172,7 @@
7772
8172
  </xsl:when>
7773
8173
  <xsl:otherwise>
7774
8174
  <xsl:apply-templates/>
8175
+ <xsl:apply-templates select="following-sibling::*[1][local-name() = 'variant-title'][@type = 'sub']" mode="subtitle"/>
7775
8176
  </xsl:otherwise>
7776
8177
  </xsl:choose>
7777
8178
  </fo:block>
@@ -7912,14 +8313,6 @@
7912
8313
  <fo:block>
7913
8314
  <fo:inline padding-right="3mm">Obligation</fo:inline><xsl:value-of select="."/>
7914
8315
  </fo:block>
7915
- </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" mode="presentation">
7916
- <fo:block xsl:use-attribute-sets="requirement-subject-style">
7917
- <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
7918
- </fo:block>
7919
- </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'inherit']">
7920
- <fo:block xsl:use-attribute-sets="requirement-inherit-style">
7921
- <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
7922
- </fo:block>
7923
8316
  </xsl:template><xsl:template match="*[local-name() = 'recommendation']">
7924
8317
  <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">
7925
8318
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
@@ -7936,6 +8329,38 @@
7936
8329
  <fo:block xsl:use-attribute-sets="recommendation-label-style">
7937
8330
  <xsl:apply-templates/>
7938
8331
  </fo:block>
8332
+ </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" priority="2"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" mode="presentation">
8333
+ <fo:block xsl:use-attribute-sets="subject-style">
8334
+ <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
8335
+ </fo:block>
8336
+ </xsl:template><xsl:template match="*[local-name() = 'subject']">
8337
+ <fo:block xsl:use-attribute-sets="subject-style">
8338
+ <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
8339
+ </fo:block>
8340
+ </xsl:template><xsl:template match="*[local-name() = 'inherit'] | *[local-name() = 'component'][@class = 'inherit']">
8341
+ <fo:block xsl:use-attribute-sets="inherit-style">
8342
+ <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
8343
+ </fo:block>
8344
+ </xsl:template><xsl:template match="*[local-name() = 'description'] | *[local-name() = 'component'][@class = 'description']">
8345
+ <fo:block xsl:use-attribute-sets="description-style">
8346
+ <xsl:apply-templates/>
8347
+ </fo:block>
8348
+ </xsl:template><xsl:template match="*[local-name() = 'specification'] | *[local-name() = 'component'][@class = 'specification']">
8349
+ <fo:block xsl:use-attribute-sets="specification-style">
8350
+ <xsl:apply-templates/>
8351
+ </fo:block>
8352
+ </xsl:template><xsl:template match="*[local-name() = 'measurement-target'] | *[local-name() = 'component'][@class = 'measurement-target']">
8353
+ <fo:block xsl:use-attribute-sets="measurement-target-style">
8354
+ <xsl:apply-templates/>
8355
+ </fo:block>
8356
+ </xsl:template><xsl:template match="*[local-name() = 'verification'] | *[local-name() = 'component'][@class = 'verification']">
8357
+ <fo:block xsl:use-attribute-sets="verification-style">
8358
+ <xsl:apply-templates/>
8359
+ </fo:block>
8360
+ </xsl:template><xsl:template match="*[local-name() = 'import'] | *[local-name() = 'component'][@class = 'import']">
8361
+ <fo:block xsl:use-attribute-sets="import-style">
8362
+ <xsl:apply-templates/>
8363
+ </fo:block>
7939
8364
  </xsl:template><xsl:template match="*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
7940
8365
  <fo:block-container margin-left="0mm" margin-right="0mm" margin-bottom="12pt">
7941
8366
  <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
@@ -8087,7 +8512,19 @@
8087
8512
  </fo:inline>
8088
8513
  </xsl:if>
8089
8514
  </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'p']">
8090
- <fo:inline><xsl:apply-templates/></fo:inline>
8515
+ <xsl:variable name="element">inline
8516
+
8517
+ </xsl:variable>
8518
+ <xsl:choose>
8519
+ <xsl:when test="contains($element, 'block')">
8520
+ <fo:block xsl:use-attribute-sets="example-p-style">
8521
+ <xsl:apply-templates/>
8522
+ </fo:block>
8523
+ </xsl:when>
8524
+ <xsl:otherwise>
8525
+ <fo:inline><xsl:apply-templates/></fo:inline>
8526
+ </xsl:otherwise>
8527
+ </xsl:choose>
8091
8528
  </xsl:template><xsl:template match="*[local-name() = 'example']">
8092
8529
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
8093
8530
 
@@ -8189,20 +8626,22 @@
8189
8626
  </xsl:if>
8190
8627
  </xsl:template><xsl:variable name="localized.source">
8191
8628
  <xsl:call-template name="getLocalizedString">
8192
- <xsl:with-param name="key">source</xsl:with-param>
8193
- </xsl:call-template>
8629
+ <xsl:with-param name="key">source</xsl:with-param>
8630
+ </xsl:call-template>
8194
8631
  </xsl:variable><xsl:template match="*[local-name() = 'origin']">
8195
8632
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8196
8633
  <xsl:if test="normalize-space(@citeas) = ''">
8197
8634
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8198
8635
  </xsl:if>
8199
8636
 
8637
+
8200
8638
  <fo:inline>
8201
8639
 
8202
8640
 
8203
8641
 
8204
8642
 
8205
8643
 
8644
+
8206
8645
  <xsl:value-of select="$localized.source"/>
8207
8646
  <xsl:text> </xsl:text>
8208
8647
 
@@ -8213,6 +8652,7 @@
8213
8652
  <fo:inline xsl:use-attribute-sets="origin-style">
8214
8653
  <xsl:apply-templates/>
8215
8654
  </fo:inline>
8655
+
8216
8656
  </fo:basic-link>
8217
8657
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
8218
8658
  <fo:inline><xsl:apply-templates/></fo:inline>
@@ -8279,6 +8719,9 @@
8279
8719
 
8280
8720
  </xsl:if>
8281
8721
 
8722
+ <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
8723
+ <xsl:variable name="text" select="normalize-space()"/>
8724
+
8282
8725
 
8283
8726
 
8284
8727
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
@@ -8300,7 +8743,9 @@
8300
8743
 
8301
8744
 
8302
8745
  </xsl:if>
8303
-
8746
+
8747
+
8748
+
8304
8749
  <xsl:apply-templates/>
8305
8750
  </fo:basic-link>
8306
8751
 
@@ -8637,6 +9082,7 @@
8637
9082
  </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'li']" priority="4">
8638
9083
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
8639
9084
  <fo:block start-indent="{5 * $level}mm" text-indent="-5mm">
9085
+
8640
9086
  <xsl:apply-templates/>
8641
9087
  </fo:block>
8642
9088
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
@@ -8703,8 +9149,8 @@
8703
9149
 
8704
9150
  </xsl:otherwise>
8705
9151
  </xsl:choose>
9152
+ <!-- end BIPM bibitem processing-->
8706
9153
 
8707
- <!-- end BIPM bibitem processing-->
8708
9154
 
8709
9155
 
8710
9156
 
@@ -8834,6 +9280,97 @@
8834
9280
  <fo:block-container border="1pt solid black" width="50%">
8835
9281
  <fo:block> </fo:block>
8836
9282
  </fo:block-container>
9283
+ </xsl:template><xsl:template match="*[local-name() = 'toc']">
9284
+ <xsl:param name="colwidths"/>
9285
+ <xsl:variable name="colwidths_">
9286
+ <xsl:choose>
9287
+ <xsl:when test="not($colwidths)">
9288
+ <xsl:variable name="toc_table_simple">
9289
+ <tbody>
9290
+ <xsl:apply-templates mode="toc_table_width"/>
9291
+ </tbody>
9292
+ </xsl:variable>
9293
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($toc_table_simple)/*/tr[1]/td)"/>
9294
+ <xsl:call-template name="calculate-column-widths">
9295
+ <xsl:with-param name="cols-count" select="$cols-count"/>
9296
+ <xsl:with-param name="table" select="$toc_table_simple"/>
9297
+ </xsl:call-template>
9298
+ </xsl:when>
9299
+ <xsl:otherwise>
9300
+ <xsl:copy-of select="$colwidths"/>
9301
+ </xsl:otherwise>
9302
+ </xsl:choose>
9303
+ </xsl:variable>
9304
+ <fo:block role="TOCI" space-after="16pt">
9305
+ <fo:table width="100%" table-layout="fixed">
9306
+ <xsl:for-each select="xalan:nodeset($colwidths_)/column">
9307
+ <fo:table-column column-width="proportional-column-width({.})"/>
9308
+ </xsl:for-each>
9309
+ <fo:table-body>
9310
+ <xsl:apply-templates/>
9311
+ </fo:table-body>
9312
+ </fo:table>
9313
+ </fo:block>
9314
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']">
9315
+ <fo:table-row min-height="5mm">
9316
+ <xsl:apply-templates/>
9317
+ </fo:table-row>
9318
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']/*[local-name() = 'p']">
9319
+ <xsl:apply-templates/>
9320
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'xref']" priority="3">
9321
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
9322
+ <xsl:variable name="target" select="@target"/>
9323
+ <xsl:for-each select="*[local-name() = 'tab']">
9324
+ <xsl:variable name="current_id" select="generate-id()"/>
9325
+ <fo:table-cell>
9326
+ <fo:block>
9327
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9328
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
9329
+ <xsl:choose>
9330
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
9331
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
9332
+ </xsl:choose>
9333
+ </xsl:for-each>
9334
+ </fo:basic-link>
9335
+ </fo:block>
9336
+ </fo:table-cell>
9337
+ </xsl:for-each>
9338
+ <!-- last column - for page numbers -->
9339
+ <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
9340
+ <fo:block>
9341
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9342
+ <fo:page-number-citation ref-id="{$target}"/>
9343
+ </fo:basic-link>
9344
+ </fo:block>
9345
+ </fo:table-cell>
9346
+ </xsl:template><xsl:template match="*" mode="toc_table_width">
9347
+ <xsl:apply-templates mode="toc_table_width"/>
9348
+ </xsl:template><xsl:template match="*[local-name() = 'clause'][@type = 'toc']/*[local-name() = 'title']" mode="toc_table_width"/><xsl:template match="*[local-name() = 'clause'][not(@type = 'toc')]/*[local-name() = 'title']" mode="toc_table_width"/><xsl:template match="*[local-name() = 'li']" mode="toc_table_width">
9349
+ <tr>
9350
+ <xsl:apply-templates mode="toc_table_width"/>
9351
+ </tr>
9352
+ </xsl:template><xsl:template match="*[local-name() = 'xref']" mode="toc_table_width">
9353
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
9354
+ <xsl:for-each select="*[local-name() = 'tab']">
9355
+ <xsl:variable name="current_id" select="generate-id()"/>
9356
+ <td>
9357
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
9358
+ <xsl:copy-of select="."/>
9359
+ </xsl:for-each>
9360
+ </td>
9361
+ </xsl:for-each>
9362
+ <td>333</td> <!-- page number, just for fill -->
9363
+ </xsl:template><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
9364
+ <fo:inline padding-right="5mm"> </fo:inline>
9365
+ <fo:inline><xsl:apply-templates/></fo:inline>
9366
+ </xsl:template><xsl:template match="*[local-name() = 'blacksquare']" name="blacksquare">
9367
+ <fo:inline padding-right="2.5mm" baseline-shift="5%">
9368
+ <fo:instream-foreign-object content-height="2mm" content-width="2mm" fox:alt-text="Quad">
9369
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" viewBox="0 0 2 2">
9370
+ <rect x="0" y="0" width="2" height="2" fill="black"/>
9371
+ </svg>
9372
+ </fo:instream-foreign-object>
9373
+ </fo:inline>
8837
9374
  </xsl:template><xsl:template name="convertDate">
8838
9375
  <xsl:param name="date"/>
8839
9376
  <xsl:param name="format" select="'short'"/>
@@ -8953,7 +9490,7 @@
8953
9490
  <xsl:variable name="lang">
8954
9491
  <xsl:call-template name="getLang"/>
8955
9492
  </xsl:variable>
8956
- <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
9493
+ <pdf:catalog>
8957
9494
  <pdf:dictionary type="normal" key="ViewerPreferences">
8958
9495
  <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
8959
9496
  </pdf:dictionary>
@@ -9072,6 +9609,26 @@
9072
9609
  <xsl:value-of select="$level"/>
9073
9610
  </xsl:otherwise>
9074
9611
  </xsl:choose>
9612
+ </xsl:template><xsl:template name="getLevelTermName">
9613
+ <xsl:choose>
9614
+ <xsl:when test="normalize-space(../@depth) != ''">
9615
+ <xsl:value-of select="../@depth"/>
9616
+ </xsl:when>
9617
+ <xsl:otherwise>
9618
+ <xsl:variable name="title_level_">
9619
+ <xsl:for-each select="../preceding-sibling::*[local-name() = 'title'][1]">
9620
+ <xsl:call-template name="getLevel"/>
9621
+ </xsl:for-each>
9622
+ </xsl:variable>
9623
+ <xsl:variable name="title_level" select="normalize-space($title_level_)"/>
9624
+ <xsl:choose>
9625
+ <xsl:when test="$title_level != ''"><xsl:value-of select="$title_level + 1"/></xsl:when>
9626
+ <xsl:otherwise>
9627
+ <xsl:call-template name="getLevel"/>
9628
+ </xsl:otherwise>
9629
+ </xsl:choose>
9630
+ </xsl:otherwise>
9631
+ </xsl:choose>
9075
9632
  </xsl:template><xsl:template name="split">
9076
9633
  <xsl:param name="pText" select="."/>
9077
9634
  <xsl:param name="sep" select="','"/>