Project

Profile

Help

Still not possible with Python and SaxonC 11.2 to return an XDM array from XPath to Python?

Added by Martin Honnen about 2 years ago

My code to return an XDM array from XPath to Python still fails with SaxonC 11.2 HE and Python 3:

from saxonc import *

with PySaxonProcessor(license=False) as proc:
    print("Test SaxonC on Python")
    print(proc.version)
    
    xpath_processor = proc.new_xpath_processor()
    
    result = xpath_processor.evaluate_single('array { random-number-generator(current-dateTime())?permute(1 to 10) }')
    
    if (xpath_processor.exception_occurred):
        print(xpath_processor.error_message)
  
    print(result)
    
    resultAsList = result.head.as_list()
    
    print(resultAsList)

gives

Test SaxonC on Python
SaxonC-HE 11.2 from Saxonica
None
Traceback (most recent call last):
  File "returnXdmArrayFromXPathTest1.py", line 16, in <module>
    resultAsList = result.head.as_list()
AttributeError: 'NoneType' object has no attribute 'head'

so no error is given for the XPath evaluation but nothing (None) is returned as the value.


    (1-2/2)

    Please register to reply