curcuru     00/12/20 06:10:45

  Modified:    test/java/src/org/apache/qetest/xsl PerformanceTest.java
                        XHTComparator.java XSLDirectoryIterator.java
  Log:
  Update to use filenameToURL, which is not completely
  tested but is better than current getURIFromString method
  
  Revision  Changes    Path
  1.2       +2 -3      
xml-xalan/test/java/src/org/apache/qetest/xsl/PerformanceTest.java
  
  Index: PerformanceTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/PerformanceTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PerformanceTest.java      2000/11/01 23:26:57     1.1
  +++ PerformanceTest.java      2000/12/20 14:10:44     1.2
  @@ -230,12 +230,11 @@
                   // Use this static convenience method; returns a URL; 
convert to String via toExternalForm()
                   // Note: we should consider caching the original strings 
first, 
                   //  in case we later on have a use for them instead of the 
URI'd format
  -                XMLName = getURLFromString(XMLName, null).toExternalForm();
  -                XSLName = getURLFromString(XSLName, null).toExternalForm();
  +                XMLName = filenameToURL(XMLName);
  +                XSLName = filenameToURL(XSLName);
   
                   // Note: Currently 28-Jun-00, the output of files is handled 
differently, so 
                   //  we do NOT want to convert those.  Subject to change, 
however.
  -                // OutName = getURLFromString(OutName, 
null).toExternalForm();
                   reporter.logTraceMsg("processSingleFile() useURI: "
                                        + XSLName);
               }
  
  
  
  1.3       +14 -346   
