From 081d01391f8e9a6e9c1218e1dea279bd79e51fea Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 19 Oct 2000 10:57:48 +0000 Subject: [PATCH] Resolve filenames in SYSTEM entity declarations relative to the project's basedir. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268106 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/ProjectHelper.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 8df38d2c8..6c7d0c845 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -179,6 +179,24 @@ public class ProjectHelper { * Handler for the root element. It's only child must be the "project" element. */ private class RootHandler extends HandlerBase { + + /** + * resolve file: URIs as releative to the project's basedir. + */ + public InputSource resolveEntity(String publicId, + String systemId) { + + if (systemId.startsWith("file:")) { + try { + return new InputSource(new FileInputStream(project.resolveFile(systemId.substring(5)))); + } catch (FileNotFoundException fne) { + project.log(fne.getMessage(), Project.MSG_WARN); + } + } + // use default if not file or file not found + return null; + } + public void startElement(String tag, AttributeList attrs) throws SAXParseException { if (tag.equals("project")) { new ProjectHandler(this).init(tag, attrs);