Project

Profile

Help

Bug #4416

itemAt not downcasting to the lowest class/type in the hierarchy

Added by O'Neil Delpratt 7 months ago. Updated 7 months ago.

Status:
In Progress
Priority:
Normal
Category:
C++ API
Start date:
2020-01-06
Due date:
% Done:

0%

Estimated time:
Found in version:
1.2.1
Fixed in version:

Description

Reported by user: https://saxonica.plan.io/boards/4/topics/7743

The itemAt method in C++, PHP and Python does not downcast to the lowest class/type in the hierarchy.

History

#1 Updated by O'Neil Delpratt 7 months ago

  • Status changed from New to In Progress

I have added code in the Python API to downcast the XdmItem to the minimum type possible. Added test cases.

#2 Updated by O'Neil Delpratt 7 months ago

  • Status changed from In Progress to Resolved

#3 Updated by Martin Honnen 7 months ago

Are the changes that are in https://dev.saxonica.com/repos/archive/opensource/latest9.9/hec/Saxon.C.API/python-saxon/saxonc.pyx the final changes and are tested?

When I use that file I run into cython errors:

Error compiling Cython file:
------------------------------------------------------------
...

        """
        cdef PyXdmValue val = None
        cdef PyXdmAtomicValue aval = None
        cdef PyXdmNode nval = None
        cdef PyXdmItem val = None // remove PyXdmItem()
                                           ^
------------------------------------------------------------

saxonc.pyx:3348:44: Syntax error in C variable declaration

If I try to fix that error by using cdef PyXdmItem val = None # remove PyXdmItem() I run into another error:

Error compiling Cython file:
------------------------------------------------------------
...
        cdef saxoncClasses.XdmItem * xdmItem = NULL
        xdmItem = self.thisvptr.itemAt(index)
        if xdmItem == NULL:
            return None
        else :
            cdef type_ = xdmItem.getType()
                ^
------------------------------------------------------------

saxonc.pyx:3354:17: cdef statement not allowed here

Using Python 3.7 and cython 0.29.14 on Windows 10.

#4 Updated by O'Neil Delpratt 7 months ago

  • Status changed from Resolved to In Progress

I should not have marked this bug as resolved. I have fixed both issues in comment #3.

These changes are not tested as yet.

Please register to edit this issue

Also available in: Atom PDF