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

New commits:
commit 86cca6b40ced4031dec4b708ac67b5cbe70cddf9
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Fri Sep 27 15:18:25 2019 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Fri Sep 27 17:27:04 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>

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