Dynamically evaluated schema

This portion of the tool makes use of the BaseX-specific xquery:eval() function to evaluate XQuery expressions dynamically:

When evaluating the rule context, a string of the query is first constructed, containing the prolog, consisting of namespace declarations and local variables, followed by the expression to be evaluated. The second argument to xquery:eval() here is a map of global variable bindings, which are effectively passed in as external variables, and the context, i.e. the instance document. BaseX binds this by the convention of using the empty string as a key.

The validation context comprising namespaces, variable bindings and user-defined functions is maintained via a map constructed when the schema is first parsed. This must be updated at two points during evaluation: while evaluating patterns, and assertions. In the case of assertions, this simply means changing the evaluation context to any rule context returned. The handling of patterns is slightly more involved.