xsltCallTemplate: Allow R to invoke an XSL template

Description Usage Arguments Details Value Author(s) References See Also

View source: R/context.R

Description

This function allows the R programmer to identify and invoke an XSL template on a particular XML node, passing parameters in the invocation that can be used to customize the behavior of the template. The template can be identified as a node or by name or XPath query string.

Usage

1
xsltCallTemplate(ctx, node, template, ..., .params = list(...))

Arguments

ctx

the XMLXPathParserContext object that is passed to an R function that is called from the XSL transformation. Such an R function must be registered with XSLT as an extension function, typically using addXSLTFunctions and must be an object of (S3) class XSLContextFunction created by a call to xsltContextFunction.

node

the XMLInternalNode object on which the template is to be applied.

template

the template which is to be called. This can be an XMLInternalNode object either obtained from the XSL stylesheet document, or the name (character string) of a template which is then used in a call to getNodeSet to find the node by matching the name attribute. Alternatively, this can be a general XPath expression which will be passed to getNodeSet.

...

one or more named parameter values which are passed in the call as xsl:param name-value pairs. At present, these should be strings. In the future, we will be able to support node sets and tree fragments. This form is useful for interactive use where the individual parameters are known at the time of the call as separate elements.

.params

a list of the named parameter values. This is the programmatic version of ... which facilitates passing the values when they are computed rather than specified manually/interactively in the call.

Details

This calls libxslt's xsltCallTemplate, but does a lot of work to construct the pre-compiled information for the templates.

Value

NULL. The purpose of calling this function is for the side effect of creating content in the target/output document being generated by the XSL transformation.

Author(s)

Duncan Temple Lang

References

http://www.w3.org/Style/XSL http://www.xmlsoft.org/XSLT

See Also

addXSLTFunctions xsltContextFunction xsltApplyStyleSheet

For an example, see applyTemplates.R, applyTemplates.xsl and applyTemplates.xml in the examples directory.


sckott/sxslt documentation built on May 26, 2017, 3:49 a.m.