You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by an...@apache.org on 2003/12/09 02:14:31 UTC
cvs commit: ant/src/testcases/org/apache/tools/ant/types XMLCatalogTest.java
antoine 2003/12/08 17:14:31
Modified: src/main/org/apache/tools/ant/types XMLCatalog.java
src/testcases/org/apache/tools/ant/types XMLCatalogTest.java
Log:
Fix URIs for DTDs entered with a full path location under Windows
PR: 23913
Revision Changes Path
1.34 +20 -3 ant/src/main/org/apache/tools/ant/types/XMLCatalog.java
Index: XMLCatalog.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- XMLCatalog.java 23 Sep 2003 14:33:43 -0000 1.33
+++ XMLCatalog.java 9 Dec 2003 01:14:31 -0000 1.34
@@ -74,6 +74,7 @@
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JAXPUtils;
import org.xml.sax.EntityResolver;
@@ -678,6 +679,8 @@
private InputSource filesystemLookup(ResourceLocation matchingEntry) {
String uri = matchingEntry.getLocation();
+ // the following line seems to be necessary on Windows under JDK 1.2
+ uri = uri.replace(File.separatorChar, '/');
URL baseURL = null;
//
@@ -697,11 +700,25 @@
InputSource source = null;
URL url = null;
-
try {
url = new URL(baseURL, uri);
} catch (MalformedURLException ex) {
- // ignore
+ // this processing is useful under Windows when the location of the DTD has been given as an absolute path
+ // see Bugzilla Report 23913
+ File testFile = new File(uri);
+ if (testFile.exists() && testFile.canRead()) {
+ log("uri : '"
+ + uri + "' matches a readable file", Project.MSG_DEBUG);
+ try {
+ url = fileUtils.getFileURL(testFile);
+ } catch (MalformedURLException ex1) {
+ throw new BuildException("could not find an URL for :" + testFile.getAbsolutePath());
+ }
+ } else {
+ log("uri : '"
+ + uri + "' does not match a readable file", Project.MSG_DEBUG);
+
+ }
}
if (url != null) {
1.7 +24 -1 ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java
Index: XMLCatalogTest.java
===================================================================
RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLCatalogTest.java 25 Sep 2003 07:44:13 -0000 1.6
+++ XMLCatalogTest.java 9 Dec 2003 01:14:31 -0000 1.7
@@ -238,6 +238,29 @@
fail("resolveEntity() failed!" + e.toString());
}
}
+ // inspired by Bugzilla Report 23913
+ // a problem used to happen under Windows when the location of the DTD was given as an absolute path
+ // possibly with a mixture of file separators
+ public void testAbsolutePath() {
+ ResourceLocation dtd = new ResourceLocation();
+ dtd.setPublicId("-//stevo//DTD doc 1.0//EN");
+
+ String sysid = System.getProperty("user.dir") + File.separator + "src/etc/testcases/taskdefs/optional/xml/doc.dtd";
+ dtd.setLocation(sysid);
+ catalog.addDTD(dtd);
+ File dtdFile = project.resolveFile(sysid);
+
+ try {
+ InputSource result = catalog.resolveEntity("-//stevo//DTD doc 1.0//EN",
+ "nap:chemical+brothers");
+ assertNotNull(result);
+ assertEquals(toURLString(dtdFile),
+ result.getSystemId());
+ } catch (Exception e) {
+ fail("resolveEntity() failed!" + e.toString());
+ }
+
+ }
public void testSimpleEntry() {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: cvs commit: ant/src/testcases/org/apache/tools/ant/types XMLCatalogTest.java
Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 9 Dec 2003, Antoine Lévy-Lambert <an...@antbuild.com> wrote:
> I would like to push into ant1.6 this change
I don't recall why I didn't merge it in.
> Any objections ?
Nope.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
AW: cvs commit: ant/src/testcases/org/apache/tools/ant/types XMLCatalogTest.java
Posted by Antoine Lévy-Lambert <an...@antbuild.com>.
Hi,
I would like to push into ant1.6 this change
http://marc.theaimsgroup.com/?l=ant-dev&m=106432764118438&w=2
bodewig 2003/09/23 07:33:43
Modified: . WHATSNEW
src/etc/testcases/taskdefs/optional xmlvalidate.xml
src/main/org/apache/tools/ant/types XMLCatalog.java
src/testcases/org/apache/tools/ant/taskdefs/optional
XmlValidateTest.java
Log:
Defer expansion of reference until the catalog gets used.
PR: 20965
and my last change (fix the full path locations of DTDs under Windows).
Any objections ?
Antoine
-----Ursprüngliche Nachricht-----
Von: antoine@apache.org [mailto:antoine@apache.org]
Gesendet: Dienstag, 9. Dezember 2003 02:15
An: ant-cvs@apache.org
Betreff: cvs commit: ant/src/testcases/org/apache/tools/ant/types
XMLCatalogTest.java
antoine 2003/12/08 17:14:31
Modified: src/main/org/apache/tools/ant/types XMLCatalog.java
src/testcases/org/apache/tools/ant/types XMLCatalogTest.java
Log:
Fix URIs for DTDs entered with a full path location under Windows
PR: 23913
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org