metanorma-un 0.5.9 → 0.5.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1420,6 +1420,7 @@
1420
1420
 
1421
1421
  </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
1422
1422
 
1423
+
1423
1424
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
1424
1425
 
1425
1426
 
@@ -1427,6 +1428,7 @@
1427
1428
 
1428
1429
 
1429
1430
 
1431
+
1430
1432
  </xsl:attribute-set><xsl:attribute-set name="quote-source-style">
1431
1433
 
1432
1434
 
@@ -1556,200 +1558,233 @@
1556
1558
  </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
1557
1559
  <!-- <xsl:call-template name="add-zero-spaces"/> -->
1558
1560
  <xsl:call-template name="add-zero-spaces-java"/>
1559
- </xsl:template><xsl:template match="*[local-name()='table']">
1561
+ </xsl:template><xsl:template match="*[local-name()='table']" name="table">
1560
1562
 
1561
- <xsl:variable name="simple-table">
1562
- <xsl:call-template name="getSimpleTable"/>
1563
- </xsl:variable>
1563
+ <xsl:variable name="table">
1564
1564
 
1565
-
1566
-
1567
-
1568
-
1569
- <!-- <xsl:if test="$namespace = 'bipm'">
1570
- <fo:block>&#xA0;</fo:block>
1571
- </xsl:if> -->
1572
-
1573
- <!-- $namespace = 'iso' or -->
1574
-
1575
- <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
1576
-
1577
-
1578
-
1579
- <xsl:call-template name="fn_name_display"/>
1565
+ <xsl:variable name="simple-table">
1566
+ <xsl:call-template name="getSimpleTable"/>
1567
+ </xsl:variable>
1580
1568
 
1581
1569
 
1582
-
1583
- <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
1584
-
1585
- <!-- <xsl:variable name="cols-count">
1586
- <xsl:choose>
1587
- <xsl:when test="*[local-name()='thead']">
1588
- <xsl:call-template name="calculate-columns-numbers">
1589
- <xsl:with-param name="table-row" select="*[local-name()='thead']/*[local-name()='tr'][1]"/>
1590
- </xsl:call-template>
1591
- </xsl:when>
1592
- <xsl:otherwise>
1593
- <xsl:call-template name="calculate-columns-numbers">
1594
- <xsl:with-param name="table-row" select="*[local-name()='tbody']/*[local-name()='tr'][1]"/>
1595
- </xsl:call-template>
1596
- </xsl:otherwise>
1597
- </xsl:choose>
1598
- </xsl:variable> -->
1599
- <!-- cols-count=<xsl:copy-of select="$cols-count"/> -->
1600
- <!-- cols-count2=<xsl:copy-of select="$cols-count2"/> -->
1601
-
1602
-
1603
-
1604
- <xsl:variable name="colwidths">
1605
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
1606
- <xsl:call-template name="calculate-column-widths">
1607
- <xsl:with-param name="cols-count" select="$cols-count"/>
1608
- <xsl:with-param name="table" select="$simple-table"/>
1609
- </xsl:call-template>
1610
- </xsl:if>
1611
- </xsl:variable>
1612
- <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
1613
-
1614
- <!-- <xsl:variable name="colwidths2">
1615
- <xsl:call-template name="calculate-column-widths">
1616
- <xsl:with-param name="cols-count" select="$cols-count"/>
1617
- </xsl:call-template>
1618
- </xsl:variable> -->
1619
-
1620
- <!-- cols-count=<xsl:copy-of select="$cols-count"/>
1621
- colwidthsNew=<xsl:copy-of select="$colwidths"/>
1622
- colwidthsOld=<xsl:copy-of select="$colwidths2"/>z -->
1623
-
1624
- <xsl:variable name="margin-left">
1625
- <xsl:choose>
1626
- <xsl:when test="sum(xalan:nodeset($colwidths)//column) &gt; 75">15</xsl:when>
1627
- <xsl:otherwise>0</xsl:otherwise>
1628
- </xsl:choose>
1629
- </xsl:variable>
1630
-
1631
- <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm">
1632
1570
 
1633
1571
 
1634
-
1635
1572
 
1636
- <xsl:attribute name="space-after">12pt</xsl:attribute>
1637
- <xsl:if test="not(ancestor::*[local-name()='sections'])">
1638
- <xsl:attribute name="font-size">10pt</xsl:attribute>
1639
- </xsl:if>
1640
-
1641
-
1573
+ <!-- <xsl:if test="$namespace = 'bipm'">
1574
+ <fo:block>&#xA0;</fo:block>
1575
+ </xsl:if> -->
1642
1576
 
1577
+ <!-- $namespace = 'iso' or -->
1643
1578
 
