Browse Source

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
master
Stefan Bodewig 24 years ago
parent
commit
081d01391f
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      src/main/org/apache/tools/ant/ProjectHelper.java

+ 18
- 0
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -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);


Loading…
Cancel
Save