What is the cause of a Stack usage error
from libxml2/libxslt/lxml?
As per @nwellnhof's answer, this stems from the fact that an extension function has been registered and called fewer parameters than expected.
In my case, it was because I was passing in the contents of a node and in some instances that node was empty. Previously this was fine, but something in my toolchain had changed and started to raise this error.
My original code looked something like:
<xsl:template match="foo">
<xsl:value-of select="my:func(.)" />
</xsl:template>
When foo
was empty, the "Stack usage error" was raised, often grouped with an "Unregistered function" error. The simple fix was to only match when there was content within foo
, eg:
<xsl:template match="foo[./*]">
<xsl:value-of select="my:func(.)" />
</xsl:template>