With any report generator, it is likely that customisation will be required. To facilitate this, new xqDocA outputs can be added to the system without modifications to the driver code. A plug-in system is provided using the dynamic loading of code modules.

This is done using custom annotations within the xqDocA code base. Functions that generate xqDocA output must have annotations in the xqDocA namespace indicating their role. At runtime, a designated directory is scanned for XQuery modules, and functions containing the appropriate annotations can be invoked without requiring any other code changes.

Three annotations are defined in the xqDocA namespace, "".

Table 3. xqDocA annotations

xqdoca:globalIndicates a global renderer(name for reference, description)
xqdoca:moduleIndicates a module renderer(name for reference, description)
xqdoca:outputSerialization details(output uri, serialization type)


A function will have one of xqdoca:global or xqdoca:module, as well as an xqdoca:output annotation.

Sample usage:

%xqdoca:module("module","Html5 report on the XQuery source")
function xqh:xqdoc-html2($file as map(*),
                         $opts as map(*),
                         $model as map(*)
as document-node() 


                "Swagger file (JSON format) from restxq annotations.")
function _:swagger($model as map(*),
                   $opts as map(*)

In order to enable runtime selection of code based on function annotations the following features must be provided by the XQuery environment:

  1. Dynamic module loading. This is standardised in the XQuery 3.1 specification as fn:load-xquery-module. Currently, this feature is not widely supported; however, many implementation have custom variants that provide equivalent functionality.

  2. Annotation introspection. That is the ability at runtime to determine what annotations are attached to a function. This is not a feature with any standardisation but again is widely supported via vendor libraries. See Saxon [10], MarkLogic [11], BaseX [12], and eXist-db [14].