Project

Profile

Help

Passing XDM array to XQuery with Python and SaxonC 11.1 gives java.lang.ClassCastException : net.sf.saxon.ma.arrays.SimpleArrayItem

Added by Martin Honnen about 2 years ago

I am not able to pass an XDM array to XQuery, XPath or XSLT with Python and SaxonC 11.1; here is a test case for XQuery (because in XQuery I at least manage to pass an XDM map with similar code):

from saxonc import *

with PySaxonProcessor(license=False) as proc:
    print("Test SaxonC on Python")
    print(proc.version)
    
    xquery_processor = proc.new_xquery_processor()
    
    list1 = range(1, 5)
    
    xdmArray1 = proc.make_array([proc.make_integer_value(i) for i in list1])
    
    xquery_processor.set_parameter('a1', xdmArray1)
    
    result =  xquery_processor.run_query_to_value(query_text = '''declare variable $a1 as array(xs:integer) external;
      $a1?*
    ''')
    
    if result is None and xquery_processor.exception_occurred:
        print(xquery_processor.error_message)
    else:
        print(isinstance(result, PyXdmValue))
        
        result1 = result.head
        
        print(isinstance(result, PyXdmItem))
        
        print(isinstance(result, PyXdmAtomicValue))
        
        print(result1)

gives

Test SaxonC on Python
SaxonC-HE 11.1 from Saxonica
java.lang.ClassCastException : net.sf.saxon.ma.arrays.SimpleArrayItem

    (1-2/2)

    Please register to reply