input=
10.0 100
20.0 200
Q0: identity transform: update(//node() | //@*, .) output=
10.0 100
20.0 200
Q1: delete all attributes: update(//@*, ()) output=
10.0 100
20.0 200
Q2: delete all chairs: update(//article[@name='chair'], ()) output=
20.0 200
Q3: delete all chairs (equivalent): update(//article, if (@name='chair') then () else .) output=
20.0 200
Q4: delete stock info of chairs: update(//article/@onStock[../@name='chair'], ()) output=
10.0 100
20.0 200
Q5: set prize of chair to 9.5: update(//article[@name='chair']/prize, 9.5) output=
9.5 100
20.0 200
Q6: set attribute value to 0: update(//article[@name='chair']/@onStock, 0) output=
10.0 100
20.0 200
Q7: increment attribute value by 50: update(//article[@name='chair']/@onStock, . + 50) output=
10.0 100
20.0 200
Q8: make all articles a bit cheaper: update(//article/prize, . * 0.95) output=
9.5 100
19 200
Q9: move article position: move second article before first article: update(//article[1], (//article[2], .)) output=
20.0 200
10.0 100
Q10: append some new elements at end: update(/articles/article[last()], (., ,
30.0 500
)) output=
10.0 100
20.0 200
30.0 500
Q11: rename an attribute: update(//@onStock, attribute {'availability'} { string(.) }) output=
10.0 100
20.0 200
Q12: rename an element: update(//article/prize, {string(.)}) output=
10.0 100
20.0 200
Q13: turn an element into an attribute: update(//article/prize, attribute {'price'} {string(.)}) output=
100
200
Q14: add comments before and after root element: update(/*, (comment {'database of articles on stock'}, ., comment {'end of database'} )) output=
10.0 100
20.0 200
Q15: delete all articles, only retaining their prize: update(//article, prize) output= 10.0 20.0 Q16: wrap each article into a new element with a derived attribute: update(//article, {.}) output=
10.0 100
20.0 200
Q17: add a summary element to each article: update(//article/*[1], (, .)) output=
10.0 100
20.0 200
Q18: add item number ID comment before each article: update(//article, (comment {index-of(../*, .)}, .)) output=
10.0 100
20.0 200
Q19: add item number ID attribute to each article: update(//article/*[1], (., attribute {'id'} {index-of(../../*, ..)} )) output=
10.0 100
20.0 200