SGML wierdness #743 [Was: Toward Closure on HTML ]

Daniel W. Connolly (connolly@hal.com)
Thu, 07 Apr 1994 16:48:53 -0500


In message <9404072310.AA5107@notes.notes>, Matt Timmermans/MSL writes:
>
>Given these conditions, if the DTD were to be rewritten to use 'p' elements as
>
>containers instead of divisions, it would be possible to specify BOTH the star
>t
>and end tags as omissible.
>
>When parsing current HTML documents with the new DTD, an SGML parser would
>usually infer the initial <p>, and infer a </p> before each explicit <p>.

Try it. It just doesn't work that way. An SGML parser can only infer
required start tags.

[This should be in a SGML FAQ or some such...]

connolly@ulua {** NONE **}../html-test[4416] cat test.sgml
<!DOCTYPE TEST [
<!ELEMENT TEST O O (HEAD, BODY)>
<!ELEMENT HEAD O O (TITLE)>
<!ELEMENT TITLE - - (#PCDATA)>
<!ELEMENT BODY O O (P | H1)*>
<!ELEMENT H1 - - (#PCDATA)>
<!ELEMENT P O O (#PCDATA)>
]>
<TITLE>testing</TITLE>
<H1>Here we go...</H1>
This causes problems.
<p>This would be fine
<p>And so would this.

connolly@ulua {** NONE **}../html-test[4417] sgmls -s test.sgml
sgmls: SGML error at test.sgml, line 11 at ".":
Out-of-context data ended TEST document element (and parse)

Take out the "problems" line, and it's fine:

connolly@ulua {** NONE **}../html-test[4420] cat test.sgml
<!DOCTYPE TEST [
<!ELEMENT TEST O O (HEAD, BODY)>
<!ELEMENT HEAD O O (TITLE)>
<!ELEMENT TITLE - - (#PCDATA)>
<!ELEMENT BODY O O (P | H1)*>
<!ELEMENT H1 - - (#PCDATA)>
<!ELEMENT P O O (#PCDATA)>
]>
<TITLE>testing</TITLE>
<H1>Here we go...</H1>
<p>This would be fine
<p>And so would this.

connolly@ulua {** NONE **}../html-test[4421] sgmls -s test.sgml
connolly@ulua {** NONE **}../html-test[4422]

Dan