Well, it's mandatory if to be a *valid* document, but then you also
need to have a DTD to be valid, and most XML documents I've seen
don't...
You *don't* need to have a declaration in order to be well-formed,
which is all that most XML documents are, IME.
When in doubt, go to the standard:
http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-well-formed
"A data object is an XML document if it is well-formed, as defined in this
specification. In addition, the XML document is valid if it meets certain
further constraints."
[Definition: A textual object is a well-formed XML document if:]
1. Taken as a whole, it matches the production labeled document.
2. It meets all the well-formedness constraints given in this
specification.
3. Each of the parsed entities which is referenced directly or
indirectly within the document is well-formed.
document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )
prolog ::= XMLDecl Misc* (doctypedecl Misc*)?
XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
So, well-formed => "matches the production labeled document" =>
prolog => XMLDecl => '<?xml'
No '<?xml', not well-formed.
QED.