On Tue, 7 Jul 2026 17:17:04 GMT, Andy Goryachev <[email protected]> wrote:

> I think the first line in xml identifies the format and the encoding, the 
> header should follow after that.

This is correct. The most recent [XML 
specification](https://www.w3.org/TR/xml/) says:

document ::= prolog element Misc*
prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
Misc ::= Comment | PI | S


This means that the prolog of an XML document _may_ start with an `<?xml ... 
?>` declaration (actually, the spec says it _should_, but it's optional). If it 
does, it must be the very first thing in the document; comments are only 
allowed after it.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2167#discussion_r3538508848

Reply via email to