Tuesday, 3 October 2006

XSLT is an XML application so why not transform it

As it happens, Michael Kay is presenting a paper entitled Meta-stylesheets at XML2006.

It must be about three years ago that I had what can only be described as an epiphany with respect to seeing XSLT for what it is, an XML application and as such can be generated by XSLT and for that matter transformed by XSLT into another XSLT.

If you are using a framework like Apache's Cocoon, that allows XSLT transforms to be referenced as the product of another pipeline then that's one way to employ meta-stylesheets. Another and potentially more interesting approach, which I'm sure Mr. Kay will bring-up, is the use of the Saxon 8 / XSLT 2 extension functions saxon:compile-transform() and saxon:transform(). These two together allow you to load a stylesheet into your running stylesheet and apply it to a node-set or sequence that you are working on.

But why stop there when you could build a transform at run-time based on some aspect of your source document then apply that transform to either the source or some node-set derived from the source to produce the desired result.

All very wonderful stuff and I'd love to be there when he presents his paper but alas I will not. So I hope it will be available post conference in some way shape or form.

I initially used XSLT transforms on XSLT stylesheets to map some XHTML generating XSLT into XSL-FO generating XSLT. The end result of that was to simplify the maintenance of a website that published to both XHTML and PDF. Structure and style changes to the XHTML where propagated to the PDF output automatically... Sweet :)

More recently I have been looking at Schematron with a mind to using for unit testing. More on that will follow in due course.

No comments:

Post a Comment