on 02-20-2007 5:35 AM
Hi Experts,
I have a source XML as shown below:
<Inventory>
<InventoryItem>
<ItemCode>InTransit</ItemCode>
<Quantity>1000</Quantity>
</InventoryItem>
<InventoryItem>
<ItemCode>Available</ItemCode>
<Quantity>1500</Quantity>
</InventoryItem>
<InventoryItem>
<ItemCode>Restricted</ItemCode>
<Quantity>2500</Quantity>
</InventoryItem>
</Inventory>
My Target XML is as below
<Inventory>
<stock>1500</stock>
</Inventory>
The stock element contains Quantity value where ItemCode is 'Available'.
But note that there are 3 InventoryItem nodes.
So how to get the desired target XML in XI mapping? Basically I have to filter data from source XML based on value of an element. What is the best approach to handle this?
Kindly help
Thanks
Gopal
Hi Gopal,
I tried using graphical mapping.I am getting the output.Just try this:
Map item and constant(available) to equals(text) and map this to ifwithoutelse(Boolean) and map quantity to other end of ifwithoutelse and map this to removecontext and this to stock.
Item----
____ equals>ifwithoutelse>removecontext-->stock |
Constant--- |
(available) quantity------
Note:equals should be from text fuction category and item,quantity context should be inventoryitem.
It will work.
Regards,
Prasanthi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For Target Field Stock, use the following Mapping (in Graphical Mapping):
If (ItemCode = Available), i.e.,
IfwithoutElse (equalsS (ItemCode, Constant (Available)))
Then map Stock to Quantity.
Note: Keep <b>Context</b> of ItemCode and Quantity as <b>Inventory</b>.
That should do it.
Regards,
Puloma.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This can be done using Graphical mapping itself.
<itemCode>(context menu -> set context to Inventory)--
equalsS ------------
Constant(Available) ----------------------------------
ifWithoutElse ------- CollapseContexts -------- splitByvalue --- stock
Quantity(context menu -> set context to Inventory)---------------------------
Note: stock should be unbounded
Regards,
P.Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi venkat,
Your solution does'nt work fine. But why are you using collapsecontext and splitbyvalue before putting the value into stock element?
Kindly explain your concept.
My target message is:
<?xml version="1.0" encoding="UTF-8"?>
<Inventory>
<InventoryItem>
<ItemCode>InTransit</ItemCode>
<Quantity>1500</Quantity>
</InventoryItem>
<InventoryItem>
<ItemCode>Available</ItemCode>
<Quantity>1000</Quantity>
</InventoryItem>
<InventoryItem>
<ItemCode>UnRestricted</ItemCode>
<Quantity>2000</Quantity>
</InventoryItem>
<InventoryItem>
<ItemCode>Available</ItemCode>
<Quantity>2500</Quantity>
</InventoryItem>
</Inventory>
I am getting the output even though stock is unbounded and I have used collapsecontext and splitbyvalue as:
<InvStock>
<Stock>1000</Stock>
</InvStock>
I should get:
<InvStock>
<Stock>1000</Stock>
<Stock>2500</Stock>
</InvStock>
Thanks
Gopal
Message was edited by:
gopalkrishna baliga
Hi,
>> am getting the output even though stock is unbounded and I have used collapsecontext and splitbyvalue as:
<InvStock>
<Stock>1000</Stock>
</InvStock>
I should get:
<InvStock>
<Stock>1000</Stock>
<Stock>2500</Stock>
</InvStock>
For this try with out the Splitby Value.
Also, it is possible to map the fields at root node level like I suggested. I tried this and got it working.
Regards,
Jai Shankar
Hi Gopal,
do the following in graphical mapping.
(ItemCode -equalS - constant( available) ) -> if -
constant[]-> then -> creatif -> InvStock
(ItemCode -equalS - constant( available) ) ->if
quantity then->Stock
Right click on quantity and change the context to Inventory.
This shall solve your query.
Thanks,
Rajeev Gupta
Gopal,
This is possible in Graphical mapping.
Use the condition at target node <Inventory>
Check for the condition "available" with a Text function equlsS here. If it is equal map the <ItemCode> to <Inventory. Use a ifwithoutElse for this purpose.
Regards,
Jai Shankar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think it is possible in visual mapping using conditions. You have to create instruction like this: If ItemCode=Available then stock=quantity.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gopal,
You can go for java mapping and u can write conditions in parsings techniques based on ur requirements and can able to extract the required data.
Regards,
Prasanthi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
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.