SAX: Error Reporting (question 4 of 10)

James Clark jjc at
Sun Jan 4 00:30:52 GMT 1998

David Megginson wrote:
> Should SAX treat errors as events?  If so, should it distinguish fatal
> errors from warnings or non-fatal errors?
>   public void warning (String message, String systemID, int line);
>   public void fatalError (String message, String systemID, int line);

There are 3 things that need to be distinguished:

- Fatal errors: violations of well-formedness constraints; processors
have to detect these and must stop normal processing.  In Java I think
an exception is the only reasonable way to handle these.  Unless you do
this people will be tempted to continue processing in violation of the

- Errors: violations of validity constraints or other errors that a
processor is not required to detect.

- Warnings: messages about conditions that do not cause a document to be

To do a really good job of reporting these, much more information is
needed that a line number and a URL.  In particular you need more
information about the entity structure.  For example, given a document

<!DOCTYPE doc SYSTEM "doc.dtd">

and doc.dtd:

<!ELEMENT doc (a)>
<!ENTITY e "<b/>">

nsgmls -e will say:

In entity e included from doc.xml:2:8
nsgmls:doc.dtd:2:15:E: element "b" undefined

There can be more than one relevant URL and line number.

This sort of facility also introduces major internationalization issues.

I can guarantee you are not going to be able to do a good job of error
reporting and still keep the interface simple.


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as:
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list