on 03-21-2011 2:46 PM
Hi All.
In addtion to my previous question , thers has been another requirement.
I have to map one field on the condition of another field
the new source can be like this
<Header>
<seg24>
<matpos>10</matpos>
<seg12>
<matdesc>red</matdesc>
<length>100</length>
</seg12>
<seg12>
<matdesc>green</matdesc>
<length>200</length>
</seg12>
<seg12>
<matdesc>black</matdesc>
<length>300</length>
</seg12>
</seg24>
<seg24>
<matpos>20</matpos>
<seg12>
<matdesc>green</matdesc>
<length>200</length>
</seg12>
<seg12>
<matdesc>black</matdesc>
<length>300</length>
</seg12>
</seg24>
<seg24>
<matpos>30</matpos>
<seg12>
<matdesc>red</matdesc>
<length>500</length>
</seg12>
<seg12>
<matdesc>green</matdesc>
<length>800</length>
</seg12>
<seg12>
<matdesc>black</matdesc>
<length>900</length>
</seg12>
</seg24>
<seg24>
<matpos>80</matpos>
<seg12>
<matdesc>red</matdesc>
<length>400</length>
</seg12>
<seg12>
<matdesc>green</matdesc>
<length>800</length>
</seg12>
<seg12>
<matdesc>black</matdesc>
<length>900</length>
</seg12>
</seg24>
...
...
...
<LineItem>
<Itempos>30</Itempos>
<Itempos>10</Itempos>
</LineItem>
<LineItem>
<Itempos>20</Itempos>
<Itempos>80</Itempos>
<Itempos>90</Itempos>
......
........
</LineItem>
</Header>
seg12 is a sub segment of seg 24
the target can be like this
<Target>
<field1></field1>
<field2></field2>
<targetitempos></targetitempos>
<targetlength></targetlength>
</Target>
I have to create one <Target> node for each LineItem, in this case 2 <Target> node and map the first found <Itempos> to targetitempos
I have only to map the <lenght> to <targetlength>.if the <matdesc> is red.
for this I have to compare the Itempos and matpos.
first map <LineItem> -
> <Target>
then
<Itempos> -
> split value targetitempos
so far so good but my problem is when mapping the <length>
if <matdesc> is red
and
if Itempos (sort ascending )eq matpos
then
<length> -
> <targetlength>.
the result I am getting is 2 <Target> node
<Target>
<targetitempos>30</targetitempos>
<targetlength>500</targetlength>
</Target>
which is correct
but the second one is getting the targetlength from another <matpos> and putting it into the <Target> node with the <targetitempos> 20 , which is the first position of <Target> node 2
<Target>
<targetitempos>20</targetitempos>
<targetlength>400</targetlength>
</Target>
now <matpos>20 in seg 24 does nor have any lenght neither any seg12 but it is taking it from another <matpos>
I have really tried with many options without help
Please suggest and many thaks.
Hi Samer,
This is due to you haven't check the condition for matdesc = "red" & if it "red" doesn't exists map blank.
for below iteration where matpos = 20 but there is no matdesc with 'Red'.
</seg24>
<seg24>
<matpos>20</matpos>
<seg12>
<matdesc>green</matdesc>
<length>200</length>
</seg12>
<seg12>
<matdesc>black</matdesc>
<length>300</length>
</seg12>
</seg24>
Thanks,
Jyoti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyoti
Thanks for your answer
I really apreciate it
I mapped a constant 1 if the <matdesc> is not red , but the result is given as constant 1 to alle <Target> nodes lenght.
I thins it is becuase I have only 2 <Target> node but when displaying the queue of the lenght it is like this
1
1
500
and as I only have 2 <Target> node , the first 2 is being mapped which is not correct.
how can I associate the right length to the right <Target> node
BR
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.