xsltGetStyleSheet: Obtain a reference to the XML internal document object for...

xsltGetStyleSheetR Documentation

Obtain a reference to the XML internal document object for the style sheet or the input XML document.

Description

These functions allow us to query the XSL transformation context to get a reference object in R to the style sheet DOM, the input XML document of the XSL transformation, or the output DOM being constructed.. This allows us then to use XPath expressions to access different nodes within these documents, identifying templates in the XSL document, or getting nodes and node sets for use in R calculations to create output in the target document. These allow us to manipulate all of the inputs from within R rather than relying on XSL operations and can be used from within an R function called by an XSL template. Such functions need to the XMLXPathParserContext object associated with the XSL transformation. This is passed as the first argument for any R function which has an S3 class named XSLTContextFunction.

Usage

xsltGetStyleSheet(ctx)
xsltGetInputDocument(ctx)
xsltGetOutputDocument(ctx)

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.

Value

An object of class XMLInternalDocument which can be used in calls to getNodeSet and whose root node can be accessed with xmlRoot and the resulting tree navigated.

Author(s)

Duncan Temple lang

References

http://www.xmlsoft.org/XSLT

See Also

getNodeSet addXSLTFunctions xsltContextFunction.

For an example, see applyTemplates.R, applyTemplates.xsl and applyTemplates.xml.

Examples

  # Find the XML and XSL files.
 files = sapply(c("applyTemplates.xml", "applyTemplates.xsl"),
                function(i)
                    system.file("examples", i, package = "Sxslt"))



 z = xsltApplyStyleSheet(files[1], files[2])

 saveXML(z$doc)

omegahat/Sxslt documentation built on Jan. 17, 2024, 6:44 p.m.