The operator replace... within returns a copy of the SGML element given as argument in which all the sub-elements corresponding to selection have been replaced by query.
Prototype:
list <-- replace selection within element by query
list <-- replace selection as varname within element by query [ where boolean ]The second variant returns only elements for which boolean is TRUE. Varname is a variable which is mapped to each visited node, and which can be used in boolean.
Selection follows the syntax and specifications explained for the within operator.
Examples:
- Renaming the PAR sub-elements by P
replace every PAR as $p within file $myfile by element P attr: attr($p) content: content($p);Correcting all the #PCDATA which contain a mistake (e.g. france --> France) replace top #PCDATA as $txt within file $myfile by regsuball("france", $txt, "France") where $txt match "france";Replacing a sub-element (the deepest) by its textual content replace bottom DIV as $div within file $myfile by text($div," ");<!DOCTYPE CESDOC PUBLIC "-//CES//DTD cesDoc//EN" > <CESDOC VERSION="3.15"><CESHEADER VERSION="2.1"><FILEDESC><TITLESTMT><H.TITLE> This is an artificial example extracted from ...(full result)...