rename

Usage

rename perl-code xpath

Description

This command is very similar to the map command, except that it operates on nodes' names rather than their data/values. For every element, attribute or processing-instruction matched by the xpath expression the following procedure is used: 1) the name of the node is stored into Perl's $_ variable, 2) the perl-code is evaluated, and 3) the (posibly changed) content of the $_ variable is used as a new name for the node.

Example 26. Renames all hobbits to halflings

xsh> map $_='halfling' //hobbit

Example 27. Make all elements and attributes uppercase

xsh> map { $_=uc($_) } (//*|//@*)

See Also

map