KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > xpdl > XPDLEntityResolver


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

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