Hi Kristian -

I'm sorry that I can't speak to the Python portion of your question, but maybe you can leverage some of the functx functions to get better information? I confess that I'm not sure how to determine typing for items beyond a certain point - hopefully someone more knowledgeable will weigh in.

```xquery
xquery version "3.1";

import module namespace functx = "http://www.functx.com";
let $list :=
  <list>
    <entry>
      <a>1</a>
      <b>2</b>
    </entry>
    <entry>
      <a>1</a>
      <b>2</b>
      <c>3</c>
    </entry>
  </list>
let $items := for $entry in $list/entry[not(exists(./c))] return $entry
return(
  <result>
    <type-of>{ functx:atomic-type($items/a) }</type-of>
    <sequence-type>{ functx:sequence-type($items/a) }</sequence-type>
    { $items }
  </result>
)
```
The above returns
<result>
  <type-of>xs:untypedAtomic</type-of>
  <sequence-type>element()</sequence-type>
  <entry>
    <a>1</a>
    <b>2</b>
  </entry>
</result>

I hope that's helpful (but recognize that it probably isn't).
Cheers,
Bridger

On Thu, Nov 1, 2018 at 8:01 AM Kristian Kankainen <kristian@keeleleek.ee> wrote:

Hello,

XQuery is a lovely language and together with BaseX it is very lovely.

But now, for a project that need Python, I find difficulties understanding the general workflow communicating between BaseX and Python.

My basic situation boils down to 1) execute a query on BaseX that returns a list of data 2) analyse every item in the in Python 3) push the analysis result back in to BaseX.

I have done updates like this solely in XQuery but this time I need the analysis part done in Python.

Since I seem to only get a list of strings out of a query executed by the client, is this usecase even possible?

Below is attached my sample running code

Best regards,
Kristian K

```Python
from BaseXClient import BaseXClient

# open a session
session = BaseXClient.Session('localhost', 1984, 'admin', 'admin')

# execute a query that returns a list of entry elements
query = session.query("""
let $list :=
  <list>
    <entry>
      <a>1</a>
      <b>2</b>
    </entry>
    <entry>
      <a>1</a>
      <b>2</b>
      <c>3</c>
    </entry>
  </list>

let $items :=
    for $entry in $list/entry[not(exists(./c))]
      return $entry

return $items
"""
)

# process each item of the query
for typecode, item in query.iter():
  print(type(item))
  print(item)

session.close()
```

This returns simply:
<class 'str'> # the type of returned item is of class 'str'
<entry>        # this is the content of the plain text object
  <a>1</a>
  <b>2</b>
</entry>