[xsl] accumulation counter in xsl

Subject: [xsl] accumulation counter in xsl
From: "Shane Knysh" <shane.knysh@xxxxxxxxx>
Date: Sun, 3 Oct 2004 19:48:32 -0700
Greetings All!

I have found a few related topics in the archives but I can not find the answer to my
question. First some background: we have a xsl:fo reporting solution coming (its about 6-9
months away), but in the meantime we are trying to make our plain html reports a little
more appealing by using xml and xsl to make the reports print with headers, footers,
summaries, etc. 

The xml report data files all follow the same structure:
<report>
<name>report name</name>
<structure>
definition of the data fields with type, max length, etc. This description is only
published for clients that want to create alternative xsl files for report generation.
</structure>
<data>
<item>
one report row in the format
<value1 length="111">display value</value1>
<value2 length="222">display value</value2>
</item>
</data>

What I am having difficulty with is dynamic paging. I can make the report display properly
by enforcing a rule like each item takes 3 lines, so a 48 line page requires a page break
every 16 items using something like test="position() mod 16 = 0". What I want is to be
able to do dynamic paging.

I am trying to do this using an accumulating counter. 

I want to calculate the number of lines a given item will require (I have this working),
and keep a running total of the number of lines used. Then when their is not enough lines
to display the current item on the current page, display the page footer, initiate a new
page using css2, display a page header, and then display the item.

I have read some online and text examples that recommend using a for-loop template but I
can not reconcile the for-loop and for-each I am using to display each item.

Any assistance would be greatly appreciated. 

-- 
Shane
shane.knysh at YonerDotCom
"God doesn't play dice with the universe." 
     - Albert Einstein
"God not only plays dice, he does it where no one can see" 
     - Stephen Hawking 

Current Thread