xml-xalan/test/java/src/org/apache/qetest/xsl/XHTComparator.java
  
  Index: XHTComparator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XHTComparator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XHTComparator.java        2000/12/06 13:42:08     1.2
  +++ XHTComparator.java        2000/12/20 14:10:44     1.3
  @@ -109,7 +109,7 @@
    * attempt to parse it as XML, not other types)
    * @author [EMAIL PROTECTED]
    * @author [EMAIL PROTECTED]
  - * @version $Id: XHTComparator.java,v 1.2 2000/12/06 13:42:08 curcuru Exp $
  + * @version $Id: XHTComparator.java,v 1.3 2000/12/20 14:10:44 curcuru Exp $
    */
   public class XHTComparator
   {
  @@ -689,8 +689,7 @@
                   // Use static worker method to get the correct format
                   // Note: this is copied straight from Xalan 1.x's 
org.apache.xalan.xslt.Process
                   // TODO verify this is the most correct and simplest way to 
munge the filename
  -                xercesFilename = getURLFromString(filename,
  -                                                  null).toExternalForm();
  +                xercesFilename = filenameToURL(filename);
               }
               catch (Exception e)
               {
  @@ -778,350 +777,19 @@
       }  // end of parse()
   
       /**
  -     * Take a user string and try and parse XML, and also return the url.
  -     * <p>Note: this needs to be revisited.  It is only used to convert 
Strings
  -     * that represent filenames into the proper URL format for Xerces 1.1x 
parser.</p>
  -     * Note: this is copied straight from Xalan 1.x's 
org.apache.xalan.xslt.Process
  -     *
  -     * NEEDSDOC @param urlString
  -     * NEEDSDOC @param base
  -     *
  -     * NEEDSDOC ($objectName$) @return
  -     * @exception Exception thrown if we really really can't create the URL
  +     * Worker method to translate a String filename to URL.  
  +     * Note: This method is not necessarily proven to get the 
  +     * correct URL for every possible kind of filename.
  +     * @param String path\filename of test file
  +     * @return URL to pass to SystemId
        */
  -    public static URL getURLFromString(String urlString, String base)
  -            throws Exception
  +    public static String filenameToURL(String filename)
       {
  -
  -        String origURLString = urlString;
  -        String origBase = base;
  -
  -        // System.out.println("getURLFromString - urlString: "+urlString+", 
base: "+base);
  -        Object doc;
  -        URL url = null;
  -        int fileStartType = 0;
  -
  -        try
  -        {
  -            if (null != base)
  -            {
  -                if (base.toLowerCase().startsWith("file:/"))
  -                {
  -                    fileStartType = 1;
  -                }
  -                else if (base.toLowerCase().startsWith("file:"))
  -                {
  -                    fileStartType = 2;
  -                }
  -            }
  -
  -            boolean isAbsoluteURL;
  -
  -            // From http://www.ics.uci.edu/pub/ietf/uri/rfc1630.txt
  -            // A partial form can be distinguished from an absolute form in 
that the
  -            // latter must have a colon and that colon must occur before any 
slash
  -            // characters. Systems not requiring partial forms should not 
use any
  -            // unencoded slashes in their naming schemes.  If they do, 
absolute URIs
  -            // will still work, but confusion may result.
  -            int indexOfColon = urlString.indexOf(':');
  -            int indexOfSlash = urlString.indexOf('/');
  -
  -            if ((indexOfColon != -1) && (indexOfSlash != -1)
  -                    && (indexOfColon < indexOfSlash))
  -            {
  -
  -                // The url (or filename, for that matter) is absolute.
  -                isAbsoluteURL = true;
  -            }
  -            else
  -            {
  -                isAbsoluteURL = false;
  -            }
  -
  -            if (isAbsoluteURL || (null == base) || (base.length() == 0))
  -            {
  -                try
  -                {
  -                    url = new URL(urlString);
  -                }
  -                catch (MalformedURLException e){}
  -            }
  -
  -            // The Java URL handling doesn't seem to handle relative file 
names.
  -            else if (!((urlString.charAt(0) == '.') || (fileStartType > 0)))
  -            {
  -                try
  -                {
  -                    URL baseUrl = new URL(base);
  -
  -                    url = new URL(baseUrl, urlString);
  -                }
  -                catch (MalformedURLException e){}
  -            }
  -
  -            if (null == url)
  -            {
  -
  -                // Then we're going to try and make a file URL below, so 
strip 
  -                // off the protocol header.
  -                if (urlString.toLowerCase().startsWith("file:/"))
  -                {
  -                    urlString = urlString.substring(6);
  -                }
  -                else if (urlString.toLowerCase().startsWith("file:"))
  -                {
  -                    urlString = urlString.substring(5);
  -                }
  -            }
  -
  -            if ((null == url) && ((null == base) || (fileStartType > 0)))
  -            {
  -                if (1 == fileStartType)
  -                {
  -                    if (null != base)
  -                        base = base.substring(6);
  -
  -                    fileStartType = 1;
  -                }
  -                else if (2 == fileStartType)
  -                {
  -                    if (null != base)
  -                        base = base.substring(5);
  -
  -                    fileStartType = 2;
  -                }
  -
  -                File f = new File(urlString);
  -
  -                if (!f.isAbsolute() && (null != base))
  -                {
  -
  -                    // String dir = f.isDirectory() ? f.getAbsolutePath() : 
f.getParent();
  -                    // System.out.println("prebuiltUrlString (1): "+base);
  -                    StringTokenizer tokenizer = new StringTokenizer(base,
  -                                                    "\\/");
  -                    String fixedBase = null;
  -
  -                    while (tokenizer.hasMoreTokens())
  -                    {
  -                        String token = tokenizer.nextToken();
  -
  -                        if (null == fixedBase)
  -                        {
  -
  -                            // Thanks to Rick Maddy for the bug fix for UNIX 
here.
  -                            if (base.charAt(0) == '\\'
  -                                    || base.charAt(0) == '/')
  -                            {
  -                                fixedBase = File.separator + token;
  -                            }
  -                            else
  -                            {
  -                                fixedBase = token;
  -                            }
  -                        }
  -                        else
  -                        {
  -                            fixedBase += File.separator + token;
  -                        }
  -                    }
  -
  -                    // System.out.println("rebuiltUrlString (1): 
"+fixedBase);
  -                    f = new File(fixedBase);
  -
  -                    String dir = f.isDirectory()
  -                                 ? f.getAbsolutePath() : f.getParent();
  -
  -                    // System.out.println("dir: "+dir);
  -                    // System.out.println("urlString: "+urlString);
  -                    // f = new File(dir, urlString);
  -                    // System.out.println("f (1): "+f.toString());
  -                    // urlString = f.getAbsolutePath();
  -                    f = new File(urlString);
  -
  -                    boolean isAbsolute = f.isAbsolute()
  -                                         || (urlString.charAt(0) == '\\')
  -                                         || (urlString.charAt(0) == '/');
  -
  -                    if (!isAbsolute)
  -                    {
  -
  -                        // Getting more and more ugly...
  -                        if (dir.charAt(dir.length() - 1)
  -                                != File.separator.charAt(0)
  -                                && urlString.charAt(0)
  -                                   != File.separator.charAt(0))
  -                        {
  -                            urlString = dir + File.separator + urlString;
  -                        }
  -                        else
  -                        {
  -                            urlString = dir + urlString;
  -                        }
  -
  -                        // System.out.println("prebuiltUrlString (2): 
"+urlString);
  -                        tokenizer = new StringTokenizer(urlString, "\\/");
  -
  -                        String rebuiltUrlString = null;
  -
  -                        while (tokenizer.hasMoreTokens())
  -                        {
  -                            String token = tokenizer.nextToken();
  -
  -                            if (null == rebuiltUrlString)
  -                            {
  -
  -                                // Thanks to Rick Maddy for the bug fix for 
UNIX here.
  -                                if (urlString.charAt(0) == '\\'
  -                                        || urlString.charAt(0) == '/')
  -                                {
  -                                    rebuiltUrlString = File.separator + 
token;
  -                                }
  -                                else
  -                                {
  -                                    rebuiltUrlString = token;
  -                                }
  -                            }
  -                            else
  -                            {
  -                                rebuiltUrlString += File.separator + token;
  -                            }
  -                        }
  -
  -                        // System.out.println("rebuiltUrlString (2): 
"+rebuiltUrlString);
  -                        if (null != rebuiltUrlString)
  -                            urlString = rebuiltUrlString;
  -                    }
  -
  -                    // System.out.println("fileStartType: "+fileStartType);
  -                    if (1 == fileStartType)
  -                    {
  -                        if (urlString.charAt(0) == '/')
  -                        {
  -                            urlString = "file://" + urlString;
  -                        }
  -                        else
  -                        {
  -                            urlString = "file:/" + urlString;
  -                        }
  -                    }
  -                    else if (2 == fileStartType)
  -                    {
  -                        urlString = "file:" + urlString;
  -                    }
  -
  -                    try
  -                    {
  -
  -                        // System.out.println("Final before try: 
"+urlString);
  -                        url = new URL(urlString);
  -                    }
  -                    catch (MalformedURLException e)
  -                    {
  -
  -                        // System.out.println("Error trying to make URL from 
"+urlString);
  -                    }
  -                }
  -            }
  -
  -            if (null == url)
  -            {
  -
  -                // The sun java VM doesn't do this correctly, but I'll 
  -                // try it here as a second-to-last resort.
  -                if ((null != origBase) && (origBase.length() > 0))
  -                {
  -                    try
  -                    {
  -                        URL baseURL = new URL(origBase);
  -
  -                        // System.out.println("Trying to make URL from 
"+origBase+" and "+origURLString);
  -                        url = new URL(baseURL, origURLString);
  -
  -                        // System.out.println("Success! New URL is: 
"+url.toString());
  -                    }
  -                    catch (MalformedURLException e)
  -                    {
  -
  -                        // System.out.println("Error trying to make URL from 
"+origBase+" and "+origURLString);
  -                    }
  -                }
  -
  -                if (null == url)
  -                {
  -                    try
  -                    {
  -                        String lastPart;
  -
  -                        if (null != origBase)
  -                        {
  -                            File baseFile = new File(origBase);
  -
  -                            if (baseFile.isDirectory())
  -                            {
  -                                lastPart =
  -                                    new File(baseFile,
  -                                             urlString).getAbsolutePath();
  -                            }
  -                            else
  -                            {
  -                                String parentDir = baseFile.getParent();
  -
  -                                lastPart =
  -                                    new File(parentDir,
  -                                             urlString).getAbsolutePath();
  -                            }
  -                        }
  -                        else
  -                        {
  -                            lastPart = new File(urlString).getAbsolutePath();
  -                        }
  -
  -                        // Hack
  -                        // if((lastPart.charAt(0) == '/') && 
(lastPart.charAt(2) == ':'))
  -                        //   lastPart = lastPart.substring(1, 
lastPart.length() - 1);
  -                        String fullpath;
  -
  -                        if (lastPart.charAt(0) == '\\'
  -                                || lastPart.charAt(0) == '/')
  -                        {
  -                            fullpath = "file://" + lastPart;
  -                        }
  -                        else
  -                        {
  -                            fullpath = "file:" + lastPart;
  -                        }
  -
  -                        url = new URL(fullpath);
  -                    }
  -                    catch (MalformedURLException e2)
  -                    {
  -
  -                        // Below throw modified from original version
  -                        throw new Exception("Cannot create url for: "
  -                                            + urlString + " threw: "
  -                                            + e2.toString());
  -
  -                        
//XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_CREATE_URL, new 
Object[]{urlString}),e2); //"Cannot create url for: " + urlString, e2 );
  -                    }
  -                }
  -            }
  -        }
  -        catch (SecurityException se)
  -        {
  -            try
  -            {
  -                url = new URL("http://xml.apache.org/xslt/";
  -                              + java.lang.Math.random());  // dummy
  -            }
  -            catch (MalformedURLException e2)
  -            {
  -
  -                // I give up
  -            }
  -        }
  -
  -        // System.out.println("url: "+url.toString());
  -        return url;
  +        File f = new File(filename);
  +        String tmp = f.getAbsolutePath();
  +         if (File.separatorChar == '\\') {
  +             tmp = tmp.replace('\\', '/');
  +         }
  +        return "file:///" + tmp;
       }
   }
  
  
  
  1.4       +4 -351    
