Skip to Content
author's profile photo Former Member
Former Member

Source header data mapping to target sub item

Hi all,

I have a mapping issue, not able to generate the correct targer structure using the source structure. Any help would be appreciated.

My source structure is as below

Source(1.1)
   Header1(1.1)
         Item(0.9999)
   Header2(0.999)

And my target structure

Target(1.1)
    tHeader(0.9999)
        tItem(0.9999)

I want as many tHeader as item hence I mapped item -> tHeader

I want as many tItem as Header2 and since Header2 is one level above item I mapped Header2->copyvalue->titem

tHeader segment is coming through correctly but under this titem is not repeating for every Header2.

For e.g source structure is below

<Source>

<Header1>

<item>item1</<item>

<item>item2</item>

</Header1>

<Header2>h1</Header2>

<Header2>h2</Header>

</Source>

I expect my target structure to be

<Target>

<tHeader>item1

<titem>h1<titem>

<titem>h2<titem>

</tHeader>

<tHeader>item2

<titem>h1<titem>

<titem>h2<titem>

</tHeader>

</Target>

I want the all the occurence of Header2 to be repeated for titem under all tHeader

Instead only first Header2 is copied across all the tHeader. How can I achieve the above?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2011 at 11:45 PM

    As above

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 06, 2011 at 05:53 AM

    Hi,

    Please try with the below logic....

    formatByExample-->tItem

    formatByExample:

    input1: Header2-->removeContext

    input2:Item>removeContext>SplitByEachvalue

    Regards,

    Priyanka

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2011 at 06:24 AM

    Hi,

    You can map directly without using copyValue.

    For nodes:

    Item to tHeader direct map.

    Header2 to tItem direct map

    For Fields:

    tHeader field to tItem field by using OneAsMany node function. (OneAsMany function first field as tHeader field, 2nd and 3rd fields are Header2 Node. After OneAsMany use split by value then map to target field).

    If we have more fields then follow the same procedure.

    Regards,

    Venkata Ramesh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 06, 2011 at 08:33 AM

    Hello,

    Need UDF to populate tItem.

    Here are the mappings:

    tHeader

    Item -> tHeader
    

    tItem

       Item -> UDF -> tItem
    Header2 -> /
    

    UDF is of Context Type

    Arguments: input1 (uses Item as input)

    input2 (uses Header2 as input)

    int len = input1.length;
    for(int a=0;a<len;a++){
     for(int b=0;b<input2.length;b++){
    	result.addValue(input2<b>);
     }
     if((len>0)&(a!=(len-1))){
    	result.addContextChange();
     }
    }
    

    Hope this helps,

    Mark

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.