You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Yao, Di" <dy...@profilesys.com> on 2000/07/19 14:16:53 UTC

dynamic xml in two formats of presentation(html & pdf)

Hi,
I want to present xml files(generated by servlets) in html/pdf. Since I do
not want to regenerate the xml files everytime when user clicks on html/pdf
to change the format. I decided to generate xml file only once per session,
delete the files when session is over.
The easiest way to achieve it(seems to me) is to dump the xml file to some
directory when generated, then redirect user to that directory with some
parameter(to determine xsl), let cocoon handles the rest. 
Is this a practical(or good) way to do it? 
Anyone has sample code for generating the similar things? The source code in
cocoon package is not very instructive.
I am a new comer to cocoon, any advice is highly appreciated.

Best regards.

Yaodi

Re: dynamic xml in two formats of presentation(html & pdf)

Posted by sudhi <su...@insage.com>.
Hi...
U can do it just by applying different stylesheet based on some
parameter.
Here is what I do. I have an xml page. Depending on a parameter I choose
one of the style sheet. I don't know whether its the best way to do it.
But it works for me :-)
here is the snippet...
---------------------------------------
<?xml version="1.0" standalone="no"?>
<?cocoon-process type="xsp"?>

<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<PAGE>
<xsp:logic>
String file = "dynamic.en.xsl";
String param = null;
param = (String)request.getParameter("file");
if (param != null &amp;&amp; !param.equals("")){
        if ( param.equals("cn"))
                file = "dynamic.cn.xsl";
}
</xsp:logic>
<xsp:pi target="cocoon-process">type="xslt"</xsp:pi>
<xsp:pi target="xml-stylesheet">href="<xsp:expr>file</xsp:expr>"
type="text/xsl"</xsp:pi>

<NEWS>
<TITLE>test</TITLE>
</NEWS>
<FILE><xsp:expr>file</xsp:expr>:<xsp:expr>param</xsp:expr></FILE>
</PAGE>
</xsp:page>
---------------------------------------
This is how I call thepage...
page.xml?file=cn or page.xml?file=en

HTH
Sudhi

"Yao, Di" wrote:
> 
> Hi,
> I want to present xml files(generated by servlets) in html/pdf. Since I do
> not want to regenerate the xml files everytime when user clicks on html/pdf
> to change the format. I decided to generate xml file only once per session,
> delete the files when session is over.
> The easiest way to achieve it(seems to me) is to dump the xml file to some
> directory when generated, then redirect user to that directory with some
> parameter(to determine xsl), let cocoon handles the rest.
> Is this a practical(or good) way to do it?
> Anyone has sample code for generating the similar things? The source code in
> cocoon package is not very instructive.
> I am a new comer to cocoon, any advice is highly appreciated.
> 
> Best regards.
> 
> Yaodi
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org