Subject: [xsl] Splitting files 5 at a time From: "Danny Leblanc" <leblancd@xxxxxxxxxxxxxxxxxxx> Date: Wed, 2 Apr 2008 14:08:14 -0400 |
Hello everyone, I currently have the following XSLT code. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:for-each select="DATA_FILE/CUSTOMER"> <xsl:result-document href="{FOLDER}{format-number(position(),'000000000')}.xml"> <DATA_FILE> <xsl:apply-templates select="."/> </DATA_FILE> </xsl:result-document> </xsl:for-each> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> This works perfectly and splits the XML input file per CUSTOMER. Now I am being asked to split the XML file but instead of having 1 customer per output file I am not being asked to split it down with 5 CUSTOMERS per "new" output file. (And the last split must work even if there is not a multiple of 5 CUSTOEMERS in the file). 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. Can you please let me know if I am going in the right direction here? Any and all help is welcome. Thank you. P.S if you try and run the code, {FOLDER} will have to be replaced. This is run inside of an application that calls an XSLT engine and the {FOLDER} is replaced by the temp folder where the files are stored as they are processed.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] RNV and xsi:types, XSL-List Owner | Thread | Re: [xsl] Splitting files 5 at a ti, David Carlisle |
Re: [xsl] Empty String param, Tony Graham | Date | Re: [xsl] Splitting files 5 at a ti, David Carlisle |
Month |