Tamino XQuery User Guide - Software AG Documentation
Tamino XQuery User Guide - Software AG Documentation
Tamino XQuery User Guide - Software AG Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Performing Update Operations<br />
update for $a in input()/bib/book<br />
let $title := $a/title<br />
where $title = "TCP/IP Illustrated"<br />
do (<br />
replace $title/text() with string-join(($title/text(), "I. The ↩<br />
Protocols"), " ")<br />
insert<br />
<br />
TCP/IP Illustrated II. The Implementation<br />
StevensW.<br />
WrightG.<br />
Addison-Wesley<br />
67.99<br />
<br />
following $a<br />
insert<br />
<br />
TCP/IP Illustrated III.<br />
StevensW.<br />
Addison-Wesley<br />
49.95<br />
<br />
following $a<br />
)<br />
The update nodes consist of book elements that have a child element title with the content "TCP/IP<br />
Illustrated". Then three update operations are performed:<br />
1. replace<br />
For all books found, the contents of the title element is replaced with the previous contents<br />
concatenated with the string "I. The Protocols" using a blank as separator.<br />
2. Two insert Operations<br />
For all books found, the two specified XML fragments are inserted as sibling elements following the<br />
book element.<br />
In this query two insert following operations act on the same update node. The result is ambiguous<br />
regarding the order of the inserted elements (not commutative). Volume 2 would be inserted as next<br />
sibling to volume 1, and then volume 3 could either be inserted as next sibling to volume 1 (thus shifting<br />
volume 2 to the next position), or it could be inserted after the just inserted volume 2.<br />
As a solution, you can define a sequence to be inserted:<br />
update for $a in input()/bib/book<br />
let $title := $a/title<br />
let $i := (<br />
TCP/IP Illustrated II. The Implementation<br />
StevensW.<br />
Addison-Wesley<br />
67.99<br />
,<br />
<br />
46<br />
<strong>XQuery</strong> <strong>User</strong> <strong>Guide</strong>