xml-xalan/test/java/src/org/apache/qetest/xsl/XSLDirectoryIterator.java
  
  Index: XSLDirectoryIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XSLDirectoryIterator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSLDirectoryIterator.java 2000/12/12 16:01:02     1.3
  +++ XSLDirectoryIterator.java 2000/12/20 14:10:44     1.4
  @@ -82,8 +82,6 @@
   // Try to catch this specific exception from the ProcessorWrapper, if it is 
thrown
   import org.xml.sax.SAXException;
   
  -// /////////////////// HACK - added from Xalan1 
org.apache.xalan.xslt.Process /////////////////////
  -import java.net.MalformedURLException;
   
   //-------------------------------------------------------------------------
   
  @@ -101,7 +99,7 @@
    * </ul>
    * @todo improve file discovery - file execution paradigm
    * @author Shane Curcuru
  - * @version $Id: XSLDirectoryIterator.java,v 1.3 2000/12/12 16:01:02 curcuru 
Exp $
  + * @version $Id: XSLDirectoryIterator.java,v 1.4 2000/12/20 14:10:44 curcuru 
Exp $
    */
   public class XSLDirectoryIterator extends XSLProcessorTestBase
   {
  @@ -1129,8 +1127,8 @@
               {
   
                   // Use this static convenience method; returns a URL; 
convert to String via toExternalForm()
  -                XMLName = getURLFromString(XMLName, null).toExternalForm();
  -                XSLName = getURLFromString(XSLName, null).toExternalForm();
  +                XMLName = filenameToURL(XMLName);
  +                XSLName = filenameToURL(XSLName);
   
                   // HACK (end)- replicate this code locally, since we may 
test Xalan2 which doesn't have this!
                   // Note: Currently 28-Jun-00, the output of files is handled 
differently, so 
  @@ -1226,7 +1224,7 @@
               if (useURI)
               {
                   // Use this static convenience method; returns a URL; 
convert to String via toExternalForm()
  -                XMLName = getURLFromString(XMLName, null).toExternalForm();
  +                XMLName = filenameToURL(XMLName);
               }
               fileTime = processorW.processEmbeddedToFile(XMLName, OutName);
   
  @@ -1765,350 +1763,5 @@
           return false;
       }
   
  -    // /////////////////// HACK - added from Xalan1 
org.apache.xalan.xslt.Process /////////////////////
  -
  -    /**
  -     * Take a user string and try and parse XML, and also return
  -     * the url.  Needed for Xerces 1.2 builds.
  -     * @todo replace this with simpler code, better logging
  -     *
  -     * NEEDSDOC @param urlString
  -     * NEEDSDOC @param base
  -     *
  -     * NEEDSDOC ($objectName$) @return
  -     * @exception SAXException thrown if we really really can't create the 
URL
  -     */
  -    public static URL getURLFromString(String urlString, String base)
  -            throws SAXException
  -    {
  -
  -        String origURLString = urlString;
  -        String origBase = base;
  -
  -        // System.out.println("getURLFromString - urlString: "+urlString+", 
base: "+base);
  -        Object doc;
  -        URL url = null;
  -        int fileStartType = 0;
  -
  -        try
  -        {
  -            if (null != base)
  -            {
  -                if (base.toLowerCase().startsWith("file:/"))
  -                {
  -                    fileStartType = 1;
  -                }
  -                else if (base.toLowerCase().startsWith("file:"))
  -                {
  -                    fileStartType = 2;
  -                }
  -            }
  -
  -            boolean isAbsoluteURL;
  -
  -            // From http://www.ics.uci.edu/pub/ietf/uri/rfc1630.txt
  -            // A partial form can be distinguished from an absolute form in 
that the
  -            // latter must have a colon and that colon must occur before any 
slash
  -            // characters. Systems not requiring partial forms should not 
use any
  -            // unencoded slashes in their naming schemes.  If they do, 
absolute URIs
  -            // will still work, but confusion may result.
  -            int indexOfColon = urlString.indexOf(':');
  -            int indexOfSlash = urlString.indexOf('/');
  -
  -            if ((indexOfColon != -1) && (indexOfSlash != -1)
  -                    && (indexOfColon < indexOfSlash))
  -            {
  -
  -                // The url (or filename, for that matter) is absolute.
  -                isAbsoluteURL = true;
  -            }
  -            else
  -            {
  -                isAbsoluteURL = false;
  -            }
  -
  -            if (isAbsoluteURL || (null == base) || (base.length() == 0))
  -            {
  -                try
  -                {
  -                    url = new URL(urlString);
  -                }
  -                catch (MalformedURLException e){}
  -            }
  -
  -            // The Java URL handling doesn't seem to handle relative file 
names.
  -            else if (!((urlString.charAt(0) == '.') || (fileStartType > 0)))
  -            {
  -                try
  -                {
  -                    URL baseUrl = new URL(base);
  -
  -                    url = new URL(baseUrl, urlString);
  -                }
  -                catch (MalformedURLException e){}
  -            }
  -
  -            if (null == url)
  -            {
  -
  -                // Then we're going to try and make a file URL below, so 
strip 
  -                // off the protocol header.
  -                if (urlString.toLowerCase().startsWith("file:/"))
  -                {
  -                    urlString = urlString.substring(6);
  -                }
  -                else if (urlString.toLowerCase().startsWith("file:"))
  -                {
  -                    urlString = urlString.substring(5);
  -                }
  -            }
  -
  -            if ((null == url) && ((null == base) || (fileStartType > 0)))
  -            {
  -                if (1 == fileStartType)
  -                {
  -                    if (null != base)
  -                        base = base.substring(6);
  -
  -                    fileStartType = 1;
  -                }
  -                else if (2 == fileStartType)
  -                {
  -                    if (null != base)
  -                        base = base.substring(5);
  -
  -                    fileStartType = 2;
  -                }
  -
  -                File f = new File(urlString);
  -
  -                if (!f.isAbsolute() && (null != base))
  -                {
  -
  -                    // String dir = f.isDirectory() ? f.getAbsolutePath() : 
f.getParent();
  -                    // System.out.println("prebuiltUrlString (1): "+base);
  -                    StringTokenizer tokenizer = new StringTokenizer(base,
  -                                                    "\\/");
  -                    String fixedBase = null;
  -
  -                    while (tokenizer.hasMoreTokens())
  -                    {
  -                        String token = tokenizer.nextToken();
  -
  -                        if (null == fixedBase)
  -                        {
  -
  -                            // Thanks to Rick Maddy for the bug fix for UNIX 
here.
  -                            if (base.charAt(0) == '\\'
  -                                    || base.charAt(0) == '/')
  -                            {
  -                                fixedBase = File.separator + token;
  -                            }
  -                            else
  -                            {
  -                                fixedBase = token;
  -                            }
  -                        }
  -                        else
  -                        {
  -                            fixedBase += File.separator + token;
  -                        }
  -                    }
  -
  -                    // System.out.println("rebuiltUrlString (1): 
"+fixedBase);
  -                    f = new File(fixedBase);
  -
  -                    String dir = f.isDirectory()
  -                                 ? f.getAbsolutePath() : f.getParent();
  -
  -                    // System.out.println("dir: "+dir);
  -                    // System.out.println("urlString: "+urlString);
  -                    // f = new File(dir, urlString);
  -                    // System.out.println("f (1): "+f.toString());
  -                    // urlString = f.getAbsolutePath();
  -                    f = new File(urlString);
  -
  -                    boolean isAbsolute = f.isAbsolute()
  -                                         || (urlString.charAt(0) == '\\')
  -                                         || (urlString.charAt(0) == '/');
  -
  -                    if (!isAbsolute)
  -                    {
  -
  -                        // Getting more and more ugly...
  -                        if (dir.charAt(dir.length() - 1)
  -                                != File.separator.charAt(0)
  -                                && urlString.charAt(0)
  -                                   != File.separator.charAt(0))
  -                        {
  -                            urlString = dir + File.separator + urlString;
  -                        }
  -                        else
  -                        {
  -                            urlString = dir + urlString;
  -                        }
  -
  -                        // System.out.println("prebuiltUrlString (2): 
"+urlString);
  -                        tokenizer = new StringTokenizer(urlString, "\\/");
  -
  -                        String rebuiltUrlString = null;
  -
  -                        while (tokenizer.hasMoreTokens())
  -                        {
  -                            String token = tokenizer.nextToken();
  -
  -                            if (null == rebuiltUrlString)
  -                            {
  -
  -                                // Thanks to Rick Maddy for the bug fix for 
UNIX here.
  -                                if (urlString.charAt(0) == '\\'
  -                                        || urlString.charAt(0) == '/')
  -                                {
  -                                    rebuiltUrlString = File.separator + 
token;
  -                                }
  -                                else
  -                                {
  -                                    rebuiltUrlString = token;
  -                                }
  -                            }
  -                            else
  -                            {
  -                                rebuiltUrlString += File.separator + token;
  -                            }
  -                        }
  -
  -                        // System.out.println("rebuiltUrlString (2): 
"+rebuiltUrlString);
  -                        if (null != rebuiltUrlString)
  -                            urlString = rebuiltUrlString;
  -                    }
  -
  -                    // System.out.println("fileStartType: "+fileStartType);
  -                    if (1 == fileStartType)
  -                    {
  -                        if (urlString.charAt(0) == '/')
  -                        {
  -                            urlString = "file://" + urlString;
  -                        }
  -                        else
  -                        {
  -                            urlString = "file:/" + urlString;
  -                        }
  -                    }
  -                    else if (2 == fileStartType)
  -                    {
  -                        urlString = "file:" + urlString;
  -                    }
  -
  -                    try
  -                    {
  -
  -                        // System.out.println("Final before try: 
"+urlString);
  -                        url = new URL(urlString);
  -                    }
  -                    catch (MalformedURLException e)
  -                    {
  -
  -                        // System.out.println("Error trying to make URL from 
"+urlString);
  -                    }
  -                }
  -            }
  -
  -            if (null == url)
  -            {
  -
  -                // The sun java VM doesn't do this correctly, but I'll 
  -                // try it here as a second-to-last resort.
  -                if ((null != origBase) && (origBase.length() > 0))
  -                {
  -                    try
  -                    {
  -                        URL baseURL = new URL(origBase);
  -
  -                        // System.out.println("Trying to make URL from 
"+origBase+" and "+origURLString);
  -                        url = new URL(baseURL, origURLString);
  -
  -                        // System.out.println("Success! New URL is: 
"+url.toString());
  -                    }
  -                    catch (MalformedURLException e)
  -                    {
  -
  -                        // System.out.println("Error trying to make URL from 
"+origBase+" and "+origURLString);
  -                    }
  -                }
  -
  -                if (null == url)
  -                {
  -                    try
  -                    {
  -                        String lastPart;
  -
  -                        if (null != origBase)
  -                        {
  -                            File baseFile = new File(origBase);
  -
  -                            if (baseFile.isDirectory())
  -                            {
  -                                lastPart =
  -                                    new File(baseFile,
  -                                             urlString).getAbsolutePath();
  -                            }
  -                            else
  -                            {
  -                                String parentDir = baseFile.getParent();
  -
  -                                lastPart =
  -                                    new File(parentDir,
  -                                             urlString).getAbsolutePath();
  -                            }
  -                        }
  -                        else
  -                        {
  -                            lastPart = new File(urlString).getAbsolutePath();
  -                        }
  -
  -                        // Hack
  -                        // if((lastPart.charAt(0) == '/') && 
(lastPart.charAt(2) == ':'))
  -                        //   lastPart = lastPart.substring(1, 
lastPart.length() - 1);
  -                        String fullpath;
  -
  -                        if (lastPart.charAt(0) == '\\'
  -                                || lastPart.charAt(0) == '/')
  -                        {
  -                            fullpath = "file://" + lastPart;
  -                        }
  -                        else
  -                        {
  -                            fullpath = "file:" + lastPart;
  -                        }
  -
  -                        url = new URL(fullpath);
  -                    }
  -                    catch (MalformedURLException e2)
  -                    {
  -                        throw new SAXException("Cannot create url for: "
  -                                               + urlString, e2);
  -
  -                        
//XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_CREATE_URL, new 
Object[]{urlString}),e2); //"Cannot create url for: " + urlString, e2 );
  -                    }
  -                }
  -            }
  -        }
  -        catch (SecurityException se)
  -        {
  -            try
  -            {
  -                url = new URL("http://xml.apache.org/xslt/";
  -                              + java.lang.Math.random());  // dummy
  -            }
  -            catch (MalformedURLException e2)
  -            {
  -
  -                // I give up
  -            }
  -        }
  -
  -        // System.out.println("url: "+url.toString());
  -        return url;
  -    }
   }  // end of class XSLDirectoryIterator
   
  
  
  

Reply via email to