Altova Mailing List Archives


RE: [xsl] Splitting files 5 at a time

From: "Danny Leblanc" <leblancd@------------------->
To:
Date: 4/2/2008 7:58:00 PM
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: [xsl] Splitting files 5 at a time

> From: Danny Leblanc [mailto:leblancd@xxxxxxxxxxxxxxxxxxx]
> Sent: 02 April, 2008 14:08
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 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.

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.