preproc: Optimize away c:{sum,product} containing preprocessed lv:*

This optimization (which already existed) is supposed to remove
c:sum/c:product nodes if they contain one or fewer calculations, but it
failed to remove them when inline templates were used (because it creates,
well, a template inline).

Instead, we'll assume that any lv:* nodes handled by the preprocessor will
be okay.  In the case of inline templates, they receive a preproc attribute
identifying what created it.

I hope this is a valid assumption.  This will be thoroughly tested.  If only
we had test cases for the preprocessor.

* src/current/include/preproc/expand.xsl: (preproc:expand)[c:sum,c:product]:
    Consider optimization for `lv:*[@preproc:*]'.
master v2.5.2
Mike Gerwitz 2017-12-13 13:50:24 -05:00
parent 0f0e88d9fb
commit 22b4d37317
1 changed files with 3 additions and 1 deletions

View File

@ -422,7 +422,9 @@
Note that we should *not* perform these optimizations if there are templates
awaiting application or any other lv:* nodes that have not been expanded.
-->
<xsl:template match="c:sum[ lv:* or t:* ]|c:product[ lv:* or t:* ]" mode="preproc:expand" priority="7">
<xsl:template match="c:sum[ lv:*[ not( @preproc:*) ] or t:* ]
|c:product[ lv:*[ not( @preproc:* ) ] or t:* ]"
mode="preproc:expand" priority="7">
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:apply-templates mode="preproc:expand" />