|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: grouping by x number of elements
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx From: David Carlisle <davidc@xxxxxxxxx> Subject: Re: grouping by x number of elements Message-Id: <200507081255.NAA25768@xxxxxxxxxxxxxxxxx> Iv'e been able to test position at the record level and do something every 5 records or whatever, but basically once I hit that position of 65,535, I want to re-write a new worksheet tag, beware the T-word. XSLT has no access to the tags in the source document and can not generate tags in the result. <Worksheet ss:name="{$WORKSHEET}">You want to generate a Worksheet node every 65,535 records so that's something like <xsl:for-each select="record[position() mod 65535 = 1]">
<?xml version="1.0" encoding="UTF-8"?> <?mso-application ="Excel.Sheet"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:variable name="GROUPSIZE">500</xsl:variable> <xsl:template match="/"> <Workbook> <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> <Author/> <LastAuthor/> <Created/> <Company/> </DocumentProperties> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> </ExcelWorkbook> <xsl:for-each select="/workbook/filename"> <xsl:apply-templates select="document(.)/DATA_RESULT"> <xsl:with-param name="FILE" select="."> </xsl:with-param> </xsl:apply-templates> </xsl:for-each> </Workbook> </xsl:template>
<xsl:template match="record" mode="group"> <xsl:param name="WSBASE" /> <xsl:param name="COUNT" /> <Worksheet> <xsl:attribute name="ss:Name"> <xsl:value-of select="concat($WSBASE, $COUNT)"/> </xsl:attribute> <Table> <xsl:apply-templates select="ancestor-or-self::record" mode="item"/> </Table> </Worksheet> <!--xsl:value-of select="following-sibling::record[500]" /--> <xsl:apply-templates select="following-sibling::record[500]" mode="group"> <xsl:with-param name="WSBASE" select="$WSBASE" /> <xsl:with-param name="COUNT" select="$COUNT + 1" /> </xsl:apply-templates> </xsl:template> <xsl:template match="record" mode="item"> <xsl:param name="remaining" select="$GROUPSIZE - 1"/> <Row> <xsl:for-each select="*"> <xsl:call-template name="cell"/> </xsl:for-each> </Row> <xsl:if test="$remaining"> <xsl:apply-templates select="following-sibling::record[1]" mode="item" > <xsl:with-param name="remaining" select="$remaining -1" /> </xsl:apply-templates> </xsl:if> </xsl:template>
</xsl:stylesheet> kp
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