1644
-
1579
+ <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
1580
+
1581
+
1582
+
1583
+ <xsl:call-template name="fn_name_display"/>
1584
+
1585
+
1586
+
1587
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
1588
+
1589
+ <!-- <xsl:variable name="cols-count">
1590
+ <xsl:choose>
1591
+ <xsl:when test="*[local-name()='thead']">
1592
+ <xsl:call-template name="calculate-columns-numbers">
1593
+ <xsl:with-param name="table-row" select="*[local-name()='thead']/*[local-name()='tr'][1]"/>
1594
+ </xsl:call-template>
1595
+ </xsl:when>
1596
+ <xsl:otherwise>
1597
+ <xsl:call-template name="calculate-columns-numbers">
1598
+ <xsl:with-param name="table-row" select="*[local-name()='tbody']/*[local-name()='tr'][1]"/>
1599
+ </xsl:call-template>
1600
+ </xsl:otherwise>
1601
+ </xsl:choose>
1602
+ </xsl:variable> -->
1603
+ <!-- cols-count=<xsl:copy-of select="$cols-count"/> -->
1604
+ <!-- cols-count2=<xsl:copy-of select="$cols-count2"/> -->
1645
1605
 
1646
1606
 
1647
1607
 
1608
+ <xsl:variable name="colwidths">
1609
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
1610
+ <xsl:call-template name="calculate-column-widths">
1611
+ <xsl:with-param name="cols-count" select="$cols-count"/>
1612
+ <xsl:with-param name="table" select="$simple-table"/>
1613
+ </xsl:call-template>
1614
+ </xsl:if>
1615
+ </xsl:variable>
1616
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
1648
1617
 
1618
+ <!-- <xsl:variable name="colwidths2">
1619
+ <xsl:call-template name="calculate-column-widths">
1620
+ <xsl:with-param name="cols-count" select="$cols-count"/>
1621
+ </xsl:call-template>
1622
+ </xsl:variable> -->
1649
1623
 
1624
+ <!-- cols-count=<xsl:copy-of select="$cols-count"/>
1625
+ colwidthsNew=<xsl:copy-of select="$colwidths"/>
1626
+ colwidthsOld=<xsl:copy-of select="$colwidths2"/>z -->
1650
1627
 
1628
+ <xsl:variable name="margin-left">
1629
+ <xsl:choose>
1630
+ <xsl:when test="sum(xalan:nodeset($colwidths)//column) &gt; 75">15</xsl:when>
1631
+ <xsl:otherwise>0</xsl:otherwise>
1632
+ </xsl:choose>
1633
+ </xsl:variable>
1651
1634
 
1652
- <xsl:variable name="table_attributes">
1653
- <attribute name="table-layout">fixed</attribute>
1654
- <attribute name="width">100%</attribute>
1655
- <attribute name="margin-left"><xsl:value-of select="$margin-left"/>mm</attribute>
1656
- <attribute name="margin-right"><xsl:value-of select="$margin-left"/>mm</attribute>
1635
+ <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm">
1657
1636
 
1658
1637
 
1638
+
1659
1639
 
1640
+ <xsl:attribute name="space-after">12pt</xsl:attribute>
1641
+ <xsl:if test="not(ancestor::*[local-name()='sections'])">
1642
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
1643
+ </xsl:if>
1644
+
1645
+
1660
1646
 
1661
-
1662
1647
 
1663
- <xsl:if test="ancestor::*[local-name()='sections']">
1664
- <attribute name="border-top">1.5pt solid black</attribute>
1665
- <attribute name="border-bottom">1.5pt solid black</attribute>
1666
- </xsl:if>
1667
-
1668
-
1648
+
1669
1649
 
1670
-
1671
1650
 
1672
- </xsl:variable>
1673
-
1674
-
1675
- <fo:table id="{@id}" table-omit-footer-at-break="true">
1676
1651
 
1677
- <xsl:for-each select="xalan:nodeset($table_attributes)/attribute">
1678
- <xsl:attribute name="{@name}">
1679
- <xsl:value-of select="."/>
1680
- </xsl:attribute>
1681
- </xsl:for-each>
1682
1652
 
1683
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/>
1684
- <xsl:if test="$isNoteOrFnExist = 'true'">
1685
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
1686
- </xsl:if>
1687
1653
 
1688
- <xsl:choose>
1689
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
1690
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
1691
- <fo:table-column column-width="{@width}"/>
1692
- </xsl:for-each>
1693
- </xsl:when>
1694
- <xsl:otherwise>
1695
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
1696
- <xsl:choose>
1697
- <xsl:when test=". = 1 or . = 0">
1698
- <fo:table-column column-width="proportional-column-width(2)"/>
1699
- </xsl:when>
1700
- <xsl:otherwise>
1701
- <fo:table-column column-width="proportional-column-width({.})"/>
1702
- </xsl:otherwise>
1703
- </xsl:choose>
1704
- </xsl:for-each>
1705
- </xsl:otherwise>
1706
- </xsl:choose>
1707
1654
 
1708
- <xsl:choose>
1709
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
1710
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
1711
- </xsl:when>
1712
- <xsl:otherwise>
1713
- <xsl:apply-templates/>
1714
- </xsl:otherwise>
1715
- </xsl:choose>
1655
+ <xsl:variable name="table_width">
1656
+ <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
1657
+
1658
+
1659
+
1660
+ <xsl:choose>
1661
+ <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
1662
+ <xsl:otherwise>100%</xsl:otherwise>
1663
+ </xsl:choose>
1664
+
1665
+ </xsl:variable>
1666
+
1667
+ <xsl:variable name="table_attributes">
1668
+ <attribute name="table-layout">fixed</attribute>
1669
+ <attribute name="width"><xsl:value-of select="normalize-space($table_width)"/></attribute>
1670
+ <attribute name="margin-left"><xsl:value-of select="$margin-left"/>mm</attribute>
1671
+ <attribute name="margin-right"><xsl:value-of select="$margin-left"/>mm</attribute>
1672
+
1673
+
1674
+
1675
+
1676
+
1677
+
1678
+ <xsl:if test="ancestor::*[local-name()='sections']">
1679
+ <attribute name="border-top">1.5pt solid black</attribute>
1680
+ <attribute name="border-bottom">1.5pt solid black</attribute>
1681
+ </xsl:if>
1682
+
1683
+
1684
+
1685
+
1686
+
1687
+ </xsl:variable>
1716
1688
 
