KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > server > util > WebXMLEntityResolver


1 package org.enhydra.server.util;
2
3 import java.io.InputStream JavaDoc;
4
5 import org.xml.sax.InputSource JavaDoc;
6 import org.xml.sax.SAXException JavaDoc;
7 import org.xml.sax.helpers.DefaultHandler JavaDoc;
8
9 /**
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 JavaDoc {
20
21     private final String JavaDoc WebDtdPublicId_23 =
22             "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
23     private final String JavaDoc WebDtdResourcePath_23 =
24             "/javax/servlet/resources/web-app_2_3.dtd";
25
26     public WebXMLEntityResolver() {
27     }
28
29     public InputSource JavaDoc resolveEntity(String JavaDoc publicId, String JavaDoc systemId) throws SAXException JavaDoc/*, IOException */{
30         if (publicId.equals(WebDtdPublicId_23)) {
31             //Get dtd from servlet.jar
32
InputStream JavaDoc dtdStream = this.getClass().getResourceAsStream(WebDtdResourcePath_23);
33
34
35 // int count = dtdStream.available();
36
// System.out.println(count);
37
// byte[] chars = new byte[count];
38
// count = dtdStream.read(chars);
39
// System.out.println(count);
40

41 // FileOutputStream fo = new FileOutputStream("C:/Temp/a.txt");
42
// fo.write(chars);
43
// fo.flush();
44
// fo.close();
45

46             return new InputSource JavaDoc(dtdStream);
47             //return null;
48
} else {
49             // use the default behaviour
50
return null;
51         }
52     }
53 }
Popular Tags