commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arun M. Thomas" <AMamm...@yahoo.com>
Subject RE: [digester] forcing a specific DTD
Date Tue, 13 Nov 2001 18:20:42 GMT
Craig,

Despite my previous response to TAL, it should be possible to do this
by instantiating the SAXParser with a subclass of DefaultHandler which
overrides the resolveEntity method.  I had to do exactly this in the
last application on which I worked using the JAXP1.0 API.  In that
case, we provided a custom implementation of EntityResolver which
always returned an INPUT source to the same dtd.  It appears the JAXP1.1
has hidden the EntityResolver under the DefaultHandler class, so providing
an implementation of that method which is customized to return a specific
dtd should suffice.

In the Digester case, it means a potentially simple modification to the
resolveEntity method of Digester (which is a DefaultHandler).  I've
included a diff of a quick patch below as a suggestion, and attached a copy
of the modified version of digester.

Cheers,
-AMT

cvs diff Digester.java (in directory
C:\Dev\jakarta-commons\digester\src\java\org\apache\commons\digester\)
Index: Digester.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/digester/src/java/org/apache/commons/digeste
r/Digester.java,v
retrieving revision 1.23
diff -r1.23 Digester.java
161c161,171
<
---
> 		/**
> 		 * Works only in a JAXP1.1 world, but allows the user to supply a fixed
URL against
> 		 * which all documents will be validated.  The supplied parameter will
be used by
> 		 * the {@link #resolveEntity(String, String)} method.
> 		 */
> 		public Digester(String fixedDTDUrl) {
> 			super();
>
> 			this.fixedDTDUrl = fixedDTDUrl;
> 		}
>
313a324,328
> 		/**
> 		 * URL which may be supplied against which all documents should be
> 		 * validated regardless of the public and system identifiers.
> 		 */
> 		private String fixedDTDUrl = null;
1042a1058,1060
> 	if (fixedDTDUrl != null)
> 		dtdURL = fixedDTDUrl;
>

-----Original Message-----
From: craigmcc@localhost [mailto:craigmcc@localhost]On Behalf Of Craig
R. McClanahan
Sent: Tuesday, November 13, 2001 9:30 AM
To: Jakarta Commons Developers List
Subject: Re: [digester] forcing a specific DTD

...

This sounds like it might be an interesting idea, but I don't know how to
implement it :-(.  Digester uses a SAX parser via the JAXP/1.1 APIs
underneath the covers.  How do you tell the parser to use an arbitrary DTD
instead of whatever is specified in the document being parsed?

Craig

Mime
View raw message