R Language
Approach is based on a XML Schema.
R XMLSchema from Duncan Temple Lang.
A package that reads XML schema into an R representation and can perform some operations on the resulting information to generate class definitions and code to read documents using this schema.
The R representation uses S4 classes.
Usage of readSchema
Installation of XMLSchema in R
install.packages("remotes")
remotes::install_github("omegahat/XMLSchema")
install.packages("sloop")
Test Run
An internal representation of the XML schema is created as S4 classes.
options(echo=TRUE)
library(sloop)
library(XML)
library(XMLSchema)
args <- commandArgs(TRUE)
print(args[1])
print('--------------------------------------------------')
cdi = readSchema(args[1], createConverters = TRUE, verbose = TRUE)
# cdi = readSchema("E:/Git/ddi-cdi/build/encoding/xml-schema/ddi-cdi.xsd", createConverters = TRUE)
print('--------------------------------------------------')
is(cdi)
print('--------------------------------------------------')
otype(cdi)
print('--------------------------------------------------')
class(cdi)
print('--------------------------------------------------')
names(cdi)
print('--------------------------------------------------')
sapply(cdi, length)
print('--------------------------------------------------')
sapply(cdi, class)
print('--------------------------------------------------')
sapply(cdi, names)
print('--------------------------------------------------')
showMethods( classes=class(cdi) )
print('--------------------------------------------------')
print(cdi)
print('--------------------------------------------------')
saveRDS(cdi, 'cdi.rds')
rm(cdi)
exists("cdi")
cdi <- readRDS('cdi.rds')
otype(cdi)
class(cdi)
names(cdi)
# serialize S4 classes, not sure if this is right
sink("cdi.R")
sapply(cdi, expandS4)
sink()
Documentation of XMLSchema
In R:
help(package="XMLSchema")
Once a local web server has been started, the documentation is displayed in the web browser.