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 19:37:19 GMT
You're absolutely right, this wouldn't work without a DOCTYPE
declaration.  However, it wouldn't matter what the contents of that
declaration were.  (The user could modify to his hearts content
and still have the document validated against the same DTD.

-AMT

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


Would something like this work even in the absence of a <DOCTYPE>
declaration at all in the file being parsed?  I thought that this was the
only time resolveEntity() was called.

Craig


On Tue, 13 Nov 2001, Arun M. Thomas wrote:

> Date: Tue, 13 Nov 2001 10:20:42 -0800
> From: Arun M. Thomas <AMammenT@yahoo.com>
> Reply-To: Jakarta Commons Developers List <commons-dev@jakarta.apache.org>
> To: Jakarta Commons Developers List <commons-dev@jakarta.apache.org>
> Subject: RE: [digester] forcing a specific DTD
>
> 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
>


--
To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message