filter/source/xslt/odf2xhtml/export/xhtml/body.xsl |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit fd0c09a906ae14aeb244bc04e4a1e09ce0e962f4
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Fri Sep 27 15:18:25 2019 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Sep 30 17:35:57 2019 +0200

    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.st...@cib.de>
    (cherry picked from commit 86cca6b40ced4031dec4b708ac67b5cbe70cddf9)
    Reviewed-on: https://gerrit.libreoffice.org/79744
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl 
b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
index 541417b2f36e..f6cebb35146e 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"/>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to