Changes

Jump to navigation Jump to search
1,615 bytes added ,  18:56, 9 August 2018
=Pragmas=
==BaseX Pragmas== Many optimizations in BaseX will only be performed if an expression is ''deterministic'' (i. e., if it always yields the same output and does not have side effects). By flagging an expression as non-deterministic, optimizations and query rewritings can be suppressed: <pre class="brush:xquery">sum( (# basex:non-deterministic #) { 1 to 100000000})</pre> This pragma can be helpful when debugging your code. ==Database Pragmas== All [[Options|Local local database options]] can be assigned locally via pragmas. Some examples: * Enforce query to be rewritten for index access. This can e. g. be helpful if the name of a database is not static (see [[Indexes#Enforce Rewritings|Enforce Rewritings]] for more examples):
<pre class="brush:xquery">
(# db:chop false enforceindex #) { doc for $db in ('doc.xmlpersons1', 'persons2', 'persons3') return db:open($db) //name[text() = 'John']}
</pre>
Various optimizations can * Temporarily disable node copying in node constructors (see {{Option|COPYNODE}} for more details). The following query will be disabled by marking an expression as non-deterministicevaluated faster, and take much less memory, than without pragma, because the database nodes will not be fully copied, but only attached to the new {{Code|xml}} parent element:
<pre class="brush:xquery">
countfile:write( 'wrapped-db-nodes.xml', (# basexdb:non-deterministic copynode false #) { 1 to 10 <xml>{ db:open('huge') }</xml> })
</pre>
=Annotations=
The following implementation-defined annotations are available==basex:inline==
* {{Code|%basex:inline([limit])}} controls if functions will be inlined.
If XQuery functions are ''inlined'', the function call will be replaced by a FLWOR expression, in which the function variables are bound to let clauses, and in which the function body is returned. This optimization triggers further query rewritings that will speed up your query. An example:
</pre>
By default, XQuery functions will be ''inlined'' if the query body is not too large and does not exceed the value assigned to a fixed number of expressions, which can be adjusted via the {{Option|INLINELIMIT}} option.
The annotation can be used to overwrite this global limit: Function inlining can be enforced if no argument is specified. Inlining will be disabled if {{Code|0}} is specified.
</pre>
* ==basex:lazy== {{Code|%basex:lazy}} enforces the lazy evaluation of a global variable. ExampleAn example:
'''Example:'''
</pre>
The annotation ensures that an error will only be thrown if the condition yields true. Without the annotation, the error will always be thrownraised, because the referenced document is not found. =Functions= ==Regular expressions== {{Mark|Introduced with Version 9.1:}} In analogy with Saxon, you can specify the flag {{Code|j}} to revert to Java’s default regex parser. For example, this allows you to use the word boundary option {{Code\b}}, which has not been included in the XQuery grammar for regular expressions: '''Example:''' <pre class="brush:xquery">(: yields "!Hi! !there!" :)fn:replace('Hi there', '\b', '!', 'j')</pre>
=Serialization=
Various other extensions are described in the articles on [[Full-Text#BaseX Features|XQuery Full Text]] and [[Updates|XQuery Update]].
 
=Changelog=
 
# Version 9.1:
 
* Added: [[#Regular expressions]], {{Code|j}} flag for using Java’s default regex parser.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu