on 12-03-2008 3:37 PM
Hi,
my source structure is like this.
>mt_root
>NODE_emp(0..n)
>name(0..n)
>id(0..n)
>city(0..n)
>NODE_company(0..n)
>name(0..n)
>location(0..n)
>reg.no(0..n)
My Requirment is like this
i would like to send the count of child elements which exists(as they are 0..n) under each node to the target field.
i.e, if i map NODE_emp, if all the elements are coming in the source payload then it should return "3"
Suggest me
Thanks inadvance
Hi,
If you use an xslt mapping, you can use the count() function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, you are right.
But I dont really undestand your mapping.
You say your source message is like:
mt_root
NODE_emp(0..n)
name(0..n)
id(0..n)
city(0..n)
Should not it be anything like...?:
mt_root
NODE_emp(0..n)
name(0..1)
id(0..1)
city(0..1)
Otherwise, How do you get 3 if the ocurrence of name, id, city is 0..unbounded?
Carlos
Yo can do, for example, the following:
name-->mapWithDefault() -->
id-->mapWithDefault() --> User_defined_function(a,b,c) ---> target
city-->mapWithDefault() -->
feed yor user defined function with name, id, city after putting mapwithDefault in every node.
Within your function, check if your parameters are empty and count it.
Return the count. Obviously the result should be either 0 or 1 or 2 or 3.
Carlos
Edited by: Carlos Gonzalez on Dec 3, 2008 5:37 PM
@ carlos
Once again Thanks for u r concern..
It will help me in the present situation..
Can we write a generic UDF which will help us permanently..?
i mean in present scenario i will pass my three child elements but if the structure is too big then it will not be suitable right..??
Regards,
Harini.G
Hi harini,
Do the mapping like below.
Source field----Remove contextcount---target feild
Regards,
Leela
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.