Last change
on this file since 5700 was 5434, checked in by kjdon, 21 years ago |
* empty log message *
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.0 KB
|
Line | |
---|
1 | package org.greenstone.gsdl3.util;
|
---|
2 |
|
---|
3 |
|
---|
4 | import org.xml.sax.InputSource;
|
---|
5 | import org.xml.sax.EntityResolver;
|
---|
6 | import java.io.File;
|
---|
7 |
|
---|
8 | // maybe use class loader to find dtds etc????
|
---|
9 | public class GSEntityResolver implements EntityResolver {
|
---|
10 |
|
---|
11 | protected String gsdl3_home = "";
|
---|
12 |
|
---|
13 | public GSEntityResolver(String gsdl3_home) {
|
---|
14 | this.gsdl3_home = gsdl3_home;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public InputSource resolveEntity (String public_id, String system_id) {
|
---|
18 |
|
---|
19 | if (system_id.endsWith(".dtd") && system_id.indexOf("jakarta")!=-1) {
|
---|
20 | int index = system_id.lastIndexOf(File.separatorChar);
|
---|
21 | if (index != -1) {
|
---|
22 | system_id = system_id.substring(index+1);
|
---|
23 | }
|
---|
24 |
|
---|
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 |
|
---|
35 | }
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.