Ask a questionAsk a question
 

AnswerXSLCompiledTransform error

  • Friday, January 05, 2007 8:35 PMClaudiu G Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi!

    I've got an InvalidProgramException occuring when transforming an xml file using XSLCompiledTransform.Transform method. I'm using a large xslt and xml input file.

    The same transformation works fine if I'm using XslTransformer class instead.

    Also if i'm reducing the xslt size, XSLCompiledTransform works too.

    Is there a limitation on the file sizes used by XSLCompiledTransform?

    Thanks

     

    Below are the details of the exception:

    System.InvalidProgramException occurred
      Message="Common Language Runtime detected an invalid program."
      Source="System.Xml.Xsl.CompiledQuery.2"
      StackTrace:
           at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/s0:REPC_MT002000.CareProvisionRequest">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces)
           at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double )
           at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in C:\Templates\HL7.xslt:line 5

Answers

  • Monday, January 08, 2007 5:24 PMAnton Lapounov - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello Claudiu,

    We are sorry you hit this error. The XslCompiledTransform engine compiles each xsl:template from the stylesheet into a single managed method. As a result, long xsl:template's may cause either very slow or inefficient JIT-compilation, because the JIT-compiler uses N-squared optimization algorithms. Huge xsl:templates's may exceed internal JIT-compiler limitations, especially easy to exceed the .NET Framework 2.0 upper limit of locals within one IL method (32K). That results in an InvalidProgramException thrown during JIT-compilation. This issue should be fixed in the .NET Framework 3.0.

    In the meantime, a workaround is to split huge templates into smaller ones (called using xsl:call-template). That should noticeably improve JIT-compilation performance as well.

    Thank you,
    Anton Lapounov

  • Thursday, June 12, 2008 11:13 PMSergey Dubinets - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Remove match="/" from templates where you don;t need it. In your case first two template are never called.

All Replies

  • Monday, January 08, 2007 5:24 PMAnton Lapounov - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello Claudiu,

    We are sorry you hit this error. The XslCompiledTransform engine compiles each xsl:template from the stylesheet into a single managed method. As a result, long xsl:template's may cause either very slow or inefficient JIT-compilation, because the JIT-compiler uses N-squared optimization algorithms. Huge xsl:templates's may exceed internal JIT-compiler limitations, especially easy to exceed the .NET Framework 2.0 upper limit of locals within one IL method (32K). That results in an InvalidProgramException thrown during JIT-compilation. This issue should be fixed in the .NET Framework 3.0.

    In the meantime, a workaround is to split huge templates into smaller ones (called using xsl:call-template). That should noticeably improve JIT-compilation performance as well.

    Thank you,
    Anton Lapounov

  • Monday, January 08, 2007 6:42 PMClaudiu G Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Splitting the xslt works well.

    Thanks
  • Tuesday, July 31, 2007 9:55 PMSandac Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Anton,

    I have exacly the same problem and tried to use

    <xslTongue Tiedtylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

    <xsl:template match="/">

    <xsl:call-template name="FirstXSLT"/>

    <xsl:call-template name="SecondXSLT"/>

    </xsl:template>

    <xsl:template name="FirstXSLT" match="/">

    ...some code...

    </xsl:template>

    <xsl:template name="SecondXSLT" match="/">

    ...some code...

    </xsl:template>

    </xslTongue Tiedtylesheet>

     

    ...my problem - in an output xml  file I can see only result produced by the SecondXSLT.

    It's look like xml produced by FirstXSLT has been overeat by  SecondXSLT.

    Can you help please?

     

    Thank you.

     

    Sam.

     

  • Thursday, June 12, 2008 11:13 PMSergey Dubinets - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Remove match="/" from templates where you don;t need it. In your case first two template are never called.