cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tagunov Anthony" <>
Subject Re: News site with XSP and SQL. (fwd)
Date Wed, 10 Jan 2001 09:36:05 GMT
From: "Tagunov Anthony" <>
To: "" <>,
	"" <>,
	"Donald Ball" <>,
	"" <>
Date: Wed, 10 Jan 2001 12:20:27 +0300
Reply-To: "Tagunov Anthony" <>
Priority: Normal
X-Mailer: PMMail 2000 Professional (2.10.2010) For Windows NT (4.0.1381;6)
In-Reply-To: <Pine.LNX.4.30.0101091313580.27724-100000@localhost.localdomain>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="_=_=_=IMA.BOUNDARY.G6XWM3138764=_=_=_"
Subject: Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP

Hello, Donald and evrybody!!

On Tue, 9 Jan 2001 13:14:07 -0500 (EST), Donald Ball wrote:

>---------- Forwarded message ----------
>Date: Tue, 9 Jan 2001 00:29:24 -0500 (EST)
>From: Donald Ball <>
>To: Cocoon-Users <>,
>Subject: Re: News site with XSP and SQL.
>On Sun, 7 Jan 2001, Christian Parpart wrote:
>> Hi,
>> my final goal is to create a site where
>> people can read news and can give comments.
>> The first step is done. You can read the news.
>> To create them and display it to the client
>> I am using MySQL.
>> Now my next step is to modify it in that way,
>> that the clients user can add a comment to a
>> news entry or add a comment to a taken comment
>> from a news entry. Here you're creating a tree
>> in SQL. That's not the problem, I think.
>> My problem is, to let them working fine with
>> XSP a.s.o.
>> My database record looks like this:
>> table news (
>> 	ID		bigint unsigned auto imcrement primary key not null,
>> 	ParentID	bigint unsigned not null,
>> 	Date		timestamp not null,
>> 	Author	varchar(40) not null,
>> 	AuthorEMail	varchar(40) not null,
>> 	Title		varchar(80) not null,
>> 	texttype	tinyint not null,
>> 	text		text not null
>> );
>> ID is the unique identification number of a
>> record(news entry or a comment). ParentID is
>> either zero, that means it is a news entry,
>> otherwise it has the ID from its parent,
>> mayby a news entry or a comment.
>> This works fine.
>> To display all news I can use a simple esql query.
>> But how can I use that to display its comments and
>> to display the comments of the comments and so on?
>as a matter of fact, i think you've stumbled on one of esql's shortcomings
>- i don't think you can do recursive queries to an arbitrary depth. that
>is to say, you could manually recurse to a fixed depth, but it would be a
>pain and look ugly to boot. the real problem is that when doing flow
>control using xsp logicsheets, you don't have access to request-time
>if you could put xsp elements inside functions, this would be possible,
>since then you could make request-time decisions about invoking blocks of
>xsp code - but doing that makes you have to pass the local xsp java
>variables into the function, which is sort of a headache - and i think,
>actually, impossible to do thoroughly since you don't know what variables
>other logicsheets will be defining that expressions you must evaluate
>depend on. 

Yes! That's it! I also hit this problem! And it looks general enough! Anyone who would write
functions for
XSP pages will hit the problem of these varibles!
That's what one of the patches I proposed for xsp-java.xsl was for..
Sending it again, hoping for a review :)

Look at the very bottom of xsp-java.diff.txt for how this patch could
potentially lead to finding a way to solve the problem discussed in this letter.

hmm, is there a way to get an array of the variables currently
>declared at the current function level in java? i know it's pretty easy to
>get at in perl... anyway, here's the idea:
><xsl:template match="xsp:page">
>  <xsp:logic>
>    void showComments(Integer id, Integer parent) throws Exception {
>      <esql:execute-query>
>        <xsp:logic>if (id != null) {
>          <esql:query><xsp:expr>"select id,title from news where id = "+id</xsp:expr></esql:query>
>        } else if (parent != null) {
>          <esql:query><xsp:expr>"select id,title from news where parentid
= "+parent</xsp:expr></esql:query>
>        }
>        <esql:results>
>          <esql:row-results>
>            <news>
>              <id><esql:get-string column="1"/></id>
>              <title><esql:get-string column="2"/></title>
>              <xsp:logic>showComments(null,new Integer(<esql:get-int column="1"/>));</xsp:logic>
>            </news>
>          </esql:row-results>
>        </esql:results>
>      }
>    </esql:execute-query>
>  </xsp:logic>
>  <xsl:apply-templates select="*|@*"/>
><xsl:template name="news:comments">
>  <xsl:variable name="id"><xsl:call-template name="get-nested-string"><xsl:with-param
name="content" select="news:id"/></xsl:call-
>  <xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
>but it's not going to work as is, because the showComments function will
>need access to xspCurrentNode, et. al., or their equivalents in c2, not to
>mention the esql local variables. any suggestions?
>- donald

Tagunov Anthony

View raw message