Joe Suharjo
Joe Suharjo

Reputation: 11

Biztalk Map create duplicate target node

Using biztalk mapper, I need a target node to be duplicated.. I have created a simplified version of my issue. Please see below map link for source and destination schema... Ooopps sorry, not enough points to post images..

I need the target Option node to be duplicated for each OptionNotes. The value of OptionNotes is to be split by a pipe ("|"), then map to target Code and Description.

The input is as below:

<ns0:Source xmlns:ns0="http://Test.SOAP.Source1">
  <Option>
    <OptionID>ID0_NoNotes</OptionID>
    <OptionName>OptionName_0</OptionName>
  </Option>
  <Option>
    <OptionID>ID1_NoNotes</OptionID>
    <OptionName>OptionName_1</OptionName>
    <OptionNotes>NOTE1|BLAH1</OptionNotes>
    <OptionNotes>NOTE2|BLAH2</OptionNotes>
  </Option>  
</ns0:Source>

The output should be as below:

<Destination>
    <Options>
        <Option>
            <Code>ID0_NoNotes</Code>
            <Description>OptionName_0</Description>
        </Option>
        <Option>
            <Code>ID1_NoNotes</Code>
            <Description>OptionName_1</Description>
        </Option>
        <Option>
            <Code>NOTE1</Code>
            <Description>BLAH1</Description>
        </Option>
        <Option>
            <Code>NOTE2</Code>
            <Description>BLAH2</Description>
        </Option>       
    </Options>
</Destination>

Tried to use Looping and combination with Value Mapping, but to no avail. Do I have to resort to inline xslt?

Upvotes: 1

Views: 670

Answers (1)

Joe Suharjo
Joe Suharjo

Reputation: 11

We have used Mapforce, which has done this easily. We then get the XSLT and import it as part of Inline XSLT scripting functoid.

The XSLT produced was as below:

<xsl:for-each select="ns0:Source/Option">
<Option>
<xsl:for-each select="OptionID">
<Code>
<xsl:value-of select="string(.)"/>
</Code>
</xsl:for-each>
<xsl:for-each select="OptionName">
<Description>
<xsl:value-of select="string(.)"/>
</Description>
</xsl:for-each>
</Option>
</xsl:for-each>
<xsl:for-each select="ns0:Source/Option/OptionNotes">
<xsl:variable name="var1_resultof_cast" select="string(.)"/>
<Option>
<Code>
<xsl:value-of select="substring-before($var1_resultof_cast, '|')"/>
</Code>
<Description>
<xsl:value-of select="substring-after($var1_resultof_cast, '|')"/>
</Description>
</Option>
</xsl:for-each>

Thanks everyone.

Upvotes: 0

Related Questions