Changes

Jump to navigation Jump to search
1,149 bytes added ,  19:20, 20 August 2018
=Option Declarations=
 
==Database Options==
[[Options|Local database options]] can be set in the prolog of an XQuery main module. In the option declaration, options need to be bound to the [[Database Module]] namespace. All values will be reset after the evaluation of a query:
declare option db:chop 'false';
doc('doc.xml')
</pre>
 
==XQuery Locks==
 
If [[Transactions#XQuery_Locks|XQuery Locks]] are defined in the query prolog of a module, access to functions of this module locks will be controlled by the central transaction management.
 
If the following XQuery code is called by two clients in parallel, the queries will be evaluated one after another:
 
<pre class="brush:xquery">
declare option basex:write-lock 'CONFIGLOCK';
file:write('config.xml', <config/>)
</pre>
This pragma can be helpful when debugging your code.
 
{{Mark|Introduced with Version 9.1:}}
 
In analogy with option declarations and function annotations, [[Transactions#XQuery_Locks|XQuery Locks]] can also set via pragmas:
 
<pre class="brush:xquery">
(# basex:write-lock CONFIGLOCK #) {
file:write('config.xml', <config/>)
}
</pre>
==Database Pragmas==
=Annotations=
==basex:inlineFunction Inlining==
{{Code|%basex:inline([limit])}} controls if functions will be inlined.
</pre>
==basex:lazyLazy Evaluation==
{{Code|%basex:lazy}} enforces the lazy evaluation of a global variable. An example:
'''Example:'''
<pre class="brush:xquery">
declare %basex:lazy variable $january := doc('does-not-exist');
if(month-from-date(current-date()) == 1) then $january else ()
</pre>
The annotation ensures that an error will only be thrown raised if the condition yields true. Without the annotation, the error will always be raised, because the referenced document is not found. ==XQuery Locks== {{Mark|Introduced with Version 9.1:}} In analogy with option declarations and pragmas, [[Transactions#XQuery_Locks|XQuery Locks]] can also set via annotations: <pre class="brush:xquery">declare %basex:write-lock('CONFIGLOCK') function local:write() { file:write('config.xml', <config/>)};</pre>
=Functions=
==Regular expressionsExpressions==
{{Mark|Introduced with Version 9.1:}}
<pre class="brush:xquery">
(: yields "!Hi! !there!" :)
fn:replace('Hi there', '\b', '!', 'j')
</pre>
For more information and some additional BaseX-specific parameters, see the article on [[Serialization]].
=Non-determinismDeterminism=
In [http://www.w3.org/TR/xpath-functions-31/#dt-deterministic XQuery], ''deterministic'' functions are “guaranteed to produce ·identical· results from repeated calls within a single ·execution scope· if the explicit and implicit arguments are identical”. In BaseX, many extension functions are non-deterministic or side-effecting. If an expression is internally flagged as non-deterministic, various optimizations that might change their execution order will not be applied.
=Changelog=
# ;Version 9.1:
* Added: XQuery Locks via pragmas and function annotations.* Added: [[#Regular expressions|Regular Expressions]], {{Code|j}} flag for using Java’s default regex parser.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu