Project

Profile

Help

Bug #4847

closed

sotransformToString - Python

Added by David Zabala almost 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
C++ API
Start date:
2020-12-02
Due date:
% Done:

0%

Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
1.2.1
Fixed in version:
11.1
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:

Description

I am trying to get the xls messages (xsl:message) using the following code:

        xsltproc = proc.new_xslt30_processor()

        outputi = xsltproc.transform_to_string(source_file="source.xml", stylesheet_file="style.xsl")

        print(outputi) #This Works

        msg = xsltproc.get_xsl_messages()

And I get the following error:

/usr/lib/libsaxonhec.sotransformToString not found


Files

Xslt30Processor.cpp (62.1 KB) Xslt30Processor.cpp O'Neil Delpratt, 2020-12-03 11:27

Related issues

Has duplicate SaxonC - Bug #4859: Jet Runtime Has detected Unrecoverable Error-libsaxonhec.dll transformToString not foundClosedO'Neil Delpratt2020-12-17

Actions
Actions #1

Updated by O'Neil Delpratt almost 4 years ago

  • Project changed from Saxon to SaxonC
  • Category changed from User error to Python Build
  • Assignee set to O'Neil Delpratt
  • Priority changed from Low to Normal
  • Found in version set to 1.2.1

Thanks for reporting this issue. It looks like a bug in the JNI. Investigating it now

Actions #2

Updated by O'Neil Delpratt almost 4 years ago

I managed to reproduce the error message and it is bug.

The problem is the return type used in the internal JNI method signature in the C++ code is wrong. The bug has been fixed in a redesign of the xsl:message mechanism to make it more usable. This will be available in the next release, but as I workaround see below.

In the method getXslMessage of the class file Xslt30Processor.cpp we currently have the following:

jmethodID mID =   (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
					"getXslMessages",
					"()[Lnet/sf/saxon/s9api/XdmValue;");

Please replace it with the following:

jmethodID mID =   (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass,
					"getXslMessages",
					"()[Lnet/sf/saxon/s9api/XdmNode;");

I have also attached the file to this bug with the patch so you can just drop and replace the file if that is easier. Then rebuild the Saxon/C python extension again.

What actually happens to the xsl:messages by default is to output messages to the standard output console, but this does not find its way to python. As mentioned in the bug issue #4147 to capture the messages you will have to call xsltproc.set_property('m', '') before you do the transformation. See example python code below which should work for you:

        xsltproc = proc.new_xslt30_processor()

        xsltproc.set_property('m', '') #This flag creates a Message Listener which intercepts the messages to return `PyXdmNode` objects of the messages

        outputi = xsltproc.transform_to_string(source_file="source.xml", stylesheet_file="style.xsl")

        print(outputi) #This Works

        messages = xsltproc.get_xsl_messages()
        if messages is not None:
            i = 0
            while i < messages.size:
                print(messages.item_at(i))
                i += 1    

The get_xsl_message returns an PyXdmValue of the individual messages which are PyXdmNode objects.

The PyXdmValue should be iterable. I will create another bug issue for this.

Actions #3

Updated by O'Neil Delpratt almost 4 years ago

  • Status changed from New to AwaitingInfo
Actions #4

Updated by David Zabala almost 4 years ago

It works perfectly now, thank you very much!

Actions #5

Updated by O'Neil Delpratt almost 4 years ago

  • Status changed from AwaitingInfo to In Progress

Bug fixed and committed to repository in the redesign. Unit tests required

Actions #6

Updated by O'Neil Delpratt almost 4 years ago

  • Has duplicate Bug #4859: Jet Runtime Has detected Unrecoverable Error-libsaxonhec.dll transformToString not found added
Actions #7

Updated by O'Neil Delpratt over 2 years ago

  • Status changed from In Progress to Resolved

Bug fixed in SaxonC 11

Actions #8

Updated by O'Neil Delpratt over 2 years ago

  • Tracker changed from Support to Bug
  • Status changed from Resolved to Closed
  • Fixed in version set to 11.1

Bug fix available in the SaxonC 11.1 release

Please register to edit this issue

Also available in: Atom PDF