[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Xslt transformation of an xslt transform


Subject: RE: [xsl] Xslt transformation of an xslt transform
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 5 Jul 2007 22:22:53 +0100

> I have a tricky question thats been bugging me for a while. I 
> am using forrest to do transforms for my company's website, 
> but am interested in offloading the xslt processing to the 
> browser (when it is able to do it). However the xslt 
> processing is in a pipeline, so what I am really interested 
> in doing is combining several xslt transforms in one. 

It's true that a pipeline of several transformations written using multiple
stylesheets can always be reduced to a single stylesheet using the node-set
extension. But I haven't seen anyone attempt to automate that process. It's
a bit tricky because you have to make sure that all the global variables,
templates, and modes in the two stylesheets are distinct - if you want to be
thorough you will have to rename variables, which means diving inside XPath
expressions to find the variable references. Or you could ignore that risk,
and just concentrate on putting all the template rules into a mode, which is
easier.

But I'm not sure why you want to do it. Simpler, I would have thought, is to
continue to run it as a multi-stylesheet pipeline in the browser. You need
to write some Javascript to achieve that, but it's quite doable. (Though I
wouldn't attempt it myself, I find doing anything in the browser is more
hassle than it's worth, and you need to pay me a lot of money to do anything
in XSLT 1.0 these days...)

> 
> Can you modify the DOM of the xslt parse tree of a 
> transformer directly before it does the transformation? (a 
> plugin or callback perhaps)

You can load the XML representation of a stylesheet into a DOM and modify it
(using XSLT or otherwise) before compiling the stylesheet.
> 
> Another idea: is it possible to send a pipeline of xslt 
> transforms for the browser to perform (I imagine not and also 
> it would slow the browser down)?
> 

You can write Javascript in an HTML page which executes a sequence of XSLT
transformations.

Michael Kay
http://www.saxonica.com/


Current Thread
Keywords