Majcen, Kurt wrote:
> Some questions remain (at least for me):
> - Should the generator produce 1 XML (including the various 'XML rows' from
> the database and maybe a tag for the PREV and the NEXT) or should it produce
> a series of XMLs (1 for each record from the DB)?

A generator has to produce a single well-formed XML document, with a 
single root element. You could write a single generator that takes as an 
optional parameter a record number. If the parameter is present, output 
that record, if not, output the summary list.

> - Can I somehow make the query (results) persistent for the PREV/NEXT
> mechanisms? Does this have to be done in the generator?

You could always output the whole database from your generator, have it 
implement the Cacheable interface, with suitable generateKey() and 
generateValidity() methods, and use the Paginator Transformer [1] to 
navigate through records.

Another method I used is to use a CachedRowSet (included in JDBC 2.0, 
but available separately [2]). I've used it to in an application where 
it would have been impractical to cache the full results of a query, so 
I cached just the keys and fetched a single record at a time when 
requested, given the key.

To explain better: I have a generator that acccepts two optional 
parameters:

The first one, "q", is a query string and is used to initialize a new 
CachedRowSet from a querly like the following:

        select key from tablename where description like '%q%'

the rowset obtained from this query is associated to a user session, 
then the current row in the rowset is set to the first one, it's "key" 
column is fetched ad used to execute a query like the following:

        select * from tablename where key = 'key'

then the table columns are output in XML.

The second one, "cmd", can have values "first", "last", "next" and 
"prev". Its value is used to do a first(), last(), next() or prev() 
operation on the rowset (taken from the current session). Then I use the 
key value to perform again the second query above.

        Hope this helps,

                Ugo


[1]: http://xml.apache.org/cocoon/howto/howto-paginator-transformer.html
[2]: 
http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/


-- 
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to