RE: XHTML questions

Recall that XHTML is an XML application -- the <?xml ... ?> is a part that
comes from the XML/SGML world. In an XML document, this declaration (it is
not a tag in the HTML sense) is actually optional (see the XML
specification at http://www.w3.org/TR/REC-xml for details -- the formal
rules are in sections 2.1, which define how a document is assembled, and
in section 2.8, which defines the document 'prolog' (see production rule
22) which, in turn, says that the XML declaration is optional.

Thus, if you're serving out XML as type text/html it is quite all right to
leave this part out.  

HOwever, if you want to declare the _character encoding_ used in the
document (which was the question being asked in the previous message), and
if you do so in a way understandable to XML software, then you must do so
within the xml declaration, so it can't be omitted.

Of course, if this is being processed as HTML, you would also want to
define the charset using a meta element of the form

<meta http-equiv="content-type" content="text/html; charset=...." >

as defined in Section 5.2.2. of the HTML 4.01 specification (see
http://www.w3.org/TR/html401/charset.html#doc-char-set)

Ian

On Tue, 27 Jun 2000, Piers Williams wrote:

> Why is this? I thought the whole point was that if you came across a tag you
> didn't understand, you just rendered the contents as if the tag wasn't
> there.
> 
> This happens on both IE 3 and NN 3 and seems to be due to the '?' at the
> beginning, which begs the question why was _that_ character chosen when it
> would break backwards compatability.
> 
> Oh well, I don't suppose there's many v3 browsers left...
> 
> > -----Original Message-----
> > From: Ian Graham [mailto:igraham@smaug.java.utoronto.ca]
> > Sent: 27 June 2000 20:32
> 
> > The XML declaration appears at the start of the document, and has
> > the form:
> > 
> > <?xml version="1.0" encoding="charsetvalue" ?>
> > 
> > However, older HTML browsers (e.g., Navigator 3) don't 
> > understand this,
> > and display this line
> 

Received on Tuesday, 27 June 2000 16:28:17 UTC