metanorma-mpfa 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@
7
7
  <xsl:variable name="images" select="document($svg_images)"/>
8
8
  <xsl:param name="basepath"/>
9
9
 
10
- <xsl:key name="kfn" match="mpfd:p/mpfd:fn" use="@reference"/>
10
+ <xsl:key name="kfn" match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" use="@reference"/>
11
11
 
12
12
 
13
13
 
@@ -287,7 +287,7 @@
287
287
 
288
288
  <xsl:variable name="display">
289
289
  <xsl:choose>
290
- <xsl:when test="$level &gt;= 3">false</xsl:when>
290
+ <xsl:when test="$level &gt; $toc_level">false</xsl:when>
291
291
  <xsl:otherwise>true</xsl:otherwise>
292
292
  </xsl:choose>
293
293
  </xsl:variable>
@@ -458,62 +458,7 @@
458
458
 
459
459
  </xsl:template>
460
460
 
461
- <!--
462
- <fn reference="1">
463
- <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
464
- </fn>
465
- -->
466
461
 
467
- <xsl:variable name="p_fn">
468
- <xsl:for-each select="//mpfd:p/mpfd:fn[generate-id(.)=generate-id(key('kfn',@reference)[1])]">
469
- <!-- copy unique fn -->
470
- <fn gen_id="{generate-id(.)}">
471
- <xsl:copy-of select="@*"/>
472
- <xsl:copy-of select="node()"/>
473
- </fn>
474
- </xsl:for-each>
475
- </xsl:variable>
476
-
477
- <xsl:template match="mpfd:p/mpfd:fn" priority="2">
478
- <xsl:variable name="gen_id" select="generate-id(.)"/>
479
- <xsl:variable name="reference" select="@reference"/>
480
- <xsl:variable name="number">
481
- <xsl:value-of select="count(xalan:nodeset($p_fn)//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
482
- </xsl:variable>
483
- <xsl:choose>
484
- <xsl:when test="xalan:nodeset($p_fn)//fn[@gen_id = $gen_id]">
485
- <fo:footnote>
486
- <fo:inline font-size="7pt" keep-with-previous.within-line="always" vertical-align="super">
487
- <fo:basic-link internal-destination="footnote_{@reference}_{$number}" fox:alt-text="footnote {@reference} {$number}">
488
- <!-- <xsl:value-of select="@reference"/> -->
489
- <xsl:value-of select="$number + count(//mpfd:bibitem[ancestor::mpfd:references[@id='_normative_references' or not(preceding-sibling::mpfd:references)]]/mpfd:note)"/>
490
- </fo:basic-link>
491
- </fo:inline>
492
- <fo:footnote-body>
493
- <fo:block font-size="9pt" margin-bottom="12pt">
494
- <fo:inline font-size="6pt" id="footnote_{@reference}_{$number}" keep-with-next.within-line="always" vertical-align="super" padding-right="1mm">
495
- <xsl:value-of select="$number + count(//mpfd:bibitem[ancestor::mpfd:references[@id='_normative_references' or not(preceding-sibling::mpfd:references)]]/mpfd:note)"/>
496
- </fo:inline>
497
- <xsl:for-each select="mpfd:p">
498
- <xsl:apply-templates/>
499
- </xsl:for-each>
500
- </fo:block>
501
- </fo:footnote-body>
502
- </fo:footnote>
503
- </xsl:when>
504
- <xsl:otherwise>
505
- <fo:inline font-size="7pt" keep-with-previous.within-line="always" vertical-align="super">
506
- <fo:basic-link internal-destination="footnote_{@reference}_{$number}" fox:alt-text="footnote {@reference} {$number}">
507
- <xsl:value-of select="$number + count(//mpfd:bibitem/mpfd:note)"/>
508
- </fo:basic-link>
509
- </fo:inline>
510
- </xsl:otherwise>
511
- </xsl:choose>
512
- </xsl:template>
513
-
514
-
515
-
516
-
517
462
 
518
463
  <xsl:template match="mpfd:bibitem">
519
464
  <fo:block id="{@id}" margin-bottom="12pt" text-indent="-11.7mm" margin-left="11.7mm"> <!-- 12 pt -->
@@ -1317,6 +1262,78 @@
1317
1262
 
1318
1263
  </xsl:attribute-set><xsl:attribute-set name="toc-style">
