Avraham Shapiro wrote:
> ** Low Priority **
> I have a slightly naive question but I just wanted to double check.
No question is too naive :-) I ask them all the time...
> In an application I use, an error is generated on the xml line:
> <?xml version='1.0' encoding='UTF-8'?>
What is the exact error message you get?
> because it doesn't recognize the UTF-8 encoding.
> This is due to the single quotes.
If it is failing to recognise the quotes then the problem is nothing to
do with the UTF-8 encoding. If it's failing to recognise the quotes then
it will be failing on the '1.0' version, not the 'UTF-8' encoding.
> I checked the XML standard but it wasn't so clear:
The XML Standard should be clear on this: see productions 24 and 80
VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )
> Is it legal to use single
> quotes around the attribute value instead of double quotes?
Yes, absolutely. (Strictly speaking these are not attributes, because
they are within a Processing Instruction, which doesn't have attributes.
And even more strictly speaking, just to confuse things even more, it's
not actually a Processing Instruction anyway, but the XML Declaration.
But for convenience the specification requires it to be treated by rules
very similar to those for attributes <sigh/> formal specs...grr :-)
> While I'm at at it, is it legal to intermix single and double quotes? as in:
> <?xml version="1.0" encoding='UTF-8'?>
Yes, that is also allowed. So long as they match, it's fine: using
encoding='UTF-8" would be an error because they don't match. Here's a
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE foo [
<!ELEMENT foo (#PCDATA)>
Both rxp and onsgmls report this file is valid. When in doubt, it's
always a good idea to construct a minimal example and test it with a
standalone validating parser.
So your file is correct and your software is probably broken.
What are you using, may I ask?