cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@neonics.com
Subject XSP decisions about XML (was: Check for user login)
Date Fri, 26 Jan 2001 21:56:34 GMT


Ok, I've been playing around with the logicsheet a bit and below is what
I've come up with.

But let me rephrase:

Logicsheets produce XML that is transformed by the stylesheet.
I want to make a decision in the logicsheet about WHAT XML I produce,
that should be possible. This goes further than the login-check question.

Here's my default logicsheet (lots of it left out):

<xsl:template match="xsp:page">
  <xsp:page>
    <xsl:apply-templates select="@*"/>
    <xsp:structure>
    </xsp:structure>
    <xsp:logic>
       ...
    </xsp:logic>

    <xsl:apply-templates/>
  </xsp:page>
</xsl:template>

I replaced the '<xsl:apply-templates/>' with the following:

    <xsl:variable name="logged_in">false</xsl:variable>

    <xsl:choose>
      <xsl:when test="$logged_in = 'false'">
        <loginpage/>
      </xsl:when>

      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>


This works fine.
But I want to be able to replace the static 'false' parth with some
java code, as follows:

    <xsl:variable name="logged_in">
      <xsp:expr>request.getParameter("piet")</xsp:expr>
    </xsp:variable>

Something like that (easy testing ;))
This however does not work.

The main idea is to transfer a java variable to an xsl variable..
It seems possible to make a template which 'body' consists of an xsp:expr
section. It is also possible to load an xsl:variable with a call to a
template. So I don't see why this does not compile (I don't use that
technique but still, the above should be possible).

The compilation error is something like 'the xsp:expr tag should be closed
by a matching </xsp:expr> tag'..

when i use the static version (without the xsp:expr code) it works fine..

Any help?


On Fri, 26 Jan 2001, Drasko Kokic wrote:

> 
> --- Forge <forge@neonics.com> wrote:
> > 
> > Hi there,
> > 
> > I want to check if a user has logged in. If so, I
> > want to show the normal
> > content. If not, I wish to show him a login page.
> > 
> > I'm using a default setup: xml page, taglib, xsl
> > sheet.
> > 
> > My idea was to replace the entire body with a
> > <loginpage/> tag
> > which is processed by the logicsheet.
> > Somewhere in the logicsheet i need to decide what
> > page to show.
> > I tried to match the xsp:page/page node and replace
> > it, no success.
> > I also tried to move the <xsl:apply-templates/> tag
> > which usually 
> > comes AFTER the xsp:logic section of my taglib into
> > the logic section
> > (surrounding it by <xsp:content> tags), and
> > surrounding it by logic to
> > test wheter a user has logged in. 
> > None of the above works.
> > 
> > Any ideas?
> > 
> > 
> 
> Maybe there is a small conceptual misunderstanding
> here:
> 
> - the logicsheet(s) are applied BEFORE the final code
> is compiled and executed ... therefore you cannot make
> any decision before you conclude if the user is valid
> or not.
> - one aproach is to redirect to another page for
> loging (simply call redirect)
> - another aproach is to apply your stylesheet (not
> logicsheet) to your <loginpage/> tag and generate a
> login form (for example)
> - my personal favourite is to use the authentication
> mechanism in the Servlet API 2.2 (implemented by
> Tomcat) which automatically does redirection to the
> predefined page to authenticate user ... this way you
> can implement a more generic
> authorisation/authentication schema which is very
> modular and abstract to the protected applications
> beneth.
> 
> HTH
> Drasko
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices. 
> http://auctions.yahoo.com/
> 
> ---------------------------------------------------------------------
> 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: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> 


Mime
View raw message