Project

Profile

Help

Regression 12.5 when using PyXdmFunctionItem().get_system_function?

Added by Martin Honnen 4 months ago

With 12.4.2 code like

from saxonche import *

with PySaxonProcessor() as saxon_proc:
    print(saxon_proc.version)

    parseJsonFn = PyXdmFunctionItem().get_system_function(saxon_proc,"{http://www.w3.org/2005/xpath-functions}parse-json",1)

    xdm_result = parseJsonFn.call(saxon_proc, [saxon_proc.make_string_value('"foo"')])

    print(xdm_result)

works without problems for me (currently running Python 3.12 on Windows) outputting e.g.

SaxonC-HE 12.4.2 from Saxonica
foo

but with SaxonC HE 12.5 I find it throws an error:

Traceback (most recent call last):
  File "C:\Users\marti\PycharmProjects\SaxonC12SystemFunctionTest1\main.py", line 6, in <module>
    parseJsonFn = PyXdmFunctionItem().get_system_function(saxon_proc,"{http://www.w3.org/2005/xpath-functions}parse-json",1)
                  ^^^^^^^^^^^^^^^^^^^
  File "python_saxon\saxonc.pyx", line 3954, in saxonche.PyXdmValue.__init__
TypeError: __init__() takes exactly 1 positional argument (0 given)

That seems to be a regression in 12.5, or am I missing something?

Or course we also have the parse_json function now https://www.saxonica.com/saxon-c/doc12/html/saxonc.html#PySaxonProcessor-parse_json but I still think the get_system_function approach should work.

main.py (344 Bytes) main.py

Replies (3)

Please register to reply

RE: Regression 12.5 when using PyXdmFunctionItem().get_system_function? - Added by O'Neil Delpratt 3 months ago

Hi Martin,

There has been a few breaking changes to the SaxonC Python API.

See the documentation under the sub-heading From SaxonC 12.5: Change History

from saxoncee import *

with PySaxonProcessor() as saxon_proc:
    print(saxon_proc.version)

    parseJsonFn = PyXdmFunctionItem.get_system_function(saxon_proc, "{http://www.w3.org/2005/xpath-functions}parse-json",1)

    xdm_result = parseJsonFn.call([saxon_proc.make_string_value('"foo"')])

    print(xdm_result)

RE: Regression 12.5 when using PyXdmFunctionItem().get_system_function? - Added by O'Neil Delpratt 3 months ago

You will notice that the get_system_function method on PyXdmFunctionItem is now a static method. Also we no longer need to pass the PySaxonProcessor object to the call method.

RE: Regression 12.5 when using PyXdmFunctionItem().get_system_function? - Added by Martin Honnen 3 months ago

Thanks, O'Neil, should have read the fine manual, it appears.

    (1-3/3)

    Please register to reply