|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
2 |
| -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:iso="http://riboseinc.com/isoxml" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" version="1.0"> |
| 2 | +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:iso="http://riboseinc.com/isoxml" xmlns:itu="https://open.ribose.com/standards/itu" xmlns:nist="http://www.nist.gov/metanorma" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:xalan="http://xml.apache.org/xalan" version="1.0"> |
3 | 3 |
|
4 | 4 |
|
5 | 5 | <xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
|
|
23 | 23 | <xsl:call-template name="add-zero-spaces"/>
|
24 | 24 | </xsl:template>
|
25 | 25 |
|
| 26 | + |
| 27 | + |
26 | 28 | <xsl:template match="*[local-name()='table']">
|
27 | 29 |
|
28 | 30 | <xsl:variable name="simple-table">
|
|
32 | 34 | </xsl:variable>
|
33 | 35 |
|
34 | 36 | <!-- DEBUG -->
|
35 |
| - <!-- SourceTable=<xsl:copy-of select="current()"/>EndSourceTable |
36 |
| - Simpletable=<xsl:copy-of select="$simple-table"/>EndSimpltable --> |
| 37 | + <!-- SourceTable=<xsl:copy-of select="current()"/>EndSourceTable --> |
| 38 | + <!-- Simpletable=<xsl:copy-of select="$simple-table"/>EndSimpltable --> |
37 | 39 |
|
38 | 40 | <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
|
39 | 41 | <xsl:if test="$namespace = 'itu'">
|
|
53 | 55 | <xsl:text>Table </xsl:text>
|
54 | 56 | <xsl:choose>
|
55 | 57 | <xsl:when test="ancestor::*[local-name()='executivesummary']"> <!-- NIST -->
|
56 |
| - <xsl:text>ES-</xsl:text><xsl:number format="1" count="*[local-name()='executivesummary']//*[local-name()='table']"/> |
| 58 | + <xsl:text>ES-</xsl:text><xsl:number format="1" count="*[local-name()='executivesummary']//*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true']"/> |
57 | 59 | </xsl:when>
|
58 | 60 | <xsl:when test="ancestor::*[local-name()='annex']">
|
59 | 61 | <xsl:choose>
|
60 | 62 | <xsl:when test="$namespace = 'iso'">
|
61 | 63 | <xsl:number format="A." count="*[local-name()='annex']"/><xsl:number format="1"/>
|
62 | 64 | </xsl:when>
|
| 65 | + <xsl:when test="$namespace = 'itu'"> |
| 66 | + <xsl:choose> |
| 67 | + <xsl:when test="ancestor::itu:annex[@obligation = 'informative']"> |
| 68 | + <xsl:variable name="annex-id" select="ancestor::itu:annex/@id"/> |
| 69 | + <!-- Table in Appendix --> |
| 70 | + <xsl:number format="I-" count="itu:annex[@obligation = 'informative']"/> |
| 71 | + <xsl:number format="1" level="any" count="itu:table[(not(@unnumbered) or @unnumbered != 'true') and ancestor::itu:annex[@id = $annex-id]]"/> |
| 72 | + </xsl:when> |
| 73 | + <!-- Table in Annex --> |
| 74 | + <xsl:when test="ancestor::itu:annex[not(@obligation) or @obligation != 'informative']"> |
| 75 | + <xsl:variable name="annex-id" select="ancestor::itu:annex/@id"/> |
| 76 | + <xsl:number format="A-" count="itu:annex[not(@obligation) or @obligation != 'informative']"/> |
| 77 | + <xsl:number format="1" level="any" count="itu:table[(not(@unnumbered) or @unnumbered != 'true') and ancestor::itu:annex[@id = $annex-id]]"/> |
| 78 | + </xsl:when> |
| 79 | + </xsl:choose> |
| 80 | + </xsl:when> |
63 | 81 | <xsl:when test="$namespace = 'nist'">
|
64 | 82 | <xsl:variable name="annex-id" select="ancestor::*[local-name()='annex']/@id"/>
|
65 | 83 | <xsl:number format="A-" count="*[local-name()='annex']"/>
|
66 |
| - <xsl:number format="1" level="any" count="*[local-name()='table'][ancestor::*[local-name()='annex'][@id = $annex-id]]"/> |
| 84 | + <xsl:number format="1" level="any" count="*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true'][ancestor::*[local-name()='annex'][@id = $annex-id]]"/> |
67 | 85 | </xsl:when>
|
68 | 86 | <xsl:otherwise> <!-- for itu -->
|
69 |
| - <xsl:number format="A-1" level="multiple" count="*[local-name()='annex'] | *[local-name()='table'] "/> |
| 87 | + <xsl:number format="A-1" level="multiple" count="*[local-name()='annex'] | *[local-name()='table'][not(@unnumbered) or @unnumbered != 'true'] "/> |
70 | 88 | </xsl:otherwise>
|
71 | 89 | </xsl:choose>
|
72 | 90 | </xsl:when>
|
73 | 91 | <xsl:otherwise>
|
74 | 92 | <!-- <xsl:number format="1"/> -->
|
75 | 93 | <xsl:number format="A." count="*[local-name()='annex']"/>
|
76 |
| - <xsl:number format="1" level="any" count="*[local-name()='sections']//*[local-name()='table']"/> |
| 94 | + <xsl:number format="1" level="any" count="*[local-name()='sections']//*[local-name()='table'][not(@unnumbered) or @unnumbered != 'true']"/> |
77 | 95 | </xsl:otherwise>
|
78 | 96 | </xsl:choose>
|
79 | 97 | <xsl:if test="*[local-name()='name']">
|
|
119 | 137 | </xsl:call-template>
|
120 | 138 | </xsl:variable>
|
121 | 139 |
|
122 |
| - |
123 |
| - <!-- colwidthsNew=<xsl:copy-of select="$colwidths"/> |
124 |
| - colwidthsOld=<xsl:copy-of select="$colwidths2"/> --> |
| 140 | + <!-- cols-count=<xsl:copy-of select="$cols-count"/> |
| 141 | + colwidthsNew=<xsl:copy-of select="$colwidths"/> |
| 142 | + colwidthsOld=<xsl:copy-of select="$colwidths2"/>z --> |
125 | 143 |
|
126 | 144 | <xsl:variable name="margin-left">
|
127 | 145 | <xsl:choose>
|
|
131 | 149 | </xsl:variable>
|
132 | 150 |
|
133 | 151 | <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm">
|
| 152 | + <xsl:if test="$namespace = 'itu' or $namespace = 'nist'"> |
| 153 | + <xsl:attribute name="space-after">6pt</xsl:attribute> |
| 154 | + </xsl:if> |
134 | 155 | <fo:table id="{@id}" table-layout="fixed" width="100%" margin-left="{$margin-left}mm" margin-right="{$margin-left}mm">
|
135 | 156 | <xsl:choose>
|
136 | 157 | <xsl:when test="$namespace = 'nist' and (ancestor::*[local-name()='annex'] or ancestor::*[local-name()='preface'])">
|
|
157 | 178 | </xsl:for-each>
|
158 | 179 | <xsl:apply-templates />
|
159 | 180 | </fo:table>
|
160 |
| - <xsl:if test="$namespace = 'itu' or $namespace = 'nist'"> |
| 181 | + <!-- <xsl:if test="$namespace = 'itu' or $namespace = 'nist'"> |
161 | 182 | <fo:block space-after="6pt"> </fo:block>
|
162 |
| - </xsl:if> |
| 183 | + </xsl:if> --> |
163 | 184 | </fo:block-container>
|
164 | 185 | </xsl:template>
|
165 | 186 |
|
|
383 | 404 |
|
384 | 405 | <xsl:template match="*[local-name()='th']">
|
385 | 406 | <fo:table-cell text-align="{@align}" border="solid black 1pt" padding-left="1mm" display-align="center">
|
| 407 | + <xsl:if test="$namespace = 'iso'"> |
| 408 | + <xsl:attribute name="padding-top">1mm</xsl:attribute> |
| 409 | + </xsl:if> |
386 | 410 | <xsl:if test="$namespace = 'nist'">
|
387 | 411 | <xsl:attribute name="text-align">center</xsl:attribute>
|
388 | 412 | <xsl:attribute name="background-color">black</xsl:attribute>
|
|
407 | 431 |
|
408 | 432 | <xsl:template match="*[local-name()='td']">
|
409 | 433 | <fo:table-cell text-align="{@align}" display-align="center" border="solid black 1pt" padding-left="1mm">
|
| 434 | + <xsl:if test="$namespace = 'iso' and ancestor::*[local-name() = 'thead']"> |
| 435 | + <xsl:attribute name="padding-top">0.5mm</xsl:attribute> |
| 436 | + </xsl:if> |
410 | 437 | <xsl:if test="$namespace = 'iso' and ancestor::*[local-name() = 'tfoot']">
|
411 | 438 | <xsl:attribute name="border">solid black 0</xsl:attribute>
|
412 | 439 | </xsl:if>
|
|
561 | 588 | <!-- *[local-name()='table']// -->
|
562 | 589 | <xsl:template match="*[local-name()='fn']">
|
563 | 590 | <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
|
564 |
| - <fo:inline font-size="80%" keep-with-previous.within-line="always" vertical-align="super"> |
| 591 | + <fo:inline font-size="80%" keep-with-previous.within-line="always"> |
| 592 | + <xsl:if test="$namespace = 'iso' and ancestor::*[local-name()='td']"> |
| 593 | + <xsl:attribute name="font-weight">normal</xsl:attribute> |
| 594 | + <!-- <xsl:attribute name="alignment-baseline">hanging</xsl:attribute> --> |
| 595 | + <xsl:attribute name="baseline-shift">15%</xsl:attribute> |
| 596 | + </xsl:if> |
565 | 597 | <xsl:if test="$namespace = 'itu' or $namespace = 'nist'">
|
| 598 | + <xsl:attribute name="vertical-align">super</xsl:attribute> |
566 | 599 | <xsl:attribute name="color">blue</xsl:attribute>
|
567 | 600 | </xsl:if>
|
568 | 601 | <xsl:if test="$namespace = 'nist'">
|
|
600 | 633 | <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
|
601 | 634 | </fo:block>
|
602 | 635 | </xsl:when>
|
603 |
| - <xsl:when test="$parent = 'formula'"> |
| 636 | + <xsl:when test="$parent = 'formula'"> <!-- a few components --> |
604 | 637 | <fo:block margin-bottom="12pt">
|
605 | 638 | <xsl:if test="$namespace = 'iso'">
|
606 |
| - <xsl:attribute name="margin-bottom">0</xsl:attribute> |
| 639 | + <xsl:attribute name="margin-bottom">6pt</xsl:attribute> |
607 | 640 | </xsl:if>
|
608 | 641 | <xsl:text>where</xsl:text>
|
609 | 642 | </fo:block>
|
|
619 | 652 | </xsl:when>
|
620 | 653 | </xsl:choose>
|
621 | 654 |
|
| 655 | + <!-- a few components --> |
622 | 656 | <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
|
623 |
| - |
624 | 657 | <fo:block>
|
| 658 | + <xsl:if test="$namespace ='iso' and $parent = 'formula'"> |
| 659 | + <xsl:attribute name="margin-left">4mm</xsl:attribute> |
| 660 | + </xsl:if> |
| 661 | + <xsl:if test="$namespace = 'itu' and local-name(..) = 'li'"> |
| 662 | + <xsl:attribute name="margin-left">-4mm</xsl:attribute> |
| 663 | + </xsl:if> |
625 | 664 | <xsl:if test="$namespace = 'nist' and not(.//*[local-name()='dt']//*[local-name()='stem'])">
|
626 | 665 | <xsl:attribute name="margin-left">5mm</xsl:attribute>
|
627 | 666 | </xsl:if>
|
628 | 667 | <fo:block>
|
629 | 668 | <xsl:if test="$namespace = 'nist' and not(.//*[local-name()='dt']//*[local-name()='stem'])">
|
630 | 669 | <xsl:attribute name="margin-left">-2.5mm</xsl:attribute>
|
631 | 670 | </xsl:if>
|
| 671 | + |
| 672 | + <!-- create virtual html table for dl/[dt and dd] --> |
| 673 | + <xsl:variable name="html-table"> |
| 674 | + <xsl:element name="{$namespace}:table"> |
| 675 | + <tbody> |
| 676 | + <xsl:apply-templates mode="dl"/> |
| 677 | + </tbody> |
| 678 | + </xsl:element> |
| 679 | + </xsl:variable> |
| 680 | + |
| 681 | + <xsl:variable name="colwidths"> |
| 682 | + <xsl:call-template name="calculate-column-widths"> |
| 683 | + <xsl:with-param name="cols-count" select="2"/> |
| 684 | + <xsl:with-param name="table" select="$html-table"/> |
| 685 | + </xsl:call-template> |
| 686 | + </xsl:variable> |
| 687 | + <!-- colwidths=<xsl:value-of select="$colwidths"/> --> |
| 688 | + |
632 | 689 | <fo:table width="95%" table-layout="fixed">
|
633 | 690 | <xsl:if test="$key_iso = 'true'">
|
634 | 691 | <xsl:attribute name="font-size">10pt</xsl:attribute>
|
635 | 692 | </xsl:if>
|
636 |
| - <!-- <xsl:if test="namespace = 'iso' and local-name(..) = 'figure'"> |
637 |
| - <xsl:attribute name="font-size">10pt</xsl:attribute> |
638 |
| - </xsl:if> --> |
| 693 | + <xsl:if test="$key_iso = 'true' and $parent = 'formula'"> |
| 694 | + <xsl:attribute name="font-size">11pt</xsl:attribute> |
| 695 | + </xsl:if> |
639 | 696 | <xsl:choose>
|
640 | 697 | <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
|
641 | 698 | <fo:table-column column-width="50%"/>
|
642 | 699 | <fo:table-column column-width="50%"/>
|
643 | 700 | </xsl:when>
|
644 | 701 | <xsl:otherwise>
|
645 |
| - <fo:table-column column-width="15%"/> |
646 |
| - <fo:table-column column-width="85%"/> |
| 702 | + <xsl:choose> |
| 703 | + <!-- <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] > 1.7"> |
| 704 | + <fo:table-column column-width="60%"/> |
| 705 | + <fo:table-column column-width="40%"/> |
| 706 | + </xsl:when> --> |
| 707 | + <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] > 1.3"> |
| 708 | + <fo:table-column column-width="50%"/> |
| 709 | + <fo:table-column column-width="50%"/> |
| 710 | + </xsl:when> |
| 711 | + <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] > 0.5"> |
| 712 | + <fo:table-column column-width="40%"/> |
| 713 | + <fo:table-column column-width="60%"/> |
| 714 | + </xsl:when> |
| 715 | + <xsl:otherwise> |
| 716 | + <xsl:for-each select="xalan:nodeset($colwidths)//column"> |
| 717 | + <xsl:choose> |
| 718 | + <xsl:when test=". = 1"> |
| 719 | + <fo:table-column column-width="proportional-column-width(2)"/> |
| 720 | + </xsl:when> |
| 721 | + <xsl:otherwise> |
| 722 | + <fo:table-column column-width="proportional-column-width({.})"/> |
| 723 | + </xsl:otherwise> |
| 724 | + </xsl:choose> |
| 725 | + </xsl:for-each> |
| 726 | + </xsl:otherwise> |
| 727 | + </xsl:choose> |
| 728 | + <!-- <fo:table-column column-width="15%"/> |
| 729 | + <fo:table-column column-width="85%"/> --> |
647 | 730 | </xsl:otherwise>
|
648 | 731 | </xsl:choose>
|
649 | 732 | <fo:table-body>
|
|
659 | 742 |
|
660 | 743 | <xsl:template match="*[local-name()='dl']/*[local-name()='note']">
|
661 | 744 | <xsl:param name="key_iso"/>
|
| 745 | + |
| 746 | + <!-- <tr> |
| 747 | + <td>NOTE</td> |
| 748 | + <td> |
| 749 | + <xsl:apply-templates /> |
| 750 | + </td> |
| 751 | + </tr> |
| 752 | + --> |
662 | 753 | <fo:table-row>
|
663 | 754 | <fo:table-cell>
|
664 | 755 | <fo:block margin-top="6pt">
|
|
676 | 767 | </fo:table-row>
|
677 | 768 | </xsl:template>
|
678 | 769 |
|
| 770 | + <xsl:template match="*[local-name()='dt']" mode="dl"> |
| 771 | + <tr> |
| 772 | + <td> |
| 773 | + <xsl:apply-templates /> |
| 774 | + </td> |
| 775 | + <td> |
| 776 | + <xsl:choose> |
| 777 | + <xsl:when test="$namespace = 'nist'"> |
| 778 | + <xsl:if test="local-name(*[1]) != 'stem'"> |
| 779 | + <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/> |
| 780 | + </xsl:if> |
| 781 | + </xsl:when> |
| 782 | + <xsl:otherwise> |
| 783 | + <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/> |
| 784 | + </xsl:otherwise> |
| 785 | + </xsl:choose> |
| 786 | + </td> |
| 787 | + </tr> |
| 788 | + <xsl:if test="local-name(*[1]) = 'stem' and $namespace = 'nist' "> |
| 789 | + <tr> |
| 790 | + <td> |
| 791 | + <xsl:text> </xsl:text> |
| 792 | + </td> |
| 793 | + <td> |
| 794 | + <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="dl_process"/> |
| 795 | + </td> |
| 796 | + </tr> |
| 797 | + </xsl:if> |
| 798 | + </xsl:template> |
| 799 | + |
679 | 800 | <xsl:template match="*[local-name()='dt']">
|
680 | 801 | <xsl:param name="key_iso"/>
|
| 802 | + |
681 | 803 | <fo:table-row>
|
682 | 804 | <fo:table-cell>
|
683 | 805 | <fo:block margin-top="6pt">
|
|
725 | 847 | </xsl:if>
|
726 | 848 | </xsl:template>
|
727 | 849 |
|
728 |
| - |
| 850 | + <xsl:template match="*[local-name()='dd']" mode="dl"/> |
| 851 | + <xsl:template match="*[local-name()='dd']" mode="dl_process"> |
| 852 | + <xsl:apply-templates /> |
| 853 | + </xsl:template> |
729 | 854 |
|
730 | 855 | <xsl:template match="*[local-name()='dd']"/>
|
731 | 856 | <xsl:template match="*[local-name()='dd']" mode="process">
|
|
897 | 1022 | <!-- Table normalization (colspan,rowspan processing for adding TDs) for column width calculation -->
|
898 | 1023 | <xsl:template name="getSimpleTable">
|
899 | 1024 | <xsl:variable name="simple-table">
|
900 |
| - <xsl:choose> |
901 |
| - <xsl:when test="current()//*[local-name()='th'][@colspan] or current()//*[local-name()='td'][@colspan] "> |
902 |
| - |
903 |
| - <!-- Step 1. colspan processing --> |
904 |
| - <xsl:variable name="simple-table-colspan"> |
905 |
| - <tbody> |
906 |
| - <xsl:apply-templates mode="simple-table-colspan"/> |
907 |
| - </tbody> |
908 |
| - </xsl:variable> |
909 |
| - |
910 |
| - <!-- Step 2. rowspan processing --> |
911 |
| - <xsl:variable name="simple-table-rowspan"> |
912 |
| - <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/> |
913 |
| - </xsl:variable> |
| 1025 | + |
| 1026 | + <!-- Step 1. colspan processing --> |
| 1027 | + <xsl:variable name="simple-table-colspan"> |
| 1028 | + <tbody> |
| 1029 | + <xsl:apply-templates mode="simple-table-colspan"/> |
| 1030 | + </tbody> |
| 1031 | + </xsl:variable> |
| 1032 | + |
| 1033 | + <!-- Step 2. rowspan processing --> |
| 1034 | + <xsl:variable name="simple-table-rowspan"> |
| 1035 | + <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/> |
| 1036 | + </xsl:variable> |
| 1037 | + |
| 1038 | + <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/> |
914 | 1039 |
|
915 |
| - <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/> |
| 1040 | + <!-- <xsl:choose> |
| 1041 | + <xsl:when test="current()//*[local-name()='th'][@colspan] or current()//*[local-name()='td'][@colspan] "> |
916 | 1042 |
|
917 | 1043 | </xsl:when>
|
918 | 1044 | <xsl:otherwise>
|
919 | 1045 | <xsl:copy-of select="current()"/>
|
920 | 1046 | </xsl:otherwise>
|
921 |
| - </xsl:choose> |
| 1047 | + </xsl:choose> --> |
922 | 1048 | </xsl:variable>
|
923 | 1049 | <xsl:copy-of select="$simple-table"/>
|
924 | 1050 | </xsl:template>
|
|
0 commit comments