cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <>
Subject Re: 2 xslt transformations
Date Tue, 21 Mar 2000 19:04:28 GMT
Michael Glenn wrote:
> John Carroll wrote:
> >
> > Is it possible to run an xml file through 2 different xsl
> > transformations using 2 xsl stylesheets?


> > So that the xml generated by the first transformation then gets
> > changed again by the application of the second stylesheet.
> I submitted a patch for this but it has yet to make it into the CVS. I'm
> awaiting Stefano's response to see if he'll add it in. 

Michael patch breaks other functionality so it will not be committed.
Also because the functionality is there just that you have to know how
XSLT works.

I'm sure you guys try to do something like

<?cocoon-process type="xslt"?>
<?xml-stylesheet href="sheet1.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="sheet2html.xsl" type="text/xsl"?>
<?xml-stylesheet href="sheet2wap.xsl" type="text/xsl" media="wap"?>

and this doesn't work as expected, right?

Ok, let's see what happens:

[suppose no media is matched]
1) cocoon finds ?cocoon-process? and send the reaction to the xslt
2) the xslt processor scans for the xml-stylesheet PIs and finds three
3) the first one with no media indication is used.

Now, what happens after the first transformation?

By default, all XSLT processor _MUST_ remove all processing instructions
if they are not explicitly told not to do so. So, when the processed
document comes back into the reactor, no PI is there and the document is
correctly sent to the client.

So, how do you do multiple transformations?

simply by making the first stylesheet place the wanted PIs for your, for

 <xsl:template match="/">
  <xsl:processing-instruction name="xml-stylesheet">type="text/xsl"



and so on.

You can make as many transformations as you like using this.

But I warn you: this is clearly a bad practice and Cocoon2 will remove
all the pipeline driving information inside the sitemap and that would
me much easier both to program and to maintain.

Hope this helps.

Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<>                             Friedrich Nietzsche
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------

View raw message