Bug #1866
closedParse errors in imported stylesheet cause no exception
100%
Description
Reported by SHARMILA SUBRAMANIAM tssharmila@gmail.com in direct email to MHK:
I'm trying to compile an xsl which imports other xsl files(sample below: test1.xsl imports CA.xsl) . If there are errors in the main xsl (test1.xsl )it is caught in the catch block. But the errors in the xsl files(CA.xsl) which are being imported using xsl:import are not getting caught. For example
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="CA.xsl"/>
</xsl:stylesheet>
CA.xsl has some errors for example : end tag is missing. But those errors are not caught and errorlist count is 0.
try
{
// To get error message in detail , Error List property is set.
List errorList = new List();
xsltCompiler.ErrorList = errorList;
transformer = xsltCompiler.Compile(
new Uri(xsltLocation)).Load();
}
catch(Exception)
{
if (xsltCompiler.ErrorList.Count > 0)
{
errorMessage = xsltCompiler.ErrorList[0].ToString();
}
System.Diagnostics.
Trace.WriteLine(errorMessage);
throw new Exception(errorMessage);
}
If I change the location of CA.xsl, it is throwing error that file cannot be found, meaning that the imported stylesheet is referenced but it is not getting compiled .
Thanks
T.S.Sharmila
NOTE: the user also reported
I’m using Saxon 9.3 ee version in .Net 4.5, with no license file.
Updated by O'Neil Delpratt over 10 years ago
- Status changed from New to AwaitingInfo
I was not able to reproduce this problem under Saxon 9.5.1.1. Would it be possible for you to try running your code under the latest version of Saxon. If the problem still exists please supply more information.
Updated by sharmila TS over 10 years ago
As you mentioned , I tried using Saxon 9.5.1.1 ee, the error was caught in
the catch block. But I couldn't get the detailed error message . I get
error as "Failed to compile stylesheet. 1 error detected." . I have also
set errorlist property on the compiler object, but the errorlist count is
0 (xsltCompiler.ErrorList.Count)
within the catch block.
Updated by O'Neil Delpratt over 10 years ago
- Status changed from AwaitingInfo to In Progress
Updated by O'Neil Delpratt over 10 years ago
I have reproduced the problem reported. It is a bug, which I am now investigating.
Updated by O'Neil Delpratt over 10 years ago
- Subject changed from On .NET, errors in imported stylesheet cause no exception to Parse errors in imported stylesheet cause no exception
- Category changed from .NET API to s9api API
- Status changed from In Progress to Resolved
This bug issue is not exclusively a .NET problem, it is reproducible in Java. The cause was in a failure to set the defined ErrorListener in the ParseOption and PipelineConfiguration in PreparedStylesheet. This affects imported stylesheets.
Bug fixed and committed to subversion. Fix applied in PreparedStylesheet.
Updated by sharmila TS over 10 years ago
Thanks for resolving it. Please let me know when the sub version is
released.
Updated by sharmila TS over 10 years ago
Thanks for resolving this issue. Please let me know when the sub version is
released.
Updated by O'Neil Delpratt over 10 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.5.1.2
Bug fix applied in the Saxon maintenance release 9.5.1.2
Updated by O'Neil Delpratt over 10 years ago
- Status changed from Closed to In Progress
I tried using sub version Saxon 9.5.1.2. This time the errorList has value, but the message is not sufficient .
It just reports " Error reported by XML parser ". There is no information about the line number or what is the error.
It would be good if there are details about error in the imported stylesheets.
Thanks
T.S.Sharmila
Updated by O'Neil Delpratt over 10 years ago
- % Done changed from 100 to 0
- Fixed in version deleted (
9.5.1.2)
We have discovered that the ErrorList does capture the inner exception from the XPathException created in the Java code and that it is available. The problem is we are not accessing it in the StaticError class under .NET. A fix will be made to concatenate the inner exception message to what is reported.
Updated by O'Neil Delpratt over 10 years ago
The line number is available, You can do something like the following:
int linenumber = ((StaticError)(xsltCompiler.ErrorList[0])).LineNumber;
Updated by O'Neil Delpratt over 10 years ago
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
Bug fix committed to subversion.
Method InnerMessage()
added to the class StaticError
which produces a concatenated message of the cause exception along with the wrapper exception.
Updated by O'Neil Delpratt over 10 years ago
- Status changed from Resolved to Closed
- Fixed in version set to 9.5.1.3
Big fix applied in the Saxon 9.5.1.3 maintenance release.
Please register to edit this issue