1717
- </fo:table>
1718
-
1719
- <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
1720
- <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
1721
- <xsl:call-template name="insertTableFooterInSeparateTable">
1722
- <xsl:with-param name="table_attributes" select="$table_attributes"/>
1723
- <xsl:with-param name="colwidths" select="$colwidths"/>
1724
- <xsl:with-param name="colgroup" select="$colgroup"/>
1725
- </xsl:call-template>
1726
- </xsl:for-each>
1727
-
1728
- <!-- insert footer as table -->
1729
- <!-- <fo:table>
1730
- <xsl:for-each select="xalan::nodeset($table_attributes)/attribute">
1731
- <xsl:attribute name="{@name}">
1732
- <xsl:value-of select="."/>
1733
- </xsl:attribute>
1734
- </xsl:for-each>
1735
1689
 
1736
- <xsl:for-each select="xalan:nodeset($colwidths)//column">
1690
+ <fo:table id="{@id}" table-omit-footer-at-break="true">
1691
+
1692
+ <xsl:for-each select="xalan:nodeset($table_attributes)/attribute">
1693
+ <xsl:attribute name="{@name}">
1694
+ <xsl:value-of select="."/>
1695
+ </xsl:attribute>
1696
+ </xsl:for-each>
1697
+
1698
+ <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/>
1699
+ <xsl:if test="$isNoteOrFnExist = 'true'">
1700
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
1701
+ </xsl:if>
1702
+
1703
+ <xsl:choose>
1704
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
1705
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
1706
+ <fo:table-column column-width="{@width}"/>
1707
+ </xsl:for-each>
1708
+ </xsl:when>
1709
+ <xsl:otherwise>
1710
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
1711
+ <xsl:choose>
1712
+ <xsl:when test=". = 1 or . = 0">
1713
+ <fo:table-column column-width="proportional-column-width(2)"/>
1714
+ </xsl:when>
1715
+ <xsl:otherwise>
1716
+ <fo:table-column column-width="proportional-column-width({.})"/>
1717
+ </xsl:otherwise>
1718
+ </xsl:choose>
1719
+ </xsl:for-each>
1720
+ </xsl:otherwise>
1721
+ </xsl:choose>
1722
+
1737
1723
  <xsl:choose>
1738
- <xsl:when test=". = 1 or . = 0">
1739
- <fo:table-column column-width="proportional-column-width(2)"/>
1724
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
1725
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
1740
1726
  </xsl:when>
1741
1727
  <xsl:otherwise>
1742
- <fo:table-column column-width="proportional-column-width({.})"/>
1728
+ <xsl:apply-templates/>
1743
1729
  </xsl:otherwise>
1744
1730
  </xsl:choose>
1731
+
1732
+ </fo:table>
1733
+
1734
+ <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/>
1735
+ <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody -->
1736
+ <xsl:call-template name="insertTableFooterInSeparateTable">
1737
+ <xsl:with-param name="table_attributes" select="$table_attributes"/>
1738
+ <xsl:with-param name="colwidths" select="$colwidths"/>
1739
+ <xsl:with-param name="colgroup" select="$colgroup"/>
1740
+ </xsl:call-template>
1745
1741
  </xsl:for-each>
