Bug #5478
closedsetTerminationMessage does not stop loading of included schemas when an error occurs in Saxon EE.
100%
Description
I have an XMLSchema with many included schemas, like this:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:include schemaLocation="A.xsd"/>
<xsd:include schemaLocation="B.xsd"/>
<xsd:include schemaLocation="C.xsd"/>
<xsd:include schemaLocation="D.xsd"/>
<xsd:include schemaLocation="E.xsd"/>
<xsd:include schemaLocation="F.xsd"/>
<xsd:include schemaLocation="G.xsd"/>
<xsd:include schemaLocation="H.xsd"/>
</xsd:schema>
The actual number of included schemas is much larger.
To validate an XML document against this XMLSchema i do this:
SchemaManager schemaManager = processor.getSchemaManager();
ErrorReporter reporter = new MyErrorReporter();
schemaManager.setErrorReporter(reporter);
Document document = ...
schemaManager.load(document);
When an included XMLSchema is not found, MyErrorReporter.report() is called. I would like to stop the validation process as soon as possible when an error (or warning) occurs.
In the documentation it says:
The application can indicate to Saxon that the error should be considered fatal by calling setTerminationMessage(String).
I do this, but it doesn't work, Saxon goes on loading all the other included schemas which takes too much time before an error is produced.
Here is the stack:
com.saxonica.ee.schema.sdoc.SchemaElement.warning(SchemaElement.java:430) com.saxonica.ee.schema.sdoc.XSDInclude.handleSchemaException(XSDInclude.java:105) com.saxonica.ee.schema.sdoc.XSDInclude.prepareAttributes(XSDInclude.java:93) com.saxonica.ee.schema.sdoc.SchemaElement.processAllAttributes(SchemaElement.java:130) com.saxonica.ee.schema.sdoc.SchemaElement.processAllAttributes(SchemaElement.java:132) com.saxonica.ee.schema.sdoc.SchemaReader.read(SchemaReader.java:169) com.saxonica.config.EnterpriseConfiguration.addSchemaSource(EnterpriseConfiguration.java:662) com.saxonica.config.EnterpriseConfiguration.addSchemaSource(EnterpriseConfiguration.java:632) com.saxonica.ee.s9api.SchemaManagerImpl.load(SchemaManagerImpl.java:145)
Updated by Michael Kay almost 2 years ago
The documentation does also warn that there's no guarantee this will have any effect - it's hard to ensure that the flag is checked on all paths. But I'm adding a test for this one.
Updated by Michael Kay almost 2 years ago
- Category set to Diagnostics
- Status changed from New to Resolved
- Assignee set to Michael Kay
- Priority changed from Low to Normal
- Applies to branch 11, trunk added
- Fix Committed on Branch 11, trunk added
- Platforms .NET, Java added
Resolved for some common cases of errors and warnings arising during schema processing. There are almost certainly other similar paths that should be changed too.
Updated by Debbie Lockett over 1 year ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 11.4 added
Bug fix applied in the Saxon 11.4 maintenance release.
Please register to edit this issue