Changeset 5962


Ignore:
Timestamp:
2003-11-25T11:43:32+13:00 (20 years ago)
Author:
kjdon
Message:

uses class loader instead of gs3home ref

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSEntityResolver.java

    r5434 r5962  
    55import org.xml.sax.EntityResolver;
    66import java.io.File;
     7import java.net.URL;
    78
    8 // maybe use class loader to find dtds etc????
     9// uses a class loader to find entities
    910public class GSEntityResolver implements EntityResolver {
    1011
    11     protected String gsdl3_home = "";
    12 
    13     public GSEntityResolver(String gsdl3_home) {
    14     this.gsdl3_home = gsdl3_home;
    15     }
    16    
     12    //public GSEntityResolver() {
     13    ///ystem.out.println("creating entity resolver");
     14    //}
    1715    public InputSource resolveEntity (String public_id, String system_id) {
    18 
     16   
     17    System.out.println("entity resolver for "+system_id);
    1918    if (system_id.endsWith(".dtd") && system_id.indexOf("jakarta")!=-1) {
    2019        int index = system_id.lastIndexOf(File.separatorChar);
    2120        if (index != -1) {
    2221        system_id = system_id.substring(index+1);
     22       
    2323        }
     24    } else if (system_id.endsWith(".dtd") && system_id.indexOf(File.separatorChar)==-1) {
    2425       
    25         // a local ref
    26         system_id = GSFile.dtdDir(gsdl3_home)+File.separatorChar+system_id;
    27         return new InputSource(system_id);
    28     } else if (system_id.endsWith(".dtd") && system_id.indexOf(File.separatorChar)==-1) {
    29         system_id = "file://"+GSFile.dtdDir(gsdl3_home)+File.separatorChar+system_id;
    30         return new InputSource(system_id);
    31        
    32     }
    33     return null; // leave it up to teh thing itself
    34        
     26    } else {
     27        return null;
     28    }
     29    System.out.println("using class loader for "+system_id);
     30    URL url = ClassLoader.getSystemResource(system_id);
     31    if (url == null) {
     32        System.out.println("class loader didn't find it");
     33        return null;
     34    }
     35    return new InputSource("file://"+url.getFile());
    3536    }
    3637}
Note: See TracChangeset for help on using the changeset viewer.