Changes

Jump to navigation Jump to search
18 bytes removed ,  15:30, 8 December 2010
no edit summary
<p>With the release of version 6.0, BaseX offers a complete implementation of the [http://www.w3.org/TR/xquery-update-10/ XQuery Update Facility (XQUF)].</p>
==Introduction==
;Returning Results
: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. Generally there is no way to perform any updating queries and return a result at the same time. But a simple and convenient workaround exists. common error: copy/fragment of dbnode-> change for result. better use transform
;Function Declaration
:To use updating expressions within a function, the 'updating' flag has to be added to the function declaration. A correct declaration of a function that contains updating expressions (or a function that calls updating functions) looks like this: declare <b>updating</b> function { ... }
==New Functionality== ===Updating Expressions==
There are five new expressions to modify data. While insert, delete, rename and replace basically explain themselves, the transform expression is different. Modified nodes are copied in advance and the original databases remain untouched.
==Examples==
An expression consists of a target node (the node we want to alter) and additional information like insertion nodes, a QName, etc. which depends on the type of expression. You can find a few examples and additional information below.
====insert========delete========replace========rename========transform==== ===Functions===
==== fn:put() Function====<p>FN:put() is also part of the XQUF and enables the user to serialize XDM instances to secondary storage. It is executed at the end of a snapshot. Serialized documents therefore reflect all changes made effective during a query.</p>
==Effects on Your Documents==
<p>In BaseX, all updates are performed on database nodes. This is why update operationsnever affect the original input file. You can, however, use the [[Commands|EXPORT]] command or the fn:put() function to create an updated XML file. Turning on the WRITEBACK property ([[Commands|SET Command]]) directly propagates changes of your database to the original input file. Make sure you back up your data in advance, as this approach modifies the underlying XML file.</p>
==Indexes==
<p>As BaseX aims mainly for efficiency, the maintenance of indexes is left to the user.
This requires the user to call the [[Commands#Optimize|Optimize]]
command if up-to-date index structures are
necessary. Using this approach guarantees fast updates and fast access at the same time.</p>
==Fragments==
<p>So far BaseX differentiates between fragments and database nodes. Updates on fragments
have no effect on any existing databases and are therefore not applied at all. This
includes the test for violation of any constraints. Thus it is possible to execute an
update on a fragment, which would raise an error if applied on a database node.</p>
;Example 1:
===Fragments & fn:put()===
<p>As a consequence, updates on a fragment are not visible in an XML file created with
<code>fn:put()</code>. If this functionality is required, the transform expression can be applied.
The copied nodes in a transform expression are internally treated like database nodes
and are updatable as a result.</p>
;Example 1:
administrator, Bureaucrats, editor, reviewer, Administrators
408

edits

Navigation menu