|
Home >Online Product Documentation >Table of Contents >Other Parts of the XQuery FLWOR Expression Other Parts of the XQuery FLWOR ExpressionWe have explored the five clauses of the FLWOR expression that give it its name. But there are a few details we have not touched on, partly because they are not used very often. They are summarized in this section. Declaring XQuery Types
In the Declaring types can be useful as a way of asserting what you believe the results of the expressions are, and getting an error message (rather than garbage output) if you have made a mistake. It helps other people coming along later to understand what the code is doing, and to avoid introducing errors when they make changes. Unlike types declared in other contexts such as function signatures (and unlike variables in XSLT 2.0), the types you declare must be exactly right. The system does not make any attempt to convert the actual value of the expression to the type you declare - for example it will not convert an integer to a double, or extract the string value of an attribute node. If you declare the type as string but the expression delivers an attribute node, that is a fatal error. XQuery Position Variables
If you have used XSLT and XPath, you have probably come across the
This selects all the even-numbered videos - useful if you are arranging the data in a table. You can use
There are various keywords in the Other things you can say in the order specification include defining whether empty values of the sort key (XQuery's equivalent of null values in SQL) should go at the start or end of the sequence, and whether the sort should be stable, in the sense that items with equal sort key values preserve their original order. Multiple AssignmentsOne simple syntax note. Instead of writing you can write:
The meaning of both is the same. This same technique applies to |