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.. -->
</fail>
</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]>