KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > XPDLEntityResolver


1 package org.enhydra.jawe.xml;
2
3 import org.xml.sax.EntityResolver JavaDoc;
4 import org.xml.sax.InputSource JavaDoc;
5
6 import java.io.*;
7
8 /**
9  * Replaces the internet location of the XPDL1.0 schema, with its content read
10  * from resources.
11  */

12 public class XPDLEntityResolver implements EntityResolver JavaDoc {
13
14    public static final String JavaDoc XPDL_SCHEMA = "org/enhydra/jawe/resources/TC-1025_schema_10_xpdl.xsd";
15
16    public InputSource JavaDoc resolveEntity (String JavaDoc publicId,String JavaDoc systemId) {
17 //System.out.println("pId="+publicId+", sId="+systemId);
18
if (systemId!=null) {
19          return getSchemaInputSource();
20       } else {
21          // use the default behaviour
22
return null;
23       }
24    }
25
26    public static InputSource JavaDoc getSchemaInputSource () {
27       InputStream is=null;
28       try {
29          java.net.URL JavaDoc u=
30                XPDLEntityResolver.class.getClassLoader().getResource(XPDL_SCHEMA);
31          is=(InputStream)u.getContent();
32          return new InputSource JavaDoc(is);
33       } catch (Exception JavaDoc ex) {
34          return null;
35       }
36    }
37 }
38
39
Popular Tags