XMLgenerators: Generate XML generator functions from XiMpLe.validity object

XMLgeneratorsR Documentation

Generate XML generator functions from XiMpLe.validity object

Description

Takes an object of class XiMpLe.validity and turns it into a character vector of generator functions for each XML node that was defined.

Usage

XMLgenerators(
  validity,
  prefix = "XML",
  checkValidity = TRUE,
  indent.by = getOption("XiMpLe_indent", "\t"),
  roxygenDocs = FALSE,
  valParam = "validity",
  replaceChar = "_",
  dir = NULL,
  overwrite = FALSE,
  oneFile = NULL
)

## S4 method for signature 'XiMpLe.validity'
XMLgenerators(
  validity,
  prefix = "XML",
  checkValidity = TRUE,
  indent.by = "\t",
  roxygenDocs = FALSE,
  valParam = "validity",
  replaceChar = "_",
  dir = NULL,
  overwrite = FALSE,
  oneFile = NULL
)

Arguments

validity

An dobject of class XiMpLe.validity.

prefix

A character string to be used as a prefix for the resulting function names.

checkValidity

Logical, whether all functions should include a check for valid XML.

indent.by

A charachter string defining how indentation should be done.

roxygenDocs

Logical, whether a skeleton for roxygen2-ish documentation should be added.

valParam

A charachter string, name of the additional parameter to use for validation if checkValidity=TRUE.

replaceChar

A (single) character to be used as an replacement for invalid characters for R parameter names.

dir

A charachter string, path to write files to. If dir=NULL, no files are being written, but the results returned in form of a character vector. If dir is set and the directory does not yet exist, it will be created.

overwrite

Logical, whether existing files should be replaced when dir is set.

oneFile

A charachter string. If set, all functions are to be documented in one single *.Rd file, named like the string.

Details

The resulting code follows these rules:

  • Each child node gets its own argument, except if there is only one valid child node. It will use the dots element instead then.

  • Each attribute will also get its own argument.

  • If CheckValidity=TRUE, one extra argument named after the value of valParam will be added.

  • All arguments are set to NULL by default.

  • Only the main level of "allAttrs" will be taken into account, there's no recursion for this slot.

Value

If dir=NULL a named vector of character strings. Otherwise one or more files are written do the location specified via dir.

See Also

XMLValidity and XiMpLe.validity

Examples

HTMLish <- XMLValidity(
   children=list(
     body=c("a", "p", "ol", "ul", "strong"),
     head=c("title"),
     html=c("head", "body"),
     li=c("a", "br", "strong"),
     ol=c("li"),
     p=c("a", "br", "ol", "ul", "strong"),
     ul=c("li")
   ),
   attrs=list(
     a=c("href", "name"),
     p=c("align")
   ),
   allChildren=c("!--"),
   allAttrs=c("id", "class"),
   empty=c("br")
)
XMLgenerators(HTMLish)

rkward-community/XiMpLe documentation built on March 6, 2023, 5:28 a.m.