Changes

Jump to navigation Jump to search
45 bytes added ,  11:07, 10 November 2015
no edit summary
</pre>
A new {{Code|count}} clause enhances the FLWOR expression with a variable that enumerates the iterated tuples. <pre class="brush:xquery">for $n in (1 to 10)[. mod 2 = 1]count $creturn &lt;number count="{ $c }" number="{ $n }"/&gt;</pre> The {{Code|allowing empty}} provides functionality similar to outer joins in SQL: <pre class="brush:xquery">for $n allowing empty in ()return 'empty? ' || empty($n)</pre> Window clauses provide a rich set of variable declarations to process sub-sequences of iterated tuples. An example: <pre class="brush:xquery">for tumbling window $w in (2, 4, 6, 8, 10, 12, 14) start at $s when fn:true() only end at $e when $e - $s eq 2return &lt;window&gt;{ $w }&lt;/window&gt;</pre> More information on window clauses, and all other enhancements, can be found in the [http://www.w3.org/TR/xquery-30/#id-windows specification]. =Simple Map Operator= The [http://www.w3.org/TR/xquery-30/#id-map-operator simple map] operator {{Code|!}} provides a compact notation for applying the results of a first to a second expression: the resulting items of the first expression are bound to the context item one group by one, and the second expression is evaluated for each item. The map operator may be used as replacement for FLWOR expressions: '''Example:''' <pre class="brush:xquery">(: Simple map notation :)(1 to 10) ! element node { . },(: FLWOR notation :)for $i in 1 to 10return element node { $i }</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 operator, the results of the map operator will not be made duplicate-free and returned in document order. =Group By=
FLWOR expressions have been extended to include the [http://www.w3.org/TR/xquery-30/#id-group-by group by] clause, which is well-established among relational database systems. <code>group by</code> can be used to apply value-based partitioning to query results:
</persons>
</pre>
 
==count==
 
A new {{Code|count}} clause enhances the FLWOR expression with a variable that enumerates the iterated tuples.
 
<pre class="brush:xquery">
for $n in (1 to 10)[. mod 2 = 1]
count $c
return &lt;number count="{ $c }" number="{ $n }"/&gt;
</pre>
 
==allowing empty==
 
The {{Code|allowing empty}} provides functionality similar to outer joins in SQL:
 
<pre class="brush:xquery">
for $n allowing empty in ()
return 'empty? ' || empty($n)
</pre>
 
==window==
 
Window clauses provide a rich set of variable declarations to process sub-sequences of iterated tuples. An example:
 
<pre class="brush:xquery">
for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
start at $s when fn:true()
only end at $e when $e - $s eq 2
return &lt;window&gt;{ $w }&lt;/window&gt;
</pre>
 
More information on window clauses, and all other enhancements, can be found in the [http://www.w3.org/TR/xquery-30/#id-windows specification].
 
=Simple Map Operator=
 
The [http://www.w3.org/TR/xquery-30/#id-map-operator simple map] operator {{Code|!}} provides a compact notation for applying the results of a first to a second expression: the resulting items of the first expression are bound to the context item one by one, and the second expression is evaluated for each item. The map operator may be used as replacement for FLWOR expressions:
 
'''Example:'''
<pre class="brush:xquery">
(: Simple map notation :)
(1 to 10) ! element node { . },
(: FLWOR notation :)
for $i in 1 to 10
return element node { $i }
</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 operator, the results of the map operator will not be made duplicate-free and returned in document order.
=Try/Catch=
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu