metanorma-iec 1.4.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -32
  3. data/.gitignore +14 -0
  4. data/Gemfile +6 -0
  5. data/Rakefile +1 -1
  6. data/lib/isodoc/iec/base_convert.rb +25 -59
  7. data/lib/isodoc/iec/html/htmlstyle.css +38 -6
  8. data/lib/isodoc/iec/html/htmlstyle.scss +35 -6
  9. data/lib/isodoc/iec/html/isodoc.css +1 -2
  10. data/lib/isodoc/iec/html/isodoc.scss +1 -2
  11. data/lib/isodoc/iec/html/scripts.html +0 -1
  12. data/lib/isodoc/iec/html/wordstyle.css +13 -11
  13. data/lib/isodoc/iec/html/wordstyle.scss +13 -11
  14. data/lib/isodoc/iec/html_convert.rb +2 -1
  15. data/lib/isodoc/iec/iec.international-standard.xsl +724 -330
  16. data/lib/isodoc/iec/presentation_xml_convert.rb +193 -5
  17. data/lib/isodoc/iec/xref.rb +9 -8
  18. data/lib/{asciidoctor → metanorma}/iec/basicdoc.rng +0 -0
  19. data/lib/{asciidoctor → metanorma}/iec/biblio.rng +0 -0
  20. data/lib/metanorma/iec/converter.rb +143 -0
  21. data/lib/{asciidoctor → metanorma}/iec/front.rb +3 -4
  22. data/lib/{asciidoctor → metanorma}/iec/iec.rng +48 -0
  23. data/lib/{asciidoctor → metanorma}/iec/iec_intro_en.xml +0 -0
  24. data/lib/{asciidoctor → metanorma}/iec/iec_intro_fr.xml +0 -0
  25. data/lib/{asciidoctor → metanorma}/iec/isodoc.rng +90 -18
  26. data/lib/{asciidoctor → metanorma}/iec/isostandard.rng +14 -0
  27. data/lib/metanorma/iec/processor.rb +15 -8
  28. data/lib/{asciidoctor → metanorma}/iec/reqt.rng +0 -0
  29. data/lib/metanorma/iec/version.rb +1 -1
  30. data/lib/metanorma-iec.rb +1 -1
  31. data/metanorma-iec.gemspec +3 -3
  32. data/spec/isodoc/iev_spec.rb +462 -120
  33. data/spec/isodoc/postproc_spec.rb +2 -5
  34. data/spec/isodoc/ref_spec.rb +359 -353
  35. data/spec/isodoc/terms_spec.rb +183 -181
  36. data/spec/{asciidoctor → metanorma}/base_spec.rb +1 -5
  37. data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
  38. data/spec/metanorma/cleanup_spec.rb +374 -0
  39. data/spec/metanorma/iev_spec.rb +248 -0
  40. data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
  41. data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
  42. data/spec/metanorma/processor_spec.rb +139 -44
  43. data/spec/{asciidoctor → metanorma}/section_spec.rb +1 -1
  44. data/spec/{asciidoctor → metanorma}/validate_spec.rb +1 -1
  45. data/spec/spec_helper.rb +12 -14
  46. metadata +26 -26
  47. data/lib/asciidoctor/iec/converter.rb +0 -105
  48. data/spec/asciidoctor/cleanup_spec.rb +0 -345
  49. data/spec/asciidoctor/iev_spec.rb +0 -243
@@ -7,6 +7,8 @@
7
7
  <xsl:variable name="images" select="document($svg_images)"/>
8
8
  <xsl:param name="basepath"/>
9
9
 
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
+
10
12
 
11
13
 
12
14
  <xsl:param name="additionalXMLs" select="''"/> <!-- iec-rice.fr.xml -->
@@ -137,6 +139,7 @@
137
139
  <contents>
138
140
  <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
139
141
  <xsl:call-template name="processMainSectionsDefault_Contents"/>
142
+ <xsl:apply-templates select="//iec:indexsect" mode="contents"/>
140
143
  <xsl:for-each select="//*[local-name() = 'figure'][@id and *[local-name() = 'name']]">
141
144
  <figure id="{@id}">
142
145
  <title><xsl:value-of select="*[local-name() = 'name']/text()"/></title>
@@ -157,6 +160,8 @@
157
160
  <xsl:call-template name="getLang"/>
158
161
  </xsl:variable>
159
162
 
163
+ <xsl:variable name="isIEV" select="normalize-space((//iec:iec-standard/iec:bibdata/iec:title[@language = 'en' and @type = 'title-main'] = 'International Electrotechnical Vocabulary') and 1 = 1)"/>
164
+
160
165
  <xsl:template match="/">
161
166
  <xsl:call-template name="namespaceCheck"/>
162
167
  <!-- https://stackoverflow.com/questions/25261949/xsl-fo-letter-spacing-with-text-align -->
@@ -497,24 +502,34 @@
497
502
  <fo:block font-size="9pt" color="{$color_blue}" line-height="150%">
498
503
  <fo:block-container width="40mm">
499
504
  <fo:block>
500
- <!-- <xsl:variable name="publisher" select="java:toUpperCase(java:java.lang.String.new(/iec:iec-standard/iec:bibdata/iec:contributor[iec:role/@type = 'publisher']/iec:organization/iec:name))"/> -->
501
- <!-- <xsl:value-of select="$publisher"/> -->
502
- <xsl:value-of select="(//iec:iec-standard)[1]/iec:localized-strings/iec:localized-string[@key='IEC' and @language=$lang]"/>
505
+ <xsl:call-template name="getLocalizedString">
506
+ <xsl:with-param name="key">IEC</xsl:with-param>
507
+ <xsl:with-param name="lang"><xsl:value-of select="$lang"/></xsl:with-param>
508
+ </xsl:call-template>
503
509
  </fo:block>
504
510
  </fo:block-container>
505
511
  </fo:block>
506
- <xsl:if test="(//iec:iec-standard)[2]/iec:localized-strings/iec:localized-string[@key='IEC' and @language=$lang_second]">
512
+
513
+ <xsl:variable name="IEC_lang_second">
514
+ <xsl:call-template name="getLocalizedString">
515
+ <xsl:with-param name="key">IEC</xsl:with-param>
516
+ <xsl:with-param name="lang"><xsl:value-of select="$lang_second"/></xsl:with-param>
517
+ </xsl:call-template>
518
+ </xsl:variable>
519
+
520
+ <xsl:if test="normalize-space($IEC_lang_second) != ''">
507
521
  <fo:block font-size="9pt" line-height="150%" margin-top="8pt">
508
522
  <fo:block-container width="40mm">
509
523
  <fo:block>
510
524
  <!-- <xsl:value-of select="'COMMISSION ELECTROTECHNIQUE INTERNATIONALE'"/> -->
511
- <xsl:value-of select="(//iec:iec-standard)[2]/iec:localized-strings/iec:localized-string[@key='IEC' and @language=$lang_second]"/>
525
+ <xsl:value-of select="$IEC_lang_second"/>
512
526
  </fo:block>
513
527
  </fo:block-container>
514
528
  </fo:block>
515
529
  </xsl:if>
516
530
  </fo:block-container>
517
531
 
532
+ <xsl:variable name="price_code_value" select="//iec:iec-standard/iec:bibdata/iec:ext/iec:price-code"/>
518
533
  <fo:table table-layout="fixed" width="102%" margin-top="-9mm" margin-bottom="2mm">
519
534
  <fo:table-column column-width="148mm"/>
520
535
  <fo:table-column column-width="16mm"/>
@@ -522,29 +537,34 @@
522
537
  <fo:table-row border-bottom="0.5pt solid {$color_gray}" height="16mm">
523
538
  <fo:table-cell font-size="8pt" text-align="right" display-align="center">
524
539
  <fo:block>
525
- <fo:block color="{$color_blue}" margin-bottom="3pt">
526
- <!-- PRICE CODE -->
527
- <xsl:variable name="price_code">
528
- <!-- <xsl:call-template name="getLocalizedString">
529
- <xsl:with-param name="key">price-code</xsl:with-param>
530
- </xsl:call-template> -->
531
- <xsl:value-of select="(//iec:iec-standard)[1]/iec:localized-strings/iec:localized-string[@key='price-code' and @language=$lang]"/>
532
- </xsl:variable>
533
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new($price_code))"/>
534
- </fo:block>
535
- <!-- <xsl:if test="$lang != 'fr'">
536
- <fo:block>CODE PRIX</fo:block>
537
- </xsl:if> -->
538
- <fo:block>
539
- <xsl:variable name="price_code">
540
- <xsl:value-of select="(//iec:iec-standard)[2]/iec:localized-strings/iec:localized-string[@key='price-code' and @language=$lang_second]"/>
541
- </xsl:variable>
542
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new($price_code))"/>
543
- </fo:block>
540
+ <xsl:if test="normalize-space($price_code_value) != ''">
541
+ <fo:block color="{$color_blue}" margin-bottom="3pt">
542
+ <!-- PRICE CODE -->
543
+ <xsl:variable name="price_code">
544
+ <xsl:call-template name="getLocalizedString">
545
+ <xsl:with-param name="key">price-code</xsl:with-param>
546
+ <xsl:with-param name="lang"><xsl:value-of select="$lang"/></xsl:with-param>
547
+ </xsl:call-template>
548
+ </xsl:variable>
549
+ <xsl:value-of select="java:toUpperCase(java:java.lang.String.new($price_code))"/>
550
+ </fo:block>
551
+ <!-- <xsl:if test="$lang != 'fr'">
552
+ <fo:block>CODE PRIX</fo:block>
553
+ </xsl:if> -->
554
+ <fo:block>
555
+ <xsl:variable name="price_code">
556
+ <xsl:call-template name="getLocalizedString">
557
+ <xsl:with-param name="key">price-code</xsl:with-param>
558
+ <xsl:with-param name="lang"><xsl:value-of select="$lang_second"/></xsl:with-param>
559
+ </xsl:call-template>
560
+ </xsl:variable>
561
+ <xsl:value-of select="java:toUpperCase(java:java.lang.String.new($price_code))"/>
562
+ </fo:block>
563
+ </xsl:if>
544
564
  </fo:block>
545
565
  </fo:table-cell>
546
566
  <fo:table-cell font-size="25pt" font-weight="bold" color="{$color_gray}" text-align="right" display-align="center">
547
- <fo:block padding-top="1mm"><xsl:value-of select="//iec:iec-standard/iec:bibdata/iec:ext/iec:price-code"/></fo:block>
567
+ <fo:block padding-top="1mm"><xsl:value-of select="$price_code_value"/></fo:block>
548
568
  </fo:table-cell>
549
569
  </fo:table-row>
550
570
  </fo:table-body>
@@ -1088,6 +1108,9 @@
1088
1108
  <xsl:if test="$num = '1'">
1089
1109
  <xsl:attribute name="initial-page-number">2</xsl:attribute>
1090
1110
  </xsl:if>
1111
+ <xsl:if test="$isIEV = 'true'">
1112
+ <xsl:attribute name="format">I</xsl:attribute>
1113
+ </xsl:if>
1091
1114
 
1092
1115
  <xsl:call-template name="insertHeaderFooter"/>
1093
1116
  <fo:flow flow-name="xsl-region-body">
@@ -1370,7 +1393,13 @@
1370
1393
  <xsl:text> — </xsl:text>
1371
1394
  <xsl:value-of select="$linebreak"/>
1372
1395
  <xsl:if test="$part != ''">
1373
- <xsl:variable name="localized_part" select="(//iec:iec-standard)[1]/iec:localized-strings/iec:localized-string[@key='locality.part' and @language=$lang]"/>
1396
+ <xsl:variable name="localized_part">
1397
+ <xsl:call-template name="getLocalizedString">
1398
+ <xsl:with-param name="key">locality.part</xsl:with-param>
1399
+ <xsl:with-param name="lang"><xsl:value-of select="$lang"/></xsl:with-param>
1400
+ </xsl:call-template>
1401
+ </xsl:variable>
1402
+
1374
1403
  <!-- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($localized_part),'#',$part)"/> -->
1375
1404
  <xsl:value-of select="concat($localized_part ,' ',$part, ': ')"/>
1376
1405
  <!-- <xsl:text>Part </xsl:text><xsl:value-of select="$part"/>
@@ -1396,10 +1425,17 @@
1396
1425
  <xsl:value-of select="$linebreak"/>
1397
1426
  <xsl:if test="$part != ''">
1398
1427
 
1428
+ <xsl:variable name="locality_part_lang_second">
1429
+ <xsl:call-template name="getLocalizedString">
1430
+ <xsl:with-param name="key">locality.part</xsl:with-param>
1431
+ <xsl:with-param name="lang"><xsl:value-of select="$lang_second"/></xsl:with-param>
1432
+ </xsl:call-template>
1433
+ </xsl:variable>
1434
+
1399
1435
  <xsl:choose>
1400
- <xsl:when test="(//iec:iec-standard)[2]/iec:localized-strings/iec:localized-string[@key='locality.part' and @language=$lang_second]">
1436
+ <xsl:when test="normalize-space($locality_part_lang_second)">
1401
1437
  <xsl:variable name="localized_part">
1402
- <xsl:value-of select="(//iec:iec-standard)[2]/iec:localized-strings/iec:localized-string[@key='locality.part' and @language=$lang_second]"/>
1438
+ <xsl:value-of select="$locality_part_lang_second"/>
1403
1439
  </xsl:variable>
1404
1440
  <xsl:value-of select="concat($localized_part ,' ',$part, ': ')"/>
1405
1441
  </xsl:when>
@@ -1426,8 +1462,8 @@
1426
1462
  <fo:block role="TOC">
1427
1463
  <fo:block font-size="12pt" text-align="center" margin-bottom="22pt" role="H1">
1428
1464
  <xsl:variable name="title-toc">
1429
- <xsl:call-template name="getTitle">
1430
- <xsl:with-param name="name" select="'title-toc'"/>
1465
+ <xsl:call-template name="getLocalizedString">
1466
+ <xsl:with-param name="key">table_of_contents</xsl:with-param>
1431
1467
  </xsl:call-template>
1432
1468
  </xsl:variable>
1433
1469
  <xsl:call-template name="addLetterSpacing">
@@ -1445,9 +1481,15 @@
1445
1481
  <xsl:if test="@level = 2">
1446
1482
  <xsl:attribute name="margin-bottom">3pt</xsl:attribute>
1447
1483
  </xsl:if>
1448
- <xsl:if test="@level = 3">
1484
+ <xsl:if test="@level &gt;= 3">
1449
1485
  <xsl:attribute name="margin-bottom">2pt</xsl:attribute>
1450
1486
  </xsl:if>
1487
+ <xsl:if test="@type = 'indexsect'">
1488
+ <xsl:attribute name="space-before">16pt</xsl:attribute>
1489
+ </xsl:if>
1490
+ <xsl:if test="@type = 'references'">
1491
+ <xsl:attribute name="space-before">5pt</xsl:attribute>
1492
+ </xsl:if>
1451
1493
  <!-- <xsl:if test="@level &gt;= 2 and @section != ''">
1452
1494
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
1453
1495
  </xsl:if> -->
@@ -1457,8 +1499,9 @@
1457
1499
  <fo:list-block>
1458
1500
  <xsl:attribute name="margin-left">
1459
1501
  <xsl:choose>
1502
+ <xsl:when test="title/@variant-title = 'true'">0mm</xsl:when>
1460
1503
  <xsl:when test="@level = 2">8mm</xsl:when>
1461
- <xsl:when test="@level = 3">23mm</xsl:when>
1504
+ <xsl:when test="@level &gt;= 3"><xsl:value-of select="(@level - 2) * 23"/>mm</xsl:when>
1462
1505
  <xsl:otherwise>0mm</xsl:otherwise>
1463
1506
  </xsl:choose>
1464
1507
  </xsl:attribute>
@@ -1467,7 +1510,7 @@
1467
1510
  <xsl:when test="@section = ''">0mm</xsl:when>
1468
1511
  <xsl:when test="@level = 1">8mm</xsl:when>
1469
1512
  <xsl:when test="@level = 2">15mm</xsl:when>
1470
- <xsl:when test="@level = 3">19mm</xsl:when>
1513
+ <xsl:when test="@level &gt;= 3"><xsl:value-of select="(@level - 2) * 19"/>mm</xsl:when>
1471
1514
  <xsl:otherwise>0mm</xsl:otherwise>
1472
1515
  </xsl:choose>
1473
1516
  </xsl:attribute>
@@ -1536,8 +1579,12 @@
1536
1579
  <xsl:param name="lang" select="$lang"/>
1537
1580
  <fo:block break-after="page"/>
1538
1581
  <fo:block-container font-size="12pt" text-align="center" margin-bottom="18pt">
1539
- <!-- <fo:block><xsl:value-of select="java:toUpperCase(java:java.lang.String.new(/iec:iec-standard/iec:bibdata/iec:contributor/iec:organization/iec:name))"/></fo:block> -->
1540
- <fo:block><xsl:value-of select="/iec:iec-standard/iec:localized-strings/iec:localized-string[@key='IEC' and @language=$lang]"/></fo:block>
1582
+ <fo:block>
1583
+ <xsl:call-template name="getLocalizedString">
1584
+ <xsl:with-param name="key">IEC</xsl:with-param>
1585
+ <xsl:with-param name="lang"><xsl:value-of select="$lang"/></xsl:with-param>
1586
+ </xsl:call-template>
1587
+ </fo:block>
1541
1588
  <fo:block>___________</fo:block>
1542
1589
  <fo:block> </fo:block>
1543
1590
  <fo:block font-weight="bold" role="H1">
@@ -1552,9 +1599,13 @@
1552
1599
  <fo:block>
1553
1600
  <xsl:if test="$part != ''">
1554
1601
  <!-- Example: Part 1: Riz -->
1555
- <!-- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-part[@lang = $lang]),'#',$part)"/> -->
1556
- <xsl:variable name="localized_part" select="//iec:iec-standard/iec:localized-strings/iec:localized-string[@key='locality.part' and @language = $lang]"/>
1557
- <xsl:value-of select="concat($localized_part ,' ',$part, ': ')"/>
1602
+ <xsl:variable name="localized_part">
1603
+ <xsl:call-template name="getLocalizedString">
1604
+ <xsl:with-param name="key">Part.sg</xsl:with-param>
1605
+ <xsl:with-param name="lang" select="$lang"/>
1606
+ </xsl:call-template>
1607
+ </xsl:variable>
1608
+ <xsl:value-of select="concat($localized_part ,' ', $part, ': ')"/>
1558
1609
  </xsl:if>
1559
1610
  <xsl:value-of select="$title-part"/>
1560
1611
  </fo:block>
@@ -1570,7 +1621,10 @@
1570
1621
  <xsl:template name="insertBodypages">
1571
1622
  <xsl:param name="lang" select="'en'"/>
1572
1623
  <!-- BODY -->
1573
- <fo:page-sequence master-reference="document" force-page-count="no-force">
1624
+ <fo:page-sequence master-reference="document" force-page-count="no-force">
1625
+ <xsl:if test="$isIEV = 'true'">
1626
+ <xsl:attribute name="initial-page-number">1</xsl:attribute>
1627
+ </xsl:if>
1574
1628
  <fo:static-content flow-name="xsl-footnote-separator">
1575
1629
  <fo:block>
1576
1630
  <fo:leader leader-pattern="rule" leader-length="30%"/>
@@ -1594,8 +1648,12 @@
1594
1648
  <fo:block>
1595
1649
  <xsl:if test="$part != ''">
1596
1650
  <!-- Example: Part 1: Rice -->
1597
- <!-- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-part[@lang = $lang]),'#',$part)"/> -->
1598
- <xsl:variable name="localized_part" select="//iec:iec-standard/iec:localized-strings/iec:localized-string[@key='locality.part' and @language = $lang]"/>
1651
+ <xsl:variable name="localized_part">
1652
+ <xsl:call-template name="getLocalizedString">
1653
+ <xsl:with-param name="key">Part.sg</xsl:with-param>
1654
+ <xsl:with-param name="lang" select="$lang"/>
1655
+ </xsl:call-template>
1656
+ </xsl:variable>
1599
1657
  <xsl:value-of select="concat($localized_part ,' ',$part, ': ')"/>
1600
1658
  </xsl:if>
1601
1659
  <xsl:value-of select="$title-part"/>
@@ -1612,6 +1670,10 @@
1612
1670
 
1613
1671
  </fo:flow>
1614
1672
  </fo:page-sequence>
1673
+
1674
+ <!-- Index -->
1675
+ <xsl:apply-templates select="//iec:indexsect" mode="index"/>
1676
+
1615
1677
  </xsl:template>
1616
1678
 
1617
1679
 
@@ -1712,7 +1774,7 @@
1712
1774
 
1713
1775
  <xsl:variable name="display">
1714
1776
  <xsl:choose>
