It would be great to have a node or a CLI possiblity to run XSLT transforms. Against Binary files or Input data in the node itself. There should be a possibility to upload/set an XSLT template and the input (binary file/input prop) and receive the transformed output or handle the error accordingly.
I don’t know any good tools in the Node.js space for that but it would make a great addition to the tool set of n8n.
So I stepped into this on my own for now and what I came up with was the following but I think it really needs a better way:
- I installed Java (I am running n8n-ubuntu docker) via
apt install default-jre
- From http://saxon.sourceforge.net I got the saxon 9 HE processor as a JAR
- I unzipped the saxon archive to
~/.n8n/saxon-he/ to have it available after updating the container (still I’d need to reinstall java inside the container but that is manageable)
- XSLT files are provided via another directory in application directory
- calls to the processor are made via the
Execute Command node e.g.
java -jar /root/.n8n/saxon-he/saxon9he.jar /data/<source-xml-file>.xml /root/.n8n/xslt/<xslt-file>.xslt
Depending on the workflow I am saving the XML to a file on disk and process it via the CLI. The transformed XML is put to STDOUT or file according to the option provided to the command.