Skip to content

Commit 032dee6

Browse files
Issue #34 and #35 fixed
1 parent 23872c3 commit 032dee6

File tree

3 files changed

+481
-511
lines changed

3 files changed

+481
-511
lines changed

xslt/common.xsl

+164-38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?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">
33

44

55
<xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
@@ -23,6 +23,8 @@
2323
<xsl:call-template name="add-zero-spaces"/>
2424
</xsl:template>
2525

26+
27+
2628
<xsl:template match="*[local-name()='table']">
2729

2830
<xsl:variable name="simple-table">
@@ -32,8 +34,8 @@
3234
</xsl:variable>
3335

3436
<!-- 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 -->
3739

3840
<!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
3941
<xsl:if test="$namespace = 'itu'">
@@ -53,27 +55,43 @@
5355
<xsl:text>Table </xsl:text>
5456
<xsl:choose>
5557
<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']"/>
5759
</xsl:when>
5860
<xsl:when test="ancestor::*[local-name()='annex']">
5961
<xsl:choose>
6062
<xsl:when test="$namespace = 'iso'">
6163
<xsl:number format="A." count="*[local-name()='annex']"/><xsl:number format="1"/>
6264
</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>
6381
<xsl:when test="$namespace = 'nist'">
6482
<xsl:variable name="annex-id" select="ancestor::*[local-name()='annex']/@id"/>
6583
<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]]"/>
6785
</xsl:when>
6886
<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'] "/>
7088
</xsl:otherwise>
7189
</xsl:choose>
7290
</xsl:when>
7391
<xsl:otherwise>
7492
<!-- <xsl:number format="1"/> -->
7593
<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']"/>
7795
</xsl:otherwise>
7896
</xsl:choose>
7997
<xsl:if test="*[local-name()='name']">
@@ -119,9 +137,9 @@
119137
</xsl:call-template>
120138
</xsl:variable>
121139

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 -->
125143

126144
<xsl:variable name="margin-left">
127145
<xsl:choose>
@@ -131,6 +149,9 @@
131149
</xsl:variable>
132150

133151
<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>
134155
<fo:table id="{@id}" table-layout="fixed" width="100%" margin-left="{$margin-left}mm" margin-right="{$margin-left}mm">
135156
<xsl:choose>
136157
<xsl:when test="$namespace = 'nist' and (ancestor::*[local-name()='annex'] or ancestor::*[local-name()='preface'])">
@@ -157,9 +178,9 @@
157178
</xsl:for-each>
158179
<xsl:apply-templates />
159180
</fo:table>
160-
<xsl:if test="$namespace = 'itu' or $namespace = 'nist'">
181+
<!-- <xsl:if test="$namespace = 'itu' or $namespace = 'nist'">
161182
<fo:block space-after="6pt">&#xA0;</fo:block>
162-
</xsl:if>
183+
</xsl:if> -->
163184
</fo:block-container>
164185
</xsl:template>
165186

@@ -383,6 +404,9 @@
383404

384405
<xsl:template match="*[local-name()='th']">
385406
<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>
386410
<xsl:if test="$namespace = 'nist'">
387411
<xsl:attribute name="text-align">center</xsl:attribute>
388412
<xsl:attribute name="background-color">black</xsl:attribute>
@@ -407,6 +431,9 @@
407431

408432
<xsl:template match="*[local-name()='td']">
409433
<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>
410437
<xsl:if test="$namespace = 'iso' and ancestor::*[local-name() = 'tfoot']">
411438
<xsl:attribute name="border">solid black 0</xsl:attribute>
412439
</xsl:if>
@@ -561,8 +588,14 @@
561588
<!-- *[local-name()='table']// -->
562589
<xsl:template match="*[local-name()='fn']">
563590
<!-- <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>
565597
<xsl:if test="$namespace = 'itu' or $namespace = 'nist'">
598+
<xsl:attribute name="vertical-align">super</xsl:attribute>
566599
<xsl:attribute name="color">blue</xsl:attribute>
567600
</xsl:if>
568601
<xsl:if test="$namespace = 'nist'">
@@ -600,10 +633,10 @@
600633
<xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
601634
</fo:block>
602635
</xsl:when>
603-
<xsl:when test="$parent = 'formula'">
636+
<xsl:when test="$parent = 'formula'"> <!-- a few components -->
604637
<fo:block margin-bottom="12pt">
605638
<xsl:if test="$namespace = 'iso'">
606-
<xsl:attribute name="margin-bottom">0</xsl:attribute>
639+
<xsl:attribute name="margin-bottom">6pt</xsl:attribute>
607640
</xsl:if>
608641
<xsl:text>where</xsl:text>
609642
</fo:block>
@@ -619,31 +652,81 @@
619652
</xsl:when>
620653
</xsl:choose>
621654

655+
<!-- a few components -->
622656
<xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
623-
624657
<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>
625664
<xsl:if test="$namespace = 'nist' and not(.//*[local-name()='dt']//*[local-name()='stem'])">
626665
<xsl:attribute name="margin-left">5mm</xsl:attribute>
627666
</xsl:if>
628667
<fo:block>
629668
<xsl:if test="$namespace = 'nist' and not(.//*[local-name()='dt']//*[local-name()='stem'])">
630669
<xsl:attribute name="margin-left">-2.5mm</xsl:attribute>
631670
</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+
632689
<fo:table width="95%" table-layout="fixed">
633690
<xsl:if test="$key_iso = 'true'">
634691
<xsl:attribute name="font-size">10pt</xsl:attribute>
635692
</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>
639696
<xsl:choose>
640697
<xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
641698
<fo:table-column column-width="50%"/>
642699
<fo:table-column column-width="50%"/>
643700
</xsl:when>
644701
<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] &gt; 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] &gt; 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] &gt; 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%"/> -->
647730
</xsl:otherwise>
648731
</xsl:choose>
649732
<fo:table-body>
@@ -659,6 +742,14 @@
659742

660743
<xsl:template match="*[local-name()='dl']/*[local-name()='note']">
661744
<xsl:param name="key_iso"/>
745+
746+
<!-- <tr>
747+
<td>NOTE</td>
748+
<td>
749+
<xsl:apply-templates />
750+
</td>
751+
</tr>
752+
-->
662753
<fo:table-row>
663754
<fo:table-cell>
664755
<fo:block margin-top="6pt">
@@ -676,8 +767,39 @@
676767
</fo:table-row>
677768
</xsl:template>
678769

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>&#xA0;</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+
679800
<xsl:template match="*[local-name()='dt']">
680801
<xsl:param name="key_iso"/>
802+
681803
<fo:table-row>
682804
<fo:table-cell>
683805
<fo:block margin-top="6pt">
@@ -725,7 +847,10 @@
725847
</xsl:if>
726848
</xsl:template>
727849

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>
729854

730855
<xsl:template match="*[local-name()='dd']"/>
731856
<xsl:template match="*[local-name()='dd']" mode="process">
@@ -897,28 +1022,29 @@
8971022
<!-- Table normalization (colspan,rowspan processing for adding TDs) for column width calculation -->
8981023
<xsl:template name="getSimpleTable">
8991024
<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)"/>
9141039

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] ">
9161042
9171043
</xsl:when>
9181044
<xsl:otherwise>
9191045
<xsl:copy-of select="current()"/>
9201046
</xsl:otherwise>
921-
</xsl:choose>
1047+
</xsl:choose> -->
9221048
</xsl:variable>
9231049
<xsl:copy-of select="$simple-table"/>
9241050
</xsl:template>

0 commit comments

Comments
 (0)