1746
- </fo:table>-->
1747
-
1748
-
1749
-
1750
-
1751
-
1752
- </fo:block-container>
1742
+
1743
+ <!-- insert footer as table -->
1744
+ <!-- <fo:table>
1745
+ <xsl:for-each select="xalan::nodeset($table_attributes)/attribute">
1746
+ <xsl:attribute name="{@name}">
1747
+ <xsl:value-of select="."/>
1748
+ </xsl:attribute>
1749
+ </xsl:for-each>
1750
+
1751
+ <xsl:for-each select="xalan:nodeset($colwidths)//column">
1752
+ <xsl:choose>
1753
+ <xsl:when test=". = 1 or . = 0">
1754
+ <fo:table-column column-width="proportional-column-width(2)"/>
1755
+ </xsl:when>
1756
+ <xsl:otherwise>
1757
+ <fo:table-column column-width="proportional-column-width({.})"/>
1758
+ </xsl:otherwise>
1759
+ </xsl:choose>
1760
+ </xsl:for-each>
1761
+ </fo:table>-->
1762
+
1763
+
1764
+
1765
+
1766
+
1767
+ </fo:block-container>
1768
+ </xsl:variable>
1769
+
1770
+
1771
+
1772
+ <xsl:choose>
1773
+ <xsl:when test="@width">
1774
+
1775
+ <!-- centered table when table name is centered (see table-name-style) -->
1776
+
1777
+
1778
+
1779
+ <xsl:copy-of select="$table"/>
1780
+
1781
+
1782
+ </xsl:when>
1783
+ <xsl:otherwise>
1784
+ <xsl:copy-of select="$table"/>
1785
+ </xsl:otherwise>
1786
+ </xsl:choose>
1787
+
1753
1788
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name() = 'name']"/><xsl:template match="*[local-name()='table']/*[local-name() = 'name']" mode="presentation">
1754
1789
  <xsl:if test="normalize-space() != ''">
1755
1790
  <fo:block xsl:use-attribute-sets="table-name-style">
@@ -2460,7 +2495,9 @@
2460
2495
  </xsl:template><xsl:template match="*[local-name()='dl']">
2461
2496
  <fo:block-container>
2462
2497
 
2463
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
2498
+ <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
2499
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2500
+ </xsl:if>
2464
2501
 
2465
2502
 
2466
2503
  <xsl:if test="parent::*[local-name() = 'note']">
@@ -2475,6 +2512,7 @@
2475
2512
  <fo:block-container>
2476
2513
 
2477
2514
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
2515
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
2478
2516
 
2479
2517
 
2480
2518
  <xsl:variable name="parent" select="local-name(..)"/>
@@ -2591,7 +2629,7 @@
2591
2629
  <xsl:with-param name="table" select="$html-table"/>
2592
2630
  </xsl:call-template>
2593
2631
  </xsl:variable>
2594
- <!-- colwidths=<xsl:value-of select="$colwidths"/> -->
2632
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
2595
2633
  <xsl:variable name="maxlength_dt">
2596
2634
  <xsl:call-template name="getMaxLength_dt"/>
2597
2635
  </xsl:variable>
@@ -2620,13 +2658,22 @@
2620
2658
  </xsl:when>
2621
2659
  <xsl:otherwise>
2622
2660
  <xsl:choose>
2661
+ <!-- to set width check most wide chars like `W` -->
2623
2662
  <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc -->
2624
- <fo:table-column column-width="5%"/>
2625
- <fo:table-column column-width="95%"/>
2663
+ <fo:table-column column-width="7%"/>
2664
+ <fo:table-column column-width="93%"/>
2665
+ </xsl:when>
2666
+ <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 5"> <!-- if dt contains short text like ABC, etc -->
2667
+ <fo:table-column column-width="15%"/>
2668
+ <fo:table-column column-width="85%"/>
2626
2669
  </xsl:when>
2627
- <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 5"> <!-- if dt contains short text like t90, a, etc -->
2628
- <fo:table-column column-width="10%"/>
2629
- <fo:table-column column-width="90%"/>
2670
+ <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 7"> <!-- if dt contains short text like ABCDEF, etc -->
2671
+ <fo:table-column column-width="20%"/>
2672
+ <fo:table-column column-width="80%"/>
2673
+ </xsl:when>
2674
+ <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 10"> <!-- if dt contains short text like ABCDEFEF, etc -->
2675
+ <fo:table-column column-width="25%"/>
2676
+ <fo:table-column column-width="75%"/>
2630
2677
  </xsl:when>
2631
2678
  <!-- <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 1.7">
2632
2679
  <fo:table-column column-width="60%"/>
@@ -2658,12 +2705,32 @@
2658
2705
  </xsl:otherwise>
2659
2706
  </xsl:choose>
2660
2707
  </xsl:template><xsl:template name="getMaxLength_dt">
2661
- <xsl:for-each select="*[local-name()='dt']">
2662
- <xsl:sort select="string-length(normalize-space(.))" data-type="number" order="descending"/>
2663
- <xsl:if test="position() = 1">
2664
- <xsl:value-of select="string-length(normalize-space(.))"/>
2665
- </xsl:if>
2666
- </xsl:for-each>
2708
+ <xsl:variable name="lengths">
2709
+ <xsl:for-each select="*[local-name()='dt']">
2710
+ <xsl:variable name="maintext_length" select="string-length(normalize-space(.))"/>
2711
+ <xsl:variable name="attributes">
2712
+ <xsl:for-each select=".//@open"><xsl:value-of select="."/></xsl:for-each>
2713
+ <xsl:for-each select=".//@close"><xsl:value-of select="."/></xsl:for-each>
2714
+ </xsl:variable>
2715
+ <length><xsl:value-of select="string-length(normalize-space(.)) + string-length($attributes)"/></length>
2716
+ </xsl:for-each>
2717
+ </xsl:variable>
2718
+ <xsl:variable name="maxLength">
2719
+ <!-- <xsl:for-each select="*[local-name()='dt']">
2720
+ <xsl:sort select="string-length(normalize-space(.))" data-type="number" order="descending"/>
2721
+ <xsl:if test="position() = 1">
2722
+ <xsl:value-of select="string-length(normalize-space(.))"/>
2723
+ </xsl:if>
2724
+ </xsl:for-each> -->
2725
+ <xsl:for-each select="xalan:nodeset($lengths)/length">
2726
+ <xsl:sort select="." data-type="number" order="descending"/>
2727
+ <xsl:if test="position() = 1">
2728
+ <xsl:value-of select="."/>
2729
+ </xsl:if>
2730
+ </xsl:for-each>
2731
+ </xsl:variable>
2732
+ <!-- <xsl:message>DEBUG:<xsl:value-of select="$maxLength"/></xsl:message> -->
2733
+ <xsl:value-of select="$maxLength"/>
2667
2734
  </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
2668
2735
  <xsl:param name="key_iso"/>
2669
2736
 
@@ -2802,6 +2869,7 @@
2802
2869
 
2803
2870
 
2804
2871
 
2872
+
2805
2873
 
2806
2874
  </xsl:variable>
2807
2875
  <xsl:variable name="font-size" select="normalize-space($_font-size)"/>
@@ -2815,6 +2883,10 @@
2815
2883
  </xsl:if>
2816
2884
  <xsl:apply-templates/>
2817
2885
  </fo:inline>
2886
+ </xsl:template><xsl:template match="*[local-name()='underline']">
2887
+ <fo:inline text-decoration="underline">
2888
+ <xsl:apply-templates/>
2889
+ </fo:inline>
2818
2890
  </xsl:template><xsl:template match="*[local-name()='del']">
2819
2891
  <fo:inline font-size="10pt" color="red" text-decoration="line-through">
2820
2892
  <xsl:apply-templates/>
@@ -2908,6 +2980,10 @@
2908
2980
  <xsl:param name="text" select="."/>
2909
2981
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
2910
2982
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| )','$1​')"/>
2983
+ </xsl:template><xsl:template name="add-zero-spaces-link-java">
2984
+ <xsl:param name="text" select="."/>
2985
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
2986
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |,)','$1​')"/>
2911
2987
  </xsl:template><xsl:template name="add-zero-spaces">
2912
2988
  <xsl:param name="text" select="."/>
2913
2989
  <xsl:variable name="zero-space-after-chars">-</xsl:variable>
@@ -3168,6 +3244,11 @@
3168
3244
  <!-- replace start and end spaces to non-break space -->
3169
3245
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
3170
3246
  </xsl:copy>
3247
+ </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml">
3248
+ <xsl:copy>
3249
+ <xsl:apply-templates select="@*|node()" mode="mathml"/>
3250
+ </xsl:copy>
3251
+ <mathml:mspace width="0.5ex"/>
3171
3252
  </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
3172
3253
  <xsl:variable name="target">
3173
3254
  <xsl:choose>
@@ -3189,7 +3270,10 @@
3189
3270
  <fo:basic-link external-destination="{@target}" fox:alt-text="{@target}">
3190
3271
  <xsl:choose>
3191
3272
  <xsl:when test="normalize-space(.) = ''">
3192
- <xsl:value-of select="$target"/>
3273
+ <!-- <xsl:value-of select="$target"/> -->
3274
+ <xsl:call-template name="add-zero-spaces-link-java">
3275
+ <xsl:with-param name="text" select="$target"/>
3276
+ </xsl:call-template>
3193
3277
  </xsl:when>
3194
3278
  <xsl:otherwise>
3195
3279
  <xsl:apply-templates/>
@@ -3408,7 +3492,7 @@
3408
3492
  </xsl:if> -->
3409
3493
  </fo:inline>
3410
3494
  </xsl:if>
3411
- </xsl:template><xsl:template match="*[local-name() = 'figure']">
3495
+ </xsl:template><xsl:template match="*[local-name() = 'figure']" name="figure">
3412
3496
  <fo:block-container id="{@id}">
3413
3497
 
3414
3498
  <fo:block>
@@ -3482,6 +3566,8 @@
3482
3566
  <xsl:variable name="bookmark-title_">
3483
3567
  <xsl:call-template name="getLangVersion">
3484
3568
  <xsl:with-param name="lang" select="@lang"/>
3569
+ <xsl:with-param name="doctype" select="@doctype"/>
3570
+ <xsl:with-param name="title" select="@title-part"/>
3485
3571
  </xsl:call-template>
3486
3572
  </xsl:variable>
3487
3573
  <xsl:choose>
@@ -3499,13 +3585,34 @@
3499
3585
  </xsl:choose>
3500
3586
  </fo:bookmark-title>
3501
3587
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3588
+
3589
+ <xsl:call-template name="insertFigureBookmarks">
3590
+ <xsl:with-param name="contents" select="contents"/>
3591
+ </xsl:call-template>
3592
+
3593
+ <xsl:call-template name="insertTableBookmarks">
3594
+ <xsl:with-param name="contents" select="contents"/>
3595
+ <xsl:with-param name="lang" select="@lang"/>
3596
+ </xsl:call-template>
3597
+
3502
3598
  </fo:bookmark>
3503
3599
 
3504
3600
  </xsl:for-each>
3505
3601
  </xsl:when>
3506
3602
  <xsl:otherwise>
3507
3603
  <xsl:for-each select="xalan:nodeset($contents)/doc">
3604
+
3508
3605
  <xsl:apply-templates select="contents/item" mode="bookmark"/>
3606
+
3607
+ <xsl:call-template name="insertFigureBookmarks">
3608
+ <xsl:with-param name="contents" select="contents"/>
3609
+ </xsl:call-template>
3610
+
3611
+ <xsl:call-template name="insertTableBookmarks">
3612
+ <xsl:with-param name="contents" select="contents"/>
3613
+ <xsl:with-param name="lang" select="@lang"/>
3614
+ </xsl:call-template>
3615
+
3509
3616
  </xsl:for-each>
3510
3617
  </xsl:otherwise>
3511
3618
  </xsl:choose>
@@ -3524,8 +3631,44 @@
3524
3631
 
3525
3632
  </fo:bookmark-tree>
3526
3633
  </xsl:if>
3634
+ </xsl:template><xsl:template name="insertFigureBookmarks">
3635
+ <xsl:param name="contents"/>
3636
+ <xsl:if test="xalan:nodeset($contents)/figure">
3637
+ <fo:bookmark internal-destination="{xalan:nodeset($contents)/figure[1]/@id}" starting-state="hide">
3638
+ <fo:bookmark-title>Figures</fo:bookmark-title>
3639
+ <xsl:for-each select="xalan:nodeset($contents)/figure">
3640
+ <fo:bookmark internal-destination="{@id}">
3641
+ <fo:bookmark-title>
3642
+ <xsl:value-of select="normalize-space(title)"/>
3643
+ </fo:bookmark-title>
3644
+ </fo:bookmark>
3645
+ </xsl:for-each>
3646
+ </fo:bookmark>
3647
+ </xsl:if>
3648
+ </xsl:template><xsl:template name="insertTableBookmarks">
3649
+ <xsl:param name="contents"/>
3650
+ <xsl:param name="lang"/>
3651
+ <xsl:if test="xalan:nodeset($contents)/table">
3652
+ <fo:bookmark internal-destination="{xalan:nodeset($contents)/table[1]/@id}" starting-state="hide">
3653
+ <fo:bookmark-title>
3654
+ <xsl:choose>
3655
+ <xsl:when test="$lang = 'fr'">Tableaux</xsl:when>
3656
+ <xsl:otherwise>Tables</xsl:otherwise>
3657
+ </xsl:choose>
3658
+ </fo:bookmark-title>
3659
+ <xsl:for-each select="xalan:nodeset($contents)/table">
3660
+ <fo:bookmark internal-destination="{@id}">
3661
+ <fo:bookmark-title>
3662
+ <xsl:value-of select="normalize-space(title)"/>
3663
+ </fo:bookmark-title>
3664
+ </fo:bookmark>
3665
+ </xsl:for-each>
3666
+ </fo:bookmark>
3667
+ </xsl:if>
3527
3668
  </xsl:template><xsl:template name="getLangVersion">
3528
3669
  <xsl:param name="lang"/>
3670
+ <xsl:param name="doctype" select="''"/>
3671
+ <xsl:param name="title" select="''"/>
3529
3672
  <xsl:choose>
3530
3673
  <xsl:when test="$lang = 'en'">
3531
3674
 
@@ -3561,6 +3704,12 @@
3561
3704
  <!-- <xsl:text> </xsl:text> -->
3562
3705
  </xsl:template><xsl:template name="getSection">
3563
3706
  <xsl:value-of select="*[local-name() = 'title']/*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
3707
+ <!--
3708
+ <xsl:for-each select="*[local-name() = 'title']/*[local-name() = 'tab'][1]/preceding-sibling::node()">
3709
+ <xsl:value-of select="."/>
3710
+ </xsl:for-each>
3711
+ -->
3712
+
3564
3713
  </xsl:template><xsl:template name="getName">
3565
3714
  <xsl:choose>
3566
3715
  <xsl:when test="*[local-name() = 'title']/*[local-name() = 'tab']">
@@ -3613,6 +3762,12 @@
3613
3762
  <xsl:copy>
3614
3763
  <xsl:apply-templates mode="contents_item"/>
3615
3764
  </xsl:copy>
3765
+ </xsl:template><xsl:template match="*[local-name() = 'em']" mode="contents_item">
3766
+ <xsl:copy>
3767
+ <xsl:apply-templates mode="contents_item"/>
3768
+ </xsl:copy>
3769
+ </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="contents_item">
3770
+ <xsl:copy-of select="."/>
3616
3771
  </xsl:template><xsl:template match="*[local-name() = 'br']" mode="contents_item">
3617
3772
  <xsl:text> </xsl:text>
3618
3773
  </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
@@ -3638,6 +3793,7 @@
3638
3793
 
3639
3794
 
3640
3795
 
3796
+
3641
3797
 
3642
3798
 
3643
3799
 
@@ -4010,10 +4166,13 @@
4010
4166
  </xsl:if>
4011
4167
  </xsl:if>
4012
4168
 
4169
+
4013
4170
  <fo:block-container margin-left="0mm">
4014
4171
 
4015
4172
  <fo:block xsl:use-attribute-sets="quote-style">
4016
- <xsl:apply-templates select=".//*[local-name() = 'p']"/>
4173
+ <!-- <xsl:apply-templates select=".//*[local-name() = 'p']"/> -->
4174
+
4175
+ <xsl:apply-templates select="./node()[not(local-name() = 'author') and not(local-name() = 'source')]"/> <!-- process all nested nodes, except author and source -->
4017
4176
  </fo:block>
4018
4177
  <xsl:if test="*[local-name() = 'author'] or *[local-name() = 'source']">
4019
4178
  <fo:block xsl:use-attribute-sets="quote-source-style">
@@ -4166,6 +4325,7 @@
4166
4325
 
4167
4326
 
4168
4327
 
4328
+
4169
4329
 
4170
4330
 
4171
4331
 
@@ -4182,7 +4342,7 @@
4182
4342
 
4183
4343
 
4184
4344
 
4185
- </xsl:template><xsl:template match="/*/*[local-name() = 'preface']/*" priority="2">
4345
+ </xsl:template><xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
4186
4346
  <fo:block break-after="page"/>
4187
4347
  <fo:block>
4188
4348
  <xsl:call-template name="setId"/>
@@ -4190,7 +4350,8 @@
4190
4350
  </fo:block>
4191
4351
  </xsl:template><xsl:template match="*[local-name() = 'clause']">
4192
4352
  <fo:block>
4193
- <xsl:call-template name="setId"/>
4353
+ <xsl:call-template name="setId"/>
4354
+
4194
4355
 
4195
4356
  <xsl:apply-templates/>
4196
4357
  </fo:block>
@@ -4341,6 +4502,8 @@
4341
4502
  <xsl:value-of select="translate(.,'. ','')"/>
4342
4503
  </xsl:template><xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip">
4343
4504
  <xsl:value-of select="substring(.,1,1)"/>
4505
+ </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title">
4506
+ <fo:inline><xsl:apply-templates/></fo:inline>
4344
4507
  </xsl:template><xsl:template name="convertDate">
4345
4508
  <xsl:param name="date"/>
4346
4509
  <xsl:param name="format" select="'short'"/>
@@ -4365,6 +4528,57 @@
4365
4528
  </xsl:variable>
4366
4529
  <xsl:variable name="result">
4367
4530
  <xsl:choose>
4531
+ <xsl:when test="$format = 'ddMMyyyy'">
4532
+ <xsl:if test="$day != ''"><xsl:value-of select="number($day)"/></xsl:if>
4533
+ <xsl:text> </xsl:text>
4534
+ <xsl:value-of select="normalize-space(concat($monthStr, ' ' , $year))"/>
4535
+ </xsl:when>
4536
+ <xsl:when test="$format = 'ddMM'">
4537
+ <xsl:if test="$day != ''"><xsl:value-of select="number($day)"/></xsl:if>
4538
+ <xsl:text> </xsl:text><xsl:value-of select="$monthStr"/>
4539
+ </xsl:when>
4540
+ <xsl:when test="$format = 'short' or $day = ''">
4541
+ <xsl:value-of select="normalize-space(concat($monthStr, ' ', $year))"/>
4542
+ </xsl:when>
4543
+ <xsl:otherwise>
4544
+ <xsl:value-of select="normalize-space(concat($monthStr, ' ', $day, ', ' , $year))"/>
4545
+ </xsl:otherwise>
4546
+ </xsl:choose>
4547
+ </xsl:variable>
4548
+ <xsl:value-of select="$result"/>
4549
+ </xsl:template><xsl:template name="convertDateLocalized">
4550
+ <xsl:param name="date"/>
4551
+ <xsl:param name="format" select="'short'"/>
4552
+ <xsl:variable name="year" select="substring($date, 1, 4)"/>
4553
+ <xsl:variable name="month" select="substring($date, 6, 2)"/>
4554
+ <xsl:variable name="day" select="substring($date, 9, 2)"/>
4555
+ <xsl:variable name="monthStr">
4556
+ <xsl:choose>
4557
+ <xsl:when test="$month = '01'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_january</xsl:with-param></xsl:call-template></xsl:when>
4558
+ <xsl:when test="$month = '02'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_february</xsl:with-param></xsl:call-template></xsl:when>
4559
+ <xsl:when test="$month = '03'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_march</xsl:with-param></xsl:call-template></xsl:when>
4560
+ <xsl:when test="$month = '04'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_april</xsl:with-param></xsl:call-template></xsl:when>
4561
+ <xsl:when test="$month = '05'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_may</xsl:with-param></xsl:call-template></xsl:when>
4562
+ <xsl:when test="$month = '06'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_june</xsl:with-param></xsl:call-template></xsl:when>
4563
+ <xsl:when test="$month = '07'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_july</xsl:with-param></xsl:call-template></xsl:when>
4564
+ <xsl:when test="$month = '08'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_august</xsl:with-param></xsl:call-template></xsl:when>
4565
+ <xsl:when test="$month = '09'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_september</xsl:with-param></xsl:call-template></xsl:when>
4566
+ <xsl:when test="$month = '10'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_october</xsl:with-param></xsl:call-template></xsl:when>
4567
+ <xsl:when test="$month = '11'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_november</xsl:with-param></xsl:call-template></xsl:when>
4568
+ <xsl:when test="$month = '12'"><xsl:call-template name="getLocalizedString"><xsl:with-param name="key">month_december</xsl:with-param></xsl:call-template></xsl:when>
4569
+ </xsl:choose>
4570
+ </xsl:variable>
4571
+ <xsl:variable name="result">
4572
+ <xsl:choose>
4573
+ <xsl:when test="$format = 'ddMMyyyy'">
4574
+ <xsl:if test="$day != ''"><xsl:value-of select="number($day)"/></xsl:if>
4575
+ <xsl:text> </xsl:text>
4576
+ <xsl:value-of select="normalize-space(concat($monthStr, ' ' , $year))"/>
4577
+ </xsl:when>
4578
+ <xsl:when test="$format = 'ddMM'">
4579
+ <xsl:if test="$day != ''"><xsl:value-of select="number($day)"/></xsl:if>
4580
+ <xsl:text> </xsl:text><xsl:value-of select="$monthStr"/>
4581
+ </xsl:when>
4368
4582
  <xsl:when test="$format = 'short' or $day = ''">
4369
4583
  <xsl:value-of select="normalize-space(concat($monthStr, ' ', $year))"/>
4370
4584
  </xsl:when>
@@ -4380,7 +4594,7 @@
4380
4594
  <xsl:param name="charDelim" select="', '"/>
4381
4595
  <xsl:choose>
4382
4596
  <xsl:when test="$sorting = 'true' or $sorting = 'yes'">
4383
- <xsl:for-each select="/*/*[local-name() = 'bibdata']//*[local-name() = 'keyword']">
4597
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']//*[local-name() = 'keyword']">
4384
4598
  <xsl:sort data-type="text" order="ascending"/>
