Project

Profile

Help

Maintenance: Planio will be observing a scheduled maintenance window this Tuesday, November 5, 2024 from 03:00 UTC until 06:30 UTC to perform urgent network maintenance in our primary data center. Your Planio account will be unavailable during this maintenance window.

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

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


Replies (2)

RE: Still not possible with Python and SaxonC 11.2 to return an XDM array from XPath to Python? - Added by O'Neil Delpratt over 2 years ago

The C++ API is returning the correct XdmArray object but the Python API is not handling this type.

    (1-2/2)

    Please register to reply