From 043065bc765e43c50e5040339dcf88ed10d11e52 Mon Sep 17 00:00:00 2001 From: mrglavas Date: Fri, 3 Jun 2005 18:28:57 +0000 Subject: [PATCH] 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 --- .../javax/xml/parsers/DocumentBuilder.java | 15 +++++++----- .../src/javax/xml/parsers/SAXParser.java | 24 ++++++++++++------- .../xml/transform/stream/StreamSource.java | 19 ++++++++------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/java/external/src/javax/xml/parsers/DocumentBuilder.java b/java/external/src/javax/xml/parsers/DocumentBuilder.java index a352a30..c732971 100644 --- a/java/external/src/javax/xml/parsers/DocumentBuilder.java +++ b/java/external/src/javax/xml/parsers/DocumentBuilder.java @@ -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); } diff --git a/java/external/src/javax/xml/parsers/SAXParser.java b/java/external/src/javax/xml/parsers/SAXParser.java index 23c0362..b96ce7a 100644 --- a/java/external/src/javax/xml/parsers/SAXParser.java +++ b/java/external/src/javax/xml/parsers/SAXParser.java @@ -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; /** *

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); } diff --git a/java/external/src/javax/xml/transform/stream/StreamSource.java b/java/external/src/javax/xml/transform/stream/StreamSource.java index bfbcfd3..c1595db 100644 --- a/java/external/src/javax/xml/transform/stream/StreamSource.java +++ b/java/external/src/javax/xml/transform/stream/StreamSource.java @@ -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; } //////////////////////////////////////////////////////////////////////