Shelly, In the main method below you have a CFXMLResolver class static method. Can you send the implementation to this please
Thanks -----Original Message----- From: Mujtaba,Shelly [mailto:[EMAIL PROTECTED]] Sent: 15 October 2002 18:36 To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Using a different DTD One way is to create your own EntityResolver which will override the dtd reference with another registered reference, and pass this entity resolver to the Mapping Object while loading the mapping. Here's an example of an entity resolver which will load the dtd from the classpath. import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; public class CfClasspathEntityResolver implements EntityResolver{ private static final CfClasspathEntityResolver THIS=new CfClasspathEntityResolver(); private Map dtdMap; /** * constructor made private to * enforce singleton */ private CfClasspathEntityResolver(){ dtdMap=new HashMap(); registerDefaultReferences(); } /** * register the defaults dtd references here * for key use the public id and for the value use * the classpath relative location */ private void registerDefaultReferences(){ } /** * register a new entity reference * for key use the public id and for the value use * the classpath relative location */ public void registerReference(String publicId, String location){ dtdMap.put(publicId,location); } /** * implement resolve entity method from super class */ public InputSource resolveEntity(String publicId, String systemId){ String dtdURL = null; if (publicId != null){ //find the registered dtd url dtdURL = (String) dtdMap.get(publicId); } if (dtdURL == null) { return null; } InputStream stream=this.getClass().getClassLoader().getResourceAsStream(dtdURL); return (new InputSource(stream)); } public static CfClasspathEntityResolver getInstance(){ return THIS; } /////////////////////////////example usage///////////////////////////// public static void main(String args[])throws Exception{ CfClasspathEntityResolver resolve=CfClasspathEntityResolver.getInstance(); resolve.registerReference("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", "web-app_2_2.dtd"); Document doc=CfXMLHelper.getDocumentFromFile("C:\\WSAD\\workspace\\WarrantyTestWeb\\w ebApplication\\WEB-INF\\web.xml",resolve,true); System.out.println(CfXMLHelper.getStringFromDocument(doc)); } } -----Original Message----- From: Shoukat, Faisal [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 15, 2002 12:13 PM To: [EMAIL PROTECTED] Subject: [castor-dev] Using a different DTD Hi, Does anyone know how to reference the DTD within the docType tag of the mapping.xml file from within a jar. for example: the mapping xml file references the following dtd file:///D:/castor/castor-0.9.3.21/castor-0.9.3.21/doc/mapping.dtd . However I am planning on deploying this to an application server and other people will want to use this mapping.xml They will not neccessarily have this dtd in the same location as mine. Thus is it possible to put this mapping.dtd within the jar file which is deployed onto the application server. How would I reference the dtd if it was within the same jar file as the mapping.xml file? All helpis greatly apprecited Thanks Faisal ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
