Hi Johannes, Welcome to the list.
However, I wonder if it is possible to evaluate the expression also within the query module itself, i.e. when method “parse” is called. Is there a way to do so?
Absolutely. You find some examples in [1]. If you your class extends the QueryModule class – which is always recommendable – a function could look as follows: import org.basex.core.Context; import org.basex.query.QueryModule; import org.basex.query.QueryProcessor; import org.basex.query.value.Value; public class Module extends QueryModule { public Value elementName(Value elem) throws Exception { // Your query String query = "declare variable $elem external;" + "name($elem), (: element bound to variable :)" + "name(.) (: element bound to context :)"; Context ctx = queryContext.context; QueryProcessor qp = new QueryProcessor(query, ctx); // Bind to context: qp.bind("elem", elem); qp.context(elem); Value value = qp.value(); return value; } } Hope this helps, Christian [1] https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/or...