Changes

Jump to navigation Jump to search
1,409 bytes removed ,  15:16, 25 June 2011
no edit summary
much faster this way, and the database meta data is only updated and regenerated
once in the updating process.
 
==DOM Nodes==
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 testing constraints as well. It is therefore possible to execute an
update on a fragment, whereas the same update applied to a database node raises an error.
 
;DOM node as target:
:<pre class="brush:xquery">insert node attribute id { '1' } into <a id='0'/></pre>
 
;Database node as target:
Result file 'doc.xml':
<pre class="brush:xml"><n id='1'/></pre>
 
Query:
<pre class="brush:xquery">insert node attribute id { '0' } into doc('doc.xml')//n</pre>
:Result: <pre style='color:red'>[XUDY0021] Duplicate attribute "id".</pre>
 
If DOM nodes have to be processed you can pipe them through a [[Update#transform|transform expression]].
 
===DOM Nodes & fn:put()===
As a consequence, updates on a fragment are not visible in a 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.
 
;Serializing a modified DOM node:
Query:
<pre class="brush:xquery">
put(
copy $node := <n/>
modify insert node <x/> into $node
return $node, 'doc.xml')
</pre>
 
Result file 'doc.xml':
<pre class="brush:xml">
<n><x/></n>
</pre>
[[Category:XQuery]]
==Error Messages==
administrator, Bureaucrats, editor, reviewer, Administrators
408

edits

Navigation menu