Project

Profile

Help

Errors were reported during stylesheet compilation

Added by Everett Hartwell over 8 years ago

I am using a c# (.NET Framework 4.6) console application with a small main starting module:


 static void Main(string[] args)
        {
            const string xsltFile = @"..\..\main.xslt";            

            var processor = new Saxon.Api.Processor();
            System.Xml.XmlReader xslt = System.Xml.XmlReader.Create(xsltFile);
            Saxon.Api.XsltTransformer transformer = processor.NewXsltCompiler().
                       Compile(xslt).Load();

        }

The main.xslt file contains:



    

The parameters.xslt file that is referenced contains:



  

When attempting to run the main module with Saxon-HE version 9.7.0.4, I receive an "Errors were reported during stylesheet compilation" error. The same main module with Saxon-HE version 9.6.0.8 runs without errors.

Why would this not work in version 9.7.0.4? Thank you.


Replies (3)

Please register to reply

RE: Errors were reported during stylesheet compilation - Added by Michael Kay over 8 years ago

The first thing is to establish what the compilation errors actually are. From the sound of it, you aren't actually seeing them. By default they go to the system error output stream, which may find its way to some log file somewhere, depending on your environment; but if you can't find the relevant log file, you should capture the errors in your application and display them somewhere. To capture the errors, set the ErrorList property of the XsltCompiler. Once we know what the errors are, we can investigate them.

RE: Errors were reported during stylesheet compilation - Added by Everett Hartwell over 8 years ago

Thanks for the reply. I am getting the following error message:

An unhandled exception of type 'net.sf.saxon.trans.XPathException' occurred in saxon9he.dll

net.sf.saxon.trans.XPathException was unhandled HResult=-2146233088 Message (System.Exception)=Errors were reported during stylesheet compilation Message=Errors were reported during stylesheet compilation Source (System.Exception)=saxon9he Source=saxon9he StackTrace (System.Exception)= at net.sf.saxon.style.Compilation.compileSingletonPackage(Configuration config, CompilerInfo compilerInfo, Source source) at Saxon.Api.XsltCompiler.Compile(XmlReader reader) at ConsoleApplication1.Program.Main(String[] args) in C:\ConsoleApplication\ConsoleApplication1\ConsoleApplication1\Program.cs:line 17 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() StackTrace: at net.sf.saxon.style.Compilation.compileSingletonPackage(Configuration config, CompilerInfo compilerInfo, Source source) at Saxon.Api.XsltCompiler.Compile(XmlReader reader) at ConsoleApplication1.Program.Main(String[] args) in C:\ConsoleApplication\ConsoleApplication1\ConsoleApplication1\Program.cs:line 17 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

RE: Errors were reported during stylesheet compilation - Added by Michael Kay over 8 years ago

Sorry for the failure to follow this up: for some reason I stopped getting email notifications from this forum a couple of weeks ago.

Unfortunately the stack trace doesn't help us much.

The XsltCompiler has an ErrorList property. To quote from the documentation:

ErrorList: List of errors. The caller should supply an empty list before calling Compile; the processor will then populate the list with error information obtained during the compilation. Each error will be included as an object of type StaticError. If no error list is supplied by the caller, error information will be written to an error list allocated by the system, which can be obtained as the value of this property.

This has actually changed since 9.6. In the 9.6 documentation the last sentence reads: "If no error list is supplied by the caller, error information will be written to the standard error stream.". I think we changed it because we found that except in console applications (which are unusual), information written to the standard error stream goes into a black hole.

    (1-3/3)

    Please register to reply