01: package org.enhydra.shark.xpdl;
02:
03: import java.io.InputStream;
04:
05: import org.xml.sax.EntityResolver;
06: import org.xml.sax.InputSource;
07:
08: /**
09: * Replaces the internet location of the XPDL1.0 schema, with its content read
10: * from resources.
11: *
12: * @author Sasa Bojanic
13: */
14: public class XPDLEntityResolver implements EntityResolver {
15:
16: public static final String XPDL_SCHEMA = "org/enhydra/shark/xpdl/resources/TC-1025_schema_10_xpdl.xsd";
17:
18: public InputSource resolveEntity(String publicId, String systemId) {
19: //System.out.println("pId="+publicId+", sId="+systemId);
20: if (systemId != null) {
21: return getSchemaInputSource();
22: }
23:
24: // use the default behaviour
25: return null;
26: }
27:
28: public static InputSource getSchemaInputSource() {
29: InputStream is = null;
30: try {
31: java.net.URL u = XPDLEntityResolver.class.getClassLoader()
32: .getResource(XPDL_SCHEMA);
33: is = (InputStream) u.getContent();
34: return new InputSource(is);
35: } catch (Exception ex) {
36: return null;
37: }
38: }
39: }
|