Skip to Content
avatar image
Former Member

JavaMapping Multipel Nodes

Hi.

I've done a mapping with a java-function and when I get mutipel elements I only get the first node with elements and for the sacond element I get just the node wirth no elements in the target.

Ocurrences in source element are 0-unbounded

Target node are 0-unbounded and the elements in the target node are 0-1.

In the source element I get a textstring where the attributes and the with belonging data are splitted up by a space.

public void serachstring (String[] a,String[] b,String[] c,ResultList result,Container container){
int     start_ind = 0, 
        end_ind = 0, 
        string_length = 0; 
        String item_string = ""; 
try { 
     start_ind  = a[0].indexOf(b[0]); 
if (start_ind<0) { 
        item_string = "No Value Present"; 
        result.addValue(item_string); 
        return; 
        } 
} 
catch (StringIndexOutOfBoundsException ex){ 
} 
        string_length = b[0].length(); 
        start_ind = start_ind + string_length; 
try { 
        end_ind = a[0].indexOf(c[0],start_ind); 
} 
catch (StringIndexOutOfBoundsException ex){ 
} 
try { 
        item_string = a[0].substring((start_ind), (end_ind)) + ""; 
} 
catch (StringIndexOutOfBoundsException ex){ 
} 

result.addValue(item_string); 
}

The function should split the string in the element like this.

sourceelement = <1="abc" 2="def" 3="ghi">

Target should look like this.

Node

element1 = abc

element2 = def

element3 = ghi

If I only get one elemt it works but if I get 2 elements I get the following result.

sourceelement = <1="abc" 2="def" 3="ghi">

sourceelement = <1="jkl" 2="mno" 3="pqr">

target

Node

element1 = abc

element2 = def

element3 = ghi

Node

So I get the first node with elements and the second node without elements.

Does anybody know why?

Edit:

The mapping looks as follow.

source: Function: Target:

element No Node

element Yes element

element Yes element

element Yes element

In the mappings between the element the function gets called. I'm calling it with a=the whole string, b=the attributename matching the target element, c=".

BR

Kalle

Edited by: Kalle Persson on Feb 22, 2008 5:08 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Feb 22, 2008 at 03:55 PM

    Hello,

    could be a context problem.

    Try the standard function 'split-by-value' after your sourceelement.

    Regards

    Patrick

    Add comment
    10|10000 characters needed characters exceeded