summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-09-27 15:18:25 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-10-01 15:11:14 +0200
commit059fff471b05c0e26589a1a621b467af5bc6a159 (patch)
tree0c4f1755dbc40f7b72dbb3438269706af176d33c
parent44c0b7416d1abee971ef0b4b17e67f6e391dd807 (diff)
filter: XHTML: make "calc-heading-digit" a little faster
Exporting OpenDocument-v1.3-csd01-part3-schema.odt to XHTML fails with: runtime error: file share/xslt/export/xhtml/body.xsl line 1404 element variable xsltApplySequenceConstructor: A potential infinite template recursion was detected. You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000). Unfortunately the document contains this many headings, and the calc-heading-digit computes the value by recursively looking at every preceding heading in the document, without TCO apparently... Try to improve this by using XPath to filter early the headings that are effectively ignored in the 3rd xsl:when case anyway: the ones with a level lower than the one for which the number is requested; this limits the recursive calls to the number of headings on the same level. Change-Id: Iddf5a91664402a57a0138731ddc9cebb06b0a126 Reviewed-on: https://gerrit.libreoffice.org/79720 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 86cca6b40ced4031dec4b708ac67b5cbe70cddf9) Reviewed-on: https://gerrit.libreoffice.org/79841 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--filter/source/xslt/odf2xhtml/export/xhtml/body.xsl11
1 files changed, 4 insertions, 7 deletions
diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
index c21840e1689e..63357d1e9b38 100644
--- a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
+++ b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
@@ -1401,9 +1401,10 @@
<xsl:param name="currentoutlineLevel"/>
<xsl:param name="i" select="1"/>
- <xsl:variable name="precedingoutlineLevel" select="preceding-sibling::text:h[$i]/@text:outline-level"/>
+ <xsl:variable name="precedingHeading" select="preceding-sibling::text:h[@text:outline-level &lt;= $currentoutlineLevel][$i]"/>
+ <xsl:variable name="precedingoutlineLevel" select="$precedingHeading/@text:outline-level"/>
<!-- tdf#107696: if text:h has attribute "is-list-header" with "true" value, it mustn't be counted for numbering -->
- <xsl:variable name="precedingoutlineLevel-is-list-header" select="preceding-sibling::text:h[$i][@text:is-list-header='true']/@text:outline-level"/>
+ <xsl:variable name="precedingoutlineLevel-is-list-header" select="$precedingHeading[@text:is-list-header='true']/@text:outline-level"/>
<xsl:choose>
<xsl:when test="($currentoutlineLevel = $precedingoutlineLevel) and (not($precedingoutlineLevel-is-list-header)) ">
<xsl:call-template name="calc-heading-digit">
@@ -1421,11 +1422,7 @@
</xsl:call-template>
</xsl:when>
<xsl:when test="$currentoutlineLevel &lt; $precedingoutlineLevel">
- <xsl:call-template name="calc-heading-digit">
- <xsl:with-param name="value" select="$value"/>
- <xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
- <xsl:with-param name="i" select="$i + 1"/>
- </xsl:call-template>
+ <xsl:message terminate="yes">this should not happen</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>