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)
Please register to edit this issue