Skip to content

xsl: teiheader2txt causes (non-fatal) errors on large input #31

@respiranto

Description

@respiranto

Given deu-eng-phonetics.tei, upon running

$ xsltproc --novalid --xinclude --stringparam dictname deu-eng --path /path/to/deu-eng/ /path/to/xsl/tei2c5.xsl build/tei/deu-eng-phonetics.tei >build/dictd/deu-eng.c5

as per the Makefiles,
the following error is printed 3 times, after a relatively short time:

XPath error : Memory allocation failed : growing nodeset hit limit

growing nodeset hit limit

^

(as I was reminded here)

The error is non-fatal, and the output is as expected.

The error is linked to the following line in xsl/inc/teiheader2txt.xsl:

  <xsl:template mode="changelog" match="tei:*[1][local-name() = 'date']"/>

The idea here seems to be:
Whenever the mode is changelog, perform the match. However, it
seems that the mode is checked after the match is (positively)
perfomed. Further, for some reason, the request to evaluate
local-name() = 'date' for a set of nodes causes all of them to be
stored in a nodeset, which is limited to a size of 10^7.

An easy fix (1) for this problem is to give an absolute path (retaining
the unusual leaf condition):

<xsl:template mode="changelog" match="/tei:TEI/tei:teiHeader/tei:revisionDesc/tei:change/tei:*[1][local-name() = 'date']"/>

Alternatively (2), one might remove the restriction that <date/> must
be the first child:

<xsl:template mode="changelog" match="date[1]"/>

Further, I wonder whether the purpose of this line--ignoring the date
element, whose value is obtained and used in the parent node's
template--cannot be achieved by easier means. I am entirely new to XSLT
though.

Finally, I wonder whether

  • using mode="changelog" is a good idea at all--except possibly for
    documentation,
  • absolute paths should be used consistently, at least to parse the
    header, but possibly also (parts of) the body.

Anyways, as a quick fix I suggest option (1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions