on 07-13-2008 3:18 AM
Source
<source>
<Record>
<Date>5/15/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
<Date>5/5/2008</Date>
<DocType>ZL</DocType>
<CompCode>1020</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>60.00</Amount>
</Record>
</source>
-
Expected Target:
<Target>
<Record>
<Date>5/15/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
</Target>
<Target>
<Record>
<Date>5/5/2008</Date>
<DocType>ZL</DocType>
<CompCode>1020</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>60.00</Amount>
</Record>
</Target>
I tried and I was able to produce, multiple targets nodes but not the record element in target elements.
When the "dateCompcode" changes a target node should be generated and all records having same "dateCompcode" should be in one target.
reg
It is a simple grouping solution using XSLT.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0" />
<xsl:key match="source/Record" name="keyDate_CompCode" use="concat(Date, ' ', CompCode)" />
<xsl:template match="/">
<Output>
<xsl:for-each select="source/Record[generate-id(.) = generate-id(key('keyDate_CompCode', concat(Date, ' ', CompCode))[1]) ]">
<xsl:variable name="groupRecord" select="key('keyDate_CompCode', concat(Date, ' ', CompCode))" />
<Target>
<xsl:for-each select="$groupRecord">
<xsl:copy-of select="." />
</xsl:for-each>
</Target>
</xsl:for-each>
</Output>
</xsl:template>
</xsl:stylesheet>
BR
Sameer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the date comes in the asending order
Just have a look at this pay load:
<MT_Source>
<Record>
<Date>5/15/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
<Record>
<Date>5/15/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>242.85</Amount>
</Record>
<Record>
<Date>05/12/2008</Date>
<DocType>ZL</DocType>
<CompCode>1020</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
<Record>
<Date>05/12/2008</Date>
<DocType>ZL</DocType>
<CompCode>1010</CompCode>
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
</MT_Source>
What I am looking at is that, whenever the datecompCode changes, New Node of MT_Target is created and all the records with same datecompCode will come under one MT_Target Node
Like:
<MT_Target>
<Record>
*<Date>5/15/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1010</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
<Record>
*<Date>5/15/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1010</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>242.85</Amount>
</Record>
</MT_Target>
<MT_Target>
<Record>
*<Date>05/12/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1020</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
</MT_Target>
<MT_Target>
<Record>
*<Date>05/12/2008</Date>*
<DocType>ZL</DocType>
*<CompCode>1010</CompCode>*
<GL_Account>21300119</GL_Account>
<Amount>14,357.83</Amount>
</Record>
</MT_Target>
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.