0

I have an issue with a BizTalk map whereby I need to copy the data from the source schema to the destination schema, but with a condition.

I want to copy the values in 3 nodes with the same name, with the exception of one value. Let me explain better.

Given the example:

<testxml>
    <node>abc</node>
    <node>def</node>
    <node>ghi</node>
    <node>jkl</node>
</testxml>

Using String concatenation, I managed to get the data on the destination schema to the following:

<testxml>
    <node>abcdefghijkl</node>
</testxml>

However I want the output to be similar to the following:

<testxml>
    <node>abcdefjkl</node>
</testxml>

Therefore I am extracting the values 'ghi' from the output.

Is there any way I can achieve this?

Note: I cannot use String Extract as the text I need to extract is in the middle of the string

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79

3 Answers3

2

Here is the "cleanest" solution (be carefull the script functoid is dangerous since it causes memory leaks in some situations like big files you must use it only in extreme cases more details are available here https://support.microsoft.com/en-us/kb/918643), now for your problem you can do this just by combining the not equal operator (where you tell basically that your element should not be equal to JKL or whatever) then add a cumulative concatenate functoid and you will have in your output all your strings concatenated except the one that shouldn't

enter image description here

You can find in the attachment a little sample i made Sample Demo

mahieddine
  • 540
  • 4
  • 14
1

This could be easily achieved with the scripting functoid and some custom inline XSLT:

BizTalk mapper scripting functoid

<xsl:variable name="outputval" select="concat(//node[1],//node[2],//node[4])" />

<xsl:element name="node">
<xsl:value-of select="$outputval" />
</xsl:element>
Jeroen Maes
  • 673
  • 3
  • 8
0

What I have done to solve this is use a custom regex C# script:

public String Trim(String Input) {
    String Output = Regex.Replace(Input, "ghi","");
return Output;
}

enter image description here

This has solved the issue for me removing the not required string values. As Jeroen Maes pointed out this can also be done through Inline XSLT using a Custom Functoid Script.

Both solutions give the following output:

<testxml>
    <node>abcdefjkl</node>
</testxml>
Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79
  • 1
    Be carefull with the script functoid, it shoudln't be used for such a basic operation, see my solution for more info – mahieddine Aug 06 '15 at 13:30