Hello,

We solved the problem of DTD file path using a class which implements
EntityResolver 
<!DOCTYPE toto SYSTEM "/castorPath/toto.dtd" .

But now, we want to do the same thing (dynamicaly resolving the path)
for ENTITY.
<!DOCTYPE toto SYSTEM "/castorPath/toto.dtd"
[
        <!ENTITY toto SYSTEM "/castorPath/toto.xml"
        <!ENTITY tata SYSTEM "/castorPath/tata.xml"]
]
>

But it doesn't seem to work.

In the SAX documentation, we have found this :

>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public interface EntityResolver

Basic interface for resolving entities. 

If a SAX application needs to implement customized handling for external
entities, it must implement this interface and register an instance with
the SAX driver using the setEntityResolver method.

The XML reader will then allow the application to intercept any external
entities (including the external DTD subset and external parameter
entities, if any) before including them.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Does the word "entities" covers DOCTYPE AND ENTITY ?

Has some body an idea ?

Sylvie.

___________________
CREDI RA
Sylvie Palluel

[EMAIL PROTECTED]
___________________



> -----Message d'origine-----
> De : PALLUEL Sylvie [mailto:[EMAIL PROTECTED] 
> Envoy� : mardi 29 juillet 2003 10:56
> � : [EMAIL PROTECTED]
> Objet : [castor-dev] Using a different DTD
> 
> 
> Hello,
> I have a problem with resolving DTD file path in XML files.
> I have seen this message below in the archives, and I'ld like 
> to know if you solved your problem? I don't have found  the 
> CfXMLHelper class. If you have it - and other information you 
> think I could need, could you to send it to me ?
> 
> Sylvie.
> 
> 
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>
> *     From: Shoukat, Faisal 
> *     Subject: Re: [castor-dev] Using a different DTD 
> *     Date: Wed, 16 Oct 2002 05:45:27 -0700 
> 
> 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\\Warr
> antyTestWe
> b\\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



___________________
CREDI RA
Sylvie Palluel
 
[EMAIL PROTECTED]
___________________





**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev




**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to