Changeset 5962
- Timestamp:
- 2003-11-25T11:43:32+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSEntityResolver.java
r5434 r5962 5 5 import org.xml.sax.EntityResolver; 6 6 import java.io.File; 7 import java.net.URL; 7 8 8 // maybe use class loader to find dtds etc????9 // uses a class loader to find entities 9 10 public class GSEntityResolver implements EntityResolver { 10 11 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 //} 17 15 public InputSource resolveEntity (String public_id, String system_id) { 18 16 17 System.out.println("entity resolver for "+system_id); 19 18 if (system_id.endsWith(".dtd") && system_id.indexOf("jakarta")!=-1) { 20 19 int index = system_id.lastIndexOf(File.separatorChar); 21 20 if (index != -1) { 22 21 system_id = system_id.substring(index+1); 22 23 23 } 24 } else if (system_id.endsWith(".dtd") && system_id.indexOf(File.separatorChar)==-1) { 24 25 25 // a local ref26 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 itself34 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()); 35 36 } 36 37 }
Note:
See TracChangeset
for help on using the changeset viewer.