Project

Profile

Help

Bug #4853

closed

proc.transform_to_string causes python to crash

Added by Brian Higashide over 3 years ago. Updated about 2 years ago.

Status:
Rejected
Priority:
High
Category:
Python
Start date:
2020-12-07
Due date:
% Done:

0%

Estimated time:
Found in version:
Saxon HE 1.2.1
Fixed in version:
Platforms:

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
Actions #1

Updated by Michael Kay over 3 years ago

  • Category set to Python
  • Assignee set to O'Neil Delpratt
Actions #2

Updated by O'Neil Delpratt over 3 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?

Actions #3

Updated by Brian Higashide over 3 years ago

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.

Actions #4

Updated by O'Neil Delpratt over 3 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.

Actions #5

Updated by O'Neil Delpratt over 3 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."

Also see: https://saxonica.plan.io/issues/4701#note-6

Actions #6

Updated by O'Neil Delpratt over 3 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()
         ...
Actions #7

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from In Progress to AwaitingInfo
Actions #8

Updated by Martin Honnen over 3 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.

Actions #9

Updated by O'Neil Delpratt over 3 years ago

Thank you Martin for providing a solution.

Actions #10

Updated by Brian Higashide over 3 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.

Actions #11

Updated by O'Neil Delpratt over 3 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

Actions #12

Updated by O'Neil Delpratt over 3 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.

Actions #13

Updated by Brian Higashide over 3 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.

Actions #14

Updated by O'Neil Delpratt over 3 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.

Actions #15

Updated by O'Neil Delpratt over 3 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.

Actions #16

Updated by Brian Higashide over 3 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!

Actions #17

Updated by O'Neil Delpratt about 2 years ago

  • Status changed from In Progress to Rejected

Please register to edit this issue

Also available in: Atom PDF