eXtended XSL TransformationsNginx module for XSL Transformations

DESCRIPTION

XXSLT is a Nginx module providing the processing of data and content in a way similar to ESI (Edge Side Includes). XXSLT empower XSL style sheet parsing directly in source code and dynamic content includes. We can use XXSLT module to:
  1. Process embedded blocks of XXSLT (xslt + include directive) commands in any document. Download XML data and define XSL stylesheets directly in processed document.
  2. Insert downloaded content directly to the page source.

XXSLT module can simplify:

  1. Caching the page parts (separation of dynamic and static components)
  2. Integrating of multiple online services (ex. rss feeds, xml interfaces)
  3. Application scaling (data generated on different servers and merge using xxslt)

Look at the example at the end of this document.

INSTALLATION

Put all sources to correct directories: (*.c, *.h, config)

COMPILATION

When compiling from source use standard -add-module option as below:

./configure --add-module=src/http/modules/xxslt --add-module=src/http/modules/download --add-module=src/http/modules/mxcache

After configure simply compile and install nginx from terminal:

make
make install

CONFIGURATION

XXSLT Module:

These are default values. Download/cache timeout and cache expire values can be set directly in include directive.

MXCache Module:

Download Module:

EXAMPLE CONFIGURATION

  location /xxslt {
	xxslt on;
	xxslt_cache_expire 5m;
	xxslt_cache_timeout 200ms;
	xxslt_download_timeout 1500ms;

	mxcache on;
	mxcache_server_ip 127.0.0.1;
	mxcache_server_port 11211;
  }

INCLUDE DIRECTIVE

<include ... />

Atributes:

MODULE USAGE EXAMPLE

Process embeded blocks of XXSLT (xslt + include directive) commands in any document

Module allows to download XML data and define XSL stylesheets directly in processed document.

You can use xslt with include tag in two ways:

<xxslt>
 	<include ... name="name1" dca="xslt" />

	[xslt instructions]
</xxslt>
<xxslt>
	<include ... name="name2" dca="xslt" />
</xxslt>
 
[...]
 
<xxslt>
 	[xslt instructions]
</xxslt>

Pay attention to the fact that the xml data included above are available below in the page. Structure of the global XML document containing all includes is as follows:

<inc>
	<name1>
		[included data]
	</name1>
	<name2>
		[included data]
	</name2>

	[...]
</inc>

Example:

<html>

	[...]	
	
	<xxslt>
		<include src="http://rss.weather.com.au/nsw/sydney" name="weather" dca="xslt" alt="weather_rss_error.xml" ttl="300" maxwait="1500"/>

		<xsl:stylesheet version="1.0" 
			xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
			xmlns="http://www.w3.org/1999/xhtml" xmlns:w="http://rss.weather.com.au/w.dtd">
			<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" encoding="UTF-8"/>
	
			<xsl:template match="/">
				<xsl:for-each select="//weather/rss/channel/item/w:forecast">
					<div>
						<img src="{@iconUri}" alt="{@iconAlt}"  class="weather" />
	
						<ul class="weather">
							<li><b>Day: </b> <xsl:value-of select="@day" /></li>
							<li><b>Min temp: </b> <xsl:value-of select="@min" />C </li>
	
							<li><b>Max temp: </b> <xsl:value-of select="@max" />C </li>
						</ul>
					</div>
				</xsl:for-each>
			</xsl:template>
		</xsl:stylesheet>
	</xxslt>
	
	[...]
	
<html>

Module will download RSS containing XML data and present it using declared stylesheet. If an error occurs rrs_error.xml will be used instead of the rss. Includes are cached if mxcache module is enabled.

Raw data include:

When dca is set to "none" (default), an included object will be included as flat text.

Example:

<html>
[...]
	<div id="menu">
		<xxslt>
			<include src="menu1.html" name="menu" ttl="500"/>
		</xxslt>
	</div>
[...]
</html>

This will include content of the file into the page source. Includes are cached if mxcache module is enabled.

License

XXSLT is licensed under the Apache License, Version 2.0 which you can obtain from: http://www.apache.org/licenses/LICENSE-2.0