You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Manuel Mall <MM...@arcus.com.au> on 2000/08/17 05:27:10 UTC

How to attached a different stylesheet

Firstly I am fairly new to cocoon and secondly the cocoon mailing list
archives appear unreachable. Therefore my apologies if this question is
either trivial or has been asked and answered before.

I need to implement sort of a report writer (document producer) based on
information retrieved from a database. So I am using the XSP SQL stuff to
get the data out of the (MySQL) database. Now, depending on the value of a
field retrieved from the database (or depending on a field in the resulting
XML) I would like to invoke a different FOP stylesheet to produce the
desired PDF output, ie. I want to have a different look and feel depending
on a database value. Is this possible? All examples I have seen which attach
multiple or different stylesheets to the same XML document are based around
the media attribute. This doesn't appear to work in my case.

Thanks

Manuel

Re: How to attached a different stylesheet

Posted by Sebastien Koechlin <sk...@ivision.fr>.
Manuel Mall wrote:

> Now, depending on the value of a
> field retrieved from the database (or depending on a field in the resulting
> XML) I would like to invoke a different FOP stylesheet to produce the
> desired PDF output, ie. I want to have a different look and feel depending
> on a database value. Is this possible? 

Yes, it is. But you have to write it in java, as no taglib will help
you.

Add a PI with the right value with <xsp:pi>, or with something like:

document.insertBefore(
    document.createProcessingInstruction(
        "xml-stylesheet",
        "type=\"text/xsl\" href=\"mode_A.wml.xsl\""
    ),
    xspCurrentNode);

-- 
Sébastien Koechlin