Bug #3138
closedWith XSLT-invoked validation, duplicate xs:ID value is not properly reported
100%
Description
XSLT 3.0 test case copy-5011.
The copy-of instruction invokes strict validation which fails because an xs:ID value is not unique.
The transformation fails with an exception. But (a) the error code is wrong (XTTE1510 rather than XTTE1555), and (b) no explanatory error message is notified to the ErrorListener. (In fact a detailed message is reported to an InvalidityReportGenerator, but this disappears into thin air.)
Updated by Michael Kay almost 8 years ago
- Applies to branch 9.7, 9.8 added
Problem applies to both 9.7 and 9.8 branches.
Updated by Michael Kay almost 8 years ago
Similarly, validation-0005 reports:
Error in xsl:for-each/@select on line 18 column 39 of validation-0005.xsl:
XTTE1510: One or more validation errors were reported
without reporting the actual validation errors.
Updated by Michael Kay over 7 years ago
The incorrect error code is because ValidatingFilter.reportValidationError() unconditionally sets XTTE1510 even if the error object already contains a more specific code.
The failure to report decent messages is because because validationContext.getInvalidityHandler() returns an InvalidityReportGenerator rather than an InvalidityHandlerWrappingErrorListener, which should be the default. It's not immediately clear why this affects the ID validation errors and not other kinds of validity error.
This is set up by EnterpriseConfiguration.prepareValidationReporting(), which has the logic:
public void prepareValidationReporting(XPathContext context, ParseOptions options) throws XPathException {
if (context.getThreadManager() != null) {
// we're in a try/catch
Builder builder = context.getController().makeBuilder();
options.setInvalidityHandler(new InvalidityReportGeneratorEE(context.getConfiguration(), builder));
}
}
and context.getThreadManager() is not null. The rationale for this code is that if we do validation in a try/catch, we want to save validation errors and not report them if the validation error is caught. But the inference in the comment is wrong: in this test case, we are not in a try/catch, and yet context.getThreadManager() is non-null.
The ThreadManager is being created by Controller.callTemplate() - that is, it is being created unconditionally when the transformation starts with a named template. But it also happens on other invocation paths, e.g. Controller.applyTemplates() and Controller.transformDocument(). It looks to me as if the existence of the ThreadManager was at one time indicative that we were in a try/catch, but this is no longer the case, and we need a better test.
Updated by Michael Kay over 7 years ago
There seems to be another issue here: if we are within a try/catch, but there's no catch clause for a validation error that actually occurs, then the the validation error should be reported, either immediately, or on completion of the try.
So: a new design. First, we cut out the code that attempts to redirect validation errors within a try/catch. Secondly, try/catch puts a new ErrorListener in the context which filters the errors being reported, suppressing any for which there is an active catch.
Updated by Michael Kay over 7 years ago
- Category set to Diagnostics
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Fix Committed on Branch 9.7, 9.8 added
These changes are working. The remaining issue is that there is no location information in the message. Ideally, in a case like this where validation is invoked from XSLT and there is no location information from the source document, we would report location information from the stylesheet (i.e what instruction invoked the validation). We could put this information in the ValidationContext. But I think that's an enhancement for a future release.
I've added the initiating location for a DocumentValidator on the 9.8 branch. It was already there for element-level validation.
Updated by O'Neil Delpratt over 7 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.7.0.18 added
Bug fix applied in the Saxon 9.7.0.18 maintenance release.
Updated by O'Neil Delpratt over 7 years ago
- Fix Committed on Branch trunk added
- Fix Committed on Branch deleted (
9.8)
Please register to edit this issue