Thank you very much, i will try this now (just have to read about XSP and
sessions first :-)...

Just a final question about C2 as it seems you know about it's inner
working. The class that gets created as a cache for my largefile.xml
document. does it contain my entire document? (since i could delete the
original file...) is it keept in memory? I would have to buy some more ram
chips i guess ;-)


mvh karl


On Thu, 9 Aug 2001, Karl Oie wrote:

> i think i understand, but won't this put a lot of processing on the
server?
> the toc.xsl takes about 3 minutes to generate. if i apply the logic in the
> XSP page the page will have to process the entire XML document each time?

Well not exactly.
The entire document gets processed ONLY when you ask the page for
the first time.
A class is generated then, consisting of your toc.xsl applied to
the original document.
If your xsp file was empty, the result would be a java-file which produces
your XML document as SAX events. You COULD delete your xml file once
the java file is generated, because it is not needed anymore (but you
shouldn't because cocoon depends on the file to be there ;)

So basically your xml document is replaced by code that fires SAX
events to the contenthandler (the first stylesheet in your pipeline).

Therefore, everytime your page gets requested the cached class file
gets called.

Your xml page will not be entirely passed through the pipeline,
because not all the code that fires the SAX events get called.

I hope you understand..
You might want to try this out with a small xml file, consisting
of only 2 tags, and a simple if-then-else statement depending
on a query parameter 'section=one' or 'two'.
Check the generated source file, it should be
in tomcats 'work' dir under
$TOMCAT_HOME/work/localhost%F8080/[servlet-zone]/org/apache/www/..._xml.java
that should clarify it for you (search for the 'generate' function).

There is another way to accomplish this. This is done as follows:
let your XSP page add an XML tag in the result, for instance
if (....)
{ 
  <xsp:content>
    <some-tag-one>
  </xsp:content>
}
else 
 <!-- some other tag -->

and let your stylesheet (NOT toc.xsl :)) check for that tag,
and then process some part of your input xml file.
This way, the document WILL get parsed EVERY time, ENTIRELY.
THis is the slow and ugly way.

So use XSP and it will be fast ;)

(btw: i've coded my own cocoon clone with XSP which is a lot faster
than cocoon, simply because it is not as modular as cocoon. That's
why I understand cocoon so well :))

Hope this helps, if not, feel free to ask.

> 
> mvh karl
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 9. august 2001 18:15
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: newbie question: (XML->XSLT) cached -> session logic ->
> browser??
> 
> 
> 
> Just create an XSP page,
> with a template matching the root element of your xml page.
> Then do some if-then-else based on your session.
> In each 'if' body you do something like this:
> 
>   if (some_session_based_expression)
>   {
>       <xsl:call-template name="henk"/>
>   }
>   else if (....)
> ....
> 
> The template 'henk' is inserted in the place of the call.
> If it just consists of content, it looks like this:
> 
> <xsl:template name="henk">
>   <xsp:content>
>     <!-- xsl code that applies templates to the parts you want -->
>   </xsp:content>
> </xsl:template>
> 
> This way you get 1 producer/generator, which can produce all the
> different pages you want (that is, sections of your XML document)
> based on some viariables in the session.
> 
> 
> I use this technique to validate users:
> 
> The XML document:
> 
>       <nsp:auth group="users">
>           <success>
>             <!-- data you want to show when the user is logged
>                  in and belongs to that group -->
>           </success>
>           <fail>
>             <nsp:login-form/> <!-- or some other xml code.. -->
>           </f
ail>
>         </nsp:auth>
>
> The xsp page:
>
> <xsl:template match="nsp:auth">
>   <xsp:logic>
>     if (userInGroup("<xsl:value-of select="@group"/>"))
>     {
>       <xsp:content>
>       <xsl:apply-templates select="success"/>
>         </xsp:content>
>     }
>     else
>     {
>       <xsp:content>
>         <xsl:apply-templates select="fail"/>
>         </xsp:content>
>     }
>   </xsp:logic>
>
> </xsl:template>
>
>
> The UserInGroup checks the session for a user object, standard code..
>
> Hope this helps,
>
>       Kenney Westerhof
>
> On Thu, 9 Aug 2001, Karl Oie wrote:
>
> > Hi, im pretty new to cocoon2 so i need some advice about the best
aproach
> > for my problem;
> >
> > I got a quite large XML file which i use a XSL stylesheet to extract
only
> > parts of, but the XML file might change so i set this up as the
generator.
> >
> > <map:match pattern="toc.html">
> >     <map:generate src="largefile.xml"/>
> >     <map:transform src="toc.xsl"/>
> >
> >     ... perform logic on the result based on sessions ...
> >
> >     <map:serialize type="html"/>
> > </map:match>
> >
> > Then based on the the user's session state i want to perform logic on
the
> > extract, to hide and show elements (this is a session based toc).
> >
> > What can i use to do this, a XSP, JSP, write a new
> > generator/transformer/serializer ?
> >
> > Is it possible to place session handling in a custom serializer? is this
a
> > job for a transformer, and will i then have to implement it myself and
is
> it
> > then possible to add session handling?
> >
> > Should i create a custom generator, if so how to implement caching and
> > session handling?
> >
> > I'm quite good at java, but i'm new to cocoon and need some pointers in
> the
> > right direction.
> >
> > in advance thanks!
> >
> > mvh Karl
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> > For additional commands, e-mail: <[EMAIL PROTECTED]>
> >
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to