Changes

Jump to navigation Jump to search
1,475 bytes removed ,  09:45, 30 November 2017
no edit summary
This article is part of the [[XQuery|XQuery Portal]].It summarizes provides a summary of the most interesting important features of the[http://www.w3.org/TR/xquery-30/ XQuery 3.0] Recommendations.XQuery 3.0 is fully supported by BaseXRecommendation.
=Enhanced FLWOR Expressions=
Most clauses of FLWOR expressions can now be specified in an arbitrary order: additional {{Code|let}} and {{Code|for}} clauses can be put after a {{Code|where}} clause, and multiple {{Code|where}}, {{Code|order by}} and {{Code|group by}} statements can be used. This means that many nested loops can now be rewritten to a single FLWOR expression.
'''Example:'''
</pre>
In contrast to the relational GROUP BY statement, the XQuery counterpartconcatenates the values of all non-grouping variables that belong to a specific group.In the context of our example, all nodes in <code>//people/person</code> that belong to the <code>preferred</code> partition are concatenated in <code class="brush:xquery">$ppl</code> after grouping has finished.You can see this effect by changing the return statement to:
<pre class="brush:xquery">
==count==
A new The {{Code|count}} clause enhances the FLWOR expression with a variable that enumerates the iterated tuples.
<pre class="brush:xquery">
</pre>
A map operator is defined to be part of a path expression, which may now mix path and map operators. In contrast to the path operatorexpressions, the results of the map operator will not be made duplicate-free and returned in document order.
=Try/Catch=
=Expanded QNames=
A ''QName'' can now be directly prefixed with the letter "Q" and a namespace URI in the [http://www.jclark.com/xml/xmlns.htm Clark Notation].
'''Examples:'''
* <code><nowiki>Q{http://www.w3.org/2005/xpath-functions/math}pi()</nowiki></code> returns the number π
* <code>Q{java:java.io.FileOutputStream}new("output.txt")</code> creates a new Java file output stream
 
The syntax differed in older versions of the XQuery 3.0 specification, in which the prefixed namespace URI was quoted:
 
* <code><nowiki>"http://www.w3.org/2005/xpath-functions/math":pi()</nowiki></code>
* <code>"java:java.io.FileOutputStream":new("output")</code>
=Namespace Constructors=
New namespaces can now be created via so-called 'Computed Namespace Constructors'.
<pre class="brush:xquery">
=External Variables=
Default values can now be attached to external variable declarations. This way, an expression can also be evaluated if its external variables have not been bound to a new value.
<pre class="brush:xquery">
=Serialization=
[[Serialization|Serialization ]]parameters can now be defined in within XQuery expressions. Parameters are placed in the query prolog and need to be specified as option declarations, using the <code>output</code> prefix.
'''Example:'''
=Context Item=
The context item can now be specified in the prolog of an XQuery expression:
'''Example:'''
local:max(2, 3)
</pre>
 
The following implementation-defined annotations are available:
 
* {{Code|%basex:inline([limit])}} enforces the inlining of a function. Example:
 
'''Example:'''
<pre class="brush:xquery">
declare option db:inlinelimit '0';
declare %basex:inline function local:id($x) { $x };
local:id(123)
</pre>
 
In this query, function inlining has been deactivated by setting [[Options#INLINELIMIT|inlinelimit]] to {{Code|0}}. The annotation enforces inlining for the given function, though, resulting in the optimized query expression {{Code|123}}.
 
If an integer is specified as annotation argument, it will be interpreted a local inline limit.
 
* {{Code|%basex:lazy}} enforces the lazy evaluation of a global variable. 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 if the condition yields true. Without the annotation, the error will always be thrown, because the referenced document is not found.
=Functions=
=Changelog=
 
;Version 8.4
 
* Added: %non-deterministic
;Version 8.0
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu