[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: well-formedness error




At 20:53 04/06/17 -0700, Tim Bray wrote:


True, but not perhaps ideal. I have long argued that the safest and best behavior, in the case where you know that you are serving XML, is to provide no charset. The reason being that the chance you have of being wrong is typically much higher than the chance an unassisted XML processor has of getting it wrong.

Especially given that the typical Web server has its content-type and charset driven off the file extension and has no chance of knowing what an XML processor would make of the BOM and encoding declaration and whatnot, it's really usually best to say

Content-type: whatever/whatever+xml

small nit: make sure that whatever != 'text'


and stop there. -Tim

This is quite okay for the case where you serve your content by putting files in a web server's file system. However, this is not the only way to serve web content. With content served from various kinds of scripting technology and databases, it is most often much easier, and architecturally cleaner and simpler, to put the 'charset' information into the HTTP Content-Type header. And the chances in this case that the scripting technology or database gets it right is quite a bit higher than the chance that the document-internal 'encoding' or 'meta' or whatever is correct.

Regards, Martin.