Author |
Message
|
madi |
Posted: Tue Jan 17, 2006 2:17 pm Post subject: mapping name-value pairs |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi all
I need to transform a valid xml tree structured document into a name value pair xml document and vice versa.
What is the best approach to do it?
THanks
madi
Last edited by madi on Wed Jan 18, 2006 7:57 am; edited 1 time in total |
|
Back to top |
|
 |
SpitFire |
Posted: Wed Jan 18, 2006 12:11 am Post subject: Samples? |
|
|
 Acolyte
Joined: 01 Aug 2005 Posts: 59 Location: India
|
Hi Madi,
I don't seem to have understood your requirement; hence, can you post some sample input and output messages? _________________ ...: 5|71+ph1|23 :... |
|
Back to top |
|
 |
madi |
Posted: Wed Jan 18, 2006 6:46 am Post subject: sample mesgs |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi
Thanks for the reply.
Here are the sample msgs.
Input/Output:
<Some headers>
<Item name="NUMBER" status="ADD"><AttrValue Value="10217180"/></Item>
<Item name="BRAND" status="ADD"><AttrValue value="Red"/></Item>
...
...
</Some Headers>
Output/Input:
<SProduct>
<Product>
<ProdID>PRODID-1</ProductID>
<U>PRODID-1-U</U>
<ActiveE>ACTIVE</ActiveE>
...
...
</Product>
<SProduct>
Can I use a mapping node?
Thanks
madi |
|
Back to top |
|
 |
elvis_gn |
Posted: Thu Jan 19, 2006 8:17 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi madi,
Even from your messages we cannot understand what u want to map with what
You can map any two message sets you want, the mapping of attribute to a simple tag or tag to attribute will not be a problem....
Regards. |
|
Back to top |
|
 |
SpitFire |
Posted: Thu Jan 19, 2006 11:35 pm Post subject: Detailed mappings |
|
|
 Acolyte
Joined: 01 Aug 2005 Posts: 59 Location: India
|
Hi Madi,
I agree with elvis_gn and I would like you to tell us the exact mappings being done here between the input and output. Only with that can we understand what the problem you are facing.
However, as elvis says if you are worried about mapping tag and attribute names, then that shouldn't be a problem at all. One of the IBM manuals that focusses on 'MessageFlows' has sections on ESQL, and there I have seen examples of mappings between tags and attributes. Refer those if that is your requirement. _________________ ...: 5|71+ph1|23 :... |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 20, 2006 4:45 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Madi, are you asking about the following type of transformation
IN
<DataElement name="XYZ" value="123"/>
OUT
<XYZ>123</XYZ>
? _________________ I am *not* the model of the modern major general.
Last edited by jefflowrey on Fri Jan 20, 2006 8:00 am; edited 1 time in total |
|
Back to top |
|
 |
SpitFire |
Posted: Fri Jan 20, 2006 5:26 am Post subject: Transformation Unclear |
|
|
 Acolyte