1319
1264
  <xsl:attribute name="line-height">135%</xsl:attribute>
1265
+ </xsl:attribute-set><xsl:attribute-set name="fn-style">
1266
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
1267
+ </xsl:attribute-set><xsl:attribute-set name="fn-num-style">
1268
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
1269
+
1270
+
1271
+
1272
+
1273
+
1274
+
1275
+
1276
+
1277
+
1278
+
1279
+
1280
+ <xsl:attribute name="font-size">7pt</xsl:attribute>
1281
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+
1288
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-style">
1289
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
1290
+ <xsl:attribute name="font-style">normal</xsl:attribute>
1291
+ <xsl:attribute name="text-indent">0</xsl:attribute>
1292
+ <xsl:attribute name="start-indent">0</xsl:attribute>
1293
+
1294
+
1295
+
1296
+
1297
+
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+
1304
+ <xsl:attribute name="font-size">9pt</xsl:attribute>
1305
+ <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
1306
+
1307
+
1308
+
1309
+
1310
+
1311
+
1312
+
1313
+
1314
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-num-style">
1315
+ <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
1316
+
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+ <xsl:attribute name="font-size">6pt</xsl:attribute>
1328
+ <xsl:attribute name="vertical-align">super</xsl:attribute>
1329
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
1330
+
1331
+
1332
+
1333
+
1334
+
1335
+
1336
+
1320
1337
  </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">
1321
1338
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
1322
1339
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
@@ -2257,6 +2274,102 @@
2257
2274
 
2258
2275
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='name']" mode="process"/><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='p']" mode="process">
2259
2276
  <xsl:apply-templates/>
2277
+ </xsl:template><xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])]" priority="2" name="fn">
2278
+
2279
+ <!-- list of footnotes to calculate actual footnotes number -->
2280
+ <xsl:variable name="p_fn_">
2281
+ <xsl:choose>
2282
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
2283
+ <fn gen_id="{generate-id(.)}">
2284
+ <xsl:copy-of select="@*"/>
2285
+ <xsl:copy-of select="node()"/>
2286
+ </fn>
2287
+ </xsl:when>
2288
+ <xsl:otherwise>
2289
+ <!-- itetation for:
2290
+ footnotes in bibdata/title
2291
+ footnotes in bibliography
2292
+ footnotes in document's body (except table's head/body/foot and figure text)
2293
+ -->
2294
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
2295
+ <fn gen_id="{generate-id(.)}">
2296
+ <xsl:copy-of select="@*"/>
2297
+ <xsl:copy-of select="node()"/>
2298
+ </fn>
2299
+ </xsl:for-each>
2300
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
2301
+ <xsl:sort select="@displayorder" data-type="number"/>
2302
+ <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
2303
+ <!-- copy unique fn -->
2304
+ <fn gen_id="{generate-id(.)}">
2305
+ <xsl:copy-of select="@*"/>
2306
+ <xsl:copy-of select="node()"/>
2307
+ </fn>
2308
+ </xsl:for-each>
2309
+ </xsl:for-each>
2310
+ </xsl:otherwise>
2311
+ </xsl:choose>
2312
+ </xsl:variable>
2313
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
2314
+
2315
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
2316
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
2317
+ <xsl:variable name="reference" select="@reference"/>
2318
+ <!-- fn sequence number in document -->
2319
+ <xsl:variable name="current_fn_number">
2320
+ <xsl:choose>
2321
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
2322
+ <xsl:otherwise>
2323
+ <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
2324
+ </xsl:otherwise>
2325
+ </xsl:choose>
2326
+ </xsl:variable>
2327
+ <xsl:variable name="current_fn_number_text">
2328
+ <xsl:value-of select="$current_fn_number"/>
2329
+
2330
+
2331
+ </xsl:variable>
2332
+
2333
+ <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
2334
+ <xsl:variable name="footnote_inline">
2335
+ <fo:inline xsl:use-attribute-sets="fn-num-style">
2336
+
2337
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
2338
+ <xsl:value-of select="$current_fn_number_text"/>
2339
+ </fo:basic-link>
2340
+ </fo:inline>
2341
+ </xsl:variable>
2342
+ <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
2343
+ gen_id=<xsl:value-of select="$gen_id"/> -->
2344
+ <xsl:choose>
2345
+ <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
2346
+ <xsl:copy-of select="$footnote_inline"/>
2347
+ </xsl:when>
2348
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
2349
+ <fo:footnote xsl:use-attribute-sets="fn-style">
2350
+ <xsl:copy-of select="$footnote_inline"/>
2351
+ <fo:footnote-body>
2352
+
2353
+ <fo:block-container text-indent="0" start-indent="0">
2354
+
2355
+
2356
+ <fo:block xsl:use-attribute-sets="fn-body-style">
2357
+
2358
+
2359
+ <fo:inline id="{$ref_id}" xsl:use-attribute-sets="fn-body-num-style">
2360
+
2361
+ <xsl:value-of select="$current_fn_number_text"/>
2362
+ </fo:inline>
2363
+ <xsl:apply-templates/>
2364
+ </fo:block>
2365
+ </fo:block-container>
2366
+ </fo:footnote-body>
2367
+ </fo:footnote>
2368
+ </xsl:when>
2369
+ <xsl:otherwise>
2370
+ <xsl:copy-of select="$footnote_inline"/>
2371
+ </xsl:otherwise>
2372
+ </xsl:choose>
2260
2373
  </xsl:template><xsl:template name="fn_display">
