You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by John Carroll <jc...@micromuse.com> on 2000/03/21 16:25:40 UTC

2 xslt transformations

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.

thanks in advance,

John.



Re: 2 xslt transformations

Posted by Ulrich Mayring <ul...@denic.de>.
john@micromuse.com 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.

The easiest thing is to import or include the second stylesheet in the
first.

Otherwise, look at the XSP samples supplied with cocoon. The first
stylesheet is an XSP stylesheet and that calls an XSL stylesheet, when
it's done.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Softwareentwicklung

Re: 2 xslt transformations

Posted by Jonathan Borden <jb...@mediaone.net>.
K.C. Jones wrote:
> > By default, all XSLT processor _MUST_ remove all
> > processing instructions if they are not explicitly told
> > not to do so. [...]  simply by making the first stylesheet
> > place the wanted PIs for your, for example
>
> Doesn't your example creates a hardwired link between the
> two XSLT transforms?  This is a pretty limiting constraint.
> Is there a 'standard' parametric approach to pipelining a
> series of XSLTs?  I would like to treat different XML-->XML
> xforms as autonomous building blocks.
>

    I have been working on this specific issue. What I have developed is an
XML notation describing links between different XSLT transformations, inputs
and outputs. I've developed two implementations of this, one which operates
within Cocoon 1 and dynamically passes Documents between transforms and
other operations. The second implementation uses XSLT to generate Java
servlets which link the component SAX event streams. I am working on a white
paper describing this 'notation' and will post a link once it is complete.

Jonathan Borden



Re: 2 xslt transformations

Posted by "K.C. Jones" <kj...@phoenix-pop.com>.
> By default, all XSLT processor _MUST_ remove all
> processing instructions if they are not explicitly told
> not to do so. [...]  simply by making the first stylesheet
> place the wanted PIs for your, for example

Doesn't your example creates a hardwired link between the
two XSLT transforms?  This is a pretty limiting constraint.
Is there a 'standard' parametric approach to pipelining a
series of XSLTs?  I would like to treat different XML-->XML
xforms as autonomous building blocks.

I think I can see how this could be achieved via tags in the
XML data stream -- but that too is sort of limiting.  Maybe
variables?  (Dr. Dudgeon's suggestion sounds like it might fit.
I'll have to chew on this for a while...)

kc jones
phoenix-pop productions
415.934.7719
kjones@phoenix-pop.com

Re: 2 xslt transformations

Posted by Stefano Mazzocchi <st...@apache.org>.
Michael Glenn wrote:
> 
> John Carroll wrote:
> >
> > Is it possible to run an xml file through 2 different xsl
> > transformations using 2 xsl stylesheets?

yes.

> > 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
processor
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
example

 <xsl:template match="/">
  <xsl:processing-instruction
name="cocoon-process">type="xslt"</xsl:processing-instruction>
  <xsl:processing-instruction name="xml-stylesheet">type="text/xsl"
href="sheet2.xsl"</xsl:processing-instruction> 

  ...

 </xsl:template>

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.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: 2 xslt transformations

Posted by Sachin Petkar <sa...@metaphasetech.com>.
This is definitely a good idea - it allows the use of a single
"basic" XML format with multiple sub-formats of XML.  This would
be useful when two different applications want to share the XML
but require a slightly different structure, with some metadata.
The appropriate metadata could be added by the first XSL stylesheet
and then the second one could perform rendering (or anything else).


Sachin



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. I don't believe
> this violates any rules and makes it a hell of a lot easier to implement
> different layers of filtering and styling. If anyone else thinks this is
> a good idea let me know. If there are any objective state those too.
> 
> --
> Michael Glenn, http://www.mglenn.com
> Principal and Web Architect
> North 49 Design
> http://www.north49design.com
> 
> -----BEGIN PGP PUBLIC KEY BLOCK-----
> Version: PGPfreeware 6.5.2 for non-commercial use <http://www.pgp.com>
> 
> mQGiBDi1W3gRBADgkh1Qvms9Qz1zpStGDdSs36K0KGX8mhuXMn21C6cE9DQ4V6d7
> S8yQo+fFwos0lV+iIy0vWomq2LI1tiniV46v8cn7OyM0QI2c4IVgNn7h5hwq8Yue
> RmdSk9Nc1B8FJjWXZKkAxrZ9UtBRpl1USUnh8NnN0uQ+4pB9QoRK77OFnQCg/8hh
> KqMCe7y3FF5jHtSK/pHT308D/ifQNxg97Sp1BQxrOGA07Jj4MbWwZDUZH3h0loSJ
> TmqEZU8dykPFu3+MCgiUP6en2b5Qk0r/ayHiS7cOwCMUnsmI2Ys4TC36w2CXIhUh
> yt8xWqR8uGJDw3OsRr4bOgOm2rhcBtsCx4CSCZ80ysWcDT2KERg4l9kgP1poI27x
> l38MA/9cJiLDhT84+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d547AJ9ze+4zXlsv/NdX
> GhsLTWp+BOQEvACgqEN5l2RiBVEYJDx1ktz9cSuvcrI=
> =KXHB
> -----END PGP PUBLIC KEY BLOCK-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

-- 
-----------------------------
Sachin Petkar                        Email:
sachin.petkar@metaphasetech.com
Metaphase Technology Division/SDRC   Phone: (513) 576-7140
2000 Eastman Drive                   Fax  : (513) 576-7691
Milford OH 45150                     http://www.metaphasetech.com/

Re: 2 xslt transformations

Posted by Michael Glenn <mi...@mglenn.com>.
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. I don't believe
this violates any rules and makes it a hell of a lot easier to implement
different layers of filtering and styling. If anyone else thinks this is
a good idea let me know. If there are any objective state those too.

-- 
Michael Glenn, http://www.mglenn.com
Principal and Web Architect
North 49 Design
http://www.north49design.com

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGPfreeware 6.5.2 for non-commercial use <http://www.pgp.com>

mQGiBDi1W3gRBADgkh1Qvms9Qz1zpStGDdSs36K0KGX8mhuXMn21C6cE9DQ4V6d7
S8yQo+fFwos0lV+iIy0vWomq2LI1tiniV46v8cn7OyM0QI2c4IVgNn7h5hwq8Yue
RmdSk9Nc1B8FJjWXZKkAxrZ9UtBRpl1USUnh8NnN0uQ+4pB9QoRK77OFnQCg/8hh
KqMCe7y3FF5jHtSK/pHT308D/ifQNxg97Sp1BQxrOGA07Jj4MbWwZDUZH3h0loSJ
TmqEZU8dykPFu3+MCgiUP6en2b5Qk0r/ayHiS7cOwCMUnsmI2Ys4TC36w2CXIhUh
yt8xWqR8uGJDw3OsRr4bOgOm2rhcBtsCx4CSCZ80ysWcDT2KER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