on 03-15-2007 10:18 AM
Hello,
in order to map an specific destination field, i have to loop over an unbounded source-node and to get access to its fields. Lets assume i have the following source-message:
node0 (1:1)
element1="element1"
element2"element2"
node1 (1:n)
name="key"
value="key_value"
/node1
node1
name="attribute1"
value="attribute1_value"
/node1
node1
name="attribute2"
value="attribute2_value"
/node1
/node0
The only thing i need to know is, which name-element has the content "key" so that i can map the content af the value-element to following destination message:
node0 (1:1)
node1 (1:1)
value="key_value"
/node1
/node0
I guess i need an extended UDF (context or queue???). How does the for-loop looks like in order to get access to the <b>content</b> of <b>all</b> <i>node1</i>-nodes? When the input value of the UDF is <i>node1</i>, the loop is just over the first occurence of <i>name/value</i>, right?
The public XI-Mapping-PDF threads do not answer this question.
Any idea?
Hi,
Yes you are right, to choose UDF.
With UDF we can do.see below
--create UDF with queue option
--input name,value
name - removecontext--\ UDF -- Split By value - target node.
value - remove context- /
In UDF
for(i=0;i<name.length;i++){
if name(i).equals("key"){
result.addValue(value(i));
}
}
<b>Note : to be replaced with "<i>"</b> , donot use ""
Regards
Chilla
<i>reward points if it is helpful..</i>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Chilla,
your hint brings me a step forward. But it remains one problem:
in my example node0, the parent node of node1, occurs <b>exactly once</b>. In this case your solution works fine even without 'removeContext' (?). But in real node0 occurs 1-unbounded and the destination node0 also occurs 1-unbounded.
And in this this case it works <b>just for first occurence</b> of node0. For all other
following instances nothing happens at all even though there is an name field with "key" as content for all instances of node 0???
HI,
I understand your prob,
but in your target node0 is 1..unbound . yes so map with empty constant OR
map the source node0 to target node0. or in target side only node0 is 0..unbound
but what about target node1 occurrences that also should be the 1..unbound right ,
then map the source node1 -- target node1 OR map the empty constant to target node1.
Do not change the removecontext other wise youwould have to change the context to root node inthe left side.
pleas clear the real structure...
Regards
Chila..
Yes you're right. My <i>destination</i> structure is a little bit different (i oversimplified it to make it easier to understand my question):
Destination:
node0 (1:1)
<b>key_value</b> (0:1)
node1 (1:unbounded)
name
value
/node1
/node0
node1 is exactly the same as in the source and is simply copied. But the element
<b>key_value</b> which occurs 0:1 for each destination node0 has to have
the content of field <i>value</i> where name has the content "key". As i mentioned before it works fine for the first occurence of node0. But for all following instances destination field <i>key_value</i> does even not exist.
Hi Gunnar,
<i>But the element
key_value which occurs 0:1 for each destination node0 has to have
the content of field value where name has the content "key". As i mentioned before it works fine for the first occurence of node0. But for all following instances destination field key_value does even not exist.</i> - Just right-click value node in graphical mapping......change context to node0.......then input this value node to UDF.......then you will get this key_value for every node0 node.......
Thanks,
Rajeev Gupta
Ok.
source message:
root
- node0 (first instance)
--- node1
-
name="<b>key</b>"
-
value="<b>my_key_value_1</b>"
--- /node1
--- node1
-
name="attribute1"
-
value="attribute1_value"
--- /node1
--- /node0
- node0 (second instance)
--- node1
-
name="<b>key</b>"
-
value="<b>my_key_value_2</b>"
--- /node1
--- node1
-
name="attribute1"
-
value="attribute1_value"
--- /node1
- /node0
/root
Desired destination message:
root
- node0 (first instance)
- key_value=<b>my_key_value_1</b> <- does exist
--- node1
-
name="<b>key</b>"
-
value="<b>my_key_value_1</b>"
--- /node1
--- node1
-
name="attribute1"
-
value="attribute1_value"
--- /node1
- /node0
- node0 (second instance)
- key_value=<b>my_key_value_2</b> < should exist but does <u>not</u> exist
--- node1
-
name="<b>key</b>"
-
value="<b>my_key_value_2</b>"
--- /node1
--- node1
-
name="attribute1"
-
value="attribute1_value"
--- /node1
- /node0
/root
Gunnar,
You do not need a UDF for your requirement. This can be hadled with standard functions.
Do the mapping like this
Constant ("key")
equalS -- ifwithoutelse (condition)
/
name
node1 --ifwithoutelse (then)
target of ifwithoutelse -- splitbyValue --node1
Change the context of name here to root.
After this, you can map value of source to value of target directly.
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.
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.