You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Donald Ball <ba...@webslingerZ.com> on 2001/01/09 19:14:07 UTC
Re: News site with XSP and SQL. (fwd)
---------- Forwarded message ----------
Date: Tue, 9 Jan 2001 00:29:24 -0500 (EST)
From: Donald Ball <ba...@webslingerZ.com>
To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
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
information.
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. 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>
...
<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-template></xsl:variable>
<xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
</xsl:template>
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
RE: News site with XSP and SQL. (fwd)
Posted by Vadim Gritsenko <vg...@hns.com>.
> -----Original Message-----
> From: Donald Ball [mailto:balld@webslingerZ.com]
> Sent: Wednesday, January 10, 2001 16:11
> To: cocoon-users@xml.apache.org
> Subject: RE: News site with XSP and SQL. (fwd)
>
>
> On Tue, 9 Jan 2001, Vadim Gritsenko wrote:
>
> > This is called "hierarchical query clause", see
> >
>
http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.
> > 817/a85397/state21b.htm for details.
> >
> > request to select all news and build tree can look like:
> >
> > SELECT * FROM news START WITH parentid IS NULL CONNECT BY PRIOR id =
> > parentid;
>
> is that standard SQL at all, do you know?
I *think* that it is definitely not a standard but Oracle extension :)
That's why I asked about Oracle database first
>
> - donald
Vadim
RE: News site with XSP and SQL. (fwd)
Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 9 Jan 2001, Vadim Gritsenko wrote:
> This is called "hierarchical query clause", see
> http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.
> 817/a85397/state21b.htm for details.
>
> request to select all news and build tree can look like:
>
> SELECT * FROM news START WITH parentid IS NULL CONNECT BY PRIOR id =
> parentid;
is that standard SQL at all, do you know?
- donald
RE: News site with XSP and SQL. (fwd)
Posted by Vadim Gritsenko <vg...@hns.com>.
This is called "hierarchical query clause", see
http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.
817/a85397/state21b.htm for details.
request to select all news and build tree can look like:
SELECT * FROM news START WITH parentid IS NULL CONNECT BY PRIOR id =
parentid;
Vadim
> -----Original Message-----
> From: Donald Ball [mailto:balld@webslingerZ.com]
> Sent: Tuesday, January 09, 2001 13:49
> To: cocoon-users@xml.apache.org
> Subject: RE: News site with XSP and SQL. (fwd)
>
>
> On Tue, 9 Jan 2001, Vadim Gritsenko wrote:
>
> > If you are doing this on Oracle, Oracle can build tree of
> comments for you.
> > In SELECT, you should just connect parent record with childs.
> > Can this help?
>
> what would this query look like?
>
> - donald
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
RE: News site with XSP and SQL. (fwd)
Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 9 Jan 2001, Vadim Gritsenko wrote:
> If you are doing this on Oracle, Oracle can build tree of comments for you.
> In SELECT, you should just connect parent record with childs.
> Can this help?
what would this query look like?
- donald
RE: News site with XSP and SQL. (fwd)
Posted by Vadim Gritsenko <vg...@hns.com>.
> -----Original Message-----
> From: Donald Ball [mailto:balld@webslingerZ.com]
> Sent: Tuesday, January 09, 2001 13:14
> To: cocoon-users@xml.apache.org; xsp-dev@xml.apache.org
> Subject: Re: News site with XSP and SQL. (fwd)
>
> ---------- Forwarded message ----------
> Date: Tue, 9 Jan 2001 00:29:24 -0500 (EST)
> From: Donald Ball <ba...@webslingerZ.com>
> To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
> 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?
If you are doing this on Oracle, Oracle can build tree of comments for you.
In SELECT, you should just connect parent record with childs.
Can this help?
Vadim
Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Posted by Donald Ball <ba...@webslingerZ.com>.
On Fri, 12 Jan 2001, Tagunov Anthony wrote:
> >i suppose i should offer an alternate suggestion. we've kicked around the
> >idea before of adding an xsp:variable element to the xsp language.
> >something like this:
> >
> ><xsp:logic>
> > <xsp:variable type="String" name="name">"foo"</xsp:variable>
> > ...
> ></xsp:logic>
> >
> >would turn into
> >
> >String name = "foo";
> >
> >then you could have utility methods, not necessarily part of the xsp
> >language proper, which would generate method headers and calls:
> >
> ><xsl:template match="util:generate-method-header">
> > <xsl:param name="name"/>
> > <xsl:param name="type"/>
> > <xsl:value-of select="$type"/>
> > <xsl:text> </xsl:text>
> > <xsl:value-of select="$name"/>
> > <xsl:text>(HttpServletResponse response, ...</xsl:text>
> > <xsl:for-each select="//xsp:variable">
> > <xsl:text>,<xsl:text>
> > <xsl:value-of select="@type"/>
> > <xsl:text> </xsl:text>
> > <xsl:value-of select="@name"/>
> > </xsl:for-each>
> > <xsl:text>) </xsl:text>
> ></xsl:template>
> >
> >if anyone thinks this is a good compromise solution, i'll try to prototype
> >something more comprehensive.
>
> Excuse my being too persistent.. To me (a green novice :) it looks
> good! (As far as I understand what we want is single Schemo for
> various languages, isn't it?) And surely there should be something to
> add additional parameters to the method (f.e. I've got a method void
> sendEmail(String email, String password), so I'd like additional
> arguments (email and password there). And we need a way to generate
> invocations for these methods!
i just checked in experimental support for this for c1. you declare
variables using the xsp:variable element:
<xsp:element name="foo" type="String"/>
they're set to null by default, but you can give a value attribute to
initialize if you want. you can generate and call methods like so:
<xsp:page>
<xsp:logic>
<util:generate-method-header name="myMethod" returns="void"/> {
...
}
</xsp:logic>
<page>
<xsp:logic>
<util:call-method name="myMethod"/>;
</xsp:logic>
</page>
</xsp:page>
i'm interested to hear what people think.
- donald
Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Posted by Donald Ball <ba...@webslingerZ.com>.
On Fri, 12 Jan 2001, Tagunov Anthony wrote:
> >i suppose i should offer an alternate suggestion. we've kicked around the
> >idea before of adding an xsp:variable element to the xsp language.
> >something like this:
> >
> ><xsp:logic>
> > <xsp:variable type="String" name="name">"foo"</xsp:variable>
> > ...
> ></xsp:logic>
> >
> >would turn into
> >
> >String name = "foo";
> >
> >then you could have utility methods, not necessarily part of the xsp
> >language proper, which would generate method headers and calls:
> >
> ><xsl:template match="util:generate-method-header">
> > <xsl:param name="name"/>
> > <xsl:param name="type"/>
> > <xsl:value-of select="$type"/>
> > <xsl:text> </xsl:text>
> > <xsl:value-of select="$name"/>
> > <xsl:text>(HttpServletResponse response, ...</xsl:text>
> > <xsl:for-each select="//xsp:variable">
> > <xsl:text>,<xsl:text>
> > <xsl:value-of select="@type"/>
> > <xsl:text> </xsl:text>
> > <xsl:value-of select="@name"/>
> > </xsl:for-each>
> > <xsl:text>) </xsl:text>
> ></xsl:template>
> >
> >if anyone thinks this is a good compromise solution, i'll try to prototype
> >something more comprehensive.
>
> Excuse my being too persistent.. To me (a green novice :) it looks
> good! (As far as I understand what we want is single Schemo for
> various languages, isn't it?) And surely there should be something to
> add additional parameters to the method (f.e. I've got a method void
> sendEmail(String email, String password), so I'd like additional
> arguments (email and password there). And we need a way to generate
> invocations for these methods!
i just checked in experimental support for this for c1. you declare
variables using the xsp:variable element:
<xsp:element name="foo" type="String"/>
they're set to null by default, but you can give a value attribute to
initialize if you want. you can generate and call methods like so:
<xsp:page>
<xsp:logic>
<util:generate-method-header name="myMethod" returns="void"/> {
...
}
</xsp:logic>
<page>
<xsp:logic>
<util:call-method name="myMethod"/>;
</xsp:logic>
</page>
</xsp:page>
i'm interested to hear what people think.
- donald
Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Posted by Tagunov Anthony <at...@nnt.ru>.
Hello!
On Thu, 11 Jan 2001 01:55:19 -0500 (EST), Donald Ball wrote:
>On Wed, 10 Jan 2001, Tagunov Anthony wrote:
>
>> >> 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
>> >information.
>> >
>> >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 :)
>
>hmm. i'm of two minds about this proposed addition to the xsp language. on
>the one hand, it sure does solve the problem xsp developers face when
>trying to put xsp code into methods. on the other hand, it strikes me as a
>real kludge, and i wonder how language-independent it really is.
>
>i suppose i should offer an alternate suggestion. we've kicked around the
>idea before of adding an xsp:variable element to the xsp language.
>something like this:
>
><xsp:logic>
> <xsp:variable type="String" name="name">"foo"</xsp:variable>
> ...
></xsp:logic>
>
>would turn into
>
>String name = "foo";
>
>then you could have utility methods, not necessarily part of the xsp
>language proper, which would generate method headers and calls:
>
><xsl:template match="util:generate-method-header">
> <xsl:param name="name"/>
> <xsl:param name="type"/>
> <xsl:value-of select="$type"/>
> <xsl:text> </xsl:text>
> <xsl:value-of select="$name"/>
> <xsl:text>(HttpServletResponse response, ...</xsl:text>
> <xsl:for-each select="//xsp:variable">
> <xsl:text>,<xsl:text>
> <xsl:value-of select="@type"/>
> <xsl:text> </xsl:text>
> <xsl:value-of select="@name"/>
> </xsl:for-each>
> <xsl:text>) </xsl:text>
></xsl:template>
>
>if anyone thinks this is a good compromise solution, i'll try to prototype
>something more comprehensive.
>
>- donald
Excuse my being too persistent.. To me (a green novice :) it looks good! (As far as I understand
what we want is single Schemo for various languages, isn't it?) And surely there should be something to add additional
parameters to the method (f.e. I've got a method void sendEmail(String email, String password), so I'd like additional
arguments (email and password there). And we need a way to generate invocations for these methods!
Best regards,
Tagunov Anthony
Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 10 Jan 2001, Tagunov Anthony wrote:
> >> 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
> >information.
> >
> >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 :)
hmm. i'm of two minds about this proposed addition to the xsp language. on
the one hand, it sure does solve the problem xsp developers face when
trying to put xsp code into methods. on the other hand, it strikes me as a
real kludge, and i wonder how language-independent it really is.
i suppose i should offer an alternate suggestion. we've kicked around the
idea before of adding an xsp:variable element to the xsp language.
something like this:
<xsp:logic>
<xsp:variable type="String" name="name">"foo"</xsp:variable>
...
</xsp:logic>
would turn into
String name = "foo";
then you could have utility methods, not necessarily part of the xsp
language proper, which would generate method headers and calls:
<xsl:template match="util:generate-method-header">
<xsl:param name="name"/>
<xsl:param name="type"/>
<xsl:value-of select="$type"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>(HttpServletResponse response, ...</xsl:text>
<xsl:for-each select="//xsp:variable">
<xsl:text>,<xsl:text>
<xsl:value-of select="@type"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
</xsl:for-each>
<xsl:text>) </xsl:text>
</xsl:template>
if anyone thinks this is a good compromise solution, i'll try to prototype
something more comprehensive.
- donald
Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Posted by Tagunov Anthony <at...@nnt.ru>.
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 <ba...@webslingerZ.com>
>To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
>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
>information.
>
>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 :)
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>
>
>...
>
><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-
template></xsl:variable>
> <xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
></xsl:template>
>
>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
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Posted by Tagunov Anthony <at...@nnt.ru>.
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 <ba...@webslingerZ.com>
>To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
>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
>information.
>
>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 :)
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>
>
>...
>
><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-
template></xsl:variable>
> <xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
></xsl:template>
>
>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
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
Re: News site with XSP and SQL. (fwd)
Posted by Tagunov Anthony <at...@nnt.ru>.
From: "Tagunov Anthony" <at...@nnt.ru>
To: "cocoon-dev@xml.apache.org" <co...@xml.apache.org>,
"cocoon-users@xml.apache.org" <co...@xml.apache.org>,
"Donald Ball" <ba...@webslingerZ.com>,
"xsp-dev@xml.apache.org" <xs...@xml.apache.org>
Date: Wed, 10 Jan 2001 12:20:27 +0300
Reply-To: "Tagunov Anthony" <at...@nnt.ru>
Priority: Normal
X-Mailer: PMMail 2000 Professional (2.10.2010) For Windows NT (4.0.1381;6)
In-Reply-To: <Pi...@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 <ba...@webslingerZ.com>
>To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
>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
>information.
>
>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>
>
>...
>
><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-
template></xsl:variable>
> <xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
></xsl:template>
>
>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
Re: News site with XSP and SQL. (fwd)
Posted by Tagunov Anthony <at...@nnt.ru>.
From: "Tagunov Anthony" <at...@nnt.ru>
To: "cocoon-dev@xml.apache.org" <co...@xml.apache.org>,
"cocoon-users@xml.apache.org" <co...@xml.apache.org>,
"Donald Ball" <ba...@webslingerZ.com>,
"xsp-dev@xml.apache.org" <xs...@xml.apache.org>
Date: Wed, 10 Jan 2001 12:20:27 +0300
Reply-To: "Tagunov Anthony" <at...@nnt.ru>
Priority: Normal
X-Mailer: PMMail 2000 Professional (2.10.2010) For Windows NT (4.0.1381;6)
In-Reply-To: <Pi...@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 <ba...@webslingerZ.com>
>To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
>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
>information.
>
>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>
>
>...
>
><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-
template></xsl:variable>
> <xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
></xsl:template>
>
>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
Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Posted by Tagunov Anthony <at...@nnt.ru>.
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 <ba...@webslingerZ.com>
>To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
>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
>information.
>
>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 :)
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>
>
>...
>
><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-
template></xsl:variable>
> <xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
></xsl:template>
>
>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
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
Re: News site with XSP and SQL. (fwd)
Posted by Tagunov Anthony <at...@nnt.ru>.
From: "Tagunov Anthony" <at...@nnt.ru>
To: "cocoon-dev@xml.apache.org" <co...@xml.apache.org>,
"cocoon-users@xml.apache.org" <co...@xml.apache.org>,
"Donald Ball" <ba...@webslingerZ.com>,
"xsp-dev@xml.apache.org" <xs...@xml.apache.org>
Date: Wed, 10 Jan 2001 12:20:27 +0300
Reply-To: "Tagunov Anthony" <at...@nnt.ru>
Priority: Normal
X-Mailer: PMMail 2000 Professional (2.10.2010) For Windows NT (4.0.1381;6)
In-Reply-To: <Pi...@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 <ba...@webslingerZ.com>
>To: Cocoon-Users <co...@xml.apache.org>, xsp-dev@xml.apache.org
>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
>information.
>
>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>
>
>...
>
><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-
template></xsl:variable>
> <xsp:logic>showComments(new Integer(<xsl:value-of select="$id"/>));</xsp:logic>
></xsl:template>
>
>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