Eval example
This example demonstrates how to dynamically generate and execute XQuery code at runtime, using the `xquery:eval` function to apply a chosen string function to book titles from an XML collection. The code first iterates over `fn:collection("books")/record/Title` to retrieve each title, then constructs a string expression that calls the external `fn:upper-case` function, passing the current title as a variable. It explicitly shows the use of the XQuery 3.1 standard, the `map` constructor for passing external variables, and the `declare variable $title external` declaration to inject the title into the evaluated expression. The example highlights dynamic code generation within a database query context, with the rendering limited to the function’s output.
AI-generated description