cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the attribute in mapping..

Former Member
0 Kudos

Hi,

My source XML looks like this

<GLDEBITACCT>

<VALUE>0545-K-2006605-5500001</VALUE>

<GLCOMP glorder="0">0545</GLCOMP>

<GLCOMP glorder="1">K</GLCOMP>

<GLCOMP glorder="2">2006605</GLCOMP>

<GLCOMP glorder="3">5500001</GLCOMP>

</GLDEBITACCT>

Where glorder is the attribute of GLCOMP. Now I have requirement to read the attribute ( atleast 2 of them)

I have to map to target field checking the value in glorder="1

For e.g. with above XML, if the value in glorder="1 is K than map value from glorder="2 (2006605) to Target 1.

IF the glorder="1 is P map the value in glorder="2 to Target 2 and goes on for another one

How can i acheive this mapping. When I tried putting the value of glorder, i am not getting anything.

Regards,

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can use below UDF. Please make sure to select context parameter while creating UDF. There will be 3 input arguments for this function:

1. GLCOMP (a)

2 @glorder (b)

3 Constant (c) --depending upon the target node

Also conext of attribute @glorder should be same as that of GLCOMP.

//write your code here
 for(int i=0;i<a.length;i++)
{
    if(b<i>.equals("1")&&c[0].equals(a<i>))
   {
    for(int j=0;j<a.length;j++)
    {
          if(b[j].equals("2"))
         {
	result.addValue(a[j].toString());
                        break;
         }
          
    }
}
}

For target node target1 use K as 3rd argument, for target node target2 use P and so on.

Let me know how it works.

Regards,

Anirudh.

Former Member
0 Kudos

HI,

Thanks for the reply. I am getting syntax error for braces. Also as you can see, GLCOMP has multiple values

<GLCOMP glorder="0">0545</GLCOMP>

<GLCOMP glorder="1">P</GLCOMP>

<GLCOMP glorder="2">1234</GLCOMP>

<GLCOMP glorder="3">4200003</GLCOMP>

Would GLCOMP be array..?

Any suggestions are welcome.

Regards,

santhosh_kumarv
Active Contributor
0 Kudos

Hellooo,

Did you created a node glorder of complex type attribute for element GLCOMP.By doing this you can read the attribute vale like any other node.

Thanks

SaNv...

Former Member
0 Kudos

Hi,

How many such conditions do you have?

Regards,

Anirudh.