cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <>
Subject Re: <HELP>Clean Page XSP sample and applying multiple XSL stylesheets</HELP>
Date Thu, 01 Feb 2001 08:04:32 GMT
On Wed, 31 Jan 2001, Luis Gois wrote:

> I want to use the total number of rows matching my query to create an
> index to each page of 20 results. Pretty much like the index you find
> at e.g. when displaying search results.

you can do it iteratively simply using esql:max-rows and esql:skip-rows. i
know cos i just finished writing one a few hours ago. i needed to add one
thing to the esql language for completeness sake - i proposed an
esql:more-results template which is instantiated if more rows exist after
the maximum number has been reached, so you know when to stop making
"next" links. anyway, the basic gist is:


    int max_rows = 10;
    int skip_rows = 0;
    try {
      max_rows = Integer.parseInt(<request:get-parameter name="max-rows"/>);
    } catch (Exception e) {}
    try {
      skip_rows = Integer.parseInt(<request:get-parameter name="skip-rows"/>);
    } catch (Exception e) {}
        <xsp:attribute name="max-rows"><xsp:expr>max_rows</xsp:expr></xsp:attribute>
          if (work_skip_rows != 0) {
            <xsp:attribute name="prev-skip-rows"><xsp:expr>work_skip_rows - work_max_rows</xsp:expr></xsp:attribute>
          <xsp:attribute name="next-skip-rows"><xsp:expr>work_skip_rows + work_max_rows</xsp:expr></xsp:attribute>


then in my stylesheet somewhere i have something like this:

<xsl:if test="@prev-skip-rows">
  <a href="foo.xml?skip-rows={@prev-skip-rows}&amp;max-rows={@max-rows}">Prev</a>
<xsl:if test="@next-skip-rows">
  <a href="foo.xml?skip-rows={@next-skip-rows}&amp;max-rows={@max-rows}">Next</a>

i'm trying to figure out how to generalize this, so that it's easier to
generate pageable results, but this should get you started. it won't work
as is because the more-results support is only in my copy of the source
right now; you can work around it by just removing the more-results and
always creating the next-skip-rows attribute, regardless if it's valid or

- donald

View raw message