Changes

Jump to navigation Jump to search
2,308 bytes added ,  10:49, 6 December 2010
Created page with "<p>With the release of version 6.0, BaseX offers a complete implementation of XQuery Update.</p> ==Effects== <p>In BaseX, all updates are performed on database nodes. This is..."
<p>With the release of version 6.0, BaseX offers a complete implementation of XQuery Update.</p>

==Effects==
<p>In BaseX, all updates are performed on database nodes. This is why update operations
never affect the original input file. You can, however, use the
<a href='commands#export'><code>EXPORT</code></a> command or the
XQuery function <code>fn:put()</code> to create an updated 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 <a href='commands#optimize'><code>OPTIMIZE</code></a>
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>
<blockquote>
<p><b>Example (correct):</b></p>
<p><b>Query:</b> <code>insert node attribute id{'1'} into &lt;a id='0'/></code></p>
<p><b>Result:</b></p>
<p><b>Example (incorrect):</b></p>
<p><b>File 'doc.xml':</b> <code>&lt;n id='1'/&gt;</code></p>
<p><b>Query:</b> <code>insert node attribute id{'0'} into doc('doc.xml')//n</code></p>
<p><b>Result:</b> <code>[XUDY0021]Duplicate attribute "id".</code></p>
</blockquote>

==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>
<blockquote>
<p><b>Example:</b></p>
<p><b>Query:</b></p>
<code> let $n := &lt;n/&gt;
return (insert node &lt;x/&gt; into $n, put($n,'doc.xml'))
</code>
<p><b>File 'doc.xml':</b> <code>&lt;n/&gt;</code></p>
<p><b>Query:</b></p>
<pre>
put(
copy $nn := &lt;n/&gt;
modify insert node &lt;x/&gt; into $nn
return $nn,
'doc.xml')
</pre>
<p><b>File 'doc.xml':</b><code> &lt;n&gt; &lt;x/&gt; &lt;/n&gt;</code></p>
</blockquote>

</div>
Anonymous user

Navigation menu