The update command

Syntax:

update expression with query

The content of the nodes selected by the given expression is replaced by the result of evaluating the query:

Examples

Given the source document:

<cities> <city name="Berlin" country="DE"/> <city name="Munich" country="DE"/> <city name="Paris" country="FR"/> <city name="Lyon" country="FR"/> <city name="Rome" country="IT"/> </cities>

The command:

update //@country[.='IT'] with "ITALIA"

produces:

<cities> <city name="Berlin" country="DE"/> <city name="Munich" country="DE"/> <city name="Paris" country="FR"/> <city name="Lyon" country="FR"/> <city name="Rome" country="ITALIA"/> </cities>

Given a source document:

<cities> <city><name>Berlin</name><country>DE</country></city> <city><name>Munich</name><country>DE</country></city> <city><name>Paris</name><country>FR</country></city> <city><name>Lyon</name><country>FR</country></city> <city><name>Rome</name><country>IT</country></city> </cities>

The command:

update //city/name[.="Munich"] with "München"

produces the document:

<cities> <city><name>Berlin</name><country>DE</country></city> <city><name>München</name><country>DE</country></city> <city><name>Paris</name><country>FR</country></city> <city><name>Lyon</name><country>FR</country></city> <city><name>Rome</name><country>IT</country></city> </cities>

With the same source document, the command:

update //@country with lower-case(.)

produces:

<cities> <city><name>Berlin</name><country>de</country></city> <city><name>Munich</name><country>de</country></city> <city><name>Paris</name><country>fr</country></city> <city><name>Lyon</name><country>fr</country></city> <city><name>Rome</name><country>it</country></city> </cities>