DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15240>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15240 No locator provided upon stylesheet errors Summary: No locator provided upon stylesheet errors Product: XalanJ2 Version: 2.4 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: org.apache.xalan.transformer AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Current processing of stylesheet errors does not allow straightforward processing like this: ========= StreamSource source = new StreamSource(source_url); // A stylesheet with an error, for example // <xsl:apply_templates/><!-- a '_' in place of a '-' --> StreamSource stylesheet = new StreamSource(stylesheet_url); StreamResult result = new StreamResult(System.out); try { Transformer transformer = factory.newTransformer(stylesheet); } catch (TransformerConfigurationException tce) { // Here we get the error message but not the location where the problem occured: // javax.xml.transform.TransformerConfigurationException: // javax.xml.transform.TransformerException: // javax.xml.transform.TransformerException: // xsl:apply_templates is not allowed in this position in the stylesheet! System.err.println(tce.getMessageAndLocation()); } ========= The exception that is thrown when parsing an erroneous stylesheet does not provide a locator. The original exception (with its locator) is burried deep into a nesting of exceptions. The TransformerConfigurationException contains: - A TransformerConfigurationException (no locator) which contains: - A TransformerException (no locator) which contains: - A SaxException which contains: - A TransformerException (with a locator !) I suggest that at least the SaxException should be avoided, because the SAX mechanism should be made transparent. The SaxException that is caught during parse() (in TransformerFactoryImpl.newTemplates()) would be unpacked and the encapsulated TransformerException be sent to the fatalError (TransformerException) Handler. The default ErrorListener may also make sure to provide a locator for the exceptions it throws (I've noticed there is an ensureLocationSet(exception) to do that). Note: This is probably similar to bug #5872
