NGINX recently added support for XSL transformations, and it is AWESOME! In fact, its one of the coolest pieces of software I’ve used in a long time.

Its very simple. The extra cool part of the module is how the templates can be chained together, and it almost seems like a stream editor in a way. Its also very fast!

The example from the NGINX modules website:

 location / {
     xml_entities       /site/dtd/entities.dtd;
     xslt_stylesheet    /site/xslt/one.xslt   param=value;
     xslt_stylesheet    /site/xslt/two.xslt;
 }

This is so cool because you can dynamically combine and mesh all sorts of xml documents together. The xml documents can come from a variety of sources - local static XML files or remote dynamic files generated from a database.

This is really, really great!

UPDATE: What’s even more amazing about this module is that it works with FastCGI output, like this:

        location = /cgi-bin/barf.cgi {
            xslt_types text/html;
            add_header     Cache-Control:  no-store;
            fastcgi_pass   unix:/tmp/fcgi.sock;
            fastcgi_param  DOCUMENT_ROOT     $document_root;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            fastcgi_param  SCRIPT_NAME       $fastcgi_script_name;
            fastcgi_param  QUERY_STRING      $query_string;
            fastcgi_param  REQUEST_METHOD    $request_method;
            fastcgi_param  CONTENT_TYPE      $content_type;
            fastcgi_param  CONTENT_LENGTH    $content_length;
            fastcgi_param  TARGET_FILENAME   $arg_TARGET_FILENAME;
            xslt_stylesheet /var/www/public/a/webop/templates/xsl/status_services.xsl mynid="$arg_nid";
        }

This means I can use a scripting language like PHP, Perl, Python, Ruby, Tcl, Lua or really anything to generate XML, and then it will be transformed via the NGINX xslt module. Sooooo cooool!!!

Whoa! It also works with proxy_pass!!!!!

¥