FRAMESET and BODY problem?

I've just been messing around with 'A Kinder, Gentler HTML Validator' [1]
just to see what would validate and what wouldn't with the HTML4.0 DTD [2]
and came across what may be a problem, but which may equally well be a
problem with my understanding of SGML, but I thought I'd ask anyway...


The HTML 4.0 specification for frames [3] says:

  An HTML document with frames has a slightly different makeup than an 
  HTML document without frames. A standard document has one HEAD section
  and one BODY. A document with frames has a HEAD, a FRAMESET, and an
  optional BODY. 
  ...
  The BODY section that follows the FRAMESET declaration provides
  alternate content for user agents that do not support frames or are 
  configured not to display frames.

And later, when discussing alternative content:

  User agents that do not support frames must display the BODY section
  that follows the outermost FRAMESET of a document.

From these, plus the bits of example HTML in the same document, I got the
impression that the preferred way of specifying non-frames content is now:

<HTML>
<HEAD>
  <TITLE>Foo</TITLE>
</HEAD>
<FRAMESET ...>
  <FRAME ...>
  <FRAME ...>
</FRAMESET>
<BODY>
...
</BODY>
</HTML>

However when trying a test file [4] with KGV I got the error:

  Error at line 14:
     <BODY>
          document type does not allow element "BODY" here

A revised version of the file [5] did validate, but this used the
following structure:

<HTML>
<HEAD>
  <TITLE>Foo2</TITLE>
</HEAD>
<FRAMESET ...>
  <FRAME ...>
  <FRAME ...>
  <NOFRAMES>
    <BODY>
    ...
    </BODY>
  </NOFRAMES>
</FRAMESET>
</HTML> 

The HTML 4.0 DTD [2] says this about the HTML element:

  <!ENTITY % html.content "HEAD, (FRAMESET|BODY)">

  <!ELEMENT HTML O O (%html.content)>

  <!ATTLIST HTML
    %version;
    %i18n;                           -- lang, dir --
    >

The 'How to read the HTML DTD' section of the spec. [6] says the following
about content model definitions:

  A | B 
    Both A and B are permitted in any order
  A , B 
    A must occur before B.

From which I understand "HEAD, (FRAMESET|BODY)" to mean a mandatory HEAD
element, followed by optional FRAMESET and BODY elements in any order,
(although [3] does go on to say:

  Elements that might normally be placed in the BODY element must not
  appear before the first FRAMESET element or the FRAMESET will be
  ignored.

which I assume to mean that FRAMESET should actually come before BODY).

So, my questions are:

  a) Given the above definition of the HTML element, why does my original
     example [4] not validate ?  Am I missing something ?

  b) Would a content model definition of "HEAD, FRAMESET?, BODY" be 
     better than "HEAD, (FRAMESET|BODY)" ?

  c) Should the content model for the FRAMESET element be changed to
     exclude NOFRAMES element, and the content model for the NOFRAMES
     element changed to exclude BODY ? 

     This would (I think) cause my second example [5] not to validate
     which, if this is no longer the preferred way of doing things, may be
     desirable. 


References: 

[1] http://ugweb.cs.ualberta.ca/~gerald/validate/
[2] http://www.w3.org/TR/WD-html40/HTML4.dtd
[3] http://www.w3.org/TR/WD-html40/present/frames.html
[4] http://www2.eng.cam.ac.uk/~praf1/test/frames.html
[5] http://www2.eng.cam.ac.uk/~praf1/test/frames2.html
[6] http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html


Paul Fidler
-- 
Cambridge University Engineering Department
Trumpington Street, Cambridge, CB2 1PZ, UK

Received on Tuesday, 15 July 1997 13:16:39 UTC