In the following module, lock annotations are used to prevent concurrent write operations on the same file:
<syntaxhighlight pre lang="'xquery"'>
module namespace config = 'config';
Locks can also be declared via pragmas:
<syntaxhighlight pre lang="'xquery"'>
update:output((# basex:lock CONFIG #) {
file:write('config.xml', <config/>)
Locks for the functions of a module can also be assigned via option declarations:
<syntaxhighlight pre lang="'xquery"'>
declare option basex:lock 'CONFIG';