on 12-01-2006 5:22 PM
Dear SDN,
I am trying to create a message mapping but I'm having problems. The source is of the form:
Source(1..1)
Line (1..unbounded)
Key (1..1)
Val (1..1)
And target is of the form:
Target(1..1)
Id (1..1)
Name (1..1)
Age (1..1)
An example of source could be
<Source>
<Line>
<Key>Name</Key>
<Val>Angie</Val>
</Line>
<Line>
<Key>Id</Key>
<Val>1002</Val>
</Line>
<Line>
<Key>Age</Key>
<Val>25</Val>
</Line>
</Source>
Target result should be
<Target>
<Id>1002</Id>
<Name>Angie</Name>
<Age>25</Age>
</Target>
Note that the mapping is from an 1..unbounded node to an 1:1 node, also note that tuples Key,Val are not sorted just like Target needed.
Any Ideas?
Hi,
Create user defined function with three inputs. Inside it use global object of type HashMap (package java.util.*).
inputs:
1) input key
2) input value
3) what to put into target
Regards,
Wojciech
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Tnks for your reply.
If I undestood, such function shoud be something like this:
GlobalContainer globalContainer;
globalContainer = container.getGlobalContainer();
HashMap hm = (HashMap) globalContainer.getParameter("hm");
hm.put(key[0], value[0]);
Two questions:
When could I create the Global HashMap? (Is there some init section?)
When could I get the values to fill target? (Could I read first whole source message before fill target?)
Hi,
You can do it either in init section. Header section of the mapping or inside this function. Just check if it's null or not. You can get this values in the same function. First create hash map if it's not created afterwards use it. Remember that it should be queue function (whole queue).
Regards,
Wojciech
THis is an XSLT scenario. Java code can get complex whereas with XSLT and right tools, it is quite easy and maintainable
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
10 | |
8 | |
6 | |
6 | |
5 | |
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.