Joined: 01 Aug 2005 Posts: 59 Location: India
|
Hi,
I was just asking what exactly Madi wants to know. And if what Madi was referring to, was simple tag to Attibute and viceversa conversions, then I said it could be found in the manuals, as far as I remember. _________________ ...: 5|71+ph1|23 :... |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 20, 2006 7:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Oooh.
Sorry, I got confused about how I was addressing.  _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
madi |
Posted: Fri Jan 20, 2006 9:00 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Thanks for the replies guys, iwas busy all day and couldnt get to them.
So anyway, I think I know how to do attribute to tag conversions which is pretty simple.
If i want to map SomeTags.ItemAttr.(XML Attribute)BRAND_NAME in this message
<SomeTags>
<ItemAttr name="ITEM_NUMBER" status="ADD"><AttrValue value="10217180"/></ItemAttr>
<ItemAttr name="BRAND_NAME" status="ADD"><AttrValue value="Mossimo Red"/></ItemAttr>
<ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
...
... (100s of them)
...
</SometTags>
to Tansaction.Products.Product.Sales in this message
<Transaction>
<MerchantID>com</MerchantID>
<UserID>txml</UserID>
<Password>txml01</Password>
<TransactionNumber>-inbound-</TransactionNumber>
<Type>BatchProduct</Type>
<Products>
<Product>
<ProductID>PRODI</ProductID>
<UPC>PRODID</UPC>
<Active>ACTIVE</Active>
<FirstUsedDate>2005.12.20 16:08:27 CST</FirstUsedDate>
<Sales>EA</Sales>
<Product>
<Products>
<Transaction>
I can use the compute node and check for each ItemAttr Attribute and then map it which would be really ugly.
So I want to know the procedure to do it using mapping node or may be not the procedure but just want to know if it is possible.
At this point my assumption is that the name value pairs may not be in the same order and also all of them may not be present.
Hope this gives a better understanding of the topic.
Thanks
madi |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 20, 2006 10:36 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Your input doesn't match your output in any meaningful way to any of your readers.
Could you please show some example messages that have the same fields or at least the same DATA in both the input and the output?
Do you, for example, want to change
IN:
<ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
To
OUT:
<SHIPPING><ADD>all_states_apo_prot</ADD></SHIPPING> _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
madi |
Posted: Fri Jan 20, 2006 1:43 pm Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Sorry for not being able to convey properly. im trying my best.
I mean i have the name value pairs and and an output schema that i need to map these name value pairs to.
Need to map <ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
in the message
<SomeTags>
<ItemAttr name="ITEM_NUMBER" status="ADD"><AttrValue value="10217180"/></ItemAttr>
<ItemAttr name="BRAND_NAME" status="ADD"><AttrValue value="Mossimo Red"/></ItemAttr>
<ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
...
... (100s of them)
...
</SometTags>
to <Transaction><Products><Product><SHIPPING><ADD>all_states_apo_prot</ADD></SHIPPING></Product></Products></Transaction> in the message
<Transaction>
<MerchantID>com</MerchantID>
<UserID>txml</UserID>
<Password>txml01</Password>
<TransactionNumber>-inbound-</TransactionNumber>
<Type>BatchProduct</Type>
<Products>
<Product>
<SHIPPING><ADD>all_states_apo_prot</ADD></SHIPPING>
<UPC>PRODID</UPC>
</Product>
</Products>
</Transaction>
Hope im clear this time.
thanks
madi |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Jan 20, 2006 8:36 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi madi,
We have two doubts:
1. Are u using message sets for the input and output message ?
2. In the output you have the field SHIPPING and ADD, are you creating those tags in output by picking the value that appears in the input....
If you are doing the 2nd then I suggest you use a compute node itself.
If you are NOT doing 2 AND doing 1, then you can do what you want to do in a mapping node, i.e if you are mapping the field in red to the ALREADY AVAILABLE field in blue.
Quote: |
<ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
<Product>
<SHIPPING><ADD>all_states_apo_prot</ADD></SHIPPING>
<UPC>PRODID</UPC>
</Product> |
Note: If you want to check the value of something else like if name="SHIPPING" and then populate the "value" to "ADD"....that also is possible.
Regards. |
|
Back to top |
|
 |
madi |
Posted: Sat Jan 21, 2006 10:26 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi elvis
First of all, the input and output fields exist and i am not creating the fields.
Secondly, i have to check the name SHIPPING and then populate the corresponding value in the output msg.
Did you say that this was possible in mapping node. Is there a link I can refer to, for learning how to do that?
Thanks
madi |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Jan 24, 2006 2:05 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
madi wrote: |
First of all, the input and output fields exist and i am not creating the fields. |
I hope you meant that the input and output message definitions exist
In the mapping node,
You will find the source and Target, right click and Add Message Mapping Input/Output.
In your input message do u have all the ItemAttr's(100s of them)
Quote: |
<SomeTags>
<ItemAttr name="ITEM_NUMBER" status="ADD"><AttrValue value="10217180"/></ItemAttr>
<ItemAttr name="BRAND_NAME" status="ADD"><AttrValue value="Mossimo Red"/></ItemAttr>
<ItemAttr name="SHIPPING" status="ADD"><AttrValue value="all_states_apo_prot"/></ItemAttr>
...
... (100s of them)
...
</SometTags> |
If the same are available in the output message also, then you just have to do a drag and drop, from source to target.
THIS is doable, if you dont have the message sets, use the comput node itself.
Regards. |
|
Back to top |
|
 |
madi |
Posted: Tue Jan 24, 2006 6:23 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi Elvis
We will have all of the ItemAttrs in the input xml but if we are dragging and dropping the mappings, does the order become important?
I mean do the name value pairs have to be in the same order everytime because we are not checking the name and then doing the mapping.
Thanks
madi |
|
Back to top |
|
 |
|