1715
- <xsl:when test="$level &gt; 3">false</xsl:when>
1777
+ <xsl:when test="$level &gt; $toc_level">false</xsl:when>
1716
1778
  <xsl:when test="$section = '' and $type = 'clause'">false</xsl:when><!-- don't show clause with number only in title -->
1717
1779
  <xsl:otherwise>true</xsl:otherwise>
1718
1780
  </xsl:choose>
@@ -1733,13 +1795,27 @@
1733
1795
  <xsl:call-template name="getName"/>
1734
1796
  </xsl:variable>
1735
1797
 
1798
+ <xsl:variable name="variant_title">
1799
+ <xsl:copy-of select="iec:variant-title/node()"/>
1800
+ </xsl:variable>
1801
+
1736
1802
  <item id="{@id}" level="{$level}" section="{$section}" type="{$type}" display="{$display}">
1737
1803
  <xsl:if test="$type ='appendix'">
1738
1804
  <xsl:attribute name="section"/>
1739
1805
  </xsl:if>
1806
+ <xsl:if test="$type ='indexsect'">
1807
+ <xsl:attribute name="level">1</xsl:attribute>
1808
+ </xsl:if>
1740
1809
  <title>
1741
1810
  <xsl:choose>
1742
- <xsl:when test="$type = 'foreword' or $type = 'introduction'">
1811
+ <!-- <xsl:when test="$type = 'foreword' or $type = 'introduction'">
1812
+ <xsl:value-of select="java:toUpperCase(java:java.lang.String.new($title))"/>
1813
+ </xsl:when> -->
1814
+ <xsl:when test="normalize-space($variant_title) != ''">
1815
+ <xsl:attribute name="variant-title">true</xsl:attribute>
1816
+ <xsl:apply-templates select="xalan:nodeset($variant_title)" mode="contents_item"/>
1817
+ </xsl:when>
1818
+ <xsl:when test="$type = 'indexsect'">
1743
1819
  <xsl:value-of select="java:toUpperCase(java:java.lang.String.new($title))"/>
1744
1820
  </xsl:when>
1745
1821
  <xsl:when test="$type = 'appendix'">
@@ -1750,7 +1826,9 @@
1750
1826
  </xsl:otherwise>
1751
1827
  </xsl:choose>
1752
1828
  </title>
1753
- <xsl:apply-templates mode="contents"/>
1829
+ <xsl:if test="$type != 'indexsect'">
1830
+ <xsl:apply-templates mode="contents"/>
1831
+ </xsl:if>
1754
1832
  </item>
1755
1833
 
1756
1834
  </xsl:if>
@@ -1850,7 +1928,8 @@
1850
1928
  <xsl:template match="iec:iec-standard/iec:preface/iec:foreword" priority="3">
1851
1929
  <fo:block id="{@id}" margin-bottom="12pt" font-size="12pt" text-align="center">
1852
1930
  <xsl:call-template name="addLetterSpacing">
1853
- <xsl:with-param name="text" select="java:toUpperCase(java:java.lang.String.new(iec:title))"/>
1931
+ <!-- <xsl:with-param name="text" select="java:toUpperCase(java:java.lang.String.new(iec:title))"/> -->
1932
+ <xsl:with-param name="text" select="iec:title"/>
1854
1933
  </xsl:call-template>
1855
1934
  </fo:block>
1856
1935
  <fo:block font-size="8.2pt" text-align="justify"> <!-- margin-left="6.3mm" -->
@@ -1910,7 +1989,8 @@
1910
1989
  </xsl:template>
1911
1990
  <xsl:template match="iec:introduction/iec:title/text()">
1912
1991
  <xsl:call-template name="addLetterSpacing">
1913
- <xsl:with-param name="text" select="java:toUpperCase(java:java.lang.String.new(.))"/>
1992
+ <!-- <xsl:with-param name="text" select="java:toUpperCase(java:java.lang.String.new(.))"/> -->
1993
+ <xsl:with-param name="text" select="."/>
1914
1994
  </xsl:call-template>
1915
1995
  </xsl:template>
1916
1996
 
@@ -1934,7 +2014,7 @@
1934
2014
  </xsl:template>
1935
2015
 
1936
2016
 
1937
- <xsl:template match="iec:title">
2017
+ <xsl:template match="iec:title" name="title">
1938
2018
 
1939
2019
  <xsl:variable name="level">
1940
2020
  <xsl:call-template name="getLevel"/>
@@ -2030,6 +2110,7 @@
2030
2110
  <!-- <xsl:if test="ancestor::iec:dl and ancestor::iec:figure">
2031
2111
  <xsl:attribute name="margin-bottom">10pt</xsl:attribute>
2032
2112
  </xsl:if> -->
2113
+ <xsl:apply-templates select="@language"/>
2033
2114
  <xsl:apply-templates/>
2034
2115
  </xsl:element>
2035
2116
  </xsl:when>
@@ -2052,37 +2133,6 @@
2052
2133
  </xsl:if> -->
2053
2134
  </xsl:template>
2054
2135
 
2055
- <!--
2056
- <fn reference="1">
2057
- <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
2058
- </fn>
2059
- -->
2060
- <xsl:template match="iec:p/iec:fn" priority="2">
2061
- <fo:footnote>
2062
- <xsl:variable name="number">
2063
- <xsl:number level="any" count="iec:p/iec:fn"/>
2064
- </xsl:variable>
2065
- <xsl:variable name="lang">
2066
- <xsl:call-template name="getLang"/>
2067
- </xsl:variable>
2068
- <fo:inline font-size="8pt" keep-with-previous.within-line="always" baseline-shift="15%"> <!-- font-size="80%" vertical-align="super"-->
2069
- <fo:basic-link internal-destination="{$lang}_footnote_{@reference}" fox:alt-text="footnote {@reference}">
2070
- <!-- <xsl:value-of select="@reference"/> -->
2071
- <xsl:value-of select="$number + count(//iec:bibitem/iec:note)"/><!-- <xsl:text>)</xsl:text> -->
2072
- </fo:basic-link>
2073
- </fo:inline>
2074
- <fo:footnote-body>
2075
- <fo:block font-size="8pt" margin-bottom="5pt">
2076
- <fo:inline id="{$lang}_footnote_{@reference}" keep-with-next.within-line="always" baseline-shift="15%" padding-right="3mm"> <!-- padding-right="3mm" font-size="60%" alignment-baseline="hanging" -->
2077
- <xsl:value-of select="$number + count(//iec:bibitem/iec:note)"/><!-- <xsl:text>)</xsl:text> -->
2078
- </fo:inline>
2079
- <!-- <xsl:for-each select="iec:p"> -->
2080
- <xsl:apply-templates/>
2081
- <!-- </xsl:for-each> -->
2082
- </fo:block>
2083
- </fo:footnote-body>
2084
- </fo:footnote>
2085
- </xsl:template>
2086
2136
 
2087
2137
  <xsl:template match="iec:p/iec:fn/iec:p">
2088
2138
  <xsl:apply-templates/>
@@ -2101,25 +2151,7 @@
2101
2151
 
2102
2152
  <xsl:template match="iec:bibitem">
2103
2153
  <fo:block id="{@id}" margin-top="5pt" margin-bottom="10pt"> <!-- letter-spacing="0.4pt" -->
2104
- <!-- iec:docidentifier -->
2105
- <xsl:if test="iec:docidentifier">
2106
- <xsl:choose>
2107
- <xsl:when test="iec:docidentifier/@type = 'metanorma'"/>
2108
- <xsl:otherwise><fo:inline><xsl:value-of select="iec:docidentifier"/></fo:inline></xsl:otherwise>
2109
- </xsl:choose>
2110
- </xsl:if>
2111
- <xsl:apply-templates select="iec:note"/>
2112
- <xsl:if test="iec:docidentifier">, </xsl:if>
2113
- <fo:inline font-style="italic">
2114
- <xsl:choose>
2115
- <xsl:when test="iec:title[@type = 'main' and @language = 'en']">
2116
- <xsl:value-of select="iec:title[@type = 'main' and @language = 'en']"/>
2117
- </xsl:when>
2118
- <xsl:otherwise>
2119
- <xsl:value-of select="iec:title"/>
2120
- </xsl:otherwise>
2121
- </xsl:choose>
2122
- </fo:inline>
2154
+ <xsl:call-template name="processBibitem"/>
2123
2155
  </fo:block>
2124
2156
  </xsl:template>
2125
2157
 
@@ -2165,12 +2197,11 @@
2165
2197
  <xsl:template match="iec:li">
2166
2198
  <fo:list-item>
2167
2199
  <fo:list-item-label end-indent="label-end()">
2168
- <xsl:if test="local-name(..) = 'ul'">
2169
- <xsl:attribute name="font-size">10pt</xsl:attribute>
2170
- </xsl:if>
2171
2200
  <fo:block>
2172
2201
  <xsl:choose>
2173
- <xsl:when test="local-name(..) = 'ul'">•</xsl:when> <!-- &#x2014; dash -->
2202
+ <xsl:when test="local-name(..) = 'ul'">
2203
+ <xsl:call-template name="setULLabel"/>
2204
+ </xsl:when>
2174
2205
  <xsl:otherwise> <!-- for ordered lists -->
2175
2206
  <xsl:choose>
2176
2207
  <xsl:when test="../@type = 'arabic'">
@@ -2222,10 +2253,16 @@
2222
2253
  <xsl:call-template name="getLevelTermName"/>
2223
2254
  </xsl:variable>
2224
2255
  <fo:block line-height="1.1" space-before="14pt" role="H{$levelTerm}">
2256
+ <xsl:if test="preceding-sibling::*[1][self::iec:preferred]">
2257
+ <xsl:attribute name="space-before">1pt</xsl:attribute>
2258
+ </xsl:if>
2259
+ <xsl:if test="parent::iec:term and not(preceding-sibling::iec:preferred)"> <!-- if first preffered in term, then display term's name -->
2260
+ <fo:block font-weight="bold" keep-with-next="always">
2261
+ <xsl:apply-templates select="ancestor::iec:term[1]/iec:name" mode="presentation"/>
2262
+ </fo:block>
2263
+ </xsl:if>
2225
2264
  <fo:block font-weight="bold" keep-with-next="always">
2226
- <xsl:apply-templates select="ancestor::iec:term[1]/iec:name" mode="presentation"/>
2227
- </fo:block>
2228
- <fo:block font-weight="bold" keep-with-next="always">
2265
+ <xsl:call-template name="setStyle_preferred"/>
2229
2266
  <xsl:apply-templates/>
2230
2267
  </fo:block>
2231
2268
  </fo:block>
