But I would like to reuse query results for further queries directly.
One common approach is to create volatile database instances from from query results (databases in BaseX are prety lightweight).
I would prefer to avoid the creation of another BaseX database for each query result.
How does your script look like?
I suggest to clarify software design consequences better according to the execution of queries which determine values for subsequent queries.
I guess that a popular use case is to count items also in XML data structures. The computed numbers would be passed then to aggregate functions for further data analyses, wouldn't they?
Regards, Markus