You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lars Huttar <la...@sil.org> on 2003/11/20 04:59:33 UTC

how to use output of transform in sitemap

Hi all,
I'm having a tough time figuring out how to use the output
of a transformation in the sitemap.
The task is fairly simple user authentication. Pseudocode for
the desired operation:

1) check the id and password request params against the user database (users.xml)
   <map:generate src="data/users.xml" />
   <map:transform src="transforms/authenticate.xsl" />

The stylesheet checks the id and password params against users.xml
for a match. It outputs <success userid="lars"/> if successful; <failed/>
otherwise.

2) If step 1 was successful, create a session and store the valid
  of userid in it; then redirect to the "menu" pipeline.
   Otherwise, redirect to the "login?login-failed=true" pipeline,
   which will present an error message and a login form.

PROBLEM: how to get the result from step 1 into a form that can
be used by the sitemap for a conditional to control step 2?
The only thing I can think of would be for authenticate.xsl
to generate XML for the "session" transformer, conditional on
the success of authentication. So the pipeline looks like
   <map:generate src="data/users.xml" />
   <map:transform src="transforms/authenticate.xsl" />
   <map:transform type="session" />
The "session" transformer code could create a session and write
the userid into a session context. However, I still have the problem
that at some point in the pipeline, I need to do things (namely,
redirect to another URL) which cannot be done by a transformer,
at least not that I know of. So I have to get the authentication
result (success or failure) out of the XML stream into something
the sitemap can use. How do I do that?

Also, the "session" transformer has the drawback that it writes
session contexts but cannot write session attributes. This means
that later on, when the user tries to access a document and so
we have to the current session for a userid, we're stuck...
there are Input Modules (session-attr) for accessing session
attributes, but not session contexts. Nor can I use
SessionSelector for a conditional because it wants session
attributes.

Any help would be greatly appreciated!

Yes, I've looked at the Authentication Framework but it doesn't
seem to do what we need.

I've counted about 8 different ways to access sessions in Cocoon,
all for use in different contexts and with different limitations,
and with documentation in varying degrees of scattered sparseness...
if I had more hair to spare I'd be pulling it!  :-#

Lars


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: how to use output of transform in sitemap

Posted by Lars Huttar <la...@sil.org>.
Hi all,
To answer my own question, a good way to get output of a pipeline
for use in the sitemap is to use the XSPAction action.
This lets you run an XSP page created by a pipeline; the XSP code
can then use <action:set-success>, <action:set-result ... />
and so on to send results out to the sitemap.
This also allows me to put session:set-attribute instructions in
the XSP code, as desired; and I can do the redirects in the
sitemap, conditional on success or failure as determined by
the XSP code.

Regards,
Lars

> -----Original Message-----
> From: Lars Huttar [mailto:lars_huttar@sil.org]
> Sent: Wednesday, November 19, 2003 10:00 PM
> 
> Hi all,
> I'm having a tough time figuring out how to use the output
> of a transformation in the sitemap.
> The task is fairly simple user authentication. Pseudocode for
> the desired operation:
> 
> 1) check the id and password request params against the user 
> database (users.xml)
>    <map:generate src="data/users.xml" />
>    <map:transform src="transforms/authenticate.xsl" />
> 
> The stylesheet checks the id and password params against users.xml
> for a match. It outputs <success userid="lars"/> if 
> successful; <failed/>
> otherwise.
> 
> 2) If step 1 was successful, create a session and store the valid
>   of userid in it; then redirect to the "menu" pipeline.
>    Otherwise, redirect to the "login?login-failed=true" pipeline,
>    which will present an error message and a login form.
> 
> PROBLEM: how to get the result from step 1 into a form that can
> be used by the sitemap for a conditional to control step 2?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org