Simple Problem?
I need to create a system that will take an XML document with user/orderS/lineItems and generate an Invoice with a fixed number of lineItems... let's say 10.
An order can contain more than 10 lineItems, in which case I need the whole invoice template repeated as a 2nd page with the next 10 lineItems and so on.
XML is my data from DB
XSL is my Invoice template + XSLT
Is there a way to construct a XSL that given 1 user, 1 order, 30 lineItems... it will return 3 instances of the Invoice template each with 10 lines?
I guess I could preprocess the recordset and call the XSLT for each 10 lineItems... but that feels wrong to me.
I did something similar on my web site.
I have an XML database of pictures when the users runs a query the site display 4 pictures per screen.
The way I did it was by using parametrized XSLT stylesheets.
I created an XSL style sheet that displays the information about the first 4 pictures as well as a link that calls the same XSL template with the same XPath query but passing an additional parameter which is the current position inside the query (like a cursor).
I use this parameter to start the loop through the pictures, something like this:
{xsl:for-each select="$qry[position()>= $the_start and position() < $the_start + $the_delta]"}
Where $qry is the xpath query, $the_start is the current position and $the_delta defines how many items I'm displaying in each screen.
I'm using eXcelon Extensible Information Server as my XML repository and XSLT processor.
You can see how it works and check the URLs and how I use XSLT parameters at
http://www.viarengo.com (click on any picture roll and then check the URL behind the next button)
(you may have to switch to English by selecting the "Language/English" menu)