----- Original Message -----
Sent: Monday, June 16, 2003 12:23
PM
Subject: Re: [cinjug-users] DTD path
problem.
Edward Sumerfield wrote:
To avoid net requests during XML parser loads I
have changed all the DTD paths to local files with a little ant task to
replace the "DOCROOT" with the expected deployment directory. This allows me
to configure the deployment directory at build time so each developer can
drive their own deployment with their own build.properties
file.
Except, the SunOne App Server changes the
deploy directory each time the product is deployed, putting the docroot into
a numbered directory that changes so there no way to know the directory
prior to deployment.
Anyone have any strategies to accomplish net
independence and install directory isolation at the same
time?
Here are three ideas; some of these may be more
palatable than others. :)
- Leave out the <!DOCTYPE> declaration. Everything should
continue to work correctly, although if you're using a DTD-aware XML editor,
you may lose some content assistance.
- Install your own SAX EntityResolver
in whatever SAX parser you're using in order to replace the particular
public ID (e.g. "-//Apache Software Foundation//DTD Struts Configuration
1.1//EN") with an InputSource
of your choice. You could read the DTD out of a jar via
getClass().getResourceAsStream() and wrap that in an InputSource.
Unfortunately, you may not have access to the SAX parser that's reading the
config file...but then again, you may. (By the way, I think Log4J uses
this technique, if you need an example.)
- Use some sort of fake URL, like that supplied by the project at http://rachel.sourceforge.net/, to
read your DTD out of your jar.
Hope that helps!
- Eric