The XML standalone declaration should always be last. The encoding declaration Second and the version info First.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> GOOD
<?xml version="1.0" standalone="yes" encoding="UTF-8" ?> BAD
See the XML Prolog and document type declaration format for clarity on this
“In a standalone document declaration, the value “
yes” indicates that there are no markup declarations external to the document entity (either in the DTD external subset, or in an external parameter entity referenced from the internal subset) which affect the information passed from the XML processor to the application. The value “
no” indicates that there are or may be such external markup declarations. Note that the standalone document declaration only denotes the presence of external declarations; the presence, in a document, of references to external entities, when those entities are internally declared, does not change its standalone status.
If there are no external markup declarations, the standalone document declaration has no meaning. If there are external markup declarations but there is no standalone document declaration, the value “
no” is assumed.
Any XML document for which
standalone="no" holds can be converted algorithmically to a standalone document, which may be desirable for some network delivery applications.
Validity Constraint: Standalone Document Declaration
The standalone document declaration must have the value “
no” if any external markup declarations contain declarations of:
- attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or
- entities (other than
quot), if references to those entities appear in the document, or
- attributes with values subject to normalization, where the attribute appears in the document with a value which will change as a result of normalization, or
- element types with element content, if white space occurs directly within any instance of those types.”