4385
4599
  <xsl:call-template name="insertKeyword">
4386
4600
  <xsl:with-param name="charAtEnd" select="$charAtEnd"/>
@@ -4389,7 +4603,7 @@
4389
4603
  </xsl:for-each>
4390
4604
  </xsl:when>
4391
4605
  <xsl:otherwise>
4392
- <xsl:for-each select="/*/*[local-name() = 'bibdata']//*[local-name() = 'keyword']">
4606
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']//*[local-name() = 'keyword']">
4393
4607
  <xsl:call-template name="insertKeyword">
4394
4608
  <xsl:with-param name="charAtEnd" select="$charAtEnd"/>
4395
4609
  <xsl:with-param name="charDelim" select="$charDelim"/>
@@ -4406,6 +4620,9 @@
4406
4620
  <xsl:otherwise><xsl:value-of select="$charAtEnd"/></xsl:otherwise>
4407
4621
  </xsl:choose>
4408
4622
  </xsl:template><xsl:template name="addPDFUAmeta">
4623
+ <xsl:variable name="lang">
4624
+ <xsl:call-template name="getLang"/>
4625
+ </xsl:variable>
4409
4626
  <fo:declarations>
4410
4627
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
4411
4628
  <pdf:dictionary type="normal" key="ViewerPreferences">
