I keep getting this error. I'm doing a loop and calling my xslt.transform() method (see listing) about 3 times in a row. It bombs about 50% of the time trying to make it to the end of the loop.
My question is, what is wrong with my code? Am I not calling a method needed to reset the new_xslt30_processor
or reset the PySaxonProcessor
between each loop? It tends to work the first time through, so that's my hunch. I'm not cleaning up something.
JET RUNTIME HAS DETECTED UNRECOVERABLE ERROR: runtime error Thread C8B63 ["Thread-0"] is terminated without notifying the JVM. Probably, "DetachCurrentThread" function was not called Please, contact the vendor of the application. Core dump will be piped to "/lib/systemd/systemd-coredump %P %u %g %s %t 9223372036854775808 %h" Extra information about error is saved in the "jet_err_822032.txt" file.
xslt.py
import os
import saxonc
from typing import Dict, List
class Xslt():
@classmethod
def transform(cls, xsl_file: str, xml_file: str, output_file: str, parameters: Dict[str,str]) -> bool:
try:
out = cls.transform_to_string(xsl_file, xml_file, parameters)
with open(output_file, "w") as f:
f.write(out)
return True
except Exception as e:
print(str(e))
return False
@classmethod
def transform_to_string(cls, xsl_file: str, xml_file: str, parameters: Dict[str,str]) -> str:
with saxonc.PySaxonProcessor(license=True) as saxonproc:
xsltproc = saxonproc.new_xslt30_processor()
for parameter in parameters:
xsltproc.set_parameter(parameter, saxonproc.make_string_value(parameters[parameter]))
saxonproc.set_cwd(os.getcwd())
return xsltproc.transform_to_string(source_file=xml_file, stylesheet_file=xsl_file)
Output
Error: failed to allocate an object - please check if an exception was thrown proc is nullptr in SaxonProcessor constructor Error: failed to allocate an object - please check if an exception was thrown Error: failed to allocate an object - please check if an exception was thrown Error: failed to allocate an object - please check if an exception was thrown Error: Xslt30Processor not in a clean state. - Exception found
╭─ bash SaxonHE11-4J 羽393ms⠀ 11.0.16 toddmo 104.5.65.251
╰─ff java -cp saxon-he-11.4.jar net.sf.saxon.Version
SAXON-J-HE 11.4 from Saxonica (build 72811)