cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tagunov Anthony" <atagu...@nnt.ru>
Subject Re: esql Bug? joint to question
Date Sat, 30 Dec 2000 20:51:15 GMT
Hello, Matthew Cordes!

There's esql schema available at
http://xml.apache.org/websrc/index.cgi/xml-cocoon/samples/sql/esql.xsd

BTW it clearly showes that <esql:no-results> should still be <esql:results> sibling.
I also noticed that I couldn't get it instantinated 
with the latest version of esql.xsl (from http://xml.apache.org/websrc/index.cgi/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/sql/esql.xsl)
Maybe it is just a bug? There's an instruction for instantiating <esql:results> but
none for <esql:no-results>.



>Hello all, 
>
>My patch to esql before may have been too hasty.
>
>I am trying to get the <esql:no-results> block to
>be done when there are no results.  My initial confusion
>was that from my experience with the older esql I assumed 
><esql:no-results/> was a sibling of <esql:results> e.g.
>
><esql:execute-query>
>	<esql:results>
>		<yes-results/>
>	</esql:results>
>
>	<esql:no-results>
>		<no-results/>
>	</esql:no-results>
></esql:execute-query>
>
>but this does not work, after a little research I discovered
>that having <esql:no-results> as a child of <esql:results>
>seemed to work, e.g.
>
><esql:execute-query>
>	<esql:results>
>		<esql:row-results>
>			<yes-results/>
>		</esql:row-results>
>		
>			<esql:no-results>
>				<no-results/>
>			</esql:no-results>
>			
>	</esql:results>
></esql:execute-query>
>
>this is due to line 318 in esql.xsl
>><xsl:template match="esql:execute-query//esql:results">
>>	<xsl:apply-templates/>
>></xsl:template>
>
>but the problem here is when <esql:max-rows> is set to 1
>there is a problem at line 342 in esql.xsl
>
>><xsl:template match="esql:results//esql:row-results">
>>  <xsp:logic>
>>    while (_esql_query.resultset.next()) {
>>      <xsl:apply-templates/>
>>      if (_esql_query.max_rows != -1 &amp;&amp; _esql_query.position - _esql_query.skip_rows
== _esql_query.max_rows-1) {
>>        break;
>>      }
>>      _esql_query.position++;
>>    }
>>  </xsp:logic>
>></xsl:template>
>
>Note the if statement, if _esql_query.max_rows == 1 and 
>_esql_query.skip_rows = 0 and _esql_query.position = 0 ( we're 
>on the first row returned ) that line reads:
>
>>if ( 1 != -1 &amp;&amp; 0 - 0 == 0 )
>
>thus the line:
>>      _esql_query.position++;
>
>is not incremented although it should be and inside 
>the check for no-results at line 326
>><xsl:template match="esql:execute-query//esql:no-results">
>>  <xsp:logic>
>>    if (_esql_query.position == _esql_query.skip_rows) {
>>      <xsl:apply-templates/>
>>    }
>>  </xsp:logic>
>></xsl:template>
>
>that if reads
>> if ( 0 == 0 )
>, thus we have applied templates for <esql:row-results> kids
>and now for <esql:no-results> kids.
>
>This is an easy fix by making that block at 324 read:
><xsl:template match="esql:results//esql:row-results">
>  <xsp:logic>
>    while (_esql_query.resultset.next()) {
>      <xsl:apply-templates/>
>      _esql_query.position++;
>
>      if (_esql_query.max_rows != -1 &amp;&amp; _esql_query.position - _esql_query.skip_rows
== _esql_query.max_rows) {
>        break;
>      }
>    }
>  </xsp:logic>
></xsl:template>
>
>Note the increment and if are inverted above and the last compare 
>is with _esql_query.max_rows not _esql_query.max_rows-1.
>
>Also I recall hearing discussion about esql's schema.  Is that 
>available? It would make deciphering the logicsheet a little easier.
>
>Please excuse me if I have misunderstood the syntax of esql.
>
>-matt

In addition to that, I've got an almost desperate call to esql develpers (Donald Ball and
Robin Green):
We should get <esql:no-results> instantiated when a rowset with zero lines has been
retrived.. (or maybe also when when max-rows and skip-rows 
parameters are set in such a way that no rows are availabel for instantiating <esql:row-results>?)..
PLEASE: CAN WE HAVE <esql:results> INSTANTIATED ONLY OTHERWISE? (FOR NEVER TO
HAVE BOTH <esql:no-results> and <esql:results> both instantiated?)

I see three variants:

1) we instantiate <esql:results> when and only when there are lines in the Resultset

                                       (and <max-rows> and <skip-rows> select
positive number of rows)
     we instantiate <esql:no-results>(if any) otherwise
2) we instantiate <esql:results> when and only when there are lines in the Resultset
                                       (and <max-rows> and <skip-rows> select
positive number of rows) 
                                       OR WHEN NO <esql:no-results> has been given
     we instantiate <esql:no-results> otherwise
3)  we instantiate <esql:results> always.
      we instantiate <esql:no-results> when it is present and the number of rows in
the resultset
                     chosen by <esql:max-rows> and <esql:skip-rows> equals to
zero

PLEASE, can we have 1) or 2) ? PLEASE, can we not have 3)? Robin and Donald?

I personally thing that it is sensible to put some framing around <esql:row-results>
(incapsulate 'em in a paremnt element)
that should be generated ONLY IF THERE ARE ANY <esql:row-results> instantiated). In
<esql:no-results> we could want
totally different tags (this will simplify the xsl that gets applied after xsp+esql.xsl).

My best regards, Tagunov Anthony
NNT Telecom Russia




Mime
View raw message