Re: [libxml++] [Fwd: DTD validation for libxml++]
- From: Jonathan Wakely <cow compsoc man ac uk>
- To: libxmlplusplus-general lists sourceforge net
- Subject: Re: [libxml++] [Fwd: DTD validation for libxml++]
- Date: Wed, 31 Mar 2004 16:46:54 +0100
On Wed, Mar 31, 2004 at 05:16:12PM +0200, Christophe de VIENNE wrote:
> Date: Wed, 31 Mar 2004 16:33:06 +0200
> From: "Guillaume Arreckx" <bill arreckx acterna com>
> To: cdevienne users sourceforge net
> Subject: DTD validation for libxml++
[snip]
> To valide an xml document, all the user has to do is :
>
> try
> {
> xmlpp::DtdValidator validator( dtdFileName );
> xmlpp::Document *pDoc = ...
> validator.validate( pDoc );
> }
> catch( const xmlpp::parse_error& )
Nice.
Should DtdValidator.validate() throw something other than parse_error ?
A new xmlpp::validation_error type maybe ?
Otherwise distinguishing between not well-formed and not valid requires
something like:
try
{
xmlpp::DtdValidator validator( dtdFileName );
xmlpp::Document *pDoc = ...
}
catch( const xmlpp::parse_error& )
{
// DTD or document is not well-formed
}
try
{
validator.validate( pDoc );
}
catch( const xmlpp:parse_error& )
{
// document is not valid
}
as opposed to:
try
{
xmlpp::DtdValidator validator( dtdFileName );
xmlpp::Document *pDoc = ...
validator.validate( pDoc );
}
catch( const xmlpp::parse_error& )
{
// DTD or document is not well-formed
}
catch ( const xmlpp::validation_error& )
{
// document is not valid
}
The exception handling in the first example reduces readibility, rather
than moving error-handling away from the business logic.
Just a thought,
jon
--
"A scientific theory should be as simple as possible, but no simpler."
- Albert Einstein
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]