@@ -2249,35 +2286,22 @@
2249
2286
  <fo:list-item>
2250
2287
  <fo:list-item-label end-indent="label-end()">
2251
2288
  <fo:block id="{@id}">
2252
- <xsl:number format="[1]"/>
2289
+ <xsl:value-of select="iec:docidentifier[@type = 'metanorma-ordinal']"/>
2290
+ <xsl:if test="not(iec:docidentifier[@type = 'metanorma-ordinal'])">
2291
+ <xsl:number format="[1]"/>
2292
+ </xsl:if>
2253
2293
  </fo:block>
2254
2294
  </fo:list-item-label>
2255
2295
  <fo:list-item-body start-indent="body-start()">
2256
2296
  <fo:block>
2257
- <xsl:if test="iec:docidentifier">
2258
- <xsl:choose>
2259
- <xsl:when test="iec:docidentifier/@type = 'metanorma'"/>
2260
- <xsl:otherwise><fo:inline><xsl:value-of select="iec:docidentifier"/>, </fo:inline></xsl:otherwise>
2261
- </xsl:choose>
2262
- </xsl:if>
2263
- <xsl:choose>
2264
- <xsl:when test="iec:title[@type = 'main' and @language = 'en']">
2265
- <xsl:apply-templates select="iec:title[@type = 'main' and @language = 'en']"/>
2266
- </xsl:when>
2267
- <xsl:otherwise>
2268
- <xsl:apply-templates select="iec:title"/>
2269
- </xsl:otherwise>
2270
- </xsl:choose>
2271
- <xsl:apply-templates select="iec:formattedref"/>
2297
+ <xsl:call-template name="processBibitem"/>
2272
2298
  </fo:block>
2273
2299
  </fo:list-item-body>
2274
2300
  </fo:list-item>
2275
2301
  </fo:list-block>
2276
2302
  </xsl:template>
2277
2303
 
2278
- <xsl:template match="iec:references[not(@normative='true')]/iec:bibitem" mode="contents"/>
2279
-
2280
- <xsl:template match="iec:references[not(@normative='true')]/iec:bibitem/iec:title">
2304
+ <xsl:template match="iec:references/iec:bibitem/iec:title">
2281
2305
  <fo:inline font-style="italic">
2282
2306
  <xsl:apply-templates/>
2283
2307
  </fo:inline>
@@ -2335,7 +2359,63 @@
2335
2359
  </fo:block>
2336
2360
  </xsl:template>
2337
2361
 
2362
+ <!-- =================== -->
2363
+ <!-- Index processing -->
2364
+ <!-- =================== -->
2365
+
2366
+ <xsl:template match="iec:indexsect"/>
2367
+ <xsl:template match="iec:indexsect" mode="index">
2368
+
2369
+ <fo:page-sequence master-reference="document" force-page-count="no-force">
2370
+ <xsl:call-template name="insertHeaderFooter"/>
2371
+ <fo:flow flow-name="xsl-region-body">
2372
+ <fo:block id="{@id}" span="all">
2373
+ <xsl:apply-templates select="iec:title"/>
2374
+ </fo:block>
2375
+ <fo:block role="Index">
2376
+ <xsl:apply-templates select="*[not(local-name() = 'title')]"/>
2377
+ </fo:block>
2378
+ </fo:flow>
2379
+ </fo:page-sequence>
2380
+ </xsl:template>
2381
+
2382
+ <xsl:template match="iec:indexsect/iec:title" priority="4">
2383
+ <fo:block font-size="12pt" font-weight="bold" margin-bottom="84pt" role="H1">
2384
+ <!-- Index -->
2385
+ <xsl:apply-templates/>
2386
+ </fo:block>
2387
+ </xsl:template>
2388
+
2389
+ <xsl:template match="iec:indexsect/iec:title/text()" priority="4">
2390
+ <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
2391
+ </xsl:template>
2338
2392
 
2393
+ <xsl:template match="iec:indexsect/iec:clause/iec:title" priority="4">
2394
+ <!-- Letter A, B, C, ... -->
2395
+ <fo:block font-size="10pt" font-weight="bold" margin-bottom="3pt" keep-with-next="always">
2396
+ <xsl:apply-templates/>
2397
+ </fo:block>
2398
+ </xsl:template>
2399
+
2400
+ <xsl:template match="iec:indexsect//iec:li/text()">
2401
+ <!-- to split by '_' and other chars -->
2402
+ <xsl:call-template name="add-zero-spaces-java"/>
2403
+ </xsl:template>
2404
+
2405
+ <xsl:template match="iec:xref[@pagenumber = 'true']" priority="2">
2406
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
2407
+ <fo:inline>
2408
+ <xsl:if test="@id">
2409
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
2410
+ </xsl:if>
2411
+ <fo:page-number-citation ref-id="{@target}"/>
2412
+ </fo:inline>
2413
+ </fo:basic-link>
2414
+ </xsl:template>
2415
+
2416
+ <!-- =================== -->
2417
+ <!-- End of Index processing -->
2418
+ <!-- =================== -->
2339
2419
 
2340
2420
  <xsl:template name="insertHeaderFooter">
2341
2421
  <fo:static-content flow-name="header-even" role="artifact">
@@ -2501,13 +2581,6 @@
2501
2581
 
2502
2582
  <xsl:variable name="titles" select="xalan:nodeset($titles_)"/><xsl:variable name="titles_">
2503
2583
 
2504
- <title-annex lang="en">Annex </title-annex>
2505
- <title-annex lang="fr">Annexe </title-annex>
2506
-
2507
- <title-annex lang="zh">Annex </title-annex>
2508
-
2509
-
2510
-
2511
2584
  <title-edition lang="en">
2512
2585
 
2513
2586
  <xsl:text>Edition </xsl:text>
@@ -2521,33 +2594,18 @@
2521
2594
 
2522
2595
  </title-edition>
2523
2596
 
2524
-
2597
+
2598
+ <!-- These titles of Table of contents renders different than determined in localized-strings -->
2525
2599
  <title-toc lang="en">
2526
2600
 
2527
- <xsl:text>Contents</xsl:text>
2528
-
2529
2601
 
2530
2602
 
2531
2603
  </title-toc>
2532
2604
  <title-toc lang="fr">
2533
2605
 
2534
- <xsl:text>Sommaire</xsl:text>
2535
-
2536
-
2537
- </title-toc>
2538
-
2539
- <title-toc lang="zh">Contents</title-toc>
2540
-
2541
-
2606
+ </title-toc>
2542
2607
 
2543
- <title-page lang="en">Page</title-page>
2544
- <title-page lang="fr">Page</title-page>
2545
2608
 
2546
- <title-key lang="en">Key</title-key>
2547
- <title-key lang="fr">Légende</title-key>
2548
-
2549
- <title-where lang="en">where</title-where>
2550
- <title-where lang="fr">où</title-where>
2551
2609
 
2552
2610
  <title-descriptors lang="en">Descriptors</title-descriptors>
2553
2611
 
@@ -2574,25 +2632,6 @@
2574
2632
 
2575
2633
  </title-subpart>
2576
2634
 
2577
- <title-modified lang="en">modified</title-modified>
2578
- <title-modified lang="fr">modifiée</title-modified>
2579
-
2580
- <title-modified lang="zh">modified</title-modified>
2581
-
2582
-
2583
-
2584
- <title-source lang="en">
2585
-
2586
- <xsl:text>SOURCE</xsl:text>
2587
-
2588
-
2589
- </title-source>
2590
-
2591
- <title-keywords lang="en">Keywords</title-keywords>
2592
-
2593
- <title-deprecated lang="en">DEPRECATED</title-deprecated>
2594
- <title-deprecated lang="fr">DEPRECATED</title-deprecated>
2595
-
2596
2635
  <title-list-tables lang="en">List of Tables</title-list-tables>
2597
2636
 
2598
2637
  <title-list-figures lang="en">List of Figures</title-list-figures>
@@ -2601,37 +2640,8 @@
2601
2640
 
2602
2641
  <title-list-recommendations lang="en">List of Recommendations</title-list-recommendations>
2603
2642
 
2604
- <title-acknowledgements lang="en">Acknowledgements</title-acknowledgements>
2605
-
2606
- <title-abstract lang="en">Abstract</title-abstract>
2607
-
2608
2643
  <title-summary lang="en">Summary</title-summary>
2609
2644
 
2610
- <title-in lang="en">in </title-in>
2611
-
2612
- <title-partly-supercedes lang="en">Partly Supercedes </title-partly-supercedes>
2613
- <title-partly-supercedes lang="zh">部分代替 </title-partly-supercedes>
2614
-
2615
- <title-completion-date lang="en">Completion date for this manuscript</title-completion-date>
2616
- <title-completion-date lang="zh">本稿完成日期</title-completion-date>
2617
-
2618
- <title-issuance-date lang="en">Issuance Date: #</title-issuance-date>
2619
- <title-issuance-date lang="zh"># 发布</title-issuance-date>
2620
-
2621
- <title-implementation-date lang="en">Implementation Date: #</title-implementation-date>
2622
- <title-implementation-date lang="zh"># 实施</title-implementation-date>
2623
-
2624
- <title-obligation-normative lang="en">normative</title-obligation-normative>
2625
- <title-obligation-normative lang="zh">规范性附录</title-obligation-normative>
2626
-
2627
- <title-caution lang="en">CAUTION</title-caution>
2628
- <title-caution lang="zh">注意</title-caution>
2629
-
2630
- <title-warning lang="en">WARNING</title-warning>
2631
- <title-warning lang="zh">警告</title-warning>
2632
-
2633
- <title-amendment lang="en">AMENDMENT</title-amendment>
2634
-
2635
2645
  <title-continued lang="en">(continued)</title-continued>
2636
2646
  <title-continued lang="fr">(continué)</title-continued>
2637
2647
 
@@ -2730,6 +2740,10 @@
2730
2740
 
2731
2741
 
2732
2742
 
2743
+ <xsl:attribute name="space-before">8pt</xsl:attribute>
2744
+ <xsl:attribute name="space-after">8pt</xsl:attribute>
2745
+
2746
+
2733
2747
 
2734
2748
 
2735
2749
 
@@ -2742,7 +2756,11 @@
2742
2756
 
2743
2757
 
2744
2758
 
2759
+ <xsl:attribute name="margin-left">10mm</xsl:attribute>
2760
+
2761
+
2745
2762
  </xsl:attribute-set><xsl:attribute-set name="example-name-style">
2763
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
2746
2764
 
2747
2765
 
2748
2766
 
@@ -2767,6 +2785,9 @@
2767
2785
 
2768
2786
 
