and no less than 3 '/' on whatever platform it is running. PR: 6259 Reported by: sl@ragbildung.de (Sascha Luedecke) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271216 13f79535-47bb-0310-9956-ffa450edef68master
@@ -76,7 +76,7 @@ public interface XSLTLiaison { | |||||
* case since most parsers for now incorrectly makes no difference | * case since most parsers for now incorrectly makes no difference | ||||
* between it.. and users also have problem with that :) | * between it.. and users also have problem with that :) | ||||
*/ | */ | ||||
String FILE_PROTOCOL_PREFIX = "file:///"; | |||||
String FILE_PROTOCOL_PREFIX = "file://"; | |||||
/** | /** | ||||
* set the stylesheet to use for the transformation. | * set the stylesheet to use for the transformation. | ||||
@@ -217,7 +217,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
/** | /** | ||||
* Set the destination directory into which the XSL result | * Set the destination directory into which the XSL result | ||||
* files should be copied to | * files should be copied to | ||||
* @param dirName the name of the destination directory | |||||
* @param dir the name of the destination directory | |||||
**/ | **/ | ||||
public void setDestdir(File dir) { | public void setDestdir(File dir) { | ||||
destDir = dir; | destDir = dir; | ||||
@@ -162,9 +162,15 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||||
// because it grabs the base uri via lastIndexOf('/') without | // because it grabs the base uri via lastIndexOf('/') without | ||||
// making sure it is really a /'ed path | // making sure it is really a /'ed path | ||||
protected String getSystemId(File file){ | protected String getSystemId(File file){ | ||||
String path = file.getAbsolutePath(); | |||||
path = path.replace('\\','/'); | |||||
return FILE_PROTOCOL_PREFIX + path; | |||||
String path = file.getAbsolutePath(); | |||||
path = path.replace('\\','/'); | |||||
// on Windows, use 'file:///' | |||||
if (File.separatorChar == '\\') { | |||||
return FILE_PROTOCOL_PREFIX + "/" + path; | |||||
} | |||||
// Unix, use 'file://' | |||||
return FILE_PROTOCOL_PREFIX + path; | |||||
} | } | ||||
public void addParam(String name, String value){ | public void addParam(String name, String value){ | ||||
@@ -1,6 +1,7 @@ | |||||
package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
import org.apache.tools.ant.taskdefs.XSLTLiaison; | import org.apache.tools.ant.taskdefs.XSLTLiaison; | ||||
import org.apache.tools.ant.taskdefs.condition.Os; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import java.io.File; | import java.io.File; | ||||
@@ -110,4 +111,17 @@ public class TraXLiaisonTest extends AbstractXSLTLiaisonTest { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public void testSystemId(){ | |||||
File file = null; | |||||
if ( File.separatorChar == '\\' ){ | |||||
file = new File("d:\\jdk"); | |||||
} else { | |||||
file = new File("/user/local/bin"); | |||||
} | |||||
String systemid = ((TraXLiaison)liaison).getSystemId(file); | |||||
assert("SystemIDs should start by file:///", systemid.startsWith("file:///")); | |||||
assert("SystemIDs should not start with file:////", !systemid.startsWith("file:////")); | |||||
} | |||||
} | } |