2261
2374
  <xsl:variable name="references">
2262
2375
 
@@ -2447,6 +2560,8 @@
2447
2560
 
2448
2561
  </fo:basic-link>
2449
2562
  </fo:inline>
2563
+ </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
2564
+ <fo:inline><xsl:value-of select="."/></fo:inline>
2450
2565
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
2451
2566
  <fo:inline>
2452
2567
  <xsl:apply-templates/>
@@ -3437,22 +3552,6 @@
3437
3552
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
3438
3553
  <xsl:apply-templates/>
3439
3554
  </fo:inline>
3440
- </xsl:template><xsl:template match="*[local-name() = 'modification']">
3441
- <xsl:variable name="title-modified">
3442
-
3443
-
3444
- <xsl:call-template name="getTitle">
3445
- <xsl:with-param name="name" select="'title-modified'"/>
3446
- </xsl:call-template>
3447
-
3448
- </xsl:variable>
3449
-
3450
- <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
3451
- <xsl:choose>
3452
- <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>
3453
- <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>
3454
- </xsl:choose>
3455
- <xsl:apply-templates/>
3456
3555
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
3457
3556
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
3458
3557
 
@@ -4684,58 +4783,69 @@
4684
4783
  <xsl:variable name="termsource_text">
4685
4784
  <xsl:apply-templates/>
4686
4785
  </xsl:variable>
4687
-
4688
- <xsl:choose>
4786
+ <xsl:copy-of select="$termsource_text"/>
4787
+ <!-- <xsl:choose>
4689
4788
  <xsl:when test="starts-with(normalize-space($termsource_text), '[')">
4690
- <!-- <xsl:apply-templates /> -->
4691
4789
  <xsl:copy-of select="$termsource_text"/>
4692
4790
  </xsl:when>
4693
4791
  <xsl:otherwise>
4694
-
4695
-
4696
- <!-- <xsl:apply-templates /> -->
4792
+ <xsl:if test="$namespace = 'bsi'">
4793
+ <xsl:choose>
4794
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>{</xsl:text></xsl:when>
4795
+ <xsl:otherwise><xsl:text>[</xsl:text></xsl:otherwise>
4796
+ </xsl:choose>
4797
+ </xsl:if>
4798
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
4799
+ <xsl:text>[</xsl:text>
4800
+ </xsl:if>
4697
4801
  <xsl:copy-of select="$termsource_text"/>
4698
-
4699
-
4802
+ <xsl:if test="$namespace = 'bsi'">
4803
+ <xsl:choose>
4804
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>}</xsl:text></xsl:when>
4805
+ <xsl:otherwise><xsl:text>]</xsl:text></xsl:otherwise>
4806
+ </xsl:choose>
4807
+ </xsl:if>
4808
+ <xsl:if test="$namespace = 'gb' or $namespace = 'iso' or $namespace = 'iec' or $namespace = 'itu' or $namespace = 'unece' or $namespace = 'unece-rec' or $namespace = 'nist-cswp' or $namespace = 'nist-sp' or $namespace = 'ogc-white-paper' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'm3d' or $namespace = 'iho' or $namespace = 'bipm' or $namespace = 'jcgm'">
4809
+ <xsl:text>]</xsl:text>
4810
+ </xsl:if>
4700
4811
  </xsl:otherwise>