2769
2787
 
2788
+ <xsl:attribute name="margin-top">5pt</xsl:attribute>
2789
+
2790
+
2770
2791
 
2771
2792
 
2772
2793
 
@@ -3058,7 +3079,78 @@
3058
3079
 
3059
3080
  </xsl:attribute-set><xsl:attribute-set name="toc-style">
3060
3081
  <xsl:attribute name="line-height">135%</xsl:attribute>
3061
- </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">
3082
+ </xsl:attribute-set><xsl:attribute-set name="fn-style">
3083
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
3084
+ </xsl:attribute-set><xsl:attribute-set name="fn-num-style">
3085
+ <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
3086
+
3087
+
3088
+
3089
+
3090
+
3091
+
3092
+ <xsl:attribute name="font-size">8pt</xsl:attribute>
3093
+ <xsl:attribute name="baseline-shift">15%</xsl:attribute>
3094
+
3095
+
3096
+
3097
+
3098
+
3099
+
3100
+
3101
+
3102
+
3103
+
3104
+
3105
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-style">
3106
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
3107
+ <xsl:attribute name="font-style">normal</xsl:attribute>
3108
+ <xsl:attribute name="text-indent">0</xsl:attribute>
3109
+ <xsl:attribute name="start-indent">0</xsl:attribute>
3110
+
3111
+
3112
+
3113
+
3114
+
3115
+
3116
+ <xsl:attribute name="font-size">8pt</xsl:attribute>
3117
+ <xsl:attribute name="margin-bottom">5pt</xsl:attribute>
3118
+
3119
+
3120
+
3121
+
3122
+
3123
+
3124
+
3125
+
3126
+
3127
+
3128
+
3129
+
3130
+
3131
+ </xsl:attribute-set><xsl:attribute-set name="fn-body-num-style">
3132
+ <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
3133
+
3134
+
3135
+
3136
+
3137
+
3138
+
3139
+ <xsl:attribute name="baseline-shift">15%</xsl:attribute>
3140
+ <xsl:attribute name="padding-right">3mm</xsl:attribute>
3141
+
3142
+
3143
+
3144
+
3145
+
3146
+
3147
+
3148
+
3149
+
3150
+
3151
+
3152
+
3153
+ </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:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="OLD_processPrefaceSectionsDefault_Contents">
3062
3154
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
3063
3155
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
3064
3156
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
@@ -3083,7 +3175,8 @@
3083
3175
  <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"/>
3084
3176
 
3085
3177
  </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
3086
- <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
3178
+
3179
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true'] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][@normative='true']]">
3087
3180
  <xsl:sort select="@displayorder" data-type="number"/>
3088
3181
  <xsl:apply-templates select="." mode="contents"/>
3089
3182
  </xsl:for-each>
@@ -3093,7 +3186,7 @@
3093
3186
  <xsl:apply-templates select="." mode="contents"/>
3094
3187
  </xsl:for-each>
3095
3188
 
3096
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3189
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
3097
3190
  <xsl:sort select="@displayorder" data-type="number"/>
3098
3191
  <xsl:apply-templates select="." mode="contents"/>
3099
3192
  </xsl:for-each>
@@ -4047,26 +4140,122 @@
4047
4140
 
4048
4141
  </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">
4049
4142
  <xsl:apply-templates/>
4050
- </xsl:template><xsl:template name="fn_display">
4051
- <xsl:variable name="references">
4143
+ </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">
4144
+
4145
+ <!-- list of footnotes to calculate actual footnotes number -->
4146
+ <xsl:variable name="p_fn_">
4147
+ <xsl:choose>
4148
+ <xsl:when test="@current_fn_number"> <!-- for BSI, footnote reference number calculated already -->
4149
+ <fn gen_id="{generate-id(.)}">
4150
+ <xsl:copy-of select="@*"/>
4151
+ <xsl:copy-of select="node()"/>
4152
+ </fn>
4153
+ </xsl:when>
4154
+ <xsl:otherwise>
4155
+ <!-- itetation for:
4156
+ footnotes in bibdata/title
4157
+ footnotes in bibliography
4158
+ footnotes in document's body (except table's head/body/foot and figure text)
4159
+ -->
4160
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']/*[local-name() = 'note'][@type='title-footnote']">
4161
+ <fn gen_id="{generate-id(.)}">
4162
+ <xsl:copy-of select="@*"/>
4163
+ <xsl:copy-of select="node()"/>
4164
+ </fn>
4165
+ </xsl:for-each>
4166
+ <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']/*">
4167
+ <xsl:sort select="@displayorder" data-type="number"/>
4168
+ <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])]">
4169
+ <!-- copy unique fn -->
4170
+ <fn gen_id="{generate-id(.)}">
4171
+ <xsl:copy-of select="@*"/>
4172
+ <xsl:copy-of select="node()"/>
4173
+ </fn>
4174
+ </xsl:for-each>
4175
+ </xsl:for-each>
4176
+ </xsl:otherwise>
4177
+ </xsl:choose>
4178
+ </xsl:variable>
4179
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
4180
+
4181
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
4182
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
4183
+ <xsl:variable name="reference" select="@reference"/>
4184
+ <!-- fn sequence number in document -->
4185
+ <xsl:variable name="current_fn_number">
4186
+ <xsl:choose>
4187
+ <xsl:when test="@current_fn_number"><xsl:value-of select="@current_fn_number"/></xsl:when> <!-- for BSI -->
4188
+ <xsl:otherwise>
4189
+ <xsl:value-of select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
4190
+ </xsl:otherwise>
4191
+ </xsl:choose>
4192
+ </xsl:variable>
4193
+ <xsl:variable name="current_fn_number_text">
4194
+ <xsl:value-of select="$current_fn_number"/>
4195
+
4052
4196
 
4053
- <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
4054
- <xsl:call-template name="create_fn"/>
4055
- </xsl:for-each>
4056
4197
  </xsl:variable>
4057
4198
 
4058
- <xsl:for-each select="xalan:nodeset($references)//fn">
4059
- <xsl:variable name="reference" select="@reference"/>
4060
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
4061
- <fo:block margin-bottom="12pt">
4199
+ <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/>
4200
+ <xsl:variable name="footnote_inline">
4201
+ <fo:inline xsl:use-attribute-sets="fn-num-style">
4062
4202
 
4063
-
4064
-
4065
-
4066
-
4067
- <xsl:attribute name="font-size">8pt</xsl:attribute>
4068
- <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4069
- <xsl:attribute name="text-indent">-6mm</xsl:attribute>
4203
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
4204
+ <xsl:value-of select="$current_fn_number_text"/>
4205
+ </fo:basic-link>
4206
+ </fo:inline>
4207
+ </xsl:variable>
4208
+ <!-- DEBUG: p_fn=<xsl:copy-of select="$p_fn"/>
4209
+ gen_id=<xsl:value-of select="$gen_id"/> -->
4210
+ <xsl:choose>
4211
+ <xsl:when test="normalize-space(@skip_footnote_body) = 'true'">
4212
+ <xsl:copy-of select="$footnote_inline"/>
4213
+ </xsl:when>
4214
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
4215
+ <fo:footnote xsl:use-attribute-sets="fn-style">
4216
+ <xsl:copy-of select="$footnote_inline"/>
4217
+ <fo:footnote-body>
4218
+
4219
+ <fo:block-container text-indent="0" start-indent="0">
4220
+
4221
+
4222
+ <fo:block xsl:use-attribute-sets="fn-body-style">
4223
+
4224
+
4225
+ <fo:inline id="{$ref_id}" xsl:use-attribute-sets="fn-body-num-style">
4226
+
4227
+ <xsl:value-of select="$current_fn_number_text"/>
4228
+ </fo:inline>
4229
+ <xsl:apply-templates/>
4230
+ </fo:block>
4231
+ </fo:block-container>
4232
+ </fo:footnote-body>
4233
+ </fo:footnote>
4234
+ </xsl:when>
4235
+ <xsl:otherwise>
4236
+ <xsl:copy-of select="$footnote_inline"/>
4237
+ </xsl:otherwise>
4238
+ </xsl:choose>
4239
+ </xsl:template><xsl:template name="fn_display">
4240
+ <xsl:variable name="references">
4241
+
4242
+ <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
4243
+ <xsl:call-template name="create_fn"/>
4244
+ </xsl:for-each>
4245
+ </xsl:variable>
4246
+
4247
+ <xsl:for-each select="xalan:nodeset($references)//fn">
4248
+ <xsl:variable name="reference" select="@reference"/>
4249
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
4250
+ <fo:block margin-bottom="12pt">
4251
+
4252
+
4253
+
4254
+
4255
+
4256
+ <xsl:attribute name="font-size">8pt</xsl:attribute>
4257
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4258
+ <xsl:attribute name="text-indent">-6mm</xsl:attribute>
4070
4259
  <xsl:attribute name="margin-left">6mm</xsl:attribute>
4071
4260
 
4072
4261
 
@@ -4260,6 +4449,8 @@
4260
4449
 
4261
4450
  </fo:basic-link>
4262
4451
  </fo:inline>
4452
+ </xsl:template><xsl:template match="*[local-name()='fn']/text()[normalize-space() != '']">
4453
+ <fo:inline><xsl:value-of select="."/></fo:inline>
4263
4454
  </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']">
4264
4455
  <fo:inline>
4265
4456
  <xsl:apply-templates/>
@@ -4312,12 +4503,9 @@
4312
4503
 
4313
4504
 
4314
4505
  <xsl:variable name="title-where">
4315
-
4316
-
4317
- <xsl:call-template name="getTitle">
4318
- <xsl:with-param name="name" select="'title-where'"/>
4319
- </xsl:call-template>
4320
-
4506
+ <xsl:call-template name="getLocalizedString">
4507
+ <xsl:with-param name="key">where</xsl:with-param>
4508
+ </xsl:call-template>
4321
4509
  </xsl:variable>
4322
4510
  <xsl:value-of select="$title-where"/>
4323
4511
  </fo:block>
@@ -4340,12 +4528,9 @@
4340
4528
 
4341
4529
 
4342
4530
  <xsl:variable name="title-where">
4343
-
4344
-
4345
- <xsl:call-template name="getTitle">
4346
- <xsl:with-param name="name" select="'title-where'"/>
4347
- </xsl:call-template>
4348
-
4531
+ <xsl:call-template name="getLocalizedString">
4532
+ <xsl:with-param name="key">where</xsl:with-param>
4533
+ </xsl:call-template>
4349
4534
  </xsl:variable>
4350
4535
  <xsl:value-of select="$title-where"/>
