Project

Profile

Help

Bug #5478

closed

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

Added by Gerben Abbink almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2022-05-07
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
11, trunk
Fix Committed on Branch:
11, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

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 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.

Actions #2

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.

Actions #3

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

Also available in: Atom PDF