cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with mapping different child nodes in other parent nodes

0 Kudos

Hi all,

I have trouble creating a mapping.

For example the entry structure looks like this.

<Parent>

                <ID_1>

                <ID_2>

                <ID_3>

</Parent>

<Parent>

<POS_1>

<POS_2>

<POS_3>

<ID_1>

<ID_2>

<ID_3>

</Parent>

<Parent>

<POS_1>

<POS_2>

<POS_3>

</Parent>

The nodes POS and ID mean the same. But if there is a POS number I’ll fill another value with a ‘0’. For the ID nodes I’ll fill the same value with something else than a ‘0’. But that’s not the problem.

The exit structure should be like this:

<Tab>

                <ID_1>

                <ID_2>

                <ID_3>

</Tab>

<Tab>

<POS_1>

<POS_2>

<POS_3>

</Tab>

<Tab>

<ID_1>

<ID_2>

<ID_3>

</Tab>

<Tab>

<POS_1>

<POS_2>

<POS_3>

</Tab>

As you can see I need an own node for every collection of IDs oder POSs in the exit structure. But this doesn’t work because I don’t have the same number of IDs and POSs.

Does anyone have an idea?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Simon,

count the number of times context change for POS and ID. use a udf to create tab node for same number of times.

for example,  in your input structure, context changed for 4 times.

now you have created correct number of <tab> nodes

second step is to divide Pos and ID to different <taab> nodes. You have to use a UDF for this

I hope your source structure is like shown below

<parnt> 0 to unbound

          ,<id> 0 to unbound

          <pos> 0 to unbound

</parnt>

now you can take <ID> and <POS> as two input parameter in the UDF( call by Queue) use mapwithdefault (with value as "XXX") so if ID or POS is not available in any <parnt> node we will get a "XXX" value.

Create two arrays IDValue[] and PoSValue[] with length equal to the number of <tparnt> nodes in the output.

now you have to calculate for which <tab> node, you have to create <id> and for which <pos> needs to be created.

To do this, you can start with <ID> node. check in each context, if ID value is available in 'i' th context, mark IDValue[i] = 1. else if in any context, ID value is "XXX", mark IDValue[i] = 0.  Do the same for <POS> also.

For the input given by you, the value of these two array at the end will be as shown below

IDVALUE--> 1,1,1

POSValue= 0,1,0

if you add these 6 values, you will get number of <tab> nodes to be generated at the output side.

based on these two array value, you can insert context change and can get the desired output.

your output will be like shown below.

<Tab>

                <ID_1>

                <ID_2>

                <ID_3>

</Tab>

<Tab>

<ID_1>

<ID_2>

<ID_3>

</Tab>

<Tab>

<POS_1>

<POS_2>

<POS_3>

</Tab>

<Tab>

<POS_1>

<POS_2>

<POS_3>

</Tab>

Regards,

Gavaksh

Former Member
0 Kudos

Minor correction. The array value will be

IDVALUE--> 1,1,0

POSValue= 0,1,1

Answers (0)