4351
4536
  </fo:block>
@@ -4360,12 +4545,9 @@
4360
4545
 
4361
4546
 
4362
4547
  <xsl:variable name="title-key">
4363
-
4364
-
4365
- <xsl:call-template name="getTitle">
4366
- <xsl:with-param name="name" select="'title-key'"/>
4367
- </xsl:call-template>
4368
-
4548
+ <xsl:call-template name="getLocalizedString">
4549
+ <xsl:with-param name="key">key</xsl:with-param>
4550
+ </xsl:call-template>
4369
4551
  </xsl:variable>
4370
4552
  <xsl:value-of select="$title-key"/>
4371
4553
  </fo:block>
@@ -4637,6 +4819,7 @@
4637
4819
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
4638
4820
  <xsl:apply-templates/>
4639
4821
  </xsl:template><xsl:template match="*[local-name()='dd']"/><xsl:template match="*[local-name()='dd']" mode="process">
4822
+ <xsl:apply-templates select="@language"/>
4640
4823
  <xsl:apply-templates/>
4641
4824
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4642
4825
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
@@ -4698,6 +4881,15 @@
4698
4881
  </fo:inline>
4699
4882
  </xsl:template><xsl:template match="*[local-name()='add']">
4700
4883
  <xsl:choose>
4884
+ <xsl:when test="starts-with(., $ace_tag)"> <!-- examples: ace-tag_A1_start, ace-tag_A2_end, C1_start, AC_start -->
4885
+ <fo:inline>
4886
+ <xsl:call-template name="insertTag">
4887
+ <xsl:with-param name="type" select="substring-after(substring-after(., $ace_tag), '_')"/> <!-- start or end -->
4888
+ <xsl:with-param name="kind" select="substring(substring-before(substring-after(., $ace_tag), '_'), 1, 1)"/> <!-- A or C -->
4889
+ <xsl:with-param name="value" select="substring(substring-before(substring-after(., $ace_tag), '_'), 2)"/> <!-- 1, 2, C -->
4890
+ </xsl:call-template>
4891
+ </fo:inline>
4892
+ </xsl:when>
4701
4893
  <xsl:when test="@amendment">
4702
4894
  <fo:inline>
4703
4895
  <xsl:call-template name="insertTag">
@@ -4732,7 +4924,6 @@
4732
4924
  </fo:inline>
4733
4925
  </xsl:otherwise>
4734
4926
  </xsl:choose>
4735
-
4736
4927
  </xsl:template><xsl:template name="insertTag">
4737
4928
  <xsl:param name="type"/>
4738
4929
  <xsl:param name="kind"/>
@@ -4748,14 +4939,14 @@
4748
4939
  <xsl:attribute name="scaling">uniform</xsl:attribute>
4749
4940
  <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4750
4941
  <g>
4751
- <xsl:if test="$type = 'closing'">
4942
+ <xsl:if test="$type = 'closing' or $type = 'end'">
4752
4943
  <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
4753
4944
  </xsl:if>
4754
4945
  <polyline points="0,0 {$maxwidth},0 {$maxwidth + 30},40 {$maxwidth},80 0,80 " stroke="black" stroke-width="5" fill="white"/>
4755
4946
  <line x1="0" y1="0" x2="0" y2="80" stroke="black" stroke-width="20"/>
4756
4947
  </g>
4757
4948
  <text font-family="Arial" x="15" y="57" font-size="40pt">
4758
- <xsl:if test="$type = 'closing'">
4949
+ <xsl:if test="$type = 'closing' or $type = 'end'">
4759
4950
  <xsl:attribute name="x">25</xsl:attribute>
4760
4951
  </xsl:if>
4761
4952
  <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
@@ -5252,9 +5443,9 @@
5252
5443
  <fo:inline role="H{$level}"><xsl:apply-templates/></fo:inline>
5253
5444
  </xsl:template><xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
5254
5445
  <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">
5255
- <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
5446
+ <xsl:apply-templates select="*[local-name()='name']"/>
5256
5447
  </fo:block>
5257
- <xsl:apply-templates/>
5448
+ <xsl:apply-templates select="node()[not(local-name()='name')]"/>
5258
5449
  </xsl:template><xsl:template match="*[local-name() = 'callout']">
5259
5450
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
5260
5451
  </xsl:template><xsl:template match="*[local-name() = 'annotation']">
@@ -5274,22 +5465,6 @@
5274
5465
  <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
5275
5466
  <xsl:apply-templates/>
5276
5467
  </fo:inline>
5277
- </xsl:template><xsl:template match="*[local-name() = 'modification']">
5278
- <xsl:variable name="title-modified">
5279
-
5280
-
5281
- <xsl:call-template name="getTitle">
5282
- <xsl:with-param name="name" select="'title-modified'"/>
5283
- </xsl:call-template>
5284
-
5285
- </xsl:variable>
5286
-
5287
- <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
5288
- <xsl:choose>
5289
- <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>
5290
- <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>
5291
- </xsl:choose>
5292
- <xsl:apply-templates/>
5293
5468
  </xsl:template><xsl:template match="*[local-name() = 'xref']">
5294
5469
  <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5295
5470
 
@@ -5856,20 +6031,67 @@
5856
6031
  </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">
5857
6032
  <xsl:apply-templates mode="contents"/>
5858
6033
  <xsl:text> </xsl:text>
5859
- </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">
6034
+ </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'] | *[local-name() = 'sourcecode']/*[local-name() = 'name']" mode="bookmarks">
5860
6035
  <xsl:apply-templates mode="bookmarks"/>
5861
6036
  <xsl:text> </xsl:text>
5862
6037
  </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="contents" priority="2">
5863
6038
  <xsl:value-of select="."/>
5864
- </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']//text()" mode="bookmarks" priority="2">
6039
+ </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement' or local-name() = 'sourcecode']/*[local-name() = 'name']//text()" mode="bookmarks" priority="2">
5865
6040
  <xsl:value-of select="."/>
5866
6041
  </xsl:template><xsl:template match="node()" mode="contents">
5867
6042
  <xsl:apply-templates mode="contents"/>
6043
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title']" priority="2" mode="contents">
6044
+ <xsl:variable name="level">
6045
+ <xsl:call-template name="getLevel">
6046
+ <xsl:with-param name="depth" select="@depth"/>
6047
+ </xsl:call-template>
6048
+ </xsl:variable>
6049
+
6050
+ <xsl:variable name="section">
6051
+ <xsl:value-of select="*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
6052
+ </xsl:variable>
6053
+
6054
+ <xsl:variable name="type">floating-title</xsl:variable>
6055
+
6056
+ <xsl:variable name="display">
6057
+ <xsl:choose>
6058
+ <xsl:when test="normalize-space(@id) = ''">false</xsl:when>
6059
+ <xsl:when test="$level &lt;= $toc_level">true</xsl:when>
6060
+ <xsl:otherwise>false</xsl:otherwise>
6061
+ </xsl:choose>
6062
+ </xsl:variable>
6063
+
6064
+ <xsl:variable name="skip">false</xsl:variable>
6065
+
6066
+ <xsl:if test="$skip = 'false'">
6067
+
6068
+ <xsl:variable name="title">
6069
+ <xsl:choose>
6070
+ <xsl:when test="*[local-name() = 'tab']">
6071
+ <xsl:copy-of select="*[local-name() = 'tab'][1]/following-sibling::node()"/>
6072
+ </xsl:when>
6073
+ <xsl:otherwise>
6074
+ <xsl:copy-of select="node()"/>
6075
+ </xsl:otherwise>
6076
+ </xsl:choose>
6077
+ </xsl:variable>
6078
+
6079
+ <xsl:variable name="root">
6080
+ <xsl:if test="ancestor-or-self::*[local-name() = 'preface']">preface</xsl:if>
6081
+ <xsl:if test="ancestor-or-self::*[local-name() = 'annex']">annex</xsl:if>
6082
+ </xsl:variable>
6083
+
6084
+ <item id="{@id}" level="{$level}" section="{$section}" type="{$type}" root="{$root}" display="{$display}">
6085
+ <title>
6086
+ <xsl:apply-templates select="xalan:nodeset($title)" mode="contents_item"/>
6087
+ </title>
6088
+ </item>
6089
+ </xsl:if>
5868
6090
  </xsl:template><xsl:template match="node()" mode="bookmarks">
5869
6091
  <xsl:apply-templates mode="bookmarks"/>
5870
6092
  </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
5871
6093
  <xsl:apply-templates select="."/>
5872
- </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
6094
+ </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
5873
6095
  <xsl:apply-templates mode="bookmarks"/>
5874
6096
  </xsl:template><xsl:template name="addBookmarks">
5875
6097
  <xsl:param name="contents"/>
@@ -6040,7 +6262,10 @@
6040
6262
  </fo:block>
6041
6263
  </xsl:if>
6042
6264
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/><xsl:template match="*[local-name() = 'title']" mode="contents_item">
6043
- <xsl:apply-templates mode="contents_item"/>
6265
+ <xsl:param name="mode">bookmarks</xsl:param>
6266
+ <xsl:apply-templates mode="contents_item">
6267
+ <xsl:with-param name="mode" select="$mode"/>
6268
+ </xsl:apply-templates>
6044
6269
  <!-- <xsl:text> </xsl:text> -->
6045
6270
  </xsl:template><xsl:template name="getSection">
6046
6271
  <xsl:value-of select="*[local-name() = 'title']/*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
@@ -6113,6 +6338,18 @@
6113
6338
  <xsl:copy-of select="."/>
6114
6339
  </xsl:template><xsl:template match="*[local-name() = 'br']" mode="contents_item">
6115
6340
  <xsl:text> </xsl:text>
6341
+ </xsl:template><xsl:template match="*[local-name() = 'name']" mode="contents_item">
6342
+ <xsl:param name="mode">bookmarks</xsl:param>
6343
+ <xsl:apply-templates mode="contents_item">
6344
+ <xsl:with-param name="mode" select="$mode"/>
6345
+ </xsl:apply-templates>
6346
+ </xsl:template><xsl:template match="*[local-name() = 'add'][starts-with(text(), $ace_tag)]" mode="contents_item">
6347
+ <xsl:param name="mode">bookmarks</xsl:param>
6348
+ <xsl:if test="$mode = 'contents'">
6349
+ <xsl:copy>
6350
+ <xsl:apply-templates mode="contents_item"/>
6351
+ </xsl:copy>
6352
+ </xsl:if>
6116
6353
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
6117
6354
 
6118
6355
  <fo:block-container margin-left="0mm">
@@ -6131,6 +6368,8 @@
6131
6368
 
6132
6369
 
6133
6370
 
6371
+
6372
+
6134
6373
  <fo:block xsl:use-attribute-sets="sourcecode-style">
6135
6374
  <xsl:variable name="_font-size">
6136
6375
 
@@ -6164,13 +6403,17 @@
6164
6403
 
6165
6404
 
6166
6405
 
6406
+
6407
+
6167
6408
  <xsl:apply-templates/>
6168
6409
  </fo:block>
6169
-
6410
+
6170
6411
 
6171
6412
  <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
6172
6413
 
6173
6414
 
6415
+
6416
+
6174
6417
  </fo:block-container>
6175
6418
  </fo:block-container>
6176
6419
  </xsl:template><xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
@@ -6443,42 +6686,54 @@
6443
6686
  <fo:block id="{@id}" xsl:use-attribute-sets="example-style">
6444
6687
 
6445
6688
 
6446
- <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
6447
-
6448
- <xsl:variable name="element">
6689
+ <xsl:variable name="fo_element">
6690
+ <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
6449
6691
 
6450
- inline
6451
- <xsl:if test=".//*[local-name() = 'table']">block</xsl:if>
6692
+
6693
+
6694
+ <xsl:choose>
6695
+ <!-- if example contains only one (except 'name') element (paragraph for example), then display it on the same line as EXAMPLE title -->
6696
+ <xsl:when test="count(*[not(local-name() = 'name')]) = 1">inline</xsl:when>
6697
+ <xsl:otherwise>block</xsl:otherwise>
6698
+ </xsl:choose>
6699
+
6452
6700
  </xsl:variable>
6453
6701
 
6702
+ <!-- display 'EXAMPLE' -->
6703
+ <xsl:apply-templates select="*[local-name()='name']">
6704
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6705
+ </xsl:apply-templates>
6706
+
6454
6707
  <xsl:choose>
6455
- <xsl:when test="contains(normalize-space($element), 'block')">
6456
- <fo:block xsl:use-attribute-sets="example-body-style">
6457
- <xsl:apply-templates/>
6458
- </fo:block>
6708
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
6709
+ <fo:block-container xsl:use-attribute-sets="example-body-style">
6710
+ <fo:block-container margin-left="0mm" margin-right="0mm">
6711
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6712
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6713
+ </xsl:apply-templates>
6714
+ </fo:block-container>
6715
+ </fo:block-container>
6459
6716
  </xsl:when>
6460
6717
  <xsl:otherwise>
6461
6718
  <fo:inline>
6462
- <xsl:apply-templates/>
6719
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
6720
+ <xsl:with-param name="fo_element" select="$fo_element"/>
6721
+ </xsl:apply-templates>
6463
6722
  </fo:inline>
6464
6723
  </xsl:otherwise>
6465
6724
  </xsl:choose>
6466
6725
 
6467
6726
  </fo:block>
6468
- </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']" mode="presentation">
6469
-
6470
- <xsl:variable name="element">
6471
-
6472
- inline
6473
- <xsl:if test="following-sibling::*[1][local-name() = 'table']">block</xsl:if>
6474
- </xsl:variable>
6727
+ </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
6728
+ <xsl:param name="fo_element">block</xsl:param>
6729
+
6475
6730
  <xsl:choose>
6476
6731
  <xsl:when test="ancestor::*[local-name() = 'appendix']">
6477
6732
  <fo:inline>
6478
6733
  <xsl:apply-templates/>
6479
6734
  </fo:inline>
6480
6735
  </xsl:when>
6481
- <xsl:when test="contains(normalize-space($element), 'block')">
6736
+ <xsl:when test="contains(normalize-space($fo_element), 'block')">
6482
6737
  <fo:block xsl:use-attribute-sets="example-name-style">
6483
6738
  <xsl:apply-templates/>
6484
6739
  </fo:block>
@@ -6491,14 +6746,15 @@
6491
6746
  </xsl:choose>
6492
6747
 
6493
6748
  </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'p']">
6749
+ <xsl:param name="fo_element">block</xsl:param>
6750
+
6494
6751
  <xsl:variable name="num"><xsl:number/></xsl:variable>
6495
6752
  <xsl:variable name="element">
6496
- block
6497
-
6498
6753
 
6754
+ <xsl:value-of select="$fo_element"/>
6499
6755
  </xsl:variable>
6500
6756
  <xsl:choose>
6501
- <xsl:when test="normalize-space($element) = 'block'">
6757
+ <xsl:when test="starts-with(normalize-space($element), 'block')">
6502
6758
  <fo:block xsl:use-attribute-sets="example-p-style">
6503
6759
 
6504
6760
  <xsl:apply-templates/>
@@ -6517,62 +6773,66 @@
6517
6773
  <xsl:variable name="termsource_text">
6518
6774
  <xsl:apply-templates/>
6519
6775
  </xsl:variable>
6520
-
6521
- <xsl:choose>
6776
+ <xsl:copy-of select="$termsource_text"/>
6777
+ <!-- <xsl:choose>
6522
6778
  <xsl:when test="starts-with(normalize-space($termsource_text), '[')">
6523
- <!-- <xsl:apply-templates /> -->
6524
6779
  <xsl:copy-of select="$termsource_text"/>
6525
6780
  </xsl:when>
6526
6781
  <xsl:otherwise>
6527
-
6528
-
6782
+ <xsl:if test="$namespace = 'bsi'">
6783
+ <xsl:choose>
6784
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>{</xsl:text></xsl:when>
6785
+ <xsl:otherwise><xsl:text>[</xsl:text></xsl:otherwise>
6786
+ </xsl:choose>
6787
+ </xsl:if>
6788
+ <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'">
6529
6789
  <xsl:text>[</xsl:text>
6530
-
6531
- <!-- <xsl:apply-templates /> -->
6790
+ </xsl:if>
6532
6791
  <xsl:copy-of select="$termsource_text"/>
6533
-
6534
-
6792
+ <xsl:if test="$namespace = 'bsi'">
6793
+ <xsl:choose>
6794
+ <xsl:when test="$document_type = 'PAS' and starts-with(*[local-name() = 'origin']/@citeas, '[')"><xsl:text>}</xsl:text></xsl:when>
6795
+ <xsl:otherwise><xsl:text>]</xsl:text></xsl:otherwise>
6796
+ </xsl:choose>
6797
+ </xsl:if>
6798
+ <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'">
6535
6799
  <xsl:text>]</xsl:text>
6536
-
6800
+ </xsl:if>
6537
6801
  </xsl:otherwise>
6538
- </xsl:choose>
6802
+ </xsl:choose> -->
6539
6803
  </fo:block>
6540
6804
  </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
6541
6805
  <xsl:if test="normalize-space() != ''">
6542
6806
  <xsl:value-of select="."/>
6543
6807
  </xsl:if>
6544
- </xsl:template><xsl:variable name="localized.source">
6545
- <xsl:call-template name="getLocalizedString">
6546
- <xsl:with-param name="key">source</xsl:with-param>
6547
- </xsl:call-template>
6548
- </xsl:variable><xsl:template match="*[local-name() = 'origin']">
6808
+ </xsl:template><xsl:template match="*[local-name() = 'termsource']/*[local-name() = 'strong'][1][following-sibling::*[1][local-name() = 'origin']]/text()">
6809
+ <fo:inline>
6810
+
6811
+
6812
+ <xsl:value-of select="."/>
6813
+ </fo:inline>
6814
+ </xsl:template><xsl:template match="*[local-name() = 'origin']">
6549
6815
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6550
6816
  <xsl:if test="normalize-space(@citeas) = ''">
6551
6817
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6552
6818
  </xsl:if>
6553
-
6554
-
6555
- <fo:inline>
6556
-
6557
-
6558
-
6559
-
6560
-
6561
-
6562
-
6563
- <xsl:call-template name="getTitle">
6564
- <xsl:with-param name="name" select="'title-source'"/>
6565
- </xsl:call-template>
6566
- <xsl:text>: </xsl:text>
6567
-
6568
-
6569
- </fo:inline>
6570
-
6571
6819
  <fo:inline xsl:use-attribute-sets="origin-style">
6572
6820
  <xsl:apply-templates/>
6573
6821
  </fo:inline>
6574
-
6575
- </fo:basic-link>
6822
+ </fo:basic-link>
6823
+ </xsl:template><xsl:template match="*[local-name() = 'modification']">
6824
+ <xsl:variable name="title-modified">
6825
+ <xsl:call-template name="getLocalizedString">
6826
+ <xsl:with-param name="key">modified</xsl:with-param>
6827
+ </xsl:call-template>
6828
+ </xsl:variable>
6829
+
6830
+ <xsl:variable name="text"><xsl:apply-templates/></xsl:variable>
6831
+ <xsl:choose>
6832
+ <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>
6833
+ <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>
6834
+ </xsl:choose>
6835
+ <xsl:apply-templates/>
6576
6836
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
6577
6837
  <fo:inline><xsl:apply-templates/></fo:inline>
6578
6838
  </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
@@ -6755,25 +7015,29 @@
6755
7015
  </fo:block>
6756
7016
  </xsl:template><xsl:template match="*[local-name() = 'deprecates']">
6757
7017
  <xsl:variable name="title-deprecated">
6758
-
6759
-
6760
- <xsl:call-template name="getTitle">
6761
- <xsl:with-param name="name" select="'title-deprecated'"/>
6762
- </xsl:call-template>
6763
-
7018
+ <xsl:call-template name="getLocalizedString">
7019
+ <xsl:with-param name="key">deprecated</xsl:with-param>
7020
+ </xsl:call-template>
6764
7021
  </xsl:variable>
6765
7022
  <fo:block xsl:use-attribute-sets="deprecates-style">
6766
7023
  <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
6767
7024
  </fo:block>
7025
+ </xsl:template><xsl:template name="setStyle_preferred">
7026
+ <xsl:if test="*[local-name() = 'strong']">
7027
+ <xsl:attribute name="font-weight">normal</xsl:attribute>
7028
+ </xsl:if>
7029
+ </xsl:template><xsl:template match="*[local-name() = 'preferred']/text()[contains(., ';')] | *[local-name() = 'preferred']/*[local-name() = 'strong']/text()[contains(., ';')]">
7030
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), ';', $linebreak)"/>
6768
7031
  </xsl:template><xsl:template match="*[local-name() = 'definition']">
6769
7032
  <fo:block xsl:use-attribute-sets="definition-style">
6770
7033
  <xsl:apply-templates/>
6771
7034
  </fo:block>
