Difference between revisions of "XQuery 3.0"
Line 48: | Line 48: | ||
==Functions== | ==Functions== | ||
− | + | In the following, all functions of the [http://www.w3.org/TR/xpath-functions-30/ XQuery 3.0 Specification] are listed that are already supported in BaseX. | |
+ | |||
+ | The following functions have a different signature: | ||
− | |||
* <code>fn:string-join()</code> with 1 argument | * <code>fn:string-join()</code> with 1 argument | ||
* <code>fn:round()</code> with 2 arguments | * <code>fn:round()</code> with 2 arguments | ||
* <code>fn:document-uri()</code> with 0 arguments | * <code>fn:document-uri()</code> with 0 arguments | ||
* <code>fn:node-name()</code> with 0 arguments | * <code>fn:node-name()</code> with 0 arguments | ||
+ | * <code>fn:data()</code> with 0 arguments | ||
+ | |||
+ | The following functions have been added: | ||
+ | |||
+ | * [[Math Functions]]: <code>math:pi()</code>, <code>math:sin()</code>, and many others | ||
* <code>fn:head()</code> | * <code>fn:head()</code> | ||
* <code>fn:tail()</code> | * <code>fn:tail()</code> | ||
* <code>fn:analyze-string()</code> | * <code>fn:analyze-string()</code> | ||
* <code>fn:generate-id()</code> | * <code>fn:generate-id()</code> | ||
− | * <code></code> | + | * <code>fn:environment-variable()</code> |
− | * <code></code> | + | * <code>fn:available-environment-variables()</code> |
− | * <code></code> | + | * <code>fn:element-with-id()</code> |
− | * <code></code> | + | * <code>fn:unparsed-text()</code> |
− | * <code></code> | + | * <code>fn:unparsed-text-available()</code> |
− | * <code></code> | + | * <code>fn:unparsed-text-lines()</code> |
+ | * <code>fn:parse-xml()</code> | ||
+ | * <code>fn:uri-collection()</code> | ||
+ | * <code>fn:serialize()</code> | ||
+ | The following functions are partially supported: | ||
+ | * <code>fn:format-integer()</code> | ||
+ | * <code>fn:format-number()</code> | ||
+ | * <code>fn:format-dateTime()</code> | ||
+ | * <code>fn:format-date()</code> | ||
+ | * <code>fn:format-time()</code> | ||
[[Category:XQuery]] | [[Category:XQuery]] | ||
[[Category:Finish]] | [[Category:Finish]] |
Revision as of 18:49, 12 January 2011
This article summarizes the most important features of the upcoming Version 3.0 of the XQuery language that have already been implemented in BaseX.
Group By
FLWOR expressions have been extended by the group by clause, which is well-established among relational database systems. Group by clauses can be used to group query results based on its values.
Michi? (Example, Details)...
Try/Catch
The try/catch construct can be used to handle errors at runtime:
Example:
try { 1 + '2' } catch *($code, $desc) { concat('Error [', $code, ']: ', $desc) }
Result: Error [XPTY0004]: '+' operator: number expected, string found.
Switch
The switch statement is available in many other programming languages. It chooses one of several expressions to evaluate based on its input value.
Example:
for $fruit in ("Apple", "Pear", "Peach") return switch ($fruit) case "Apple" return "red" case "Pear" return "green" case "Peach" return "pink" default return "unknown"
Result: red green pink
Serialization
Serialization parameters can now be defined within XQuery expressions. All available parameters are supported, which are specified in the W3C Serialization Document. Parameters are placed in the query prolog and need to be specified as option declarations, using the output
prefix.
Example:
declare option output:omit-xml-declaration "no"; declare option output:method "xhtml"; <html/>
Result: <?xml version="1.0" encoding="UTF-8"?><html></html>
Functions
In the following, all functions of the XQuery 3.0 Specification are listed that are already supported in BaseX.
The following functions have a different signature:
fn:string-join()
with 1 argumentfn:round()
with 2 argumentsfn:document-uri()
with 0 argumentsfn:node-name()
with 0 argumentsfn:data()
with 0 arguments
The following functions have been added:
- Math Functions:
math:pi()
,math:sin()
, and many others fn:head()
fn:tail()
fn:analyze-string()
fn:generate-id()
fn:environment-variable()
fn:available-environment-variables()
fn:element-with-id()
fn:unparsed-text()
fn:unparsed-text-available()
fn:unparsed-text-lines()
fn:parse-xml()
fn:uri-collection()
fn:serialize()
The following functions are partially supported:
fn:format-integer()
fn:format-number()
fn:format-dateTime()
fn:format-date()
fn:format-time()