Subject: Re: [xsl] grouping by x number of elements From: "kevin p" <kpear1@xxxxxxxxxxx> Date: Tue, 12 Jul 2005 20:09:10 +0000 |
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx From: David Carlisle <davidc@xxxxxxxxx> Subject: Re: [xsl] 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]">
The problem here is that there has to be a closing worksheet tag, so i have to process all the rows recursively, but when i do that I can't specifiy over approximately 500 rows as a split point, or I run out of memory basically, under saxon, xalan, etc. Here's my new style sheet, but I'm sure I'm needlessly recursing, but I couldn't figure out how else to create the worksheet names cat1, cat2, cat3, dog1, dog2, dog3, etc. as i'm calling into the group without the COUNT parameter being supplied back to itself in group mode.
<xsl:template match="DATA_RESULT"> <xsl:param name="FILE"/> <xsl:variable name="WORKSHEET"> <xsl:if test="substring($FILE, string-length($FILE) -3) = '.xml'" > <xsl:value-of select="substring($FILE, 1, string-length($FILE) -4)"> </xsl:value-of> </xsl:if> </xsl:variable> <xsl:call-template name="worksheet"> <xsl:with-param name="WSBASE" select="$WORKSHEET"/> </xsl:call-template> </xsl:template>
<xsl:template name="worksheet"> <xsl:param name="WSBASE"/> <xsl:variable name="POSITION" select="position()"/> <xsl:apply-templates select="record[1]" mode="group"> <xsl:with-param name="WSBASE" select="$WSBASE" /> <xsl:with-param name="COUNT" select="$POSITION"/> </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:template name="cell"> <Cell> <xsl:if test='number(.)'> <Data ss:Type="Number"> <xsl:value-of select="."/> </Data> </xsl:if> <xsl:if test="not(number(.))"> <Data ss:Type="String"> <xsl:if test="(.) != 'NULL'"> <xsl:value-of select="."/> </xsl:if> </Data> </xsl:if> </Cell> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] grouping by x number of e, David Carlisle | Thread | Re: [xsl] grouping by x number of e, David Carlisle |
Re: [xsl] Subgrouping Muenchian Gro, Joris Gillis | Date | [xsl] matching attribute values wit, Stefan Podkowinski |
Month |