on 07-27-2009 4:43 AM
Hi
i have a requirement where i need to map source sturcture to target structrue based below conditions
Source Structure
<WorkStateList> 0.....unbounded
<AllLocations>
<VisibleName>
<State>
<City>
<InternalCode>
<LocShortDesc>
</WorkStateList>
Target Stucture..
<Categories>
<Category>
<Name>Region</Name>
<CategoryValue>
<Name>All Locations</Name>
<Code>ALL_REG</Code>
<CategoryValue>
<Name>UnitedSates</Name>
<Code>US</Code>
*<CategoryValue>..............................State*
*<Name></Name> state name*
*<Code></Code> code*
*<CategoryValue>*
*<Name></Name> City name in the state*
*<Code></Code> City code in the State*
*</CategoryValue>*
</CategoryValue>**
</CategoryValue>
</CategoryValue>
</Category>
</Categories>
Bold values should repeat for as many times as State and city values does......
so finally State node should contains all state values with corresponding City values..
For Example.. <WorkStateList>
<AllLocations/>
<VisibleName/>
<State/>State1</State>
<City/>State-1City-1<City/>
<InternalCode>123</InternalCode>
<LocShortDesc/>
</WorkStateList>
<WorkStateList>
<AllLocations/>
<VisibleName/>
<State/>State2</State>
<City/>State-2City-2<City/>
<InternalCode>234</InternalCode>
<LocShortDesc/>
</WorkStateList>
<WorkStateList>
<AllLocations/>
<VisibleName/>
<State/>State3</State>
<City/>State-3City-3<City/>
<InternalCode>23434</InternalCode>
<LocShortDesc/>
</WorkStateList>
PLease help me on this...
Regards,
DEEPS
Edited by: sandeep on Jul 27, 2009 5:43 AM
Test Data
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Location_Src xmlns:ns0="http://yash.com/yh1309/Mapping_Test">
<WorlStateList>
<AllLocations/>
<VisibleName/>
<State>State1</State>
<City>State1city1</City>
<InternalCode>111</InternalCode>
<LocShortDesc/>
</WorlStateList>
<WorlStateList>
<AllLocations/>
<VisibleName/>
<State>State1</State>
<City>State1city2</City>
<InternalCode>1222</InternalCode>
<LocShortDesc/>
</WorlStateList>
<WorlStateList>
<AllLocations/>
<VisibleName/>
<State>State2</State>
<City>state2City1</City>
<InternalCode>21111</InternalCode>
<LocShortDesc/>
</WorlStateList>
<WorlStateList>
<AllLocations/>
<VisibleName/>
<State>State2</State>
<City>state2City2</City>
<InternalCode>2222</InternalCode>
<LocShortDesc/>
</WorlStateList>
</ns0:MT_Location_Src>
Target Output
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Location_Trg xmlns:ns0="http://yash.com/yh1309/Mapping_Test">
<Categories>
<Category>
<StateName>State1</Name>
<CategoryValue>
<CityName>State1city1</Name>
<Code>111</Code>
</CategoryValue>
<CategoryValue>
<CityName>State1city2</Name>
<Code>1222</Code>
</CategoryValue>
</Category>
<Category>
<StateName>State2</Name>
<CategoryValue>
<CityName>state2City1</Name>
<Code>21111</Code>
</CategoryValue>
<CategoryValue>
<CityName>state2City2</Name>
<Code>2222</Code>
</CategoryValue>
</Category>
</Categories>
</ns0:MT_Location_Trg>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Source structure
WorkStateList--------0..unbounded
Alllocations
VisibleName
State
City
internalCode
LocShortDesc
Target structure
Categories
Category------0..unbounded
StateName
CategoryValue-----0..unbounded
CityName
Code
Do the mapping as given below.I have tested it.
State----->RemoveContext------>-sort---->splitByValue(ValueChange)------>CollapseContext----->Category
State----->RemoveContext------>-sort---->splitByValue(ValueChange)------>CollapseContext----->SplitByValue(EachValue)---->StateName
State---removeContext-->SortByKey--------------------->FormatByExample--------CategoryValue
City-----removeContext---/
state--->removeContext---sort----SplitByValue(Value Change)(map it to formatByExample above)
state--->removeContext--->SortByKey--->SplitByValue(each value)-->CityName
city-->rermoveContext/
state--->removeContext--->SortByKey--->SplitByValue(each value)-->Code
InternalCode-->rermoveContext/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
change the category occurence in the target structure to 0..unbounded if you want all cities belong to one state to appear under it.and category to be repeated for each state and categorieValue for each city in a state.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looking at your structure can it be said that your Categoryvalue node in Target is 0...unbounded? If yes, then you can use the Duplicate Subtree option and have two different CategoryValue nodes
Map one with State and the other with City from the source so that the respective CategoryValue will repeat based on State, City
Then map the child elements of both State/ City to the corresponding CategoryValue child elements.......you may need to play with Context of the source nodes (if needed)
I hope i understood your requirement correctly!
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Abhishek For your reply..
Category value is occurence 0....1
Target strucutre should be like this..
<Categories>
<Category>
<name>
<Categoryvalue>
<Name>All Locations</Name>
<Code>Code1</Code>
<CategoryValue>
<name>US</Name>
<Code>USCODE<code>
<CategoryValue>
<Name>State1</Name>
<Code>stateCode</Code>
<CategoryValue>
<name>Cityi\1ofSate1</name>
<Code>Code1</Code>
<CategoryValue>
<name>Cityi2ofSate1</name>
<Code>Code2</Code>
<categoryValue>
<Name>State2</Name>
<Code>stateCode</Code>
<CategoryValue>
<name>Cityi1ofSate2</name>
<Code>Code1</Code>
<CategoryValue>
<name>Cityi2ofSate2</name>
<Code>Code2</Code>
i hope this is not poosible without having 0...unbounded value for Categoryvalue.. right?
Regards,
Deeps
Thanks Abhishek....Structure hasbeen changed.. Category value set to 0 to 0ccurence..
i did as per you suggestion.. i have taken same state with three different cities ..every time State is repeating.. with city value..
i dont want that..
this is should be the output
<CategoryValue>
<Name>State1</Name>
<Code>stateCode</Code>
<CategoryValue>
<name>Cityi1ofSate1</name>
<Code>Code1</Code>
<CategoryValue>
<name>Cityi2ofSate1</name>
<Code>Code2</Code>
<categoryValue>
<Name>State2</Name>
<Code>stateCode</Code>
<CategoryValue>
<name>Cityi1ofSate2</name>
<Code>Code1</Code>
<CategoryValue>
<name>Cityi2ofSate2</name>
<Code>Code2</Code>
if i have 4 cities of same state then under State category value there should be 4 category city values.. with out repetition of state value... as shown above
please suggest on this..
Regards,
Deeps
Source message
<List> 0...............unbounded
<Locations>All_Locations</AllLocations>
<Name>AAA</VisibleName>
<State>AL</State>
<City>City1</City>
<lCode>AL048</InternalCode>
<ShortDesc>AL048 </LocShortDesc>
</List>
this needs to be mapped with below target structure
<Categories>
<Category>
<Name>Work Location</Name>
<CategoryValue>
<Name>Work Locations</Name>
<Code>ALL</Code>
<CategoryValue>
<Name>United States - Non Call Center</Name>
<Code>USANCC</Code>
<CategoryValue> 0............unbounded state node
<Name>Arizona</Name>
<Code>AZ</Code>
<CategoryValue> 0........unbouded city node...
<Name>City1</Name>
<Code>AZ004</Code>
</CategoryValue>
</CategoryValue>
</CategoryValue>
</CategoryValue>
</Category>
</Categories>
my problem is source structre may have different state and different city values..
now target structure should have this state and corresponding city in the bold nodes ... if 5 cities of state1 exists in the source structure then all the cities should be under state1 node , if 3 cities of state2 exists then all the 3 cities should go under state2 node..
PLease help me on this..
Regards,
Deeps
Hi all thanks for your response..
Fatima, your solution is working fine..
We have added one more field.. State code ,state name..
even for this your solution os working.. but sorting is not..
we have state values like AR,AZ,AL,..
now our strucutre is as shown below
<WorkStateList>
<StateCode>AL</StateCode>
<StateVisibleName>Alabama</StateVisibleName>
<LocationCode>AL044</LocationCode>
<LocationVisibleName>Athens </LocationVisibleName>
</WorkStateList>
<WorkStateList>
<StateCode>AR</StateCode>
<StateVisibleName>Arkansas</StateVisibleName>
<LocationCode>AR700</LocationCode>
<LocationVisibleName>Little Rock </LocationVisibleName>
</WorkStateList>
<WorkStateList>
<StateCode>AZ</StateCode>
<StateVisibleName>Arizona</StateVisibleName>
<LocationCode>AZ019</LocationCode><LocationVisibleName>Avondale - AZ019 AZ</LocationVisibleName>
</WorkStateList>
Alabama state getting the correct code but rest of states are not..
<Categories>
<Category>
<StateName>State1</Name>
<CategoryValue>
<CityName>Alabama</Name>
<Code>AL</Code>
</CategoryValue>
<CategoryValue>
<CityName>1city2</Name>
<Code>1222</Code>
</CategoryValue>
</Category>
<Category>
<StateName>Arizona</Name>
<Code>AR</Code>..........................this value should be AZ
<CategoryValue>
<CityName>state2City1</Name>
<Code>21111</Code>
</CategoryValue>
<CategoryValue>
<CityName>state2City2</Name>
<Code>2222</Code>
</CategoryValue>
</Category>
<Category>
<StateName>Arkansas</Name>
<Code>AZ</Code>................................this value shold be AR
<CategoryValue>
<CityName>state2City1</Name>
<Code>21111</Code>
</CategoryValue>
<CategoryValue>
<CityName>state2City2</Name>
<Code>2222</Code>
</CategoryValue>
</Category>
</Categories>
this is sorting problem.. can anyone help me on this..
Regards,
Deeps
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.