The Sxslt package
This package is an R interface to Dan Veillard's libxslt translator.
It allows R programmers to use XSLT directly from within R,
and also allows XSL code to make use of R functions.
In this sense, it is a dual, bi-directional package.
It provides a stand-alone XSLT processor that extends
xsltproc with support for R functions inside XSL,
and it also provides functions within R to
parse and apply stylesheets in R.
This allows one to use R functions to create content dynamically at the
time the document is being created
using either XSL or R or both.
We have previously provided the same style of extension for Xalan, the Apache XSL
translator. This package currently provides more access to the
internal DOM (Document Object Model) of the translator itself.
- Nodesets are passed from XSL to R as references to the internal
C objects and methods are defined on such objects to access
the different nodes and their data such as node name,
attributes, children, namespace,...
- One can use (new) features in the XML package which make it easy to use R
to create XML trees directly in memory using libxml. These can then be
inserted directly into the target DOM being built as part of the XSL
transformation. See a prototype example.
The advantage of this approach is that it allows one to separate the
formatting from the generation of output from statistical software but
to have them integrated at the time one creates the document. This
allows one to avoid running the statistical software in one window and
cutting and pasting the results into a document, or having the
statistical software write output to files that are latter included
into a larger document.
Possible uses for this package include
- Report generation
- The XML input acts as a template whose place-holders are
expanded when the XSL processing is done using data that is
available at that time. Documents such as nightly reports
can then be produced with a format specified in the XML file,
but with data integrated dynamically.
- Reproducible reports (research, simulation, etc.)
The report can be created as self-contained, single object
from which we can generate all the contents. This avoids
synchronizing figures, tables and results in the document with
other files which may be based on different data, etc.
Additionally, these reports can be re-processed with different
inputs to generate similarly styled documents, but with
different results. This allows what-if analyses to be
done relatively easily and consistently with the original
The current version is available as a GNU-zipped tar file
See the README and INSTALL files for instructions on using and
installing the package.
There are currently a few examples
- S in XSLT
- Some notes and documentation.
- Changes across the different versions.
- An S package for reading and writing S objects formatted using
functions and access S objects as well as allowing S to call
- An package for reading and writing XML within S.
Duncan Temple Lang
Last modified: Mon Jun 5 06:21:24 PDT 2006