This tutorial will demonstrate how to add a new header segment to IDOC for SAP using MAP in BizTalk 2010 using XSLT.

Source Schema


Destination IDOC Schema


We need to generate header node Z1MISCDATA for each segment in IDOC with:

  • datetime=”2015-07-01T18:31:21+00:00″>Value of Type under VALUE_2
  • Value of Id under VALUE_1 if Id not equal to 1


1. Drag and drop the Scripting Functoid on the Map pane.


2. Double click on Functoid to open properties. Select Inline XSLT from the “Select script type” dropdown under the “Script Functoid Configuration” tab.


3. Copy and paste below XSLT under “Inline script” editor and click OK.



<xsl:for-each select="/*[local-name()='SAPOrder' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1']/*[local-name()='Interface' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1']">
  <xsl:variable name="index" select="position()"/>
  <xsl:variable name="IdVal" select="string(/*[local-name()='SAPOrder' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1']/*[local-name()='Interface' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1'][$index]/*[local-name()='Id' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1'])"/>

      <xsl:value-of select="string(/*[local-name()='SAPOrder' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1']/*[local-name()='Interface' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1'][$index]/*[local-name()='Type' and namespace-uri()='urn:schemas-citrite-net:SAP:Order:1'])"/>
    <xsl:if test="not($IdVal='1')">
        <xsl:value-of select="$IdVal"/>
    <xsl:if test="$IdVal='1'">


In the above code, we are iterating each node of the source schema to get values of the Id and Type fields and are generating corresponding header segments.

Note: XPath for fields used in XSLT can be taken by right-clicking on the field and selecting “Copy XPath.”


4. Connect Scripting Functoid to segment Z1MISCDATA.