[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: grouping by x number of elements

Subject: Re: grouping by x number of elements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 12 Jul 2005 21:52:56 +0100
xsl number of elements
> >beware the T-word. XSLT has no access to the tags in the source document
> >and can not generate tags in the result.
> 
> >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]">
>   <Worksheet ss:name="{$WORKSHEET}">
> 
> 
> The problem here is that there has to be a closing worksheet tag,

As I said, XSLT doesn't work with tags.

> so i have to process all the rows recursively, 

You could do, or you could most likely use the simpler method of
processing n records at a time (for n = 65535 or 500 or whatever you
need) that I show above.

				<xsl:value-of select="substring($FILE, 1, string-length($FILE) -4)">
				</xsl:value-of>

value of has to be empty.


	<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>


This appears to be processing $GROUPSIZE siblings at a time, if so there
is no need to use recursion here (processors will not be optimised to
recurse that deeply, most likely) you can just do
<xsl:apply-templates
select="following-sibling::record[position()&lt;$GROUPSIZE]
no need to explictly recurse.

		<xsl:if test='number(.)'>
		<xsl:if test="not(number(.))">

testing for zzz and not(zzz) is always equivalent to an axsl:choose with
a single test and an otherwise. In this case I don't think you want to
test number(.) as that will first coerce the current node to being a
number, and then be true if that number is non-zero. Perhaps that is
what you want but I suspect that you want to test
test="number(.)=number(.)"
which is true if the content coerces to a number that is not NotANumber.


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.