Details
Description
Assuming you have
- system property javax.xml.accessExternalDTD set to all or file
- enabled out validation
- an xsd that references a DTD
And fire a request, the following log appears:
WARN [org.apa.cxf.ws.add.EndpointReferenceUtils] Could not resolve Schema for ../dtd/XMLSchema.dtd
The request is then correctly validated, despite the warning. Tested with both valid and invalid equests.
Looking at the code:
if (impl == null) { [...] // if found in schemas map: return impl; if (systemId != null) { [...] // if found by systemId: return impl; } if (namespaceURI != null) { [...] // if found by namespaceURI: return impl; } [...] if (systemId == null) { systemId = publicId; } if (systemId != null) { InputSource source = resolver.resolve(systemId, baseURI); if (source != null) { impl = new LSInputImpl(); impl.setByteStream(source.getByteStream()); impl.setSystemId(source.getSystemId()); impl.setPublicId(source.getPublicId()); + ### the code above is run, source is found, impl is set + ### i miss a 'return impl;' here, to match the code above } } LOG.warning("Could not resolve Schema for " + systemId); } return impl;
I added two inline 'comments', starting with ### to mark the place where i miss a return statement.
Reasoning:
- all of the above happens in an if block: if (impl==null)
- it seems that with different searches eg. via namespaceURI and systemId, the variable impl should be filled and then returned
- the warning in the last line says 'Could not resolve Schema'
- but the code directly above it may indeed find a source and fill impl
- so the schema (in my case a DTD) is found. I can verify that by looking into debug values. And the validation then takes place, with expected outcomes.
- first finding the schema and then printing that it could not be found is misleading
proposed solution:
- either a return impl; statement like mentioned above
- or guard the warning with if (impl==null)