This is a showcase for a Node.js server with Express on localhost. It demonstrates an XSL transformation with Saxon-JS for Adobe Indesign. The result of the transformation can be retrieved via a REST API.
A short video about it on Vimeo.
Saxon-JS is a XSLT 3.0 processor that runs in browser or on Node.js. Further information can be found on www.saxonica.com.
To run the server, Node.js must be installed on your computer. You can download it from Nodejs.org.
-
Clone GitHub repo to your computer
git clone https://github.com/RolandDreger/node-xslt3-api.git
-
Install node dependencies
npm install
-
Start Server
npm start
To test the transformation e.g. with Postman, the XML file and the stylesheet in the assets folder can be used:
localhost:3000/transform/simple?stylesheet=stylesheet_group.sef.json
»simpel« is an optional parameter that can be used in the stylesheet. »?stylesheet=stylesheet_group.sef.json« defines the stylesheet in the assets folder.
npx xslt3 -xsl:assets/xsl/stylesheet_group.xsl -export:assets/xsl/stylesheet_group.sef.json -nogo
Further information in Saxon-JS 2 documentation.
InDesign ExtendScript snippet with cURL (macOS):
var _curlCommand = "curl -X POST 'http://localhost:3000/transform/simple?stylesheet=stylesheet_group.sef.json' -H 'Host: localhost:3000' -H 'content-type: text/xml' -d '@/[PathToYourFolder]/assets/source_group.xml'";
var _apiRequestString = app.doScript('do shell script "' + _curlCommand + '"', ScriptLanguage.APPLESCRIPT_LANGUAGE);
Roland Dreger, www.rolanddreger.net
PayPal Link