25.12.2013 Views

Tamino XQuery User Guide - Software AG Documentation

Tamino XQuery User Guide - Software AG Documentation

Tamino XQuery User Guide - Software AG Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Performing Update Operations<br />

In <strong>Tamino</strong> <strong>XQuery</strong> you can perform the following elementary update operations on the node level:<br />

inserting, deleting, replacing and renaming. All update operations follow the syntactic pattern<br />

that they begin with the keyword update. You can either specify directly one of the update operations<br />

using insert, delete, replace, rename or you can construct more complex expressions by<br />

using a special form of the FLWOR expression that is only used for update operations. In general,<br />

all update operations have to result in well-formed documents.<br />

Inserting Nodes<br />

For inserting nodes you have to specify two expressions. The first expression represents the node(s)<br />

to be inserted and the second expression determines the update node, namely the position in all<br />

matching documents at which the insert operation should take place. As a result, the documents<br />

will contain the additional element or attribute nodes inserted at the update node. This is done<br />

differently for element and attribute nodes.<br />

Inserting Element Nodes<br />

Consider the following query expression that extends our current bibliography:<br />

update insert<br />

<br />

XML Schema Part 0: Primer<br />

<br />

Fallside<br />

David C.<br />

IBM<br />

<br />

World Wide Web Consortium<br />

0.00<br />

<br />

into input()/bib<br />

This query inserts the book element as last child element of each bib element. Using the keyword<br />

into always tries to insert an element as the last child element of the update node. If the update<br />

node has not yet any child elements, the elements to insert will then be its first child elements.<br />

Apart from into there are two other keywords that you can use when inserting element nodes.<br />

Using preceding the element nodes will be inserted as preceding siblings to the update node.<br />

Using following the element nodes will be inserted as siblings following the update node.<br />

38<br />

<strong>XQuery</strong> <strong>User</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!