@@ -4418,13 +4635,16 @@
4418
4635
  <!-- Dublin Core properties go here -->
4419
4636
  <dc:title>
4420
4637
  <xsl:variable name="title">
4421
-
4422
- <xsl:value-of select="/*/*[local-name() = 'bibdata']/*[local-name() = 'title'][@language = 'en' and @type = 'main']"/>
4423
-
4424
-
4425
-
4426
-
4427
-
4638
+ <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']">
4639
+
4640
+ <xsl:value-of select="*[local-name() = 'title'][@language = $lang and @type = 'main']"/>
4641
+
4642
+
4643
+
4644
+
4645
+
4646
+
4647
+ </xsl:for-each>
4428
4648
  </xsl:variable>
4429
4649
  <xsl:choose>
4430
4650
  <xsl:when test="normalize-space($title) != ''">
@@ -4436,17 +4656,21 @@
4436
4656
  </xsl:choose>
4437
4657
  </dc:title>
4438
4658
  <dc:creator>
4439
-
4440
-
4441
-
4442
- </dc:creator>
4443
- <dc:description>
4444
- <xsl:variable name="abstract">
4659
+ <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']">
4660
+
4661
+ <xsl:for-each select="*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']">
4662
+ <xsl:value-of select="*[local-name() = 'organization']/*[local-name() = 'name']"/>
4663
+ <xsl:if test="position() != last()">; </xsl:if>
4664
+ </xsl:for-each>
4445
4665
 
