Skip to content

Simple Node.js web server application with RESTful API for XSL transformation

Notifications You must be signed in to change notification settings

RolandDreger/node-xslt3-api

Repository files navigation

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.

Installation

To run the server, Node.js must be installed on your computer. You can download it from Nodejs.org.

  1. Clone GitHub repo to your computer

    git clone https://github.com/RolandDreger/node-xslt3-api.git

  2. Install node dependencies

    npm install

  3. Start Server

    npm start

POST Request Test

To test the transformation e.g. with Postman, the XML file and the stylesheet in the assets folder can be used:

postman_screenshot

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.

Compile XSL Stylesheet

npx xslt3 -xsl:assets/xsl/stylesheet_group.xsl -export:assets/xsl/stylesheet_group.sef.json -nogo

Further information in Saxon-JS 2 documentation.

InDesign Example

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);

License

MIT

Author

Roland Dreger, www.rolanddreger.net

PayPal Link

About

Simple Node.js web server application with RESTful API for XSL transformation

Topics

Resources

Stars

Watchers

Forks