Quantcast
Viewing all articles
Browse latest Browse all 11

Difference in mapping between BizTalk 2010 and 2013

Difference in mapping 2010
versus 2013

 

Artifacts description

In a
BizTalk 2010 project we have a function that passes the current XmlNode as an
XpathNodeIterator to a helper component. In BizTalk 2010 the map look like
this:

Image may be NSFW.
Clik here to view.

Note that
we are using custom XSLT here. The content of the XSLT is show below :

<?xml version=1.0 encoding=UTF-16?>
<xsl:stylesheet
xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” xmlns:msxsl=”urn:schemas-microsoft-com:xslt” xmlns:var=”http://schemas.microsoft.com/BizTalk/2003/var” exclude-result-prefixes=”msxsl var userCSharp
ScriptNS0″ version=”1.0″ xmlns:ns0=”http://TestMap.SomeSchema” xmlns:userCSharp=”http://schemas.microsoft.com/BizTalk/2003/userCSharp” xmlns:ScriptNS0=”http://schemas.microsoft.com/BizTalk/2003/ScriptNS0″>
  <xsl:output omit-xml-declaration=“yes” method=”xml” version=”1.0″ />
  <xsl:template match=“/”>
    <xsl:apply-templates select=“/ns0:Root” />
  </xsl:template>
  <xsl:template match=“/ns0:Root”>
    <ns0:Root>
      <xsl:for-each select=“RepeatingNode”>
        <xsl:variable name=“var:v1″ select=”userCSharp:StringTrimRight(string(SomeNode1/text()))” />
        <xsl:variable name=“var:v3″ select=”userCSharp:StringTrimRight(string(SomeNode2/text()))” />
        <RepeatingNode>
          <xsl:variable name=“var:v2″ select=”ScriptNS0:WriteNode(string($var:v1) , .)” />
          <SomeNode1>
            <xsl:value-of select=“$var:v2″ />
          </SomeNode1>
          <xsl:variable name=“var:v4″ select=”ScriptNS0:WriteNode(string($var:v3) , .)” />
          <SomeNode2>
            <xsl:value-of select=“$var:v4″ />
          </SomeNode2>
        </RepeatingNode>
      </xsl:for-each>
    </ns0:Root>
  </xsl:template>
  <msxsl:script language=“C#” implements-prefix=”userCSharp”><![CDATA[

public
string StringTrimRight(string str)
{
       if (str == null)
       {
               return "";
       }
       return str.TrimEnd(null);
}
]]></msxsl:script>
</xsl:stylesheet>

 

The content
of the Extension XML is shown below :

<ExtensionObjects>
  <ExtensionObject Namespace=“http://schemas.microsoft.com/BizTalk/2003/ScriptNS0″ AssemblyName=”MapHelper,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=94092251336a29ea” ClassName=”MapHelper.mapHelperClass” />
</ExtensionObjects>

 

The code of
function in the Helperclass is shown below :

using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Xml.XPath;
using
System.Xml;

 

namespace
MapHelper
{
   public class mapHelperClass
   {

        public static bool
WriteNode(string somedata,XPathNodeIterator node)
        {
           XPathNavigator
xpn = node.Current;
           XmlDocument
xdoc = new XmlDocument();
           xdoc.LoadXml(xpn.OuterXml);
           System.Diagnostics.Trace.WriteLine(“In
function ->”+ xdoc.OuterXml);
            return true;
       }
   }
}

Expected behavior BizTalk
2010

If we run
this map in BizTalk 2010 and watch for the output in Debug View we get the
expected output

Image may be NSFW.
Clik here to view.

Also the
map test succeeds in BizTalk 2010. As shown below:

Image may be NSFW.
Clik here to view.

Invoking
component…
F:ProjectsTestMapTestMapSomeMap.btm:
The compilation is using the CustomXslt and CustomExtensionXml tags to generate
the output.  The map content is ignored.
TestMap
used the following file:
<file:///C:UsersAdministratorAppDataLocalTempinputfile.xml> as
input to the map.
Test Map
success for map file F:ProjectsTestMapTestMapSomeMap.btm. The output is
stored in the following file:
<file:///C:UsersAdministratorAppDataLocalTemp_MapDataTestMapSomeMap_output.xml>
Component invocation succeeded.


Observed behavior BizTalk
2013

If we run
this in BizTalk 2013 we get the following output.

Image may be NSFW.
Clik here to view.

Invoking component…

C:ProjectsTestMap2013TestMapTestMapSomeMap.btm:
The compilation is using the CustomXslt and CustomExtensionXml tags to generate
the output.  The map content is ignored.
TestMap used the following file:
<file:///C:UsersAdministratorAppDataLocalTempinputfile.xml> as
input to the map.
C:ProjectsTestMap2013TestMapTestMapSomeMap.btm:
error btm1050: XSL transform error: Unable to write output instance to the
following
<file:///C:UsersAdministratorAppDataLocalTemp_MapDataTestMapSomeMap_output.xml>.

Exception
has been thrown by the target of an invocation. An error occurred during a call
to extension function ‘WriteNode’. See InnerException for a complete
description of the error. Enumeration has not started. Call MoveNext.
Test Map failure for map file <file:///C:ProjectsTestMap2013TestMapTestMapSomeMap.btm>.
The output is stored in the following file:
<file:///C:UsersAdministratorAppDataLocalTemp_MapDataTestMapSomeMap_output.xml>
Component invocation succeeded.

So the map failed because the behavior of the compiled xslt is different from the interpreted xslt.

Desired Behavior

The behavior
should be the same as in BizTalk 2010.

 

You can find the test project in the attachment


Viewing all articles
Browse latest Browse all 11

Trending Articles