Transform XML using SaxonJS's XSLT 3.0
Created to be the backend of https://github.com/joaovitorbf/xslt.info
- ATTENTION! THE FULL SERVER IS INSECURE IF YOU ALLOW USER INPUT! XSLT INJECTION CAN RUN ARBITRARY CODE INSIDE THE CONTAINER!
- IF YOU NEED DYNAMIC XSLT, CONSIDER USING THE COMPILEONLY VERSION AND PROCESSING IT CLIENTISDE VIA SAXONJS
To run the NOT RECOMMENDED and NO LONGER AVAILABLE on Docker Hub full server on localhost (replace port):
docker run -d -p 127.0.0.1:[port]:8080 joaovitorbf/xslt-string-server
To run compile-only server on localhost (replace port):
docker run -d -p 127.0.0.1:[port]:8080 joaovitorbf/xslt-string-server-compileonly
Use the /transform endpoint and pass your xml and xslt files as x-www-form-urlencoded.
The xml parameter is not needed if you are using the compile-only version.
Example generated by Postman:
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("xml", "<yourxmlhere>"); // not required if using compileonly
urlencoded.append("xslt", "<yourxslthere>");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("localhost:8080/transform", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));