comparison src/de/mpiwg/dwinter/fulltextIndexer/harvester/MyResolver.java @ 0:dc7622afcfea default tip

initial
author dwinter
date Wed, 03 Nov 2010 12:33:16 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:dc7622afcfea
1 package de.mpiwg.dwinter.fulltextIndexer.harvester;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.io.InputStream;
6
7 import org.xml.sax.EntityResolver;
8 import org.xml.sax.InputSource;
9 import org.xml.sax.SAXException;
10
11 public class MyResolver implements EntityResolver {
12
13 public InputSource resolveEntity(String publicId, String systemId)
14 throws SAXException, IOException {
15 // TODO Auto-generated method stub
16 // System.out.println("public:"+publicId);
17 // System.out.println("static"+systemId);
18 //File f = new File(
19 // "/Users/dwinter/Documents/Projekte/data-mining/developmentEclipse/fulltextIndexer/catalog/xhtml1-transitional.dtd");
20
21
22 //if (!f.exists()) {
23 // System.err.println("Cant't find xhtml-dtd: MyResolver");
24 // return null;
25 //}
26 //if (publicId.equals("-//W3C//DTD XHTML 1.0 Transitional//EN"))
27 // return new InputSource(f.getAbsolutePath());
28
29 if (publicId.equals("-//W3C//DTD XHTML 1.0 Transitional//EN")){
30 InputStream res = getClass().getResourceAsStream("/de/mpiwg/dwinter/fulltextIndexer/catalog/xhtml1-transitional.dtd");
31 return new InputSource(res);
32 } else if (publicId.equals("-//W3C//ENTITIES Latin 1 for XHTML//EN")){
33 InputStream res = getClass().getResourceAsStream("/de/mpiwg/dwinter/fulltextIndexer/catalog/xhtml-lat1.ent");
34 return new InputSource(res);
35 } else if (publicId.equals("-//W3C//ENTITIES Symbols for XHTML//EN")){
36 InputStream res = getClass().getResourceAsStream("/de/mpiwg/dwinter/fulltextIndexer/catalog/xhtml-symbol.ent");
37 return new InputSource(res);
38 } else if (publicId.equals("-//W3C//ENTITIES Special for XHTML//EN")){
39 InputStream res = getClass().getResourceAsStream("/de/mpiwg/dwinter/fulltextIndexer/catalog/xhtml-special.ent");
40 return new InputSource(res);
41 }
42 return new InputSource(systemId);
43 }
44
45 }