Convert XML using XSLT in R



I have task currently being performed by SQL Server Reporting Services where it exports a dataset to an XML format using an XSLT that converts the typical schema to a bespoke one. In order to replace this report, I need to be able to similarly transform XML when the user wants to download it.


The end layout produced by XSLT is horrible - it involves padding and all sorts of whacky concatenations and I'd rather not reinvent the wheel by doing the whole transformation in the first conversion from data to XML.


My google-fu has failed me: how do I convert XML via an XSLT using R?


MWE


Here is a script that uses iris data and converts it to XML (I use my package from CRAN purely to keep the code level down on the example). I then have an XSLT (on gist) that when I run the XML through in Visual Studio converts the XML but I don't know how to translate that activity into R.



library(optiRum)
library(XML)
irisdata<-convertToXML(iris)
saveXML(irisdata,"iris.xml")

No comments:

Post a Comment