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

RE: Splitting files 5 at a time

Subject: RE: Splitting files 5 at a time
From: "Danny Leblanc" <leblancd@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 2 Apr 2008 15:57:29 -0400
RE:  Splitting files 5 at a time
Thank you Andrew, that worked perfectly. For some reason I could not get David
Carlisle's method to work. I was not even getting multiple files outputted.
Something in ALTOVA (the engine I am using) was not liking the for-each line.

Danny

-----Message d'origine-----
De : Houghton,Andrew [mailto:houghtoa@xxxxxxxx]
Envoyi : April 2, 2008 2:40 PM
@ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Objet : RE:  Splitting files 5 at a time

> From: Danny Leblanc [mailto:leblancd@xxxxxxxxxxxxxxxxxxx]
> Sent: 02 April, 2008 14:08
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Splitting files 5 at a time
>
>   I have played with the for-each since I won't need a loop
> iteration per CUSTOMER anymore but 1 per 5 so I tried something like
>
> <xsl:for-each select="DATA_FILE/CUSTOMER[count() mod 5 = 0">
>
>   But this did not work. I am certain I will have to change
> the apply-templates as well but I have not even gotten to
> that point yet.

I recently had to do something similar, so perhaps you could modify
what I did to fit your situation.  My problem was that I had a list
of n items and I wanted to group the list by the first two items,
then the next two items, etc.  This is basically what I came up
with:

<xsl:for-each-group select="$values"
  group-by="ceiling(position() div 2)"
>
  <xsl:variable name="first"  select="current-group()[1]"/>
  <xsl:variable name="second" select="current-group()[2]"/>
  <!-- ... -->
</xsl:for-each-group>

So I'm thinking that you could do:

<xsl:for-each-group select="DATA_FILE/CUSTOMER"
  group-by="ceiling(position() div 5)"
>
  <xsl:result-document ...>
  </xsl:result-document>
</xsl:for-each-group>


Andy.

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.