Re: Scripting Functoid - String manipulation (From one input node to multiple output nodes)



"Mani" <psmanii@xxxxxxxxx> wrote in message news:b30ab5e3-39c7-4e90-8e44-5e5f218536b8@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 24, 4:58 pm, "Wolfgang Kluge"
<wolfg...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> "Mani" <psma...@xxxxxxxxx> schrieb im > Newsbeitragnews:3f88e2ca-f17b-4a49-9d2d-877135983f2b@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>
>
>
>
> > Hi,
>
> > I am a newbie to biztalk server.
>
> > In my inbound document, I have an element which has many values like
> > name, address1, address2, city, state with newline character as
> > delimeter. I have to split this values and set it to my outbound
> > document as different elements as name, add1, add2, city, state. I
> > tried using scripting functoid to split the string values, but I am
> > not sure how would I map those splitted values to different elements
> > in the outbound document.
>
> > Please help me.
>
> > Thanks.
> > Mani
>
> Hi Mani,
> not sure if I've understood your problem...
>
> If your inbound document has one(1) value and you need to split this > value
> into many elements of your outbound document, then there are several
> solutions.
> One of the simpliest is to use a scripting functoid for each outbound
> element.
>
> For example:
> You have a inbond field named "Full name" and you want to split the > value
> and write them into 2 elements named "first name" and "last name".
>
> Full name
> > - Scripting functoid 1: fullName.Split(' ')[0]
> - first name
> - Scripting functoid 2: fullName.Split(' ')[1]
> - last name
>
> Both functoids get their value from "Full Name". Functoid 1 sets its > value
> to "first name" and functoid 2 to "last name"...
> By the way: fullName.Split() is no good style ;)
>
> Greets, Wolfgang Klugehttp://gehirnwindung.de/http://klugesoftware.de/- > Hide quoted text -
>
> - Show quoted text -

Hi Kluge,

Thank you very much for your reply.

Yes, you got the problem correct. That's what I am trying to do and
for time being
I had already implemented the way which you have explained here, but I
am sure that's
not the correct approach and there should be a better way to do it.
Currently
we are receiving only two lines of data in the inbound field but in
future we will be
getting 4 to 5 lines of data in the inbound field and placing a
scripting functoid for
each line of data is not good. Please let me know if there is any
better approach to
handle this problem.

Thanks,
Mani



Hi Mani,

there is a better approach, though. But I'm afraid that you want somewhat else ;) Anyhow. Here are my suggestions.

You can cache the result of the split-function. Simply add a scripting functoid to the mapper and add a variable definition (outside of the function block). For example:

//"global" Scripting functoid
string[] _names = null;


Add a link from your FullName-node to each following functoid to read a name part from.

//single scripting functoid
string GetNamePart(string fullName, int index){
if( _names == null ){
_names = fullName.Split(' ');
}
return _names[index];
}


If you always use the same function name and parameters, the function is created only once. I think (but didn't know exactly) this is so, even if you have differenences inside the function itself.

Another approach is to use table looping functoid, but you still have to provide a scription functoid for every output value.
The last solution I know is to write and use your own custom functoid (but that's only an enhancment for the first solution with its scripting functoids).

Depending of what schemas you have exactly, there could be a somewhat better approach, e.g. to write a scripting functoid with your own xslt-code where you can use xsl:for-each and xsl:sort the entries or something like that.


A very much better solution (and this is my explicit recommendation) is to divide the values inside the schema (if possible)...

Keep in mind, that the biztalk mapper goes from output to input. Every linked output node results in a xslt-command. The input is only secondary (if at all).
--
Regards, Wolfgang
Blog: http://gehirnwindung.de/
Company: http://klugesoftware.de/

.