cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Help

Former Member
0 Kudos

Hi All,

I have a specific requirement where I have to repeat a target segment with respect to the integer value of a source element.

Source Structure

<Ticket Print>

--> Store(0..1)

-->TicketSize(0..1)

--> Item(0..n)

------>Header(0..1)

------>Counter(0..1)

------->StartDate(0..1)

-------->TicketQty(0..1)

Target Structure is also same

But I have to repeat Item node with respect to ticket quantity.

Source XML

<Ticket Print>

<Store>23<Store>

<TicketSize>2</TicketSize>

<Item>

----><Header>A</Header>

----><Counter>1</Counter>

----><StartDate>20130517</StartDate>

----><TicketQty>2</TicketQty>

<Item>

----><Header>B</Header>

----><Counter>2</Counter>

----><StartDate>20130517</StartDate>

----><TicketQty>1</TicketQty>

TargetXML

<Ticket Print>

<Store>23<Store>

<TicketSize>2</TicketSize>

<Item>

----><Header>A</Header>

----><Counter>1</Counter>

----><StartDate>20130517</StartDate>

----><TicketQty>1</TicketQty>

<Item>

----><Header>A</Header>

----><Counter>1</Counter>

----><StartDate>20130517</StartDate>

----><TicketQty>1</TicketQty>

<Item>

----><Header>B</Header>

----><Counter>2</Counter>

----><StartDate>20130517</StartDate>

----><TicketQty>1</TicketQty>

So the Item node shud repeat as per the value of ticket qty in source.

Ticket qty will have only value 1 in XML.

Can you please suggest any idea on how to proceed.

Regards,

Malini

Accepted Solutions (0)

Answers (1)

Answers (1)

allamudi_loordh
Active Participant
0 Kudos

hi

pass this TicketQty to below udf.

for(int i=0;i<ticketQty;i++)

{

result.addvalue("");

}

ticketQtry-->UDF-->ItemNode

if ticketQty not coming sometimes try with exists and createif functionality

Regards,

Loordh

Former Member
0 Kudos

Hi,

I have already tried with the UDF as well as one as many, but strange thing is

For a Display queue I'm getting the entries correctly, but when I check the same in test tab the Item node doesnt repeat.

Please advice.

allamudi_loordh
Active Participant
0 Kudos

If you don't can you please post your mapping screenshot for the item node and the below elements..

paste your source xml what you are giving in test mapping.

Former Member
0 Kudos

Source XML is big structure with more than 100 fields.

allamudi_loordh
Active Participant
0 Kudos

hi,

do like this

int len= qty.length();

for(int i=0;i<len;i++)

{

int q= integer.parseInt(qty[i]);

for (int j =0;j<q;j++)

{

result.addvalue("1");

}

}