Understand exception raised by XsltCompiler.C
Added by Anonymous over 15 years ago
Legacy ID: #7385946 Legacy Poster: Bruno Chatel (bcha)
Hi, I wonder how to understand why I get the following Exception (using Saxon.NET 9) during XSLT stylesheet compilation - Message "Object reference not set to an instance of an object." - StackTrace at net.sf.saxon.style.XSLStylesheet.compileStylesheet() at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(DocumentImpl doc, StyleNodeFactory snFactory) at net.sf.saxon.PreparedStylesheet.prepare(Source styleSource) at net.sf.saxon.TransformerFactoryImpl.newTemplates(Source source, CompilerInfo info) at Saxon.Api.XsltCompiler.Compile(XdmNode node) at TogCore.XsltTransformer.XSLTTransformer.LoadAndCompileXslt(XdmNode xslt_XmdNode) in C:\Applications\tableGenerator3\dev\src\TogCore\XsltTransformer\XSLTTransformer.cs:line 277 It appears after make a modification in a stylesheet and seems to be caused by a call of an xslt function. <xsl:function name="param:getBooleanParam" as="xs:boolean"> <xsl:param name="formatParams"/> <xsl:param name="xpath" as="xs:string"/> <xsl:value-of select="true()"/> <!-- it is not the real purpose of this function but the problem appears with this simple return too --> </xsl:function> called by <xsl:variable name="showLastUpdateDate" select="param:getBooleanParam($formatedParams, 'PublicationInformation/PublicationGeneralParams/ShowLastUpdateDate')" /> No more problem if I change this by <xsl:variable name="showLastUpdateDate" select="true()"/> In fact, the application contains several XSLT2 stylesheets and many other calls to this param:getBooleanParam function works. Moreover, sometimes the exception is not raised... The general application environment is a quiet complex to reproduce here.. and I am wondering how to go on on this problem. Thanks in advance. -- bruno --
Replies (5)
Please register to reply
RE: Understand exception raised by XsltCompiler.C - Added by Anonymous over 15 years ago
Legacy ID: #7386014 Legacy Poster: Michael Kay (mhkay)
Without line numbers in the stack trace it's difficult to tell. The first thing I would do is to check that the base URI / system ID of the stylesheet is known. Not setting this is a common source of problems, likely to manifest themselves as a NullPointerException (which translates in .NET to "Object reference not set to an instance of an Object"). You're creating the stylesheet for some reason from an XdmNode, so check how you constructed the XdmNode and whether it has a base URI. (It's acceptable for a node to have no Base URI so long as the base URI isn't needed. But many functions in XSLT do rely on the base URI of an instruction in the stylesheet.)
RE: Understand exception raised by XsltCompiler.C - Added by Anonymous over 15 years ago
Legacy ID: #7387580 Legacy Poster: Bruno Chatel (bcha)
Thanks for your answer. I have checked BaseUri of the XdmNode and try compiling the stylesheet using Compile(Uri) but the exception still appears. I agree that without line numbers in the stack trace it is difficult to understand. But how getting it or how being able to debug using Saxon source code ? I have tried to generate saxon.dll (using IKVM.NET version 0.38.0.2) but get a link error (using ikvmc) Link Error: Method "ikvm.lang.CIL.box_long(J)Lcli.System.Int64;" has a return type "cli.System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" instead of type "cli.System.Int64 (unknown assembly)" as expected by "net.sf.saxon.dotnet.DotNetExtensionFunctionCall" . In Saxon.NET distribution, it appears that IKVM version 0.36.0.11 is used.. Is it a reason of error ? Any tips to recompile saxon.dll with degub info ? Best regards -- bruno --
RE: Understand exception raised by XsltCompiler.C - Added by Anonymous over 15 years ago
Legacy ID: #7387667 Legacy Poster: Michael Kay (mhkay)
I think your best bet is to try to get the code to me in a form where I can examine it and preferably run it under a debugger.
RE: Understand exception raised by XsltCompiler.C - Added by Anonymous over 15 years ago
Legacy ID: #7391768 Legacy Poster: Bruno Chatel (bcha)
Ok. Thanks. I send you an email with the code and some explanations.
RE: Understand exception raised by XsltCompiler.C - Added by Anonymous over 15 years ago
Legacy ID: #7391982 Legacy Poster: Michael Kay (mhkay)
Thanks for sending the code (offlist). I've identified the bug and logged it here: https://sourceforge.net/tracker/?func=detail&aid=2791790&group_id=29872&atid=397617 A patch is in Subversion and will appear in the next maintenance release. I've also supplied a workaround (offlist). Michael Kay
Please register to reply