xml.cond.replacement: Conditional replacement of xml elements

Description Usage Arguments Details

Description

This function replaces values in specific element nodes of xml scenario files if a condition is satisfied. This may be useful when, for example, a few resource maps have been used to generate scenarios for a LHS analysis. When this occurs, all the nodes (events) that use the resource map need to match the value in the node that was used to generate the LHS matrix. If the name of the map is unique, it may be possible to simply search and replace for a text string within all files. However, this approach will cause problem if the same string is used in different components of the xml file (for example, if there is a trait that is named as the resource map is).

Usage

1
2
3
4
5
6
7
xml.cond.replacement(
  path.scenarios = NULL,
  scenarios = "all",
  csv.in,
  lookup,
  verbose = TRUE
)

Arguments

path.scenarios

The path to the 'Scenarios' folder

scenarios

A character vector with the scenarios to be processed or "all"

csv.in

The name of the .csv file in the "Scenarios" folder with the information on the nodes that need to be modified (or checked in case of xml.cond.replacement)

lookup

character vector with the csv file names of the element values to changed. One file for each row of csv.in

verbose

Whether report to screen nodes found and changed (default: TRUE)

Details

The file csv.in, which is constructed in the same way as in LHS.scenarios, identifies element nodes whose value needs to be satisfied. That is, a search is performed to identify a node and its values is compared to the value reported in the column 'value' in csv.in. For each row in csv.in, a lookup csv file needs to be present, where a list of nodes that need to be modified and their new values is stored. These values are applied in the xml files where the condition in the relevant row of csv.in is met.


carlopacioni/HexSimR documentation built on Nov. 28, 2020, 4:12 p.m.