4701
- </xsl:choose>
4812
+ </xsl:choose> -->
4702
4813
  </fo:block>
4703
4814
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
4704
4815
  <xsl:if test="normalize-space() != ''">
4705
4816
  <xsl:value-of select="."/>
4706
4817
  </xsl:if>
4707
- </xsl:template><xsl:variable name="localized.source">
4708
- <xsl:call-template name="getLocalizedString">
4709
- <xsl:with-param name="key">source</xsl:with-param>
4710
- </xsl:call-template>
4711
- </xsl:variable><xsl:template match="*[local-name() = 'origin']">
4818
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/*[local-name() = 'strong'][1][following-sibling::*[1][local-name() = 'origin']]/text()">
4819
+ <fo:inline>
4820
+
4821
+
4822
+ <xsl:value-of select="."/>
4823
+ </fo:inline>
4824
+ </xsl:template><xsl:template match="*[local-name() = 'origin']">
4712
4825
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
4713
4826
  <xsl:if test="normalize-space(@citeas) = ''">
4714
4827
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
4715
4828
  </xsl:if>
4716
-
4717
-
4718
- <fo:inline>
4719
-
4720
-
4721
-
4722
-
4723
-
4724
-
4725
-
4726
- <xsl:call-template name="getTitle">
4727
- <xsl:with-param name="name" select="'title-source'"/>
4728
- </xsl:call-template>
4729
- <xsl:text>: </xsl:text>
4730
-
4731
-
4732
- </fo:inline>
4733
-
4734
4829
  <fo:inline xsl:use-attribute-sets="origin-style">
4735
4830
  <xsl:apply-templates/>
4736
4831
  </fo:inline>
4832
+ </fo:basic-link>
4833
+ </xsl:template><xsl:template match="*[local-name() = 'modification']">
4834
+ <xsl:variable name="title-modified">
4737
4835
 
4738
- </fo:basic-link>
4836
+
4837
+ <xsl:call-template name="getTitle">
4838
+ <xsl:with-param name="name" select="'title-modified'"/>
4839
+ </xsl:call-template>
4840
+
4841
+ </xsl:variable>
4842
+
4843
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
4844
+ <xsl:choose>
4845
+ <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>
4846
+ <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>
4847
+ </xsl:choose>
4848
+ <xsl:apply-templates/>
4739
4849
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
4740
4850
  <fo:inline><xsl:apply-templates/></fo:inline>
4741
4851
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
@@ -5331,7 +5441,31 @@
5331
5441
  <fo:block-container border="1pt solid black" width="50%">
5332
5442
  <fo:block> </fo:block>
5333
5443
  </fo:block-container>
5334
- </xsl:template><xsl:template match="*[local-name() = 'toc']">
5444
+ </xsl:template><xsl:variable name="toc_level">
5445
+ <xsl:choose>
5446
+ <xsl:when test="1 = 2"/> <!-- to do https://github.com/metanorma/mn-native-pdf/issues/337: if there is value in xml -->
5447
+ <xsl:otherwise><!-- default value -->
5448
+
5449
+
5450
+
5451
+
5452
+
5453
+
5454
+
5455
+
5456
+
5457
+
5458
+ 2
5459
+
5460
+
5461
+
5462
+
5463
+
5464
+
5465
+
5466
+ </xsl:otherwise>
5467
+ </xsl:choose>
5468
+ </xsl:variable><xsl:template match="*[local-name() = 'toc']">
5335
5469
  <xsl:param name="colwidths"/>
5336
5470
  <xsl:variable name="colwidths_">
5337
5471
  <xsl:choose>
@@ -5964,4 +6098,14 @@
5964
6098
  </xsl:otherwise>
5965
6099
  </xsl:choose>
5966
6100
  </xsl:if>
6101
+ </xsl:template><xsl:template name="setAltText">
6102
+ <xsl:param name="value"/>
6103
+ <xsl:attribute name="fox:alt-text">
6104
+ <xsl:choose>
6105
+ <xsl:when test="normalize-space($value) != ''">
6106
+ <xsl:value-of select="$value"/>
6107
+ </xsl:when>
6108
+ <xsl:otherwise>_</xsl:otherwise>
6109
+ </xsl:choose>
6110
+ </xsl:attribute>
5967
6111
  </xsl:template></xsl:stylesheet>