Project

Profile

Help

problem using set_query_base_uri from Python API

Added by Martin Honnen almost 5 years ago

https://www.saxonica.com/saxon-c/doc/html/saxonc.html#PyXQueryProcessor-set_query_base_uri suggests I can pass in a Python string to that method, yet an attempt like

    cwd = os.getcwd()
    
    base_uri = pathlib.Path(cwd).as_uri()
    
    print(base_uri)

    xquery_processor.set_query_base_uri(base_uri)

gives me an error

> xquery_processor.set_query_base_uri(base_uri)
> File "saxonc.pyx", line 2493, in saxonc.PyXQueryProcessor.set_query_base_uri
> self.thisxqptr.setQueryBaseURI(base_uri)
> TypeError: expected bytes, str found

This is with Saxon/C 1.2.1 running with Saxon-HE 9.9.1.5C from Saxonica.


Replies (2)

RE: problem using set_query_base_uri from Python API - Added by O'Neil Delpratt almost 5 years ago

Thanks for reporting the problem.

I have created and fixed the bug issue: #4409

There is a simple bug here where are trying to pass the python str to the C++ method, even though we have done the conversion to the C string.

Bug fixed in the set_query_base_uri function.

The following line:

self.thisxqptr.setQueryBaseURI(base_uri)

Changed to the following:

self.thisxqptr.setQueryBaseURI(c_content)

RE: problem using set_query_base_uri from Python API - Added by O'Neil Delpratt almost 5 years ago

Fix available in the next maintenance release. The workaround is to use the updated saxonc.pyx file from subversion or make the suggested changes to the local file.

    (1-2/2)

    Please register to reply