try {
/**
* SAX 2 style parser used to parse the given file.
*/
XMLReader parser = JAXPUtils.getNamespaceXMLReader();
String uri = null;
if (buildFile != null) {
uri = FILE_UTILS.toURI(buildFile.getAbsolutePath());
inputStream = new FileInputStream(buildFile);
} else {
uri = url.toString();
int pling = -1;
if (uri.startsWith("jar:file")
&& (pling = uri.indexOf("!/")) > -1) {
zf = new ZipFile(org.apache.tools.ant.launch.Locator
.fromJarURI(uri), "UTF-8");
inputStream =
zf.getInputStream(zf.getEntry(uri.substring(pling + 1)));
} else {
inputStream = url.openStream();
}
}
inputSource = new InputSource(inputStream);
if (uri != null) {
inputSource.setSystemId(uri);
}
project.log("parsing buildfile " + buildFileName + " with URI = "
+ uri + (zf != null ? " from a zip file" : ""),
Project.MSG_VERBOSE);
DefaultHandler hb = handler;
parser.setContentHandler(hb);
parser.setEntityResolver(hb);
parser.setErrorHandler(hb);
parser.setDTDHandler(hb);
parser.parse(inputSource);
} catch (SAXParseException exc) {
Location location = new Location(exc.getSystemId(), exc.getLineNumber(), exc
.getColumnNumber());
Throwable t = exc.getException();