on 01-27-2015 10:31 AM
People,
I have a source xml where the structures are independent. The link between them is via the id field. See the example below:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:mtOrigem xmlns:ns0="http://poc.wilson.sons:testejoinentreestruturas">
<header>
<id>1</id>
</header>
<header>
<id>2</id>
</header>
<item>
<id>2</id>
<item>2A</item>
<valor>2000.00</valor>
</item>
</ns0:mtOrigem>
In this example I have two headers (id 1 and 2) and an item on the id 2.
The problem is that the target structure is linked (the item is below the header). How to make that link? Notice that, after mapping, the item was below the id 1, when the correct would be below the id 2 :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:mtDestino xmlns:ns0="http://poc.wilson.sons:testejoinentreestruturas">
<header>
<id>1</id>
<item>
<item>2A</item>
<valor>2000.00</valor>
</item>
</header>
<header>
<id>2</id>
</header>
</ns0:mtDestino>
Can anyone help me solve this issue? In the attached image is the print of the mapping.
Thanks,
Oscar Möller
Oscar,
Please write multiple input, multiple output UDF with execution type 'all values in queue'. Input fields, id from header and all fields under item. Output fields as item field and valor field
Below is sample code
for (int i = 0; i < id_header.length; i++) {
for (int j = 0; j < id_item.length; j++) {
if (id_header[i].equals(id_item[j])) {
result1.addValue(item_field[j]);
result2.addValue(valor[j]));
}
}
result.addValue(ResultList.CC);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Raghu,
I researched and found that the CC is the "context Change". Ok, but have not worked. The "CC" should not be after creating fields of the item? I put there, but it is only creating the first item of the first id. I'm trying to understand how the logic applies in the creation of tags. I removed the contexts of all input parameters. Is that so?
Thaks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jannus,
Really worked for the example, but if I put more than one item for the same header or another item in another header, gives error in useoneasmany function.
The reason is that the second parameter is not much the number of contexts corresponding to the number of items or contexts of the first parameter.
I understood the logic of your mapping, but I can not find something valid for the second parameter, which makes work for all cases.
Can you help me again?
Thank's,
Jannus,
Note that, in the source layout, the two structures are unbounded. So I can have 0..n items for each header. Here are other examples:
<? xml version = "1.0" encoding = "UTF-8"?>
<ns0: mtOrigem xmlns: ns0 = "http: //poc.wilson.sons: testejoinentreestruturas">
<header>
<id> 1 </ id>
</ header>
<header>
<id> 2 </ id>
</ header>
<item>
<id> 2 </ id>
<item> 2A </ item>
<value> 2000.00 </ value>
</ item>
<item>
<id> 1 </ id>
<item> 1A </ item>
<value> 1000.00 </ value>
</ item>
</ ns0: mtOrigem>
<? xml version = "1.0" encoding = "UTF-8"?>
<ns0: mtOrigem xmlns: ns0 = "http: //poc.wilson.sons: testejoinentreestruturas">
<header>
<id> 1 </ id>
</ header>
<header>
<id> 2 </ id>
</ header>
<header>
<id> 3 </ id>
</ header>
<item>
<id> 3 </ id>
<item> 3A </ item>
<value> 3000.00 </ value>
</ item>
<item>
<id> 1 </ id>
<item> 1A </ item>
<value> 1000.00 </ value>
</ item>
<item>
<id> 3 </ id>
<item> 3B </ item>
<value> 3300.00 </ value>
</ item>
</ ns0: mtOrigem>
Thank´s
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
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.