Project

Profile

Help

Bug #5478

open

setTerminationMessage does not stop loading of included schemas when an error occurs in Saxon EE.

Added by Gerben Abbink 9 days ago. Updated 9 days ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2022-05-07
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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)

Actions #1

Updated by Michael Kay 9 days 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.

Please register to edit this issue

Also available in: Atom PDF