Description Usage Arguments Details Value Author(s) References See Also Examples
This function provides a way to define an XSL function
that is implemented using an R function.
The XSL function is immediately available to the XSLT engine.
This should only be called during the initialization
of the XSLT module (or during the evaluation of one of the
R functions exported to the XSLT module).
It is not used in between the application of
XSL sheets. To “queue” functions to be registered
with the XSLT engine when the module is initialized,
use addXSLTFunctions
rather than this one.
1 2 |
name |
the name to use for the XSL function being defined. This is how it will be addressed/referenced in the XSL stylesheets. |
fun |
a function object, the name of a function or
a string that is an S expression that evaluates to a function object.
If this is not supplied, we use the function named
|
symbol |
the name of a C routine to use as the implementation
of the XSL function |
uri |
the URI identifying the XSL namespace for this XSL function. This specifies how the XSL code addresses the function. The namespace and URI should be declared in the XSL document. |
old |
a logical value indicating whether the previous function or
symbol associated with this XSL function name should be returned or
not.
This allows the function to be easily called from XSL
(the |
context |
the XSLT parsing context that is passed as the second argument to the initialization function. |
This stores the S function in an internal table under
the index name
and registers the XSL function
name with the XSLT engine along with a C routine that is a generic R function handler.
When the XSL function is called, the XSLT engine calls that C routine
which retrieves the associated R function from the internal table
and calls it with the arguments from the XSL stack.
If old
is FALSE
,
this returns a logical value indicating whether the function
was registered or not.
If old
is TRUE
, the R function
or C symbol that was previously registered (if any) will be returned.
Duncan Temple Lang
http://www.omegahat.org/Sxslt, http://www.omegahat.org/SXalan, http://www.w3.org/Style/XSL
register.xsl, register.xml and register.R in the examples directory.
1 2 3 4 5 6 7 8 9 10 | ## Not run:
registerXSLFunction("init", function(...) { TRUE })
registerXSLFunction("register", function(name, func) { TRUE })
registerXSLFunction("foo", function(x) { cat("in foo\n"); print(x) ; x*2})
registerXSLFunction("bar", function(x,y) { cat("in bar\n"); print(x) ; print(y) ; nchar(x) + nchar(y)})
xsltApplyStyleSheet(system.file("examples", "register.xml", package = "Sxslt"),
system.file("examples", "register.xsl", package = "Sxslt"), FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.