Skip to Content
0
Former Member
Feb 18, 2006 at 02:07 PM

Mapping Issue - Multiple Segments

27 Views

My mapping problem is as follows:

Source:

A 1..unbounded

item1 0..1

item2 0..1

Target:

A 1..unbounded

item1 0..1

item2 0..1

The values of item2 in source are unimportant.The issue is selecting the values for item2 in Target from a specified data base table with 1 column and replicating the node A in Target as many times as the number of rows in data base table.

For example, data base table is: (10,20,30) ->one column

3 rows, source is:

<A>

<item1> 1 </item1>

<item2> 2 </item2>

</A>

The target must be:

<A>

<item1> 1 </item1>

<item2> 10 </item2>

</A>

<A>

<item1> 1 </item1>

<item2> 20 </item2>

</A>

<A>

<item1> 1 </item1>

<item2> 30 </item2>

</A>

I've started this way (not sure is the right one):

1. Writing Lookup function in JAVA (it works) which returns ArrayList (named v) of all the values in data base table

2. Writing advanced udf (cache: queue) named Set:

public void Set(String[] item1, String[] item2, ....)

{

ArrayList v=Lookup("TABLE"), item1List, item2List;

item1List = new ArrayList();

item1List = new ArrayList();

GlobalContainer g=container.getGlobalContainer();

for(int i=0; i<item1.length; i++)

{ if(!item1.equals(ResultList.CC))

for(int j=0; j<v.size(); j++)

{ String s = (String)v.get(j));

item1List.add(item1<i>);

item2List.add(s);

result.addValue(item1<i>);

result.addValue(s);

}

}

g.setParameter("ITEM1",item1List.toArray());

g.setParameter("ITEM2",item2List.toArray());

}

3.Mapping item1, item2 --> Set --> A

4.Writing 2 advanced udf (cache queue ) named getItem1, getItem2 and mapping as folows:

getItem1 --> item1

getItem2 --> item2

public void getItem1(String[] a, .....)

{

globalContainer g=container.getGlobalContainer();

String[] item1 = (String[]) g.getParameter("ITEM1");

for(int i=0; i<item1.length; i++)

{

result.addValue(item1<i>);

result.addValue(ResultList.CC);

}

}

getItem2 is identical to the above function

What am I missing (since I'm new to XI) ?

The algorithm is wrong ?

I have this mapping error:

null pointer in getItem1

cannot produce target element A check xml instance is valid for source xsd and so on...

All idea or hint will really help,

Thanks

Message was edited by: carmen simcha