loge.hixie.ch

Hixie's Natural Log

2004-01-22 14:33 UTC Error handling and XML

In my last post I explained what Web specification authors should do with respect to error handling, in my opinion.

What about Web browser implementors and XML?

There is a lot of debate in Web log comments, mailing lists, and forums, about what Web browsers should do. There really shouldn't be. The spec is very clear about this.

As a Web browser implementor, you have two options:

  1. The moment you hit a well-formedness error, replace the entire page with an error message.
  2. The moment you hit a well-formedness error, discard everything from that point on, and display what you got so far, with an error message.

There is no other option. If your browser does anything else, it is violating the specifications. If people want XML to do something else, then they should invent their own language with its own rules — but if you use XML, the above two scenarios are the only allowable scenarios.

(Actually there are a couple of other options, but really they are just variants of the above. First, you are allowed to report more than one error, so long as you don't do anything with any of the content after the first error except for reporting errors. Second, you are also allowed to complain about more than just well-formedness errors: if you are a validating parser you can check for validity as well. For performance and other reasons, these options are never really workable for Web browsers.)