class ClassLoaderXmlEntityResolver extends ClassLoaderURIResolver implements XMLEntityResolver {

	@Override
	public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
		if (log.isDebugEnabled()) log.debug("resolveEntity publicId ["+resourceIdentifier.getPublicId()+"] baseSystemId ["+resourceIdentifier.getBaseSystemId()+"] expandedSystemId ["+resourceIdentifier.getExpandedSystemId()+"] literalSystemId ["+resourceIdentifier.getLiteralSystemId()+"] namespace ["+resourceIdentifier.getNamespace()+"]");
		if (resourceIdentifier.getBaseSystemId() == null
				&& resourceIdentifier.getExpandedSystemId() == null
				&& resourceIdentifier.getLiteralSystemId() == null
				&& resourceIdentifier.getNamespace() == null
				&& resourceIdentifier.getPublicId() == null) {
			// This seems to happen sometimes. For example with import of
			// sub01a.xsd and sub05.xsd without namespace in
			// /XmlValidator/import_include/root.xsd of Ibis4TestIAF. The
			// default resolve entity implementation seems to ignore it, hence
			// return null.
			return null;
		}
		
		String base = resourceIdentifier.getBaseSystemId();
		String href = resourceIdentifier.getLiteralSystemId();
		if (href == null) {
			// Ignore import with namespace but without schemaLocation
			return null;
		}

		Resource resource;
		try {
			resource = resolveToResource(href, base);
		} catch (TransformerException e) {
			throw new XNIException(e);
		}
	
		
		InputStream inputStream = resource.getURL().openStream();
		return new XMLInputSource(null, resource.getSystemId(), null, inputStream, null);
	}

	public  ClassLoaderXmlEntityResolver(ClassLoader classLoader);

}