XSLT compile error when using XslCompiledTransform.Load indirectly called from unmanaged code.  
Author Message
Rich Steck





PostPosted: XML and the .NET Framework, XSLT compile error when using XslCompiledTransform.Load indirectly called from unmanaged code. Top

I have a component I wrote in C#. Among other things it performs a XSLT transform on XML data it collects. When I test this feature using another C# project that uses the component it works just fine. However when I export the component as a COM component and try to use this feature from a unmanaged application it fails on the XslCompiledTransform.Load command with an XSLT compile error.

If I take out the template tags then it loads just fine, of course it will not actually do anything then either.

Thanks for any help you can provide,

Rich

Inner exception: {"Overflow or underflow in the arithmetic operation."}

Stack Trace:

at System.Xml.Xsl.Xslt.QilGenerator.Compile(Compiler compiler)

at System.Xml.Xsl.Xslt.Compiler.Compile(Object stylesheet, XmlResolver xmlResolver, QilExpression& qil)

at System.Xml.Xsl.XslCompiledTransform.CompileToQil(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)

at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)

at System.Xml.Xsl.XslCompiledTransform.Load(IXPathNavigable stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)

at EDEN.XmlSqlExport.XmlSqlExportControl.ProcessExportFull(Boolean useBackground, String dataSelectSQL, String xmlConfig, String outputFile, String connectionString) in S:\NET20\XMLSQLExport\EDEN.XmlSqlExport\XmlSqlExportControl.cs:line 195

Content of the XSL document:

<xsl:stylesheet xmlns:xsl=" http://www.hide-link.com/ " version="2.0"

xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:output omit-xml-declaration="yes" indent ="no" method="text" encoding="us-ascii"/>

<xsl:template match="/">

</xsl:template>

</xsl:stylesheet>



.NET Development4  
 
 
-Anton Lapounov





PostPosted: XML and the .NET Framework, XSLT compile error when using XslCompiledTransform.Load indirectly called from unmanaged code. Top

Could you please paste the full exception stack for the *inner* exception here Your stylesheet specifies version="2.0", however the XslCompiledTransform class supports XSLT 1.0 only.

Thanks,
Anton


 
 
Sergey Dubinets - MSFT





PostPosted: XML and the .NET Framework, XSLT compile error when using XslCompiledTransform.Load indirectly called from unmanaged code. Top

Obviously version="2.0" shouldn't be the reason to throw an exception.

XslCompiledTransform would use forward compatibility processing in this case.

We'll try to repro the bug, but please alos privide full stack.



 
 
Rich Steck





PostPosted: XML and the .NET Framework, XSLT compile error when using XslCompiledTransform.Load indirectly called from unmanaged code. Top

The full stack follows. I had the version set to "1.0" and changed it to 2 at one point to see if it made a difference. Of course it does not. I have also tried several twists in how I load the XSLT document, but again no luck.

Thanks in advance for any help.

System.Xml.Xsl.XslLoadException: XSLT compile error. An error occurred at S:\ES\ESTest\tmp.xslt(4,3). ---> System.ArithmeticException: Overflow or underflow in the arithmetic operation.
at System.Xml.Xsl.Xslt.TemplateMatch..ctor(Template template, QilLoop filter)
at System.Xml.Xsl.Xslt.Stylesheet.AddTemplateMatch(Template template, QilLoop filter)
at System.Xml.Xsl.Xslt.QilGenerator.CompileAndSortMatches(Stylesheet sheet)
at System.Xml.Xsl.Xslt.QilGenerator.Compile(Compiler compiler)
--- End of inner exception stack trace ---
at System.Xml.Xsl.Xslt.QilGenerator.Compile(Compiler compiler)
at System.Xml.Xsl.Xslt.Compiler.Compile(Object stylesheet, XmlResolver xmlResolver, QilExpression& qil)
at System.Xml.Xsl.XslCompiledTransform.CompileToQil(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at EDEN.XmlSqlExport.XmlSqlExportControl.ProcessExportFull(Boolean useBackground, String dataSelectSQL, String xmlConfig, String outputFile, String connectionString) in S:\Eden.NET20\XMLSQLExport\EDEN.XmlSqlExport\XmlSqlExportControl.cs:line 206


 
 
Rich Steck





PostPosted: XML and the .NET Framework, XSLT compile error when using XslCompiledTransform.Load indirectly called from unmanaged code. Top

After a lot more searching it seems I have found the issue and solution. Anton, I have also noticed that you have run across this same question that someone else asked. In my case I’m using Borland Delphi and in the other persons case they were using Borland C++. Hopefully they found the issue as well.

It seems that Microsoft suppresses specific floating point errors whereas Borland raises them. So when the code is ran from a Borland compiled program it crashes, but when it’s ran from a Microsoft compiled program it works just fine. The solution is provided by Borland, see http://homepages.borland.com/ccalvert/TechPapers/FloatingPoint.html. But it comes down to an easy line of code that I put in my units initialization section.

initialization

Set8087CW(DWord($133f));

Works like a charm. Thanks again for anyone who gave this some thought.


 
 
-Anton Lapounov





PostPosted: XML and the .NET Framework, XSLT compile error when using XslCompiledTransform.Load indirectly called from unmanaged code. Top

Hello Rich,