I have a large XML file of this format:
<data jsxid="jsxroot" caseNumber="59878">
<record jsxid="1" poNumber="13-192208" manu="Biotronik" catNumber="101" total="0" />
<record jsxid="2" poNumber="13-192208" manu="Biotronik" catNumber="102" total="0" />
<record jsxid="3" poNumber="13-192208" manu="Biotronik Total" catNumber="" total="1" />
<record jsxid="4" poNumber="13-192211" manu="Biotronik" catNumber="103" total="0" />
<record jsxid="5" poNumber="13-192211" manu="Biotronik Total" catNumber="" total="1"/>
I want to paginate it into groups of 25 or less, and each page must end on a total line (@total="1").
I got as far as inserting a static page number using the following XSL, but that sometimes cuts off in the middle of a poNumber group so the total is on the next page:
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pagesize" select="25" />
<xsl:template match="data">
<data>
<xsl:for-each select="@*">
<xsl:copy-of select="." />
</xsl:for-each>
<xsl:apply-templates mode="page" select="record[position() mod $pagesize = 1]" />
</data>
</xsl:template>
<xsl:template match="record" mode="page">
<record jsxid="{position()}" >
<xsl:apply-templates select=". | following-sibling::record[position() < $pagesize]" />
</record>
</xsl:template>
<xsl:template match="record">
<xsl:copy-of select="." />
</xsl:template>
Any ideas on how to make sure the last record on each page is a total?
EDIT: I just wanted to clarify what I was doing with the stylesheet I posted. It inserts a placeholder for a page (jsxid = n) every ($pagesize) records. So if pagesize = 5 for a dataset similar to the one I posted, the output is:
<data jsxid="jsxroot" caseNumber="59878">
<record jsxid="1">
<record jsxid="1" poNumber="13-192208" manufacturer="Biotronik" catalogNumber="101" total="0" />
<record jsxid="2" poNumber="13-192208" manufacturer="Biotronik" catalogNumber="102" total="0" />
<record jsxid="3" poNumber="13-192208" manufacturer="Biotronik Total" catalogNumber="" total="1" />
<record jsxid="4" poNumber="13-192211" manufacturer="Biotronik" catalogNumber="103" total="0" />
<record jsxid="5" poNumber="13-192211" manufacturer="Biotronik Total" catalogNumber="" total="1"/>
<record jsxid="2">
<record jsxid="6" poNumber="13-192208" manufacturer="Biotronik" catalogNumber="101" total="0" />
<record jsxid="7" poNumber="13-192208" manufacturer="Biotronik" catalogNumber="102" total="0" />
I'm displaying this data in a matrix in General Interface and using the jsxid to iterate between "pages."
Thanks.