Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348777

Summary: [typesystem.xsd] XMLReader cannot handle xml that depends on spring-batch.xsd
Product: [Modeling] M2T Reporter: Stephan Herrmann <stephan.herrmann>
Component: XpandAssignee: Project Inbox <m2t.xpand-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Stephan Herrmann CLA 2011-06-08 12:28:40 EDT
This is org.eclipse.xtends.typesystem.xsd version 1.0.1

I have an XML file that refers in its xsi:schemaLocation attribute to
  http://www.springframework.org/schema/batch
  http://www.springframework.org/schema/batch/spring-batch.xsd

I have a workflow that uses an XMLReader to read this file.

The workflow silently(!) fails.
If I remove those two lines the workflow succeeds.

About the silence: I noticed that internally an OawXSDResource
is useing a NoOpLog for reporting. Is it possible to configure this
to something more visible?


About the actual problem I found the following suspecious bits:

When reading spring-batch.xsd the xsd:import for 
http://www.springframework.org/schema/tool fails to use the schema location 
http://www.springframework.org/schema/tool/spring-tool-2.5.xsd
(I haven't found why)

Thus reading that schema falls back to using the URL
http://www.springframework.org/schema/tool
At this location we don't find an xsd but an HTML page linking to the
versioned files in that directory.

To add insult to injury the HTML is not accepted, because of this error:
"DOM: White spaces are required between publicId and systemId."
Apparently this DOCTYPE is malformed:
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

As a result of this error the OawXSDResource for 
"http://www.springframework.org/schema/tool" has an "empty" xsdSchema
(a valid object but most its fields are null/empty).


A second schema import from spring-batch.xsd refers to
http://www.springframework.org/schema/beans
For this schema I have an ecore model, so schema lookup yields
an EPackage which is not recognized by XSDResolver.tryLoadSchema()
(not an XSDResourceImpl) thus null is returned as the resolved schema.
(Note that a direct reference from the XML to the same ../schema/beans
poses no problems).

Next in OawXSDResource.collectImportedSchemas() when collecting the
broken import we do:
    list.add(res)
where res == null (for .../schema/beans).

Finally OawXSDResource.generateECore() blows up with an NPE
at builder.copy(r.generateECore()) because r is null.


I then patched OawXSDResource.collectImportedSchemas() so it would
skip any null resources, but then eventually XMLReaderImpl.readXML()
throws WorkflowInterruptedException because the XSDManager contains
a resource with errors (the resource for .../schema/tools).


For another experiment I replaced the references to schema/batch with
direct references to the offending schema/tool. Much to my surprise
this direct reference poses *no* problems.


This report has grown quite long and I don't know if all this is 
relevant, or if I'm actually facing more than one problem.


I found this quite difficult to debug because many errors are swalled 
by the NoOpLog. Additionally, I wonder why the XMLReader has to bail
out on any error of any transitively referenced resource?
Comment 1 Karsten Thoms CLA 2020-04-30 13:54:46 EDT
This is a batch close of open M2T Xpand bugs. It is not planned work on this component in the foreseeable future. If you think this issue needs to be solved and you plan to contribute a fix then feel free to reopen it.