diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2019-09-27 15:18:25 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2019-09-27 17:27:04 +0200 |
commit | 86cca6b40ced4031dec4b708ac67b5cbe70cddf9 (patch) | |
tree | 67ee2cab6a6b063788ccb9d3ce7b55e07c866b7a /filter | |
parent | sw: document what Cont means in SwFootnoteContFrame (diff) | |
download | core-86cca6b40ced4031dec4b708ac67b5cbe70cddf9.tar.gz core-86cca6b40ced4031dec4b708ac67b5cbe70cddf9.zip |
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>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/xslt/odf2xhtml/export/xhtml/body.xsl | 11 |
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 e10840951d35..26a344928097 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 <= $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 < $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"/> |