Home Page › Forums › BizTalk 2004 – BizTalk 2010 › custom xsl works differently inside map
- This topic has 4 replies, 1 voice, and was last updated 7 years, 9 months ago by community-content.
-
AuthorPosts
-
-
July 7, 2006 at 8:07 PM #15003
I heard that VS2005 had new XSLT debugger. I have gotten used to using Stylus Studio (it allows you specify several different \”processors\”).
I would guess that BT2006 would have used the .NET 2 processor, but maybe it still uses .NET 1?
Stylus has two .NET options (they are not 1.0 and 2.0), they are labeled .NET XslTransform and .NET XslCompiledTransform).
If you want to send me a small sample, I could try it under the different processors.
Neal
-
July 10, 2006 at 4:54 PM #15004
There are different results (at least in the sequence), but they both ran without errors.
Output from .NET XSLTransform:
[code:1:2e0b09606e]<?xml version=’1.0′ encoding=’utf-8′ ?>
<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\" xmlns:userCSharp=\"http://schemas.microsoft.com/BizTalk/2003/userCSharp\">
<node_type_2>type2, data 1</node_type_2>
<node_type_2>type2, data 2</node_type_2>
<node_type_2>type2, data 3</node_type_2>
<node_type_1>type1, data 1</node_type_1>
</root>[/code:1:2e0b09606e]Output from .NET XSLCompiledTransform:
[code:1:2e0b09606e]<?xml version=\"1.0\" encoding=\"utf-8\"?>
<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\" xmlns:userCSharp=\"http://schemas.microsoft.com/BizTalk/2003/userCSharp\">
<node_type_1>type1, data 1</node_type_1>
<node_type_2>type2, data 1</node_type_2>
<node_type_2>type2, data 2</node_type_2>
<node_type_2>type2, data 3</node_type_2>
</root>[/code:1:2e0b09606e]-
July 7, 2006 at 2:13 PM #15005
Does anyone know what xpath implementation the biztalk mapper uses? This has happened to me more than once where I apply a stylesheet to an input doc using the VS 2005 Debug XSLT feature and I get the expected result, but when I run same stylesheet with the same input through the Test Map feature, I get slightly different results.
I posted previoulsy about the document() function not working in the mapper, and today I found that the union operator is not behaving the same way either.
For example, I have two xsl varialbes, $var1 and $var2. $var1 is a set of one element. $var2 is a set of 3 elements.
This code :
<xsl:copy-of select=\”($var1 | $var2)\” />results in an output of 4 elements, as expected, when I run it directly in VS. When I run that same code on the same input through the map, it reults in only the one element from $var1.
Furthermore, if I run this code:
<xsl:copy-of select=\”($var2 | $var1)\” />it results in only the first element from $var2.
Can anyone shed any light on what might be going on here?
Thanks
-SBD-
July 7, 2006 at 3:27 PM #15006
I did just realize a workaround for my union problem …
<xsl:variable name=\”varUnion\” >
<xsl:copy-of select=\”$var1\” />
<xsl:copy-of select=\”$var2\” />
</xsl:variable><xsl:copy-of select=\”$varUnion\” />
will produce the results I was looking for. However, this may not be as useful in all cases, and I would still like to know the difference between running the xsl in VS and running it in the mapper for future reference.
Thanks,
SBD-
July 7, 2006 at 10:22 PM #15007
Neal, thanks for your reply.
I put together a simple test case, and I found that the problem did not occur for the simplest case of taking the union of two sets.
However, the problem did occur when one of those sets came from an external source. I use an inline c# script to import nodes from an external file. There are two differences between the map and the VS debugger. First, when I use VS, I can use the nodes returned by the c# script immediately. But in the map I have to convert them to a node set using msxsl:node-set(). And second, even after I convert it, the union of the two sets is not the same in each case. In the map, the union appears to be incomplete.
I included my xsl and my input files below. If you have a chance to run it throught those different processors, that would be great.
Input Doc 1:
<root>
<node_type_1>type1, data 1</node_type_1>
</root>Input Doc 2:
<root>
<node_type_2>type2, data 1</node_type_2>
<node_type_2>type2, data 2</node_type_2>
<node_type_2>type2, data 3</node_type_2>
</root>Stylesheet:
<?xml version=’1.0′ encoding=’utf-8′?>
<xsl:stylesheet version=\”1.0\” xmlns:xsl=\”http://www.w3.org/1999/XSL/Transform\”
xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\”
xmlns:msxsl=\”urn:schemas-microsoft-com:xslt\”
xmlns:userCSharp=\”http://schemas.microsoft.com/BizTalk/2003/userCSharp\”
><xsl:output method=\”xml\” indent=\”yes\”/>
<xsl:template match=\”/\” >
<xsl:variable name=\”externalDoc\” select=\”userCSharp:RetrieveXMLDocument(‘C:\\Biztalk Projects\\M3.WorkRequest\\SOWSchema\\XSL\\union_test2.xml’)\” />
<xsl:variable name=\”set1\” select=\”//node_type_1\” />
<xsl:variable name=\”set2\” select=\”msxsl:node-set($externalDoc)/node_type_2\” />
<root>
<xsl:copy-of select=\”$set1 | $set2\”/>
</root>
</xsl:template><msxsl:script language=\”C#\” implements-prefix=\”userCSharp\”>
<![CDATA[
public static System.Xml.XmlNode RetrieveXMLDocument(string url)
{
System.IO.Stream responseStream = null;
try
{
responseStream = (System.IO.Stream)new System.IO.FileStream(url, System.IO.FileMode.Open);
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.Load(responseStream);
System.Xml.XmlNode node = xDoc.FirstChild;
while (node.NodeType != System.Xml.XmlNodeType.Element)
{
node = node.NextSibling;
}
return node;
}
finally
{
if (responseStream != null)
{
responseStream.Close();
}
}
}]]>
</msxsl:script>
</xsl:stylesheet>
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.