Fixing Bugzilla #34913:

http://issues.apache.org/bugzilla/show_bug.cgi?id=34913

Usage of the File to URI conversion code only existed on the tck-jaxp-1_2_0 branch.
Merging these fixes into the main branch. For some reason the diffs are showing
the entire file changed however the changes are local to the methods which convert
File objects into URIs.


git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226208 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
mrglavas
2005-06-03 18:28:57 +00:00
parent 743421a9fe
commit 043065bc76
3 changed files with 34 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2004 The Apache Software Foundation.
* Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,6 +55,7 @@ import org.xml.sax.SAXException;
public abstract class DocumentBuilder {
private static final boolean DEBUG = false;
/** Protected constructor */
protected DocumentBuilder () {
@@ -173,12 +174,14 @@ public abstract class DocumentBuilder {
if (f == null) {
throw new IllegalArgumentException("File cannot be null");
}
String uri = "file:" + f.getAbsolutePath();
if (File.separatorChar == '\\') {
uri = uri.replace('\\', '/');
String escapedURI = FilePathToURI.filepath2URI(f.getAbsolutePath());
if (DEBUG) {
System.out.println("Escaped URI = " + escapedURI);
}
InputSource in = new InputSource(uri);
InputSource in = new InputSource(escapedURI);
return parse(in);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2004 The Apache Software Foundation.
* Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,6 +71,8 @@ import org.xml.sax.helpers.DefaultHandler;
* @version $Revision$, $Date$
*/
public abstract class SAXParser {
private static final boolean DEBUG = false;
/**
* <p>Protected constructor to prevent instaniation.
@@ -285,12 +287,14 @@ public abstract class SAXParser {
if (f == null) {
throw new IllegalArgumentException("File cannot be null");
}
String escapedURI = FilePathToURI.filepath2URI(f.getAbsolutePath());
String uri = "file:" + f.getAbsolutePath();
if (File.separatorChar == '\\') {
uri = uri.replace('\\', '/');
if (DEBUG) {
System.out.println("Escaped URI = " + escapedURI);
}
InputSource input = new InputSource(uri);
InputSource input = new InputSource(escapedURI);
this.parse(input, hb);
}
@@ -312,12 +316,14 @@ public abstract class SAXParser {
if (f == null) {
throw new IllegalArgumentException("File cannot be null");
}
String escapedURI = FilePathToURI.filepath2URI(f.getAbsolutePath());
String uri = "file:" + f.getAbsolutePath();
if (File.separatorChar == '\\') {
uri = uri.replace('\\', '/');
if (DEBUG) {
System.out.println("Escaped URI = " + escapedURI);
}
InputSource input = new InputSource(uri);
InputSource input = new InputSource(escapedURI);
this.parse(input, dh);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2004 The Apache Software Foundation.
* Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -243,14 +243,15 @@ public class StreamSource implements Source {
* @param f Must a non-null File reference.
*/
public void setSystemId(File f) {
String fpath=f.getAbsolutePath();
if (File.separatorChar != '/') {
fpath = fpath.replace(File.separatorChar, '/');
}
if( fpath.startsWith("/"))
this.systemId= "file://" + fpath;
else
this.systemId = "file:///" + fpath;
this.systemId = FilePathToURI.filepath2URI(f.getAbsolutePath());
// String fpath=f.getAbsolutePath();
// if (File.separatorChar != '/') {
// fpath = fpath.replace(File.separatorChar, '/');
// }
// if( fpath.startsWith("/"))
// this.systemId= "file://" + fpath;
// else
// this.systemId = "file:///" + fpath;
}
//////////////////////////////////////////////////////////////////////