Project

Profile

Help

PyXdmlArray array_length not working

Added by Martin Honnen over 2 years ago

I am trying to read out the length of an XDM array constructed as a PyXdmArray, accessing .array_length:

from saxonc import *

with PySaxonProcessor(license=False) as proc:
    print("Test SaxonC on Python")
    print(proc.version)
    
    list1 = [1,2,3]
    
    print(list1)
    
    xdmValueList1 = [proc.make_integer_value(i) for i in list1]
    
    print(xdmValueList1)
    
    xdmArray1 = proc.make_array(xdmValueList1)
    
    print(isinstance(xdmArray1, PyXdmArray))
    
    print(xdmArray1.array_length)

Output:

Test SaxonC on Python
SaxonC-HE 11.1 from Saxonica
[1, 2, 3]
[1, 2, 3]
True
Traceback (most recent call last):
  File "C:\Users\marti\OneDrive\Documents\xslt\blog-xslt-3-by-example\saxonc-11.1-python\arrays-and-maps\testArrayLength1.py", line 19, in <module>
    print(xdmArray1.array_length)
  File "saxonc.pyx", line 4351, in saxonc.PyXdmArray.array_length.__get__
    return derivedaaptr.arrayLength()
NameError: name 'derivedaaptr' is not defined

What is the right way to read out the length of a PyXdmArray?


Replies (1)

RE: PyXdmlArray array_length not working - Added by O'Neil Delpratt over 2 years ago

See bug issue #5270 for details of the resolution to the problem.

    (1-1/1)

    Please register to reply