cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping first node

Former Member
0 Kudos

<Empid>

<ID>

<No>12</No>

</ID>

<Name>

<FirstName>demo</FirstName>

<LastName>test</LastName>

</Name>

<Empid>

I have to check if the first occurence of FirstName in the Name node as Test1 then map to target element.

Somebody pelase help me with the mapping for this condition.

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Problem occured again

Former Member
0 Kudos

Hi,

Try the below mapping:

FirstName> mapWithDefault> removeContext> CollapseContext>

Constant [Test1]> equalsS>

ifWithoutElse --> Target

FirstName-->

-Supriya.

Former Member
0 Kudos

Hi Newa,

Map the fields like .. check if the field value is Test1 then send Test1 else make make that to fail.

Thanks,

Former Member
0 Kudos

Hi,

I have given an example of the input data

<Empid>

<ID>

<No>12</No>

</ID>

<Name>

<FirstName>demo</FirstName>

<LastName>test</LastName>

</Name>

<Name>

<FirstName>Test</FirstName>

<LastName>test</LastName>

</Name>

<Name>

<FirstName>demo1</FirstName>

<LastName>test</LastName>

</Name>

<Name>

<FirstName>Test</FirstName>

<LastName>test</LastName>

</Name>

<Empid>

If u see the above example, 2nd and 4th Name node have first name as Test but i should only consider the 2nd nodes First Name only,

please suggest with respect fo the above example.

Thanks

Former Member
0 Kudos

Hi ,

Chk this:

FirstName(change uts context to EmpId) -> sort-> splitbyvalue(ValueChanged) -> collapsecontext-----

-


equals---ifwthoutelse ---Target

Constant(Test)----


Mapping of "then" part:

FirstName(change uts context to EmpId) -> sort-> splitbyvalue(ValueChanged) -> collapsecontext---then

Thnaks

Amit

Former Member
0 Kudos

Hi,

i guess u can achive this using a simple UDF ( extractFirstName)

Execution type: All value of Queue.

for(int i =0;i<FirstName.length;i++)
{
if(FirstName<i>.equals("Test"))
 {
   result.addValue(FirstName<i>);
   break;
}
}

Now map

FirstName ->extractFirstName->targetNode

Edited by: biplab das on Apr 8, 2011 1:01 PM

maciej_jarecki
Contributor
0 Kudos

Hi

Change contex of FirstName to <Empid>.

Equals forst parameter is above statment secone is contatnt text that you want to check

Then if without else. if parameter is above statment secone is oyu eleemtn tah you want to put in target message

Regards

MAciej

Former Member
0 Kudos

Hi,

I used a part of what you have suggested to map..

I changed the context of Firstname to <Empid >, then used collapse context and mapped its output toequals function , then use If without else and mappe it to target element.

<FirstName> ( context points to Empid) -


> Collapse Context -


>

Equals ---> IF

Test -


> -


> Target element

Then

Demo -


>

Thanks

Former Member
0 Kudos

Hi All,

With respect to the below example:

When i test the mapping , if Test comes in the First node then mapping with the output is fine

<Empid>

<ID>

<No>12</No>

</ID>

<Name>

<FirstName>Test</FirstName>

<LastName>lastname</LastName>

</Name>

<Name>

<FirstName>Demo</FirstName>

<LastName>test1</LastName>

</Name>

<Name>

<FirstName>Test</FirstName>

<LastName>test1</LastName>

</Name>

<Empid>

With respect to the above scenario , it works fine by taking the nodes with First Name as " Test" and mapping the target with the first occurence on Test

but when the file is :

<Name>

<FirstName>Demo</FirstName>

<LastName>lastname</LastName>

</Name>

<Name>

<FirstName>Test</FirstName>

<LastName>test1</LastName>

</Name>

The target is not getting filled.

Please suggest me with mapping...

Thanks

Newa

Former Member
0 Kudos

For this input file:

<Name>

<FirstName>Demo</FirstName>

<LastName>lastname</LastName>

</Name>

<Name>

<FirstName>Test</FirstName>

<LastName>test1</LastName>

</Name>

u want ur output something like this:

<Name>

<FirstName>Test</FirstName>

<LastName>test1</LastName>

</Name>

if that is the case then do ur mapping like this:

1)

FirstName(change its context to EmpId) -> sort-> splitbyvalue(ValueChanged) -> collapsecontext-----

-


equals-ifwthoutelse -removeContextName

Constant(Test)----


Mapping of "then" part:

FirstName(change uts context to EmpId) -> sort-> splitbyvalue(ValueChanged) -> collapsecontext---then

2)

FirstName(change its context to EmpId) -> sort-> splitbyvalue(ValueChanged) -> collapsecontext-----

-


equals---ifwthoutelse -


FirstName

Constant(Test)----


Mapping of "then" part:

FirstName(change uts context to EmpId) -> sort-> splitbyvalue(ValueChanged) -> collapsecontext---then