4446
4666
 
4447
4667
 
4448
- <xsl:copy-of select="/*/*[local-name() = 'preface']/*[local-name() = 'abstract']//text()"/>
4668
+ </xsl:for-each>
4669
+ </dc:creator>
4670
+ <dc:description>
4671
+ <xsl:variable name="abstract">
4449
4672
 
4673
+ <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*[local-name() = 'abstract']//text()"/>
4450
4674
 
4451
4675
 
4452
4676
  </xsl:variable>
@@ -4559,6 +4783,7 @@
4559
4783
 
4560
4784
 
4561
4785
 
4786
+
4562
4787
  </xsl:variable>
4563
4788
  <xsl:if test="$documentNS != $XSLNS">
4564
4789
  <xsl:message>[WARNING]: Document namespace: '<xsl:value-of select="$documentNS"/>' doesn't equal to xslt namespace '<xsl:value-of select="$XSLNS"/>'</xsl:message>
@@ -4618,6 +4843,11 @@
4618
4843
  <xsl:call-template name="getLang"/>
4619
4844
  </xsl:variable>
4620
4845
 
4621
- <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
4846
+ <xsl:choose>
4847
+ <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]">
4848
+ <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/>
4849
+ </xsl:when>
4850
+ <xsl:otherwise><xsl:value-of select="$key"/></xsl:otherwise>
4851
+ </xsl:choose>
4622
4852
 
4623
4853
  </xsl:template></xsl:stylesheet>