6772
7035
  </xsl:template><xsl:template match="*[local-name() = 'definition'][preceding-sibling::*[local-name() = 'domain']]">
6773
7036
  <xsl:apply-templates/>
6774
- </xsl:template><xsl:template match="*[local-name() = 'definition'][preceding-sibling::*[local-name() = 'domain']]/*[local-name() = 'p']">
7037
+ </xsl:template><xsl:template match="*[local-name() = 'definition'][preceding-sibling::*[local-name() = 'domain']]/*[local-name() = 'p'][1]">
6775
7038
  <fo:inline> <xsl:apply-templates/></fo:inline>
6776
- <fo:block> </fo:block>
7039
+ <!-- <fo:block>&#xA0;</fo:block> -->
7040
+ <fo:block/>
6777
7041
  </xsl:template><xsl:template match="/*/*[local-name() = 'sections']/*" priority="2">
6778
7042
 
6779
7043
  <fo:block>
@@ -6829,6 +7093,53 @@
6829
7093
  </xsl:template><xsl:template match="*[local-name() = 'name']/text()">
6830
7094
  <!-- 0xA0 to space replacement -->
6831
7095
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
7096
+ </xsl:template><xsl:variable name="ul_labels_">
7097
+
7098
+
7099
+
7100
+
7101
+
7102
+ <label level="1" font-size="10pt">•</label>
7103
+ <label level="2" font-size="10pt">—</label><!-- em dash -->
7104
+ <label level="3" font-size="75%">o</label> <!-- white circle -->
7105
+
7106
+
7107
+
7108
+
7109
+
7110
+
7111
+
7112
+
7113
+
7114
+
7115
+
7116
+
7117
+
7118
+ </xsl:variable><xsl:variable name="ul_labels" select="xalan:nodeset($ul_labels_)"/><xsl:template name="setULLabel">
7119
+ <xsl:variable name="list_level_" select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
7120
+ <xsl:variable name="list_level">
7121
+ <xsl:choose>
7122
+ <xsl:when test="$list_level_ &lt;= 3"><xsl:value-of select="$list_level_"/></xsl:when>
7123
+ <xsl:otherwise><xsl:value-of select="$list_level_ mod 3"/></xsl:otherwise>
7124
+ </xsl:choose>
7125
+ </xsl:variable>
7126
+ <xsl:choose>
7127
+ <xsl:when test="$ul_labels/label[not(@level)]"> <!-- one label for all levels -->
7128
+ <xsl:apply-templates select="$ul_labels/label[not(@level)]" mode="ul_labels"/>
7129
+ </xsl:when>
7130
+ <xsl:when test="$list_level mod 3 = 0">
7131
+ <xsl:apply-templates select="$ul_labels/label[@level = 3]" mode="ul_labels"/>
7132
+ </xsl:when>
7133
+ <xsl:when test="$list_level mod 2 = 0">
7134
+ <xsl:apply-templates select="$ul_labels/label[@level = 2]" mode="ul_labels"/>
7135
+ </xsl:when>
7136
+ <xsl:otherwise>
7137
+ <xsl:apply-templates select="$ul_labels/label[@level = 1]" mode="ul_labels"/>
7138
+ </xsl:otherwise>
7139
+ </xsl:choose>
7140
+ </xsl:template><xsl:template match="label" mode="ul_labels">
7141
+ <xsl:copy-of select="@*[not(local-name() = 'level')]"/>
7142
+ <xsl:value-of select="."/>
6832
7143
  </xsl:template><xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
6833
7144
  <xsl:choose>
6834
7145
  <xsl:when test="parent::*[local-name() = 'note'] or parent::*[local-name() = 'termnote']">
@@ -7039,16 +7350,51 @@
7039
7350
 
7040
7351
 
7041
7352
 
7042
-
7353
+
7354
+
7355
+
7356
+
7357
+
7358
+
7359
+
7360
+ <!-- start IEC bibtem processing -->
7361
+ <xsl:variable name="docidentifier">
7362
+ <xsl:choose>
7363
+ <xsl:when test="*[local-name() = 'docidentifier']/@type = 'metanorma'"/>
7364
+ <xsl:otherwise><xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma-ordinal')]"/></xsl:otherwise>
7365
+ </xsl:choose>
7366
+ </xsl:variable>
7367
+ <xsl:value-of select="$docidentifier"/>
7368
+ <xsl:apply-templates select="iec:note"/>
7369
+ <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
7370
+ <xsl:choose>
7371
+ <xsl:when test="iec:title[@type = 'main' and @language = 'en']">
7372
+ <xsl:apply-templates select="iec:title[@type = 'main' and @language = 'en']"/>
7373
+ </xsl:when>
7374
+ <xsl:otherwise>
7375
+ <xsl:apply-templates select="iec:title"/>
7376
+ </xsl:otherwise>
7377
+ </xsl:choose>
7378
+ <xsl:apply-templates select="iec:formattedref"/>
7379
+ <!-- end IEC bibtem processing -->
7043
7380
 
7044
7381
 
7045
7382
 
7046
7383
 
7047
7384
 
7385
+
7386
+
7387
+
7388
+
7389
+ <!-- end MPFD bibitem processing -->
7390
+
7391
+ <!-- start M3D bibitem processing -->
7048
7392
 
7049
7393
 
7394
+
7395
+
7050
7396
  </xsl:template><xsl:template name="processBibitemDocId">
7051
- <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/>
7397
+ <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/>
7052
7398
  <xsl:choose>
7053
7399
  <xsl:when test="normalize-space($_doc_ident) != ''">
7054
7400
  <!-- <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/>
@@ -7062,7 +7408,7 @@
7062
7408
  <xsl:if test="$type != ''">
7063
7409
  <xsl:value-of select="$type"/><xsl:text> </xsl:text>
7064
7410
  </xsl:if> -->
7065
- <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]"/>
7411
+ <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma') and not(@type = 'metanorma-ordinal')]"/>
7066
7412
  </xsl:otherwise>
7067
7413
  </xsl:choose>
7068
7414
  </xsl:template><xsl:template name="processPersonalAuthor">
@@ -7167,7 +7513,35 @@
7167
7513
  <fo:block-container border="1pt solid black" width="50%">
7168
7514
  <fo:block> </fo:block>
7169
7515
  </fo:block-container>
7170
- </xsl:template><xsl:template match="*[local-name() = 'toc']">
7516
+ </xsl:template><xsl:variable name="toc_level">
7517
+ <!-- https://www.metanorma.org/author/ref/document-attributes/ -->
7518
+ <xsl:variable name="htmltoclevels" select="normalize-space(//*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name']/text() = 'HTML TOC Heading Levels']/*[local-name() = 'value'])"/> <!-- :htmltoclevels Number of table of contents levels to render in HTML/PDF output; used to override :toclevels:-->
7519
+ <xsl:variable name="toclevels" select="normalize-space(//*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name']/text() = 'TOC Heading Levels']/*[local-name() = 'value'])"/> <!-- Number of table of contents levels to render -->
7520
+ <xsl:choose>
7521
+ <xsl:when test="$htmltoclevels != ''"><xsl:value-of select="number($htmltoclevels)"/></xsl:when> <!-- if there is value in xml -->
7522
+ <xsl:when test="$toclevels != ''"><xsl:value-of select="number($toclevels)"/></xsl:when> <!-- if there is value in xml -->
7523
+ <xsl:otherwise><!-- default value -->
7524
+
7525
+
7526
+
7527
+
7528
+
7529
+ 3
7530
+
7531
+
7532
+
7533
+
7534
+
7535
+
7536
+
7537
+
7538
+
7539
+
7540
+
7541
+
7542
+ </xsl:otherwise>
7543
+ </xsl:choose>
7544
+ </xsl:variable><xsl:template match="*[local-name() = 'toc']">
7171
7545
  <xsl:param name="colwidths"/>
7172
7546
  <xsl:variable name="colwidths_">
7173
7547
  <xsl:choose>
@@ -7247,7 +7621,7 @@
7247
7621
  </td>
7248
7622
  </xsl:for-each>
7249
7623
  <td>333</td> <!-- page number, just for fill -->
7250
- </xsl:template><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
7624
+ </xsl:template><xsl:template match="*[local-name() = 'variant-title']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
7251
7625
  <fo:inline padding-right="5mm"> </fo:inline>
7252
7626
  <fo:inline><xsl:apply-templates/></fo:inline>
7253
7627
  </xsl:template><xsl:template match="*[local-name() = 'blacksquare']" name="blacksquare">
@@ -7258,6 +7632,10 @@
7258
7632
  </svg>
7259
7633
  </fo:instream-foreign-object>
7260
7634
  </fo:inline>
7635
+ </xsl:template><xsl:template match="@language">
7636
+ <xsl:copy-of select="."/>
7637
+ </xsl:template><xsl:template match="*[local-name() = 'p'][@type = 'floating-title']" priority="4">
7638
+ <xsl:call-template name="title"/>
7261
7639
  </xsl:template><xsl:template name="convertDate">
7262
7640
  <xsl:param name="date"/>
7263
7641
  <xsl:param name="format" select="'short'"/>
@@ -7615,9 +7993,15 @@
7615
7993
  </xsl:template><xsl:template name="getLocalizedString">
7616
7994
  <xsl:param name="key"/>
7617
7995
  <xsl:param name="formatted">false</xsl:param>
7996
+ <xsl:param name="lang"/>
7618
7997
 
7619
7998
  <xsl:variable name="curr_lang">
7620
- <xsl:call-template name="getLang"/>
7999
+ <xsl:choose>
8000
+ <xsl:when test="$lang != ''"><xsl:value-of select="$lang"/></xsl:when>
8001
+ <xsl:otherwise>
8002
+ <xsl:call-template name="getLang"/>
8003
+ </xsl:otherwise>
8004
+ </xsl:choose>
7621
8005
  </xsl:variable>
7622
8006
 
7623
8007
  <xsl:variable name="data_value">
@@ -7807,4 +8191,14 @@
7807
8191
  </xsl:otherwise>
7808
8192
  </xsl:choose>
7809
8193
  </xsl:if>
8194
+ </xsl:template><xsl:template name="setAltText">
8195
+ <xsl:param name="value"/>
8196
+ <xsl:attribute name="fox:alt-text">
8197
+ <xsl:choose>
8198
+ <xsl:when test="normalize-space($value) != ''">
8199
+ <xsl:value-of select="$value"/>
8200
+ </xsl:when>
8201
+ <xsl:otherwise>_</xsl:otherwise>
8202
+ </xsl:choose>
8203
+ </xsl:attribute>
7810
8204
  </xsl:template></xsl:stylesheet>