Is there some way to have the Python API see an XdmlItem which is an XdmNode as an XdmNode without explicitly using get_node_value?
When looking at the Python API of Saxon-C 1.2.1 so far I find it cumbersome that it seems to be necessary to cast an
XdmItem which is an
XdmNode explicitly to a node with the help of https://www.saxonica.com/saxon-c/doc/html/saxonc.html#PyXdmItem-get_node_value.
xdmSequence = xqueryEngine.executeQueryToValue('.', ['qs'], ['1, <foo/>']) and then access the two items in the returned sequence with e.g.
> xdmSequence.itemAt(0) JavaObject[net.sf.saxon.s9api.XdmAtomicValue]
> xdmSequence.itemAt(1) JavaObject[net.sf.saxon.s9api.XdmNode]
then the script engine knows when it as an atomic value or a node and allows me to use the relevant, specific API without any explicit cast.
I understand the situation with the Saxon-C Python API is much more complex with some hierarchy of types in Java, some in C++, then in Python but I wonder whether the current required explicit cast is due to limitations of that complex setup or whether there are some changes possible in the Python/CPython API configuration and/or implementation to script an XdmItem which is an XdmNode as an XdmNode without having to call get_node_value.
RE: Is there some way to have the Python API see an XdmlItem which is an XdmNode as an XdmNode without explicitly using get_node_value? - Added by O'Neil Delpratt about 2 years ago
Indeed this is cumbersome. There is no real why we cannot downcast the XdmItem object returned from
item_at function in the Python API to the lowest class/type in the hierarchy. I have created a bug issue to investigate this issue #4416
We should also make this change in the C++ and PHP APIs.
Please register to reply