My previous post ‘XSLT and Binary File Formats‘, brought-up the subject of the sequence in XSLT 2.0 and how it can be used to build a byte sequence for a binary file format like a TIFF image. For the XSLT generation of new binary files to be even remotely useful, you would need something that requires transformation into binary data and a way to transform it.
In the world of 3D computer graphics Pixar are the ‘King of the hill’ and their Reyes Image Rendering Architecture defines a very powerful image processing pipeline that is used for the transformation of complex graphics primitives into smaller, simpler primitives that are easier to sample and rasterize. The keyword in the last sentence was transformation, and XSLT is very good at transforming hierarchical data structures like computer graphics models.
To simplify the implementation of a Reyes pipeline processor in XSLT, it makes scene to start with just two dimensions and use SVG as the source model, while the final output format can be TIFF (see previous post). The following example shows an enhanced Reyes pipeline, expressed in XML, that makes use of their bucketing technique to allow for more efficient sorting and sampling strategies. The XSLT transform consumes the pipeline definition in order to control the processing of the source model.
<?xml version="1.0" encoding="UTF-8"?>
<pipeline xmlns:svg="http://www.w3.org/2000/svg" name="svg-reyes">
<options href="../options/svg-reyes.xml"/>
<steps>
<svg:read/>
<svg:depth-sort/>
<svg:bound/>
<svg:on-screen/>
<svg:diceable/>
<svg:bucket-sort/>
<svg:bucket-processor>
<svg:dice/>
<svg:shade/>
<svg:bust/>
<svg:bound-micropolygons/>
<svg:bucket-sort-micropolygons/>
<svg:sample/>
<svg:visibility/>
<svg:filter/>
</svg:bucket-processor>
<svg:format/>
</steps>
</pipeline>
A nice feature of the core pipeline processing templates is the ability to declare breakpoints in the pipeline where the transformation exits allowing you to see what is going on at that point in the process.
Recursively transforming the model, in order to dice the large/complex primitives into smaller and more manageable micropolygons before they can go on to be shaded and sampled, means a new model is created for each step in the pipeline. Each revision of the model is embedded into a ‘job-bag’ that carries with it metadata about the current state of the job.
XSLT can easily handle the types of, often complex, transformations required to rasterize the source SVG image; but more importantly, it seems a very intuitive way of implementing the pipeline and its processes. XSLT/XML’s declarative nature allow you to concentrate on the process and not get too bogged-down in the implementation of data structures and the code that handles them.
Although XSLT/XML do not provide an optimised or high-performance solution for this type of work, it is surprising what they can achieve, especially when taken outside of their normal boundaries.
Whilst working on X-Reyes, the XSLT implementation of the Reyes architecture, I maintained a project blog that includes some sample results from the processor.
A comment to my previous post, from Christian Timmerer, drew my attention to the Bitstream Syntax Description Language which deals with the adaptation of existing binary resources (images and video) to suite differing device capabilities. It makes use of XSLT to transform binary resources that have been encoded in XML, and it makes for a very interesting read.

