defineClasses: Define R classes corresponding to XML schema types

defineClassesR Documentation

Define R classes corresponding to XML schema types

Description

This function maps SchemaType-class objects describing XML schema types to R class definitions within the existing R session.

Usage

defineClasses(types, where = globalenv(), namespaceDefs = list(),
               verbose = FALSE, baseClass = BaseClassName, force = FALSE,
               opts = new("CodeGenOpts"),
                pending = new.env(hash = TRUE, emptyenv()),
                classes = new.env(hash = TRUE, emptyenv()))

Arguments

types

a list of SchemaType-class objects describing the XML schema types.

where

the environment in which the new R class definitions should be defined and assigned. This is passed as the value of the where parameter in the call to setClass.

namespaceDefs

a character vector giving the prefix = URI pairs which are used to compare the namespaces in the SchemaType-class objects with those in the standard schema, i.e. XSD.

verbose

a logical value indicating whether to emit messages on the console as classes are defined.

baseClass

the name of the base class which is added to the contains vector for each new class. This allows all the newly defined classes to have a common base class, perhaps with multiple inheritance. This can be used to define methods for all these classes and instances. For example, we might provide a documentation method that provides the help from the XML schema's annotation nodes.

force

a logical value. By default, if there is an existing R class with a name corresponding to a SchemaType-class object, this function does not redefine it. This means that when one runs the function a second time, the classes are not redefined. To override this, use force = TRUE.

opts

an instance of CodeGenOpts that controls how the sub-functions generate code. This class can be sub-classed/derived and new options introduced.

pending,classes

environments which are updated by the different functions and methods we call to register the names of the classes that are being processed and defined. We allow these to be specified by the caller so that she can control and monitor some of the processing.

...

additional parameters passed on to defClass. For example, defineEnumVars can be TRUE and then string values from RestrictedStringDefinition types are also assigned to variables with the same name as the value. This can be beneficial as typos are caught because the variables aren't found. However, non-matching values are also caught at run time too.

Value

A list with the class definitions. This function is run more for its side-effect of defining new classes.

Author(s)

Duncan Temple Lang


omegahat/XMLSchema documentation built on Jan. 17, 2024, 7:08 p.m.