I have an input schema (input_schema) as such:
...
<ContactNo>
<Contact_1>
<Contact-Type>MOBILE|HOME|WORK</Contact-Type>
<Contact-SubType>UK|OVERSEAS</Contact-SubType>
<Contact-CountyCode>44</Contact-CountyCode>
<Contact-No>01443788800</Contact-No>
<Contact-Ex>85000</Contact-Ex>
</Contact_1>
<Contact_2>
<Contact-Type>MOBILE|HOME|WORK</Contact-Type>
<Contact-SubType>UK|OVERSEAS</Contact-SubType>
<Contact-CountyCode>44</Contact-CountyCode>
<Contact-No>01443788800</Contact-No>
<Contact-Ex>85000</Contact-Ex>
</Contact_2>
<Contact_3>
<Contact-Type>MOBILE|HOME|WORK</Contact-Type>
<Contact-SubType>UK|OVERSEAS</Contact-SubType>
<Contact-CountyCode>44</Contact-CountyCode>
<Contact-No>01443788800</Contact-No>
<Contact-Ex>85000</Contact-Ex>
</Contact_3>
...
</ContactNo>
...
Each one of child nodes to the ContactNo can only occur once (one Contact_1, one Contact_2 and one Contact_3). I need to apply some business logic for the Contact-Type, SubType to construct the Contact-No, but my question is how best would you map this structure across to the relevant out_put schema nodes (these nodes are max occurs 20) but can only have a max of three based on the input_schema schema structure below:
...
<HomeTelephone>
<WorkTelephone>
<MobileTelephone>
...
Sample Input/Output
...
<ContactNo>
<Contact_1>
<Contact-Type>HOME</Contact-Type>
<Contact-SubType>UK</Contact-SubType>
<Contact-CountyCode />
<Contact-No>01443788800</Contact-No>
<Contact-Ex/>
</Contact_1>
<Contact_2>
<Contact-Type>WORK</Contact-Type>
<Contact-SubType />
<Contact-CountyCode />
<Contact-No>01743788800</Contact-No>
<Contact-Ex>86000</Contact-Ex>
</Contact_2>
<Contact_3>
<Contact-Type>WORK</Contact-Type>
<Contact-SubType>UK</Contact-SubType>
<Contact-CountyCode />
<Contact-No>01443788800</Contact-No>
<Contact-Ex>85000</Contact-Ex>
</Contact_3>
...
</ContactNo>
...
...
<HomeTelephone>01443788800</HomeTelephone>
<WorkTelephone>0174378880086000</WorkTelephone>
<WorkTelephone>0144378880085000</WorkTelephone>
<MobileTelephone />
...
Currently I am checking Contact-Type (=Home) then mapping the output through a value mapper to a script functoid for data confirmation before mapping the output. This seems to be causing duplicate nodes.
Have you considered using XSLT in your mapping? Not only a lot easier to use than the BizTalk mapper, also a lot more flexible and widely used (you can use XSLT natively in a lot of products).
An appropriate XSLT would result in something like the following:
<xsl:for-each select="ContactNo/*">
<xsl:if test="position() < 4">
<xsl:choose>
<xsl:when test="Contact-Type/text() = 'WORK'">
<WorkTelephone>
<xsl:value-of select="Contact-No/text()" />
</WorkTelephone>
</xsl:when>
<xsl:when test="Contact-Type/text() = 'HOME'">
<HomeTelephone>
<xsl:value-of select="Contact-No/text()" />
</HomeTelephone>
</xsl:when>
<xsl:when test="Contact-Type/text() = 'MOBILE'">
<MobileTelephone>
<xsl:value-of select="Contact-No/text()" />
</MobileTelephone>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:for-each>
This should loop through the first 3 contacts and list them accordingly.
Let me know if this suits your needs.
Disclaimer: haven't tested this out due to time constraints, beware of syntax and typing mistakes. Also I know you were asking for the mapper, I just am convinced the mapper is utterly inferior to the native xslt approach.