Bug #4853
closedproc.transform_to_string causes python to crash
Added by Brian Higashide almost 4 years ago. Updated over 2 years ago.
0%
Description
I am trying to use the xslt processor to validate schematron.
import saxonc
proc=saxonc.PyXslt30Processor(license=False)
proc.transform_to_string(source_file=path_to_file)
Running this code causes python to crash. There's no traceback or error feedback, it just crashes.
Files
sample.sch (1.13 KB) sample.sch | Brian Higashide, 2020-12-07 17:57 |
Updated by Michael Kay almost 4 years ago
- Category set to Python
- Assignee set to O'Neil Delpratt
Updated by O'Neil Delpratt almost 4 years ago
Hi,
If you on the linux platform, you can try running the python file with gdb, which should show up what is causing the crash. For example:
gdb python3 example.py
> handle SIG35 noprint nostop
> run example.py
> bt
As an alternative is it possible to for you to supply the stylesheet please?
Updated by Brian Higashide almost 4 years ago
- File sample.sch sample.sch added
I can't upload the file I was using originally, but I have created a new .sch file from a code snippet and I am seeing the same behavior here.
Updated by O'Neil Delpratt almost 4 years ago
Thanks. I need a complete repo please. Where do I find the XSLT stylesheet that you use for the schematron file? Maybe you can email it to us.
Updated by O'Neil Delpratt almost 4 years ago
- Status changed from New to AwaitingInfo
Update:
Following some offline correspondence the issue is the same as #4701. The explain in that bug issue should help here:
"The way Schematron validation typically works is that you run a (schematron-supplied) XSLT transformation that
takes your schematron rules as input and produces an XSLT stylesheet as output, and then you run this XSLT
stylesheet against your source document. As far as Saxon is concerned, both processes are simply regular
XSLT transformations, that can be run using the standard XSLT transformation API."
Updated by O'Neil Delpratt almost 4 years ago
- Status changed from AwaitingInfo to In Progress
Attempting to compile an invalid stylesheet should not crash python. The above python code is actually incorrect.
The PyXslt30Processor object needs to be created via the PySaxonProcessor object (which is the context). See the example code below:
with saxonc.PySaxonProcessor(license=False) as proc:
xslt30proc = proc.new_xslt30_processor()
...
Updated by O'Neil Delpratt almost 4 years ago
- Status changed from In Progress to AwaitingInfo
Updated by Martin Honnen almost 4 years ago
As for using the Saxon-C Python API to compile a Schematron schema file first to XSLT to then run the XSLT representation of the Schematron file in a second call with Saxon-C see the code samples in https://stackoverflow.com/questions/65134343/schematron-validation-with-python-and-xslt-2-0. There is a link to the Schxslt implementation of Schematron which is now the current and supported XSLT based Schematron implementation.
Updated by O'Neil Delpratt almost 4 years ago
Thank you Martin for providing a solution.
Updated by Brian Higashide almost 4 years ago
Thank you this is helpful. I was also able to use Oxygen XML to generate a stylesheet.
I am seeing a different problem now, When I run this line:
-with saxonc.PySaxonProcessor(license=False) as proc:-
I am getting the following error
Unable to load C:\Program Files\Saxonica\SaxonHEC1.2.1\libsaxonhec.dll
The .dll file does exist in that location.
Updated by O'Neil Delpratt almost 4 years ago
It looks like a classpath issue. Did you follow the instructions for Windows platform here: https://www.saxonica.com/saxon-c/documentation/index.html#!starting/installingpython
Updated by O'Neil Delpratt almost 4 years ago
Are you running a 32-bit or 64-bit Windows build? Saxon/C only runs on 64-bit Windows. We have stopped support for the 32-bit version.
Updated by Brian Higashide almost 4 years ago
I am running 64-bit, Saxon was installed to default directory and added to PYTHONPATH environment variable, but I am still getting the same error.
Updated by O'Neil Delpratt almost 4 years ago
- Status changed from AwaitingInfo to In Progress
Thanks for the information. These kind of problems are somethings difficult to reproduce. Please can you describe your setup in more detail, such as, how you are invoking Saxon/C (is from Powershell, command or something else?), Windows version, etc.
Updated by O'Neil Delpratt almost 4 years ago
Your error may also be similar to the issue #4436 where the problem turned out to be a 32-bit python installed on 64-bit Windows.
Updated by Brian Higashide almost 4 years ago
Yes, the issue was my python version was 32 bit. After installing the 64 bit version I am now able to run the code without issue.
Thanks!
Updated by O'Neil Delpratt over 2 years ago
- Status changed from In Progress to Rejected
Please register to edit this issue