You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Tal Dayan <ta...@zapta.com> on 2001/11/13 18:04:43 UTC
[digester] forcing a specific DTD
We plan to use Digester for parsing XML based configuration files and would
like
to use a DTD to save some validation code. From the Digester documentation
it seems that the DTD based validation works as follows, the user specifies
an arbitrary DTD, and digester.parse() makes sure the XML document matches
the user's specified DTD.
We have two problems with this approach:
1. When we parse a file, we know what DTD it should conform to so there is
not need require the user to type it (e.g. when Tomcat reads server.xml, the
user does not care about the DTD, it should be up to Tomcat to do the magic
of validating it).
2. The user can specify arbitrary DTD but we want to validate against a
*specific* DTD. It does not help us much if we know that the XML conforms to
some arbitrary DTD the user specified (this reminds me an old joke, a man is
asked by the bank manager to identify himself, he pull a picture of from his
pocket and says 'that's me').
Any idea how to address these issues ?
A good solution would be example a digester.forceSpecificDTD(...) method
that forces a specific DTD for that instance of the parser. This makes sense
since the digester is configured anyway (via the set of rules) to parse a
specific type of XML document.
Thanks,
Tal
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] forcing a specific DTD
Posted by Jeff Turner <je...@socialchange.net.au>.
On Tue, Nov 13, 2001 at 11:57:46PM -0800, Tal Dayan wrote:
> Hi Jeff,
>
> It worked as advertised in first try.
Glad you found it useful. Fudging doctypes is not exactly an elegant
solution, but in the real world it's unfortunately necessary, at least
until XML schemas take over the world ("NOoo..!!";)
> The API looks very flexible (e.g. generating a DOCTYPE based on the original
> one) and it generated
> the correct DOCTYPE in all cases I tried (with and without <? xml ... ?>,
> with and without original
> DOCTYPE, etc).
>
> It seems like a very good workaround for the DTD enforcing issue and if the
> license permits, we would like to use it.
The original code was released under the MPL 1.1, which I *think* is
APL-compatible, and which I guess is changeable to APL anyway if it's
"non-viral"? I hate licenses..
--Jeff
> Thanks,
>
> Tal
>
> > -----Original Message-----
> > From: Jeff Turner [mailto:jeff@socialchange.net.au]
> > Sent: Tuesday, November 13, 2001 6:46 PM
> > To: Jakarta Commons Developers List
> > Subject: Re: [digester] forcing a specific DTD
> >
> >
> > You can use this utility to force a specific doctype:
> >
> > http://newgate.socialchange.net.au/~jeff/doctypechanger/
> >
> > I posted this on Nov 5:
> >
> > http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=100491227030900&w=2
> >
> >
> > --Jeff
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] forcing a specific DTD
Posted by Jeff Turner <je...@socialchange.net.au>.
On Wed, Nov 14, 2001 at 07:37:05PM -0800, Tal Dayan wrote:
> Hi Jeff,
>
> Have you considered to open for it a SourceForge project ? I think it is
> free and you get CVS, webspace, shell access for builds, etc.
This isn't the kind of code that gets a *developer* community, because it is
mostly finished (much like BCEL). The API has been through 3 rewrites, and now
allows you to do _anything_ to the DOCTYPE declaration. There's no features to
add, without expanding the scope of the project.
All it can do now is amass lots of users :) I have yet to "announce" it
anywhere except here, and in passing on xml-general@xml.apache.org. It would be
nice if (hint hint) any of the committers would comment on hosting it in
jakarta-commons. Otherwise, it's happy where it is :)
--Jeff
> Tal
>
> > -----Original Message-----
> > From: Jeff Turner [mailto:jeff@socialchange.net.au]
> > Sent: Wednesday, November 14, 2001 4:20 PM
> > To: Jakarta Commons Developers List
> > Subject: Re: [digester] forcing a specific DTD
> >
> >
> > On Wed, Nov 14, 2001 at 11:34:57AM -0800, Tal Dayan wrote:
> > > Yes, I think Jeff mentioned that he tried to contribute it.
> >
> > Yep.
> >
> > > This code addresses a real issue with the exiting API of SAX and it will
> > > be great if we can find for it a good home so it is get maintained and
> > > others can use it as well.
> >
> > I recently got a friendly sysadmin to set up a more permanent
> > domain, and the
> > code can now be obtained at:
> >
> > http://opensource.socialchange.net.au/doctypechanger/
> >
> > The old URL redirects to this.
> >
> > > Ideally, this should be fixed by SAX (API change).
> > >
> > > Jeff, have you considered to submit it to the Sax project
> > > http://sourceforge.net/projects/sax/ ? Or, how about creating
> > for it, for
> > > the time being, a project by itself at SourceForge ?
> >
> > SAX and DOM specify mainly the post-parse API. JAXP might be more
> > appropriate..
> > a "forceValidation(URL dtd);" method or something.
> >
> >
> > --Jeff
> >
> > > Tal
> >
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
Hi Jeff,
Have you considered to open for it a SourceForge project ? I think it is
free and you get
CVS, webspace, shell access for builds, etc.
Tal
> -----Original Message-----
> From: Jeff Turner [mailto:jeff@socialchange.net.au]
> Sent: Wednesday, November 14, 2001 4:20 PM
> To: Jakarta Commons Developers List
> Subject: Re: [digester] forcing a specific DTD
>
>
> On Wed, Nov 14, 2001 at 11:34:57AM -0800, Tal Dayan wrote:
> > Yes, I think Jeff mentioned that he tried to contribute it.
>
> Yep.
>
> > This code addresses a real issue with the exiting API of SAX and it will
> > be great if we can find for it a good home so it is get maintained and
> > others can use it as well.
>
> I recently got a friendly sysadmin to set up a more permanent
> domain, and the
> code can now be obtained at:
>
> http://opensource.socialchange.net.au/doctypechanger/
>
> The old URL redirects to this.
>
> > Ideally, this should be fixed by SAX (API change).
> >
> > Jeff, have you considered to submit it to the Sax project
> > http://sourceforge.net/projects/sax/ ? Or, how about creating
> for it, for
> > the time being, a project by itself at SourceForge ?
>
> SAX and DOM specify mainly the post-parse API. JAXP might be more
> appropriate..
> a "forceValidation(URL dtd);" method or something.
>
>
> --Jeff
>
> > Tal
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] forcing a specific DTD
Posted by Jeff Turner <je...@socialchange.net.au>.
On Wed, Nov 14, 2001 at 11:34:57AM -0800, Tal Dayan wrote:
> Yes, I think Jeff mentioned that he tried to contribute it.
Yep.
> This code addresses a real issue with the exiting API of SAX and it will
> be great if we can find for it a good home so it is get maintained and
> others can use it as well.
I recently got a friendly sysadmin to set up a more permanent domain, and the
code can now be obtained at:
http://opensource.socialchange.net.au/doctypechanger/
The old URL redirects to this.
> Ideally, this should be fixed by SAX (API change).
>
> Jeff, have you considered to submit it to the Sax project
> http://sourceforge.net/projects/sax/ ? Or, how about creating for it, for
> the time being, a project by itself at SourceForge ?
SAX and DOM specify mainly the post-parse API. JAXP might be more appropriate..
a "forceValidation(URL dtd);" method or something.
--Jeff
> Tal
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
Yes, I think Jeff mentioned that he tried to contribute it.
This code addresses a real issue with the exiting API of SAX and it will
be great if we can find for it a good home so it is get maintained and
others can use it as well.
Ideally, this should be fixed by SAX (API change).
Jeff, have you considered to submit it to the Sax project
http://sourceforge.net/projects/sax/ ? Or, how about creating for it, for
the time being, a project by itself at SourceForge ?
Tal
> -----Original Message-----
> From: robert burrell donkin [mailto:robertdonkin@mac.com]
> Sent: Wednesday, November 14, 2001 10:49 AM
> To: Jakarta Commons Developers List
> Subject: Re: [digester] forcing a specific DTD
>
>
>
> On Wednesday, November 14, 2001, at 05:49 PM, Tal Dayan wrote:
>
> > I am not sure. It is very long and I am not a lawyer ;-)
> >
> > One way to convert it to ASL is to ask for the permissions of the
> > authors. This is how Lucene became a Jakarta project, it used to
> > be GPL.
>
> is this the code that jeff offered to donate to the commons earlier this
> month?
> (check the archives 'Subject: Submission: XML DOCTYPE manipulation code')
>
> is that right, jeff?
>
> as i understand it (i'm sure somebody will correct me if i'm wrong),
> the sandbox is for projects with proposals and so a class can't be
> committed by itself.
> maybe if stuff like EntityResolvers and other xml utility classes from
> other jakarta projects were also thrown into the mix, it might be
> possible
> to come up with a viable proposal for a project consisting of xml tools.
>
> - robert
>
> >
> > Tal
> >
> >> -----Original Message-----
> >> From: Jeff Turner [mailto:jeff@socialchange.net.au]
> >> Sent: Tuesday, November 13, 2001 9:02 PM
> >> To: Tal Dayan
> >> Cc: Jakarta Commons Developers List
> >> Subject: Re: [digester] forcing a specific DTD
> >>
> >>
> >> On Tue, Nov 13, 2001 at 07:59:47PM -0800, Tal Dayan wrote:
> >>> This looks great. I will give it a try and will report here.
> >>>
> >>> I presume that the license is ASF. Is it so ?
> >>
> >> The license of the original code is MPL, which I presume is
> >> ASL-compatible..?
> >>
> >> --Jeff
> >>
> >> --
> >> To unsubscribe, e-mail:
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail:
> >> <ma...@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>
>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] forcing a specific DTD
Posted by robert burrell donkin <ro...@mac.com>.
On Wednesday, November 14, 2001, at 05:49 PM, Tal Dayan wrote:
> I am not sure. It is very long and I am not a lawyer ;-)
>
> One way to convert it to ASL is to ask for the permissions of the
> authors. This is how Lucene became a Jakarta project, it used to
> be GPL.
is this the code that jeff offered to donate to the commons earlier this
month?
(check the archives 'Subject: Submission: XML DOCTYPE manipulation code')
is that right, jeff?
as i understand it (i'm sure somebody will correct me if i'm wrong),
the sandbox is for projects with proposals and so a class can't be
committed by itself.
maybe if stuff like EntityResolvers and other xml utility classes from
other jakarta projects were also thrown into the mix, it might be possible
to come up with a viable proposal for a project consisting of xml tools.
- robert
>
> Tal
>
>> -----Original Message-----
>> From: Jeff Turner [mailto:jeff@socialchange.net.au]
>> Sent: Tuesday, November 13, 2001 9:02 PM
>> To: Tal Dayan
>> Cc: Jakarta Commons Developers List
>> Subject: Re: [digester] forcing a specific DTD
>>
>>
>> On Tue, Nov 13, 2001 at 07:59:47PM -0800, Tal Dayan wrote:
>>> This looks great. I will give it a try and will report here.
>>>
>>> I presume that the license is ASF. Is it so ?
>>
>> The license of the original code is MPL, which I presume is
>> ASL-compatible..?
>>
>> --Jeff
>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@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>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
I am not a lawyer either but possibly it can be view as follows:
1. The authors have the original copyright.
2. By contributing the code to a GPL project, the authors are allowing
others to use
their pieces of code under the GPL license.
3. The authors can also release their code under other licenses.
Because of the dependency between the contributions of the various authors
(e.g. applying a patch to an existing code), you probably need *all* the
authors to agree to release the code *also* under a different license. Of
course, you can not revoke the old license but it will apply only to the old
code.
This is just a layman point of view.
Tal
> -----Original Message-----
> From: Michael Gerdau [mailto:mgd@technosis.de]
> Sent: Wednesday, November 14, 2001 11:05 AM
> To: Jakarta Commons Developers List
> Subject: RE: [digester] forcing a specific DTD
>
>
> >I am not sure. It is very long and I am not a lawyer ;-)
> >
> >One way to convert it to ASL is to ask for the permissions of the
> >authors. This is how Lucene became a Jakarta project, it used to
> >be GPL.
>
> I'm no lawyer either. But one of the most prominent properties of
> the GPL (at least to my understanding) is its "stickyness". Once some
> code is GPL'd you can't take away that property no matter what you
> do.
>
> If I recall it right this was one of the driving forces to create the
> GPL the way it is.
>
> Best,
> Michael
> --
> Vote against SPAM - see http://www.politik-digital.de/spam/
> Michael Gerdau email: mgd@technosis.de
> Win9x? For fast relief call 800-3-IBM-OS2.
> PGP-keys available on request or at public keyserver
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Michael Gerdau <mg...@technosis.de>.
>I am not sure. It is very long and I am not a lawyer ;-)
>
>One way to convert it to ASL is to ask for the permissions of the
>authors. This is how Lucene became a Jakarta project, it used to
>be GPL.
I'm no lawyer either. But one of the most prominent properties of
the GPL (at least to my understanding) is its "stickyness". Once some
code is GPL'd you can't take away that property no matter what you
do.
If I recall it right this was one of the driving forces to create the
GPL the way it is.
Best,
Michael
--
Vote against SPAM - see http://www.politik-digital.de/spam/
Michael Gerdau email: mgd@technosis.de
Win9x? For fast relief call 800-3-IBM-OS2.
PGP-keys available on request or at public keyserver
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
I am not sure. It is very long and I am not a lawyer ;-)
One way to convert it to ASL is to ask for the permissions of the
authors. This is how Lucene became a Jakarta project, it used to
be GPL.
Tal
> -----Original Message-----
> From: Jeff Turner [mailto:jeff@socialchange.net.au]
> Sent: Tuesday, November 13, 2001 9:02 PM
> To: Tal Dayan
> Cc: Jakarta Commons Developers List
> Subject: Re: [digester] forcing a specific DTD
>
>
> On Tue, Nov 13, 2001 at 07:59:47PM -0800, Tal Dayan wrote:
> > This looks great. I will give it a try and will report here.
> >
> > I presume that the license is ASF. Is it so ?
>
> The license of the original code is MPL, which I presume is
> ASL-compatible..?
>
> --Jeff
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
What is MPL ?
Hope not Microsoft Proprietary License ;-)
Tal
> -----Original Message-----
> From: Jeff Turner [mailto:jeff@socialchange.net.au]
> Sent: Tuesday, November 13, 2001 9:02 PM
> To: Tal Dayan
> Cc: Jakarta Commons Developers List
> Subject: Re: [digester] forcing a specific DTD
>
>
> On Tue, Nov 13, 2001 at 07:59:47PM -0800, Tal Dayan wrote:
> > This looks great. I will give it a try and will report here.
> >
> > I presume that the license is ASF. Is it so ?
>
> The license of the original code is MPL, which I presume is
> ASL-compatible..?
>
> --Jeff
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] forcing a specific DTD
Posted by Jeff Turner <je...@socialchange.net.au>.
On Tue, Nov 13, 2001 at 07:59:47PM -0800, Tal Dayan wrote:
> This looks great. I will give it a try and will report here.
>
> I presume that the license is ASF. Is it so ?
The license of the original code is MPL, which I presume is ASL-compatible..?
--Jeff
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
Hi Jeff,
It worked as advertised in first try.
The API looks very flexible (e.g. generating a DOCTYPE based on the original
one) and it generated
the correct DOCTYPE in all cases I tried (with and without <? xml ... ?>,
with and without original
DOCTYPE, etc).
It seems like a very good workaround for the DTD enforcing issue and if the
license permits, we would like to use it. We have a wrapper class for the
Digester class so we just added to its constructor two new parameters, one
for the name of the root element and one for the URL of the DTD and now our
DTD is enforced in all cases and with minimum effort.
The only problem we have now is that when a DTD violation is detected in the
XML document, all we get is a log printout but the application is not aware
of the validation error and cannot for example throw and exception.
Thanks,
Tal
> -----Original Message-----
> From: Jeff Turner [mailto:jeff@socialchange.net.au]
> Sent: Tuesday, November 13, 2001 6:46 PM
> To: Jakarta Commons Developers List
> Subject: Re: [digester] forcing a specific DTD
>
>
> You can use this utility to force a specific doctype:
>
> http://newgate.socialchange.net.au/~jeff/doctypechanger/
>
> I posted this on Nov 5:
>
> http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=100491227030900&w=2
>
>
> --Jeff
>
> On Tue, Nov 13, 2001 at 09:04:43AM -0800, Tal Dayan wrote:
> >
> > We plan to use Digester for parsing XML based configuration
> files and would
> > like
> > to use a DTD to save some validation code. From the Digester
> documentation
> > it seems that the DTD based validation works as follows, the
> user specifies
> > an arbitrary DTD, and digester.parse() makes sure the XML
> document matches
> > the user's specified DTD.
> >
> > We have two problems with this approach:
> >
> > 1. When we parse a file, we know what DTD it should conform to
> so there is
> > not need require the user to type it (e.g. when Tomcat reads
> server.xml, the
> > user does not care about the DTD, it should be up to Tomcat to
> do the magic
> > of validating it).
> >
> > 2. The user can specify arbitrary DTD but we want to validate against a
> > *specific* DTD. It does not help us much if we know that the
> XML conforms to
> > some arbitrary DTD the user specified (this reminds me an old
> joke, a man is
> > asked by the bank manager to identify himself, he pull a
> picture of from his
> > pocket and says 'that's me').
> >
> > Any idea how to address these issues ?
> >
> > A good solution would be example a digester.forceSpecificDTD(...) method
> > that forces a specific DTD for that instance of the parser.
> This makes sense
> > since the digester is configured anyway (via the set of rules)
> to parse a
> > specific type of XML document.
> >
> > Thanks,
> >
> > Tal
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
This looks great. I will give it a try and will report here.
I presume that the license is ASF. Is it so ?
Tal
> -----Original Message-----
> From: Jeff Turner [mailto:jeff@socialchange.net.au]
> Sent: Tuesday, November 13, 2001 6:46 PM
> To: Jakarta Commons Developers List
> Subject: Re: [digester] forcing a specific DTD
>
>
> You can use this utility to force a specific doctype:
>
> http://newgate.socialchange.net.au/~jeff/doctypechanger/
>
> I posted this on Nov 5:
>
> http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=100491227030900&w=2
>
>
> --Jeff
>
> On Tue, Nov 13, 2001 at 09:04:43AM -0800, Tal Dayan wrote:
> >
> > We plan to use Digester for parsing XML based configuration
> files and would
> > like
> > to use a DTD to save some validation code. From the Digester
> documentation
> > it seems that the DTD based validation works as follows, the
> user specifies
> > an arbitrary DTD, and digester.parse() makes sure the XML
> document matches
> > the user's specified DTD.
> >
> > We have two problems with this approach:
> >
> > 1. When we parse a file, we know what DTD it should conform to
> so there is
> > not need require the user to type it (e.g. when Tomcat reads
> server.xml, the
> > user does not care about the DTD, it should be up to Tomcat to
> do the magic
> > of validating it).
> >
> > 2. The user can specify arbitrary DTD but we want to validate against a
> > *specific* DTD. It does not help us much if we know that the
> XML conforms to
> > some arbitrary DTD the user specified (this reminds me an old
> joke, a man is
> > asked by the bank manager to identify himself, he pull a
> picture of from his
> > pocket and says 'that's me').
> >
> > Any idea how to address these issues ?
> >
> > A good solution would be example a digester.forceSpecificDTD(...) method
> > that forces a specific DTD for that instance of the parser.
> This makes sense
> > since the digester is configured anyway (via the set of rules)
> to parse a
> > specific type of XML document.
> >
> > Thanks,
> >
> > Tal
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] forcing a specific DTD
Posted by Jeff Turner <je...@socialchange.net.au>.
You can use this utility to force a specific doctype:
http://newgate.socialchange.net.au/~jeff/doctypechanger/
I posted this on Nov 5:
http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=100491227030900&w=2
--Jeff
On Tue, Nov 13, 2001 at 09:04:43AM -0800, Tal Dayan wrote:
>
> We plan to use Digester for parsing XML based configuration files and would
> like
> to use a DTD to save some validation code. From the Digester documentation
> it seems that the DTD based validation works as follows, the user specifies
> an arbitrary DTD, and digester.parse() makes sure the XML document matches
> the user's specified DTD.
>
> We have two problems with this approach:
>
> 1. When we parse a file, we know what DTD it should conform to so there is
> not need require the user to type it (e.g. when Tomcat reads server.xml, the
> user does not care about the DTD, it should be up to Tomcat to do the magic
> of validating it).
>
> 2. The user can specify arbitrary DTD but we want to validate against a
> *specific* DTD. It does not help us much if we know that the XML conforms to
> some arbitrary DTD the user specified (this reminds me an old joke, a man is
> asked by the bank manager to identify himself, he pull a picture of from his
> pocket and says 'that's me').
>
> Any idea how to address these issues ?
>
> A good solution would be example a digester.forceSpecificDTD(...) method
> that forces a specific DTD for that instance of the parser. This makes sense
> since the digester is configured anyway (via the set of rules) to parse a
> specific type of XML document.
>
> Thanks,
>
> Tal
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] forcing a specific DTD
Posted by James Strachan <ja...@yahoo.co.uk>.
FWIW Xerces has some properties for setting the location of an XML Schema
document via SAX properties which allows you to perform validation without
the source document containing a schema declaration. I don't think
specifying a DTD is possible yet.
Other than that you could use Sun's MSV library to validate a SAX event
stream using a DTD, XML Schema, RelaxNG document etc.
http://www.sun.com/software/xml/developers/multischema
James
----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
> On Tue, 13 Nov 2001, Tal Dayan wrote:
>
> > Date: Tue, 13 Nov 2001 09:04:43 -0800
> > From: Tal Dayan <ta...@zapta.com>
> > Reply-To: Jakarta Commons Developers List
<co...@jakarta.apache.org>
> > To: commons-dev@jakarta.apache.org
> > Subject: [digester] forcing a specific DTD
> >
> >
> > We plan to use Digester for parsing XML based configuration files and
would
> > like
> > to use a DTD to save some validation code. From the Digester
documentation
> > it seems that the DTD based validation works as follows, the user
specifies
> > an arbitrary DTD, and digester.parse() makes sure the XML document
matches
> > the user's specified DTD.
> >
> > We have two problems with this approach:
> >
> > 1. When we parse a file, we know what DTD it should conform to so there
is
> > not need require the user to type it (e.g. when Tomcat reads server.xml,
the
> > user does not care about the DTD, it should be up to Tomcat to do the
magic
> > of validating it).
> >
> > 2. The user can specify arbitrary DTD but we want to validate against a
> > *specific* DTD. It does not help us much if we know that the XML
conforms to
> > some arbitrary DTD the user specified (this reminds me an old joke, a
man is
> > asked by the bank manager to identify himself, he pull a picture of from
his
> > pocket and says 'that's me').
> >
> > Any idea how to address these issues ?
> >
> > A good solution would be example a digester.forceSpecificDTD(...) method
> > that forces a specific DTD for that instance of the parser. This makes
sense
> > since the digester is configured anyway (via the set of rules) to parse
a
> > specific type of XML document.
> >
> > Thanks,
> >
> > Tal
> >
>
> 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:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by "Arun M. Thomas" <AM...@yahoo.com>.
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 <AM...@yahoo.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@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:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] relative patterns
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 13 Nov 2001, Tal Dayan wrote:
> Date: Tue, 13 Nov 2001 18:59:31 -0800
> From: Tal Dayan <ta...@zapta.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: RE: [digester] relative patterns
>
> Thanks, I will take a look, I am still finding my way in the features
> provided by the
> current version of Digester.
>
> The case I had in mind was not where the same set of rules is used several
> times
> but where several rules are used with the same path.
>
> As for using '*/b' instead of '/a/b', I presume this changes the semantic of
> the rule, right ?
It doesn't change the semantic of what the rule *does*. It only changes
the semantic of when the rule is *matched*.
>
> Tal
>
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] relative patterns
Posted by Tal Dayan <ta...@zapta.com>.
Thanks, I will take a look, I am still finding my way in the features
provided by the
current version of Digester.
The case I had in mind was not where the same set of rules is used several
times
but where several rules are used with the same path.
As for using '*/b' instead of '/a/b', I presume this changes the semantic of
the rule, right ?
Tal
> -----Original Message-----
> From: craigmcc@localhost [mailto:craigmcc@localhost]On Behalf Of Craig
> R. McClanahan
> Sent: Tuesday, November 13, 2001 11:34 AM
> To: Jakarta Commons Developers List
> Subject: RE: [digester] relative patterns
>
>
> There are two things you should take a look at in the documentation:
>
> * Using the "*" in a matching pattern ("*/a" matches <a> no matter
> where it is nested)
>
> * The ability to write your own implementation of matching by defining
> a "Rules" implementation.
>
> I would not personally implement your "the previous path" pattern -- it
> makes setting up the rules very fragile if you switch the order of your
> addRule() statements around. But you can do it yourself.
>
> For re-use of existing sets of rules, check out the RuleSet class as well.
> Tomcat makes good use of this mechanism, because there are multiple places
> at which the same set of rules should be applied (but with different
> prefixes to the matching patterns).
>
> Craig
>
>
> On Tue, 13 Nov 2001, Tal Dayan wrote:
>
> > Date: Tue, 13 Nov 2001 11:14:05 -0800
> > From: Tal Dayan <ta...@zapta.com>
> > Reply-To: Jakarta Commons Developers List
> <co...@jakarta.apache.org>
> > To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> > Subject: RE: [digester] relative patterns
> >
> > Hello,
> >
> >
> > It looks like Digester accepts built in rules only with
> absolute patterns
> > such as
> >
> > digester.addSomeRule("aa"
> > digester.addSomeRule("aa/bb/cc"
> > digester.addSomeRule("aa/bb"
> >
> > which requires some work when moving things around the hierarchy.
> >
> > How about adding support for relative patterns like (very rough syntax):
> >
> > digester.setBase("/aa")
> > digester.addSomeRule("." --> /aa
> > digester.addSomeRule("./bb/cc" --> /aa/bb/cc
> > digester.addSomeRule("!" --> /aa/bb/cc (the
> previous path)
> > digester.addSomeRule("!/../dd" --> /aa/bb/dd
> >
> > This will affect only the creation of the rules and will not
> add overhead to
> > the actual parsing of the XML document.
> >
> > Tal
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] using non URL'ed DTD's
Posted by ma...@tumbleweed.com.
>From the Javadocs for java.lang.Error:
"An Error is a subclass of Throwable that indicates serious problems that a
reasonable application should not try to catch."
So, no, Error is not the right thing to throw, because presumably it's
something you want to catch and handle elsewhere in your app. You'll want to
throw an exception of a class derived from java.lang.Exception instead.
--
Martin Cooper
----- Original Message -----
From: "Tal Dayan" <ta...@zapta.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, November 14, 2001 10:04 AM
Subject: RE: [digester] using non URL'ed DTD's
> >
> > > Now, how do I abort the parsing and throw an exception if the
validation
> > > (using the DTD) fails ? Currently the parsing just continues as usual
so
> > > when the parsing ends, the application does not know if the XML
> > document was
> > > valid or not.
> > >
> >
> > Normally, Digester just logs the error messages and goes on. If you
want
> > it to abort the parse instead, you need to implement a SAX ErrorHandler
> > that actually throws exeptions from its methods, and then call
> > digester.setErrorHandler() before the parse to install it.
>
> Thanks. It worked as advertised. We abort the parsing by throwing an
> java.lang.Error from the
> Error Handler. Is this is the right way to do so ?
>
> Also, Digester prints the entire stack trace of the SAXParseException
> excpetion before it calls our handler, even when the debugging level is
set
> to zero. We don't want to turn off the logging but the dump of the entire
> stack just to report a syntax error in the XML document is more than our
> users need.
>
> How about not logging or dumping the exception if it is passed to a
> customized handler anyway ? Or, we can have a flag when setting the
handler
> to indicate if Digester should report the exceptions as well.
>
>
> > > And next step, how can I check if the public ID of the DTD in the XML
> > > document was the expected one (for which we set a local
> > resolver using the
> > > register() method) ?
> > >
> >
> > In other words, you want to ensure that *only* one of your registered
> > public IDs is selected? In the plans is a setEntityResolver() that will
> > work like setErrorHandler() does, and lets you install your own. In the
> > mean time, you could subclass Digester and override the resolveEntity()
> > method. If the first argument is registered, go ahead and call the
> > superclass resolveEntity() method; if it's not, throw an exception.
>
> We integrated Jeff's Doctype Changer in our Digester wrapper class and it
> works great. You can
> force any DTD that you want, even if there is not DOCTYPE at all. The DTD
> you force can be fixed,
> or based on the original DOCTYPE and you can also save the properties of
the
> original DOCTYPE to verified that the user specified a valid DTD. This is
> kind of functionality that I would expect to find in the XML parsers
> themselves but I don't think they provide it.
>
> Tal
>
> >
> > > Thanks,
> > >
> > > Tal
> > >
> >
> > Craig
> >
> >
> > > > -----Original Message-----
> > > > From: Louis Tribble [mailto:louis.tribble@webgain.com]
> > > > Sent: Tuesday, November 13, 2001 8:19 PM
> > > > To: Jakarta Commons Developers List
> > > > Subject: Re: [digester] using non URL'ed DTD's
> > > >
> > > >
> > > > > We are still not able to use a DTD for validation because our
> > > > DTD file has a
> > > > > path that
> > > > > is not acceptable by Digester and/or the underlying XML parser
> > > > (the URL is
> > > > > 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> > > > > everything).
> > > >
> > > > >From RFC 1738:
> > > > > A file URL takes the form:
> > > > >
> > > > > file://<host>/<path>
> > > > >
> > > > > <snip>
> > > > > As a special case, <host> can be the string "localhost" or the
> > > > empty string; this
> > > > > is interpreted as `the machine from which the URL is being
> > interpreted'.
> > > >
> > > > With two slashes, "d:" is a host name. With three slashes, the
> > > > URL should be interpreted
> > > > correctly. By the grace of many URL parsers, one slash sometimes
> > > > works too.
> > > >
> > > > Louis Tribble
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 14 Nov 2001, Tal Dayan wrote:
> Date: Wed, 14 Nov 2001 10:04:16 -0800
> From: Tal Dayan <ta...@zapta.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: RE: [digester] using non URL'ed DTD's
>
> >
> > > Now, how do I abort the parsing and throw an exception if the validation
> > > (using the DTD) fails ? Currently the parsing just continues as usual so
> > > when the parsing ends, the application does not know if the XML
> > document was
> > > valid or not.
> > >
> >
> > Normally, Digester just logs the error messages and goes on. If you want
> > it to abort the parse instead, you need to implement a SAX ErrorHandler
> > that actually throws exeptions from its methods, and then call
> > digester.setErrorHandler() before the parse to install it.
>
> Thanks. It worked as advertised. We abort the parsing by throwing an
> java.lang.Error from the
> Error Handler. Is this is the right way to do so ?
>
That works ... or you could throw a SAXException (or a subclass of it) if
you wanted the error to be more specific. This would ultimately get
rethrown from digester.parse() back to the application, so you could
throw (for example) a SAXParseException that includes the location of the
actual error.
> Also, Digester prints the entire stack trace of the SAXParseException
> excpetion before it calls our handler, even when the debugging level is set
> to zero. We don't want to turn off the logging but the dump of the entire
> stack just to report a syntax error in the XML document is more than our
> users need.
>
> How about not logging or dumping the exception if it is passed to a
> customized handler anyway ? Or, we can have a flag when setting the handler
> to indicate if Digester should report the exceptions as well.
>
That makes sense. In the mean time, you can always subclass and override.
>
> > > And next step, how can I check if the public ID of the DTD in the XML
> > > document was the expected one (for which we set a local
> > resolver using the
> > > register() method) ?
> > >
> >
> > In other words, you want to ensure that *only* one of your registered
> > public IDs is selected? In the plans is a setEntityResolver() that will
> > work like setErrorHandler() does, and lets you install your own. In the
> > mean time, you could subclass Digester and override the resolveEntity()
> > method. If the first argument is registered, go ahead and call the
> > superclass resolveEntity() method; if it's not, throw an exception.
>
> We integrated Jeff's Doctype Changer in our Digester wrapper class and it
> works great. You can
> force any DTD that you want, even if there is not DOCTYPE at all. The DTD
> you force can be fixed,
> or based on the original DOCTYPE and you can also save the properties of the
> original DOCTYPE to verified that the user specified a valid DTD. This is
> kind of functionality that I would expect to find in the XML parsers
> themselves but I don't think they provide it.
>
> Tal
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by Tal Dayan <ta...@zapta.com>.
>
> > Now, how do I abort the parsing and throw an exception if the validation
> > (using the DTD) fails ? Currently the parsing just continues as usual so
> > when the parsing ends, the application does not know if the XML
> document was
> > valid or not.
> >
>
> Normally, Digester just logs the error messages and goes on. If you want
> it to abort the parse instead, you need to implement a SAX ErrorHandler
> that actually throws exeptions from its methods, and then call
> digester.setErrorHandler() before the parse to install it.
Thanks. It worked as advertised. We abort the parsing by throwing an
java.lang.Error from the
Error Handler. Is this is the right way to do so ?
Also, Digester prints the entire stack trace of the SAXParseException
excpetion before it calls our handler, even when the debugging level is set
to zero. We don't want to turn off the logging but the dump of the entire
stack just to report a syntax error in the XML document is more than our
users need.
How about not logging or dumping the exception if it is passed to a
customized handler anyway ? Or, we can have a flag when setting the handler
to indicate if Digester should report the exceptions as well.
> > And next step, how can I check if the public ID of the DTD in the XML
> > document was the expected one (for which we set a local
> resolver using the
> > register() method) ?
> >
>
> In other words, you want to ensure that *only* one of your registered
> public IDs is selected? In the plans is a setEntityResolver() that will
> work like setErrorHandler() does, and lets you install your own. In the
> mean time, you could subclass Digester and override the resolveEntity()
> method. If the first argument is registered, go ahead and call the
> superclass resolveEntity() method; if it's not, throw an exception.
We integrated Jeff's Doctype Changer in our Digester wrapper class and it
works great. You can
force any DTD that you want, even if there is not DOCTYPE at all. The DTD
you force can be fixed,
or based on the original DOCTYPE and you can also save the properties of the
original DOCTYPE to verified that the user specified a valid DTD. This is
kind of functionality that I would expect to find in the XML parsers
themselves but I don't think they provide it.
Tal
>
> > Thanks,
> >
> > Tal
> >
>
> Craig
>
>
> > > -----Original Message-----
> > > From: Louis Tribble [mailto:louis.tribble@webgain.com]
> > > Sent: Tuesday, November 13, 2001 8:19 PM
> > > To: Jakarta Commons Developers List
> > > Subject: Re: [digester] using non URL'ed DTD's
> > >
> > >
> > > > We are still not able to use a DTD for validation because our
> > > DTD file has a
> > > > path that
> > > > is not acceptable by Digester and/or the underlying XML parser
> > > (the URL is
> > > > 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> > > > everything).
> > >
> > > >From RFC 1738:
> > > > A file URL takes the form:
> > > >
> > > > file://<host>/<path>
> > > >
> > > > <snip>
> > > > As a special case, <host> can be the string "localhost" or the
> > > empty string; this
> > > > is interpreted as `the machine from which the URL is being
> interpreted'.
> > >
> > > With two slashes, "d:" is a host name. With three slashes, the
> > > URL should be interpreted
> > > correctly. By the grace of many URL parsers, one slash sometimes
> > > works too.
> > >
> > > Louis Tribble
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 13 Nov 2001, Tal Dayan wrote:
> Date: Tue, 13 Nov 2001 23:01:10 -0800
> From: Tal Dayan <ta...@zapta.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>,
> Louis Tribble <lo...@webgain.com>
> Subject: RE: [digester] using non URL'ed DTD's
>
> Thanks. This works. The DTD file is now recognized and I can see printout of
> exceptions if the
> XML document does not match the DTD.
>
Cool.
> Now, how do I abort the parsing and throw an exception if the validation
> (using the DTD) fails ? Currently the parsing just continues as usual so
> when the parsing ends, the application does not know if the XML document was
> valid or not.
>
Normally, Digester just logs the error messages and goes on. If you want
it to abort the parse instead, you need to implement a SAX ErrorHandler
that actually throws exeptions from its methods, and then call
digester.setErrorHandler() before the parse to install it.
> And next step, how can I check if the public ID of the DTD in the XML
> document was the expected one (for which we set a local resolver using the
> register() method) ?
>
In other words, you want to ensure that *only* one of your registered
public IDs is selected? In the plans is a setEntityResolver() that will
work like setErrorHandler() does, and lets you install your own. In the
mean time, you could subclass Digester and override the resolveEntity()
method. If the first argument is registered, go ahead and call the
superclass resolveEntity() method; if it's not, throw an exception.
> Thanks,
>
> Tal
>
Craig
> > -----Original Message-----
> > From: Louis Tribble [mailto:louis.tribble@webgain.com]
> > Sent: Tuesday, November 13, 2001 8:19 PM
> > To: Jakarta Commons Developers List
> > Subject: Re: [digester] using non URL'ed DTD's
> >
> >
> > > We are still not able to use a DTD for validation because our
> > DTD file has a
> > > path that
> > > is not acceptable by Digester and/or the underlying XML parser
> > (the URL is
> > > 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> > > everything).
> >
> > >From RFC 1738:
> > > A file URL takes the form:
> > >
> > > file://<host>/<path>
> > >
> > > <snip>
> > > As a special case, <host> can be the string "localhost" or the
> > empty string; this
> > > is interpreted as `the machine from which the URL is being interpreted'.
> >
> > With two slashes, "d:" is a host name. With three slashes, the
> > URL should be interpreted
> > correctly. By the grace of many URL parsers, one slash sometimes
> > works too.
> >
> > Louis Tribble
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by Tal Dayan <ta...@zapta.com>.
Thanks. This works. The DTD file is now recognized and I can see printout of
exceptions if the
XML document does not match the DTD.
Now, how do I abort the parsing and throw an exception if the validation
(using the DTD) fails ? Currently the parsing just continues as usual so
when the parsing ends, the application does not know if the XML document was
valid or not.
And next step, how can I check if the public ID of the DTD in the XML
document was the expected one (for which we set a local resolver using the
register() method) ?
Thanks,
Tal
> -----Original Message-----
> From: Louis Tribble [mailto:louis.tribble@webgain.com]
> Sent: Tuesday, November 13, 2001 8:19 PM
> To: Jakarta Commons Developers List
> Subject: Re: [digester] using non URL'ed DTD's
>
>
> > We are still not able to use a DTD for validation because our
> DTD file has a
> > path that
> > is not acceptable by Digester and/or the underlying XML parser
> (the URL is
> > 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> > everything).
>
> >From RFC 1738:
> > A file URL takes the form:
> >
> > file://<host>/<path>
> >
> > <snip>
> > As a special case, <host> can be the string "localhost" or the
> empty string; this
> > is interpreted as `the machine from which the URL is being interpreted'.
>
> With two slashes, "d:" is a host name. With three slashes, the
> URL should be interpreted
> correctly. By the grace of many URL parsers, one slash sometimes
> works too.
>
> Louis Tribble
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [digester] using non URL'ed DTD's
Posted by Louis Tribble <lo...@webgain.com>.
> We are still not able to use a DTD for validation because our DTD file has a
> path that
> is not acceptable by Digester and/or the underlying XML parser (the URL is
> 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> everything).
>From RFC 1738:
> A file URL takes the form:
>
> file://<host>/<path>
>
> <snip>
> As a special case, <host> can be the string "localhost" or the empty string; this
> is interpreted as `the machine from which the URL is being interpreted'.
With two slashes, "d:" is a host name. With three slashes, the URL should be interpreted
correctly. By the grace of many URL parsers, one slash sometimes works too.
Louis Tribble
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by Tal Dayan <ta...@zapta.com>.
Any objection from the maintainers of Digester for adding a register(...,
InputStream) method ?
Internally, the digester converts anyway the URL to an InputStream. This
will allow to accept a DTD from any source (memory, database, etc) and not
just a URL'ed resource. This is supported anyway by the underlying parsers.
I may provide the code if needed.
Tal
> -----Original Message-----
> From: craigmcc@localhost [mailto:craigmcc@localhost]On Behalf Of Craig
> R. McClanahan
> Sent: Tuesday, November 13, 2001 6:56 PM
> To: Jakarta Commons Developers List
> Subject: RE: [digester] using non URL'ed DTD's
>
>
>
>
> On Tue, 13 Nov 2001, Tal Dayan wrote:
>
> > Date: Tue, 13 Nov 2001 18:59:30 -0800
> > From: Tal Dayan <ta...@zapta.com>
> > Reply-To: Jakarta Commons Developers List
> <co...@jakarta.apache.org>
> > To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> > Subject: RE: [digester] using non URL'ed DTD's
> >
> > Hello,
> >
> > We are still not able to use a DTD for validation because our
> DTD file has a
> > path that
> > is not acceptable by Digester and/or the underlying XML parser
> (the URL is
> > 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> > everything).
>
> Digester couldn't care less, as long as the JDK doesn't throw
> MalformedURLException. If your parser chokes on this, it's time to get a
> better parser :-). Or, figure out what your parser *will* accept for
> Windows-based file paths. That's up to whatever parser you are using, not
> Digester.
>
> > Actually, this is a more general issue in cases where the DTD
> > can not be referred to by a URL (e.g., when it is taken
> directly from a data
> > base).
> >
> > My suggestion is to add another registration method that
> accepts a Reader
> > instead of the URL. This way the DTD can be retrieved from
> file, in memory
> > cache buffer, etc.
> >
>
> Both JAXP/1.1 and Xerces 1.4.3 work for me, on both Windows and Unix.
>
> > Thanks,
> >
> > Tal
> >
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 13 Nov 2001, Tal Dayan wrote:
> Date: Tue, 13 Nov 2001 18:59:30 -0800
> From: Tal Dayan <ta...@zapta.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: RE: [digester] using non URL'ed DTD's
>
> Hello,
>
> We are still not able to use a DTD for validation because our DTD file has a
> path that
> is not acceptable by Digester and/or the underlying XML parser (the URL is
> 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> everything).
Digester couldn't care less, as long as the JDK doesn't throw
MalformedURLException. If your parser chokes on this, it's time to get a
better parser :-). Or, figure out what your parser *will* accept for
Windows-based file paths. That's up to whatever parser you are using, not
Digester.
> Actually, this is a more general issue in cases where the DTD
> can not be referred to by a URL (e.g., when it is taken directly from a data
> base).
>
> My suggestion is to add another registration method that accepts a Reader
> instead of the URL. This way the DTD can be retrieved from file, in memory
> cache buffer, etc.
>
Both JAXP/1.1 and Xerces 1.4.3 work for me, on both Windows and Unix.
> Thanks,
>
> Tal
>
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by Michael Smith <mi...@iammichael.org>.
file://d:/a/b/c.dtd isn't a valid URL.
Section 3.10 of RFC 1738 [ http://www.faqs.org/rfcs/rfc1738.html ]:
A file URL takes the form:
file://<host>/<path>
where <host> is the fully qualified domain name of the system on
which the <path> is accessible, and <path> is a hierarchical
directory path of the form <directory>/<directory>/.../<name>.
[snip]
As a special case, <host> can be the string "localhost" or the empty
string; this is interpreted as `the machine from which the URL is
being interpreted'.
By specifying file://d:/a/b/c.dtd, you are specifing that "d:" is the
host rather than part of the actual file path.
Add an extra / in there, and things should work ok:
file:///d:/a/b/c.dtd
in this case the "empty string" between the second and third / implies
the file is on the local host.
regards,
michael
> -----Original Message-----
> From: Tal Dayan [mailto:tal@zapta.com]
> Sent: Tuesday, November 13, 2001 10:00 PM
> To: Jakarta Commons Developers List
> Subject: RE: [digester] using non URL'ed DTD's
>
>
> Hello,
>
> We are still not able to use a DTD for validation because our
> DTD file has a
> path that
> is not acceptable by Digester and/or the underlying XML
> parser (the URL is
> 'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
> everything). Actually, this is a more general issue in cases
> where the DTD
> can not be referred to by a URL (e.g., when it is taken
> directly from a data
> base).
>
> My suggestion is to add another registration method that
> accepts a Reader
> instead of the URL. This way the DTD can be retrieved from
> file, in memory
> cache buffer, etc.
>
> Thanks,
>
> Tal
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] using non URL'ed DTD's
Posted by Tal Dayan <ta...@zapta.com>.
Hello,
We are still not able to use a DTD for validation because our DTD file has a
path that
is not acceptable by Digester and/or the underlying XML parser (the URL is
'file://d:/a/b/c.dtd' but the Windows drive letter 'd:' confuses
everything). Actually, this is a more general issue in cases where the DTD
can not be referred to by a URL (e.g., when it is taken directly from a data
base).
My suggestion is to add another registration method that accepts a Reader
instead of the URL. This way the DTD can be retrieved from file, in memory
cache buffer, etc.
Thanks,
Tal
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] relative patterns
Posted by "Craig R. McClanahan" <cr...@apache.org>.
There are two things you should take a look at in the documentation:
* Using the "*" in a matching pattern ("*/a" matches <a> no matter
where it is nested)
* The ability to write your own implementation of matching by defining
a "Rules" implementation.
I would not personally implement your "the previous path" pattern -- it
makes setting up the rules very fragile if you switch the order of your
addRule() statements around. But you can do it yourself.
For re-use of existing sets of rules, check out the RuleSet class as well.
Tomcat makes good use of this mechanism, because there are multiple places
at which the same set of rules should be applied (but with different
prefixes to the matching patterns).
Craig
On Tue, 13 Nov 2001, Tal Dayan wrote:
> Date: Tue, 13 Nov 2001 11:14:05 -0800
> From: Tal Dayan <ta...@zapta.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: RE: [digester] relative patterns
>
> Hello,
>
>
> It looks like Digester accepts built in rules only with absolute patterns
> such as
>
> digester.addSomeRule("aa"
> digester.addSomeRule("aa/bb/cc"
> digester.addSomeRule("aa/bb"
>
> which requires some work when moving things around the hierarchy.
>
> How about adding support for relative patterns like (very rough syntax):
>
> digester.setBase("/aa")
> digester.addSomeRule("." --> /aa
> digester.addSomeRule("./bb/cc" --> /aa/bb/cc
> digester.addSomeRule("!" --> /aa/bb/cc (the previous path)
> digester.addSomeRule("!/../dd" --> /aa/bb/dd
>
> This will affect only the creation of the rules and will not add overhead to
> the actual parsing of the XML document.
>
> Tal
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] relative patterns
Posted by Tal Dayan <ta...@zapta.com>.
Hello,
It looks like Digester accepts built in rules only with absolute patterns
such as
digester.addSomeRule("aa"
digester.addSomeRule("aa/bb/cc"
digester.addSomeRule("aa/bb"
which requires some work when moving things around the hierarchy.
How about adding support for relative patterns like (very rough syntax):
digester.setBase("/aa")
digester.addSomeRule("." --> /aa
digester.addSomeRule("./bb/cc" --> /aa/bb/cc
digester.addSomeRule("!" --> /aa/bb/cc (the previous path)
digester.addSomeRule("!/../dd" --> /aa/bb/dd
This will affect only the creation of the rules and will not add overhead to
the actual parsing of the XML document.
Tal
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by "Craig R. McClanahan" <cr...@apache.org>.
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 <AM...@yahoo.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by "Arun M. Thomas" <AM...@yahoo.com>.
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
Re: [digester] forcing a specific DTD
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 13 Nov 2001, Tal Dayan wrote:
> Date: Tue, 13 Nov 2001 09:04:43 -0800
> From: Tal Dayan <ta...@zapta.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: commons-dev@jakarta.apache.org
> Subject: [digester] forcing a specific DTD
>
>
> We plan to use Digester for parsing XML based configuration files and would
> like
> to use a DTD to save some validation code. From the Digester documentation
> it seems that the DTD based validation works as follows, the user specifies
> an arbitrary DTD, and digester.parse() makes sure the XML document matches
> the user's specified DTD.
>
> We have two problems with this approach:
>
> 1. When we parse a file, we know what DTD it should conform to so there is
> not need require the user to type it (e.g. when Tomcat reads server.xml, the
> user does not care about the DTD, it should be up to Tomcat to do the magic
> of validating it).
>
> 2. The user can specify arbitrary DTD but we want to validate against a
> *specific* DTD. It does not help us much if we know that the XML conforms to
> some arbitrary DTD the user specified (this reminds me an old joke, a man is
> asked by the bank manager to identify himself, he pull a picture of from his
> pocket and says 'that's me').
>
> Any idea how to address these issues ?
>
> A good solution would be example a digester.forceSpecificDTD(...) method
> that forces a specific DTD for that instance of the parser. This makes sense
> since the digester is configured anyway (via the set of rules) to parse a
> specific type of XML document.
>
> Thanks,
>
> Tal
>
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
> Tomcat doesn't actually do a validating XML parse (against a DTD) of the
> server.xml file. This is because the set of attributes for the various
> elements like <Valve> and <Logger> are open-ended. It is not possible to
> write a complete DTD for server.xml that will cover everything.
>
> > As we said, we can write the validation code in the application
> but this has
> > too problems:
> >
> > 1. More code to write and maintain.
> >
>
> DTDs are all right for some purposes, but they are by no means sufficient
> to perform what I think of as validation. For example, there's no way I
> can say in a DTD, going back to Tomcat as an example again, that "the
> servlet name referenced in this <servlet-mapping> must have already been
> defined in a <servlet> definition". XML Schema is getting closer to this,
> but there are still going to be things that you can only validate in the
> actual application.
Yes, the DTD is mostly for validating the context free aspect of the XML
dialect in use. The rest may be done in the application. Howevever, having a
validation against a DTD is already a great time saver and requires less
code in the application.
> > 2. I am not sure if the application that uses Digester has all the
> > information about the XML, at least not from what I saw after a
> brief usage
> > of the rules. For example, if the user misspelled the name of
> an option tag,
> > does the Digester pass it at all to the application ?
> >
>
> No. Digester is a pattern matching application that silently ignores
> everything that doesn't match the patterns for which you have registered
> rules. If you want *all* the content, you should parse the document
> yourself.
I definitly don't want *all* the content, this is why I use Digester ;-) My
point is that
even if you are ready to add validation to the application, it does not have
the ability to
do it 100% because Digester filters out some of the information. In any
case, I think a DTD
validation is the way to go for first level validation and then to perform
the rest
in the application.
Tal
>
> > Tal
> >
>
> Craig
>
>
> > > -----Original Message-----
> > > From: Arun M. Thomas [mailto:AMammenT@yahoo.com]
> > > Sent: Tuesday, November 13, 2001 9:56 AM
> > > To: Jakarta Commons Developers List
> > > Subject: RE: [digester] forcing a specific DTD
> > >
> > >
> > > Tal,
> > >
> > > Note that you can register a local copy of
> > > the dtd against which you'd like to process
> > > a document using the digester.register()
> > > method. You can also require that the user
> > > supply the correct PUBLIC Id (as per your
> > > documentation or template) simply by checking
> > > the public id via the digester.getPublicId()
> > > method.
> > >
> > > (I haven't actually had a need to do this,
> > > but it does seem to be possible :)
> > >
> > > It doesn't satisfy all your requirements; e.g.
> > > the user must still ensure that a public and system
> > > id are present in the XML file. However, this can
> > > probably be handled simply by documenting the
> > > required Public ID. Also, validating against a
> > > dtd other than that visible to the user in the
> > > XML file is misleading to the user if there is
> > > an error occuring.
> > >
> > > However, note that the Tomcat example you provided
> > > is slightly at odds with what I understand you're
> > > trying to accomplish. Tomcat parsing simply defers
> > > all validation to the application itself. As you
> > > said, the Tomcat implementation does the magic of
> > > validation. Here, you're hoping to have the digester
> > > do some of that magic so that your particular
> > > application code doesn't need to do so. If you're
> > > willing to code all the validation rules into
> > > your application, you wouldn't need to use a
> > > validating parser.
> > >
> > > Cheers,
> > > -AMT
> > >
> > > -----Original Message-----
> > > From: Tal Dayan [mailto:tal@zapta.com]
> > > Sent: Tuesday, November 13, 2001 9:05 AM
> > > To: commons-dev@jakarta.apache.org
> > > Subject: [digester] forcing a specific DTD
> > >
> > >
> > >
> > > We plan to use Digester for parsing XML based configuration files
> > > and would
> > > like
> > > to use a DTD to save some validation code. From the Digester
> documentation
> > > it seems that the DTD based validation works as follows, the user
> > > specifies
> > > an arbitrary DTD, and digester.parse() makes sure the XML
> document matches
> > > the user's specified DTD.
> > >
> > > We have two problems with this approach:
> > >
> > > 1. When we parse a file, we know what DTD it should conform
> to so there is
> > > not need require the user to type it (e.g. when Tomcat reads
> > > server.xml, the
> > > user does not care about the DTD, it should be up to Tomcat to do
> > > the magic
> > > of validating it).
> > >
> > > 2. The user can specify arbitrary DTD but we want to validate
> against a
> > > *specific* DTD. It does not help us much if we know that the XML
> > > conforms to
> > > some arbitrary DTD the user specified (this reminds me an old
> > > joke, a man is
> > > asked by the bank manager to identify himself, he pull a picture
> > > of from his
> > > pocket and says 'that's me').
> > >
> > > Any idea how to address these issues ?
> > >
> > > A good solution would be example a
> digester.forceSpecificDTD(...) method
> > > that forces a specific DTD for that instance of the parser. This
> > > makes sense
> > > since the digester is configured anyway (via the set of
> rules) to parse a
> > > specific type of XML document.
> > >
> > > Thanks,
> > >
> > > Tal
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 13 Nov 2001, Tal Dayan wrote:
> Date: Tue, 13 Nov 2001 10:54:48 -0800
> From: Tal Dayan <ta...@zapta.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: RE: [digester] forcing a specific DTD
>
> Hi Arun,
>
> When I used the Tomcat example, this was from the view point of the user
> that
> write the XML file. How Tomcat does it is an implementation issue that can
> be changed at anytime.
>
Tomcat doesn't actually do a validating XML parse (against a DTD) of the
server.xml file. This is because the set of attributes for the various
elements like <Valve> and <Logger> are open-ended. It is not possible to
write a complete DTD for server.xml that will cover everything.
> As we said, we can write the validation code in the application but this has
> too problems:
>
> 1. More code to write and maintain.
>
DTDs are all right for some purposes, but they are by no means sufficient
to perform what I think of as validation. For example, there's no way I
can say in a DTD, going back to Tomcat as an example again, that "the
servlet name referenced in this <servlet-mapping> must have already been
defined in a <servlet> definition". XML Schema is getting closer to this,
but there are still going to be things that you can only validate in the
actual application.
> 2. I am not sure if the application that uses Digester has all the
> information about the XML, at least not from what I saw after a brief usage
> of the rules. For example, if the user misspelled the name of an option tag,
> does the Digester pass it at all to the application ?
>
No. Digester is a pattern matching application that silently ignores
everything that doesn't match the patterns for which you have registered
rules. If you want *all* the content, you should parse the document
yourself.
> Tal
>
Craig
> > -----Original Message-----
> > From: Arun M. Thomas [mailto:AMammenT@yahoo.com]
> > Sent: Tuesday, November 13, 2001 9:56 AM
> > To: Jakarta Commons Developers List
> > Subject: RE: [digester] forcing a specific DTD
> >
> >
> > Tal,
> >
> > Note that you can register a local copy of
> > the dtd against which you'd like to process
> > a document using the digester.register()
> > method. You can also require that the user
> > supply the correct PUBLIC Id (as per your
> > documentation or template) simply by checking
> > the public id via the digester.getPublicId()
> > method.
> >
> > (I haven't actually had a need to do this,
> > but it does seem to be possible :)
> >
> > It doesn't satisfy all your requirements; e.g.
> > the user must still ensure that a public and system
> > id are present in the XML file. However, this can
> > probably be handled simply by documenting the
> > required Public ID. Also, validating against a
> > dtd other than that visible to the user in the
> > XML file is misleading to the user if there is
> > an error occuring.
> >
> > However, note that the Tomcat example you provided
> > is slightly at odds with what I understand you're
> > trying to accomplish. Tomcat parsing simply defers
> > all validation to the application itself. As you
> > said, the Tomcat implementation does the magic of
> > validation. Here, you're hoping to have the digester
> > do some of that magic so that your particular
> > application code doesn't need to do so. If you're
> > willing to code all the validation rules into
> > your application, you wouldn't need to use a
> > validating parser.
> >
> > Cheers,
> > -AMT
> >
> > -----Original Message-----
> > From: Tal Dayan [mailto:tal@zapta.com]
> > Sent: Tuesday, November 13, 2001 9:05 AM
> > To: commons-dev@jakarta.apache.org
> > Subject: [digester] forcing a specific DTD
> >
> >
> >
> > We plan to use Digester for parsing XML based configuration files
> > and would
> > like
> > to use a DTD to save some validation code. From the Digester documentation
> > it seems that the DTD based validation works as follows, the user
> > specifies
> > an arbitrary DTD, and digester.parse() makes sure the XML document matches
> > the user's specified DTD.
> >
> > We have two problems with this approach:
> >
> > 1. When we parse a file, we know what DTD it should conform to so there is
> > not need require the user to type it (e.g. when Tomcat reads
> > server.xml, the
> > user does not care about the DTD, it should be up to Tomcat to do
> > the magic
> > of validating it).
> >
> > 2. The user can specify arbitrary DTD but we want to validate against a
> > *specific* DTD. It does not help us much if we know that the XML
> > conforms to
> > some arbitrary DTD the user specified (this reminds me an old
> > joke, a man is
> > asked by the bank manager to identify himself, he pull a picture
> > of from his
> > pocket and says 'that's me').
> >
> > Any idea how to address these issues ?
> >
> > A good solution would be example a digester.forceSpecificDTD(...) method
> > that forces a specific DTD for that instance of the parser. This
> > makes sense
> > since the digester is configured anyway (via the set of rules) to parse a
> > specific type of XML document.
> >
> > Thanks,
> >
> > Tal
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by Tal Dayan <ta...@zapta.com>.
Hi Arun,
When I used the Tomcat example, this was from the view point of the user
that
write the XML file. How Tomcat does it is an implementation issue that can
be changed at anytime.
As we said, we can write the validation code in the application but this has
too problems:
1. More code to write and maintain.
2. I am not sure if the application that uses Digester has all the
information about the XML, at least not from what I saw after a brief usage
of the rules. For example, if the user misspelled the name of an option tag,
does the Digester pass it at all to the application ?
Tal
> -----Original Message-----
> From: Arun M. Thomas [mailto:AMammenT@yahoo.com]
> Sent: Tuesday, November 13, 2001 9:56 AM
> To: Jakarta Commons Developers List
> Subject: RE: [digester] forcing a specific DTD
>
>
> Tal,
>
> Note that you can register a local copy of
> the dtd against which you'd like to process
> a document using the digester.register()
> method. You can also require that the user
> supply the correct PUBLIC Id (as per your
> documentation or template) simply by checking
> the public id via the digester.getPublicId()
> method.
>
> (I haven't actually had a need to do this,
> but it does seem to be possible :)
>
> It doesn't satisfy all your requirements; e.g.
> the user must still ensure that a public and system
> id are present in the XML file. However, this can
> probably be handled simply by documenting the
> required Public ID. Also, validating against a
> dtd other than that visible to the user in the
> XML file is misleading to the user if there is
> an error occuring.
>
> However, note that the Tomcat example you provided
> is slightly at odds with what I understand you're
> trying to accomplish. Tomcat parsing simply defers
> all validation to the application itself. As you
> said, the Tomcat implementation does the magic of
> validation. Here, you're hoping to have the digester
> do some of that magic so that your particular
> application code doesn't need to do so. If you're
> willing to code all the validation rules into
> your application, you wouldn't need to use a
> validating parser.
>
> Cheers,
> -AMT
>
> -----Original Message-----
> From: Tal Dayan [mailto:tal@zapta.com]
> Sent: Tuesday, November 13, 2001 9:05 AM
> To: commons-dev@jakarta.apache.org
> Subject: [digester] forcing a specific DTD
>
>
>
> We plan to use Digester for parsing XML based configuration files
> and would
> like
> to use a DTD to save some validation code. From the Digester documentation
> it seems that the DTD based validation works as follows, the user
> specifies
> an arbitrary DTD, and digester.parse() makes sure the XML document matches
> the user's specified DTD.
>
> We have two problems with this approach:
>
> 1. When we parse a file, we know what DTD it should conform to so there is
> not need require the user to type it (e.g. when Tomcat reads
> server.xml, the
> user does not care about the DTD, it should be up to Tomcat to do
> the magic
> of validating it).
>
> 2. The user can specify arbitrary DTD but we want to validate against a
> *specific* DTD. It does not help us much if we know that the XML
> conforms to
> some arbitrary DTD the user specified (this reminds me an old
> joke, a man is
> asked by the bank manager to identify himself, he pull a picture
> of from his
> pocket and says 'that's me').
>
> Any idea how to address these issues ?
>
> A good solution would be example a digester.forceSpecificDTD(...) method
> that forces a specific DTD for that instance of the parser. This
> makes sense
> since the digester is configured anyway (via the set of rules) to parse a
> specific type of XML document.
>
> Thanks,
>
> Tal
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [digester] forcing a specific DTD
Posted by "Arun M. Thomas" <AM...@yahoo.com>.
Tal,
Note that you can register a local copy of
the dtd against which you'd like to process
a document using the digester.register()
method. You can also require that the user
supply the correct PUBLIC Id (as per your
documentation or template) simply by checking
the public id via the digester.getPublicId()
method.
(I haven't actually had a need to do this,
but it does seem to be possible :)
It doesn't satisfy all your requirements; e.g.
the user must still ensure that a public and system
id are present in the XML file. However, this can
probably be handled simply by documenting the
required Public ID. Also, validating against a
dtd other than that visible to the user in the
XML file is misleading to the user if there is
an error occuring.
However, note that the Tomcat example you provided
is slightly at odds with what I understand you're
trying to accomplish. Tomcat parsing simply defers
all validation to the application itself. As you
said, the Tomcat implementation does the magic of
validation. Here, you're hoping to have the digester
do some of that magic so that your particular
application code doesn't need to do so. If you're
willing to code all the validation rules into
your application, you wouldn't need to use a
validating parser.
Cheers,
-AMT
-----Original Message-----
From: Tal Dayan [mailto:tal@zapta.com]
Sent: Tuesday, November 13, 2001 9:05 AM
To: commons-dev@jakarta.apache.org
Subject: [digester] forcing a specific DTD
We plan to use Digester for parsing XML based configuration files and would
like
to use a DTD to save some validation code. From the Digester documentation
it seems that the DTD based validation works as follows, the user specifies
an arbitrary DTD, and digester.parse() makes sure the XML document matches
the user's specified DTD.
We have two problems with this approach:
1. When we parse a file, we know what DTD it should conform to so there is
not need require the user to type it (e.g. when Tomcat reads server.xml, the
user does not care about the DTD, it should be up to Tomcat to do the magic
of validating it).
2. The user can specify arbitrary DTD but we want to validate against a
*specific* DTD. It does not help us much if we know that the XML conforms to
some arbitrary DTD the user specified (this reminds me an old joke, a man is
asked by the bank manager to identify himself, he pull a picture of from his
pocket and says 'that's me').
Any idea how to address these issues ?
A good solution would be example a digester.forceSpecificDTD(...) method
that forces a specific DTD for that instance of the parser. This makes sense
since the digester is configured anyway (via the set of rules) to parse a
specific type of XML document.
Thanks,
Tal
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>