Rev 8141 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{catalogLoad}\alias{catalogLoad}\alias{catalogClearTable}\alias{catalogAdd}\alias{catalogDump}\title{Manipulate XML catalog contents}\description{These functions allow the R user to programmatically control theXML catalog table used in the XML parsing tools in theC-level libxml2 library and hence in R packages that use these, e.g.the XML and Sxslt packages.Catalogs are consulted whenever an external document needs to be loaded.XML catalogs allow one to influence how such a document is loadedby mapping document identifiers toalternative locations, for example to refer to locallyavailable versions.They support mapping URI prefixes to local file directories/files,resolving both SYSTEM and PUBLIC identifiers used in DOCTYPE declarations at thetop of an XML/HTML document, and delegating resolution to other catalog files.Catalogs are written using an XML format.Catalogs allow resources used in XInclude nodes and XSL templatesto refer to generic network URLs and have these be mapped to local filesand so avoid potentially slow network retrieval.Catalog files are written in XMLWe might have a catalog file that contains the XMLIn the XDynDocs package, we refer to OmegahatXSL files andDocBook XSL files have a catalog file of the formThe functions provided here allow the R programmer toempty the current contents of the global catalog table and sostart from scratch (\code{catalogClearTable}),load the contents of a catalog file into the global catalog table (\code{catalogLoad}),and to add individual entries programmatically without the need for a catalog table.In addition to controlling the catalogs via these functions, we canuse \code{\link{catalogResolve}} to use the catalogto resolve the name of a resource and map it to a local resource.\code{catalogDump} allows us to retrieve an XML document representing the currentcontents of the in-memory catalog .More information can be found at\url{http://xmlsoft.org/catalog.html}%% and \url{http://www.sagehill.net/docbookxsl/Catalogs.html} amongmany resources and the specification for the catalog format at\url{https://www.oasis-open.org/committees/entity/spec-2001-08-06.html}.}\usage{catalogLoad(fileNames)catalogClearTable()catalogAdd(orig, replace, type = "rewriteURI")catalogDump(fileName = tempfile(), asText = TRUE)}\arguments{\item{orig}{a character vector of identifiers, e.g. URIs, that are to be mapped to a differentname via the catalog.This can be a named character vector where the names are the original URIs and the values are thecorresponding rewritten values.}\item{replace}{a character vector of the rewritten or resolved values for theidentifiers given in orig. Often this omitted and theoriginal-rewrite pairs are given as a named vector via orig.}\item{type}{a character vector with the same length asorig (or recycled to have the same length) which specifiesthe type of the resources in the elements of orig.Valid values are rewriteURI, rewriteSystem, system, public.}\item{fileNames}{a character vector giving the names of thecatalog files to load.}\item{fileName}{the name of the file in which to place the contents of the current catalog}\item{asText}{a logical value which indicates whether to write the catalogas a character string if \code{filename} is not specified.}}\value{These functions are used for their side effects on the globalcatalog table maintained in C by libxml2. Their return values arelogical values/vectors indicating whether the particular operationwere successful or not.}\references{This provides an R-like interface to a small subset of the catalog APImade available in libxml2.}\seealso{\code{\link{catalogResolve}}XInclude, XSL and import/include directives.In addition to these functions, there is an un-exported, undocumentedfunction named \code{catalogDump} that can be used toget the contents of the (first) catalog table.}\examples{# Add a rewrite rule##catalogAdd(c("https://www.omegahat.net/XML" = system.file("XML", package= "XML")))catalogAdd("https://www.omegahat.net/XML", system.file("XML", package ="XML"))catalogAdd("http://www.r-project.org/doc/",paste(R.home(), "doc", "", sep = .Platform$file.sep))## This shows how we can load a catalog and then resolve a# systemidentifier that it maps.#catalogLoad(system.file("exampleData", "catalog.xml", package = "XML"))catalogResolve("docbook4.4.dtd", "system")catalogResolve("-//OASIS//DTD DocBook XML V4.4//EN", "public")}\keyword{IO}