Changes

Jump to navigation Jump to search
188 bytes added ,  15:04, 26 August 2018
It summarizes the update features of BaseX.
BaseX offers a complete implementation of the[http://www.w3.org/TR/xquery-update-10/ XQuery Update Facility (XQUF)].This article aims to provide a very quick and basic introduction to the XQUF.First, some examples for update expressions are given. After that,a few problems the challenges are addressed that frequently arise due to the nature functional semantics of thelanguage. These are stated in the [[Update#Concepts|Concepts]] paragraph.
=Features=
The {{Code|update}} expression is a BaseX-specific convenience operator for the {{Code|copy/modify/return}}
construct. : * Similar to the [[XQuery 3.0#Simple Map Operator|XQuery 3.0 map operator]], the value of the first
expression is bound as context item, and the second expression performs updates on this item.
The updated item is returned as result. An example:
<pre class="brush:xquery">
</pre>
With {{Version|8.5}}, the update expression was extended: * More than one node can now be specified as source:
<pre class="brush:xquery">
</pre>
* In analogy with [[#transform with|transform with]], the updating expressions can now be If wrapped with curly braces. * Update , update expressions can now be chained:
<pre class="brush:xquery">
}
</pre>
 
Please note that the curly braces are mandatory here. Otherwise, the second {{Code|update}} keyword would be associated with the context item expression {{Code|.}}.
===transform with===
 
{{Mark|Introduced with Version 8.5}}:
The {{Code|transform with}} expression was added to the current [https://www.w3.org/TR/xquery-update-30/#id-transform-with XQuery Update 3.0] working draft. It is a simple version of the [[#update|update]] expression and also available in BaseX:
===Built-in Functions===
{{Code|fn:put()}} is can be used to serialize XDM instances to secondary storage. It is : * The function will be executed at the end of a snapshotafter all other updates. * Serialized documents therefore reflect all changes made effective during a query.* No files will be created if the addressed nodes have been deleted.* Serialization parameters can be specified as third argument (more details are found in the [https://www.w3.org/TR/xquery-update-30/#id-func-put XQUF 3.0 Specification]).
Additional Numerous additional [[Database Module#Updates|database functions]] exist for performing updates on document and database level.
===User-Defined Functions===
==Pending Update List==
The most important thing to keep in mind when using XQuery Update is the Pending Update List (PUL). Updating statements are not executed immediately, but are first collected as update primitives within a set-like structure. At After the end evaluation of a the query, and after some consistency checks and optimizations, the update primitives will be applied in the following order:
* '''Backups (1)''': {{Code|db:create-backup()}}
By default, it is not possible to mix different types of expressions in a query result. The outermost expression of a query must either be a collection of updating or non-updating expressions. But there are two ways out:
* The BaseX-specific <code>[[Database Update Module#dbupdate:output|dbupdate:output()]]</code> function bridges this gap: it caches the results of its arguments at runtime and returns them after all updates have been processed. The following example performs an update and returns a success message:
<pre class="brush:xquery">
dbupdate:output("Update successful."), insert node <c/> into doc('factbook')/mondial
</pre>
=Error Messages=
Along with the Update Facility, a number of new error codes and messages have been addedto the specification and BaseX. All errors are listed in the[[XQuery Errors#Update Errors|XQuery Errors]] overview. Please remember that the collected updates will be executed after the query evaluation. All logical errors will be raised before the updates are actually executed.
=Changelog=
 
;Version 9.0
* Updated: [[#Built-in Functions|Built-in Functions]]: serialization parameters
;Version 8.5
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu