on 12-06-2011 10:01 AM
Hi gurus,
we have a following challenge to solve;
INPUT
<root>
<header>
<stats>
<ID>AAA</ID>
<color>green</color>
</stats>
<stats>
<ID>BBB</ID>
<color>blue</color>
</stats>
<stats>
<ID>CCC</ID>
<color>red</color>
</stats>
</header>
<item>
<order>
<ID>AAA</ID>
<value>1001</ID>
</order>
<order>
<ID>AAA</ID>
<value>1002</ID>
</order>
<order>
<ID>BBB</ID>
<value>1003</ID>
</order>
<order>
<ID>CCC</ID>
<value>1004</ID>
</order>
<item>
</root>
NEEDED OUTPUT
<root>
<header>
<stats>
<ID>AAA</ID>
<color>green</color>
<order>
<ID>AAA</ID>
<value>1001</ID>
</order>
<order>
<ID>AAA</ID>
<value>1002</ID>
</order>
</stats>
<stats>
<ID>BBB</ID>
<color>blue</color>
<order>
<ID>BBB</ID>
<value>1003</ID>
</order>
</stats>
<stats>
<ID>CCC</ID>
<color>red</color>
<order>
<ID>CCC</ID>
<value>1004</ID>
</order>
</stats>
</header>
Who can help me?
Thanx in advance for any hints!
Regards,
PM
Hi Peter,
Try with the below logic....
header--->header
id>removeContext>sort>SplitByValueChange>CollapseContext--->Status
id(change context to ItemLevel)->sort>SplitByvalueChange-->Order
id & color are one to one mapping...For VAlue use the below logic
formatByExample--->value
formatByExample:
input1:resultofSortByKey
input2:id(change context to ItemLevel)>sort>splitByEachValue
SortByKey:
input1:id-->removeContext
input2:value-->removeContext
Regards,
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use the mapping like below
Status to Status node mapping
Status-ID to Status-ID field mapping
Status-Color to Status-color field mapping
Under status we have Order node.
create queue type UDF
Inputs are Header-ID, Item-ID, Item-value
String flag='A';
for(int i =1; i<Header-ID.length; i++)
{
for(int j=0; j<Item-ID.length; j++)
if ((Header-ID<i>).equals(Item-ID[j]))
{
result.addValue(Item-value[j]);
flag='B';
}
}
if (flag.equals('B')) result.addValue("");
Map this UDF output to Order node
Map this UDF output to SplitByValue node function then Value field in Order
For ID field:
take the ID field from Order node then pass to OneAsMany node function as first parameter, 2nd and 3rd inputs are above UDF (After udf use SplitByValue then map) then output map to status node ID field.
Regards,
Venkata Ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Peter!
try this mapping:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8"/>
<xsl:key name="dep" match="root/header/stats" use="concat(ID, '|', color)"/>
<xsl:key name="dep1" match="root/item/order" use="concat(ID, '|', value)"/>
<xsl:template match="root">
<root>
<header>
<xsl:for-each select = "header/stats[generate-id(.)=generate-id(key('dep', concat(ID, '|', color)))]">
<stats>
<ID>
<xsl:value-of select="ID"/>
</ID>
<color>
<xsl:value-of select="color"/>
</color>
<xsl:for-each select = "../../item/order[generate-id(.)=generate-id(key('dep1', concat(ID, '|', value)))][ID = current()/ID]">
<order>
<ID>
<xsl:value-of select="ID"/>
</ID>
<value>
<xsl:value-of select="value"/>
</value>
</order>
</xsl:for-each>
</stats>
</xsl:for-each>
</header>
</root>
</xsl:template>
</xsl:stylesheet>
Thanks & Regards
Stanislav
Edited by: Stanyslav Bobrovskiy on Dec 6, 2011 2:22 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
UDF is required to populate order record values in status record, also we need to populate the target side nodes in a order (not all status records in a sequence and not all the order record values in a sequence).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.