Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
respiranto opened this issue Jul 4, 2021 · 1 comment
Closed

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

respiranto opened this issue Jul 4, 2021 · 1 comment

Comments

@respiranto
Copy link
Contributor

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).

@humenda
Copy link
Member

humenda commented Jul 4, 2021 via email

respiranto added a commit that referenced this issue Jul 4, 2021
This avoids an error to be printed in a case where the input is very
large (e.g., deu-eng).  The error is neither fatal nor does it change
the expected header output.

See in-line documentation and issue #31 [0] for more information.

[0] #31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants