use of org.eclipse.wst.xml.core.internal.validation.core.LazyURLInputStream in project webtools.sourceediting by eclipse.
the class DTDParser method resolveEntity.
public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
InputSource result = null;
URIResolver idResolver = URIResolverPlugin.createResolver();
String logicalURI = idResolver.resolve(currentDTD.getName(), publicId, systemId);
// bug 113537, ensure physical resolution gets done here
// right before we attempt to open a stream
String physicalURI = idResolver.resolvePhysicalLocation(currentDTD.getName(), publicId, logicalURI);
result = new InputSource(logicalURI);
if (// $NON-NLS-1$
!(physicalURI == null || physicalURI.equals("") || URIHelper.hasProtocol(physicalURI))) {
// $NON-NLS-1$
physicalURI = "file:///" + physicalURI;
}
result.setByteStream(new LazyURLInputStream(physicalURI));
return result;
}
use of org.eclipse.wst.xml.core.internal.validation.core.LazyURLInputStream in project webtools.sourceediting by eclipse.
the class XMLValidator method _internalResolveEntity.
public static XMLInputSource _internalResolveEntity(URIResolver uriResolver, XMLResourceIdentifier rid, NestedValidatorContext context) throws IOException {
XMLInputSource is = null;
if (uriResolver != null) {
String id = rid.getPublicId();
if (id == null) {
id = rid.getNamespace();
}
String location = null;
if (id != null || rid.getLiteralSystemId() != null) {
location = uriResolver.resolve(rid.getBaseSystemId(), id, rid.getLiteralSystemId());
}
if (location != null) {
String physical = uriResolver.resolvePhysicalLocation(rid.getBaseSystemId(), id, location);
// if physical is already a known bad uri, just go ahead and throw an exception
if (context instanceof XMLNestedValidatorContext) {
XMLNestedValidatorContext xmlContext = ((XMLNestedValidatorContext) context);
if (xmlContext.isURIMarkedInaccessible(physical)) {
throw new FileNotFoundException(physical);
}
}
is = new XMLInputSource(rid.getPublicId(), location, location);
// This block checks that the file exists. If it doesn't we need to throw
// an exception so Xerces will report an error. note: This may not be
// necessary with all versions of Xerces but has specifically been
// experienced with the version included in IBM's 1.4.2 JDK.
InputStream isTemp = null;
try {
isTemp = new URL(physical).openStream();
} catch (IOException e) {
// physical was a bad url, so cache it so we know next time
if (context instanceof XMLNestedValidatorContext) {
XMLNestedValidatorContext xmlContext = ((XMLNestedValidatorContext) context);
xmlContext.markURIInaccessible(physical);
}
throw e;
} finally {
if (isTemp != null) {
isTemp.close();
}
}
is.setByteStream(new LazyURLInputStream(physical));
}
}
return is;
}
Aggregations