01: package org.enhydra.server.util;
02:
03: import java.io.InputStream;
04:
05: import org.xml.sax.InputSource;
06: import org.xml.sax.SAXException;
07: import org.xml.sax.helpers.DefaultHandler;
08:
09: /**
10: * <p>Title: </p>
11: * <p>Description: </p>
12: * <p>Copyright: Copyright (c) 2002</p>
13: * <p>Company: </p>
14: * @author tweety
15: * @version 1.0
16: */
17:
18: //public class WebXMLEntityResolver implements EntityResolver {
19: public class WebXMLEntityResolver extends DefaultHandler {
20:
21: private static final String WebDtdPublicId_23 = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
22: private static final String WebDtdResourcePath_23 = "/javax/servlet/resources/web-app_2_3.dtd";
23:
24: public WebXMLEntityResolver() {
25: }
26:
27: public InputSource resolveEntity(String publicId, String systemId)
28: throws SAXException/*, IOException */{
29: if (publicId.equals(WebDtdPublicId_23)) {
30: //Get dtd from servlet.jar
31: InputStream dtdStream = this .getClass()
32: .getResourceAsStream(WebDtdResourcePath_23);
33:
34: // int count = dtdStream.available();
35: // System.out.println(count);
36: // byte[] chars = new byte[count];
37: // count = dtdStream.read(chars);
38: // System.out.println(count);
39:
40: // FileOutputStream fo = new FileOutputStream("C:/Temp/a.txt");
41: // fo.write(chars);
42: // fo.flush();
43: // fo.close();
44:
45: return new InputSource(dtdStream);
46: //return null;
47: } else {
48: // use the default behaviour
49: return null;
50: }
51: }
52: }
|