01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.dp.xml;
06:
07: import java.io.StringReader;
08:
09: import org.xml.sax.InputSource;
10: import org.xml.sax.helpers.DefaultHandler;
11: import com.sun.portal.desktop.util.Resource;
12:
13: /**
14: * This is a custom XML handler to load the dtds from the classpath.
15: * This should be used by all the xml parsing document builders to
16: * set the default entity resolvers.
17: * Specify the dtds as follows
18: * jar://resources/psdp.dtd
19: */
20:
21: public class XMLDPEntityResolver extends DefaultHandler {
22:
23: public InputSource resolveEntity(String aPublicID, String aSystemID) {
24:
25: String sysid = aSystemID.trim();
26:
27: if (sysid.toLowerCase().startsWith("jar://")) {
28: String dtdname = sysid.substring(5);
29: String dtdValue = Resource.read(dtdname).trim();
30: return new InputSource(new StringReader(dtdValue));
31: }
32: return null;
33: }
34:
35: }
|