xsl-list
[Top] [All Lists]

RE: [xsl] Splitting files 5 at a time

2008-04-02 11:41:26
From: Danny Leblanc [mailto:leblancd(_at_)ca(_dot_)objectiflune(_dot_)com] 
Sent: 02 April, 2008 14:08
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>