The XML specification grants parsers a sometimes confusing amount of leeway in processing XML documents. Parsers are allowed to validate or not, to resolve external entities or not, to treat nondeterministic content models as errors or not, to support nonstandard encodings or not, to check for namespace well- formedness or not, and much more. Depending on exactly which choices two parsers make for all of these options, they can produce quite different pictures of the same XML document. Indeed in a few cases, one parser may even report a document to be well- formed while another parser may report the same document to be malformed .
To support the wide range of capabilities among different parsers, the XMLReader interface that represents parsers in SAX is deliberately nonspecific. It can be instantiated in a variety of different ways. It can read XML documents stored in a variety of media. It can be configured with features and properties both known and unknown. This chapter explores in detail the configuration and use of XMLReader objects.