Skip to content

Commit ddcafb2

Browse files
Merge pull request #679 from metanorma/table_width_fix
table width algorithm performance optimization, metanorma/mn2pdf#245
2 parents 2147537 + 36b61fa commit ddcafb2

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

xslt_src/common.xsl

+27-4
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132

133133
<xsl:variable name="isApplyAutolayoutAlgorithm_">
134134
<xsl:choose>
135-
<xsl:when test="$namespace = 'bipm' or $namespace = 'bsi' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'iec' or $namespace = 'ieee' or $namespace = 'iho' or $namespace = 'iso' or $namespace = 'itu' or $namespace = 'jcgm' or $namespace = 'jis' or $namespace = 'm3d' or $namespace = 'mpfd' or $namespace = 'nist-sp' or $namespace = 'nist-cswp' or $namespace = 'ogc' or $namespace = 'ogc-white-paper' or $namespace = 'rsd' or $namespace = 'unece' or $namespace = 'unece-rec'">true</xsl:when>
136-
<xsl:when test="$namespace = 'plateau'">skip</xsl:when>
135+
<xsl:when test="$namespace = 'bipm' or $namespace = 'bsi' or $namespace = 'csa' or $namespace = 'csd' or $namespace = 'iec' or $namespace = 'ieee' or $namespace = 'iho' or $namespace = 'iso' or $namespace = 'itu' or $namespace = 'jcgm' or $namespace = 'jis' or $namespace = 'm3d' or $namespace = 'mpfd' or $namespace = 'nist-sp' or $namespace = 'nist-cswp' or $namespace = 'ogc' or $namespace = 'ogc-white-paper' or $namespace = 'plateau' or $namespace = 'rsd' or $namespace = 'unece' or $namespace = 'unece-rec'">true</xsl:when>
136+
<!-- <xsl:when test="$namespace = 'plateau'">skip</xsl:when> -->
137137
<xsl:otherwise>false</xsl:otherwise>
138138
</xsl:choose>
139139
</xsl:variable>
@@ -7155,14 +7155,20 @@
71557155
</xsl:for-each>
71567156
</xsl:template>
71577157

7158-
<xsl:param name="table_only_with_id"/><!-- Example: table1, for table auto-layout algorithm -->
7158+
<!-- for table auto-layout algorithm -->
7159+
<xsl:param name="table_only_with_id"/> <!-- Example: 'table1' -->
7160+
<xsl:param name="table_only_with_ids"/> <!-- Example: 'table1 table2 table3 ' -->
71597161

71607162
<xsl:template match="*[local-name()='table']" priority="2">
71617163
<xsl:choose>
71627164
<xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
71637165
<xsl:call-template name="table"/>
71647166
</xsl:when>
71657167
<xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
7168+
<xsl:when test="$table_only_with_ids != '' and contains($table_only_with_ids, concat(@id, ' '))">
7169+
<xsl:call-template name="table"/>
7170+
</xsl:when>
7171+
<xsl:when test="$table_only_with_ids != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
71667172
<xsl:otherwise>
71677173
<xsl:call-template name="table"/>
71687174
</xsl:otherwise>
@@ -9316,6 +9322,10 @@
93169322
<xsl:call-template name="dl"/>
93179323
</xsl:when>
93189324
<xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
9325+
<xsl:when test="$table_only_with_ids != '' and contains($table_only_with_ids, concat(@id, ' '))">
9326+
<xsl:call-template name="dl"/>
9327+
</xsl:when>
9328+
<xsl:when test="$table_only_with_ids != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
93199329
<xsl:otherwise>
93209330
<xsl:call-template name="dl"/>
93219331
</xsl:otherwise>
@@ -9550,7 +9560,7 @@
95509560

95519561
<!-- create virtual html table for dl/[dt and dd] -->
95529562
<xsl:variable name="simple-table">
9553-
9563+
<!-- initial='<xsl:copy-of select="."/>' -->
95549564
<xsl:variable name="dl_table">
95559565
<tbody>
95569566
<xsl:apply-templates mode="dl_if">
@@ -18087,11 +18097,24 @@
1808718097
<!-- optimization: remove clause if table_only_with_id isn't empty and clause doesn't contain table or dl with table_only_with_id -->
1808818098
<xsl:template match="*[local-name() = 'clause' or local-name() = 'p' or local-name() = 'definitions' or local-name() = 'annex']" mode="update_xml_step1">
1808918099
<xsl:choose>
18100+
<xsl:when test="($table_only_with_id != '' or $table_only_with_ids != '') and local-name() = 'p' and (ancestor::*[local-name() = 'table' or local-name() = 'dl' or local-name() = 'toc'])">
18101+
<xsl:copy>
18102+
<xsl:copy-of select="@*"/>
18103+
<xsl:apply-templates mode="update_xml_step1"/>
18104+
</xsl:copy>
18105+
</xsl:when>
18106+
<!-- for table auto-layout algorithm -->
1809018107
<xsl:when test="$table_only_with_id != '' and not(.//*[local-name() = 'table' or local-name() = 'dl'][@id = $table_only_with_id])">
1809118108
<xsl:copy>
1809218109
<xsl:copy-of select="@*"/>
1809318110
</xsl:copy>
1809418111
</xsl:when>
18112+
<!-- for table auto-layout algorithm -->
18113+
<xsl:when test="$table_only_with_ids != '' and not(.//*[local-name() = 'table' or local-name() = 'dl'][contains($table_only_with_ids, concat(@id, ' '))])">
18114+
<xsl:copy>
18115+
<xsl:copy-of select="@*"/>
18116+
</xsl:copy>
18117+
</xsl:when>
1809518118
<xsl:otherwise>
1809618119
<xsl:copy>
1809718120
<xsl:copy-of select="@*"/>

0 commit comments

Comments
 (0)